xref: /titanic_52/usr/src/uts/common/inet/iptun.h (revision f6e214c7418f43af38bd8c3a557e3d0a1d311cfa)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_INET_IPTUN_H
27 #define	_INET_IPTUN_H
28 
29 #include <sys/socket.h>
30 #include <sys/types.h>
31 #include <sys/dld_ioc.h>
32 #include <netinet/in.h>
33 #include <netinet/ip6.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * from http://www.iana.org/assignments/ip-parameters
41  */
42 #define	IPTUN_DEFAULT_HOPLIMIT		64
43 /* from RFC 2473 */
44 #define	IPTUN_DEFAULT_ENCAPLIMIT	4
45 
46 #define	IPTUN_CREATE		IPTUNIOC(1)
47 #define	IPTUN_DELETE		IPTUNIOC(2)
48 #define	IPTUN_MODIFY		IPTUNIOC(3)
49 #define	IPTUN_INFO		IPTUNIOC(4)
50 #define	IPTUN_SET_6TO4RELAY	IPTUNIOC(9)
51 #define	IPTUN_GET_6TO4RELAY	IPTUNIOC(10)
52 
53 typedef enum {
54 	IPTUN_TYPE_UNKNOWN = 0,
55 	IPTUN_TYPE_IPV4,
56 	IPTUN_TYPE_IPV6,
57 	IPTUN_TYPE_6TO4
58 } iptun_type_t;
59 
60 /*
61  * To maintain proper alignment of fields between 32bit user-land and 64bit
62  * kernel, all fields in iptun_kparams_t after itk_fields must be in
63  * descending order of size.  Due to strict structure size checks done in the
64  * iptun ioctl processing, the structure size must be the same on 32 and 64
65  * bit.  amd64 will pad the end of the structure to make the end 64bit
66  * aligned, so we must add explicit padding to make sure that it's similarly
67  * aligned when compiled in 32 bit mode.
68  */
69 typedef struct iptun_kparams {
70 	datalink_id_t		iptun_kparam_linkid;
71 	uint32_t		iptun_kparam_flags;
72 	struct sockaddr_storage	iptun_kparam_laddr;	/* local address */
73 	struct sockaddr_storage	iptun_kparam_raddr;	/* remote address */
74 	ipsec_req_t		iptun_kparam_secinfo;
75 	iptun_type_t		iptun_kparam_type;
76 	uint32_t		_iptun_kparam_padding;
77 } iptun_kparams_t;
78 
79 /* itk_flags */
80 #define	IPTUN_KPARAM_TYPE	0x00000001 /* itk_type is set */
81 #define	IPTUN_KPARAM_LADDR	0x00000002 /* itk_laddr is set */
82 #define	IPTUN_KPARAM_RADDR	0x00000004 /* itk_raddr is set */
83 #define	IPTUN_KPARAM_SECINFO	0x00000008 /* itk_secinfo is set */
84 #define	IPTUN_KPARAM_IMPLICIT	0x00000010 /* implicitly created IP tunnel */
85 #define	IPTUN_KPARAM_IPSECPOL	0x00000020 /* ipsecconf(1M) policy present */
86 
87 #ifdef	__cplusplus
88 }
89 #endif
90 
91 #endif	/* _INET_IPTUN_H */
92