Web server based weather station using Sparkfun Weather Meters.

Dependencies:   FatFileSystem mbed WeatherMeters SDFileSystem

Committer:
AdamGreen
Date:
Sat Feb 25 03:28:05 2012 +0000
Revision:
1:c7958aa34fa1
Parent:
0:616601bde9fb
Use published libraries where possible.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AdamGreen 0:616601bde9fb 1 /*****************************************************************************
AdamGreen 0:616601bde9fb 2 * ppp_oe.h - PPP Over Ethernet implementation for lwIP.
AdamGreen 0:616601bde9fb 3 *
AdamGreen 0:616601bde9fb 4 * Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
AdamGreen 0:616601bde9fb 5 *
AdamGreen 0:616601bde9fb 6 * The authors hereby grant permission to use, copy, modify, distribute,
AdamGreen 0:616601bde9fb 7 * and license this software and its documentation for any purpose, provided
AdamGreen 0:616601bde9fb 8 * that existing copyright notices are retained in all copies and that this
AdamGreen 0:616601bde9fb 9 * notice and the following disclaimer are included verbatim in any
AdamGreen 0:616601bde9fb 10 * distributions. No written agreement, license, or royalty fee is required
AdamGreen 0:616601bde9fb 11 * for any of the authorized uses.
AdamGreen 0:616601bde9fb 12 *
AdamGreen 0:616601bde9fb 13 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
AdamGreen 0:616601bde9fb 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
AdamGreen 0:616601bde9fb 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
AdamGreen 0:616601bde9fb 16 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
AdamGreen 0:616601bde9fb 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
AdamGreen 0:616601bde9fb 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
AdamGreen 0:616601bde9fb 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
AdamGreen 0:616601bde9fb 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AdamGreen 0:616601bde9fb 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
AdamGreen 0:616601bde9fb 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AdamGreen 0:616601bde9fb 23 *
AdamGreen 0:616601bde9fb 24 ******************************************************************************
AdamGreen 0:616601bde9fb 25 * REVISION HISTORY
AdamGreen 0:616601bde9fb 26 *
AdamGreen 0:616601bde9fb 27 * 06-01-01 Marc Boucher <marc@mbsi.ca>
AdamGreen 0:616601bde9fb 28 * Ported to lwIP.
AdamGreen 0:616601bde9fb 29 *****************************************************************************/
AdamGreen 0:616601bde9fb 30
AdamGreen 0:616601bde9fb 31
AdamGreen 0:616601bde9fb 32
AdamGreen 0:616601bde9fb 33 /* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */
AdamGreen 0:616601bde9fb 34
AdamGreen 0:616601bde9fb 35 /*-
AdamGreen 0:616601bde9fb 36 * Copyright (c) 2002 The NetBSD Foundation, Inc.
AdamGreen 0:616601bde9fb 37 * All rights reserved.
AdamGreen 0:616601bde9fb 38 *
AdamGreen 0:616601bde9fb 39 * This code is derived from software contributed to The NetBSD Foundation
AdamGreen 0:616601bde9fb 40 * by Martin Husemann <martin@NetBSD.org>.
AdamGreen 0:616601bde9fb 41 *
AdamGreen 0:616601bde9fb 42 * Redistribution and use in source and binary forms, with or without
AdamGreen 0:616601bde9fb 43 * modification, are permitted provided that the following conditions
AdamGreen 0:616601bde9fb 44 * are met:
AdamGreen 0:616601bde9fb 45 * 1. Redistributions of source code must retain the above copyright
AdamGreen 0:616601bde9fb 46 * notice, this list of conditions and the following disclaimer.
AdamGreen 0:616601bde9fb 47 * 2. Redistributions in binary form must reproduce the above copyright
AdamGreen 0:616601bde9fb 48 * notice, this list of conditions and the following disclaimer in the
AdamGreen 0:616601bde9fb 49 * documentation and/or other materials provided with the distribution.
AdamGreen 0:616601bde9fb 50 * 3. All advertising materials mentioning features or use of this software
AdamGreen 0:616601bde9fb 51 * must display the following acknowledgement:
AdamGreen 0:616601bde9fb 52 * This product includes software developed by the NetBSD
AdamGreen 0:616601bde9fb 53 * Foundation, Inc. and its contributors.
AdamGreen 0:616601bde9fb 54 * 4. Neither the name of The NetBSD Foundation nor the names of its
AdamGreen 0:616601bde9fb 55 * contributors may be used to endorse or promote products derived
AdamGreen 0:616601bde9fb 56 * from this software without specific prior written permission.
AdamGreen 0:616601bde9fb 57 *
AdamGreen 0:616601bde9fb 58 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
AdamGreen 0:616601bde9fb 59 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
AdamGreen 0:616601bde9fb 60 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
AdamGreen 0:616601bde9fb 61 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
AdamGreen 0:616601bde9fb 62 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
AdamGreen 0:616601bde9fb 63 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
AdamGreen 0:616601bde9fb 64 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
AdamGreen 0:616601bde9fb 65 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
AdamGreen 0:616601bde9fb 66 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
AdamGreen 0:616601bde9fb 67 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
AdamGreen 0:616601bde9fb 68 * POSSIBILITY OF SUCH DAMAGE.
AdamGreen 0:616601bde9fb 69 */
AdamGreen 0:616601bde9fb 70 #ifndef PPP_OE_H
AdamGreen 0:616601bde9fb 71 #define PPP_OE_H
AdamGreen 0:616601bde9fb 72
AdamGreen 0:616601bde9fb 73 #include "lwip/opt.h"
AdamGreen 0:616601bde9fb 74
AdamGreen 0:616601bde9fb 75 #if PPPOE_SUPPORT > 0
AdamGreen 0:616601bde9fb 76
AdamGreen 0:616601bde9fb 77 #include "netif/etharp.h"
AdamGreen 0:616601bde9fb 78
AdamGreen 0:616601bde9fb 79 #ifdef PACK_STRUCT_USE_INCLUDES
AdamGreen 0:616601bde9fb 80 # include "arch/bpstruct.h"
AdamGreen 0:616601bde9fb 81 #endif
AdamGreen 0:616601bde9fb 82 PACK_STRUCT_BEGIN
AdamGreen 0:616601bde9fb 83 struct pppoehdr {
AdamGreen 0:616601bde9fb 84 PACK_STRUCT_FIELD(u8_t vertype);
AdamGreen 0:616601bde9fb 85 PACK_STRUCT_FIELD(u8_t code);
AdamGreen 0:616601bde9fb 86 PACK_STRUCT_FIELD(u16_t session);
AdamGreen 0:616601bde9fb 87 PACK_STRUCT_FIELD(u16_t plen);
AdamGreen 0:616601bde9fb 88 } PACK_STRUCT_STRUCT;
AdamGreen 0:616601bde9fb 89 PACK_STRUCT_END
AdamGreen 0:616601bde9fb 90 #ifdef PACK_STRUCT_USE_INCLUDES
AdamGreen 0:616601bde9fb 91 # include "arch/epstruct.h"
AdamGreen 0:616601bde9fb 92 #endif
AdamGreen 0:616601bde9fb 93
AdamGreen 0:616601bde9fb 94 #ifdef PACK_STRUCT_USE_INCLUDES
AdamGreen 0:616601bde9fb 95 # include "arch/bpstruct.h"
AdamGreen 0:616601bde9fb 96 #endif
AdamGreen 0:616601bde9fb 97 PACK_STRUCT_BEGIN
AdamGreen 0:616601bde9fb 98 struct pppoetag {
AdamGreen 0:616601bde9fb 99 PACK_STRUCT_FIELD(u16_t tag);
AdamGreen 0:616601bde9fb 100 PACK_STRUCT_FIELD(u16_t len);
AdamGreen 0:616601bde9fb 101 } PACK_STRUCT_STRUCT;
AdamGreen 0:616601bde9fb 102 PACK_STRUCT_END
AdamGreen 0:616601bde9fb 103 #ifdef PACK_STRUCT_USE_INCLUDES
AdamGreen 0:616601bde9fb 104 # include "arch/epstruct.h"
AdamGreen 0:616601bde9fb 105 #endif
AdamGreen 0:616601bde9fb 106
AdamGreen 0:616601bde9fb 107
AdamGreen 0:616601bde9fb 108 #define PPPOE_STATE_INITIAL 0
AdamGreen 0:616601bde9fb 109 #define PPPOE_STATE_PADI_SENT 1
AdamGreen 0:616601bde9fb 110 #define PPPOE_STATE_PADR_SENT 2
AdamGreen 0:616601bde9fb 111 #define PPPOE_STATE_SESSION 3
AdamGreen 0:616601bde9fb 112 #define PPPOE_STATE_CLOSING 4
AdamGreen 0:616601bde9fb 113 /* passive */
AdamGreen 0:616601bde9fb 114 #define PPPOE_STATE_PADO_SENT 1
AdamGreen 0:616601bde9fb 115
AdamGreen 0:616601bde9fb 116 #define PPPOE_HEADERLEN sizeof(struct pppoehdr)
AdamGreen 0:616601bde9fb 117 #define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */
AdamGreen 0:616601bde9fb 118
AdamGreen 0:616601bde9fb 119 #define PPPOE_TAG_EOL 0x0000 /* end of list */
AdamGreen 0:616601bde9fb 120 #define PPPOE_TAG_SNAME 0x0101 /* service name */
AdamGreen 0:616601bde9fb 121 #define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */
AdamGreen 0:616601bde9fb 122 #define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */
AdamGreen 0:616601bde9fb 123 #define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */
AdamGreen 0:616601bde9fb 124 #define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */
AdamGreen 0:616601bde9fb 125 #define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */
AdamGreen 0:616601bde9fb 126 #define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */
AdamGreen 0:616601bde9fb 127 #define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */
AdamGreen 0:616601bde9fb 128 #define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */
AdamGreen 0:616601bde9fb 129
AdamGreen 0:616601bde9fb 130 #define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */
AdamGreen 0:616601bde9fb 131 #define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */
AdamGreen 0:616601bde9fb 132 #define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */
AdamGreen 0:616601bde9fb 133 #define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */
AdamGreen 0:616601bde9fb 134 #define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */
AdamGreen 0:616601bde9fb 135
AdamGreen 0:616601bde9fb 136 #ifndef ETHERMTU
AdamGreen 0:616601bde9fb 137 #define ETHERMTU 1500
AdamGreen 0:616601bde9fb 138 #endif
AdamGreen 0:616601bde9fb 139
AdamGreen 0:616601bde9fb 140 /* two byte PPP protocol discriminator, then IP data */
AdamGreen 0:616601bde9fb 141 #define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2)
AdamGreen 0:616601bde9fb 142
AdamGreen 0:616601bde9fb 143 #ifndef PPPOE_MAX_AC_COOKIE_LEN
AdamGreen 0:616601bde9fb 144 #define PPPOE_MAX_AC_COOKIE_LEN 64
AdamGreen 0:616601bde9fb 145 #endif
AdamGreen 0:616601bde9fb 146
AdamGreen 0:616601bde9fb 147 struct pppoe_softc {
AdamGreen 0:616601bde9fb 148 struct pppoe_softc *next;
AdamGreen 0:616601bde9fb 149 struct netif *sc_ethif; /* ethernet interface we are using */
AdamGreen 0:616601bde9fb 150 int sc_pd; /* ppp unit number */
AdamGreen 0:616601bde9fb 151 void (*sc_linkStatusCB)(int pd, int up);
AdamGreen 0:616601bde9fb 152
AdamGreen 0:616601bde9fb 153 int sc_state; /* discovery phase or session connected */
AdamGreen 0:616601bde9fb 154 struct eth_addr sc_dest; /* hardware address of concentrator */
AdamGreen 0:616601bde9fb 155 u16_t sc_session; /* PPPoE session id */
AdamGreen 0:616601bde9fb 156
AdamGreen 0:616601bde9fb 157 #ifdef PPPOE_TODO
AdamGreen 0:616601bde9fb 158 char *sc_service_name; /* if != NULL: requested name of service */
AdamGreen 0:616601bde9fb 159 char *sc_concentrator_name; /* if != NULL: requested concentrator id */
AdamGreen 0:616601bde9fb 160 #endif /* PPPOE_TODO */
AdamGreen 0:616601bde9fb 161 u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
AdamGreen 0:616601bde9fb 162 size_t sc_ac_cookie_len; /* length of cookie data */
AdamGreen 0:616601bde9fb 163 #ifdef PPPOE_SERVER
AdamGreen 0:616601bde9fb 164 u8_t *sc_hunique; /* content of host unique we must echo back */
AdamGreen 0:616601bde9fb 165 size_t sc_hunique_len; /* length of host unique */
AdamGreen 0:616601bde9fb 166 #endif
AdamGreen 0:616601bde9fb 167 int sc_padi_retried; /* number of PADI retries already done */
AdamGreen 0:616601bde9fb 168 int sc_padr_retried; /* number of PADR retries already done */
AdamGreen 0:616601bde9fb 169 };
AdamGreen 0:616601bde9fb 170
AdamGreen 0:616601bde9fb 171
AdamGreen 0:616601bde9fb 172 #define pppoe_init() /* compatibility define, no initialization needed */
AdamGreen 0:616601bde9fb 173
AdamGreen 0:616601bde9fb 174 err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
AdamGreen 0:616601bde9fb 175 err_t pppoe_destroy(struct netif *ifp);
AdamGreen 0:616601bde9fb 176
AdamGreen 0:616601bde9fb 177 int pppoe_connect(struct pppoe_softc *sc);
AdamGreen 0:616601bde9fb 178 void pppoe_disconnect(struct pppoe_softc *sc);
AdamGreen 0:616601bde9fb 179
AdamGreen 0:616601bde9fb 180 void pppoe_disc_input(struct netif *netif, struct pbuf *p);
AdamGreen 0:616601bde9fb 181 void pppoe_data_input(struct netif *netif, struct pbuf *p);
AdamGreen 0:616601bde9fb 182
AdamGreen 0:616601bde9fb 183 err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb);
AdamGreen 0:616601bde9fb 184
AdamGreen 0:616601bde9fb 185 /** used in ppp.c */
AdamGreen 0:616601bde9fb 186 #define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN)
AdamGreen 0:616601bde9fb 187
AdamGreen 0:616601bde9fb 188 #endif /* PPPOE_SUPPORT */
AdamGreen 0:616601bde9fb 189
AdamGreen 0:616601bde9fb 190 #endif /* PPP_OE_H */