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