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