2fe75fcc63118aa9d597a5816442bbe78395ce98
[strongswan.git] / src / starter / confread.h
1 /* strongSwan IPsec config file parser
2 * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
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 * RCSID $Id: confread.h,v 1.23 2006/04/17 10:32:36 as Exp $
15 */
16
17 #ifndef _IPSEC_CONFREAD_H_
18 #define _IPSEC_CONFREAD_H_
19
20 #ifndef _FREESWAN_H
21 #include <freeswan.h>
22 #include "../pluto/constants.h"
23 #endif
24
25 #include "parser.h"
26 #include "interfaces.h"
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 KEY_EXCHANGE_IKE,
45 KEY_EXCHANGE_IKEV1,
46 KEY_EXCHANGE_IKEV2
47 } keyexchange_t;
48
49 typedef enum {
50 STRICT_NO,
51 STRICT_YES,
52 STRICT_IFURI
53 } strict_t;
54
55 typedef struct starter_end starter_end_t;
56
57 struct starter_end {
58 lset_t seen;
59 char *id;
60 char *rsakey;
61 char *cert;
62 char *ca;
63 char *groups;
64 char *iface;
65 ip_address addr;
66 ip_address nexthop;
67 ip_address srcip;
68 ip_subnet subnet;
69 bool has_client;
70 bool has_client_wildcard;
71 bool has_port_wildcard;
72 bool has_srcip;
73 bool has_natip;
74 bool modecfg;
75 certpolicy_t sendcert;
76 bool firewall;
77 bool hostaccess;
78 char *updown;
79 u_int16_t port;
80 u_int8_t protocol;
81 char *virt;
82 };
83
84 typedef struct also also_t;
85
86 struct also {
87 char *name;
88 bool included;
89 also_t *next;
90 };
91
92 typedef struct starter_conn starter_conn_t;
93
94 struct starter_conn {
95 lset_t seen;
96 char *name;
97 also_t *also;
98 kw_list_t *kw;
99 u_int visit;
100 startup_t startup;
101 starter_state_t state;
102
103 keyexchange_t keyexchange;
104 int eap;
105 lset_t policy;
106 time_t sa_ike_life_seconds;
107 time_t sa_ipsec_life_seconds;
108 time_t sa_rekey_margin;
109 unsigned long sa_keying_tries;
110 unsigned long sa_rekey_fuzz;
111 sa_family_t addr_family;
112 sa_family_t tunnel_addr_family;
113
114 starter_end_t left, right;
115
116 unsigned long id;
117
118 char *esp;
119 char *ike;
120 char *pfsgroup;
121
122 time_t dpd_delay;
123 time_t dpd_timeout;
124 dpd_action_t dpd_action;
125 int dpd_count;
126
127 starter_conn_t *next;
128 };
129
130 typedef struct starter_ca starter_ca_t;
131
132 struct starter_ca {
133 lset_t seen;
134 char *name;
135 also_t *also;
136 kw_list_t *kw;
137 u_int visit;
138 startup_t startup;
139 starter_state_t state;
140
141 char *cacert;
142 char *ldaphost;
143 char *ldapbase;
144 char *crluri;
145 char *crluri2;
146 char *ocspuri;
147 char *ocspuri2;
148
149 bool strict;
150
151 starter_ca_t *next;
152 };
153
154 typedef struct starter_config starter_config_t;
155
156 struct starter_config {
157 struct {
158 lset_t seen;
159 char **interfaces;
160 char *dumpdir;
161 bool charonstart;
162 bool plutostart;
163
164 /* pluto/charon keywords */
165 char **plutodebug;
166 char *charondebug;
167 char *prepluto;
168 char *postpluto;
169 bool uniqueids;
170 u_int overridemtu;
171 u_int crlcheckinterval;
172 bool cachecrls;
173 strict_t strictcrlpolicy;
174 bool nocrsend;
175 bool nat_traversal;
176 u_int keep_alive;
177 char *virtual_private;
178 char *eapdir;
179 char *pkcs11module;
180 bool pkcs11keepstate;
181 bool pkcs11proxy;
182
183 /* KLIPS keywords */
184 char **klipsdebug;
185 bool fragicmp;
186 char *packetdefault;
187 bool hidetos;
188 } setup;
189
190 /* information about the default route */
191 defaultroute_t defaultroute;
192
193 /* number of encountered parsing errors */
194 u_int err;
195
196 /* do we parse also statements */
197 bool parse_also;
198
199 /* ca %default */
200 starter_ca_t ca_default;
201
202 /* connections list (without %default) */
203 starter_ca_t *ca_first, *ca_last;
204
205 /* conn %default */
206 starter_conn_t conn_default;
207
208 /* connections list (without %default) */
209 starter_conn_t *conn_first, *conn_last;
210 };
211
212 extern starter_config_t *confread_load(const char *file);
213 extern void confread_free(starter_config_t *cfg);
214
215 #endif /* _IPSEC_CONFREAD_H_ */
216