Added a stroke memusage command to show memory usage
[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 CRL cache entries */
109 PURGE_CRLS = 0x0002,
110 /** purge X509 cache entries */
111 PURGE_CERTS = 0x0004,
112 /** purge IKE_SAs without a CHILD_SA */
113 PURGE_IKE = 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 /* print memory usage details */
216 STR_MEMUSAGE,
217 /* more to come */
218 } type;
219
220 /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
221 int output_verbosity;
222
223 union {
224 /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
225 struct {
226 char *name;
227 } initiate, route, unroute, terminate, rekey, status, del_conn, del_ca;
228
229 /* data for STR_TERMINATE_SRCIP */
230 struct {
231 char *start;
232 char *end;
233 } terminate_srcip;
234
235 /* data for STR_ADD_CONN */
236 struct {
237 char *name;
238 int ikev2;
239 /* next three are deprecated, use stroke_end_t.auth instead */
240 int auth_method;
241 u_int32_t eap_type;
242 u_int32_t eap_vendor;
243 char *eap_identity;
244 char *aaa_identity;
245 int mode;
246 int mobike;
247 int force_encap;
248 int ipcomp;
249 time_t inactivity;
250 int proxy_mode;
251 int install_policy;
252 u_int32_t reqid;
253 u_int32_t tfc;
254
255 crl_policy_t crl_policy;
256 int unique;
257 struct {
258 char *ike;
259 char *esp;
260 } algorithms;
261 struct {
262 int reauth;
263 time_t ipsec_lifetime;
264 time_t ike_lifetime;
265 time_t margin;
266 u_int64_t life_bytes;
267 u_int64_t margin_bytes;
268 u_int64_t life_packets;
269 u_int64_t margin_packets;
270 unsigned long tries;
271 unsigned long fuzz;
272 } rekey;
273 struct {
274 time_t delay;
275 int action;
276 } dpd;
277 struct {
278 int mediation;
279 char *mediated_by;
280 char *peerid;
281 } ikeme;
282 struct {
283 u_int32_t value;
284 u_int32_t mask;
285 } mark_in, mark_out;
286 stroke_end_t me, other;
287 } add_conn;
288
289 /* data for STR_ADD_CA */
290 struct {
291 char *name;
292 char *cacert;
293 char *crluri;
294 char *crluri2;
295 char *ocspuri;
296 char *ocspuri2;
297 char *certuribase;
298 } add_ca;
299
300 /* data for STR_LOGLEVEL */
301 struct {
302 char *type;
303 int level;
304 } loglevel;
305
306 /* data for STR_CONFIG */
307 struct {
308 int cachecrl;
309 } config;
310
311 /* data for STR_LIST */
312 struct {
313 list_flag_t flags;
314 int utc;
315 } list;
316
317 /* data for STR_REREAD */
318 struct {
319 reread_flag_t flags;
320 } reread;
321
322 /* data for STR_PURGE */
323 struct {
324 purge_flag_t flags;
325 } purge;
326
327 /* data for STR_EXPORT */
328 struct {
329 export_flag_t flags;
330 char *selector;
331 } export;
332
333 /* data for STR_LEASES */
334 struct {
335 char *pool;
336 char *address;
337 } leases;
338 };
339 char buffer[STROKE_BUF_LEN];
340 };
341
342 #endif /* STROKE_MSG_H_ */