nm: Pass external gateway to NM
[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 #include <kernel/kernel_ipsec.h>
20
21 typedef enum {
22 STARTUP_NO,
23 STARTUP_ADD,
24 STARTUP_ROUTE,
25 STARTUP_START
26 } startup_t;
27
28 typedef enum {
29 STATE_IGNORE,
30 STATE_TO_ADD,
31 STATE_ADDED,
32 STATE_REPLACED,
33 STATE_INVALID
34 } starter_state_t;
35
36 typedef enum {
37 /* shared with ike_version_t */
38 KEY_EXCHANGE_IKE = 0,
39 KEY_EXCHANGE_IKEV1 = 1,
40 KEY_EXCHANGE_IKEV2 = 2,
41 } keyexchange_t;
42
43 typedef enum {
44 STRICT_NO,
45 STRICT_YES,
46 STRICT_IFURI,
47 } strict_t;
48
49 typedef enum {
50 CERT_ALWAYS_SEND,
51 CERT_SEND_IF_ASKED,
52 CERT_NEVER_SEND,
53 CERT_YES_SEND, /* synonym for CERT_ALWAYS_SEND */
54 CERT_NO_SEND, /* synonym for CERT_NEVER_SEND */
55 } certpolicy_t;
56
57 typedef enum {
58 DPD_ACTION_NONE,
59 DPD_ACTION_CLEAR,
60 DPD_ACTION_HOLD,
61 DPD_ACTION_RESTART,
62 DPD_ACTION_UNKNOW,
63 } dpd_action_t;
64
65 typedef enum {
66 /* same as in ike_cfg.h */
67 FRAGMENTATION_NO,
68 FRAGMENTATION_YES,
69 FRAGMENTATION_FORCE,
70 } fragmentation_t;
71
72 typedef enum {
73 /* IPsec options */
74 SA_OPTION_COMPRESS = 1 << 1, /* use IPComp */
75
76 /* IKE and other other options */
77 SA_OPTION_DONT_REKEY = 1 << 2, /* don't rekey state either Phase */
78 SA_OPTION_DONT_REAUTH = 1 << 3, /* don't reauthenticate on rekeying, IKEv2 only */
79 SA_OPTION_MODECFG_PUSH = 1 << 4, /* is modecfg pushed by server? */
80 SA_OPTION_XAUTH_SERVER = 1 << 5, /* are we an XAUTH server? */
81 SA_OPTION_MOBIKE = 1 << 6, /* enable MOBIKE for IKEv2 */
82 SA_OPTION_FORCE_ENCAP = 1 << 7, /* force UDP encapsulation */
83 } sa_option_t;
84
85 typedef struct starter_end starter_end_t;
86
87 struct starter_end {
88 char *auth;
89 char *auth2;
90 char *id;
91 char *id2;
92 char *rsakey;
93 char *cert;
94 char *cert2;
95 char *ca;
96 char *ca2;
97 char *groups;
98 char *groups2;
99 char *cert_policy;
100 char *host;
101 u_int ikeport;
102 char *subnet;
103 bool modecfg;
104 certpolicy_t sendcert;
105 bool firewall;
106 bool hostaccess;
107 bool allow_any;
108 char *updown;
109 uint16_t from_port;
110 uint16_t to_port;
111 uint8_t protocol;
112 char *sourceip;
113 char *dns;
114 };
115
116 typedef struct starter_conn starter_conn_t;
117
118 struct starter_conn {
119 char *name;
120 startup_t startup;
121 starter_state_t state;
122
123 keyexchange_t keyexchange;
124 char *eap_identity;
125 char *aaa_identity;
126 char *xauth_identity;
127 char *authby;
128 ipsec_mode_t mode;
129 bool proxy_mode;
130 fragmentation_t fragmentation;
131 u_int ikedscp;
132 sa_option_t options;
133 time_t sa_ike_life_seconds;
134 time_t sa_ipsec_life_seconds;
135 time_t sa_rekey_margin;
136 uint64_t sa_ipsec_life_bytes;
137 uint64_t sa_ipsec_margin_bytes;
138 uint64_t sa_ipsec_life_packets;
139 uint64_t sa_ipsec_margin_packets;
140 unsigned long sa_keying_tries;
141 unsigned long sa_rekey_fuzz;
142 uint32_t reqid;
143 mark_t mark_in;
144 mark_t mark_out;
145 uint32_t replay_window;
146 uint32_t tfc;
147 bool install_policy;
148 bool aggressive;
149 starter_end_t left, right;
150
151 unsigned long id;
152
153 char *esp;
154 char *ah;
155 char *ike;
156
157 time_t dpd_delay;
158 time_t dpd_timeout;
159 dpd_action_t dpd_action;
160 int dpd_count;
161
162 dpd_action_t close_action;
163
164 time_t inactivity;
165
166 bool me_mediation;
167 char *me_mediated_by;
168 char *me_peerid;
169
170 starter_conn_t *next;
171 };
172
173 typedef struct starter_ca starter_ca_t;
174
175 struct starter_ca {
176 char *name;
177 startup_t startup;
178 starter_state_t state;
179
180 char *cacert;
181 char *crluri;
182 char *crluri2;
183 char *ocspuri;
184 char *ocspuri2;
185 char *certuribase;
186
187 bool strict;
188
189 starter_ca_t *next;
190 };
191
192 typedef struct starter_config starter_config_t;
193
194 struct starter_config {
195 struct {
196 char *charondebug;
197 bool uniqueids;
198 bool cachecrls;
199 strict_t strictcrlpolicy;
200 } setup;
201
202 /* number of encountered parsing errors */
203 u_int err;
204 u_int non_fatal_err;
205
206 /* connections list */
207 starter_ca_t *ca_first, *ca_last;
208
209 /* connections list */
210 starter_conn_t *conn_first, *conn_last;
211 };
212
213 starter_config_t *confread_load(const char *file);
214 void confread_free(starter_config_t *cfg);
215
216 #endif /* _IPSEC_CONFREAD_H_ */