]> git.ipfire.org Git - thirdparty/openvpn.git/blame - src/openvpn/options.h
Allow all GCM ciphers
[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 *
49979459 8 * Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net>
6fbf66fa
JY
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
caa54ac3
DS
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6fbf66fa
JY
22 */
23
24/*
25 * 2004-01-28: Added Socks5 proxy support
26 * (Christof Meerwald, http://cmeerw.org)
27 */
28
29#ifndef OPTIONS_H
30#define OPTIONS_H
31
32#include "basic.h"
33#include "common.h"
34#include "mtu.h"
35#include "route.h"
36#include "tun.h"
37#include "socket.h"
38#include "plugin.h"
39#include "manage.h"
40#include "proxy.h"
38d96bd7 41#include "comp.h"
3eee126e 42#include "pushlist.h"
581bef87 43#include "clinat.h"
2193d7c0 44#include "crypto_backend.h"
2193d7c0 45
6fbf66fa
JY
46
47/*
48 * Maximum number of parameters associated with an option,
49 * including the option name itself.
50 */
51#define MAX_PARMS 16
52
53/*
54 * Max size of options line and parameter.
55 */
56#define OPTION_PARM_SIZE 256
57#define OPTION_LINE_SIZE 256
58
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 bool ncp_enabled;
516 const char *ncp_ciphers;
517 const char *authname;
81d882d5
DS
518 const char *prng_hash;
519 int prng_nonce_secret_len;
520 const char *engine;
521 bool replay;
522 bool mute_replay_warnings;
523 int replay_window;
524 int replay_time;
525 const char *packet_id_file;
81d882d5 526 bool test_crypto;
0f25d296 527#ifdef ENABLE_PREDICTION_RESISTANCE
81d882d5
DS
528 bool use_prediction_resistance;
529#endif
530
531 /* TLS (control channel) parms */
532 bool tls_server;
533 bool tls_client;
534 const char *ca_file;
cb2e9218 535 bool ca_file_inline;
81d882d5
DS
536 const char *ca_path;
537 const char *dh_file;
cb2e9218 538 bool dh_file_inline;
81d882d5 539 const char *cert_file;
cb2e9218 540 bool cert_file_inline;
81d882d5 541 const char *extra_certs_file;
cb2e9218 542 bool extra_certs_file_inline;
81d882d5 543 const char *priv_key_file;
cb2e9218 544 bool priv_key_file_inline;
81d882d5 545 const char *pkcs12_file;
cb2e9218 546 bool pkcs12_file_inline;
81d882d5 547 const char *cipher_list;
ea4ee313 548 const char *cipher_list_tls13;
8353ae80 549 const char *tls_groups;
aba75874 550 const char *tls_cert_profile;
81d882d5
DS
551 const char *ecdh_curve;
552 const char *tls_verify;
553 int verify_x509_type;
554 const char *verify_x509_name;
555 const char *tls_export_cert;
556 const char *crl_file;
cb2e9218 557 bool crl_file_inline;
81d882d5
DS
558
559 int ns_cert_type; /* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */
560 unsigned remote_cert_ku[MAX_PARMS];
561 const char *remote_cert_eku;
d1fe6d52 562 struct verify_hash_list *verify_hash;
2193d7c0 563 hash_algo_type verify_hash_algo;
c3a7065d 564 int verify_hash_depth;
423ced96 565 bool verify_hash_no_ca;
81d882d5 566 unsigned int ssl_flags; /* set to SSLF_x flags from ssl.h */
bed73623
JY
567
568#ifdef ENABLE_PKCS11
81d882d5
DS
569 const char *pkcs11_providers[MAX_PARMS];
570 unsigned pkcs11_private_mode[MAX_PARMS];
571 bool pkcs11_protected_authentication[MAX_PARMS];
572 bool pkcs11_cert_private[MAX_PARMS];
573 int pkcs11_pin_cache_period;
574 const char *pkcs11_id;
575 bool pkcs11_id_management;
bed73623
JY
576#endif
577
93c22ecc 578#ifdef ENABLE_CRYPTOAPI
81d882d5 579 const char *cryptoapi_cert;
6fbf66fa 580#endif
81d882d5
DS
581 /* Per-packet timeout on control channel */
582 int tls_timeout;
6fbf66fa 583
81d882d5
DS
584 /* Data channel key renegotiation parameters */
585 int renegotiate_bytes;
586 int renegotiate_packets;
587 int renegotiate_seconds;
dd996463 588 int renegotiate_seconds_min;
6fbf66fa 589
81d882d5
DS
590 /* Data channel key handshake must finalize
591 * within n seconds of handshake initiation. */
592 int handshake_window;
6fbf66fa 593
fbd18db6 594#ifdef ENABLE_X509ALTUSERNAME
3b04c34d
VG
595 /* Field list used to be the username in X509 cert. */
596 char *x509_username_field[MAX_PARMS];
fbd18db6 597#endif
2e8337de 598
81d882d5
DS
599 /* Old key allowed to live n seconds after new key goes active */
600 int transition_window;
6fbf66fa 601
81d882d5
DS
602 /* Shared secret used for TLS control channel authentication */
603 const char *tls_auth_file;
cb2e9218 604 bool tls_auth_file_inline;
6fbf66fa 605
81d882d5
DS
606 /* Shared secret used for TLS control channel authenticated encryption */
607 const char *tls_crypt_file;
cb2e9218 608 bool tls_crypt_file_inline;
c6e24fa3 609
9d59029a
SK
610 /* Client-specific secret or server key used for TLS control channel
611 * authenticated encryption v2 */
612 const char *tls_crypt_v2_file;
cb2e9218 613 bool tls_crypt_v2_file_inline;
9d59029a 614
9d59029a
SK
615 const char *tls_crypt_v2_metadata;
616
ff931c5e
SK
617 const char *tls_crypt_v2_verify_script;
618
81d882d5
DS
619 /* Allow only one session */
620 bool single_session;
6fbf66fa 621
81d882d5 622 bool push_peer_info;
aaf72974 623
81d882d5 624 bool tls_exit;
6fbf66fa 625
81d882d5 626 const struct x509_track *x509_track;
9356bae8 627
81d882d5
DS
628 /* special state parms */
629 int foreign_option_index;
6fbf66fa 630
445b192a 631#ifdef _WIN32
81d882d5
DS
632 HANDLE msg_channel;
633 const char *exit_event_name;
634 bool exit_event_initial_state;
635 bool show_net_up;
636 int route_method;
637 bool block_outside_dns;
36215dc5 638 enum windows_driver_type windows_driver;
6fbf66fa 639#endif
65eedc35 640
81d882d5
DS
641 bool use_peer_id;
642 uint32_t peer_id;
685e486e 643
5defbba4 644#ifdef HAVE_EXPORT_KEYING_MATERIAL
81d882d5
DS
645 /* Keying Material Exporters [RFC 5705] */
646 const char *keying_material_exporter_label;
647 int keying_material_exporter_length;
685e486e 648#endif
7f74c27e 649
99f28081
AQ
650 bool vlan_tagging;
651 enum vlan_acceptable_frames vlan_accept;
652 uint16_t vlan_pvid;
653
81d882d5 654 struct pull_filter_list *pull_filter_list;
e8c42658 655
81d882d5
DS
656 /* Useful when packets sent by openvpn itself are not subject
657 * to the routing tables that would move packets into the tunnel. */
658 bool allow_recursive_routing;
6dc09d0d
AS
659
660 /* Use RFC5705 key export to generate data channel keys */
661 bool data_channel_use_ekm;
6fbf66fa
JY
662};
663
664#define streq(x, y) (!strcmp((x), (y)))
665
666/*
667 * Option classes.
668 */
669#define OPT_P_GENERAL (1<<0)
670#define OPT_P_UP (1<<1)
671#define OPT_P_ROUTE (1<<2)
672#define OPT_P_IPWIN32 (1<<3)
673#define OPT_P_SCRIPT (1<<4)
674#define OPT_P_SETENV (1<<5)
675#define OPT_P_SHAPER (1<<6)
676#define OPT_P_TIMER (1<<7)
677#define OPT_P_PERSIST (1<<8)
678#define OPT_P_PERSIST_IP (1<<9)
679#define OPT_P_COMP (1<<10) /* TODO */
680#define OPT_P_MESSAGES (1<<11)
d728ebed 681#define OPT_P_NCP (1<<12) /**< Negotiable crypto parameters */
6fbf66fa
JY
682#define OPT_P_TLS_PARMS (1<<13) /* TODO */
683#define OPT_P_MTU (1<<14) /* TODO */
684#define OPT_P_NICE (1<<15)
685#define OPT_P_PUSH (1<<16)
6168f53d 686#define OPT_P_INSTANCE (1<<17) /**< allowed in ccd, client-connect etc*/
6fbf66fa
JY
687#define OPT_P_CONFIG (1<<18)
688#define OPT_P_EXPLICIT_NOTIFY (1<<19)
689#define OPT_P_ECHO (1<<20)
690#define OPT_P_INHERIT (1<<21)
3c7f2f55
JY
691#define OPT_P_ROUTE_EXTRAS (1<<22)
692#define OPT_P_PULL_MODE (1<<23)
693#define OPT_P_PLUGIN (1<<24)
00d39170
JY
694#define OPT_P_SOCKBUF (1<<25)
695#define OPT_P_SOCKFLAGS (1<<26)
4e9a51d7 696#define OPT_P_CONNECTION (1<<27)
65eedc35 697#define OPT_P_PEER_ID (1<<28)
cb2e9218 698#define OPT_P_INLINE (1<<29)
6fbf66fa 699
3c7f2f55 700#define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE))
6fbf66fa 701
6fbf66fa 702#define PULL_DEFINED(opt) ((opt)->pull)
6fbf66fa 703#define PUSH_DEFINED(opt) ((opt)->push_list)
6fbf66fa
JY
704
705#ifndef PULL_DEFINED
706#define PULL_DEFINED(opt) (false)
707#endif
708
709#ifndef PUSH_DEFINED
710#define PUSH_DEFINED(opt) (false)
711#endif
712
445b192a 713#ifdef _WIN32
6fbf66fa
JY
714#define ROUTE_OPTION_FLAGS(o) ((o)->route_method & ROUTE_METHOD_MASK)
715#else
716#define ROUTE_OPTION_FLAGS(o) (0)
717#endif
718
6fbf66fa 719#define SHAPER_DEFINED(opt) ((opt)->shaper)
6fbf66fa
JY
720
721#ifdef ENABLE_PLUGIN
722#define PLUGIN_OPTION_LIST(opt) ((opt)->plugin_list)
723#else
724#define PLUGIN_OPTION_LIST(opt) (NULL)
725#endif
726
99d217b2 727#ifdef ENABLE_MANAGEMENT
90efcacb
JY
728#define MAN_CLIENT_AUTH_ENABLED(opt) ((opt)->management_flags & MF_CLIENT_AUTH)
729#else
730#define MAN_CLIENT_AUTH_ENABLED(opt) (false)
731#endif
732
81d882d5
DS
733void parse_argv(struct options *options,
734 const int argc,
735 char *argv[],
736 const int msglevel,
737 const unsigned int permission_mask,
738 unsigned int *option_types_found,
739 struct env_set *es);
6fbf66fa 740
81d882d5 741void notnull(const char *arg, const char *description);
6fbf66fa 742
81d882d5 743void usage_small(void);
6fbf66fa 744
5b17803e
JY
745void show_library_versions(const unsigned int flags);
746
445b192a 747#ifdef _WIN32
cdc65ea0 748void show_windows_version(const unsigned int flags);
81d882d5 749
cdc65ea0
LS
750#endif
751
81d882d5
DS
752void init_options(struct options *o, const bool init_gc);
753
754void uninit_options(struct options *o);
6fbf66fa 755
81d882d5 756void setenv_settings(struct env_set *es, const struct options *o);
6fbf66fa 757
81d882d5
DS
758void show_settings(const struct options *o);
759
760bool string_defined_equal(const char *s1, const char *s2);
6fbf66fa 761
81d882d5
DS
762const char *options_string_version(const char *s, struct gc_arena *gc);
763
764char *options_string(const struct options *o,
765 const struct frame *frame,
766 struct tuntap *tt,
dc7fcd71 767 openvpn_net_ctx_t *ctx,
81d882d5
DS
768 bool remote,
769 struct gc_arena *gc);
770
771bool options_cmp_equal_safe(char *actual, const char *expected, size_t actual_n);
6fbf66fa 772
81d882d5 773void options_warning_safe(char *actual, const char *expected, size_t actual_n);
6fbf66fa 774
81d882d5
DS
775bool options_cmp_equal(char *actual, const char *expected);
776
777void options_warning(char *actual, const char *expected);
6fbf66fa 778
6e5ad2fa
SK
779/**
780 * Given an OpenVPN options string, extract the value of an option.
781 *
81d882d5
DS
782 * @param options_string Zero-terminated, comma-separated options string
783 * @param opt_name The name of the option to extract
784 * @param gc The gc to allocate the return value
6e5ad2fa
SK
785 *
786 * @return gc-allocated value of option with name opt_name if option was found,
787 * or NULL otherwise.
788 */
81d882d5
DS
789char *options_string_extract_option(const char *options_string,
790 const char *opt_name, struct gc_arena *gc);
791
6e5ad2fa 792
81d882d5 793void options_postprocess(struct options *options);
6e5ad2fa 794
c1150e5b 795void pre_connect_save(struct options *o);
6fbf66fa 796
c1150e5b 797void pre_connect_restore(struct options *o, struct gc_arena *gc);
6fbf66fa 798
81d882d5
DS
799bool apply_push_options(struct options *options,
800 struct buffer *buf,
801 unsigned int permission_mask,
802 unsigned int *option_types_found,
803 struct env_set *es);
6fbf66fa 804
81d882d5 805void options_detach(struct options *o);
6fbf66fa 806
81d882d5
DS
807void options_server_import(struct options *o,
808 const char *filename,
809 int msglevel,
810 unsigned int permission_mask,
811 unsigned int *option_types_found,
812 struct env_set *es);
6fbf66fa 813
81d882d5 814void pre_pull_default(struct options *o);
6fbf66fa 815
81d882d5 816void rol_check_alloc(struct options *options);
6fbf66fa 817
81d882d5
DS
818int parse_line(const char *line,
819 char *p[],
820 const int n,
821 const char *file,
822 const int line_num,
823 int msglevel,
824 struct gc_arena *gc);
6fbf66fa 825
3c7f2f55
JY
826/*
827 * parse/print topology coding
828 */
829
81d882d5
DS
830int parse_topology(const char *str, const int msglevel);
831
832const char *print_topology(const int topology);
3c7f2f55 833
6fbf66fa
JY
834/*
835 * Manage auth-retry variable
836 */
837
6fbf66fa
JY
838#define AR_NONE 0
839#define AR_INTERACT 1
840#define AR_NOINTERACT 2
841
81d882d5
DS
842int auth_retry_get(void);
843
844bool auth_retry_set(const int msglevel, const char *option);
845
846const char *auth_retry_print(void);
6fbf66fa 847
81d882d5
DS
848void options_string_import(struct options *options,
849 const char *config,
850 const int msglevel,
851 const unsigned int permission_mask,
852 unsigned int *option_types_found,
853 struct env_set *es);
3c7f2f55 854
81d882d5 855#endif /* ifndef OPTIONS_H */