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