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