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