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