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