xref: /illumos-gate/usr/src/uts/common/net/sppptun.h (revision f53eecf5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*f53eecf5SJames Carlson  * Common Development and Distribution License (the "License").
6*f53eecf5SJames Carlson  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  * sppptun.h - ioctl and other miscellaneous definitions for PPP
237c478bd9Sstevel@tonic-gate  * tunneling STREAMS module
247c478bd9Sstevel@tonic-gate  *
25*f53eecf5SJames Carlson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
277c478bd9Sstevel@tonic-gate  *
287c478bd9Sstevel@tonic-gate  * See also:
297c478bd9Sstevel@tonic-gate  *	RFC 2341, Cisco Layer Two Forwarding (Protocol) "L2F"
307c478bd9Sstevel@tonic-gate  *	RFC 2516, A Method for Transmitting PPP Over Ethernet (PPPoE)
317c478bd9Sstevel@tonic-gate  *	RFC 2637, Point-to-Point Tunneling Protocol (PPTP)
327c478bd9Sstevel@tonic-gate  *	RFC 2661, Layer Two Tunneling Protocol "L2TP"
337c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate #ifndef __SPPPTUN_H
367c478bd9Sstevel@tonic-gate #define	__SPPPTUN_H
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <sys/socket.h>
407c478bd9Sstevel@tonic-gate #include <sys/ethernet.h>
417c478bd9Sstevel@tonic-gate #include <net/if.h>
427c478bd9Sstevel@tonic-gate #include <netinet/in.h>
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
487c478bd9Sstevel@tonic-gate /* Device name */
497c478bd9Sstevel@tonic-gate #define	PPP_TUN_NAME "sppptun"
517c478bd9Sstevel@tonic-gate /* The constant below is "TUN" in hex. */
527c478bd9Sstevel@tonic-gate #define	_PPPTUN(n)	(0x54554E00 + (n))
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * Except where otherwise noted (mod), these apply to the driver side
567c478bd9Sstevel@tonic-gate  * of the PPP tunnel multiplexor.
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate #define	PPPTUN_SNAME	_PPPTUN(1)	/* set interface name (mod) */
597c478bd9Sstevel@tonic-gate #define	PPPTUN_SINFO	_PPPTUN(3)	/* set multiplex ID/style */
607c478bd9Sstevel@tonic-gate #define	PPPTUN_GINFO	_PPPTUN(4)	/* get multiplex ID/style */
617c478bd9Sstevel@tonic-gate #define	PPPTUN_GNNAME	_PPPTUN(5)	/* get Nth interface name */
627c478bd9Sstevel@tonic-gate #define	PPPTUN_LCLADDR	_PPPTUN(6)	/* set local address */
637c478bd9Sstevel@tonic-gate #define	PPPTUN_SPEER	_PPPTUN(7)	/* set peer ID */
647c478bd9Sstevel@tonic-gate #define	PPPTUN_GPEER	_PPPTUN(8)	/* get peer ID */
657c478bd9Sstevel@tonic-gate #define	PPPTUN_SDATA	_PPPTUN(9)	/* set data channel by name */
667c478bd9Sstevel@tonic-gate #define	PPPTUN_GDATA	_PPPTUN(10)	/* get data channel name */
677c478bd9Sstevel@tonic-gate #define	PPPTUN_SCTL	_PPPTUN(11)	/* set control channel by name */
687c478bd9Sstevel@tonic-gate #define	PPPTUN_GCTL	_PPPTUN(12)	/* get control channel name */
697c478bd9Sstevel@tonic-gate #define	PPPTUN_DCTL	_PPPTUN(13)	/* remove control channel */
70*f53eecf5SJames Carlson #define	PPPTUN_SSAP	_PPPTUN(14)	/* set SAP value; uint_t */
727c478bd9Sstevel@tonic-gate /* Lower layer link name size */
737c478bd9Sstevel@tonic-gate #define	PPPTUNNAMSIZ	32
757c478bd9Sstevel@tonic-gate typedef char ppptun_lname[PPPTUNNAMSIZ];
777c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * PPPTUN_SCTL, PPPTUN_GCTL, and PPPTUN_DCTL, just this structure is
807c478bd9Sstevel@tonic-gate  * used.
817c478bd9Sstevel@tonic-gate  *
827c478bd9Sstevel@tonic-gate  * PPPTUN_GNNAME takes in a single int (0...N) and this structure is
837c478bd9Sstevel@tonic-gate  * returned.  Use ptn_index to pass in the index.
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate union ppptun_name {
867c478bd9Sstevel@tonic-gate 	uint32_t	ptn_index;
877c478bd9Sstevel@tonic-gate 	ppptun_lname	ptn_name;
887c478bd9Sstevel@tonic-gate };
907c478bd9Sstevel@tonic-gate /* PPPTUN_SINFO and PPPTUN_GINFO use this structure */
917c478bd9Sstevel@tonic-gate struct ppptun_info {
927c478bd9Sstevel@tonic-gate 	ppptun_lname	pti_name;
937c478bd9Sstevel@tonic-gate 	uint32_t	pti_muxid;	/* ID from I_PLINK (not L2F!) */
947c478bd9Sstevel@tonic-gate 	uint32_t	pti_style;	/* One of PTS_* below */
957c478bd9Sstevel@tonic-gate };
977c478bd9Sstevel@tonic-gate #define	PTS_NONE	0		/* Illegal configuration */
987c478bd9Sstevel@tonic-gate #define	PTS_PPPOE	1		/* DLPI PPPoE */
997c478bd9Sstevel@tonic-gate #define	PTS_L2FTP	2		/* TLI L2F or L2TP over UDP GRE */
1007c478bd9Sstevel@tonic-gate #define	PTS_PPTP	3		/* TPI PPTP over IP GRE */
1017c478bd9Sstevel@tonic-gate #define	PTS__MAX	4		/* one greater than last above */
1037c478bd9Sstevel@tonic-gate struct ppptun_gre_addr {
1047c478bd9Sstevel@tonic-gate 	struct in6_addr	ptga_peer_ip;
1057c478bd9Sstevel@tonic-gate 	uint16_t	ptga_peer_port;	/* L2TP or L2F, not PPTP */
1067c478bd9Sstevel@tonic-gate 	uint8_t		ptga_version;	/* one of PTGAV_* below */
1077c478bd9Sstevel@tonic-gate };
1097c478bd9Sstevel@tonic-gate struct ppptun_mac_addr {
1107c478bd9Sstevel@tonic-gate 	struct ether_addr	ptma_mac_ether_addr;
1117c478bd9Sstevel@tonic-gate #define	ptma_mac	ptma_mac_ether_addr.ether_addr_octet
1127c478bd9Sstevel@tonic-gate };
1147c478bd9Sstevel@tonic-gate /* Values for ptga_version; corresponds to GRE version number */
1157c478bd9Sstevel@tonic-gate #define	PTGAV_L2F	0x01
1167c478bd9Sstevel@tonic-gate #define	PTGAV_PPTP	0x01
1177c478bd9Sstevel@tonic-gate #define	PTGAV_L2TP	0x02
1197c478bd9Sstevel@tonic-gate typedef union {
1207c478bd9Sstevel@tonic-gate 	struct ppptun_gre_addr	pta_l2f;
1217c478bd9Sstevel@tonic-gate 	struct ppptun_gre_addr	pta_l2tp;
1227c478bd9Sstevel@tonic-gate 	struct ppptun_gre_addr	pta_pptp;
1237c478bd9Sstevel@tonic-gate 	struct ppptun_mac_addr	pta_pppoe;
1247c478bd9Sstevel@tonic-gate } ppptun_atype;
1267c478bd9Sstevel@tonic-gate /* For PPPTUN_SPEER and PPPTUN_GPEER; the address depends on the style */
1277c478bd9Sstevel@tonic-gate struct ppptun_peer {
1287c478bd9Sstevel@tonic-gate 	uint32_t	ptp_style;	/* Sanity check; must match lower */
1297c478bd9Sstevel@tonic-gate 	uint32_t	ptp_flags;	/* See PTPF_* below */
1307c478bd9Sstevel@tonic-gate 	uint32_t	ptp_ltunid;	/* Local Tunnel ID (L2F/L2TP) */
1317c478bd9Sstevel@tonic-gate 	uint32_t	ptp_rtunid;	/* Remote Tunnel ID (L2F/L2TP) */
1327c478bd9Sstevel@tonic-gate 	uint32_t	ptp_lsessid;	/* Local Session ID */
1337c478bd9Sstevel@tonic-gate 	uint32_t	ptp_rsessid;	/* Remote Session ID */
1347c478bd9Sstevel@tonic-gate 	ppptun_atype	ptp_address;	/* Peer address */
1357c478bd9Sstevel@tonic-gate };
1377c478bd9Sstevel@tonic-gate #define	PTPF_DAEMON	0x00000001	/* server side; session ID 0 */
1397c478bd9Sstevel@tonic-gate /* For M_PROTO (control message) */
1407c478bd9Sstevel@tonic-gate struct ppptun_control {
1417c478bd9Sstevel@tonic-gate 	uint32_t	ptc_discrim;	/* Use PPPOE_DISCRIM */
1427c478bd9Sstevel@tonic-gate 	uint32_t	ptc_action;	/* See PTCA_* below */
1437c478bd9Sstevel@tonic-gate 	uint32_t	ptc_rsessid;	/* Remote session ID */
1447c478bd9Sstevel@tonic-gate 	ppptun_atype	ptc_address;	/* Peer address (if any) */
1457c478bd9Sstevel@tonic-gate 	ppptun_lname	ptc_name;	/* Lower stream name (if any) */
1467c478bd9Sstevel@tonic-gate };
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * This value, currently set to the characters "POE1," is used to
1507c478bd9Sstevel@tonic-gate  * distinguish among control messages from multiple lower streams
1517c478bd9Sstevel@tonic-gate  * under /dev/sppp.  This feature is needed to support PPP translation
1527c478bd9Sstevel@tonic-gate  * (LAC-like behavior), but isn't currently used.
1537c478bd9Sstevel@tonic-gate  */
1547c478bd9Sstevel@tonic-gate #define	PPPOE_DISCRIM	0x504F4531
1567c478bd9Sstevel@tonic-gate #define	PTCA_TEST	1		/* Test/set stream discriminator */
1577c478bd9Sstevel@tonic-gate #define	PTCA_CONTROL	2		/* Inbound control message */
1587c478bd9Sstevel@tonic-gate #define	PTCA_DISCONNECT	3		/* Client disconnected */
1597c478bd9Sstevel@tonic-gate #define	PTCA_UNPLUMB	4		/* Lower stream unplumbed (no addr) */
160*f53eecf5SJames Carlson #define	PTCA_BADCTRL	5		/* Malformed control message */
1627c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1637c478bd9Sstevel@tonic-gate }
1647c478bd9Sstevel@tonic-gate #endif
1667c478bd9Sstevel@tonic-gate #endif /* __SPPPTUN_H */