removing svn keyword $Id$ from all files
[strongswan.git] / src / whack / whack.h
1 /* Structure of messages from whack to Pluto proper.
2 * Copyright (C) 1998-2001 D. Hugh Redelmeier.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 #ifndef _WHACK_H
16 #define _WHACK_H
17
18 #include <freeswan.h>
19
20 /* copy of smartcard operations, defined in smartcard.h */
21 #ifndef SC_OP_T
22 #define SC_OP_T
23 typedef enum {
24 SC_OP_NONE = 0,
25 SC_OP_ENCRYPT = 1,
26 SC_OP_DECRYPT = 2,
27 SC_OP_SIGN = 3,
28 } sc_op_t;
29 #endif /* SC_OP_T */
30
31 /* Since the message remains on one host, native representation is used.
32 * Think of this as horizontal microcode: all selected operations are
33 * to be done (in the order declared here).
34 *
35 * MAGIC is used to help detect version mismatches between whack and Pluto.
36 * Whenever the interface (i.e. this struct) changes in form or
37 * meaning, change this value (probably by changing the last number).
38 *
39 * If the command only requires basic actions (status or shutdown),
40 * it is likely that the relevant part of the message changes less frequently.
41 * Whack uses WHACK_BASIC_MAGIC in those cases.
42 *
43 * NOTE: no value of WHACK_BASIC_MAGIC may equal any value of WHACK_MAGIC.
44 * Otherwise certain version mismatches will not be detected.
45 */
46
47 #define WHACK_BASIC_MAGIC (((((('w' << 8) + 'h') << 8) + 'k') << 8) + 24)
48 #define WHACK_MAGIC (((((('w' << 8) + 'h') << 8) + 'k') << 8) + 26)
49
50 typedef struct whack_end whack_end_t;
51
52 /* struct whack_end is a lot like connection.h's struct end
53 * It differs because it is going to be shipped down a socket
54 * and because whack is a separate program from pluto.
55 */
56 struct whack_end {
57 char *id; /* id string (if any) -- decoded by pluto */
58 char *cert; /* path string (if any) -- loaded by pluto */
59 char *ca; /* distinguished name string (if any) -- parsed by pluto */
60 char *groups; /* access control groups (if any) -- parsed by pluto */
61 ip_address
62 host_addr,
63 host_nexthop,
64 host_srcip;
65 ip_subnet client;
66
67 bool key_from_DNS_on_demand;
68 bool has_client;
69 bool has_client_wildcard;
70 bool has_port_wildcard;
71 bool has_srcip;
72 bool has_natip;
73 bool modecfg;
74 bool hostaccess;
75 bool allow_any;
76 certpolicy_t sendcert;
77 char *updown; /* string */
78 u_int16_t host_port; /* host order */
79 u_int16_t port; /* host order */
80 u_int8_t protocol;
81 char *virt;
82 };
83
84 typedef struct whack_message whack_message_t;
85
86 struct whack_message {
87 unsigned int magic;
88
89 /* for WHACK_STATUS: */
90 bool whack_status;
91 bool whack_statusall;
92
93
94 /* for WHACK_SHUTDOWN */
95 bool whack_shutdown;
96
97 /* END OF BASIC COMMANDS
98 * If you change anything earlier in this struct, update WHACK_BASIC_MAGIC.
99 */
100
101 /* name is used in connection, ca and initiate */
102 size_t name_len; /* string 1 */
103 char *name;
104
105 /* for WHACK_OPTIONS: */
106
107 bool whack_options;
108
109 lset_t debugging; /* only used #ifdef DEBUG, but don't want layout to change */
110
111 /* for WHACK_CONNECTION */
112
113 bool whack_connection;
114 bool whack_async;
115 bool ikev1;
116
117 lset_t policy;
118 time_t sa_ike_life_seconds;
119 time_t sa_ipsec_life_seconds;
120 time_t sa_rekey_margin;
121 unsigned long sa_rekey_fuzz;
122 unsigned long sa_keying_tries;
123
124 /* For DPD 3706 - Dead Peer Detection */
125 time_t dpd_delay;
126 time_t dpd_timeout;
127 dpd_action_t dpd_action;
128
129 /* note that each end contains string 2/5.id, string 3/6 cert,
130 * and string 4/7 updown
131 */
132 whack_end_t left;
133 whack_end_t right;
134
135 /* note: if the client is the gateway, the following must be equal */
136 sa_family_t addr_family; /* between gateways */
137 sa_family_t tunnel_addr_family; /* between clients */
138
139 char *ike; /* ike algo string (separated by commas) */
140 char *pfsgroup; /* pfsgroup will be "encapsulated" in esp string for pluto */
141 char *esp; /* esp algo string (separated by commas) */
142
143 /* for WHACK_KEY: */
144 bool whack_key;
145 bool whack_addkey;
146 char *keyid; /* string 8 */
147 enum pubkey_alg pubkey_alg;
148 chunk_t keyval; /* chunk */
149
150 /* for WHACK_MYID: */
151 bool whack_myid;
152 char *myid; /* string 7 */
153
154 /* for WHACK_ROUTE: */
155 bool whack_route;
156
157 /* for WHACK_UNROUTE: */
158 bool whack_unroute;
159
160 /* for WHACK_INITIATE: */
161 bool whack_initiate;
162
163 /* for WHACK_OPINITIATE */
164 bool whack_oppo_initiate;
165 ip_address oppo_my_client, oppo_peer_client;
166
167 /* for WHACK_TERMINATE: */
168 bool whack_terminate;
169
170 /* for WHACK_DELETE: */
171 bool whack_delete;
172
173 /* for WHACK_DELETESTATE: */
174 bool whack_deletestate;
175 so_serial_t whack_deletestateno;
176
177 /* for WHACK_LISTEN: */
178 bool whack_listen, whack_unlisten;
179
180 /* for WHACK_CRASH - note if a remote peer is known to have rebooted */
181 bool whack_crash;
182 ip_address whack_crash_peer;
183
184 /* for WHACK_LIST */
185 bool whack_utc;
186 lset_t whack_list;
187
188 /* for WHACK_PURGEOCSP */
189 bool whack_purgeocsp;
190
191 /* for WHACK_REREAD */
192 u_char whack_reread;
193
194 /* for WHACK_CA */
195 bool whack_ca;
196 bool whack_strict;
197
198 char *cacert;
199 char *ldaphost;
200 char *ldapbase;
201 char *crluri;
202 char *crluri2;
203 char *ocspuri;
204
205 /* for WHACK_SC_OP */
206 sc_op_t whack_sc_op;
207 int inbase, outbase;
208 char *sc_data;
209
210 /* space for strings (hope there is enough room):
211 * Note that pointers don't travel on wire.
212 * 1 connection name [name_len]
213 * 2 left's name [left.host.name.len]
214 * 3 left's cert
215 * 4 left's ca
216 * 5 left's groups
217 * 6 left's updown
218 * 7 right's name [left.host.name.len]
219 * 8 right's cert
220 * 9 right's ca
221 * 10 right's groups
222 * 11 right's updown
223 * 12 keyid
224 * 13 myid
225 * 14 cacert
226 * 15 ldaphost
227 * 16 ldapbase
228 * 17 crluri
229 * 18 crluri2
230 * 19 ocspuri
231 * 20 ike
232 " 21 esp
233 * 22 rsa_data
234 * plus keyval (limit: 8K bits + overhead), a chunk.
235 */
236 size_t str_size;
237 char string[2048];
238 };
239
240 /* Codes for status messages returned to whack.
241 * These are 3 digit decimal numerals. The structure
242 * is inspired by section 4.2 of RFC959 (FTP).
243 * Since these will end up as the exit status of whack, they
244 * must be less than 256.
245 * NOTE: ipsec_auto(8) knows about some of these numbers -- change carefully.
246 */
247 enum rc_type {
248 RC_COMMENT, /* non-commital utterance (does not affect exit status) */
249 RC_WHACK_PROBLEM, /* whack-detected problem */
250 RC_LOG, /* message aimed at log (does not affect exit status) */
251 RC_LOG_SERIOUS, /* serious message aimed at log (does not affect exit status) */
252 RC_SUCCESS, /* success (exit status 0) */
253
254 /* failure, but not definitive */
255
256 RC_RETRANSMISSION = 10,
257
258 /* improper request */
259
260 RC_DUPNAME = 20, /* attempt to reuse a connection name */
261 RC_UNKNOWN_NAME, /* connection name unknown or state number */
262 RC_ORIENT, /* cannot orient connection: neither end is us */
263 RC_CLASH, /* clash between two Road Warrior connections OVERLOADED */
264 RC_DEAF, /* need --listen before --initiate */
265 RC_ROUTE, /* cannot route */
266 RC_RTBUSY, /* cannot unroute: route busy */
267 RC_BADID, /* malformed --id */
268 RC_NOKEY, /* no key found through DNS */
269 RC_NOPEERIP, /* cannot initiate when peer IP is unknown */
270 RC_INITSHUNT, /* cannot initiate a shunt-oly connection */
271 RC_WILDCARD, /* cannot initiate when ID has wildcards */
272 RC_NOVALIDPIN, /* cannot initiate without valid PIN */
273
274 /* permanent failure */
275
276 RC_BADWHACKMESSAGE = 30,
277 RC_NORETRANSMISSION,
278 RC_INTERNALERR,
279 RC_OPPOFAILURE, /* Opportunism failed */
280
281 /* entry of secrets */
282 RC_ENTERSECRET = 40,
283
284 /* progress: start of range for successful state transition.
285 * Actual value is RC_NEW_STATE plus the new state code.
286 */
287 RC_NEW_STATE = 100,
288
289 /* start of range for notification.
290 * Actual value is RC_NOTIFICATION plus code for notification
291 * that should be generated by this Pluto.
292 */
293 RC_NOTIFICATION = 200 /* as per IKE notification messages */
294 };
295
296 /* options of whack --list*** command */
297
298 #define LIST_NONE 0x0000 /* don't list anything */
299 #define LIST_ALGS 0x0001 /* list all registered IKE algorithms */
300 #define LIST_PUBKEYS 0x0002 /* list all public keys */
301 #define LIST_CERTS 0x0004 /* list all host/user certs */
302 #define LIST_CACERTS 0x0008 /* list all ca certs */
303 #define LIST_ACERTS 0x0010 /* list all attribute certs */
304 #define LIST_AACERTS 0x0020 /* list all aa certs */
305 #define LIST_OCSPCERTS 0x0040 /* list all ocsp certs */
306 #define LIST_GROUPS 0x0080 /* list all access control groups */
307 #define LIST_CAINFOS 0x0100 /* list all ca information records */
308 #define LIST_CRLS 0x0200 /* list all crls */
309 #define LIST_OCSP 0x0400 /* list all ocsp cache entries */
310 #define LIST_CARDS 0x0800 /* list all smartcard records */
311
312 #define LIST_ALL LRANGES(LIST_ALGS, LIST_CARDS) /* all list options */
313
314 /* options of whack --reread*** command */
315
316 #define REREAD_NONE 0x00 /* don't reread anything */
317 #define REREAD_SECRETS 0x01 /* reread /etc/ipsec.secrets */
318 #define REREAD_CACERTS 0x02 /* reread certs in /etc/ipsec.d/cacerts */
319 #define REREAD_AACERTS 0x04 /* reread certs in /etc/ipsec.d/aacerts */
320 #define REREAD_OCSPCERTS 0x08 /* reread certs in /etc/ipsec.d/ocspcerts */
321 #define REREAD_ACERTS 0x10 /* reread certs in /etc/ipsec.d/acerts */
322 #define REREAD_CRLS 0x20 /* reread crls in /etc/ipsec.d/crls */
323
324 #define REREAD_ALL LRANGES(REREAD_SECRETS, REREAD_CRLS) /* all reread options */
325
326 #endif /* _WHACK_H */