patched lwip with https://github.com/mbedmicro/mbed/commit/8222bde1af2e328e4c58d0f438827f3091e5e0eb

Fork of lwip by mbed official

Committer:
mbed_official
Date:
Fri Jun 22 09:25:39 2012 +0000
Revision:
0:51ac1d130fd4
Initial import from lwip-1.4.0: http://download.savannah.gnu.org/releases/lwip/lwip-1.4.0.zip

Who changed what in which revision?

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