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