64ea125f3562c18757a06eef6aa974a4553a84c7
[linux-flexiantxendom0-3.2.10.git] / include / linux / xfrm.h
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         __u8    prefixlen_d;
41         __u8    prefixlen_s;
42         __u8    proto;
43         int     ifindex;
44         uid_t   user;
45 };
46
47 #define XFRM_INF (~(__u64)0)
48
49 struct xfrm_lifetime_cfg
50 {
51         __u64   soft_byte_limit;
52         __u64   hard_byte_limit;
53         __u64   soft_packet_limit;
54         __u64   hard_packet_limit;
55         __u64   soft_add_expires_seconds;
56         __u64   hard_add_expires_seconds;
57         __u64   soft_use_expires_seconds;
58         __u64   hard_use_expires_seconds;
59 };
60
61 struct xfrm_lifetime_cur
62 {
63         __u64   bytes;
64         __u64   packets;
65         __u64   add_time;
66         __u64   use_time;
67 };
68
69 struct xfrm_replay_state
70 {
71         __u32   oseq;
72         __u32   seq;
73         __u32   bitmap;
74 };
75
76 struct xfrm_algo {
77         char    alg_name[64];
78         int     alg_key_len;    /* in bits */
79         char    alg_key[0];
80 };
81
82 struct xfrm_stats {
83         __u32   replay_window;
84         __u32   replay;
85         __u32   integrity_failed;
86 };
87
88 enum
89 {
90         XFRM_POLICY_IN  = 0,
91         XFRM_POLICY_OUT = 1,
92         XFRM_POLICY_FWD = 2,
93         XFRM_POLICY_MAX = 3
94 };
95
96 enum
97 {
98         XFRM_SHARE_ANY,         /* No limitations */
99         XFRM_SHARE_SESSION,     /* For this session only */
100         XFRM_SHARE_USER,        /* For this user only */
101         XFRM_SHARE_UNIQUE       /* Use once */
102 };
103
104 /* Netlink configuration messages.  */
105 #define XFRM_MSG_BASE           0x10
106
107 #define XFRM_MSG_NEWSA          (XFRM_MSG_BASE + 0)
108 #define XFRM_MSG_DELSA          (XFRM_MSG_BASE + 1)
109 #define XFRM_MSG_GETSA          (XFRM_MSG_BASE + 2)
110
111 #define XFRM_MSG_NEWPOLICY      (XFRM_MSG_BASE + 3)
112 #define XFRM_MSG_DELPOLICY      (XFRM_MSG_BASE + 4)
113 #define XFRM_MSG_GETPOLICY      (XFRM_MSG_BASE + 5)
114
115 #define XFRM_MSG_ALLOCSPI       (XFRM_MSG_BASE + 6)
116 #define XFRM_MSG_ACQUIRE        (XFRM_MSG_BASE + 7)
117 #define XFRM_MSG_EXPIRE         (XFRM_MSG_BASE + 8)
118
119 #define XFRM_MSG_UPDPOLICY      (XFRM_MSG_BASE + 9)
120 #define XFRM_MSG_UPDSA          (XFRM_MSG_BASE + 10)
121
122 #define XFRM_MSG_POLEXPIRE      (XFRM_MSG_BASE + 11)
123
124 #define XFRM_MSG_MAX            (XFRM_MSG_POLEXPIRE+1)
125
126 struct xfrm_user_tmpl {
127         struct xfrm_id          id;
128         xfrm_address_t          saddr;
129         __u32                   reqid;
130         __u8                    mode;
131         __u8                    share;
132         __u8                    optional;
133         __u32                   aalgos;
134         __u32                   ealgos;
135         __u32                   calgos;
136 };
137
138 struct xfrm_encap_tmpl {
139         __u16           encap_type;
140         __u16           encap_sport;
141         __u16           encap_dport;
142         xfrm_address_t  encap_oa;
143 };
144
145 /* Netlink message attributes.  */
146 enum xfrm_attr_type_t {
147         XFRMA_UNSPEC,
148         XFRMA_ALG_AUTH,         /* struct xfrm_algo */
149         XFRMA_ALG_CRYPT,        /* struct xfrm_algo */
150         XFRMA_ALG_COMP,         /* struct xfrm_algo */
151         XFRMA_ENCAP,            /* struct xfrm_algo + struct xfrm_encap_tmpl */
152         XFRMA_TMPL,             /* 1 or more struct xfrm_user_tmpl */
153
154 #define XFRMA_MAX XFRMA_TMPL
155 };
156
157 struct xfrm_usersa_info {
158         struct xfrm_selector            sel;
159         struct xfrm_id                  id;
160         xfrm_address_t                  saddr;
161         struct xfrm_lifetime_cfg        lft;
162         struct xfrm_lifetime_cur        curlft;
163         struct xfrm_stats               stats;
164         __u32                           seq;
165         __u32                           reqid;
166         __u16                           family;
167         __u8                            mode; /* 0=transport,1=tunnel */
168         __u8                            replay_window;
169 };
170
171 struct xfrm_usersa_id {
172         xfrm_address_t                  daddr;
173         __u32                           spi;
174         __u16                           family;
175         __u8                            proto;
176 };
177
178 struct xfrm_userspi_info {
179         struct xfrm_usersa_info         info;
180         __u32                           min;
181         __u32                           max;
182 };
183
184 struct xfrm_userpolicy_info {
185         struct xfrm_selector            sel;
186         struct xfrm_lifetime_cfg        lft;
187         struct xfrm_lifetime_cur        curlft;
188         __u32                           priority;
189         __u32                           index;
190         __u16                           family;
191         __u8                            dir;
192         __u8                            action;
193 #define XFRM_POLICY_ALLOW       0
194 #define XFRM_POLICY_BLOCK       1
195         __u8                            flags;
196 #define XFRM_POLICY_LOCALOK     1       /* Allow user to override global policy */
197         __u8                            share;
198 };
199
200 struct xfrm_userpolicy_id {
201         struct xfrm_selector            sel;
202         __u32                           index;
203         __u8                            dir;
204 };
205
206 struct xfrm_user_acquire {
207         struct xfrm_id                  id;
208         xfrm_address_t                  saddr;
209         struct xfrm_selector            sel;
210         struct xfrm_userpolicy_info     policy;
211         __u32                           aalgos;
212         __u32                           ealgos;
213         __u32                           calgos;
214         __u32                           seq;
215 };
216
217 struct xfrm_user_expire {
218         struct xfrm_usersa_info         state;
219         __u8                            hard;
220 };
221
222 struct xfrm_user_polexpire {
223         struct xfrm_userpolicy_info     pol;
224         __u8                            hard;
225 };
226
227 #define XFRMGRP_ACQUIRE         1
228 #define XFRMGRP_EXPIRE          2
229
230 #endif /* _LINUX_XFRM_H */