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