]>
git.saurik.com Git - apple/network_cmds.git/blob - racoon.tproj/policy.h
27ba3fdf6ec99de8f8b8dd03b81fc9bba795dc17
1 /* $KAME: policy.h,v 1.18 2001/10/02 04:10:17 sakane Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/queue.h>
39 * Security Policy Index
40 * NOTE: Ensure to be same address family and upper layer protocol.
41 * NOTE: ul_proto, port number, uid, gid:
42 * ANY: reserved for waldcard.
43 * 0 to (~0 - 1): is one of the number of each value.
46 u_int8_t dir
; /* direction of packet flow, see blow */
47 struct sockaddr_storage src
; /* IP src address for SP */
48 struct sockaddr_storage dst
; /* IP dst address for SP */
49 u_int8_t prefs
; /* prefix length in bits for src */
50 u_int8_t prefd
; /* prefix length in bits for dst */
51 u_int16_t ul_proto
; /* upper layer Protocol */
54 /* Security Policy Data Base */
56 TAILQ_ENTRY(secpolicy
) chain
;
58 struct policyindex spidx
; /* selector */
59 u_int32_t id
; /* It's unique number on the system. */
61 u_int policy
; /* DISCARD, NONE or IPSEC, see keyv2.h */
62 struct ipsecrequest
*req
;
63 /* pointer to the ipsec request tree, */
64 /* if policy == IPSEC else this value == NULL.*/
67 /* Security Assocciation Index */
68 /* NOTE: Ensure to be same address family */
70 struct sockaddr_storage src
; /* srouce address for SA */
71 struct sockaddr_storage dst
; /* destination address for SA */
72 u_int16_t proto
; /* IPPROTO_ESP or IPPROTO_AH */
73 u_int8_t mode
; /* mode of protocol, see ipsec.h */
74 u_int32_t reqid
; /* reqid id who owned this SA */
75 /* see IPSEC_MANUAL_REQID_MAX. */
78 /* Request for IPsec */
80 struct ipsecrequest
*next
;
81 /* pointer to next structure */
82 /* If NULL, it means the end of chain. */
84 struct secasindex saidx
;/* hint for search proper SA */
85 /* if __ss_len == 0 then no address specified.*/
86 u_int level
; /* IPsec level defined below. */
88 struct secpolicy
*sp
; /* back pointer to SP */
91 #define KEY_SETSECSPIDX(_dir, s, d, ps, pd, ulp, idx) \
93 bzero((idx), sizeof(struct policyindex)); \
94 (idx)->dir = (_dir); \
95 (idx)->prefs = (ps); \
96 (idx)->prefd = (pd); \
97 (idx)->ul_proto = (ulp); \
98 memcpy(&(idx)->src, (s), ((struct sockaddr *)(s))->sa_len); \
99 memcpy(&(idx)->dst, (d), ((struct sockaddr *)(d))->sa_len); \
104 extern struct secpolicy
*getsp
__P((struct policyindex
*));
105 extern struct secpolicy
*getsp_r
__P((struct policyindex
*));
106 struct secpolicy
*getspbyspid
__P((u_int32_t
));
107 extern int cmpspidxstrict
__P((struct policyindex
*, struct policyindex
*));
108 extern int cmpspidxwild
__P((struct policyindex
*, struct policyindex
*));
109 extern struct secpolicy
*newsp
__P((void));
110 extern void delsp
__P((struct secpolicy
*));
111 extern void delsp_bothdir
__P((struct policyindex
*));
112 extern void inssp
__P((struct secpolicy
*));
113 extern void remsp
__P((struct secpolicy
*));
114 extern void flushsp
__P((void));
115 extern void initsp
__P((void));
116 extern struct ipsecrequest
*newipsecreq
__P((void));
118 extern const char *spidx2str
__P((const struct policyindex
*));
121 #endif /* __POLICY_H__ */