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