merged tasking branch into trunk
[strongswan.git] / src / stroke / stroke.h
1 /**
2 * @file stroke.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_H_
24 #define STROKE_H_
25
26 #include <sys/types.h>
27
28 /**
29 * Socket which is used to communicate between charon and stroke
30 */
31 #define STROKE_SOCKET "/var/run/charon.ctl"
32
33 #define STROKE_BUF_LEN 2048
34
35 typedef enum list_flag_t list_flag_t;
36
37 /**
38 * Definition of the LIST flags, used for
39 * the various stroke list* commands.
40 */
41 enum list_flag_t {
42 /** don't list anything */
43 LIST_NONE = 0x0000,
44 /** list all host/user certs */
45 LIST_CERTS = 0x0001,
46 /** list all ca certs */
47 LIST_CACERTS = 0x0002,
48 /** list all ocsp signer certs */
49 LIST_OCSPCERTS = 0x0004,
50 /** list all ca information records */
51 LIST_CAINFOS = 0x0008,
52 /** list all crls */
53 LIST_CRLS = 0x0010,
54 /** list all ocsp cache entries */
55 LIST_OCSP = 0x0020,
56 /** all list options */
57 LIST_ALL = 0x003F,
58 };
59
60 typedef enum reread_flag_t reread_flag_t;
61
62 /**
63 * Definition of the REREAD flags, used for
64 * the various stroke reread* commands.
65 */
66 enum reread_flag_t {
67 /** don't reread anything */
68 REREAD_NONE = 0x0000,
69 /** reread all ca certs */
70 REREAD_CACERTS = 0x0001,
71 /** reread all ocsp signer certs */
72 REREAD_OCSPCERTS = 0x0002,
73 /** reread all crls */
74 REREAD_CRLS = 0x0004,
75 /** all reread options */
76 REREAD_ALL = 0x0007,
77 };
78
79 typedef enum purge_flag_t purge_flag_t;
80
81 /**
82 * Definition of the PURGE flags, currently used for
83 * the stroke purgeocsp command.
84 */
85 enum purge_flag_t {
86 /** don't purge anything */
87 PURGE_NONE = 0x0000,
88 /** purge ocsp cache entries */
89 PURGE_OCSP = 0x0001,
90 };
91
92 typedef struct stroke_end_t stroke_end_t;
93
94 /**
95 * definition of a peer in a stroke message
96 */
97 struct stroke_end_t {
98 char *id;
99 char *cert;
100 char *ca;
101 char *updown;
102 char *address;
103 char *sourceip;
104 u_int8_t virtual_ip;
105 char *subnet;
106 int subnet_mask;
107 int sendcert;
108 int hostaccess;
109 u_int8_t protocol;
110 u_int16_t port;
111 };
112
113 typedef struct stroke_msg_t stroke_msg_t;
114
115 /**
116 * @brief A stroke message sent over the unix socket.
117 */
118 struct stroke_msg_t {
119 /* length of this message with all strings */
120 u_int16_t length;
121
122 /* type of the message */
123 enum {
124 /* initiate a connection */
125 STR_INITIATE,
126 /* install SPD entries for a policy */
127 STR_ROUTE,
128 /* uninstall SPD entries for a policy */
129 STR_UNROUTE,
130 /* add a connection */
131 STR_ADD_CONN,
132 /* delete a connection */
133 STR_DEL_CONN,
134 /* terminate connection */
135 STR_TERMINATE,
136 /* show connection status */
137 STR_STATUS,
138 /* show verbose connection status */
139 STR_STATUS_ALL,
140 /* add a ca information record */
141 STR_ADD_CA,
142 /* delete ca information record */
143 STR_DEL_CA,
144 /* set a log type to log/not log */
145 STR_LOGLEVEL,
146 /* list various objects */
147 STR_LIST,
148 /* reread various objects */
149 STR_REREAD,
150 /* purge various objects */
151 STR_PURGE
152 /* more to come */
153 } type;
154
155 /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
156 int output_verbosity;
157
158 union {
159 /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
160 struct {
161 char *name;
162 } initiate, route, unroute, terminate, status, del_conn, del_ca;
163
164 /* data for STR_ADD_CONN */
165 struct {
166 char *name;
167 int ikev2;
168 int auth_method;
169 int eap_type;
170 int mode;
171 struct {
172 char *ike;
173 char *esp;
174 } algorithms;
175 struct {
176 int reauth;
177 time_t ipsec_lifetime;
178 time_t ike_lifetime;
179 time_t margin;
180 unsigned long tries;
181 unsigned long fuzz;
182 } rekey;
183 struct {
184 time_t delay;
185 int action;
186 } dpd;
187 stroke_end_t me, other;
188 } add_conn;
189
190 /* data for STR_ADD_CA */
191 struct {
192 char *name;
193 char *cacert;
194 char *crluri;
195 char *crluri2;
196 char *ocspuri;
197 char *ocspuri2;
198 } add_ca;
199
200 /* data for STR_LOGLEVEL */
201 struct {
202 char *type;
203 int level;
204 } loglevel;
205
206 /* data for STR_LIST */
207 struct {
208 list_flag_t flags;
209 int utc;
210 } list;
211
212 /* data for STR_REREAD */
213 struct {
214 reread_flag_t flags;
215 } reread;
216
217 /* data for STR_PURGE */
218 struct {
219 purge_flag_t flags;
220 } purge;
221 };
222 char buffer[STROKE_BUF_LEN];
223 };
224
225 #endif /* STROKE_H_ */