xref: /titanic_52/usr/src/uts/common/net/pppoe.h (revision 0a0e9771ca0211c15f3ac4466b661c145feeb9e4)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <sys/types.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Protocol description and well-known constants used by Informational
45  * RFC 2516, "A Method for Transmitting PPP Over Ethernet (PPPoE)."
46  *
47  * Caution:  Note that, contrary to standard practice, length counts
48  * used in PPPoE do not include the applicable header length.
49  */
50 
51 /* Aligned PPPoE packet header; both discovery and session stages */
52 typedef struct poep_s {
53 	uint8_t		poep_version_type;	/* Use POE_VERSION */
54 	uint8_t		poep_code;	/* POECODE_* below */
55 	uint16_t	poep_session_id;	/* POESESS_* below */
56 	uint16_t	poep_length;	/* NOT including this header */
57 } poep_t;
58 #define	POE_HDR_ALIGN	(sizeof (ushort_t))
59 
60 #define	PPPOE_MSGMAX	1500	/* Maximum possible message length */
61 #define	PPPOE_MTU	1492	/* Maximum PPP MTU/MRU with PPPoE */
62 #define	PPPOE_MAXPADI	1484	/* Max from RFC 2516 */
63 
64 #define	POE_VERSION	0x11	/* RFC 2516 version/type fields */
65 
66 /* poep_t.poep_code numbers from RFC 2516 */
67 #define	POECODE_DATA	0x00	/* Data packet (uses other Ethertype) */
68 #define	POECODE_PADO	0x07	/* Active Discovery Offer */
69 #define	POECODE_PADI	0x09	/* Active Discovery Initiation (bcast) */
70 #define	POECODE_PADR	0x19	/* Active Discovery Request */
71 #define	POECODE_PADS	0x65	/* Active Discovery Session-confirmation */
72 #define	POECODE_PADT	0xA7	/* Active Discovery Terminate */
73 
74 /* poep_t.poep_code numbers from draft-carrel-info-pppoe-ext. */
75 #define	POECODE_PADM	0xD3	/* Active Discovery Message */
76 #define	POECODE_PADN	0xD4	/* Active Discovery Network */
77 
78 /* Special values for poep_t.poep_session_id */
79 #define	POESESS_NONE	0x0000	/* PADI, PADO, and PADR only */
80 #define	POESESS_ALL	0xFFFF	/* For multicast data */
81 
82 /*
83  * Tag parsing macros (unaligned) for discovery stage packets.
84  * These assume that the pointer to the data is a uint8_t *.
85  */
86 #define	POET_GET_TYPE(x)	(((x)[0]<<8) | (x)[1])
87 #define	POET_SET_TYPE(x, t)	(void)((x)[0] = (t)>>8, (x)[1] = (t)&0xFF)
88 #define	POET_GET_LENG(x)	(((x)[2]<<8) | (x)[3])
89 #define	POET_SET_LENG(x, l)	(void)((x)[2] = (l)>>8, (x)[3] = (l)&0xFF)
90 #define	POET_HDRLEN		4
91 #define	POET_DATA(x)		((x)+POET_HDRLEN)
92 #define	POET_NEXT(x)		(POET_DATA(x) + POET_GET_LENG(x))
93 
94 /* Tag types for discovery stage packets from RFC 2516. */
95 #define	POETT_END	0x0000	/* End-Of-List; not required */
96 #define	POETT_SERVICE	0x0101	/* Service-Name; UTF-8 string follows */
97 #define	POETT_ACCESS	0x0102	/* AC-Name; UTF-8 */
98 #define	POETT_UNIQ	0x0103	/* Host-Uniq; arbitrary binary */
99 #define	POETT_COOKIE	0x0104	/* AC-Cookie; DoS reducer */
100 #define	POETT_VENDOR	0x0105	/* Vendor-Specific; 0+enterprise+data */
101 #define	POETT_RELAY	0x0110	/* Relay-Session-Id; opaque data */
102 #define	POETT_NAMERR	0x0201	/* Service-Name-Error; no data */
103 #define	POETT_SYSERR	0x0202	/* AC-System-Error; may have UTF-8 */
104 #define	POETT_GENERR	0x0203	/* Generic-Error; may have UTF-8 */
105 
106 /* Tag types from draft-carrel-info-pppoe-ext. */
107 #define	POETT_MULTI	0x0106	/* Multicast-Capable; one byte version */
108 #define	POETT_HURL	0x0111	/* Host-URL; UTF-8 for browser */
109 #define	POETT_MOTM	0x0112	/* Message-Of-The-Minute; UTF-8 for human */
110 #define	POETT_RTEADD	0x0121	/* IP-Route-Add; single poer_t below */
111 
112 /* Data byte in POETT_MULTI (Multicast-Capable) tag. */
113 #define	POET_MULTI_VER	0x00	/* Current version is zero */
114 
115 /* POETT_RTEADD tag contents */
116 typedef struct poer_s {
117 	uint32_t	poer_dest_network;
118 	uint32_t	poer_subnet_mask;
119 	uint32_t	poer_gateway;
120 	uint32_t	poer_metric;
121 } poer_t;
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif /* _NETINET_PPPOE_H */
128