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