xref: /illumos-gate/usr/src/uts/common/inet/iptun.h (revision bbf21555)
12b24ab6bSSebastien Roy /*
22b24ab6bSSebastien Roy  * CDDL HEADER START
32b24ab6bSSebastien Roy  *
42b24ab6bSSebastien Roy  * The contents of this file are subject to the terms of the
52b24ab6bSSebastien Roy  * Common Development and Distribution License (the "License").
62b24ab6bSSebastien Roy  * You may not use this file except in compliance with the License.
72b24ab6bSSebastien Roy  *
82b24ab6bSSebastien Roy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92b24ab6bSSebastien Roy  * or http://www.opensolaris.org/os/licensing.
102b24ab6bSSebastien Roy  * See the License for the specific language governing permissions
112b24ab6bSSebastien Roy  * and limitations under the License.
122b24ab6bSSebastien Roy  *
132b24ab6bSSebastien Roy  * When distributing Covered Code, include this CDDL HEADER in each
142b24ab6bSSebastien Roy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152b24ab6bSSebastien Roy  * If applicable, add the following below this CDDL HEADER, with the
162b24ab6bSSebastien Roy  * fields enclosed by brackets "[]" replaced with your own identifying
172b24ab6bSSebastien Roy  * information: Portions Copyright [yyyy] [name of copyright owner]
182b24ab6bSSebastien Roy  *
192b24ab6bSSebastien Roy  * CDDL HEADER END
202b24ab6bSSebastien Roy  */
212b24ab6bSSebastien Roy /*
222b24ab6bSSebastien Roy  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
232b24ab6bSSebastien Roy  * Use is subject to license terms.
242b24ab6bSSebastien Roy  */
252b24ab6bSSebastien Roy 
262b24ab6bSSebastien Roy #ifndef	_INET_IPTUN_H
272b24ab6bSSebastien Roy #define	_INET_IPTUN_H
282b24ab6bSSebastien Roy 
292b24ab6bSSebastien Roy #include <sys/socket.h>
302b24ab6bSSebastien Roy #include <sys/types.h>
312b24ab6bSSebastien Roy #include <sys/dld_ioc.h>
322b24ab6bSSebastien Roy #include <netinet/in.h>
332b24ab6bSSebastien Roy #include <netinet/ip6.h>
342b24ab6bSSebastien Roy 
352b24ab6bSSebastien Roy #ifdef	__cplusplus
362b24ab6bSSebastien Roy extern "C" {
372b24ab6bSSebastien Roy #endif
382b24ab6bSSebastien Roy 
392b24ab6bSSebastien Roy /*
402b24ab6bSSebastien Roy  * from http://www.iana.org/assignments/ip-parameters
412b24ab6bSSebastien Roy  */
422b24ab6bSSebastien Roy #define	IPTUN_DEFAULT_HOPLIMIT		64
432b24ab6bSSebastien Roy /* from RFC 2473 */
442b24ab6bSSebastien Roy #define	IPTUN_DEFAULT_ENCAPLIMIT	4
452b24ab6bSSebastien Roy 
462b24ab6bSSebastien Roy #define	IPTUN_CREATE		IPTUNIOC(1)
472b24ab6bSSebastien Roy #define	IPTUN_DELETE		IPTUNIOC(2)
482b24ab6bSSebastien Roy #define	IPTUN_MODIFY		IPTUNIOC(3)
492b24ab6bSSebastien Roy #define	IPTUN_INFO		IPTUNIOC(4)
502b24ab6bSSebastien Roy #define	IPTUN_SET_6TO4RELAY	IPTUNIOC(9)
512b24ab6bSSebastien Roy #define	IPTUN_GET_6TO4RELAY	IPTUNIOC(10)
522b24ab6bSSebastien Roy 
532b24ab6bSSebastien Roy typedef enum {
542b24ab6bSSebastien Roy 	IPTUN_TYPE_UNKNOWN = 0,
552b24ab6bSSebastien Roy 	IPTUN_TYPE_IPV4,
562b24ab6bSSebastien Roy 	IPTUN_TYPE_IPV6,
572b24ab6bSSebastien Roy 	IPTUN_TYPE_6TO4
582b24ab6bSSebastien Roy } iptun_type_t;
592b24ab6bSSebastien Roy 
602b24ab6bSSebastien Roy /*
612b24ab6bSSebastien Roy  * To maintain proper alignment of fields between 32bit user-land and 64bit
622b24ab6bSSebastien Roy  * kernel, all fields in iptun_kparams_t after itk_fields must be in
632b24ab6bSSebastien Roy  * descending order of size.  Due to strict structure size checks done in the
642b24ab6bSSebastien Roy  * iptun ioctl processing, the structure size must be the same on 32 and 64
652b24ab6bSSebastien Roy  * bit.  amd64 will pad the end of the structure to make the end 64bit
662b24ab6bSSebastien Roy  * aligned, so we must add explicit padding to make sure that it's similarly
672b24ab6bSSebastien Roy  * aligned when compiled in 32 bit mode.
682b24ab6bSSebastien Roy  */
692b24ab6bSSebastien Roy typedef struct iptun_kparams {
702b24ab6bSSebastien Roy 	datalink_id_t		iptun_kparam_linkid;
712b24ab6bSSebastien Roy 	uint32_t		iptun_kparam_flags;
722b24ab6bSSebastien Roy 	struct sockaddr_storage	iptun_kparam_laddr;	/* local address */
732b24ab6bSSebastien Roy 	struct sockaddr_storage	iptun_kparam_raddr;	/* remote address */
742b24ab6bSSebastien Roy 	ipsec_req_t		iptun_kparam_secinfo;
752b24ab6bSSebastien Roy 	iptun_type_t		iptun_kparam_type;
762b24ab6bSSebastien Roy 	uint32_t		_iptun_kparam_padding;
772b24ab6bSSebastien Roy } iptun_kparams_t;
782b24ab6bSSebastien Roy 
792b24ab6bSSebastien Roy /* itk_flags */
802b24ab6bSSebastien Roy #define	IPTUN_KPARAM_TYPE	0x00000001 /* itk_type is set */
812b24ab6bSSebastien Roy #define	IPTUN_KPARAM_LADDR	0x00000002 /* itk_laddr is set */
822b24ab6bSSebastien Roy #define	IPTUN_KPARAM_RADDR	0x00000004 /* itk_raddr is set */
832b24ab6bSSebastien Roy #define	IPTUN_KPARAM_SECINFO	0x00000008 /* itk_secinfo is set */
842b24ab6bSSebastien Roy #define	IPTUN_KPARAM_IMPLICIT	0x00000010 /* implicitly created IP tunnel */
85*bbf21555SRichard Lowe #define	IPTUN_KPARAM_IPSECPOL	0x00000020 /* ipsecconf(8) policy present */
862b24ab6bSSebastien Roy 
872b24ab6bSSebastien Roy #ifdef	__cplusplus
882b24ab6bSSebastien Roy }
892b24ab6bSSebastien Roy #endif
902b24ab6bSSebastien Roy 
912b24ab6bSSebastien Roy #endif	/* _INET_IPTUN_H */
92