6 * Copyright (c) 1996-1999 Whistle Communications, Inc.
9 * Subject to the following obligations and disclaimer of warranty, use and
10 * redistribution of this software, in source or object code forms, with or
11 * without modifications are expressly permitted by Whistle Communications;
12 * provided, however, that:
13 * 1. Any and all reproductions of the source or object code must include the
14 * copyright notice above and the following disclaimer of warranties; and
15 * 2. No rights are granted, in any manner or form, to use Whistle
16 * Communications, Inc. trademarks, including the mark "WHISTLE
17 * COMMUNICATIONS" on advertising, endorsements, or otherwise except as
18 * such appears in the above copyright notice or in the software.
20 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
21 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
22 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
23 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
25 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
26 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
27 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
28 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
29 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
30 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
31 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
32 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
38 * Author: Julian Elischer <julian@freebsd.org>
41 * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $
44 #ifndef _NETGRAPH_NG_PPPOE_H_
45 #define _NETGRAPH_NG_PPPOE_H_
47 /********************************************************************
48 * Netgraph hook constants etc.
49 ********************************************************************/
50 /* Node type name. This should be unique among all netgraph node types */
51 #define NG_PPPOE_NODE_TYPE "pppoe"
53 #define NGM_PPPOE_COOKIE 1089893072
54 #define NGM_PPPOE_SETMAXP_COOKIE 1441624322
56 #define PPPOE_SERVICE_NAME_SIZE 64 /* for now */
59 #define NG_PPPOE_HOOK_ETHERNET "ethernet"
60 #define NG_PPPOE_HOOK_DEBUG "debug"
63 #define NG_PPPOE_STANDARD "standard"
64 #define NG_PPPOE_3COM "3Com"
65 #define NG_PPPOE_NONSTANDARD NG_PPPOE_3COM
66 #define NG_PPPOE_DLINK "D-Link"
68 /**********************************************************************
69 * Netgraph commands understood by this node type.
70 * FAIL, SUCCESS, CLOSE and ACNAME are sent by the node rather than received.
71 ********************************************************************/
73 NGM_PPPOE_SET_FLAG = 1,
74 NGM_PPPOE_CONNECT = 2, /* Client, Try find this service */
75 NGM_PPPOE_LISTEN = 3, /* Server, Await a request for this service */
76 NGM_PPPOE_OFFER = 4, /* Server, hook X should respond (*) */
77 NGM_PPPOE_SUCCESS = 5, /* State machine connected */
78 NGM_PPPOE_FAIL = 6, /* State machine could not connect */
79 NGM_PPPOE_CLOSE = 7, /* Session closed down */
80 NGM_PPPOE_SERVICE = 8, /* additional Service to advertise (in PADO) */
81 NGM_PPPOE_ACNAME = 9, /* AC_NAME for informational purposes */
82 NGM_PPPOE_GET_STATUS = 10, /* data in/out */
83 NGM_PPPOE_SESSIONID = 11, /* Session_ID for informational purposes */
84 NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */
85 NGM_PPPOE_GETMODE = 13, /* see current mode */
86 NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */
87 NGM_PPPOE_SETMAXP = 15 /* Set PPP-Max-Payload value */
90 /***********************
91 * Structures passed in the various netgraph command messages.
92 ***********************/
93 /* This structure is returned by the NGM_PPPOE_GET_STATUS command */
95 u_int packets_in; /* packets in from ethernet */
96 u_int packets_out; /* packets out towards ethernet */
99 /* Keep this in sync with the above structure definition */
100 #define NG_PPPOESTAT_TYPE_INFO { \
101 { "packets_in", &ng_parse_uint_type }, \
102 { "packets_out", &ng_parse_uint_type }, \
107 * When this structure is accepted by the NGM_PPPOE_CONNECT command :
108 * The data field is MANDATORY.
109 * The session sends out a PADI request for the named service.
112 * When this structure is accepted by the NGM_PPPOE_LISTEN command.
113 * If no service is given this is assumed to accept ALL PADI requests.
114 * This may at some time take a regexp expression, but not yet.
115 * Matching PADI requests will be passed up the named hook.
118 * When this structure is accepted by the NGM_PPPOE_OFFER command:
119 * The AC-NAme field is set from that given and a PADI
120 * packet is expected to arrive from the session control daemon, on the
121 * named hook. The session will then issue the appropriate PADO
122 * and begin negotiation.
124 struct ngpppoe_init_data {
125 char hook[NG_HOOKSIZ]; /* hook to monitor on */
126 u_int16_t data_len; /* Length of the service name */
127 char data[]; /* init data goes here */
130 /* Keep this in sync with the above structure definition */
131 #define NG_PPPOE_INIT_DATA_TYPE_INFO { \
132 { "hook", &ng_parse_hookbuf_type }, \
133 { "data", &ng_parse_sizedstring_type }, \
138 * This structure is used by the asychronous success and failure messages.
139 * (to report which hook has failed or connected). The message is sent
140 * to whoever requested the connection. (close may use this too).
143 char hook[NG_HOOKSIZ]; /* hook associated with event session */
146 /* Keep this in sync with the above structure definition */
147 #define NG_PPPOE_STS_TYPE_INFO { \
148 { "hook", &ng_parse_hookbuf_type }, \
153 * This structure is used to send PPP-Max-Payload value from server to client.
155 struct ngpppoe_maxp {
156 char hook[NG_HOOKSIZ]; /* hook associated with event session */
160 /********************************************************************
161 * Constants and definitions specific to pppoe
162 ********************************************************************/
164 #define PPPOE_TIMEOUT_LIMIT 64
165 #define PPPOE_OFFER_TIMEOUT 16
166 #define PPPOE_INITIAL_TIMEOUT 2
168 /* Codes to identify message types */
169 #define PADI_CODE 0x09
170 #define PADO_CODE 0x07
171 #define PADR_CODE 0x19
172 #define PADS_CODE 0x65
173 #define PADT_CODE 0xa7
175 /* Tag identifiers */
176 #if BYTE_ORDER == BIG_ENDIAN
177 #define PTT_EOL (0x0000)
178 #define PTT_SRV_NAME (0x0101)
179 #define PTT_AC_NAME (0x0102)
180 #define PTT_HOST_UNIQ (0x0103)
181 #define PTT_AC_COOKIE (0x0104)
182 #define PTT_VENDOR (0x0105)
183 #define PTT_RELAY_SID (0x0110)
184 #define PTT_MAX_PAYL (0x0120) /* PPP-Max-Payload (RFC4638) */
185 #define PTT_SRV_ERR (0x0201)
186 #define PTT_SYS_ERR (0x0202)
187 #define PTT_GEN_ERR (0x0203)
189 #define ETHERTYPE_PPPOE_DISC 0x8863 /* pppoe discovery packets */
190 #define ETHERTYPE_PPPOE_SESS 0x8864 /* pppoe session packets */
191 #define ETHERTYPE_PPPOE_3COM_DISC 0x3c12 /* pppoe discovery packets 3com? */
192 #define ETHERTYPE_PPPOE_3COM_SESS 0x3c13 /* pppoe session packets 3com? */
194 #define PTT_EOL (0x0000)
195 #define PTT_SRV_NAME (0x0101)
196 #define PTT_AC_NAME (0x0201)
197 #define PTT_HOST_UNIQ (0x0301)
198 #define PTT_AC_COOKIE (0x0401)
199 #define PTT_VENDOR (0x0501)
200 #define PTT_RELAY_SID (0x1001)
201 #define PTT_MAX_PAYL (0x2001) /* PPP-Max-Payload (RFC4638) */
202 #define PTT_SRV_ERR (0x0102)
203 #define PTT_SYS_ERR (0x0202)
204 #define PTT_GEN_ERR (0x0302)
206 #define ETHERTYPE_PPPOE_DISC 0x6388 /* pppoe discovery packets */
207 #define ETHERTYPE_PPPOE_SESS 0x6488 /* pppoe session packets */
208 #define ETHERTYPE_PPPOE_3COM_DISC 0x123c /* pppoe discovery packets 3com? */
209 #define ETHERTYPE_PPPOE_3COM_SESS 0x133c /* pppoe session packets 3com? */
226 struct pppoe_full_hdr {
227 struct ether_header eh;
232 struct pppoe_full_hdr pkt_header;
233 u_int8_t bytes[2048];
237 struct pppoe_tag hdr;
238 u_int8_t data[PPPOE_SERVICE_NAME_SIZE];
242 struct pppoe_tag hdr;
247 * Define the order in which we will place tags in packets
248 * this may be ignored
254 #define TAGO_ACNAME 0
256 #define TAGO_COOKIE 2
261 #define TAGR_COOKIE 2
263 #define TAGS_ACNAME 0
265 #define TAGS_COOKIE 2
269 #endif /* _NETGRAPH_NG_PPPOE_H_ */