]>
Commit | Line | Data |
---|---|---|
6fbf66fa JY |
1 | /* |
2 | * OpenVPN -- An application to securely tunnel IP networks | |
3 | * over a single UDP port, with support for SSL/TLS-based | |
4 | * session authentication and key exchange, | |
5 | * packet encryption, packet authentication, and | |
6 | * packet compression. | |
7 | * | |
49979459 | 8 | * Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net> |
6fbf66fa JY |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License version 2 | |
12 | * as published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
caa54ac3 DS |
19 | * You should have received a copy of the GNU General Public License along |
20 | * with this program; if not, write to the Free Software Foundation, Inc., | |
21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
6fbf66fa JY |
22 | */ |
23 | ||
24 | /* | |
25 | * 2004-01-28: Added Socks5 proxy support | |
26 | * (Christof Meerwald, http://cmeerw.org) | |
27 | */ | |
28 | ||
29 | #ifndef OPTIONS_H | |
30 | #define OPTIONS_H | |
31 | ||
32 | #include "basic.h" | |
33 | #include "common.h" | |
34 | #include "mtu.h" | |
35 | #include "route.h" | |
36 | #include "tun.h" | |
37 | #include "socket.h" | |
38 | #include "plugin.h" | |
39 | #include "manage.h" | |
40 | #include "proxy.h" | |
38d96bd7 | 41 | #include "comp.h" |
3eee126e | 42 | #include "pushlist.h" |
581bef87 | 43 | #include "clinat.h" |
2193d7c0 | 44 | #include "crypto_backend.h" |
2193d7c0 | 45 | |
6fbf66fa JY |
46 | |
47 | /* | |
48 | * Maximum number of parameters associated with an option, | |
49 | * including the option name itself. | |
50 | */ | |
51 | #define MAX_PARMS 16 | |
52 | ||
53 | /* | |
54 | * Max size of options line and parameter. | |
55 | */ | |
56 | #define OPTION_PARM_SIZE 256 | |
57 | #define OPTION_LINE_SIZE 256 | |
58 | ||
59 | extern const char title_string[]; | |
60 | ||
61 | #if P2MP | |
62 | ||
6fbf66fa JY |
63 | /* certain options are saved before --pull modifications are applied */ |
64 | struct options_pre_pull | |
65 | { | |
81d882d5 DS |
66 | bool tuntap_options_defined; |
67 | struct tuntap_options tuntap_options; | |
6fbf66fa | 68 | |
81d882d5 DS |
69 | bool routes_defined; |
70 | struct route_option_list *routes; | |
6fbf66fa | 71 | |
81d882d5 DS |
72 | bool routes_ipv6_defined; |
73 | struct route_ipv6_option_list *routes_ipv6; | |
91402236 | 74 | |
81d882d5 DS |
75 | bool client_nat_defined; |
76 | struct client_nat_option_list *client_nat; | |
581bef87 | 77 | |
81d882d5 | 78 | int foreign_option_index; |
6fbf66fa JY |
79 | }; |
80 | ||
253329a8 | 81 | #endif |
c7ca9133 | 82 | #if !defined(ENABLE_CRYPTO_OPENSSL) && !defined(ENABLE_CRYPTO_MBEDTLS) |
81d882d5 | 83 | #error "At least one of OpenSSL or mbed TLS needs to be defined." |
6fbf66fa JY |
84 | #endif |
85 | ||
4e9a51d7 JY |
86 | struct connection_entry |
87 | { | |
81d882d5 DS |
88 | int proto; |
89 | sa_family_t af; | |
90 | const char *local_port; | |
91 | bool local_port_defined; | |
92 | const char *remote_port; | |
93 | const char *local; | |
94 | const char *remote; | |
95 | bool remote_float; | |
96 | bool bind_defined; | |
97 | bool bind_ipv6_only; | |
98 | bool bind_local; | |
99 | int connect_retry_seconds; | |
100 | int connect_retry_seconds_max; | |
101 | int connect_timeout; | |
102 | struct http_proxy_options *http_proxy_options; | |
103 | const char *socks_proxy_server; | |
104 | const char *socks_proxy_port; | |
105 | const char *socks_proxy_authfile; | |
106 | ||
107 | int tun_mtu; /* MTU of tun device */ | |
108 | bool tun_mtu_defined; /* true if user overriding parm with command line option */ | |
109 | int tun_mtu_extra; | |
110 | bool tun_mtu_extra_defined; | |
111 | int link_mtu; /* MTU of device over which tunnel packets pass via TCP/UDP */ | |
112 | bool link_mtu_defined; /* true if user overriding parm with command line option */ | |
113 | ||
114 | /* Advanced MTU negotiation and datagram fragmentation options */ | |
115 | int mtu_discover_type; /* used if OS supports setting Path MTU discovery options on socket */ | |
116 | ||
117 | int fragment; /* internal fragmentation size */ | |
118 | int mssfix; /* Upper bound on TCP MSS */ | |
119 | bool mssfix_default; /* true if --mssfix was supplied without a parameter */ | |
120 | ||
121 | int explicit_exit_notification; /* Explicitly tell peer when we are exiting via OCC_EXIT or [RESTART] message */ | |
122 | ||
123 | #define CE_DISABLED (1<<0) | |
124 | #define CE_MAN_QUERY_PROXY (1<<1) | |
125 | #define CE_MAN_QUERY_REMOTE_UNDEF 0 | |
126 | #define CE_MAN_QUERY_REMOTE_QUERY 1 | |
127 | #define CE_MAN_QUERY_REMOTE_ACCEPT 2 | |
128 | #define CE_MAN_QUERY_REMOTE_MOD 3 | |
129 | #define CE_MAN_QUERY_REMOTE_SKIP 4 | |
130 | #define CE_MAN_QUERY_REMOTE_MASK (0x07) | |
131 | #define CE_MAN_QUERY_REMOTE_SHIFT (2) | |
132 | unsigned int flags; | |
57d6f103 AQ |
133 | |
134 | /* Shared secret used for TLS control channel authentication */ | |
135 | const char *tls_auth_file; | |
cb2e9218 | 136 | bool tls_auth_file_inline; |
57d6f103 AQ |
137 | int key_direction; |
138 | ||
139 | /* Shared secret used for TLS control channel authenticated encryption */ | |
140 | const char *tls_crypt_file; | |
cb2e9218 | 141 | bool tls_crypt_file_inline; |
9d59029a SK |
142 | |
143 | /* Client-specific secret or server key used for TLS control channel | |
144 | * authenticated encryption v2 */ | |
145 | const char *tls_crypt_v2_file; | |
cb2e9218 | 146 | bool tls_crypt_v2_file_inline; |
4e9a51d7 JY |
147 | }; |
148 | ||
149 | struct remote_entry | |
150 | { | |
81d882d5 DS |
151 | const char *remote; |
152 | const char *remote_port; | |
153 | int proto; | |
154 | sa_family_t af; | |
4e9a51d7 JY |
155 | }; |
156 | ||
4e9a51d7 JY |
157 | #define CONNECTION_LIST_SIZE 64 |
158 | ||
159 | struct connection_list | |
160 | { | |
81d882d5 DS |
161 | int len; |
162 | int current; | |
163 | struct connection_entry *array[CONNECTION_LIST_SIZE]; | |
4e9a51d7 JY |
164 | }; |
165 | ||
166 | struct remote_list | |
167 | { | |
81d882d5 DS |
168 | int len; |
169 | struct remote_entry *array[CONNECTION_LIST_SIZE]; | |
4e9a51d7 JY |
170 | }; |
171 | ||
99f28081 AQ |
172 | enum vlan_acceptable_frames |
173 | { | |
e375a5ce | 174 | VLAN_ONLY_TAGGED, |
99f28081 | 175 | VLAN_ONLY_UNTAGGED_OR_PRIORITY, |
d626fa17 | 176 | VLAN_ALL, |
99f28081 AQ |
177 | }; |
178 | ||
54561af6 JY |
179 | struct remote_host_store |
180 | { | |
81d882d5 DS |
181 | #define RH_HOST_LEN 80 |
182 | char host[RH_HOST_LEN]; | |
076fd3e4 | 183 | #define RH_PORT_LEN 20 |
81d882d5 | 184 | char port[RH_PORT_LEN]; |
54561af6 | 185 | }; |
54561af6 | 186 | |
0d80b562 AS |
187 | enum genkey_type { |
188 | GENKEY_SECRET, | |
189 | GENKEY_TLS_CRYPTV2_CLIENT, | |
190 | GENKEY_TLS_CRYPTV2_SERVER, | |
1b9a88a2 | 191 | GENKEY_AUTH_TOKEN |
0d80b562 AS |
192 | }; |
193 | ||
6fbf66fa JY |
194 | /* Command line options */ |
195 | struct options | |
196 | { | |
81d882d5 DS |
197 | struct gc_arena gc; |
198 | bool gc_owned; | |
6fbf66fa | 199 | |
81d882d5 DS |
200 | /* first config file */ |
201 | const char *config; | |
6fbf66fa | 202 | |
81d882d5 DS |
203 | /* major mode */ |
204 | #define MODE_POINT_TO_POINT 0 | |
205 | #define MODE_SERVER 1 | |
206 | int mode; | |
6fbf66fa | 207 | |
81d882d5 DS |
208 | /* enable forward compatibility for post-2.1 features */ |
209 | bool forward_compatible; | |
42d9f324 | 210 | /* list of options that should be ignored even if unknown */ |
81d882d5 | 211 | const char **ignore_unknown_option; |
373faab1 | 212 | |
81d882d5 DS |
213 | /* persist parms */ |
214 | bool persist_config; | |
215 | int persist_mode; | |
6fbf66fa | 216 | |
81d882d5 DS |
217 | const char *key_pass_file; |
218 | bool show_ciphers; | |
219 | bool show_digests; | |
220 | bool show_engines; | |
221 | bool show_tls_ciphers; | |
222 | bool show_curves; | |
223 | bool genkey; | |
0d80b562 | 224 | enum genkey_type genkey_type; |
9cf7b492 AS |
225 | const char *genkey_filename; |
226 | const char *genkey_extra_data; | |
81d882d5 DS |
227 | |
228 | /* Networking parms */ | |
229 | int connect_retry_max; | |
230 | struct connection_entry ce; | |
231 | struct connection_list *connection_list; | |
232 | ||
233 | struct remote_list *remote_list; | |
234 | /* Do not advanced the connection or remote addr list*/ | |
235 | bool no_advance; | |
236 | /* Counts the number of unsuccessful connection attempts */ | |
237 | unsigned int unsuccessful_attempts; | |
4e9a51d7 | 238 | |
a4b8f653 | 239 | #if ENABLE_MANAGEMENT |
81d882d5 DS |
240 | struct http_proxy_options *http_proxy_override; |
241 | #endif | |
242 | ||
243 | struct remote_host_store *rh_store; | |
244 | ||
245 | bool remote_random; | |
246 | const char *ipchange; | |
247 | const char *dev; | |
248 | const char *dev_type; | |
249 | const char *dev_node; | |
250 | const char *lladdr; | |
251 | int topology; /* one of the TOP_x values from proto.h */ | |
252 | const char *ifconfig_local; | |
253 | const char *ifconfig_remote_netmask; | |
254 | const char *ifconfig_ipv6_local; | |
255 | int ifconfig_ipv6_netbits; | |
256 | const char *ifconfig_ipv6_remote; | |
257 | bool ifconfig_noexec; | |
258 | bool ifconfig_nowarn; | |
3d163bc5 | 259 | #ifdef ENABLE_FEATURE_SHAPER |
81d882d5 | 260 | int shaper; |
6fbf66fa | 261 | #endif |
6fbf66fa | 262 | |
81d882d5 | 263 | int proto_force; |
51e6e5b0 | 264 | |
6fbf66fa | 265 | #ifdef ENABLE_OCC |
81d882d5 | 266 | bool mtu_test; |
6fbf66fa JY |
267 | #endif |
268 | ||
ffea644c | 269 | #ifdef ENABLE_MEMSTATS |
81d882d5 | 270 | char *memstats_fn; |
ffea644c JY |
271 | #endif |
272 | ||
81d882d5 | 273 | bool mlock; |
6fbf66fa | 274 | |
81d882d5 DS |
275 | int keepalive_ping; /* a proxy for ping/ping-restart */ |
276 | int keepalive_timeout; | |
6fbf66fa | 277 | |
81d882d5 DS |
278 | int inactivity_timeout; /* --inactive */ |
279 | int inactivity_minimum_bytes; | |
838911cc | 280 | |
81d882d5 DS |
281 | int ping_send_timeout; /* Send a TCP/UDP ping to remote every n seconds */ |
282 | int ping_rec_timeout; /* Expect a TCP/UDP ping from remote at least once every n seconds */ | |
283 | bool ping_timer_remote; /* Run ping timer only if we have a remote address */ | |
6fbf66fa | 284 | |
81d882d5 DS |
285 | #define PING_UNDEF 0 |
286 | #define PING_EXIT 1 | |
287 | #define PING_RESTART 2 | |
288 | int ping_rec_timeout_action; /* What action to take on ping_rec_timeout (exit or restart)? */ | |
6fbf66fa | 289 | |
81d882d5 DS |
290 | bool persist_tun; /* Don't close/reopen TUN/TAP dev on SIGUSR1 or PING_RESTART */ |
291 | bool persist_local_ip; /* Don't re-resolve local address on SIGUSR1 or PING_RESTART */ | |
292 | bool persist_remote_ip; /* Don't re-resolve remote address on SIGUSR1 or PING_RESTART */ | |
293 | bool persist_key; /* Don't re-read key files on SIGUSR1 or PING_RESTART */ | |
6fbf66fa | 294 | |
6fbf66fa | 295 | #if PASSTOS_CAPABILITY |
81d882d5 | 296 | bool passtos; |
6fbf66fa JY |
297 | #endif |
298 | ||
81d882d5 DS |
299 | int resolve_retry_seconds; /* If hostname resolve fails, retry for n seconds */ |
300 | bool resolve_in_advance; | |
301 | const char *ip_remote_hint; | |
6fbf66fa | 302 | |
81d882d5 | 303 | struct tuntap_options tuntap_options; |
6fbf66fa | 304 | |
81d882d5 DS |
305 | /* Misc parms */ |
306 | const char *username; | |
307 | const char *groupname; | |
308 | const char *chroot_dir; | |
309 | const char *cd_dir; | |
cd5990e0 | 310 | #ifdef ENABLE_SELINUX |
81d882d5 | 311 | char *selinux_context; |
99385447 | 312 | #endif |
81d882d5 DS |
313 | const char *writepid; |
314 | const char *up_script; | |
315 | const char *down_script; | |
316 | bool user_script_used; | |
317 | bool down_pre; | |
318 | bool up_delay; | |
319 | bool up_restart; | |
320 | bool daemon; | |
6fbf66fa | 321 | |
81d882d5 | 322 | int remap_sigusr1; |
6fbf66fa | 323 | |
81d882d5 DS |
324 | /* inetd modes defined in socket.h */ |
325 | int inetd; | |
6fbf66fa | 326 | |
81d882d5 DS |
327 | bool log; |
328 | bool suppress_timestamps; | |
329 | bool machine_readable_output; | |
330 | int nice; | |
331 | int verbosity; | |
332 | int mute; | |
6fbf66fa JY |
333 | |
334 | #ifdef ENABLE_DEBUG | |
81d882d5 | 335 | int gremlin; |
6fbf66fa JY |
336 | #endif |
337 | ||
81d882d5 DS |
338 | const char *status_file; |
339 | int status_file_version; | |
340 | int status_file_update_freq; | |
6fbf66fa | 341 | |
81d882d5 DS |
342 | /* optimize TUN/TAP/UDP writes */ |
343 | bool fast_io; | |
6fbf66fa | 344 | |
38d96bd7 | 345 | #ifdef USE_COMP |
81d882d5 DS |
346 | struct compress_options comp; |
347 | #endif | |
348 | ||
349 | /* buffer sizes */ | |
350 | int rcvbuf; | |
351 | int sndbuf; | |
352 | ||
353 | /* mark value */ | |
354 | int mark; | |
19d3c602 | 355 | char *bind_dev; |
81d882d5 DS |
356 | |
357 | /* socket flags */ | |
358 | unsigned int sockflags; | |
359 | ||
360 | /* route management */ | |
361 | const char *route_script; | |
362 | const char *route_predown_script; | |
363 | const char *route_default_gateway; | |
d24e1b17 | 364 | const char *route_ipv6_default_gateway; |
81d882d5 DS |
365 | int route_default_metric; |
366 | bool route_noexec; | |
367 | int route_delay; | |
368 | int route_delay_window; | |
369 | bool route_delay_defined; | |
370 | struct route_option_list *routes; | |
371 | struct route_ipv6_option_list *routes_ipv6; /* IPv6 */ | |
e11d2d14 | 372 | bool block_ipv6; |
81d882d5 DS |
373 | bool route_nopull; |
374 | bool route_gateway_via_dhcp; | |
375 | bool allow_pull_fqdn; /* as a client, allow server to push a FQDN for certain parameters */ | |
376 | struct client_nat_option_list *client_nat; | |
581bef87 | 377 | |
6fbf66fa | 378 | #ifdef ENABLE_OCC |
81d882d5 DS |
379 | /* Enable options consistency check between peers */ |
380 | bool occ; | |
6fbf66fa JY |
381 | #endif |
382 | ||
383 | #ifdef ENABLE_MANAGEMENT | |
81d882d5 DS |
384 | const char *management_addr; |
385 | const char *management_port; | |
386 | const char *management_user_pass; | |
387 | int management_log_history_cache; | |
388 | int management_echo_buffer_size; | |
389 | int management_state_buffer_size; | |
390 | const char *management_write_peer_info_file; | |
90efcacb | 391 | |
81d882d5 DS |
392 | const char *management_client_user; |
393 | const char *management_client_group; | |
bb564a59 | 394 | |
81d882d5 DS |
395 | /* Mask of MF_ values of manage.h */ |
396 | unsigned int management_flags; | |
397 | const char *management_certificate; | |
6fbf66fa JY |
398 | #endif |
399 | ||
400 | #ifdef ENABLE_PLUGIN | |
81d882d5 | 401 | struct plugin_option_list *plugin_list; |
6fbf66fa JY |
402 | #endif |
403 | ||
ea5e091e | 404 | |
b70d99fb | 405 | |
6fbf66fa JY |
406 | #if P2MP |
407 | ||
81d882d5 DS |
408 | /* the tmp dir is for now only used in the P2P server context */ |
409 | const char *tmp_dir; | |
410 | bool server_defined; | |
411 | in_addr_t server_network; | |
412 | in_addr_t server_netmask; | |
413 | bool server_ipv6_defined; /* IPv6 */ | |
414 | struct in6_addr server_network_ipv6; /* IPv6 */ | |
415 | unsigned int server_netbits_ipv6; /* IPv6 */ | |
416 | ||
417 | #define SF_NOPOOL (1<<0) | |
418 | #define SF_TCP_NODELAY_HELPER (1<<1) | |
419 | #define SF_NO_PUSH_ROUTE_GATEWAY (1<<2) | |
420 | unsigned int server_flags; | |
421 | ||
422 | bool server_bridge_proxy_dhcp; | |
423 | ||
424 | bool server_bridge_defined; | |
425 | in_addr_t server_bridge_ip; | |
426 | in_addr_t server_bridge_netmask; | |
427 | in_addr_t server_bridge_pool_start; | |
428 | in_addr_t server_bridge_pool_end; | |
429 | ||
430 | struct push_list push_list; | |
431 | bool ifconfig_pool_defined; | |
432 | in_addr_t ifconfig_pool_start; | |
433 | in_addr_t ifconfig_pool_end; | |
434 | in_addr_t ifconfig_pool_netmask; | |
435 | const char *ifconfig_pool_persist_filename; | |
436 | int ifconfig_pool_persist_refresh_freq; | |
437 | ||
438 | bool ifconfig_ipv6_pool_defined; /* IPv6 */ | |
439 | struct in6_addr ifconfig_ipv6_pool_base; /* IPv6 */ | |
440 | int ifconfig_ipv6_pool_netbits; /* IPv6 */ | |
441 | ||
442 | int real_hash_size; | |
443 | int virtual_hash_size; | |
444 | const char *client_connect_script; | |
445 | const char *client_disconnect_script; | |
446 | const char *learn_address_script; | |
447 | const char *client_config_dir; | |
448 | bool ccd_exclusive; | |
449 | bool disable; | |
450 | int n_bcast_buf; | |
451 | int tcp_queue_limit; | |
452 | struct iroute *iroutes; | |
453 | struct iroute_ipv6 *iroutes_ipv6; /* IPv6 */ | |
454 | bool push_ifconfig_defined; | |
455 | in_addr_t push_ifconfig_local; | |
456 | in_addr_t push_ifconfig_remote_netmask; | |
457 | in_addr_t push_ifconfig_local_alias; | |
458 | bool push_ifconfig_constraint_defined; | |
459 | in_addr_t push_ifconfig_constraint_network; | |
460 | in_addr_t push_ifconfig_constraint_netmask; | |
6ae2f19d | 461 | bool push_ifconfig_ipv4_blocked; /* IPv4 */ |
81d882d5 DS |
462 | bool push_ifconfig_ipv6_defined; /* IPv6 */ |
463 | struct in6_addr push_ifconfig_ipv6_local; /* IPv6 */ | |
464 | int push_ifconfig_ipv6_netbits; /* IPv6 */ | |
465 | struct in6_addr push_ifconfig_ipv6_remote; /* IPv6 */ | |
466 | bool push_ifconfig_ipv6_blocked; /* IPv6 */ | |
467 | bool enable_c2c; | |
468 | bool duplicate_cn; | |
469 | int cf_max; | |
470 | int cf_per; | |
471 | int max_clients; | |
472 | int max_routes_per_client; | |
473 | int stale_routes_check_interval; | |
474 | int stale_routes_ageing_time; | |
475 | ||
476 | const char *auth_user_pass_verify_script; | |
477 | bool auth_user_pass_verify_script_via_file; | |
478 | bool auth_token_generate; | |
c8723aa7 AS |
479 | bool auth_token_gen_secret_file; |
480 | bool auth_token_call_auth; | |
481 | int auth_token_lifetime; | |
1b9a88a2 | 482 | const char *auth_token_secret_file; |
cb2e9218 | 483 | bool auth_token_secret_file_inline; |
1b9a88a2 | 484 | |
6add6b2f | 485 | #if PORT_SHARE |
81d882d5 DS |
486 | char *port_share_host; |
487 | char *port_share_port; | |
488 | const char *port_share_journal_dir; | |
6fbf66fa JY |
489 | #endif |
490 | ||
81d882d5 DS |
491 | bool client; |
492 | bool pull; /* client pull of config options from server */ | |
493 | int push_continuation; | |
494 | unsigned int push_option_types_found; | |
495 | const char *auth_user_pass_file; | |
496 | struct options_pre_pull *pre_pull; | |
6fbf66fa | 497 | |
81d882d5 | 498 | int scheduled_exit_interval; |
6fbf66fa | 499 | |
66b9409b | 500 | #ifdef ENABLE_MANAGEMENT |
81d882d5 | 501 | struct static_challenge_info sc_info; |
6fbf66fa | 502 | #endif |
81d882d5 | 503 | #endif /* if P2MP */ |
6fbf66fa | 504 | |
81d882d5 DS |
505 | /* Cipher parms */ |
506 | const char *shared_secret_file; | |
cb2e9218 | 507 | bool shared_secret_file_inline; |
81d882d5 DS |
508 | int key_direction; |
509 | const char *ciphername; | |
510 | bool ncp_enabled; | |
511 | const char *ncp_ciphers; | |
512 | const char *authname; | |
513 | int keysize; | |
514 | const char *prng_hash; | |
515 | int prng_nonce_secret_len; | |
516 | const char *engine; | |
517 | bool replay; | |
518 | bool mute_replay_warnings; | |
519 | int replay_window; | |
520 | int replay_time; | |
521 | const char *packet_id_file; | |
81d882d5 | 522 | bool test_crypto; |
0f25d296 | 523 | #ifdef ENABLE_PREDICTION_RESISTANCE |
81d882d5 DS |
524 | bool use_prediction_resistance; |
525 | #endif | |
526 | ||
527 | /* TLS (control channel) parms */ | |
528 | bool tls_server; | |
529 | bool tls_client; | |
530 | const char *ca_file; | |
cb2e9218 | 531 | bool ca_file_inline; |
81d882d5 DS |
532 | const char *ca_path; |
533 | const char *dh_file; | |
cb2e9218 | 534 | bool dh_file_inline; |
81d882d5 | 535 | const char *cert_file; |
cb2e9218 | 536 | bool cert_file_inline; |
81d882d5 | 537 | const char *extra_certs_file; |
cb2e9218 | 538 | bool extra_certs_file_inline; |
81d882d5 | 539 | const char *priv_key_file; |
cb2e9218 | 540 | bool priv_key_file_inline; |
81d882d5 | 541 | const char *pkcs12_file; |
cb2e9218 | 542 | bool pkcs12_file_inline; |
81d882d5 | 543 | const char *cipher_list; |
ea4ee313 | 544 | const char *cipher_list_tls13; |
aba75874 | 545 | const char *tls_cert_profile; |
81d882d5 DS |
546 | const char *ecdh_curve; |
547 | const char *tls_verify; | |
548 | int verify_x509_type; | |
549 | const char *verify_x509_name; | |
550 | const char *tls_export_cert; | |
551 | const char *crl_file; | |
cb2e9218 | 552 | bool crl_file_inline; |
81d882d5 DS |
553 | |
554 | int ns_cert_type; /* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */ | |
555 | unsigned remote_cert_ku[MAX_PARMS]; | |
556 | const char *remote_cert_eku; | |
557 | uint8_t *verify_hash; | |
2193d7c0 | 558 | hash_algo_type verify_hash_algo; |
81d882d5 | 559 | unsigned int ssl_flags; /* set to SSLF_x flags from ssl.h */ |
bed73623 JY |
560 | |
561 | #ifdef ENABLE_PKCS11 | |
81d882d5 DS |
562 | const char *pkcs11_providers[MAX_PARMS]; |
563 | unsigned pkcs11_private_mode[MAX_PARMS]; | |
564 | bool pkcs11_protected_authentication[MAX_PARMS]; | |
565 | bool pkcs11_cert_private[MAX_PARMS]; | |
566 | int pkcs11_pin_cache_period; | |
567 | const char *pkcs11_id; | |
568 | bool pkcs11_id_management; | |
bed73623 JY |
569 | #endif |
570 | ||
93c22ecc | 571 | #ifdef ENABLE_CRYPTOAPI |
81d882d5 | 572 | const char *cryptoapi_cert; |
6fbf66fa JY |
573 | #endif |
574 | ||
81d882d5 DS |
575 | /* data channel key exchange method */ |
576 | int key_method; | |
6fbf66fa | 577 | |
81d882d5 DS |
578 | /* Per-packet timeout on control channel */ |
579 | int tls_timeout; | |
6fbf66fa | 580 | |
81d882d5 DS |
581 | /* Data channel key renegotiation parameters */ |
582 | int renegotiate_bytes; | |
583 | int renegotiate_packets; | |
584 | int renegotiate_seconds; | |
dd996463 | 585 | int renegotiate_seconds_min; |
6fbf66fa | 586 | |
81d882d5 DS |
587 | /* Data channel key handshake must finalize |
588 | * within n seconds of handshake initiation. */ | |
589 | int handshake_window; | |
6fbf66fa | 590 | |
fbd18db6 | 591 | #ifdef ENABLE_X509ALTUSERNAME |
81d882d5 DS |
592 | /* Field used to be the username in X509 cert. */ |
593 | char *x509_username_field; | |
fbd18db6 | 594 | #endif |
2e8337de | 595 | |
81d882d5 DS |
596 | /* Old key allowed to live n seconds after new key goes active */ |
597 | int transition_window; | |
6fbf66fa | 598 | |
81d882d5 DS |
599 | /* Shared secret used for TLS control channel authentication */ |
600 | const char *tls_auth_file; | |
cb2e9218 | 601 | bool tls_auth_file_inline; |
6fbf66fa | 602 | |
81d882d5 DS |
603 | /* Shared secret used for TLS control channel authenticated encryption */ |
604 | const char *tls_crypt_file; | |
cb2e9218 | 605 | bool tls_crypt_file_inline; |
c6e24fa3 | 606 | |
9d59029a SK |
607 | /* Client-specific secret or server key used for TLS control channel |
608 | * authenticated encryption v2 */ | |
609 | const char *tls_crypt_v2_file; | |
cb2e9218 | 610 | bool tls_crypt_v2_file_inline; |
9d59029a | 611 | |
9d59029a SK |
612 | const char *tls_crypt_v2_metadata; |
613 | ||
ff931c5e SK |
614 | const char *tls_crypt_v2_verify_script; |
615 | ||
81d882d5 DS |
616 | /* Allow only one session */ |
617 | bool single_session; | |
6fbf66fa | 618 | |
81d882d5 | 619 | bool push_peer_info; |
aaf72974 | 620 | |
81d882d5 | 621 | bool tls_exit; |
6fbf66fa | 622 | |
81d882d5 | 623 | const struct x509_track *x509_track; |
9356bae8 | 624 | |
81d882d5 DS |
625 | /* special state parms */ |
626 | int foreign_option_index; | |
6fbf66fa | 627 | |
445b192a | 628 | #ifdef _WIN32 |
81d882d5 DS |
629 | HANDLE msg_channel; |
630 | const char *exit_event_name; | |
631 | bool exit_event_initial_state; | |
632 | bool show_net_up; | |
633 | int route_method; | |
634 | bool block_outside_dns; | |
36215dc5 | 635 | enum windows_driver_type windows_driver; |
6fbf66fa | 636 | #endif |
65eedc35 | 637 | |
81d882d5 DS |
638 | bool use_peer_id; |
639 | uint32_t peer_id; | |
685e486e | 640 | |
5defbba4 | 641 | #ifdef HAVE_EXPORT_KEYING_MATERIAL |
81d882d5 DS |
642 | /* Keying Material Exporters [RFC 5705] */ |
643 | const char *keying_material_exporter_label; | |
644 | int keying_material_exporter_length; | |
685e486e | 645 | #endif |
7f74c27e | 646 | |
99f28081 AQ |
647 | bool vlan_tagging; |
648 | enum vlan_acceptable_frames vlan_accept; | |
649 | uint16_t vlan_pvid; | |
650 | ||
81d882d5 | 651 | struct pull_filter_list *pull_filter_list; |
e8c42658 | 652 | |
81d882d5 DS |
653 | /* Useful when packets sent by openvpn itself are not subject |
654 | * to the routing tables that would move packets into the tunnel. */ | |
655 | bool allow_recursive_routing; | |
6fbf66fa JY |
656 | }; |
657 | ||
658 | #define streq(x, y) (!strcmp((x), (y))) | |
659 | ||
660 | /* | |
661 | * Option classes. | |
662 | */ | |
663 | #define OPT_P_GENERAL (1<<0) | |
664 | #define OPT_P_UP (1<<1) | |
665 | #define OPT_P_ROUTE (1<<2) | |
666 | #define OPT_P_IPWIN32 (1<<3) | |
667 | #define OPT_P_SCRIPT (1<<4) | |
668 | #define OPT_P_SETENV (1<<5) | |
669 | #define OPT_P_SHAPER (1<<6) | |
670 | #define OPT_P_TIMER (1<<7) | |
671 | #define OPT_P_PERSIST (1<<8) | |
672 | #define OPT_P_PERSIST_IP (1<<9) | |
673 | #define OPT_P_COMP (1<<10) /* TODO */ | |
674 | #define OPT_P_MESSAGES (1<<11) | |
d728ebed | 675 | #define OPT_P_NCP (1<<12) /**< Negotiable crypto parameters */ |
6fbf66fa JY |
676 | #define OPT_P_TLS_PARMS (1<<13) /* TODO */ |
677 | #define OPT_P_MTU (1<<14) /* TODO */ | |
678 | #define OPT_P_NICE (1<<15) | |
679 | #define OPT_P_PUSH (1<<16) | |
680 | #define OPT_P_INSTANCE (1<<17) | |
681 | #define OPT_P_CONFIG (1<<18) | |
682 | #define OPT_P_EXPLICIT_NOTIFY (1<<19) | |
683 | #define OPT_P_ECHO (1<<20) | |
684 | #define OPT_P_INHERIT (1<<21) | |
3c7f2f55 JY |
685 | #define OPT_P_ROUTE_EXTRAS (1<<22) |
686 | #define OPT_P_PULL_MODE (1<<23) | |
687 | #define OPT_P_PLUGIN (1<<24) | |
00d39170 JY |
688 | #define OPT_P_SOCKBUF (1<<25) |
689 | #define OPT_P_SOCKFLAGS (1<<26) | |
4e9a51d7 | 690 | #define OPT_P_CONNECTION (1<<27) |
65eedc35 | 691 | #define OPT_P_PEER_ID (1<<28) |
cb2e9218 | 692 | #define OPT_P_INLINE (1<<29) |
6fbf66fa | 693 | |
3c7f2f55 | 694 | #define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE)) |
6fbf66fa JY |
695 | |
696 | #if P2MP | |
697 | #define PULL_DEFINED(opt) ((opt)->pull) | |
6fbf66fa JY |
698 | #define PUSH_DEFINED(opt) ((opt)->push_list) |
699 | #endif | |
6fbf66fa JY |
700 | |
701 | #ifndef PULL_DEFINED | |
702 | #define PULL_DEFINED(opt) (false) | |
703 | #endif | |
704 | ||
705 | #ifndef PUSH_DEFINED | |
706 | #define PUSH_DEFINED(opt) (false) | |
707 | #endif | |
708 | ||
445b192a | 709 | #ifdef _WIN32 |
6fbf66fa JY |
710 | #define ROUTE_OPTION_FLAGS(o) ((o)->route_method & ROUTE_METHOD_MASK) |
711 | #else | |
712 | #define ROUTE_OPTION_FLAGS(o) (0) | |
713 | #endif | |
714 | ||
3d163bc5 | 715 | #ifdef ENABLE_FEATURE_SHAPER |
6fbf66fa JY |
716 | #define SHAPER_DEFINED(opt) ((opt)->shaper) |
717 | #else | |
718 | #define SHAPER_DEFINED(opt) (false) | |
719 | #endif | |
720 | ||
721 | #ifdef ENABLE_PLUGIN | |
722 | #define PLUGIN_OPTION_LIST(opt) ((opt)->plugin_list) | |
723 | #else | |
724 | #define PLUGIN_OPTION_LIST(opt) (NULL) | |
725 | #endif | |
726 | ||
90efcacb JY |
727 | #ifdef MANAGEMENT_DEF_AUTH |
728 | #define MAN_CLIENT_AUTH_ENABLED(opt) ((opt)->management_flags & MF_CLIENT_AUTH) | |
729 | #else | |
730 | #define MAN_CLIENT_AUTH_ENABLED(opt) (false) | |
731 | #endif | |
732 | ||
81d882d5 DS |
733 | void parse_argv(struct options *options, |
734 | const int argc, | |
735 | char *argv[], | |
736 | const int msglevel, | |
737 | const unsigned int permission_mask, | |
738 | unsigned int *option_types_found, | |
739 | struct env_set *es); | |
6fbf66fa | 740 | |
81d882d5 | 741 | void notnull(const char *arg, const char *description); |
6fbf66fa | 742 | |
81d882d5 | 743 | void usage_small(void); |
6fbf66fa | 744 | |
5b17803e JY |
745 | void show_library_versions(const unsigned int flags); |
746 | ||
445b192a | 747 | #ifdef _WIN32 |
cdc65ea0 | 748 | void show_windows_version(const unsigned int flags); |
81d882d5 | 749 | |
cdc65ea0 LS |
750 | #endif |
751 | ||
81d882d5 DS |
752 | void init_options(struct options *o, const bool init_gc); |
753 | ||
754 | void uninit_options(struct options *o); | |
6fbf66fa | 755 | |
81d882d5 | 756 | void setenv_settings(struct env_set *es, const struct options *o); |
6fbf66fa | 757 | |
81d882d5 DS |
758 | void show_settings(const struct options *o); |
759 | ||
760 | bool string_defined_equal(const char *s1, const char *s2); | |
6fbf66fa JY |
761 | |
762 | #ifdef ENABLE_OCC | |
763 | ||
81d882d5 DS |
764 | const char *options_string_version(const char *s, struct gc_arena *gc); |
765 | ||
766 | char *options_string(const struct options *o, | |
767 | const struct frame *frame, | |
768 | struct tuntap *tt, | |
dc7fcd71 | 769 | openvpn_net_ctx_t *ctx, |
81d882d5 DS |
770 | bool remote, |
771 | struct gc_arena *gc); | |
772 | ||
773 | bool options_cmp_equal_safe(char *actual, const char *expected, size_t actual_n); | |
6fbf66fa | 774 | |
81d882d5 | 775 | void options_warning_safe(char *actual, const char *expected, size_t actual_n); |
6fbf66fa | 776 | |
81d882d5 DS |
777 | bool options_cmp_equal(char *actual, const char *expected); |
778 | ||
779 | void options_warning(char *actual, const char *expected); | |
6fbf66fa JY |
780 | |
781 | #endif | |
782 | ||
6e5ad2fa SK |
783 | /** |
784 | * Given an OpenVPN options string, extract the value of an option. | |
785 | * | |
81d882d5 DS |
786 | * @param options_string Zero-terminated, comma-separated options string |
787 | * @param opt_name The name of the option to extract | |
788 | * @param gc The gc to allocate the return value | |
6e5ad2fa SK |
789 | * |
790 | * @return gc-allocated value of option with name opt_name if option was found, | |
791 | * or NULL otherwise. | |
792 | */ | |
81d882d5 DS |
793 | char *options_string_extract_option(const char *options_string, |
794 | const char *opt_name, struct gc_arena *gc); | |
795 | ||
6e5ad2fa | 796 | |
81d882d5 | 797 | void options_postprocess(struct options *options); |
6e5ad2fa | 798 | |
81d882d5 | 799 | void pre_pull_save(struct options *o); |
6fbf66fa | 800 | |
81d882d5 | 801 | void pre_pull_restore(struct options *o, struct gc_arena *gc); |
6fbf66fa | 802 | |
81d882d5 DS |
803 | bool apply_push_options(struct options *options, |
804 | struct buffer *buf, | |
805 | unsigned int permission_mask, | |
806 | unsigned int *option_types_found, | |
807 | struct env_set *es); | |
6fbf66fa | 808 | |
81d882d5 | 809 | void options_detach(struct options *o); |
6fbf66fa | 810 | |
81d882d5 DS |
811 | void options_server_import(struct options *o, |
812 | const char *filename, | |
813 | int msglevel, | |
814 | unsigned int permission_mask, | |
815 | unsigned int *option_types_found, | |
816 | struct env_set *es); | |
6fbf66fa | 817 | |
81d882d5 | 818 | void pre_pull_default(struct options *o); |
6fbf66fa | 819 | |
81d882d5 | 820 | void rol_check_alloc(struct options *options); |
6fbf66fa | 821 | |
81d882d5 DS |
822 | int parse_line(const char *line, |
823 | char *p[], | |
824 | const int n, | |
825 | const char *file, | |
826 | const int line_num, | |
827 | int msglevel, | |
828 | struct gc_arena *gc); | |
6fbf66fa | 829 | |
3c7f2f55 JY |
830 | /* |
831 | * parse/print topology coding | |
832 | */ | |
833 | ||
81d882d5 DS |
834 | int parse_topology(const char *str, const int msglevel); |
835 | ||
836 | const char *print_topology(const int topology); | |
3c7f2f55 | 837 | |
6fbf66fa JY |
838 | /* |
839 | * Manage auth-retry variable | |
840 | */ | |
841 | ||
842 | #if P2MP | |
843 | ||
844 | #define AR_NONE 0 | |
845 | #define AR_INTERACT 1 | |
846 | #define AR_NOINTERACT 2 | |
847 | ||
81d882d5 DS |
848 | int auth_retry_get(void); |
849 | ||
850 | bool auth_retry_set(const int msglevel, const char *option); | |
851 | ||
852 | const char *auth_retry_print(void); | |
6fbf66fa JY |
853 | |
854 | #endif | |
855 | ||
81d882d5 DS |
856 | void options_string_import(struct options *options, |
857 | const char *config, | |
858 | const int msglevel, | |
859 | const unsigned int permission_mask, | |
860 | unsigned int *option_types_found, | |
861 | struct env_set *es); | |
3c7f2f55 | 862 | |
81d882d5 | 863 | #endif /* ifndef OPTIONS_H */ |