2 * Copyright (c) 2012 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_DTLS_H_
30 #define _NET_IF_UTUN_CRYPTO_DTLS_H_
32 #define UTUN_CRYPTO_DTLS_HANDLE_INVALID -1
36 #include <sys/systm.h>
37 #include <sys/socket.h>
39 #include <net/if_types.h>
41 #include <netinet/in.h>
42 #include <netinet6/in6_var.h>
43 #include <netinet6/in6_var.h>
44 #include <netinet/ip.h>
45 #include <netinet/ip6.h>
46 #include <netinet/ip_var.h>
47 #include <net/if_utun.h>
48 #include <net/if_utun_crypto.h>
49 #include <sys/kernel_types.h>
50 #include <net/kpi_interface.h>
52 #define utun_cleanup_all_crypto_dtls(pcb) utun_ctl_disable_crypto_dtls(pcb)
55 * Summary: initializes global vars needed for any utun crypto based on dtls
58 utun_ctl_init_crypto_dtls(void);
61 utun_ctl_register_dtls (utun_crypto_kpi_reg_t
*reg
);
64 * Summary: disables all crypto DTLS in one shot
67 utun_cleanup_all_crypto_dtls (struct utun_pcb
*pcb
);
70 * Summary: enables dtls crypto info for the specified utun. dtls ref is passed into args.
73 utun_ctl_enable_crypto_dtls(struct utun_pcb
*pcb
, utun_crypto_args_t
*args
);
76 * Summary: disables ipsec crypto info for the specified utun.
79 utun_ctl_disable_crypto_dtls(struct utun_pcb
*pcb
);
82 utun_ctl_config_crypto_dtls_framer(utun_crypto_ctx_t
*crypto_ctx
, utun_crypto_framer_args_t
*args
);
85 utun_ctl_unconfig_crypto_dtls_framer(utun_crypto_ctx_t
*crypto_ctx
, utun_crypto_framer_args_t
*args
);
88 * Summary: enables handling of data traffic
91 utun_ctl_start_datatraffic_crypto_dtls(struct utun_pcb
*pcb
);
94 * Summary: disables handling of data traffic
97 utun_ctl_stop_datatraffic_crypto_dtls(struct utun_pcb
*pcb
);
100 utun_pkt_dtls_output(struct utun_pcb
*pcb
, mbuf_t
*pkt
);
103 utun_pkt_dtls_input(struct utun_pcb
*pcb
, mbuf_t
*pkt
, protocol_family_t family
);
105 static inline protocol_family_t
106 utun_crypto_framer_inner_type_to_protocol_family (utun_crypto_framer_inner_type_t type
)
108 if (type
== UTUN_CRYPTO_INNER_TYPE_IPv4
) {
115 static inline utun_crypto_framer_inner_type_t
116 utun_crypto_framer_protocol_family_to_inner_type (protocol_family_t family
)
118 if (family
== PF_INET
) {
119 return UTUN_CRYPTO_INNER_TYPE_IPv4
;
121 return UTUN_CRYPTO_INNER_TYPE_IPv6
;
125 #endif // KERNEL_PRIVATE
127 #endif // _NET_IF_UTUN_CRYPTO_DTLS_H_