Added a stroke command to export cached x509 certificates to the console
[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 /** all list options */
69 LIST_ALL = 0x07FF,
70 };
71
72 typedef enum reread_flag_t reread_flag_t;
73
74 /**
75 * Definition of the REREAD flags, used for
76 * the various stroke reread* commands.
77 */
78 enum reread_flag_t {
79 /** don't reread anything */
80 REREAD_NONE = 0x0000,
81 /** reread all secret keys */
82 REREAD_SECRETS = 0x0001,
83 /** reread all ca certs */
84 REREAD_CACERTS = 0x0002,
85 /** reread all ocsp signer certs */
86 REREAD_OCSPCERTS = 0x0004,
87 /** reread all aa certs */
88 REREAD_AACERTS = 0x0008,
89 /** reread all attribute certs */
90 REREAD_ACERTS = 0x0010,
91 /** reread all crls */
92 REREAD_CRLS = 0x0020,
93 /** all reread options */
94 REREAD_ALL = 0x003F,
95 };
96
97 typedef enum purge_flag_t purge_flag_t;
98
99 /**
100 * Definition of the PURGE flags, currently used for
101 * the stroke purgeocsp command.
102 */
103 enum purge_flag_t {
104 /** don't purge anything */
105 PURGE_NONE = 0x0000,
106 /** purge ocsp cache entries */
107 PURGE_OCSP = 0x0001,
108 /** purge IKE_SAs without a CHILD_SA */
109 PURGE_IKE = 0x0002,
110 };
111
112 typedef enum export_flag_t export_flag_t;
113
114 /**
115 * Definition of the export flags
116 */
117 enum export_flag_t {
118 /** export an X509 certificate */
119 EXPORT_X509 = 0x0001,
120 };
121
122 /**
123 * CRL certificate validation policy
124 */
125 typedef enum {
126 CRL_STRICT_NO,
127 CRL_STRICT_YES,
128 CRL_STRICT_IFURI,
129 } crl_policy_t;
130
131
132 typedef struct stroke_end_t stroke_end_t;
133
134 /**
135 * definition of a peer in a stroke message
136 */
137 struct stroke_end_t {
138 char *auth;
139 char *auth2;
140 char *id;
141 char *id2;
142 char *eap_id;
143 char *cert;
144 char *cert2;
145 char *ca;
146 char *ca2;
147 char *groups;
148 char *updown;
149 char *address;
150 u_int16_t ikeport;
151 char *sourceip;
152 int sourceip_mask;
153 char *subnets;
154 int sendcert;
155 int hostaccess;
156 int tohost;
157 u_int8_t protocol;
158 u_int16_t port;
159 };
160
161 typedef struct stroke_msg_t stroke_msg_t;
162
163 /**
164 * @brief A stroke message sent over the unix socket.
165 */
166 struct stroke_msg_t {
167 /* length of this message with all strings */
168 u_int16_t length;
169
170 /* type of the message */
171 enum {
172 /* initiate a connection */
173 STR_INITIATE,
174 /* install SPD entries for a policy */
175 STR_ROUTE,
176 /* uninstall SPD entries for a policy */
177 STR_UNROUTE,
178 /* add a connection */
179 STR_ADD_CONN,
180 /* delete a connection */
181 STR_DEL_CONN,
182 /* terminate connection */
183 STR_TERMINATE,
184 /* terminate connection by peers srcip/virtual ip */
185 STR_TERMINATE_SRCIP,
186 /* show connection status */
187 STR_STATUS,
188 /* show verbose connection status */
189 STR_STATUS_ALL,
190 /* add a ca information record */
191 STR_ADD_CA,
192 /* delete ca information record */
193 STR_DEL_CA,
194 /* set a log type to log/not log */
195 STR_LOGLEVEL,
196 /* configure global options for stroke */
197 STR_CONFIG,
198 /* list various objects */
199 STR_LIST,
200 /* reread various objects */
201 STR_REREAD,
202 /* purge various objects */
203 STR_PURGE,
204 /* show pool leases */
205 STR_LEASES,
206 /* export credentials */
207 STR_EXPORT,
208 /* more to come */
209 } type;
210
211 /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
212 int output_verbosity;
213
214 union {
215 /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
216 struct {
217 char *name;
218 } initiate, route, unroute, terminate, status, del_conn, del_ca;
219
220 /* data for STR_TERMINATE_SRCIP */
221 struct {
222 char *start;
223 char *end;
224 } terminate_srcip;
225
226 /* data for STR_ADD_CONN */
227 struct {
228 char *name;
229 int ikev2;
230 /* next three are deprecated, use stroke_end_t.auth instead */
231 int auth_method;
232 u_int32_t eap_type;
233 u_int32_t eap_vendor;
234 char *eap_identity;
235 int mode;
236 int mobike;
237 int force_encap;
238 int ipcomp;
239 time_t inactivity;
240 int proxy_mode;
241 int install_policy;
242 u_int32_t reqid;
243
244 crl_policy_t crl_policy;
245 int unique;
246 struct {
247 char *ike;
248 char *esp;
249 } algorithms;
250 struct {
251 int reauth;
252 time_t ipsec_lifetime;
253 time_t ike_lifetime;
254 time_t margin;
255 u_int64_t life_bytes;
256 u_int64_t margin_bytes;
257 u_int64_t life_packets;
258 u_int64_t margin_packets;
259 unsigned long tries;
260 unsigned long fuzz;
261 } rekey;
262 struct {
263 time_t delay;
264 int action;
265 } dpd;
266 struct {
267 int mediation;
268 char *mediated_by;
269 char *peerid;
270 } ikeme;
271 struct {
272 u_int32_t value;
273 u_int32_t mask;
274 } mark_in, mark_out;
275 stroke_end_t me, other;
276 } add_conn;
277
278 /* data for STR_ADD_CA */
279 struct {
280 char *name;
281 char *cacert;
282 char *crluri;
283 char *crluri2;
284 char *ocspuri;
285 char *ocspuri2;
286 char *certuribase;
287 } add_ca;
288
289 /* data for STR_LOGLEVEL */
290 struct {
291 char *type;
292 int level;
293 } loglevel;
294
295 /* data for STR_CONFIG */
296 struct {
297 int cachecrl;
298 } config;
299
300 /* data for STR_LIST */
301 struct {
302 list_flag_t flags;
303 int utc;
304 } list;
305
306 /* data for STR_REREAD */
307 struct {
308 reread_flag_t flags;
309 } reread;
310
311 /* data for STR_PURGE */
312 struct {
313 purge_flag_t flags;
314 } purge;
315
316 /* data for STR_EXPORT */
317 struct {
318 export_flag_t flags;
319 char *selector;
320 } export;
321
322 /* data for STR_LEASES */
323 struct {
324 char *pool;
325 char *address;
326 } leases;
327 };
328 char buffer[STROKE_BUF_LEN];
329 };
330
331 #endif /* STROKE_MSG_H_ */