starter: Removed all unsupported keywords.
[strongswan.git] / src / starter / confread.h
1 /* strongSwan IPsec config file parser
2 * Copyright (C) 2001-2002 Mathieu Lafon
3 * Arkoon Network Security
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #ifndef _IPSEC_CONFREAD_H_
17 #define _IPSEC_CONFREAD_H_
18
19 #include <kernel/kernel_ipsec.h>
20
21 #include "ipsec-parser.h"
22
23 /** to mark seen keywords */
24 typedef u_int64_t seen_t;
25 #define SEEN_NONE 0;
26 #define SEEN_KW(kw, base) ((seen_t)1 << ((kw) - (base)))
27
28 typedef enum {
29 STARTUP_NO,
30 STARTUP_ADD,
31 STARTUP_ROUTE,
32 STARTUP_START
33 } startup_t;
34
35 typedef enum {
36 STATE_IGNORE,
37 STATE_TO_ADD,
38 STATE_ADDED,
39 STATE_REPLACED,
40 STATE_INVALID
41 } starter_state_t;
42
43 typedef enum {
44 /* shared with ike_version_t */
45 KEY_EXCHANGE_IKE = 0,
46 KEY_EXCHANGE_IKEV1 = 1,
47 KEY_EXCHANGE_IKEV2 = 2,
48 } keyexchange_t;
49
50 typedef enum {
51 STRICT_NO,
52 STRICT_YES,
53 STRICT_IFURI
54 } strict_t;
55
56 typedef enum {
57 CERT_ALWAYS_SEND,
58 CERT_SEND_IF_ASKED,
59 CERT_NEVER_SEND,
60 CERT_YES_SEND, /* synonym for CERT_ALWAYS_SEND */
61 CERT_NO_SEND, /* synonym for CERT_NEVER_SEND */
62 } certpolicy_t;
63
64 typedef enum {
65 DPD_ACTION_NONE,
66 DPD_ACTION_CLEAR,
67 DPD_ACTION_HOLD,
68 DPD_ACTION_RESTART,
69 DPD_ACTION_UNKNOW,
70 } dpd_action_t;
71
72 typedef enum {
73 /* IPsec options */
74 SA_OPTION_AUTHENTICATE = 1 << 0, /* use AH instead of ESP? */
75 SA_OPTION_COMPRESS = 1 << 1, /* use IPComp */
76
77 /* IKE and other other options */
78 SA_OPTION_DONT_REKEY = 1 << 2, /* don't rekey state either Phase */
79 SA_OPTION_DONT_REAUTH = 1 << 3, /* don't reauthenticate on rekeying, IKEv2 only */
80 SA_OPTION_MODECFG_PUSH = 1 << 4, /* is modecfg pushed by server? */
81 SA_OPTION_XAUTH_SERVER = 1 << 5, /* are we an XAUTH server? */
82 SA_OPTION_MOBIKE = 1 << 6, /* enable MOBIKE for IKEv2 */
83 SA_OPTION_FORCE_ENCAP = 1 << 7, /* force UDP encapsulation */
84 } sa_option_t;
85
86 typedef struct starter_end starter_end_t;
87
88 struct starter_end {
89 seen_t seen;
90 char *auth;
91 char *auth2;
92 char *id;
93 char *id2;
94 char *rsakey;
95 char *cert;
96 char *cert2;
97 char *ca;
98 char *ca2;
99 char *groups;
100 char *cert_policy;
101 char *host;
102 u_int ikeport;
103 char *subnet;
104 bool has_natip;
105 bool modecfg;
106 certpolicy_t sendcert;
107 bool firewall;
108 bool hostaccess;
109 bool allow_any;
110 char *updown;
111 u_int16_t port;
112 u_int8_t protocol;
113 char *sourceip;
114 int sourceip_mask;
115 };
116
117 typedef struct also also_t;
118
119 struct also {
120 char *name;
121 bool included;
122 also_t *next;
123 };
124
125 typedef struct starter_conn starter_conn_t;
126
127 struct starter_conn {
128 seen_t seen;
129 char *name;
130 also_t *also;
131 kw_list_t *kw;
132 u_int visit;
133 startup_t startup;
134 starter_state_t state;
135
136 keyexchange_t keyexchange;
137 char *eap_identity;
138 char *aaa_identity;
139 char *xauth_identity;
140 char *authby;
141 ipsec_mode_t mode;
142 bool proxy_mode;
143 sa_option_t options;
144 time_t sa_ike_life_seconds;
145 time_t sa_ipsec_life_seconds;
146 time_t sa_rekey_margin;
147 u_int64_t sa_ipsec_life_bytes;
148 u_int64_t sa_ipsec_margin_bytes;
149 u_int64_t sa_ipsec_life_packets;
150 u_int64_t sa_ipsec_margin_packets;
151 unsigned long sa_keying_tries;
152 unsigned long sa_rekey_fuzz;
153 u_int32_t reqid;
154 mark_t mark_in;
155 mark_t mark_out;
156 u_int32_t tfc;
157 bool install_policy;
158 bool aggressive;
159 starter_end_t left, right;
160
161 unsigned long id;
162
163 char *esp;
164 char *ike;
165
166 time_t dpd_delay;
167 time_t dpd_timeout;
168 dpd_action_t dpd_action;
169 int dpd_count;
170
171 dpd_action_t close_action;
172
173 time_t inactivity;
174
175 bool me_mediation;
176 char *me_mediated_by;
177 char *me_peerid;
178
179 starter_conn_t *next;
180 };
181
182 typedef struct starter_ca starter_ca_t;
183
184 struct starter_ca {
185 seen_t seen;
186 char *name;
187 also_t *also;
188 kw_list_t *kw;
189 u_int visit;
190 startup_t startup;
191 starter_state_t state;
192
193 char *cacert;
194 char *ldaphost;
195 char *ldapbase;
196 char *crluri;
197 char *crluri2;
198 char *ocspuri;
199 char *ocspuri2;
200 char *certuribase;
201
202 bool strict;
203
204 starter_ca_t *next;
205 };
206
207 typedef struct starter_config starter_config_t;
208
209 struct starter_config {
210 struct {
211 seen_t seen;
212 bool charonstart;
213 char *charondebug;
214 bool uniqueids;
215 bool cachecrls;
216 strict_t strictcrlpolicy;
217 } setup;
218
219 /* number of encountered parsing errors */
220 u_int err;
221 u_int non_fatal_err;
222
223 /* do we parse also statements */
224 bool parse_also;
225
226 /* ca %default */
227 starter_ca_t ca_default;
228
229 /* connections list (without %default) */
230 starter_ca_t *ca_first, *ca_last;
231
232 /* conn %default */
233 starter_conn_t conn_default;
234
235 /* connections list (without %default) */
236 starter_conn_t *conn_first, *conn_last;
237 };
238
239 extern starter_config_t *confread_load(const char *file);
240 extern void confread_free(starter_config_t *cfg);
241
242 #endif /* _IPSEC_CONFREAD_H_ */
243