3350d76033e193bcd9b55951f0d4b0b4211135b3
[strongswan.git] / src / stroke / stroke_msg.h
1 /**
2 * @file stroke_msg.h
3 *
4 * @brief Definition of stroke_msg_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef STROKE_MSG_H_
24 #define STROKE_MSG_H_
25
26 #include <sys/types.h>
27
28 #include <library.h>
29
30 /**
31 * Socket which is used to communicate between charon and stroke
32 */
33 #define STROKE_SOCKET IPSEC_PIDDIR "/charon.ctl"
34
35 #define STROKE_BUF_LEN 2048
36
37 typedef enum list_flag_t list_flag_t;
38
39 /**
40 * Definition of the LIST flags, used for
41 * the various stroke list* commands.
42 */
43 enum list_flag_t {
44 /** don't list anything */
45 LIST_NONE = 0x0000,
46 /** list all raw public keys */
47 LIST_PUBKEYS = 0x0001,
48 /** list all host/user certs */
49 LIST_CERTS = 0x0002,
50 /** list all ca certs */
51 LIST_CACERTS = 0x0004,
52 /** list all ocsp signer certs */
53 LIST_OCSPCERTS = 0x0008,
54 /** list all aa certs */
55 LIST_AACERTS = 0x0010,
56 /** list all attribute certs */
57 LIST_ACERTS = 0x0020,
58 /** list all access control groups */
59 LIST_GROUPS = 0x0040,
60 /** list all ca information records */
61 LIST_CAINFOS = 0x0080,
62 /** list all crls */
63 LIST_CRLS = 0x0100,
64 /** list all ocsp cache entries */
65 LIST_OCSP = 0x0200,
66 /** list all supported algorithms */
67 LIST_ALGS = 0x0400,
68 /** list plugin information */
69 LIST_PLUGINS = 0x0800,
70 /** all list options */
71 LIST_ALL = 0x0FFF,
72 };
73
74 typedef enum reread_flag_t reread_flag_t;
75
76 /**
77 * Definition of the REREAD flags, used for
78 * the various stroke reread* commands.
79 */
80 enum reread_flag_t {
81 /** don't reread anything */
82 REREAD_NONE = 0x0000,
83 /** reread all secret keys */
84 REREAD_SECRETS = 0x0001,
85 /** reread all ca certs */
86 REREAD_CACERTS = 0x0002,
87 /** reread all ocsp signer certs */
88 REREAD_OCSPCERTS = 0x0004,
89 /** reread all aa certs */
90 REREAD_AACERTS = 0x0008,
91 /** reread all attribute certs */
92 REREAD_ACERTS = 0x0010,
93 /** reread all crls */
94 REREAD_CRLS = 0x0020,
95 /** all reread options */
96 REREAD_ALL = 0x003F,
97 };
98
99 typedef enum purge_flag_t purge_flag_t;
100
101 /**
102 * Definition of the PURGE flags, currently used for
103 * the stroke purgeocsp command.
104 */
105 enum purge_flag_t {
106 /** don't purge anything */
107 PURGE_NONE = 0x0000,
108 /** purge ocsp cache entries */
109 PURGE_OCSP = 0x0001,
110 /** purge CRL cache entries */
111 PURGE_CRLS = 0x0002,
112 /** purge X509 cache entries */
113 PURGE_CERTS = 0x0004,
114 /** purge IKE_SAs without a CHILD_SA */
115 PURGE_IKE = 0x0008,
116 };
117
118 typedef enum export_flag_t export_flag_t;
119
120 /**
121 * Definition of the export flags
122 */
123 enum export_flag_t {
124 /** export an X509 certificate */
125 EXPORT_X509 = 0x0001,
126 };
127
128 /**
129 * CRL certificate validation policy
130 */
131 typedef enum {
132 CRL_STRICT_NO,
133 CRL_STRICT_YES,
134 CRL_STRICT_IFURI,
135 } crl_policy_t;
136
137
138 typedef struct stroke_end_t stroke_end_t;
139
140 /**
141 * definition of a peer in a stroke message
142 */
143 struct stroke_end_t {
144 char *auth;
145 char *auth2;
146 char *id;
147 char *id2;
148 char *eap_id;
149 char *cert;
150 char *cert2;
151 char *ca;
152 char *ca2;
153 char *groups;
154 char *cert_policy;
155 char *updown;
156 char *address;
157 u_int16_t ikeport;
158 char *sourceip;
159 int sourceip_mask;
160 char *subnets;
161 int sendcert;
162 int hostaccess;
163 int tohost;
164 u_int8_t protocol;
165 u_int16_t port;
166 };
167
168 typedef struct stroke_msg_t stroke_msg_t;
169
170 /**
171 * @brief A stroke message sent over the unix socket.
172 */
173 struct stroke_msg_t {
174 /* length of this message with all strings */
175 u_int16_t length;
176
177 /* type of the message */
178 enum {
179 /* initiate a connection */
180 STR_INITIATE,
181 /* install SPD entries for a policy */
182 STR_ROUTE,
183 /* uninstall SPD entries for a policy */
184 STR_UNROUTE,
185 /* add a connection */
186 STR_ADD_CONN,
187 /* delete a connection */
188 STR_DEL_CONN,
189 /* terminate connection */
190 STR_TERMINATE,
191 /* terminate connection by peers srcip/virtual ip */
192 STR_TERMINATE_SRCIP,
193 /* rekey a connection */
194 STR_REKEY,
195 /* show connection status */
196 STR_STATUS,
197 /* show verbose connection status */
198 STR_STATUS_ALL,
199 /* show verbose connection status, non-blocking variant */
200 STR_STATUS_ALL_NOBLK,
201 /* add a ca information record */
202 STR_ADD_CA,
203 /* delete ca information record */
204 STR_DEL_CA,
205 /* set a log type to log/not log */
206 STR_LOGLEVEL,
207 /* configure global options for stroke */
208 STR_CONFIG,
209 /* list various objects */
210 STR_LIST,
211 /* reread various objects */
212 STR_REREAD,
213 /* purge various objects */
214 STR_PURGE,
215 /* show pool leases */
216 STR_LEASES,
217 /* export credentials */
218 STR_EXPORT,
219 /* print memory usage details */
220 STR_MEMUSAGE,
221 /* more to come */
222 } type;
223
224 /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
225 int output_verbosity;
226
227 union {
228 /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
229 struct {
230 char *name;
231 } initiate, route, unroute, terminate, rekey, status, del_conn, del_ca;
232
233 /* data for STR_TERMINATE_SRCIP */
234 struct {
235 char *start;
236 char *end;
237 } terminate_srcip;
238
239 /* data for STR_ADD_CONN */
240 struct {
241 char *name;
242 int ikev2;
243 /* next three are deprecated, use stroke_end_t.auth instead */
244 int auth_method;
245 u_int32_t eap_type;
246 u_int32_t eap_vendor;
247 char *eap_identity;
248 char *aaa_identity;
249 char *xauth_identity;
250 int mode;
251 int mobike;
252 int force_encap;
253 int ipcomp;
254 time_t inactivity;
255 int proxy_mode;
256 int install_policy;
257 int close_action;
258 u_int32_t reqid;
259 u_int32_t tfc;
260
261 crl_policy_t crl_policy;
262 int unique;
263 struct {
264 char *ike;
265 char *esp;
266 } algorithms;
267 struct {
268 int reauth;
269 time_t ipsec_lifetime;
270 time_t ike_lifetime;
271 time_t margin;
272 u_int64_t life_bytes;
273 u_int64_t margin_bytes;
274 u_int64_t life_packets;
275 u_int64_t margin_packets;
276 unsigned long tries;
277 unsigned long fuzz;
278 } rekey;
279 struct {
280 time_t delay;
281 int action;
282 } dpd;
283 struct {
284 int mediation;
285 char *mediated_by;
286 char *peerid;
287 } ikeme;
288 struct {
289 u_int32_t value;
290 u_int32_t mask;
291 } mark_in, mark_out;
292 stroke_end_t me, other;
293 } add_conn;
294
295 /* data for STR_ADD_CA */
296 struct {
297 char *name;
298 char *cacert;
299 char *crluri;
300 char *crluri2;
301 char *ocspuri;
302 char *ocspuri2;
303 char *certuribase;
304 } add_ca;
305
306 /* data for STR_LOGLEVEL */
307 struct {
308 char *type;
309 int level;
310 } loglevel;
311
312 /* data for STR_CONFIG */
313 struct {
314 int cachecrl;
315 } config;
316
317 /* data for STR_LIST */
318 struct {
319 list_flag_t flags;
320 int utc;
321 } list;
322
323 /* data for STR_REREAD */
324 struct {
325 reread_flag_t flags;
326 } reread;
327
328 /* data for STR_PURGE */
329 struct {
330 purge_flag_t flags;
331 } purge;
332
333 /* data for STR_EXPORT */
334 struct {
335 export_flag_t flags;
336 char *selector;
337 } export;
338
339 /* data for STR_LEASES */
340 struct {
341 char *pool;
342 char *address;
343 } leases;
344 };
345 char buffer[STROKE_BUF_LEN];
346 };
347
348 #endif /* STROKE_MSG_H_ */