ipsec_info.h revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _INET_IPSEC_INFO_H
#define _INET_IPSEC_INFO_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* IPsec informational messages. These are M_CTL STREAMS messages, which
* convey IPsec information between various IP and related modules. The
* messages come in a few flavors:
*
* * IPSEC_{IN,OUT} - These show what IPsec action have been taken (for
* inbound datagrams), or need to be taken (for outbound datagrams).
*
* * Keysock consumer interface - These messages are wrappers for
*
* Some of these messages include pointers such as a netstack_t pointer.
* We do not explicitly reference count those with netstack_hold/rele,
* since we depend on IP's ability to discard all of the IPSEC_{IN,OUT}
* messages in order to handle the ipsa pointers.
* We have special logic when doing asynch callouts to kEF for which we
* verify netstack_t pointer using the netstackid_t.
*/
/*
* The IPsec M_CTL value MUST be something that will not be even close
* to an IPv4 or IPv6 header. This means the first byte must not be
* 0x40 - 0x4f or 0x60-0x6f. For big-endian machines, this is fixable with
* the IPSEC_M_CTL prefix. For little-endian machines, the actual M_CTL
* _type_ must not be in the aforementioned ranges.
*
* datagram get sent from to TCP or UDP when an ICMP datagram affects a
*/
#define IPSEC_M_CTL 0x73706900
/*
* M_CTL types for IPsec messages. Remember, the values 0x40 - 0x4f and 0x60
* - 0x6f are not to be used because of potential little-endian confusion.
*
* Offsets 1-25 (decimal) are in use, spread through this file.
* Check for duplicates through the whole file before adding.
*/
/*
* IPSEC_{IN,OUT} policy expressors.
*/
/*
* for Inbound datagrams. IPSEC_IN is allocated by IP before IPSEC
* processing begins. On return spi fields are initialized so that
* IP can locate the security associations later on for doing policy
* checks. For loopback case, IPSEC processing is not done. But the
* attributes of the security are reflected in <foo>_done fields below.
* The code in policy check infers that it is a loopback case and
* would not try to get the associations.
*
* The comment below (and for other netstack_t references) refers
* to the fact that we only do netstack_hold in particular cases,
* such as the references from open streams (ill_t and conn_t's
* pointers). Internally within IP we rely on IP's ability to cleanup e.g.
* ire_t's when an ill goes away.
*/
typedef struct ipsec_in_s {
struct ipsec_policy_head_s *ipsec_in_policy;
unsigned int
/* a matching inner packet? */
/* all should trust this. */
ipsec_in_pad_bits : 25;
int ipsec_in_ill_index; /* interface on which ipha_dst was */
/* configured when pkt was recv'd */
int ipsec_in_rill_index; /* interface on which pkt was recv'd */
/*
* For call to the kernel crypto framework. State needed during
* the execution of a crypto request. Storing these here
* allow us to avoid a separate allocation before calling the
* crypto framework.
*/
} ipsec_in_t;
/*
* for Outbound datagrams. IPSEC_OUT is allocated by IP before IPSEC
* processing begins. On return SA fields are initialized so that
* IP can locate the security associations later on for doing policy
* checks. The policy and the actions associated with this packet are
* stored in the ipsec_out_policy and ipsec_out_act fields respectively.
* IPSEC_OUT is also used to carry non-ipsec information when conn is
* absent or the conn information is lost across the calls to ARP.
* example: message from ARP or from ICMP error routines.
*/
typedef struct ipsec_out_s {
struct ipsec_policy_head_s *ipsec_out_polhead;
/*
* NOTE: "Source" and "Dest" are w.r.t. outbound datagrams. Ports can
* be zero, and the protocol number is needed to make the ports
* significant.
*/
unsigned int
/*
* Following five values reflects the values stored
* in conn.
*/
ipsec_out_dontroute : 1,
ipsec_out_reserved : 1,
ipsec_out_v4 : 1,
ipsec_out_failed: 1,
/*
* To indicate that packet must be accelerated, i.e.
* ICV or encryption performed, by Provider.
*/
/*
* Used by IP to tell IPsec that the outbound ill for this
* packet supports acceleration of the AH or ESP prototocol.
* If set, ipsec_out_capab_ill_index contains the
* index of the ill.
*/
/*
* Indicates ICMP message destined for self. These
* messages are to be trusted by all receivers.
*/
ipsec_out_pad_bits : 13;
/*
* For call to the kernel crypto framework. State needed during
* the execution of a crypto request. Storing these here
* allow us to avoid a separate allocation before calling the
* crypto framework.
*/
} ipsec_out_t;
/*
* This is used to mark the ipsec_out_t *req* fields
* when the operation is done without affecting the
* requests.
*/
#define IPSEC_REQ_DONE 0x80000000
/*
* module.
*/
#define IPSEC_REQ_FAILED 0x40000000
/*
* Keysock consumer interface.
*
* a module to 'consumers' like AH and ESP) uses keysock consumer interface
* messages to pass on PF_KEY messages to consumers who process and act upon
* them.
*/
/*
* KEYSOCK_HELLO is sent by keysock to a consumer when it is pushed on top
* of one (i.e. opened as a module).
*
* NOTE: Keysock_hello is simply an ipsec_info_t
*/
/*
* KEYSOCK_HELLO_ACK is sent by a consumer to acknowledge a KEYSOCK_HELLO.
* It contains the PF_KEYv2 sa_type, so keysock can redirect PF_KEY messages
* to the right consumer.
*/
typedef struct keysock_hello_ack_s {
#define KS_IN_ADDR_UNKNOWN 0
#define KS_IN_ADDR_NOTTHERE 1
#define KS_IN_ADDR_UNSPEC 2
#define KS_IN_ADDR_ME 3
#define KS_IN_ADDR_NOTME 4
#define KS_IN_ADDR_MBCAST 5
#define KS_IN_ADDR_DONTCARE 6
/*
* KEYSOCK_IN is a PF_KEY message from a PF_KEY socket destined for a consumer.
*/
typedef struct keysock_in_s {
/*
* NOTE: These pointers MUST be into the M_DATA that follows
* this M_CTL message. If they aren't, weirdness
* results.
*/
int ks_in_srctype; /* Source address type. */
int ks_in_dsttype; /* Dest address type. */
} keysock_in_t;
/*
* KEYSOCK_OUT is a PF_KEY message from a consumer destined for a PF_KEY
* socket.
*/
typedef struct keysock_out_s {
/*
* KEYSOCK_OUT_ERR is sent to a consumer from keysock if for some reason
* keysock could not find a PF_KEY socket to deliver a consumer-originated
* message (e.g. SADB_ACQUIRE).
*/
typedef struct keysock_out_err_s {
int ks_err_errno;
/*
* Other, richer error information may end up going here eventually.
*/
/*
* M_CTL message type for sending inbound pkt information between IP & ULP.
* These are _not_ related to IPsec in any way, but are here so that there is
* one place where all these values are defined which makes it easier to track.
* The choice of this value has the same rationale as explained above.
*/
/*
* IPSEC_CTL messages are used by IPsec to send control type requests
* to IP. Such a control message is currently used by IPsec to request
* that IP send the contents of an IPsec SA or the entire SADB to
* every IPsec hardware acceleration capable provider.
*/
typedef struct ipsec_ctl_s {
void *ipsec_ctl_sa;
} ipsec_ctl_t;
/*
* All IPsec informational messages are placed into the ipsec_info_t
* union, so that allocation can be done once, and IPsec informational
* messages can be recycled.
*/
typedef union ipsec_info_u {
struct {
} ipsec_allu;
} ipsec_info_t;
#ifdef __cplusplus
}
#endif
#endif /* _INET_IPSEC_INFO_H */