xref: /xnu-11417.140.69/bsd/netkey/key.h (revision 43a90889846e00bfb5cf1d255cdc0a701a1e05a4)
1*43a90889SApple OSS Distributions /*	$KAME: key.h,v 1.11 2000/03/25 07:24:12 sumikawa Exp $	*/
2*43a90889SApple OSS Distributions 
3*43a90889SApple OSS Distributions /*
4*43a90889SApple OSS Distributions  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5*43a90889SApple OSS Distributions  * All rights reserved.
6*43a90889SApple OSS Distributions  *
7*43a90889SApple OSS Distributions  * Redistribution and use in source and binary forms, with or without
8*43a90889SApple OSS Distributions  * modification, are permitted provided that the following conditions
9*43a90889SApple OSS Distributions  * are met:
10*43a90889SApple OSS Distributions  * 1. Redistributions of source code must retain the above copyright
11*43a90889SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer.
12*43a90889SApple OSS Distributions  * 2. Redistributions in binary form must reproduce the above copyright
13*43a90889SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer in the
14*43a90889SApple OSS Distributions  *    documentation and/or other materials provided with the distribution.
15*43a90889SApple OSS Distributions  * 3. Neither the name of the project nor the names of its contributors
16*43a90889SApple OSS Distributions  *    may be used to endorse or promote products derived from this software
17*43a90889SApple OSS Distributions  *    without specific prior written permission.
18*43a90889SApple OSS Distributions  *
19*43a90889SApple OSS Distributions  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20*43a90889SApple OSS Distributions  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21*43a90889SApple OSS Distributions  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22*43a90889SApple OSS Distributions  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23*43a90889SApple OSS Distributions  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24*43a90889SApple OSS Distributions  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25*43a90889SApple OSS Distributions  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26*43a90889SApple OSS Distributions  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27*43a90889SApple OSS Distributions  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28*43a90889SApple OSS Distributions  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29*43a90889SApple OSS Distributions  * SUCH DAMAGE.
30*43a90889SApple OSS Distributions  */
31*43a90889SApple OSS Distributions 
32*43a90889SApple OSS Distributions #ifndef _NETKEY_KEY_H_
33*43a90889SApple OSS Distributions #define _NETKEY_KEY_H_
34*43a90889SApple OSS Distributions #include <sys/appleapiopts.h>
35*43a90889SApple OSS Distributions 
36*43a90889SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE
37*43a90889SApple OSS Distributions 
38*43a90889SApple OSS Distributions #define KEY_SADB_UNLOCKED       0
39*43a90889SApple OSS Distributions #define KEY_SADB_LOCKED         1
40*43a90889SApple OSS Distributions 
41*43a90889SApple OSS Distributions extern struct key_cb key_cb;
42*43a90889SApple OSS Distributions extern lck_mtx_t sadb_mutex_data;
43*43a90889SApple OSS Distributions #define sadb_mutex (&sadb_mutex_data)
44*43a90889SApple OSS Distributions 
45*43a90889SApple OSS Distributions struct secpolicy;
46*43a90889SApple OSS Distributions struct secpolicyindex;
47*43a90889SApple OSS Distributions struct ipsecrequest;
48*43a90889SApple OSS Distributions struct secasvar;
49*43a90889SApple OSS Distributions struct sockaddr;
50*43a90889SApple OSS Distributions struct socket;
51*43a90889SApple OSS Distributions struct sadb_msg;
52*43a90889SApple OSS Distributions struct sadb_x_policy;
53*43a90889SApple OSS Distributions struct secasindex;
54*43a90889SApple OSS Distributions struct secashead;
55*43a90889SApple OSS Distributions struct sadb_key;
56*43a90889SApple OSS Distributions struct sadb_lifetime;
57*43a90889SApple OSS Distributions 
58*43a90889SApple OSS Distributions extern struct secpolicy *key_allocsp(struct secpolicyindex *, u_int);
59*43a90889SApple OSS Distributions extern struct secasvar *key_allocsa_policy(struct secasindex *);
60*43a90889SApple OSS Distributions extern struct secpolicy *key_gettunnel(struct sockaddr *,
61*43a90889SApple OSS Distributions     struct sockaddr *, struct sockaddr *, struct sockaddr *);
62*43a90889SApple OSS Distributions extern struct secasvar *key_alloc_outbound_sav_for_interface(ifnet_t interface, int family,
63*43a90889SApple OSS Distributions     struct sockaddr *src,
64*43a90889SApple OSS Distributions     struct sockaddr *dst);
65*43a90889SApple OSS Distributions extern int key_checkrequest(struct ipsecrequest *isr, struct secasindex *,
66*43a90889SApple OSS Distributions     struct secasvar **sav);
67*43a90889SApple OSS Distributions struct secasvar *key_allocsa(union sockaddr_in_4_6 *src, union sockaddr_in_4_6 *dst,
68*43a90889SApple OSS Distributions     u_int proto, u_int32_t spi, ifnet_t interface);
69*43a90889SApple OSS Distributions extern bool key_checksa_present(union sockaddr_in_4_6 *src, union sockaddr_in_4_6 *dst);
70*43a90889SApple OSS Distributions extern u_int16_t key_natt_get_translated_port(struct secasvar *);
71*43a90889SApple OSS Distributions extern void key_freesp(struct secpolicy *, int);
72*43a90889SApple OSS Distributions extern void key_freesav(struct secasvar *, int);
73*43a90889SApple OSS Distributions extern struct secpolicy *key_newsp(void);
74*43a90889SApple OSS Distributions extern struct secpolicy *key_msg2sp(struct sadb_x_policy *__sized_by(len), size_t len, int *);
75*43a90889SApple OSS Distributions extern struct mbuf *key_sp2msg(struct secpolicy *);
76*43a90889SApple OSS Distributions extern int key_ismyaddr(struct sockaddr *);
77*43a90889SApple OSS Distributions extern int key_spdacquire(struct secpolicy *);
78*43a90889SApple OSS Distributions extern void key_timehandler(void);
79*43a90889SApple OSS Distributions extern u_int32_t key_random(void);
80*43a90889SApple OSS Distributions extern void key_randomfill(void *, size_t);
81*43a90889SApple OSS Distributions extern void key_freereg(struct socket *);
82*43a90889SApple OSS Distributions extern int key_parse(struct mbuf *, struct socket *);
83*43a90889SApple OSS Distributions extern int key_checktunnelsanity(struct secasvar *, u_int, caddr_t, caddr_t);
84*43a90889SApple OSS Distributions extern void key_sa_recordxfer(struct secasvar *, size_t);
85*43a90889SApple OSS Distributions extern void key_sa_routechange(struct sockaddr *);
86*43a90889SApple OSS Distributions extern void key_sa_chgstate(struct secasvar *, u_int8_t);
87*43a90889SApple OSS Distributions extern void key_sa_stir_iv(struct secasvar *);
88*43a90889SApple OSS Distributions extern void key_delsah(struct secashead *sah);
89*43a90889SApple OSS Distributions extern struct secashead *key_newsah2(struct secasindex *saidx, u_int8_t dir);
90*43a90889SApple OSS Distributions extern void key_delsav(struct secasvar *sav);
91*43a90889SApple OSS Distributions extern struct secpolicy *key_getspbyid(u_int32_t);
92*43a90889SApple OSS Distributions extern void key_delsp_for_ipsec_if(ifnet_t ipsec_if);
93*43a90889SApple OSS Distributions 
94*43a90889SApple OSS Distributions struct ifnet;
95*43a90889SApple OSS Distributions struct ifnet_keepalive_offload_frame;
96*43a90889SApple OSS Distributions extern u_int32_t key_fill_offload_frames_for_savs(struct ifnet *,
97*43a90889SApple OSS Distributions     struct ifnet_keepalive_offload_frame *__counted_by(frames_count)frames_array, u_int32_t frames_count, size_t);
98*43a90889SApple OSS Distributions 
99*43a90889SApple OSS Distributions extern bool key_custom_ipsec_token_is_valid(void *);
100*43a90889SApple OSS Distributions extern int key_reserve_custom_ipsec(void **, union sockaddr_in_4_6 *, union sockaddr_in_4_6 *, u_int8_t proto);
101*43a90889SApple OSS Distributions extern void key_release_custom_ipsec(void **);
102*43a90889SApple OSS Distributions 
103*43a90889SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */
104*43a90889SApple OSS Distributions #endif /* _NETKEY_KEY_H_ */
105