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