]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netgraph/ng_pppoe.h
acpica: Create merge commit against vendor branch
[FreeBSD/FreeBSD.git] / sys / netgraph / ng_pppoe.h
1 /*
2  * ng_pppoe.h
3  */
4
5 /*-
6  * Copyright (c) 1996-1999 Whistle Communications, Inc.
7  * All rights reserved.
8  * 
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.
19  * 
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
36  * OF SUCH DAMAGE.
37  *
38  * Author: Julian Elischer <julian@freebsd.org>
39  * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $
40  */
41
42 #ifndef _NETGRAPH_NG_PPPOE_H_
43 #define _NETGRAPH_NG_PPPOE_H_
44
45 /********************************************************************
46  * Netgraph hook constants etc.
47  ********************************************************************/
48 /* Node type name. This should be unique among all netgraph node types */
49 #define NG_PPPOE_NODE_TYPE      "pppoe"
50
51 #define NGM_PPPOE_COOKIE                1089893072
52 #define NGM_PPPOE_SETMAXP_COOKIE        1441624322
53 #define NGM_PPPOE_PADM_COOKIE           1488405822
54
55 #define PPPOE_SERVICE_NAME_SIZE         64 /* for now */
56 #define PPPOE_PADM_VALUE_SIZE           128 /* for now */
57
58 /* Hook names */
59 #define NG_PPPOE_HOOK_ETHERNET  "ethernet"
60 #define NG_PPPOE_HOOK_DEBUG     "debug"
61
62 /* Mode names */
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"
67
68 /**********************************************************************
69  * Netgraph commands understood by this node type.
70  * FAIL, SUCCESS, CLOSE and ACNAME are sent by the node rather than received.
71  ********************************************************************/
72 enum cmd {
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 */
88         NGM_PPPOE_SEND_HURL = 16, /* Send PADM HURL message */
89         NGM_PPPOE_HURL      = 17, /* HURL for informational purposes */
90         NGM_PPPOE_SEND_MOTM = 18, /* Send PADM MOTM message */
91         NGM_PPPOE_MOTM      = 19  /* MOTM for informational purposes */
92 };
93
94 /***********************
95  * Structures passed in the various netgraph command messages.
96  ***********************/
97 /* This structure is returned by the NGM_PPPOE_GET_STATUS command */
98 struct ngpppoestat {
99         u_int   packets_in;     /* packets in from ethernet */
100         u_int   packets_out;    /* packets out towards ethernet */
101 };
102
103 /* Keep this in sync with the above structure definition */
104 #define NG_PPPOESTAT_TYPE_INFO  {                               \
105           { "packets_in",       &ng_parse_uint_type     },      \
106           { "packets_out",      &ng_parse_uint_type     },      \
107           { NULL }                                              \
108 }
109
110 /*
111  * When this structure is accepted by the NGM_PPPOE_CONNECT command :
112  * The data field is MANDATORY.
113  * The session sends out a PADI request for the named service.
114  *
115  *
116  * When this structure is accepted by the NGM_PPPOE_LISTEN command.
117  * If no service is given this is assumed to accept ALL PADI requests.
118  * This may at some time take a regexp expression, but not yet.
119  * Matching PADI requests will be passed up the named hook.
120  *
121  *
122  * When this structure is accepted by the NGM_PPPOE_OFFER command:
123  * The AC-NAme field is set from that given and a PADI
124  * packet is expected to arrive from the session control daemon, on the
125  * named hook. The session will then issue the appropriate PADO
126  * and begin negotiation.
127  */
128 struct ngpppoe_init_data {
129         char            hook[NG_HOOKSIZ];       /* hook to monitor on */
130         u_int16_t       data_len;               /* Length of the service name */
131         char            data[];                 /* init data goes here */
132 };
133
134 /* Keep this in sync with the above structure definition */
135 #define NG_PPPOE_INIT_DATA_TYPE_INFO    {               \
136           { "hook",     &ng_parse_hookbuf_type  },      \
137           { "data",     &ng_parse_sizedstring_type },   \
138           { NULL }                                      \
139 }
140
141 /*
142  * This structure is used by the asynchronous success and failure messages.
143  * (to report which hook has failed or connected). The message is sent
144  * to whoever requested the connection. (close may use this too).
145  */
146 struct ngpppoe_sts {
147         char    hook[NG_HOOKSIZ];       /* hook associated with event session */
148 };
149
150 /* Keep this in sync with the above structure definition */
151 #define NG_PPPOE_STS_TYPE_INFO          {               \
152           { "hook",     &ng_parse_hookbuf_type  },      \
153           { NULL }                                      \
154 }
155
156 /*
157  * This structure is used to send PPP-Max-Payload value from server to client.
158  */
159 struct ngpppoe_maxp {
160         char    hook[NG_HOOKSIZ];       /* hook associated with event session */
161         uint16_t        data;
162 };
163
164 /*
165  * This structure is used to send PADM messages from server to client.
166  */
167 struct ngpppoe_padm {
168         char    msg[PPPOE_PADM_VALUE_SIZE];
169 };
170
171 /********************************************************************
172  * Constants and definitions specific to pppoe
173  ********************************************************************/
174
175 #define PPPOE_TIMEOUT_LIMIT 64
176 #define PPPOE_OFFER_TIMEOUT 16
177 #define PPPOE_INITIAL_TIMEOUT 2
178
179 /* Codes to identify message types */
180 #define PADI_CODE       0x09
181 #define PADO_CODE       0x07
182 #define PADR_CODE       0x19
183 #define PADS_CODE       0x65
184 #define PADT_CODE       0xa7
185 #define PADM_CODE       0xd3
186
187 /* Tag identifiers */
188 #if BYTE_ORDER == BIG_ENDIAN
189 #define PTT_EOL         (0x0000)
190 #define PTT_SRV_NAME    (0x0101)
191 #define PTT_AC_NAME     (0x0102)
192 #define PTT_HOST_UNIQ   (0x0103)
193 #define PTT_AC_COOKIE   (0x0104)
194 #define PTT_VENDOR      (0x0105)
195 #define PTT_RELAY_SID   (0x0110)
196 #define PTT_HURL        (0x0111)        /* PPPoE Extensions (CARREL) */
197 #define PTT_MOTM        (0x0112)        /* PPPoE Extensions (CARREL) */
198 #define PTT_MAX_PAYL    (0x0120)        /* PPP-Max-Payload (RFC4638) */
199 #define PTT_SRV_ERR     (0x0201)
200 #define PTT_SYS_ERR     (0x0202)
201 #define PTT_GEN_ERR     (0x0203)
202
203 #define ETHERTYPE_PPPOE_DISC    0x8863  /* pppoe discovery packets     */
204 #define ETHERTYPE_PPPOE_SESS    0x8864  /* pppoe session packets       */
205 #define ETHERTYPE_PPPOE_3COM_DISC 0x3c12 /* pppoe discovery packets 3com? */
206 #define ETHERTYPE_PPPOE_3COM_SESS 0x3c13 /* pppoe session packets   3com? */
207 #else
208 #define PTT_EOL         (0x0000)
209 #define PTT_SRV_NAME    (0x0101)
210 #define PTT_AC_NAME     (0x0201)
211 #define PTT_HOST_UNIQ   (0x0301)
212 #define PTT_AC_COOKIE   (0x0401)
213 #define PTT_VENDOR      (0x0501)
214 #define PTT_RELAY_SID   (0x1001)
215 #define PTT_HURL        (0x1101)        /* PPPoE Extensions (CARREL) */
216 #define PTT_MOTM        (0x1201)        /* PPPoE Extensions (CARREL) */
217 #define PTT_MAX_PAYL    (0x2001)        /* PPP-Max-Payload (RFC4638) */
218 #define PTT_SRV_ERR     (0x0102)
219 #define PTT_SYS_ERR     (0x0202)
220 #define PTT_GEN_ERR     (0x0302)
221
222 #define ETHERTYPE_PPPOE_DISC    0x6388  /* pppoe discovery packets     */
223 #define ETHERTYPE_PPPOE_SESS    0x6488  /* pppoe session packets       */
224 #define ETHERTYPE_PPPOE_3COM_DISC 0x123c /* pppoe discovery packets 3com? */
225 #define ETHERTYPE_PPPOE_3COM_SESS 0x133c /* pppoe session packets   3com? */
226 #endif
227
228 struct pppoe_tag {
229         u_int16_t tag_type;
230         u_int16_t tag_len;
231 }__packed;
232
233 struct pppoe_hdr{
234         u_int8_t ver:4;
235         u_int8_t type:4;
236         u_int8_t code;
237         u_int16_t sid;
238         u_int16_t length;
239 }__packed;
240
241 struct pppoe_full_hdr {
242         struct  ether_header eh;
243         struct pppoe_hdr ph;
244 }__packed;
245
246 union   packet {
247         struct pppoe_full_hdr   pkt_header;
248         u_int8_t        bytes[2048];
249 };
250
251 struct datatag {
252         struct pppoe_tag hdr;
253         u_int8_t        data[PPPOE_SERVICE_NAME_SIZE];
254 };     
255
256 struct maxptag {
257         struct pppoe_tag hdr;
258         uint16_t        data;
259 };
260
261 /*
262  * Define the order in which we will place tags in packets
263  * this may be ignored
264  */
265 /* for PADI */
266 #define TAGI_SVC 0
267 #define TAGI_HUNIQ 1
268 /* for PADO */
269 #define TAGO_ACNAME 0
270 #define TAGO_SVC 1
271 #define TAGO_COOKIE 2
272 #define TAGO_HUNIQ 3
273 /* for PADR */
274 #define TAGR_SVC 0
275 #define TAGR_HUNIQ 1
276 #define TAGR_COOKIE 2
277 /* for PADS */
278 #define TAGS_ACNAME 0
279 #define TAGS_SVC 1
280 #define TAGS_COOKIE 2
281 #define TAGS_HUNIQ 3
282 /* for PADT */
283
284 #endif /* _NETGRAPH_NG_PPPOE_H_ */