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