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