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