]>
git.saurik.com Git - apple/ipsec.git/blob - ipsec-tools/racoon/policy.h
1 /* $Id: policy.h,v 1.5 2004/06/11 16:00:17 ludvigm 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 "racoon_types.h"
36 #include <sys/queue.h>
40 * Security Policy Index
41 * NOTE: Ensure to be same address family and upper layer protocol.
42 * NOTE: ul_proto, port number, uid, gid:
43 * ANY: reserved for waldcard.
44 * 0 to (~0 - 1): is one of the number of each value.
47 u_int8_t dir
; /* direction of packet flow, see blow */
48 struct sockaddr_storage src
; /* IP src address for SP */
49 struct sockaddr_storage dst
; /* IP dst address for SP */
50 u_int8_t prefs
; /* prefix length in bits for src */
51 u_int8_t prefd
; /* prefix length in bits for dst */
52 u_int16_t ul_proto
; /* upper layer Protocol */
53 u_int32_t priority
; /* priority for the policy */
56 /* Security Policy Data Base */
58 TAILQ_ENTRY(secpolicy
) chain
;
60 struct policyindex spidx
; /* selector */
61 u_int32_t id
; /* It's unique number on the system. */
63 u_int policy
; /* DISCARD, NONE or IPSEC, see keyv2.h */
64 struct ipsecrequest
*req
;
65 /* pointer to the ipsec request tree, */
66 /* if policy == IPSEC else this value == NULL.*/
69 /* Security Assocciation Index */
70 /* NOTE: Ensure to be same address family */
72 struct sockaddr_storage src
; /* srouce address for SA */
73 struct sockaddr_storage dst
; /* destination address for SA */
74 u_int16_t proto
; /* IPPROTO_ESP or IPPROTO_AH */
75 u_int8_t mode
; /* mode of protocol, see ipsec.h */
76 u_int32_t reqid
; /* reqid id who owned this SA */
77 /* see IPSEC_MANUAL_REQID_MAX. */
80 /* Request for IPsec */
82 struct ipsecrequest
*next
;
83 /* pointer to next structure */
84 /* If NULL, it means the end of chain. */
86 struct secasindex saidx
;/* hint for search proper SA */
87 /* if __ss_len == 0 then no address specified.*/
88 u_int level
; /* IPsec level defined below. */
90 struct secpolicy
*sp
; /* back pointer to SP */
93 #ifdef HAVE_PFKEY_POLICY_PRIORITY
94 #define KEY_SETSECSPIDX(_dir, s, d, ps, pd, ulp, _priority, idx) \
96 bzero((idx), sizeof(struct policyindex)); \
97 (idx)->dir = (_dir); \
98 (idx)->prefs = (ps); \
99 (idx)->prefd = (pd); \
100 (idx)->ul_proto = (ulp); \
101 (idx)->priority = (_priority); \
102 memcpy(&(idx)->src, (s), sysdep_sa_len((struct sockaddr *)(s))); \
103 memcpy(&(idx)->dst, (d), sysdep_sa_len((struct sockaddr *)(d))); \
106 #define KEY_SETSECSPIDX(_dir, s, d, ps, pd, ulp, idx) \
108 bzero((idx), sizeof(struct policyindex)); \
109 (idx)->dir = (_dir); \
110 (idx)->prefs = (ps); \
111 (idx)->prefd = (pd); \
112 (idx)->ul_proto = (ulp); \
113 memcpy(&(idx)->src, (s), sysdep_sa_len((struct sockaddr *)(s))); \
114 memcpy(&(idx)->dst, (d), sysdep_sa_len((struct sockaddr *)(d))); \
120 extern struct secpolicy
*getsp (struct policyindex
*);
121 extern struct secpolicy
*getsp_r (struct policyindex
*, phase2_handle_t
*);
122 struct secpolicy
*getspbyspid (u_int32_t
);
123 extern int cmpspidxstrict (struct policyindex
*, struct policyindex
*);
124 extern int cmpspidxwild (struct policyindex
*, struct policyindex
*);
125 extern struct secpolicy
*newsp (void);
126 extern void delsp (struct secpolicy
*);
127 extern void delsp_bothdir (struct policyindex
*);
128 extern void inssp (struct secpolicy
*);
129 extern void remsp (struct secpolicy
*);
130 extern void flushsp (void);
131 extern void initsp (void);
132 extern struct ipsecrequest
*newipsecreq (void);
133 extern int policies_installed (void);
135 extern const char *spidx2str (const struct policyindex
*);
137 #endif /* _POLICY_H */