xref: /onnv-gate/usr/src/uts/common/net/sppptun.h (revision 9751:8e29565352fc)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*9751Sjames.d.carlson@sun.com  * Common Development and Distribution License (the "License").
6*9751Sjames.d.carlson@sun.com  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
220Sstevel@tonic-gate  * sppptun.h - ioctl and other miscellaneous definitions for PPP
230Sstevel@tonic-gate  * tunneling STREAMS module
240Sstevel@tonic-gate  *
25*9751Sjames.d.carlson@sun.com  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
260Sstevel@tonic-gate  * Use is subject to license terms.
270Sstevel@tonic-gate  *
280Sstevel@tonic-gate  * See also:
290Sstevel@tonic-gate  *	RFC 2341, Cisco Layer Two Forwarding (Protocol) "L2F"
300Sstevel@tonic-gate  *	RFC 2516, A Method for Transmitting PPP Over Ethernet (PPPoE)
310Sstevel@tonic-gate  *	RFC 2637, Point-to-Point Tunneling Protocol (PPTP)
320Sstevel@tonic-gate  *	RFC 2661, Layer Two Tunneling Protocol "L2TP"
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifndef __SPPPTUN_H
360Sstevel@tonic-gate #define	__SPPPTUN_H
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #include <sys/types.h>
390Sstevel@tonic-gate #include <sys/socket.h>
400Sstevel@tonic-gate #include <sys/ethernet.h>
410Sstevel@tonic-gate #include <net/if.h>
420Sstevel@tonic-gate #include <netinet/in.h>
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #ifdef	__cplusplus
450Sstevel@tonic-gate extern "C" {
460Sstevel@tonic-gate #endif
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /* Device name */
490Sstevel@tonic-gate #define	PPP_TUN_NAME "sppptun"
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /* The constant below is "TUN" in hex. */
520Sstevel@tonic-gate #define	_PPPTUN(n)	(0x54554E00 + (n))
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /*
550Sstevel@tonic-gate  * Except where otherwise noted (mod), these apply to the driver side
560Sstevel@tonic-gate  * of the PPP tunnel multiplexor.
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate #define	PPPTUN_SNAME	_PPPTUN(1)	/* set interface name (mod) */
590Sstevel@tonic-gate #define	PPPTUN_SINFO	_PPPTUN(3)	/* set multiplex ID/style */
600Sstevel@tonic-gate #define	PPPTUN_GINFO	_PPPTUN(4)	/* get multiplex ID/style */
610Sstevel@tonic-gate #define	PPPTUN_GNNAME	_PPPTUN(5)	/* get Nth interface name */
620Sstevel@tonic-gate #define	PPPTUN_LCLADDR	_PPPTUN(6)	/* set local address */
630Sstevel@tonic-gate #define	PPPTUN_SPEER	_PPPTUN(7)	/* set peer ID */
640Sstevel@tonic-gate #define	PPPTUN_GPEER	_PPPTUN(8)	/* get peer ID */
650Sstevel@tonic-gate #define	PPPTUN_SDATA	_PPPTUN(9)	/* set data channel by name */
660Sstevel@tonic-gate #define	PPPTUN_GDATA	_PPPTUN(10)	/* get data channel name */
670Sstevel@tonic-gate #define	PPPTUN_SCTL	_PPPTUN(11)	/* set control channel by name */
680Sstevel@tonic-gate #define	PPPTUN_GCTL	_PPPTUN(12)	/* get control channel name */
690Sstevel@tonic-gate #define	PPPTUN_DCTL	_PPPTUN(13)	/* remove control channel */
70*9751Sjames.d.carlson@sun.com #define	PPPTUN_SSAP	_PPPTUN(14)	/* set SAP value; uint_t */
710Sstevel@tonic-gate 
720Sstevel@tonic-gate /* Lower layer link name size */
730Sstevel@tonic-gate #define	PPPTUNNAMSIZ	32
740Sstevel@tonic-gate 
750Sstevel@tonic-gate typedef char ppptun_lname[PPPTUNNAMSIZ];
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*
780Sstevel@tonic-gate  * For PPPTUN_SNAME, PPPTUN_GNAME, PPPTUN_SDATA, PPPTUN_GDATA,
790Sstevel@tonic-gate  * PPPTUN_SCTL, PPPTUN_GCTL, and PPPTUN_DCTL, just this structure is
800Sstevel@tonic-gate  * used.
810Sstevel@tonic-gate  *
820Sstevel@tonic-gate  * PPPTUN_GNNAME takes in a single int (0...N) and this structure is
830Sstevel@tonic-gate  * returned.  Use ptn_index to pass in the index.
840Sstevel@tonic-gate  */
850Sstevel@tonic-gate union ppptun_name {
860Sstevel@tonic-gate 	uint32_t	ptn_index;
870Sstevel@tonic-gate 	ppptun_lname	ptn_name;
880Sstevel@tonic-gate };
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /* PPPTUN_SINFO and PPPTUN_GINFO use this structure */
910Sstevel@tonic-gate struct ppptun_info {
920Sstevel@tonic-gate 	ppptun_lname	pti_name;
930Sstevel@tonic-gate 	uint32_t	pti_muxid;	/* ID from I_PLINK (not L2F!) */
940Sstevel@tonic-gate 	uint32_t	pti_style;	/* One of PTS_* below */
950Sstevel@tonic-gate };
960Sstevel@tonic-gate 
970Sstevel@tonic-gate #define	PTS_NONE	0		/* Illegal configuration */
980Sstevel@tonic-gate #define	PTS_PPPOE	1		/* DLPI PPPoE */
990Sstevel@tonic-gate #define	PTS_L2FTP	2		/* TLI L2F or L2TP over UDP GRE */
1000Sstevel@tonic-gate #define	PTS_PPTP	3		/* TPI PPTP over IP GRE */
1010Sstevel@tonic-gate #define	PTS__MAX	4		/* one greater than last above */
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate struct ppptun_gre_addr {
1040Sstevel@tonic-gate 	struct in6_addr	ptga_peer_ip;
1050Sstevel@tonic-gate 	uint16_t	ptga_peer_port;	/* L2TP or L2F, not PPTP */
1060Sstevel@tonic-gate 	uint8_t		ptga_version;	/* one of PTGAV_* below */
1070Sstevel@tonic-gate };
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate struct ppptun_mac_addr {
1100Sstevel@tonic-gate 	struct ether_addr	ptma_mac_ether_addr;
1110Sstevel@tonic-gate #define	ptma_mac	ptma_mac_ether_addr.ether_addr_octet
1120Sstevel@tonic-gate };
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate /* Values for ptga_version; corresponds to GRE version number */
1150Sstevel@tonic-gate #define	PTGAV_L2F	0x01
1160Sstevel@tonic-gate #define	PTGAV_PPTP	0x01
1170Sstevel@tonic-gate #define	PTGAV_L2TP	0x02
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate typedef union {
1200Sstevel@tonic-gate 	struct ppptun_gre_addr	pta_l2f;
1210Sstevel@tonic-gate 	struct ppptun_gre_addr	pta_l2tp;
1220Sstevel@tonic-gate 	struct ppptun_gre_addr	pta_pptp;
1230Sstevel@tonic-gate 	struct ppptun_mac_addr	pta_pppoe;
1240Sstevel@tonic-gate } ppptun_atype;
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate /* For PPPTUN_SPEER and PPPTUN_GPEER; the address depends on the style */
1270Sstevel@tonic-gate struct ppptun_peer {
1280Sstevel@tonic-gate 	uint32_t	ptp_style;	/* Sanity check; must match lower */
1290Sstevel@tonic-gate 	uint32_t	ptp_flags;	/* See PTPF_* below */
1300Sstevel@tonic-gate 	uint32_t	ptp_ltunid;	/* Local Tunnel ID (L2F/L2TP) */
1310Sstevel@tonic-gate 	uint32_t	ptp_rtunid;	/* Remote Tunnel ID (L2F/L2TP) */
1320Sstevel@tonic-gate 	uint32_t	ptp_lsessid;	/* Local Session ID */
1330Sstevel@tonic-gate 	uint32_t	ptp_rsessid;	/* Remote Session ID */
1340Sstevel@tonic-gate 	ppptun_atype	ptp_address;	/* Peer address */
1350Sstevel@tonic-gate };
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate #define	PTPF_DAEMON	0x00000001	/* server side; session ID 0 */
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate /* For M_PROTO (control message) */
1400Sstevel@tonic-gate struct ppptun_control {
1410Sstevel@tonic-gate 	uint32_t	ptc_discrim;	/* Use PPPOE_DISCRIM */
1420Sstevel@tonic-gate 	uint32_t	ptc_action;	/* See PTCA_* below */
1430Sstevel@tonic-gate 	uint32_t	ptc_rsessid;	/* Remote session ID */
1440Sstevel@tonic-gate 	ppptun_atype	ptc_address;	/* Peer address (if any) */
1450Sstevel@tonic-gate 	ppptun_lname	ptc_name;	/* Lower stream name (if any) */
1460Sstevel@tonic-gate };
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate /*
1490Sstevel@tonic-gate  * This value, currently set to the characters "POE1," is used to
1500Sstevel@tonic-gate  * distinguish among control messages from multiple lower streams
1510Sstevel@tonic-gate  * under /dev/sppp.  This feature is needed to support PPP translation
1520Sstevel@tonic-gate  * (LAC-like behavior), but isn't currently used.
1530Sstevel@tonic-gate  */
1540Sstevel@tonic-gate #define	PPPOE_DISCRIM	0x504F4531
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate #define	PTCA_TEST	1		/* Test/set stream discriminator */
1570Sstevel@tonic-gate #define	PTCA_CONTROL	2		/* Inbound control message */
1580Sstevel@tonic-gate #define	PTCA_DISCONNECT	3		/* Client disconnected */
1590Sstevel@tonic-gate #define	PTCA_UNPLUMB	4		/* Lower stream unplumbed (no addr) */
160*9751Sjames.d.carlson@sun.com #define	PTCA_BADCTRL	5		/* Malformed control message */
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #ifdef	__cplusplus
1630Sstevel@tonic-gate }
1640Sstevel@tonic-gate #endif
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate #endif /* __SPPPTUN_H */
167