6c8dcf5f93f9b2d00bda159f1d67032842fcddba
[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 /** export an X509 end entity certificate for a connection */
127 EXPORT_CONN_CERT = 0x0002,
128 /** export the complete trust chain of a connection */
129 EXPORT_CONN_CHAIN = 0x0004,
130 };
131
132 /**
133 * CRL certificate validation policy
134 */
135 typedef enum {
136 CRL_STRICT_NO,
137 CRL_STRICT_YES,
138 CRL_STRICT_IFURI,
139 } crl_policy_t;
140
141
142 typedef struct stroke_end_t stroke_end_t;
143
144 /**
145 * definition of a peer in a stroke message
146 */
147 struct stroke_end_t {
148 char *auth;
149 char *auth2;
150 char *id;
151 char *id2;
152 char *eap_id;
153 char *rsakey;
154 char *cert;
155 char *cert2;
156 char *ca;
157 char *ca2;
158 char *groups;
159 char *groups2;
160 char *cert_policy;
161 char *updown;
162 char *address;
163 u_int16_t ikeport;
164 char *sourceip;
165 char *dns;
166 char *subnets;
167 int sendcert;
168 int hostaccess;
169 int tohost;
170 int allow_any;
171 u_int8_t protocol;
172 u_int16_t from_port;
173 u_int16_t to_port;
174 };
175
176 typedef struct stroke_msg_t stroke_msg_t;
177
178 /**
179 * @brief A stroke message sent over the unix socket.
180 */
181 struct stroke_msg_t {
182 /* length of this message with all strings */
183 u_int16_t length;
184
185 /* type of the message */
186 enum {
187 /* initiate a connection */
188 STR_INITIATE,
189 /* install SPD entries for a policy */
190 STR_ROUTE,
191 /* uninstall SPD entries for a policy */
192 STR_UNROUTE,
193 /* add a connection */
194 STR_ADD_CONN,
195 /* delete a connection */
196 STR_DEL_CONN,
197 /* terminate connection */
198 STR_TERMINATE,
199 /* terminate connection by peers srcip/virtual ip */
200 STR_TERMINATE_SRCIP,
201 /* rekey a connection */
202 STR_REKEY,
203 /* show connection status */
204 STR_STATUS,
205 /* show verbose connection status */
206 STR_STATUS_ALL,
207 /* show verbose connection status, non-blocking variant */
208 STR_STATUS_ALL_NOBLK,
209 /* add a ca information record */
210 STR_ADD_CA,
211 /* delete ca information record */
212 STR_DEL_CA,
213 /* set a log type to log/not log */
214 STR_LOGLEVEL,
215 /* configure global options for stroke */
216 STR_CONFIG,
217 /* list various objects */
218 STR_LIST,
219 /* reread various objects */
220 STR_REREAD,
221 /* purge various objects */
222 STR_PURGE,
223 /* show pool leases */
224 STR_LEASES,
225 /* export credentials */
226 STR_EXPORT,
227 /* print memory usage details */
228 STR_MEMUSAGE,
229 /* set username and password for a connection */
230 STR_USER_CREDS,
231 /* print/reset counters */
232 STR_COUNTERS,
233 /* more to come */
234 } type;
235
236 /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
237 int output_verbosity;
238
239 union {
240 /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
241 struct {
242 char *name;
243 } initiate, route, unroute, terminate, rekey, status, del_conn, del_ca;
244
245 /* data for STR_TERMINATE_SRCIP */
246 struct {
247 char *start;
248 char *end;
249 } terminate_srcip;
250
251 /* data for STR_ADD_CONN */
252 struct {
253 char *name;
254 int version;
255 char *eap_identity;
256 char *aaa_identity;
257 char *xauth_identity;
258 int mode;
259 int mobike;
260 int aggressive;
261 int pushmode;
262 int force_encap;
263 int fragmentation;
264 int ipcomp;
265 time_t inactivity;
266 int proxy_mode;
267 int install_policy;
268 int close_action;
269 u_int32_t reqid;
270 u_int32_t tfc;
271 u_int8_t ikedscp;
272
273 crl_policy_t crl_policy;
274 int unique;
275 struct {
276 char *ike;
277 char *esp;
278 } algorithms;
279 struct {
280 int reauth;
281 time_t ipsec_lifetime;
282 time_t ike_lifetime;
283 time_t margin;
284 u_int64_t life_bytes;
285 u_int64_t margin_bytes;
286 u_int64_t life_packets;
287 u_int64_t margin_packets;
288 unsigned long tries;
289 unsigned long fuzz;
290 } rekey;
291 struct {
292 time_t delay;
293 time_t timeout;
294 int action;
295 } dpd;
296 struct {
297 int mediation;
298 char *mediated_by;
299 char *peerid;
300 } ikeme;
301 struct {
302 u_int32_t value;
303 u_int32_t mask;
304 } mark_in, mark_out;
305 stroke_end_t me, other;
306 } add_conn;
307
308 /* data for STR_ADD_CA */
309 struct {
310 char *name;
311 char *cacert;
312 char *crluri;
313 char *crluri2;
314 char *ocspuri;
315 char *ocspuri2;
316 char *certuribase;
317 } add_ca;
318
319 /* data for STR_LOGLEVEL */
320 struct {
321 char *type;
322 int level;
323 } loglevel;
324
325 /* data for STR_CONFIG */
326 struct {
327 int cachecrl;
328 } config;
329
330 /* data for STR_LIST */
331 struct {
332 list_flag_t flags;
333 int utc;
334 } list;
335
336 /* data for STR_REREAD */
337 struct {
338 reread_flag_t flags;
339 } reread;
340
341 /* data for STR_PURGE */
342 struct {
343 purge_flag_t flags;
344 } purge;
345
346 /* data for STR_EXPORT */
347 struct {
348 export_flag_t flags;
349 char *selector;
350 } export;
351
352 /* data for STR_LEASES */
353 struct {
354 char *pool;
355 char *address;
356 } leases;
357
358 /* data for STR_USER_CREDS */
359 struct {
360 char *name;
361 char *username;
362 char *password;
363 } user_creds;
364
365 /* data for STR_COUNTERS */
366 struct {
367 /* reset or print counters? */
368 int reset;
369 char *name;
370 } counters;
371 };
372 char buffer[STROKE_BUF_LEN];
373 };
374
375 #endif /* STROKE_MSG_H_ */