7f321162825b718e174093d55ffc4d8a87ca2234
[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 *iface;
68 ip_address addr;
69 ip_address nexthop;
70 char *subnet;
71 bool has_client;
72 bool has_client_wildcard;
73 bool has_port_wildcard;
74 bool has_natip;
75 bool has_virt;
76 bool modecfg;
77 certpolicy_t sendcert;
78 bool firewall;
79 bool hostaccess;
80 bool allow_any;
81 bool dns_failed;
82 char *updown;
83 u_int16_t port;
84 u_int8_t protocol;
85 char *sourceip;
86 int sourceip_mask;
87 };
88
89 typedef struct also also_t;
90
91 struct also {
92 char *name;
93 bool included;
94 also_t *next;
95 };
96
97 typedef struct starter_conn starter_conn_t;
98
99 struct starter_conn {
100 lset_t seen;
101 char *name;
102 also_t *also;
103 kw_list_t *kw;
104 u_int visit;
105 startup_t startup;
106 starter_state_t state;
107
108 keyexchange_t keyexchange;
109 u_int32_t eap_type;
110 u_int32_t eap_vendor;
111 char *eap_identity;
112 lset_t policy;
113 time_t sa_ike_life_seconds;
114 time_t sa_ipsec_life_seconds;
115 time_t sa_rekey_margin;
116 u_int64_t sa_ipsec_life_bytes;
117 u_int64_t sa_ipsec_margin_bytes;
118 u_int64_t sa_ipsec_life_packets;
119 u_int64_t sa_ipsec_margin_packets;
120 unsigned long sa_keying_tries;
121 unsigned long sa_rekey_fuzz;
122 sa_family_t addr_family;
123 sa_family_t tunnel_addr_family;
124 bool install_policy;
125 starter_end_t left, right;
126
127 unsigned long id;
128
129 char *esp;
130 char *ike;
131 char *pfsgroup;
132
133 time_t dpd_delay;
134 time_t dpd_timeout;
135 dpd_action_t dpd_action;
136 int dpd_count;
137
138 time_t inactivity;
139
140 bool me_mediation;
141 char *me_mediated_by;
142 char *me_peerid;
143
144 starter_conn_t *next;
145 };
146
147 typedef struct starter_ca starter_ca_t;
148
149 struct starter_ca {
150 lset_t seen;
151 char *name;
152 also_t *also;
153 kw_list_t *kw;
154 u_int visit;
155 startup_t startup;
156 starter_state_t state;
157
158 char *cacert;
159 char *ldaphost;
160 char *ldapbase;
161 char *crluri;
162 char *crluri2;
163 char *ocspuri;
164 char *ocspuri2;
165 char *certuribase;
166
167 bool strict;
168
169 starter_ca_t *next;
170 };
171
172 typedef struct starter_config starter_config_t;
173
174 struct starter_config {
175 struct {
176 lset_t seen;
177 char **interfaces;
178 char *dumpdir;
179 bool charonstart;
180 bool plutostart;
181
182 /* pluto/charon keywords */
183 char **plutodebug;
184 char *charondebug;
185 char *prepluto;
186 char *postpluto;
187 char *plutostderrlog;
188 bool uniqueids;
189 u_int overridemtu;
190 u_int crlcheckinterval;
191 bool cachecrls;
192 strict_t strictcrlpolicy;
193 bool nocrsend;
194 bool nat_traversal;
195 u_int keep_alive;
196 u_int force_keepalive;
197 char *virtual_private;
198 char *pkcs11module;
199 char *pkcs11initargs;
200 bool pkcs11keepstate;
201 bool pkcs11proxy;
202
203 /* KLIPS keywords */
204 char **klipsdebug;
205 bool fragicmp;
206 char *packetdefault;
207 bool hidetos;
208 } setup;
209
210 /* information about the default route */
211 defaultroute_t defaultroute;
212
213 /* number of encountered parsing errors */
214 u_int err;
215 u_int non_fatal_err;
216
217 /* do we parse also statements */
218 bool parse_also;
219
220 /* ca %default */
221 starter_ca_t ca_default;
222
223 /* connections list (without %default) */
224 starter_ca_t *ca_first, *ca_last;
225
226 /* conn %default */
227 starter_conn_t conn_default;
228
229 /* connections list (without %default) */
230 starter_conn_t *conn_first, *conn_last;
231 };
232
233 extern starter_config_t *confread_load(const char *file);
234 extern void confread_free(starter_config_t *cfg);
235
236 #endif /* _IPSEC_CONFREAD_H_ */
237