Dependencies:   FatFileSystem mbed WeatherMeters SDFileSystem

Committer:
dcoban
Date:
Tue Apr 03 18:43:13 2012 +0000
Revision:
0:1a61c61d0845

        

Who changed what in which revision?

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