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