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