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