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