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