xref: /titanic_51/usr/src/uts/common/inet/ipsec_info.h (revision bd670b35a010421b6e1a5536c34453a827007c81)
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
58810c16bSdanmcd  * Common Development and Distribution License (the "License").
68810c16bSdanmcd  * 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 /*
22e11c3f44Smeem  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_INET_IPSEC_INFO_H
277c478bd9Sstevel@tonic-gate #define	_INET_IPSEC_INFO_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/crypto/common.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * IPsec informational messages.  These are M_CTL STREAMS messages, which
37*bd670b35SErik Nordmark  * convey IPsec information between various IP and related modules.  Most
38*bd670b35SErik Nordmark  * have been deprecated by the de-STREAMS-ing of TCP/IP.  What remains is:
397c478bd9Sstevel@tonic-gate  *
407c478bd9Sstevel@tonic-gate  *	* Keysock consumer interface  -  These messages are wrappers for
417c478bd9Sstevel@tonic-gate  *	  PF_KEY messages.  They flow between AH/ESP and keysock.
42f4b3ec61Sdh155122  *
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * The IPsec M_CTL value MUST be something that will not be even close
477c478bd9Sstevel@tonic-gate  * to an IPv4 or IPv6 header.  This means the first byte must not be
487c478bd9Sstevel@tonic-gate  * 0x40 - 0x4f or 0x60-0x6f.  For big-endian machines, this is fixable with
497c478bd9Sstevel@tonic-gate  * the IPSEC_M_CTL prefix.  For little-endian machines, the actual M_CTL
507c478bd9Sstevel@tonic-gate  * _type_ must not be in the aforementioned ranges.
517c478bd9Sstevel@tonic-gate  *
527c478bd9Sstevel@tonic-gate  * The reason for this avoidance is because M_CTL's with a real IPv4/IPv6
537c478bd9Sstevel@tonic-gate  * datagram get sent from to TCP or UDP when an ICMP datagram affects a
547c478bd9Sstevel@tonic-gate  * TCP/UDP session.
557c478bd9Sstevel@tonic-gate  */
56a86080f9Sdanmcd #define	IPSEC_M_CTL	0x73706900
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  * M_CTL types for IPsec messages.  Remember, the values 0x40 - 0x4f and 0x60
607c478bd9Sstevel@tonic-gate  * - 0x6f are not to be used because of potential little-endian confusion.
617c478bd9Sstevel@tonic-gate  *
62*bd670b35SErik Nordmark  * Offsets 3-7 (decimal) are in use, spread through this file.
637c478bd9Sstevel@tonic-gate  * Check for duplicates through the whole file before adding.
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * Keysock consumer interface.
687c478bd9Sstevel@tonic-gate  *
697c478bd9Sstevel@tonic-gate  * The driver/module keysock (which is a driver to PF_KEY sockets, but is
707c478bd9Sstevel@tonic-gate  * a module to 'consumers' like AH and ESP) uses keysock consumer interface
717c478bd9Sstevel@tonic-gate  * messages to pass on PF_KEY messages to consumers who process and act upon
727c478bd9Sstevel@tonic-gate  * them.
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate #define	KEYSOCK_IN		(IPSEC_M_CTL + 3)
757c478bd9Sstevel@tonic-gate #define	KEYSOCK_OUT		(IPSEC_M_CTL + 4)
767c478bd9Sstevel@tonic-gate #define	KEYSOCK_OUT_ERR		(IPSEC_M_CTL + 5)
777c478bd9Sstevel@tonic-gate #define	KEYSOCK_HELLO		(IPSEC_M_CTL + 6)
787c478bd9Sstevel@tonic-gate #define	KEYSOCK_HELLO_ACK	(IPSEC_M_CTL + 7)
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * KEYSOCK_HELLO is sent by keysock to a consumer when it is pushed on top
827c478bd9Sstevel@tonic-gate  * of one (i.e. opened as a module).
837c478bd9Sstevel@tonic-gate  *
847c478bd9Sstevel@tonic-gate  * NOTE: Keysock_hello is simply an ipsec_info_t
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * KEYSOCK_HELLO_ACK is sent by a consumer to acknowledge a KEYSOCK_HELLO.
897c478bd9Sstevel@tonic-gate  * It contains the PF_KEYv2 sa_type, so keysock can redirect PF_KEY messages
907c478bd9Sstevel@tonic-gate  * to the right consumer.
917c478bd9Sstevel@tonic-gate  */
927c478bd9Sstevel@tonic-gate typedef struct keysock_hello_ack_s {
937c478bd9Sstevel@tonic-gate 	uint32_t ks_hello_type;
947c478bd9Sstevel@tonic-gate 	uint32_t ks_hello_len;
957c478bd9Sstevel@tonic-gate 	uint8_t ks_hello_satype;	/* PF_KEYv2 sa_type of ks client */
967c478bd9Sstevel@tonic-gate } keysock_hello_ack_t;
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #define	KS_IN_ADDR_UNKNOWN 0
997c478bd9Sstevel@tonic-gate #define	KS_IN_ADDR_NOTTHERE 1
1007c478bd9Sstevel@tonic-gate #define	KS_IN_ADDR_UNSPEC 2
1017c478bd9Sstevel@tonic-gate #define	KS_IN_ADDR_ME 3
1027c478bd9Sstevel@tonic-gate #define	KS_IN_ADDR_NOTME 4
1037c478bd9Sstevel@tonic-gate #define	KS_IN_ADDR_MBCAST 5
1048810c16bSdanmcd #define	KS_IN_ADDR_DONTCARE 6
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  * KEYSOCK_IN is a PF_KEY message from a PF_KEY socket destined for a consumer.
1087c478bd9Sstevel@tonic-gate  */
1097c478bd9Sstevel@tonic-gate typedef struct keysock_in_s {
1107c478bd9Sstevel@tonic-gate 	uint32_t ks_in_type;
1117c478bd9Sstevel@tonic-gate 	uint32_t ks_in_len;
1127c478bd9Sstevel@tonic-gate 	/*
1137c478bd9Sstevel@tonic-gate 	 * NOTE:	These pointers MUST be into the M_DATA that follows
1147c478bd9Sstevel@tonic-gate 	 *		this M_CTL message.  If they aren't, weirdness
1157c478bd9Sstevel@tonic-gate 	 *		results.
1167c478bd9Sstevel@tonic-gate 	 */
1177c478bd9Sstevel@tonic-gate 	struct sadb_ext *ks_in_extv[SADB_EXT_MAX + 1];
1187c478bd9Sstevel@tonic-gate 	int ks_in_srctype;	/* Source address type. */
1197c478bd9Sstevel@tonic-gate 	int ks_in_dsttype;	/* Dest address type. */
1207c478bd9Sstevel@tonic-gate 	minor_t ks_in_serial;	/* Serial # of sending socket. */
1217c478bd9Sstevel@tonic-gate } keysock_in_t;
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate /*
1247c478bd9Sstevel@tonic-gate  * KEYSOCK_OUT is a PF_KEY message from a consumer destined for a PF_KEY
1257c478bd9Sstevel@tonic-gate  * socket.
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate typedef struct keysock_out_s {
1287c478bd9Sstevel@tonic-gate 	uint32_t ks_out_type;
1297c478bd9Sstevel@tonic-gate 	uint32_t ks_out_len;
1307c478bd9Sstevel@tonic-gate 	minor_t ks_out_serial;	/* Serial # of sending socket. */
1317c478bd9Sstevel@tonic-gate } keysock_out_t;
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /*
1347c478bd9Sstevel@tonic-gate  * KEYSOCK_OUT_ERR is sent to a consumer from keysock if for some reason
1357c478bd9Sstevel@tonic-gate  * keysock could not find a PF_KEY socket to deliver a consumer-originated
1367c478bd9Sstevel@tonic-gate  * message (e.g. SADB_ACQUIRE).
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate typedef struct keysock_out_err_s {
1397c478bd9Sstevel@tonic-gate 	uint32_t ks_err_type;
1407c478bd9Sstevel@tonic-gate 	uint32_t ks_err_len;
1417c478bd9Sstevel@tonic-gate 	minor_t ks_err_serial;
1427c478bd9Sstevel@tonic-gate 	int ks_err_errno;
1437c478bd9Sstevel@tonic-gate 	/*
1447c478bd9Sstevel@tonic-gate 	 * Other, richer error information may end up going here eventually.
1457c478bd9Sstevel@tonic-gate 	 */
1467c478bd9Sstevel@tonic-gate } keysock_out_err_t;
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * All IPsec informational messages are placed into the ipsec_info_t
1507c478bd9Sstevel@tonic-gate  * union, so that allocation can be done once, and IPsec informational
1517c478bd9Sstevel@tonic-gate  * messages can be recycled.
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate typedef union ipsec_info_u {
1547c478bd9Sstevel@tonic-gate 	struct {
1557c478bd9Sstevel@tonic-gate 		uint32_t ipsec_allu_type;
1567c478bd9Sstevel@tonic-gate 		uint32_t ipsec_allu_len;	/* In bytes */
1577c478bd9Sstevel@tonic-gate 	} ipsec_allu;
1587c478bd9Sstevel@tonic-gate 	keysock_hello_ack_t keysock_hello_ack;
1597c478bd9Sstevel@tonic-gate 	keysock_in_t keysock_in;
1607c478bd9Sstevel@tonic-gate 	keysock_out_t keysock_out;
1617c478bd9Sstevel@tonic-gate 	keysock_out_err_t keysock_out_err;
1627c478bd9Sstevel@tonic-gate } ipsec_info_t;
1637c478bd9Sstevel@tonic-gate #define	ipsec_info_type ipsec_allu.ipsec_allu_type
1647c478bd9Sstevel@tonic-gate #define	ipsec_info_len ipsec_allu.ipsec_allu_len
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1677c478bd9Sstevel@tonic-gate }
1687c478bd9Sstevel@tonic-gate #endif
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate #endif	/* _INET_IPSEC_INFO_H */
171