xref: /titanic_44/usr/src/uts/common/inet/iptun.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
1*2b24ab6bSSebastien Roy /*
2*2b24ab6bSSebastien Roy  * CDDL HEADER START
3*2b24ab6bSSebastien Roy  *
4*2b24ab6bSSebastien Roy  * The contents of this file are subject to the terms of the
5*2b24ab6bSSebastien Roy  * Common Development and Distribution License (the "License").
6*2b24ab6bSSebastien Roy  * You may not use this file except in compliance with the License.
7*2b24ab6bSSebastien Roy  *
8*2b24ab6bSSebastien Roy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2b24ab6bSSebastien Roy  * or http://www.opensolaris.org/os/licensing.
10*2b24ab6bSSebastien Roy  * See the License for the specific language governing permissions
11*2b24ab6bSSebastien Roy  * and limitations under the License.
12*2b24ab6bSSebastien Roy  *
13*2b24ab6bSSebastien Roy  * When distributing Covered Code, include this CDDL HEADER in each
14*2b24ab6bSSebastien Roy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2b24ab6bSSebastien Roy  * If applicable, add the following below this CDDL HEADER, with the
16*2b24ab6bSSebastien Roy  * fields enclosed by brackets "[]" replaced with your own identifying
17*2b24ab6bSSebastien Roy  * information: Portions Copyright [yyyy] [name of copyright owner]
18*2b24ab6bSSebastien Roy  *
19*2b24ab6bSSebastien Roy  * CDDL HEADER END
20*2b24ab6bSSebastien Roy  */
21*2b24ab6bSSebastien Roy /*
22*2b24ab6bSSebastien Roy  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*2b24ab6bSSebastien Roy  * Use is subject to license terms.
24*2b24ab6bSSebastien Roy  */
25*2b24ab6bSSebastien Roy 
26*2b24ab6bSSebastien Roy #ifndef	_INET_IPTUN_H
27*2b24ab6bSSebastien Roy #define	_INET_IPTUN_H
28*2b24ab6bSSebastien Roy 
29*2b24ab6bSSebastien Roy #include <sys/socket.h>
30*2b24ab6bSSebastien Roy #include <sys/types.h>
31*2b24ab6bSSebastien Roy #include <sys/dld_ioc.h>
32*2b24ab6bSSebastien Roy #include <netinet/in.h>
33*2b24ab6bSSebastien Roy #include <netinet/ip6.h>
34*2b24ab6bSSebastien Roy 
35*2b24ab6bSSebastien Roy #ifdef	__cplusplus
36*2b24ab6bSSebastien Roy extern "C" {
37*2b24ab6bSSebastien Roy #endif
38*2b24ab6bSSebastien Roy 
39*2b24ab6bSSebastien Roy /*
40*2b24ab6bSSebastien Roy  * from http://www.iana.org/assignments/ip-parameters
41*2b24ab6bSSebastien Roy  */
42*2b24ab6bSSebastien Roy #define	IPTUN_DEFAULT_HOPLIMIT		64
43*2b24ab6bSSebastien Roy /* from RFC 2473 */
44*2b24ab6bSSebastien Roy #define	IPTUN_DEFAULT_ENCAPLIMIT	4
45*2b24ab6bSSebastien Roy 
46*2b24ab6bSSebastien Roy #define	IPTUN_CREATE		IPTUNIOC(1)
47*2b24ab6bSSebastien Roy #define	IPTUN_DELETE		IPTUNIOC(2)
48*2b24ab6bSSebastien Roy #define	IPTUN_MODIFY		IPTUNIOC(3)
49*2b24ab6bSSebastien Roy #define	IPTUN_INFO		IPTUNIOC(4)
50*2b24ab6bSSebastien Roy #define	IPTUN_SET_6TO4RELAY	IPTUNIOC(9)
51*2b24ab6bSSebastien Roy #define	IPTUN_GET_6TO4RELAY	IPTUNIOC(10)
52*2b24ab6bSSebastien Roy 
53*2b24ab6bSSebastien Roy typedef enum {
54*2b24ab6bSSebastien Roy 	IPTUN_TYPE_UNKNOWN = 0,
55*2b24ab6bSSebastien Roy 	IPTUN_TYPE_IPV4,
56*2b24ab6bSSebastien Roy 	IPTUN_TYPE_IPV6,
57*2b24ab6bSSebastien Roy 	IPTUN_TYPE_6TO4
58*2b24ab6bSSebastien Roy } iptun_type_t;
59*2b24ab6bSSebastien Roy 
60*2b24ab6bSSebastien Roy /*
61*2b24ab6bSSebastien Roy  * To maintain proper alignment of fields between 32bit user-land and 64bit
62*2b24ab6bSSebastien Roy  * kernel, all fields in iptun_kparams_t after itk_fields must be in
63*2b24ab6bSSebastien Roy  * descending order of size.  Due to strict structure size checks done in the
64*2b24ab6bSSebastien Roy  * iptun ioctl processing, the structure size must be the same on 32 and 64
65*2b24ab6bSSebastien Roy  * bit.  amd64 will pad the end of the structure to make the end 64bit
66*2b24ab6bSSebastien Roy  * aligned, so we must add explicit padding to make sure that it's similarly
67*2b24ab6bSSebastien Roy  * aligned when compiled in 32 bit mode.
68*2b24ab6bSSebastien Roy  */
69*2b24ab6bSSebastien Roy typedef struct iptun_kparams {
70*2b24ab6bSSebastien Roy 	datalink_id_t		iptun_kparam_linkid;
71*2b24ab6bSSebastien Roy 	uint32_t		iptun_kparam_flags;
72*2b24ab6bSSebastien Roy 	struct sockaddr_storage	iptun_kparam_laddr;	/* local address */
73*2b24ab6bSSebastien Roy 	struct sockaddr_storage	iptun_kparam_raddr;	/* remote address */
74*2b24ab6bSSebastien Roy 	ipsec_req_t		iptun_kparam_secinfo;
75*2b24ab6bSSebastien Roy 	iptun_type_t		iptun_kparam_type;
76*2b24ab6bSSebastien Roy 	uint32_t		_iptun_kparam_padding;
77*2b24ab6bSSebastien Roy } iptun_kparams_t;
78*2b24ab6bSSebastien Roy 
79*2b24ab6bSSebastien Roy /* itk_flags */
80*2b24ab6bSSebastien Roy #define	IPTUN_KPARAM_TYPE	0x00000001 /* itk_type is set */
81*2b24ab6bSSebastien Roy #define	IPTUN_KPARAM_LADDR	0x00000002 /* itk_laddr is set */
82*2b24ab6bSSebastien Roy #define	IPTUN_KPARAM_RADDR	0x00000004 /* itk_raddr is set */
83*2b24ab6bSSebastien Roy #define	IPTUN_KPARAM_SECINFO	0x00000008 /* itk_secinfo is set */
84*2b24ab6bSSebastien Roy #define	IPTUN_KPARAM_IMPLICIT	0x00000010 /* implicitly created IP tunnel */
85*2b24ab6bSSebastien Roy #define	IPTUN_KPARAM_IPSECPOL	0x00000020 /* ipsecconf(1M) policy present */
86*2b24ab6bSSebastien Roy 
87*2b24ab6bSSebastien Roy #ifdef	__cplusplus
88*2b24ab6bSSebastien Roy }
89*2b24ab6bSSebastien Roy #endif
90*2b24ab6bSSebastien Roy 
91*2b24ab6bSSebastien Roy #endif	/* _INET_IPTUN_H */
92