9793a55a53086be62cb98e2c920329fa9fcad322
[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 struct starter_end starter_end_t;
50
51 struct starter_end {
52 lset_t seen;
53 char *id;
54 char *rsakey;
55 char *cert;
56 char *ca;
57 char *groups;
58 char *iface;
59 ip_address addr;
60 ip_address nexthop;
61 ip_address srcip;
62 ip_subnet subnet;
63 bool has_client;
64 bool has_client_wildcard;
65 bool has_port_wildcard;
66 bool has_srcip;
67 bool modecfg;
68 certpolicy_t sendcert;
69 bool firewall;
70 bool hostaccess;
71 char *updown;
72 u_int16_t port;
73 u_int8_t protocol;
74 #ifdef VIRTUAL_IP
75 char *virt;
76 #endif
77 };
78
79 typedef struct also also_t;
80
81 struct also {
82 char *name;
83 bool included;
84 also_t *next;
85 };
86
87 typedef struct starter_conn starter_conn_t;
88
89 struct starter_conn {
90 lset_t seen;
91 char *name;
92 also_t *also;
93 kw_list_t *kw;
94 u_int visit;
95 startup_t startup;
96 starter_state_t state;
97
98 keyexchange_t keyexchange;
99 lset_t policy;
100 time_t sa_ike_life_seconds;
101 time_t sa_ipsec_life_seconds;
102 time_t sa_rekey_margin;
103 unsigned long sa_keying_tries;
104 unsigned long sa_rekey_fuzz;
105 sa_family_t addr_family;
106 sa_family_t tunnel_addr_family;
107
108 starter_end_t left, right;
109
110 unsigned long id;
111
112 char *esp;
113 char *ike;
114 char *pfsgroup;
115
116 time_t dpd_delay;
117 time_t dpd_timeout;
118 dpd_action_t dpd_action;
119 int dpd_count;
120
121 starter_conn_t *next;
122 };
123
124 typedef struct starter_ca starter_ca_t;
125
126 struct starter_ca {
127 lset_t seen;
128 char *name;
129 also_t *also;
130 kw_list_t *kw;
131 u_int visit;
132 startup_t startup;
133 starter_state_t state;
134
135 char *cacert;
136 char *ldaphost;
137 char *ldapbase;
138 char *crluri;
139 char *crluri2;
140 char *ocspuri;
141
142 bool strict;
143
144 starter_ca_t *next;
145 };
146
147 typedef struct starter_config starter_config_t;
148
149 struct starter_config {
150 struct {
151 lset_t seen;
152 char **interfaces;
153 char *dumpdir;
154
155 /* pluto keywords */
156 char **plutodebug;
157 char *prepluto;
158 char *postpluto;
159 bool uniqueids;
160 u_int overridemtu;
161 u_int crlcheckinterval;
162 bool cachecrls;
163 bool strictcrlpolicy;
164 bool nocrsend;
165 bool nat_traversal;
166 u_int keep_alive;
167 char *virtual_private;
168 char *pkcs11module;
169 bool pkcs11keepstate;
170 bool pkcs11proxy;
171
172 /* KLIPS keywords */
173 char **klipsdebug;
174 bool fragicmp;
175 char *packetdefault;
176 bool hidetos;
177 } setup;
178
179 /* information about the default route */
180 defaultroute_t defaultroute;
181
182 /* number of encountered parsing errors */
183 u_int err;
184
185 /* do we parse also statements */
186 bool parse_also;
187
188 /* ca %default */
189 starter_ca_t ca_default;
190
191 /* connections list (without %default) */
192 starter_ca_t *ca_first, *ca_last;
193
194 /* conn %default */
195 starter_conn_t conn_default;
196
197 /* connections list (without %default) */
198 starter_conn_t *conn_first, *conn_last;
199 };
200
201 extern starter_config_t *confread_load(const char *file);
202 extern void confread_free(starter_config_t *cfg);
203
204 #endif /* _IPSEC_CONFREAD_H_ */
205