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