fe3219f32bea030016cb9906db513c59e738ed36
[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 #ifndef _FREESWAN_H
20 #include <freeswan.h>
21 #endif
22
23 #include "parser.h"
24 #include "interfaces.h"
25
26 typedef enum {
27 STARTUP_NO,
28 STARTUP_ADD,
29 STARTUP_ROUTE,
30 STARTUP_START
31 } startup_t;
32
33 typedef enum {
34 STATE_IGNORE,
35 STATE_TO_ADD,
36 STATE_ADDED,
37 STATE_REPLACED,
38 STATE_INVALID
39 } starter_state_t;
40
41 typedef enum {
42 KEY_EXCHANGE_IKE,
43 KEY_EXCHANGE_IKEV1,
44 KEY_EXCHANGE_IKEV2
45 } keyexchange_t;
46
47 typedef enum {
48 STRICT_NO,
49 STRICT_YES,
50 STRICT_IFURI
51 } strict_t;
52
53 typedef struct starter_end starter_end_t;
54
55 struct starter_end {
56 lset_t seen;
57 char *auth;
58 char *auth2;
59 char *id;
60 char *id2;
61 char *rsakey;
62 char *cert;
63 char *cert2;
64 char *ca;
65 char *ca2;
66 char *groups;
67 char *cert_policy;
68 char *iface;
69 ip_address addr;
70 u_int ikeport;
71 ip_address nexthop;
72 char *subnet;
73 bool has_client;
74 bool has_client_wildcard;
75 bool has_port_wildcard;
76 bool has_natip;
77 bool has_virt;
78 bool modecfg;
79 certpolicy_t sendcert;
80 bool firewall;
81 bool hostaccess;
82 bool allow_any;
83 bool dns_failed;
84 char *updown;
85 u_int16_t port;
86 u_int8_t protocol;
87 char *sourceip;
88 int sourceip_mask;
89 };
90
91 typedef struct also also_t;
92
93 struct also {
94 char *name;
95 bool included;
96 also_t *next;
97 };
98
99 typedef struct starter_conn starter_conn_t;
100
101 struct starter_conn {
102 lset_t seen;
103 char *name;
104 also_t *also;
105 kw_list_t *kw;
106 u_int visit;
107 startup_t startup;
108 starter_state_t state;
109
110 keyexchange_t keyexchange;
111 u_int32_t eap_type;
112 u_int32_t eap_vendor;
113 char *eap_identity;
114 char *aaa_identity;
115 char *xauth_identity;
116 lset_t policy;
117 time_t sa_ike_life_seconds;
118 time_t sa_ipsec_life_seconds;
119 time_t sa_rekey_margin;
120 u_int64_t sa_ipsec_life_bytes;
121 u_int64_t sa_ipsec_margin_bytes;
122 u_int64_t sa_ipsec_life_packets;
123 u_int64_t sa_ipsec_margin_packets;
124 unsigned long sa_keying_tries;
125 unsigned long sa_rekey_fuzz;
126 u_int32_t reqid;
127 mark_t mark_in;
128 mark_t mark_out;
129 u_int32_t tfc;
130 sa_family_t addr_family;
131 sa_family_t tunnel_addr_family;
132 bool install_policy;
133 starter_end_t left, right;
134
135 unsigned long id;
136
137 char *esp;
138 char *ike;
139 char *pfsgroup;
140
141 time_t dpd_delay;
142 time_t dpd_timeout;
143 dpd_action_t dpd_action;
144 int dpd_count;
145
146 dpd_action_t close_action;
147
148 time_t inactivity;
149
150 bool me_mediation;
151 char *me_mediated_by;
152 char *me_peerid;
153
154 starter_conn_t *next;
155 };
156
157 typedef struct starter_ca starter_ca_t;
158
159 struct starter_ca {
160 lset_t seen;
161 char *name;
162 also_t *also;
163 kw_list_t *kw;
164 u_int visit;
165 startup_t startup;
166 starter_state_t state;
167
168 char *cacert;
169 char *ldaphost;
170 char *ldapbase;
171 char *crluri;
172 char *crluri2;
173 char *ocspuri;
174 char *ocspuri2;
175 char *certuribase;
176
177 bool strict;
178
179 starter_ca_t *next;
180 };
181
182 typedef struct starter_config starter_config_t;
183
184 struct starter_config {
185 struct {
186 lset_t seen;
187 char **interfaces;
188 char *dumpdir;
189 bool charonstart;
190 bool plutostart;
191
192 /* pluto/charon keywords */
193 char **plutodebug;
194 char *charondebug;
195 char *prepluto;
196 char *postpluto;
197 char *plutostderrlog;
198 bool uniqueids;
199 u_int overridemtu;
200 u_int crlcheckinterval;
201 bool cachecrls;
202 strict_t strictcrlpolicy;
203 bool nocrsend;
204 bool nat_traversal;
205 u_int keep_alive;
206 u_int force_keepalive;
207 char *virtual_private;
208 char *pkcs11module;
209 char *pkcs11initargs;
210 bool pkcs11keepstate;
211 bool pkcs11proxy;
212
213 /* KLIPS keywords */
214 char **klipsdebug;
215 bool fragicmp;
216 char *packetdefault;
217 bool hidetos;
218 } setup;
219
220 /* information about the default route */
221 defaultroute_t defaultroute;
222
223 /* number of encountered parsing errors */
224 u_int err;
225 u_int non_fatal_err;
226
227 /* do we parse also statements */
228 bool parse_also;
229
230 /* ca %default */
231 starter_ca_t ca_default;
232
233 /* connections list (without %default) */
234 starter_ca_t *ca_first, *ca_last;
235
236 /* conn %default */
237 starter_conn_t conn_default;
238
239 /* connections list (without %default) */
240 starter_conn_t *conn_first, *conn_last;
241 };
242
243 extern starter_config_t *confread_load(const char *file);
244 extern void confread_free(starter_config_t *cfg);
245
246 #endif /* _IPSEC_CONFREAD_H_ */
247