xref: /onnv-gate/usr/src/uts/common/net/pppoe.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * PPPoE Protocol definitions.
24*0Sstevel@tonic-gate  *
25*0Sstevel@tonic-gate  * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
26*0Sstevel@tonic-gate  * All rights reserved.
27*0Sstevel@tonic-gate  *
28*0Sstevel@tonic-gate  * See also:
29*0Sstevel@tonic-gate  *	RFC 2516, A Method for Transmitting PPP Over Ethernet (PPPoE)
30*0Sstevel@tonic-gate  */
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifndef _NETINET_PPPOE_H
33*0Sstevel@tonic-gate #define	_NETINET_PPPOE_H
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #include <sys/types.h>
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #ifdef __cplusplus
40*0Sstevel@tonic-gate extern "C" {
41*0Sstevel@tonic-gate #endif
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate /*
44*0Sstevel@tonic-gate  * Protocol description and well-known constants used by Informational
45*0Sstevel@tonic-gate  * RFC 2516, "A Method for Transmitting PPP Over Ethernet (PPPoE)."
46*0Sstevel@tonic-gate  *
47*0Sstevel@tonic-gate  * Caution:  Note that, contrary to standard practice, length counts
48*0Sstevel@tonic-gate  * used in PPPoE do not include the applicable header length.
49*0Sstevel@tonic-gate  */
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate /* Aligned PPPoE packet header; both discovery and session stages */
52*0Sstevel@tonic-gate typedef struct poep_s {
53*0Sstevel@tonic-gate 	uint8_t		poep_version_type;	/* Use POE_VERSION */
54*0Sstevel@tonic-gate 	uint8_t		poep_code;	/* POECODE_* below */
55*0Sstevel@tonic-gate 	uint16_t	poep_session_id;	/* POESESS_* below */
56*0Sstevel@tonic-gate 	uint16_t	poep_length;	/* NOT including this header */
57*0Sstevel@tonic-gate } poep_t;
58*0Sstevel@tonic-gate #define	POE_HDR_ALIGN	(sizeof (ushort_t))
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate #define	PPPOE_MSGMAX	1500	/* Maximum possible message length */
61*0Sstevel@tonic-gate #define	PPPOE_MTU	1492	/* Maximum PPP MTU/MRU with PPPoE */
62*0Sstevel@tonic-gate #define	PPPOE_MAXPADI	1484	/* Max from RFC 2516 */
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate #define	POE_VERSION	0x11	/* RFC 2516 version/type fields */
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate /* poep_t.poep_code numbers from RFC 2516 */
67*0Sstevel@tonic-gate #define	POECODE_DATA	0x00	/* Data packet (uses other Ethertype) */
68*0Sstevel@tonic-gate #define	POECODE_PADO	0x07	/* Active Discovery Offer */
69*0Sstevel@tonic-gate #define	POECODE_PADI	0x09	/* Active Discovery Initiation (bcast) */
70*0Sstevel@tonic-gate #define	POECODE_PADR	0x19	/* Active Discovery Request */
71*0Sstevel@tonic-gate #define	POECODE_PADS	0x65	/* Active Discovery Session-confirmation */
72*0Sstevel@tonic-gate #define	POECODE_PADT	0xA7	/* Active Discovery Terminate */
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate /* poep_t.poep_code numbers from draft-carrel-info-pppoe-ext. */
75*0Sstevel@tonic-gate #define	POECODE_PADM	0xD3	/* Active Discovery Message */
76*0Sstevel@tonic-gate #define	POECODE_PADN	0xD4	/* Active Discovery Network */
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate /* Special values for poep_t.poep_session_id */
79*0Sstevel@tonic-gate #define	POESESS_NONE	0x0000	/* PADI, PADO, and PADR only */
80*0Sstevel@tonic-gate #define	POESESS_ALL	0xFFFF	/* For multicast data */
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * Tag parsing macros (unaligned) for discovery stage packets.
84*0Sstevel@tonic-gate  * These assume that the pointer to the data is a uint8_t *.
85*0Sstevel@tonic-gate  */
86*0Sstevel@tonic-gate #define	POET_GET_TYPE(x)	(((x)[0]<<8) | (x)[1])
87*0Sstevel@tonic-gate #define	POET_SET_TYPE(x, t)	(void)((x)[0] = (t)>>8, (x)[1] = (t)&0xFF)
88*0Sstevel@tonic-gate #define	POET_GET_LENG(x)	(((x)[2]<<8) | (x)[3])
89*0Sstevel@tonic-gate #define	POET_SET_LENG(x, l)	(void)((x)[2] = (l)>>8, (x)[3] = (l)&0xFF)
90*0Sstevel@tonic-gate #define	POET_HDRLEN		4
91*0Sstevel@tonic-gate #define	POET_DATA(x)		((x)+POET_HDRLEN)
92*0Sstevel@tonic-gate #define	POET_NEXT(x)		(POET_DATA(x) + POET_GET_LENG(x))
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate /* Tag types for discovery stage packets from RFC 2516. */
95*0Sstevel@tonic-gate #define	POETT_END	0x0000	/* End-Of-List; not required */
96*0Sstevel@tonic-gate #define	POETT_SERVICE	0x0101	/* Service-Name; UTF-8 string follows */
97*0Sstevel@tonic-gate #define	POETT_ACCESS	0x0102	/* AC-Name; UTF-8 */
98*0Sstevel@tonic-gate #define	POETT_UNIQ	0x0103	/* Host-Uniq; arbitrary binary */
99*0Sstevel@tonic-gate #define	POETT_COOKIE	0x0104	/* AC-Cookie; DoS reducer */
100*0Sstevel@tonic-gate #define	POETT_VENDOR	0x0105	/* Vendor-Specific; 0+enterprise+data */
101*0Sstevel@tonic-gate #define	POETT_RELAY	0x0110	/* Relay-Session-Id; opaque data */
102*0Sstevel@tonic-gate #define	POETT_NAMERR	0x0201	/* Service-Name-Error; no data */
103*0Sstevel@tonic-gate #define	POETT_SYSERR	0x0202	/* AC-System-Error; may have UTF-8 */
104*0Sstevel@tonic-gate #define	POETT_GENERR	0x0203	/* Generic-Error; may have UTF-8 */
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate /* Tag types from draft-carrel-info-pppoe-ext. */
107*0Sstevel@tonic-gate #define	POETT_MULTI	0x0106	/* Multicast-Capable; one byte version */
108*0Sstevel@tonic-gate #define	POETT_HURL	0x0111	/* Host-URL; UTF-8 for browser */
109*0Sstevel@tonic-gate #define	POETT_MOTM	0x0112	/* Message-Of-The-Minute; UTF-8 for human */
110*0Sstevel@tonic-gate #define	POETT_RTEADD	0x0121	/* IP-Route-Add; single poer_t below */
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate /* Data byte in POETT_MULTI (Multicast-Capable) tag. */
113*0Sstevel@tonic-gate #define	POET_MULTI_VER	0x00	/* Current version is zero */
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate /* POETT_RTEADD tag contents */
116*0Sstevel@tonic-gate typedef struct poer_s {
117*0Sstevel@tonic-gate 	uint32_t	poer_dest_network;
118*0Sstevel@tonic-gate 	uint32_t	poer_subnet_mask;
119*0Sstevel@tonic-gate 	uint32_t	poer_gateway;
120*0Sstevel@tonic-gate 	uint32_t	poer_metric;
121*0Sstevel@tonic-gate } poer_t;
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate #ifdef __cplusplus
124*0Sstevel@tonic-gate }
125*0Sstevel@tonic-gate #endif
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate #endif /* _NETINET_PPPOE_H */
128