Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
pppoe.h
00001 /***************************************************************************** 00002 * /@code 00003 * 00004 * pppoe.h - PPP Over Ethernet implementation for lwIP. 00005 * 00006 * Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. 00007 * 00008 * The authors hereby grant permission to use, copy, modify, distribute, 00009 * and license this software and its documentation for any purpose, provided 00010 * that existing copyright notices are retained in all copies and that this 00011 * notice and the following disclaimer are included verbatim in any 00012 * distributions. No written agreement, license, or royalty fee is required 00013 * for any of the authorized uses. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 00016 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00017 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00019 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00020 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00021 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00022 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00024 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 * 00026 ****************************************************************************** 00027 * REVISION HISTORY 00028 * 00029 * 06-01-01 Marc Boucher <marc@mbsi.ca> 00030 * Ported to lwIP. 00031 * 00032 * /@endcode 00033 *****************************************************************************/ 00034 00035 00036 00037 /* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ 00038 00039 /*- 00040 * Copyright (c) 2002 The NetBSD Foundation, Inc. 00041 * All rights reserved. 00042 * 00043 * This code is derived from software contributed to The NetBSD Foundation 00044 * by Martin Husemann <martin@NetBSD.org>. 00045 * 00046 * Redistribution and use in source and binary forms, with or without 00047 * modification, are permitted provided that the following conditions 00048 * are met: 00049 * 1. Redistributions of source code must retain the above copyright 00050 * notice, this list of conditions and the following disclaimer. 00051 * 2. Redistributions in binary form must reproduce the above copyright 00052 * notice, this list of conditions and the following disclaimer in the 00053 * documentation and/or other materials provided with the distribution. 00054 * 3. All advertising materials mentioning features or use of this software 00055 * must display the following acknowledgement: 00056 * This product includes software developed by the NetBSD 00057 * Foundation, Inc. and its contributors. 00058 * 4. Neither the name of The NetBSD Foundation nor the names of its 00059 * contributors may be used to endorse or promote products derived 00060 * from this software without specific prior written permission. 00061 * 00062 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 00063 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00064 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00065 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 00066 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00067 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00068 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00069 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00070 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00071 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00072 * POSSIBILITY OF SUCH DAMAGE. 00073 */ 00074 #include "ppp_opts.h" 00075 #if PPP_SUPPORT && PPPOE_SUPPORT /* don't build if not configured for use in ppp_opts.h */ 00076 00077 #ifndef PPP_OE_H 00078 #define PPP_OE_H 00079 00080 #include "ppp.h" 00081 00082 #ifdef __cplusplus 00083 extern "C" { 00084 #endif 00085 00086 #ifdef PACK_STRUCT_USE_INCLUDES 00087 # include "arch/bpstruct.h" 00088 #endif 00089 PACK_STRUCT_BEGIN 00090 struct pppoehdr { 00091 PACK_STRUCT_FLD_8(u8_t vertype); 00092 PACK_STRUCT_FLD_8(u8_t code); 00093 PACK_STRUCT_FIELD(u16_t session); 00094 PACK_STRUCT_FIELD(u16_t plen); 00095 } PACK_STRUCT_STRUCT; 00096 PACK_STRUCT_END 00097 #ifdef PACK_STRUCT_USE_INCLUDES 00098 # include "arch/epstruct.h" 00099 #endif 00100 00101 #ifdef PACK_STRUCT_USE_INCLUDES 00102 # include "arch/bpstruct.h" 00103 #endif 00104 PACK_STRUCT_BEGIN 00105 struct pppoetag { 00106 PACK_STRUCT_FIELD(u16_t tag); 00107 PACK_STRUCT_FIELD(u16_t len); 00108 } PACK_STRUCT_STRUCT; 00109 PACK_STRUCT_END 00110 #ifdef PACK_STRUCT_USE_INCLUDES 00111 # include "arch/epstruct.h" 00112 #endif 00113 00114 00115 #define PPPOE_STATE_INITIAL 0 00116 #define PPPOE_STATE_PADI_SENT 1 00117 #define PPPOE_STATE_PADR_SENT 2 00118 #define PPPOE_STATE_SESSION 3 00119 /* passive */ 00120 #define PPPOE_STATE_PADO_SENT 1 00121 00122 #define PPPOE_HEADERLEN sizeof(struct pppoehdr) 00123 #define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ 00124 00125 #define PPPOE_TAG_EOL 0x0000 /* end of list */ 00126 #define PPPOE_TAG_SNAME 0x0101 /* service name */ 00127 #define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ 00128 #define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ 00129 #define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ 00130 #define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ 00131 #define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ 00132 #define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ 00133 #define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ 00134 #define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ 00135 00136 #define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ 00137 #define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ 00138 #define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ 00139 #define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ 00140 #define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ 00141 00142 #ifndef PPPOE_MAX_AC_COOKIE_LEN 00143 #define PPPOE_MAX_AC_COOKIE_LEN 64 00144 #endif 00145 00146 struct pppoe_softc { 00147 struct pppoe_softc *next; 00148 struct netif *sc_ethif; /* ethernet interface we are using */ 00149 ppp_pcb *pcb; /* PPP PCB */ 00150 00151 struct eth_addr sc_dest; /* hardware address of concentrator */ 00152 u16_t sc_session; /* PPPoE session id */ 00153 u8_t sc_state; /* discovery phase or session connected */ 00154 00155 #ifdef PPPOE_TODO 00156 u8_t *sc_service_name; /* if != NULL: requested name of service */ 00157 u8_t *sc_concentrator_name; /* if != NULL: requested concentrator id */ 00158 #endif /* PPPOE_TODO */ 00159 u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */ 00160 u8_t sc_ac_cookie_len; /* length of cookie data */ 00161 #ifdef PPPOE_SERVER 00162 u8_t *sc_hunique; /* content of host unique we must echo back */ 00163 u8_t sc_hunique_len; /* length of host unique */ 00164 #endif 00165 u8_t sc_padi_retried; /* number of PADI retries already done */ 00166 u8_t sc_padr_retried; /* number of PADR retries already done */ 00167 }; 00168 00169 00170 #define pppoe_init() /* compatibility define, no initialization needed */ 00171 00172 ppp_pcb *pppoe_create(struct netif *pppif, 00173 struct netif *ethif, 00174 const char *service_name, const char *concentrator_name, 00175 ppp_link_status_cb_fn link_status_cb, void *ctx_cb); 00176 00177 /* 00178 * Functions called from stack 00179 * DO NOT CALL FROM stack USER APPLICATION. 00180 */ 00181 void pppoe_disc_input(struct netif *netif, struct pbuf *p); 00182 void pppoe_data_input(struct netif *netif, struct pbuf *p); 00183 00184 #ifdef __cplusplus 00185 } 00186 #endif 00187 00188 #endif /* PPP_OE_H */ 00189 00190 #endif /* PPP_SUPPORT && PPPOE_SUPPORT */
Generated on Tue Jul 12 2022 13:54:42 by
