]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netipsec/key.h
Import tzdata 2019c.
[FreeBSD/FreeBSD.git] / sys / netipsec / key.h
1 /*      $FreeBSD$       */
2 /*      $KAME: key.h,v 1.21 2001/07/27 03:51:30 itojun Exp $    */
3
4 /*-
5  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the project nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32
33 #ifndef _NETIPSEC_KEY_H_
34 #define _NETIPSEC_KEY_H_
35
36 #ifdef _KERNEL
37
38 struct secpolicy;
39 struct secpolicyindex;
40 struct secasvar;
41 struct sockaddr;
42 struct socket;
43 struct sadb_msg;
44 struct sadb_x_policy;
45 struct secasindex;
46 union sockaddr_union;
47
48 struct secpolicy *key_newsp(void);
49 struct secpolicy *key_allocsp(struct secpolicyindex *, u_int);
50 struct secpolicy *key_msg2sp(struct sadb_x_policy *, size_t, int *);
51 int key_sp2msg(struct secpolicy *, void *, size_t *);
52 void key_addref(struct secpolicy *);
53 void key_freesp(struct secpolicy **);
54 int key_spdacquire(struct secpolicy *);
55 int key_havesp(u_int);
56 void key_bumpspgen(void);
57 uint32_t key_getspgen(void);
58 uint32_t key_newreqid(void);
59
60 struct secasvar *key_allocsa(union sockaddr_union *, uint8_t, uint32_t);
61 struct secasvar *key_allocsa_tunnel(union sockaddr_union *,
62     union sockaddr_union *, uint8_t);
63 struct secasvar *key_allocsa_policy(struct secpolicy *,
64     const struct secasindex *, int *);
65 struct secasvar *key_allocsa_tcpmd5(struct secasindex *);
66 void key_freesav(struct secasvar **);
67
68 int key_sockaddrcmp(const struct sockaddr *, const struct sockaddr *, int);
69 int key_sockaddrcmp_withmask(const struct sockaddr *, const struct sockaddr *,
70     size_t);
71
72 int key_register_ifnet(struct secpolicy **, u_int);
73 void key_unregister_ifnet(struct secpolicy **, u_int);
74
75 extern u_long key_random(void);
76 extern void key_randomfill(void *, size_t);
77 extern void key_freereg(struct socket *);
78 extern int key_parse(struct mbuf *, struct socket *);
79 extern void key_init(void);
80 #ifdef VIMAGE
81 extern void key_destroy(void);
82 #endif
83 extern void key_sa_recordxfer(struct secasvar *, struct mbuf *);
84 uint16_t key_portfromsaddr(struct sockaddr *);
85 void key_porttosaddr(struct sockaddr *, uint16_t port);
86
87 #ifdef MALLOC_DECLARE
88 MALLOC_DECLARE(M_IPSEC_SA);
89 MALLOC_DECLARE(M_IPSEC_SAH);
90 MALLOC_DECLARE(M_IPSEC_SP);
91 MALLOC_DECLARE(M_IPSEC_SR);
92 MALLOC_DECLARE(M_IPSEC_MISC);
93 MALLOC_DECLARE(M_IPSEC_SAQ);
94 MALLOC_DECLARE(M_IPSEC_SAR);
95 MALLOC_DECLARE(M_IPSEC_INPCB);
96 #endif /* MALLOC_DECLARE */
97
98 #endif /* defined(_KERNEL) */
99 #endif /* _NETIPSEC_KEY_H_ */