]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX_XFRM_H |
2 | #define _LINUX_XFRM_H | |
3 | ||
4 | #include <linux/types.h> | |
5 | ||
6 | /* All of the structures in this file may not change size as they are | |
7 | * passed into the kernel from userspace via netlink sockets. | |
8 | */ | |
9 | ||
10 | /* Structure to encapsulate addresses. I do not want to use | |
11 | * "standard" structure. My apologies. | |
12 | */ | |
13 | typedef union | |
14 | { | |
15 | __u32 a4; | |
16 | __u32 a6[4]; | |
17 | } xfrm_address_t; | |
18 | ||
19 | /* Ident of a specific xfrm_state. It is used on input to lookup | |
20 | * the state by (spi,daddr,ah/esp) or to store information about | |
21 | * spi, protocol and tunnel address on output. | |
22 | */ | |
23 | struct xfrm_id | |
24 | { | |
25 | xfrm_address_t daddr; | |
26 | __u32 spi; | |
27 | __u8 proto; | |
28 | }; | |
29 | ||
30 | /* Selector, used as selector both on policy rules (SPD) and SAs. */ | |
31 | ||
32 | struct xfrm_selector | |
33 | { | |
34 | xfrm_address_t daddr; | |
35 | xfrm_address_t saddr; | |
36 | __u16 dport; | |
37 | __u16 dport_mask; | |
38 | __u16 sport; | |
39 | __u16 sport_mask; | |
40 | __u16 family; | |
41 | __u8 prefixlen_d; | |
42 | __u8 prefixlen_s; | |
43 | __u8 proto; | |
44 | int ifindex; | |
45 | uid_t user; | |
46 | }; | |
47 | ||
48 | #define XFRM_INF (~(__u64)0) | |
49 | ||
50 | struct xfrm_lifetime_cfg | |
51 | { | |
52 | __u64 soft_byte_limit; | |
53 | __u64 hard_byte_limit; | |
54 | __u64 soft_packet_limit; | |
55 | __u64 hard_packet_limit; | |
56 | __u64 soft_add_expires_seconds; | |
57 | __u64 hard_add_expires_seconds; | |
58 | __u64 soft_use_expires_seconds; | |
59 | __u64 hard_use_expires_seconds; | |
60 | }; | |
61 | ||
62 | struct xfrm_lifetime_cur | |
63 | { | |
64 | __u64 bytes; | |
65 | __u64 packets; | |
66 | __u64 add_time; | |
67 | __u64 use_time; | |
68 | }; | |
69 | ||
70 | struct xfrm_replay_state | |
71 | { | |
72 | __u32 oseq; | |
73 | __u32 seq; | |
74 | __u32 bitmap; | |
75 | }; | |
76 | ||
77 | struct xfrm_algo { | |
78 | char alg_name[64]; | |
79 | int alg_key_len; /* in bits */ | |
80 | char alg_key[0]; | |
81 | }; | |
82 | ||
83 | struct xfrm_stats { | |
84 | __u32 replay_window; | |
85 | __u32 replay; | |
86 | __u32 integrity_failed; | |
87 | }; | |
88 | ||
89 | enum | |
90 | { | |
91 | XFRM_POLICY_IN = 0, | |
92 | XFRM_POLICY_OUT = 1, | |
93 | XFRM_POLICY_FWD = 2, | |
94 | XFRM_POLICY_MAX = 3 | |
95 | }; | |
96 | ||
97 | enum | |
98 | { | |
99 | XFRM_SHARE_ANY, /* No limitations */ | |
100 | XFRM_SHARE_SESSION, /* For this session only */ | |
101 | XFRM_SHARE_USER, /* For this user only */ | |
102 | XFRM_SHARE_UNIQUE /* Use once */ | |
103 | }; | |
104 | ||
105 | /* Netlink configuration messages. */ | |
106 | enum { | |
107 | XFRM_MSG_BASE = 0x10, | |
108 | ||
109 | XFRM_MSG_NEWSA = 0x10, | |
110 | #define XFRM_MSG_NEWSA XFRM_MSG_NEWSA | |
111 | XFRM_MSG_DELSA, | |
112 | #define XFRM_MSG_DELSA XFRM_MSG_DELSA | |
113 | XFRM_MSG_GETSA, | |
114 | #define XFRM_MSG_GETSA XFRM_MSG_GETSA | |
115 | ||
116 | XFRM_MSG_NEWPOLICY, | |
117 | #define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY | |
118 | XFRM_MSG_DELPOLICY, | |
119 | #define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY | |
120 | XFRM_MSG_GETPOLICY, | |
121 | #define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY | |
122 | ||
123 | XFRM_MSG_ALLOCSPI, | |
124 | #define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI | |
125 | XFRM_MSG_ACQUIRE, | |
126 | #define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE | |
127 | XFRM_MSG_EXPIRE, | |
128 | #define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE | |
129 | ||
130 | XFRM_MSG_UPDPOLICY, | |
131 | #define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY | |
132 | XFRM_MSG_UPDSA, | |
133 | #define XFRM_MSG_UPDSA XFRM_MSG_UPDSA | |
134 | ||
135 | XFRM_MSG_POLEXPIRE, | |
136 | #define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE | |
137 | ||
138 | XFRM_MSG_FLUSHSA, | |
139 | #define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA | |
140 | XFRM_MSG_FLUSHPOLICY, | |
141 | #define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY | |
142 | ||
526bdb80 | 143 | __XFRM_MSG_MAX |
1da177e4 | 144 | }; |
526bdb80 | 145 | #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1) |
1da177e4 | 146 | |
492b558b TG |
147 | #define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE) |
148 | ||
1da177e4 LT |
149 | struct xfrm_user_tmpl { |
150 | struct xfrm_id id; | |
151 | __u16 family; | |
152 | xfrm_address_t saddr; | |
153 | __u32 reqid; | |
154 | __u8 mode; | |
155 | __u8 share; | |
156 | __u8 optional; | |
157 | __u32 aalgos; | |
158 | __u32 ealgos; | |
159 | __u32 calgos; | |
160 | }; | |
161 | ||
162 | struct xfrm_encap_tmpl { | |
163 | __u16 encap_type; | |
164 | __u16 encap_sport; | |
165 | __u16 encap_dport; | |
166 | xfrm_address_t encap_oa; | |
167 | }; | |
168 | ||
169 | /* Netlink message attributes. */ | |
170 | enum xfrm_attr_type_t { | |
171 | XFRMA_UNSPEC, | |
172 | XFRMA_ALG_AUTH, /* struct xfrm_algo */ | |
173 | XFRMA_ALG_CRYPT, /* struct xfrm_algo */ | |
174 | XFRMA_ALG_COMP, /* struct xfrm_algo */ | |
175 | XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */ | |
176 | XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */ | |
0603eac0 HX |
177 | XFRMA_SA, |
178 | XFRMA_POLICY, | |
1da177e4 LT |
179 | __XFRMA_MAX |
180 | ||
181 | #define XFRMA_MAX (__XFRMA_MAX - 1) | |
182 | }; | |
183 | ||
184 | struct xfrm_usersa_info { | |
185 | struct xfrm_selector sel; | |
186 | struct xfrm_id id; | |
187 | xfrm_address_t saddr; | |
188 | struct xfrm_lifetime_cfg lft; | |
189 | struct xfrm_lifetime_cur curlft; | |
190 | struct xfrm_stats stats; | |
191 | __u32 seq; | |
192 | __u32 reqid; | |
193 | __u16 family; | |
194 | __u8 mode; /* 0=transport,1=tunnel */ | |
195 | __u8 replay_window; | |
196 | __u8 flags; | |
197 | #define XFRM_STATE_NOECN 1 | |
198 | #define XFRM_STATE_DECAP_DSCP 2 | |
dd87147e | 199 | #define XFRM_STATE_NOPMTUDISC 4 |
1da177e4 LT |
200 | }; |
201 | ||
202 | struct xfrm_usersa_id { | |
203 | xfrm_address_t daddr; | |
204 | __u32 spi; | |
205 | __u16 family; | |
206 | __u8 proto; | |
207 | }; | |
208 | ||
209 | struct xfrm_userspi_info { | |
210 | struct xfrm_usersa_info info; | |
211 | __u32 min; | |
212 | __u32 max; | |
213 | }; | |
214 | ||
215 | struct xfrm_userpolicy_info { | |
216 | struct xfrm_selector sel; | |
217 | struct xfrm_lifetime_cfg lft; | |
218 | struct xfrm_lifetime_cur curlft; | |
219 | __u32 priority; | |
220 | __u32 index; | |
221 | __u8 dir; | |
222 | __u8 action; | |
223 | #define XFRM_POLICY_ALLOW 0 | |
224 | #define XFRM_POLICY_BLOCK 1 | |
225 | __u8 flags; | |
226 | #define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */ | |
227 | __u8 share; | |
228 | }; | |
229 | ||
230 | struct xfrm_userpolicy_id { | |
231 | struct xfrm_selector sel; | |
232 | __u32 index; | |
233 | __u8 dir; | |
234 | }; | |
235 | ||
236 | struct xfrm_user_acquire { | |
237 | struct xfrm_id id; | |
238 | xfrm_address_t saddr; | |
239 | struct xfrm_selector sel; | |
240 | struct xfrm_userpolicy_info policy; | |
241 | __u32 aalgos; | |
242 | __u32 ealgos; | |
243 | __u32 calgos; | |
244 | __u32 seq; | |
245 | }; | |
246 | ||
247 | struct xfrm_user_expire { | |
248 | struct xfrm_usersa_info state; | |
249 | __u8 hard; | |
250 | }; | |
251 | ||
252 | struct xfrm_user_polexpire { | |
253 | struct xfrm_userpolicy_info pol; | |
254 | __u8 hard; | |
255 | }; | |
256 | ||
257 | struct xfrm_usersa_flush { | |
258 | __u8 proto; | |
259 | }; | |
260 | ||
ac6d439d PM |
261 | #ifndef __KERNEL__ |
262 | /* backwards compatibility for userspace */ | |
1da177e4 LT |
263 | #define XFRMGRP_ACQUIRE 1 |
264 | #define XFRMGRP_EXPIRE 2 | |
26b15dad JHS |
265 | #define XFRMGRP_SA 4 |
266 | #define XFRMGRP_POLICY 8 | |
ac6d439d PM |
267 | #endif |
268 | ||
269 | enum xfrm_nlgroups { | |
270 | XFRMNLGRP_NONE, | |
271 | #define XFRMNLGRP_NONE XFRMNLGRP_NONE | |
272 | XFRMNLGRP_ACQUIRE, | |
273 | #define XFRMNLGRP_ACQUIRE XFRMNLGRP_ACQUIRE | |
274 | XFRMNLGRP_EXPIRE, | |
275 | #define XFRMNLGRP_EXPIRE XFRMNLGRP_EXPIRE | |
276 | XFRMNLGRP_SA, | |
277 | #define XFRMNLGRP_SA XFRMNLGRP_SA | |
278 | XFRMNLGRP_POLICY, | |
279 | #define XFRMNLGRP_POLICY XFRMNLGRP_POLICY | |
280 | __XFRMNLGRP_MAX | |
281 | }; | |
282 | #define XFRMNLGRP_MAX (__XFRMNLGRP_MAX - 1) | |
1da177e4 LT |
283 | |
284 | #endif /* _LINUX_XFRM_H */ |