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