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