xref: /illumos-gate/usr/src/uts/common/net/sppptun.h (revision 4de2612967d06c4fdbf524a62556a1e8118a006f)
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  * sppptun.h - ioctl and other miscellaneous definitions for PPP
24  * tunneling STREAMS module
25  *
26  * Copyright 2000-2002 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  *
29  * See also:
30  *	RFC 2341, Cisco Layer Two Forwarding (Protocol) "L2F"
31  *	RFC 2516, A Method for Transmitting PPP Over Ethernet (PPPoE)
32  *	RFC 2637, Point-to-Point Tunneling Protocol (PPTP)
33  *	RFC 2661, Layer Two Tunneling Protocol "L2TP"
34  */
35 
36 #ifndef __SPPPTUN_H
37 #define	__SPPPTUN_H
38 
39 #pragma ident	"%Z%%M%	%I%	%E% SMI"
40 
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <sys/ethernet.h>
44 #include <net/if.h>
45 #include <netinet/in.h>
46 
47 #ifdef	__cplusplus
48 extern "C" {
49 #endif
50 
51 /* Device name */
52 #define	PPP_TUN_NAME "sppptun"
53 
54 /* The constant below is "TUN" in hex. */
55 #define	_PPPTUN(n)	(0x54554E00 + (n))
56 
57 /*
58  * Except where otherwise noted (mod), these apply to the driver side
59  * of the PPP tunnel multiplexor.
60  */
61 #define	PPPTUN_SNAME	_PPPTUN(1)	/* set interface name (mod) */
62 #define	PPPTUN_GNAME	_PPPTUN(2)	/* get interface name (mod) */
63 #define	PPPTUN_SINFO	_PPPTUN(3)	/* set multiplex ID/style */
64 #define	PPPTUN_GINFO	_PPPTUN(4)	/* get multiplex ID/style */
65 #define	PPPTUN_GNNAME	_PPPTUN(5)	/* get Nth interface name */
66 #define	PPPTUN_LCLADDR	_PPPTUN(6)	/* set local address */
67 #define	PPPTUN_SPEER	_PPPTUN(7)	/* set peer ID */
68 #define	PPPTUN_GPEER	_PPPTUN(8)	/* get peer ID */
69 #define	PPPTUN_SDATA	_PPPTUN(9)	/* set data channel by name */
70 #define	PPPTUN_GDATA	_PPPTUN(10)	/* get data channel name */
71 #define	PPPTUN_SCTL	_PPPTUN(11)	/* set control channel by name */
72 #define	PPPTUN_GCTL	_PPPTUN(12)	/* get control channel name */
73 #define	PPPTUN_DCTL	_PPPTUN(13)	/* remove control channel */
74 
75 /* Lower layer link name size */
76 #define	PPPTUNNAMSIZ	32
77 
78 typedef char ppptun_lname[PPPTUNNAMSIZ];
79 
80 /*
81  * For PPPTUN_SNAME, PPPTUN_GNAME, PPPTUN_SDATA, PPPTUN_GDATA,
82  * PPPTUN_SCTL, PPPTUN_GCTL, and PPPTUN_DCTL, just this structure is
83  * used.
84  *
85  * PPPTUN_GNNAME takes in a single int (0...N) and this structure is
86  * returned.  Use ptn_index to pass in the index.
87  */
88 union ppptun_name {
89 	uint32_t	ptn_index;
90 	ppptun_lname	ptn_name;
91 };
92 
93 /* PPPTUN_SINFO and PPPTUN_GINFO use this structure */
94 struct ppptun_info {
95 	ppptun_lname	pti_name;
96 	uint32_t	pti_muxid;	/* ID from I_PLINK (not L2F!) */
97 	uint32_t	pti_style;	/* One of PTS_* below */
98 };
99 
100 #define	PTS_NONE	0		/* Illegal configuration */
101 #define	PTS_PPPOE	1		/* DLPI PPPoE */
102 #define	PTS_L2FTP	2		/* TLI L2F or L2TP over UDP GRE */
103 #define	PTS_PPTP	3		/* TPI PPTP over IP GRE */
104 #define	PTS__MAX	4		/* one greater than last above */
105 
106 struct ppptun_gre_addr {
107 	struct in6_addr	ptga_peer_ip;
108 	uint16_t	ptga_peer_port;	/* L2TP or L2F, not PPTP */
109 	uint8_t		ptga_version;	/* one of PTGAV_* below */
110 };
111 
112 struct ppptun_mac_addr {
113 	struct ether_addr	ptma_mac_ether_addr;
114 #define	ptma_mac	ptma_mac_ether_addr.ether_addr_octet
115 };
116 
117 /* Values for ptga_version; corresponds to GRE version number */
118 #define	PTGAV_L2F	0x01
119 #define	PTGAV_PPTP	0x01
120 #define	PTGAV_L2TP	0x02
121 
122 typedef union {
123 	struct ppptun_gre_addr	pta_l2f;
124 	struct ppptun_gre_addr	pta_l2tp;
125 	struct ppptun_gre_addr	pta_pptp;
126 	struct ppptun_mac_addr	pta_pppoe;
127 } ppptun_atype;
128 
129 /* For PPPTUN_SPEER and PPPTUN_GPEER; the address depends on the style */
130 struct ppptun_peer {
131 	uint32_t	ptp_style;	/* Sanity check; must match lower */
132 	uint32_t	ptp_flags;	/* See PTPF_* below */
133 	uint32_t	ptp_ltunid;	/* Local Tunnel ID (L2F/L2TP) */
134 	uint32_t	ptp_rtunid;	/* Remote Tunnel ID (L2F/L2TP) */
135 	uint32_t	ptp_lsessid;	/* Local Session ID */
136 	uint32_t	ptp_rsessid;	/* Remote Session ID */
137 	ppptun_atype	ptp_address;	/* Peer address */
138 };
139 
140 #define	PTPF_DAEMON	0x00000001	/* server side; session ID 0 */
141 
142 /* For M_PROTO (control message) */
143 struct ppptun_control {
144 	uint32_t	ptc_discrim;	/* Use PPPOE_DISCRIM */
145 	uint32_t	ptc_action;	/* See PTCA_* below */
146 	uint32_t	ptc_rsessid;	/* Remote session ID */
147 	ppptun_atype	ptc_address;	/* Peer address (if any) */
148 	ppptun_lname	ptc_name;	/* Lower stream name (if any) */
149 };
150 
151 /*
152  * This value, currently set to the characters "POE1," is used to
153  * distinguish among control messages from multiple lower streams
154  * under /dev/sppp.  This feature is needed to support PPP translation
155  * (LAC-like behavior), but isn't currently used.
156  */
157 #define	PPPOE_DISCRIM	0x504F4531
158 
159 #define	PTCA_TEST	1		/* Test/set stream discriminator */
160 #define	PTCA_CONTROL	2		/* Inbound control message */
161 #define	PTCA_DISCONNECT	3		/* Client disconnected */
162 #define	PTCA_UNPLUMB	4		/* Lower stream unplumbed (no addr) */
163 
164 #ifdef	__cplusplus
165 }
166 #endif
167 
168 #endif /* __SPPPTUN_H */
169