2 * Copyright (c) 2011 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _NET_IF_UTUN_CRYPTO_IPSEC_H_
30 #define _NET_IF_UTUN_CRYPTO_IPSEC_H_
36 #define UTUN_CRYPTO_DIR_TO_IPSEC_DIR(dir) (dir == UTUN_CRYPTO_DIR_IN)? IPSEC_DIR_INBOUND : IPSEC_DIR_OUTBOUND
37 #define IF_UTUN_GET_TX_CRYPTO_KEYS(pcb) LIST_FIRST(&pcb->utun_crypto_ctx[UTUN_CRYPTO_DIR_TO_IDX(UTUN_CRYPTO_DIR_OUT)].keys_listhead)
38 #define IF_UTUN_GET_CRYPTO_KEYS_IPSEC_SAH(keys) keys->state.u.ipsec.sah
39 #define IF_UTUN_GET_CRYPTO_KEYS_IPSEC_SAV(keys) keys->state.u.ipsec.sav
42 * Summary: cleans up all crypto info for the specified utun.
45 utun_cleanup_all_crypto_ipsec(struct utun_pcb
*pcb
);
48 * Summary: enables ipsec crypto info for the specified utun.
51 utun_ctl_enable_crypto_ipsec(struct utun_pcb
*pcb
, utun_crypto_args_t
*args
);
54 * Summary: disables ipsec crypto info for the specified utun.
57 utun_ctl_disable_crypto_ipsec(struct utun_pcb
*pcb
);
60 * Summary: configures an ipsec crypto context for the specified utun, with keying material
61 * (needed for traffic encrypt/decrypt).
63 * pcb - the specified utun state info
64 * args - the ipsec crypto context keying arguments as passed down from userland.
65 * crypto_ctx_mat - the ipsec crypto context's keying material to be filled.
66 * Returns: 0 if successful, otherwise returns an appropriate errno.
69 utun_ctl_config_crypto_keys_ipsec(struct utun_pcb
*pcb
,
70 utun_crypto_keys_args_t
*args
,
71 utun_crypto_keys_t
*crypto_ctx_mat
);
74 * Summary: unconfigures the keying material in an ipsec crypto context for the specified utun.
76 * args - the ipsec crypto context keying arguments as passed down from userland.
77 * crypto_ctx_mat - the ipsec crypto context's keying material to be filled.
78 * Returns: 0 if successful, otherwise returns an appropriate errno.
81 utun_ctl_unconfig_crypto_keys_ipsec(utun_crypto_keys_args_t
*args
,
82 utun_crypto_keys_t
*crypto_ctx_mat
);
85 * Summary: generates an SPI/index to be using by keying material in an ipsec crypto context
86 * for the specified utun.
88 * args - the ipsec crypto context key index arguments as passed down from userland.
89 * Returns: 0 if successful, otherwise returns an appropriate errno.
92 utun_ctl_generate_crypto_keys_idx_ipsec(utun_crypto_keys_idx_args_t
*args
);
95 utun_pkt_ipsec_output(struct utun_pcb
*pcb
, mbuf_t
*pkt
);
98 utun_pkt_is_ipsec_keepalive(struct utun_pcb
*pcb
, mbuf_t
*pkt
, u_int16_t nxt
, u_int32_t flags
, size_t off
);
101 utun_pkt_ipsec_input(struct utun_pcb
*pcb
, mbuf_t
*pkt
, protocol_family_t family
);
103 #endif // KERNEL_PRIVATE
105 #endif // _NET_IF_UTUN_CRYPTO_IPSEC_H_