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