]> git.ipfire.org Git - thirdparty/openvpn.git/blame - src/openvpn/options.h
Add unit test for reliable_get_num_output_sequenced_available
[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;
c9474fa3 275 /* Do not advance the connection or remote addr list */
81d882d5 276 bool no_advance;
c9474fa3
AS
277 /* Advance directly to the next remote, skipping remaining addresses of the
278 * current remote */
279 bool advance_next_remote;
81d882d5
DS
280 /* Counts the number of unsuccessful connection attempts */
281 unsigned int unsuccessful_attempts;
c9474fa3
AS
282 /* the server can suggest a backoff time to the client, it
283 * will still be capped by the max timeout between connections
284 * (300s by default) */
285 int server_backoff_time;
4e9a51d7 286
a4b8f653 287#if ENABLE_MANAGEMENT
81d882d5
DS
288 struct http_proxy_options *http_proxy_override;
289#endif
290
291 struct remote_host_store *rh_store;
292
b3e0d95d
HH
293 struct dns_options dns_options;
294
81d882d5
DS
295 bool remote_random;
296 const char *ipchange;
297 const char *dev;
298 const char *dev_type;
299 const char *dev_node;
300 const char *lladdr;
301 int topology; /* one of the TOP_x values from proto.h */
302 const char *ifconfig_local;
303 const char *ifconfig_remote_netmask;
304 const char *ifconfig_ipv6_local;
305 int ifconfig_ipv6_netbits;
306 const char *ifconfig_ipv6_remote;
307 bool ifconfig_noexec;
308 bool ifconfig_nowarn;
81d882d5 309 int shaper;
6fbf66fa 310
81d882d5 311 int proto_force;
51e6e5b0 312
81d882d5 313 bool mtu_test;
6fbf66fa 314
ffea644c 315#ifdef ENABLE_MEMSTATS
81d882d5 316 char *memstats_fn;
ffea644c
JY
317#endif
318
81d882d5 319 bool mlock;
6fbf66fa 320
81d882d5
DS
321 int keepalive_ping; /* a proxy for ping/ping-restart */
322 int keepalive_timeout;
6fbf66fa 323
81d882d5 324 int inactivity_timeout; /* --inactive */
cae1a7fc 325 int64_t inactivity_minimum_bytes;
838911cc 326
f96290ff
DZ
327 int session_timeout; /* Force-kill session after n seconds */
328
81d882d5
DS
329 int ping_send_timeout; /* Send a TCP/UDP ping to remote every n seconds */
330 int ping_rec_timeout; /* Expect a TCP/UDP ping from remote at least once every n seconds */
331 bool ping_timer_remote; /* Run ping timer only if we have a remote address */
6fbf66fa 332
81d882d5
DS
333#define PING_UNDEF 0
334#define PING_EXIT 1
335#define PING_RESTART 2
336 int ping_rec_timeout_action; /* What action to take on ping_rec_timeout (exit or restart)? */
6fbf66fa 337
81d882d5
DS
338 bool persist_tun; /* Don't close/reopen TUN/TAP dev on SIGUSR1 or PING_RESTART */
339 bool persist_local_ip; /* Don't re-resolve local address on SIGUSR1 or PING_RESTART */
340 bool persist_remote_ip; /* Don't re-resolve remote address on SIGUSR1 or PING_RESTART */
341 bool persist_key; /* Don't re-read key files on SIGUSR1 or PING_RESTART */
6fbf66fa 342
6fbf66fa 343#if PASSTOS_CAPABILITY
81d882d5 344 bool passtos;
6fbf66fa
JY
345#endif
346
81d882d5
DS
347 int resolve_retry_seconds; /* If hostname resolve fails, retry for n seconds */
348 bool resolve_in_advance;
349 const char *ip_remote_hint;
6fbf66fa 350
81d882d5 351 struct tuntap_options tuntap_options;
6fbf66fa 352
81d882d5
DS
353 /* Misc parms */
354 const char *username;
355 const char *groupname;
356 const char *chroot_dir;
357 const char *cd_dir;
cd5990e0 358#ifdef ENABLE_SELINUX
81d882d5 359 char *selinux_context;
99385447 360#endif
81d882d5
DS
361 const char *writepid;
362 const char *up_script;
363 const char *down_script;
364 bool user_script_used;
365 bool down_pre;
366 bool up_delay;
367 bool up_restart;
368 bool daemon;
6fbf66fa 369
81d882d5 370 int remap_sigusr1;
6fbf66fa 371
81d882d5
DS
372 bool log;
373 bool suppress_timestamps;
374 bool machine_readable_output;
375 int nice;
376 int verbosity;
377 int mute;
6fbf66fa
JY
378
379#ifdef ENABLE_DEBUG
81d882d5 380 int gremlin;
6fbf66fa
JY
381#endif
382
81d882d5
DS
383 const char *status_file;
384 int status_file_version;
385 int status_file_update_freq;
6fbf66fa 386
81d882d5
DS
387 /* optimize TUN/TAP/UDP writes */
388 bool fast_io;
6fbf66fa 389
38d96bd7 390#ifdef USE_COMP
81d882d5
DS
391 struct compress_options comp;
392#endif
393
394 /* buffer sizes */
395 int rcvbuf;
396 int sndbuf;
397
398 /* mark value */
399 int mark;
19d3c602 400 char *bind_dev;
81d882d5
DS
401
402 /* socket flags */
403 unsigned int sockflags;
404
405 /* route management */
406 const char *route_script;
407 const char *route_predown_script;
408 const char *route_default_gateway;
d24e1b17 409 const char *route_ipv6_default_gateway;
81d882d5
DS
410 int route_default_metric;
411 bool route_noexec;
412 int route_delay;
413 int route_delay_window;
414 bool route_delay_defined;
415 struct route_option_list *routes;
416 struct route_ipv6_option_list *routes_ipv6; /* IPv6 */
e11d2d14 417 bool block_ipv6;
81d882d5
DS
418 bool route_nopull;
419 bool route_gateway_via_dhcp;
420 bool allow_pull_fqdn; /* as a client, allow server to push a FQDN for certain parameters */
421 struct client_nat_option_list *client_nat;
581bef87 422
81d882d5
DS
423 /* Enable options consistency check between peers */
424 bool occ;
6fbf66fa
JY
425
426#ifdef ENABLE_MANAGEMENT
81d882d5
DS
427 const char *management_addr;
428 const char *management_port;
429 const char *management_user_pass;
430 int management_log_history_cache;
431 int management_echo_buffer_size;
432 int management_state_buffer_size;
90efcacb 433
81d882d5
DS
434 const char *management_client_user;
435 const char *management_client_group;
bb564a59 436
81d882d5
DS
437 /* Mask of MF_ values of manage.h */
438 unsigned int management_flags;
439 const char *management_certificate;
6fbf66fa
JY
440#endif
441
442#ifdef ENABLE_PLUGIN
81d882d5 443 struct plugin_option_list *plugin_list;
6fbf66fa
JY
444#endif
445
81d882d5
DS
446 /* the tmp dir is for now only used in the P2P server context */
447 const char *tmp_dir;
448 bool server_defined;
449 in_addr_t server_network;
450 in_addr_t server_netmask;
451 bool server_ipv6_defined; /* IPv6 */
452 struct in6_addr server_network_ipv6; /* IPv6 */
453 unsigned int server_netbits_ipv6; /* IPv6 */
454
455#define SF_NOPOOL (1<<0)
456#define SF_TCP_NODELAY_HELPER (1<<1)
457#define SF_NO_PUSH_ROUTE_GATEWAY (1<<2)
458 unsigned int server_flags;
459
460 bool server_bridge_proxy_dhcp;
461
462 bool server_bridge_defined;
463 in_addr_t server_bridge_ip;
464 in_addr_t server_bridge_netmask;
465 in_addr_t server_bridge_pool_start;
466 in_addr_t server_bridge_pool_end;
467
468 struct push_list push_list;
469 bool ifconfig_pool_defined;
470 in_addr_t ifconfig_pool_start;
471 in_addr_t ifconfig_pool_end;
472 in_addr_t ifconfig_pool_netmask;
473 const char *ifconfig_pool_persist_filename;
474 int ifconfig_pool_persist_refresh_freq;
475
476 bool ifconfig_ipv6_pool_defined; /* IPv6 */
477 struct in6_addr ifconfig_ipv6_pool_base; /* IPv6 */
478 int ifconfig_ipv6_pool_netbits; /* IPv6 */
479
480 int real_hash_size;
481 int virtual_hash_size;
482 const char *client_connect_script;
483 const char *client_disconnect_script;
484 const char *learn_address_script;
23eec2d2 485 const char *client_crresponse_script;
81d882d5
DS
486 const char *client_config_dir;
487 bool ccd_exclusive;
488 bool disable;
489 int n_bcast_buf;
490 int tcp_queue_limit;
491 struct iroute *iroutes;
492 struct iroute_ipv6 *iroutes_ipv6; /* IPv6 */
493 bool push_ifconfig_defined;
494 in_addr_t push_ifconfig_local;
495 in_addr_t push_ifconfig_remote_netmask;
496 in_addr_t push_ifconfig_local_alias;
497 bool push_ifconfig_constraint_defined;
498 in_addr_t push_ifconfig_constraint_network;
499 in_addr_t push_ifconfig_constraint_netmask;
6ae2f19d 500 bool push_ifconfig_ipv4_blocked; /* IPv4 */
81d882d5
DS
501 bool push_ifconfig_ipv6_defined; /* IPv6 */
502 struct in6_addr push_ifconfig_ipv6_local; /* IPv6 */
503 int push_ifconfig_ipv6_netbits; /* IPv6 */
504 struct in6_addr push_ifconfig_ipv6_remote; /* IPv6 */
505 bool push_ifconfig_ipv6_blocked; /* IPv6 */
506 bool enable_c2c;
507 bool duplicate_cn;
508 int cf_max;
509 int cf_per;
510 int max_clients;
511 int max_routes_per_client;
512 int stale_routes_check_interval;
513 int stale_routes_ageing_time;
514
515 const char *auth_user_pass_verify_script;
516 bool auth_user_pass_verify_script_via_file;
517 bool auth_token_generate;
c8723aa7
AS
518 bool auth_token_call_auth;
519 int auth_token_lifetime;
9a516170 520 int auth_token_renewal;
1b9a88a2 521 const char *auth_token_secret_file;
cb2e9218 522 bool auth_token_secret_file_inline;
1b9a88a2 523
6add6b2f 524#if PORT_SHARE
81d882d5
DS
525 char *port_share_host;
526 char *port_share_port;
527 const char *port_share_journal_dir;
6fbf66fa
JY
528#endif
529
81d882d5
DS
530 bool client;
531 bool pull; /* client pull of config options from server */
532 int push_continuation;
533 unsigned int push_option_types_found;
534 const char *auth_user_pass_file;
7d48d31b 535 bool auth_user_pass_file_inline;
c1150e5b 536 struct options_pre_connect *pre_connect;
6fbf66fa 537
81d882d5 538 int scheduled_exit_interval;
6fbf66fa 539
66b9409b 540#ifdef ENABLE_MANAGEMENT
81d882d5 541 struct static_challenge_info sc_info;
6fbf66fa 542#endif
81d882d5
DS
543 /* Cipher parms */
544 const char *shared_secret_file;
cb2e9218 545 bool shared_secret_file_inline;
81d882d5
DS
546 int key_direction;
547 const char *ciphername;
2c1d8c33 548 bool enable_ncp_fallback; /**< If defined fall back to
abe49856 549 * ciphername if NCP fails */
81d882d5
DS
550 const char *ncp_ciphers;
551 const char *authname;
81d882d5 552 const char *engine;
08081aa0 553 struct provider_list providers;
81d882d5
DS
554 bool replay;
555 bool mute_replay_warnings;
556 int replay_window;
557 int replay_time;
558 const char *packet_id_file;
81d882d5 559 bool test_crypto;
0f25d296 560#ifdef ENABLE_PREDICTION_RESISTANCE
81d882d5
DS
561 bool use_prediction_resistance;
562#endif
563
564 /* TLS (control channel) parms */
565 bool tls_server;
566 bool tls_client;
567 const char *ca_file;
cb2e9218 568 bool ca_file_inline;
81d882d5
DS
569 const char *ca_path;
570 const char *dh_file;
cb2e9218 571 bool dh_file_inline;
81d882d5 572 const char *cert_file;
cb2e9218 573 bool cert_file_inline;
81d882d5 574 const char *extra_certs_file;
cb2e9218 575 bool extra_certs_file_inline;
81d882d5 576 const char *priv_key_file;
cb2e9218 577 bool priv_key_file_inline;
81d882d5 578 const char *pkcs12_file;
cb2e9218 579 bool pkcs12_file_inline;
81d882d5 580 const char *cipher_list;
ea4ee313 581 const char *cipher_list_tls13;
8353ae80 582 const char *tls_groups;
aba75874 583 const char *tls_cert_profile;
81d882d5
DS
584 const char *ecdh_curve;
585 const char *tls_verify;
586 int verify_x509_type;
587 const char *verify_x509_name;
588 const char *tls_export_cert;
589 const char *crl_file;
cb2e9218 590 bool crl_file_inline;
81d882d5
DS
591
592 int ns_cert_type; /* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */
593 unsigned remote_cert_ku[MAX_PARMS];
594 const char *remote_cert_eku;
d1fe6d52 595 struct verify_hash_list *verify_hash;
2193d7c0 596 hash_algo_type verify_hash_algo;
c3a7065d 597 int verify_hash_depth;
423ced96 598 bool verify_hash_no_ca;
81d882d5 599 unsigned int ssl_flags; /* set to SSLF_x flags from ssl.h */
bed73623
JY
600
601#ifdef ENABLE_PKCS11
81d882d5
DS
602 const char *pkcs11_providers[MAX_PARMS];
603 unsigned pkcs11_private_mode[MAX_PARMS];
604 bool pkcs11_protected_authentication[MAX_PARMS];
605 bool pkcs11_cert_private[MAX_PARMS];
606 int pkcs11_pin_cache_period;
607 const char *pkcs11_id;
608 bool pkcs11_id_management;
bed73623
JY
609#endif
610
93c22ecc 611#ifdef ENABLE_CRYPTOAPI
81d882d5 612 const char *cryptoapi_cert;
6fbf66fa 613#endif
81d882d5
DS
614 /* Per-packet timeout on control channel */
615 int tls_timeout;
6fbf66fa 616
81d882d5
DS
617 /* Data channel key renegotiation parameters */
618 int renegotiate_bytes;
619 int renegotiate_packets;
620 int renegotiate_seconds;
dd996463 621 int renegotiate_seconds_min;
6fbf66fa 622
81d882d5
DS
623 /* Data channel key handshake must finalize
624 * within n seconds of handshake initiation. */
625 int handshake_window;
6fbf66fa 626
fbd18db6 627#ifdef ENABLE_X509ALTUSERNAME
3b04c34d
VG
628 /* Field list used to be the username in X509 cert. */
629 char *x509_username_field[MAX_PARMS];
fbd18db6 630#endif
2e8337de 631
81d882d5
DS
632 /* Old key allowed to live n seconds after new key goes active */
633 int transition_window;
6fbf66fa 634
81d882d5
DS
635 /* Shared secret used for TLS control channel authentication */
636 const char *tls_auth_file;
cb2e9218 637 bool tls_auth_file_inline;
6fbf66fa 638
81d882d5
DS
639 /* Shared secret used for TLS control channel authenticated encryption */
640 const char *tls_crypt_file;
cb2e9218 641 bool tls_crypt_file_inline;
c6e24fa3 642
9d59029a
SK
643 /* Client-specific secret or server key used for TLS control channel
644 * authenticated encryption v2 */
645 const char *tls_crypt_v2_file;
cb2e9218 646 bool tls_crypt_v2_file_inline;
9d59029a 647
9d59029a
SK
648 const char *tls_crypt_v2_metadata;
649
ff931c5e
SK
650 const char *tls_crypt_v2_verify_script;
651
81d882d5
DS
652 /* Allow only one session */
653 bool single_session;
6fbf66fa 654
81d882d5 655 bool push_peer_info;
aaf72974 656
81d882d5 657 bool tls_exit;
6fbf66fa 658
81d882d5 659 const struct x509_track *x509_track;
9356bae8 660
81d882d5
DS
661 /* special state parms */
662 int foreign_option_index;
6fbf66fa 663
445b192a 664#ifdef _WIN32
81d882d5
DS
665 HANDLE msg_channel;
666 const char *exit_event_name;
667 bool exit_event_initial_state;
668 bool show_net_up;
669 int route_method;
670 bool block_outside_dns;
36215dc5 671 enum windows_driver_type windows_driver;
6fbf66fa 672#endif
65eedc35 673
81d882d5
DS
674 bool use_peer_id;
675 uint32_t peer_id;
685e486e 676
5defbba4 677#ifdef HAVE_EXPORT_KEYING_MATERIAL
81d882d5
DS
678 /* Keying Material Exporters [RFC 5705] */
679 const char *keying_material_exporter_label;
680 int keying_material_exporter_length;
685e486e 681#endif
7f74c27e 682
99f28081
AQ
683 bool vlan_tagging;
684 enum vlan_acceptable_frames vlan_accept;
685 uint16_t vlan_pvid;
686
81d882d5 687 struct pull_filter_list *pull_filter_list;
e8c42658 688
81d882d5
DS
689 /* Useful when packets sent by openvpn itself are not subject
690 * to the routing tables that would move packets into the tunnel. */
691 bool allow_recursive_routing;
6dc09d0d 692
9c625f4a 693 /* data channel crypto flags set by push/pull. Reuses the CO_* crypto_flags */
179b3728 694 unsigned int imported_protocol_flags;
6fbf66fa
JY
695};
696
697#define streq(x, y) (!strcmp((x), (y)))
698
699/*
700 * Option classes.
701 */
702#define OPT_P_GENERAL (1<<0)
703#define OPT_P_UP (1<<1)
704#define OPT_P_ROUTE (1<<2)
8a7d0005 705#define OPT_P_DHCPDNS (1<<3) /* includes ip windows options like */
6fbf66fa
JY
706#define OPT_P_SCRIPT (1<<4)
707#define OPT_P_SETENV (1<<5)
708#define OPT_P_SHAPER (1<<6)
709#define OPT_P_TIMER (1<<7)
710#define OPT_P_PERSIST (1<<8)
711#define OPT_P_PERSIST_IP (1<<9)
712#define OPT_P_COMP (1<<10) /* TODO */
713#define OPT_P_MESSAGES (1<<11)
d728ebed 714#define OPT_P_NCP (1<<12) /**< Negotiable crypto parameters */
6fbf66fa
JY
715#define OPT_P_TLS_PARMS (1<<13) /* TODO */
716#define OPT_P_MTU (1<<14) /* TODO */
717#define OPT_P_NICE (1<<15)
718#define OPT_P_PUSH (1<<16)
6168f53d 719#define OPT_P_INSTANCE (1<<17) /**< allowed in ccd, client-connect etc*/
6fbf66fa
JY
720#define OPT_P_CONFIG (1<<18)
721#define OPT_P_EXPLICIT_NOTIFY (1<<19)
722#define OPT_P_ECHO (1<<20)
723#define OPT_P_INHERIT (1<<21)
3c7f2f55
JY
724#define OPT_P_ROUTE_EXTRAS (1<<22)
725#define OPT_P_PULL_MODE (1<<23)
726#define OPT_P_PLUGIN (1<<24)
00d39170
JY
727#define OPT_P_SOCKBUF (1<<25)
728#define OPT_P_SOCKFLAGS (1<<26)
4e9a51d7 729#define OPT_P_CONNECTION (1<<27)
65eedc35 730#define OPT_P_PEER_ID (1<<28)
cb2e9218 731#define OPT_P_INLINE (1<<29)
6fbf66fa 732
3c7f2f55 733#define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE))
6fbf66fa 734
6fbf66fa 735#define PULL_DEFINED(opt) ((opt)->pull)
6fbf66fa 736#define PUSH_DEFINED(opt) ((opt)->push_list)
6fbf66fa
JY
737
738#ifndef PULL_DEFINED
739#define PULL_DEFINED(opt) (false)
740#endif
741
742#ifndef PUSH_DEFINED
743#define PUSH_DEFINED(opt) (false)
744#endif
745
445b192a 746#ifdef _WIN32
6fbf66fa
JY
747#define ROUTE_OPTION_FLAGS(o) ((o)->route_method & ROUTE_METHOD_MASK)
748#else
749#define ROUTE_OPTION_FLAGS(o) (0)
750#endif
751
6fbf66fa 752#define SHAPER_DEFINED(opt) ((opt)->shaper)
6fbf66fa
JY
753
754#ifdef ENABLE_PLUGIN
755#define PLUGIN_OPTION_LIST(opt) ((opt)->plugin_list)
756#else
757#define PLUGIN_OPTION_LIST(opt) (NULL)
758#endif
759
99d217b2 760#ifdef ENABLE_MANAGEMENT
90efcacb
JY
761#define MAN_CLIENT_AUTH_ENABLED(opt) ((opt)->management_flags & MF_CLIENT_AUTH)
762#else
763#define MAN_CLIENT_AUTH_ENABLED(opt) (false)
764#endif
765
81d882d5
DS
766void parse_argv(struct options *options,
767 const int argc,
768 char *argv[],
769 const int msglevel,
770 const unsigned int permission_mask,
771 unsigned int *option_types_found,
772 struct env_set *es);
6fbf66fa 773
81d882d5 774void notnull(const char *arg, const char *description);
6fbf66fa 775
81d882d5 776void usage_small(void);
6fbf66fa 777
5b17803e
JY
778void show_library_versions(const unsigned int flags);
779
445b192a 780#ifdef _WIN32
cdc65ea0 781void show_windows_version(const unsigned int flags);
81d882d5 782
cdc65ea0
LS
783#endif
784
81d882d5
DS
785void init_options(struct options *o, const bool init_gc);
786
787void uninit_options(struct options *o);
6fbf66fa 788
81d882d5 789void setenv_settings(struct env_set *es, const struct options *o);
6fbf66fa 790
81d882d5
DS
791void show_settings(const struct options *o);
792
793bool string_defined_equal(const char *s1, const char *s2);
6fbf66fa 794
81d882d5
DS
795const char *options_string_version(const char *s, struct gc_arena *gc);
796
797char *options_string(const struct options *o,
798 const struct frame *frame,
799 struct tuntap *tt,
dc7fcd71 800 openvpn_net_ctx_t *ctx,
81d882d5
DS
801 bool remote,
802 struct gc_arena *gc);
803
804bool options_cmp_equal_safe(char *actual, const char *expected, size_t actual_n);
6fbf66fa 805
81d882d5 806void options_warning_safe(char *actual, const char *expected, size_t actual_n);
6fbf66fa 807
81d882d5
DS
808bool options_cmp_equal(char *actual, const char *expected);
809
810void options_warning(char *actual, const char *expected);
6fbf66fa 811
6e5ad2fa
SK
812/**
813 * Given an OpenVPN options string, extract the value of an option.
814 *
81d882d5
DS
815 * @param options_string Zero-terminated, comma-separated options string
816 * @param opt_name The name of the option to extract
817 * @param gc The gc to allocate the return value
6e5ad2fa
SK
818 *
819 * @return gc-allocated value of option with name opt_name if option was found,
820 * or NULL otherwise.
821 */
81d882d5
DS
822char *options_string_extract_option(const char *options_string,
823 const char *opt_name, struct gc_arena *gc);
824
6e5ad2fa 825
dac85fff 826void options_postprocess(struct options *options, struct env_set *es);
6e5ad2fa 827
b3e0d95d
HH
828bool options_postprocess_pull(struct options *o, struct env_set *es);
829
c1150e5b 830void pre_connect_restore(struct options *o, struct gc_arena *gc);
6fbf66fa 831
81d882d5
DS
832bool apply_push_options(struct options *options,
833 struct buffer *buf,
834 unsigned int permission_mask,
835 unsigned int *option_types_found,
836 struct env_set *es);
6fbf66fa 837
81d882d5 838void options_detach(struct options *o);
6fbf66fa 839
81d882d5
DS
840void options_server_import(struct options *o,
841 const char *filename,
842 int msglevel,
843 unsigned int permission_mask,
844 unsigned int *option_types_found,
845 struct env_set *es);
6fbf66fa 846
81d882d5 847void pre_pull_default(struct options *o);
6fbf66fa 848
81d882d5 849void rol_check_alloc(struct options *options);
6fbf66fa 850
81d882d5
DS
851int parse_line(const char *line,
852 char *p[],
853 const int n,
854 const char *file,
855 const int line_num,
856 int msglevel,
857 struct gc_arena *gc);
6fbf66fa 858
3c7f2f55
JY
859/*
860 * parse/print topology coding
861 */
862
81d882d5
DS
863int parse_topology(const char *str, const int msglevel);
864
865const char *print_topology(const int topology);
3c7f2f55 866
6fbf66fa
JY
867/*
868 * Manage auth-retry variable
869 */
870
6fbf66fa
JY
871#define AR_NONE 0
872#define AR_INTERACT 1
873#define AR_NOINTERACT 2
874
81d882d5
DS
875int auth_retry_get(void);
876
877bool auth_retry_set(const int msglevel, const char *option);
878
879const char *auth_retry_print(void);
6fbf66fa 880
81d882d5
DS
881void options_string_import(struct options *options,
882 const char *config,
883 const int msglevel,
884 const unsigned int permission_mask,
885 unsigned int *option_types_found,
886 struct env_set *es);
3c7f2f55 887
4b85c488
SN
888bool key_is_external(const struct options *options);
889
4f1671fa
AQ
890/**
891 * Returns whether the current configuration has dco enabled.
892 */
893static inline bool
894dco_enabled(const struct options *o)
895{
e9a156a1 896#ifdef ENABLE_DCO
4f1671fa 897 return !o->tuntap_options.disable_dco;
3adbc5c6 898#else
4f1671fa 899 return false;
e9a156a1 900#endif /* ENABLE_DCO */
4f1671fa
AQ
901}
902
81d882d5 903#endif /* ifndef OPTIONS_H */