~ubuntu-branches/ubuntu/saucy/openvpn/saucy-proposed

« back to all changes in this revision

Viewing changes to src/openvpn/options.h

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2013-05-24 17:42:45 UTC
  • mfrom: (1.1.19) (10.2.22 sid)
  • Revision ID: package-import@ubuntu.com-20130524174245-g9y6wlforycufqy5
Tags: 2.3.1-2ubuntu1
* Merge from Debian unstable. Remaining changes:
  - debian/openvpn.init.d:
    + Do not use start-stop-daemon and </dev/null to avoid blocking boot.
    + Show per-VPN result messages.
    + Add "--script-security 2" by default for backwards compatabliity.

Show diffs side-by-side

added added

removed removed

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