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