]>
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 | ||
6fbf66fa JY |
219 | /* Advanced MTU negotiation and datagram fragmentation options */ |
220 | int mtu_discover_type; /* used if OS supports setting Path MTU discovery options on socket */ | |
221 | ||
222 | #ifdef ENABLE_OCC | |
223 | bool mtu_test; | |
224 | #endif | |
225 | ||
226 | int fragment; /* internal fragmentation size */ | |
227 | ||
228 | bool mlock; | |
229 | ||
230 | int keepalive_ping; /* a proxy for ping/ping-restart */ | |
231 | int keepalive_timeout; | |
232 | ||
838911cc JY |
233 | int inactivity_timeout; /* --inactive */ |
234 | int inactivity_minimum_bytes; | |
235 | ||
6fbf66fa JY |
236 | int ping_send_timeout; /* Send a TCP/UDP ping to remote every n seconds */ |
237 | int ping_rec_timeout; /* Expect a TCP/UDP ping from remote at least once every n seconds */ | |
238 | bool ping_timer_remote; /* Run ping timer only if we have a remote address */ | |
239 | bool tun_ipv6; /* Build tun dev that supports IPv6 */ | |
240 | ||
241 | # define PING_UNDEF 0 | |
242 | # define PING_EXIT 1 | |
243 | # define PING_RESTART 2 | |
244 | int ping_rec_timeout_action; /* What action to take on ping_rec_timeout (exit or restart)? */ | |
245 | ||
246 | #ifdef ENABLE_OCC | |
247 | int explicit_exit_notification; /* Explicitly tell peer when we are exiting via OCC_EXIT message */ | |
248 | #endif | |
249 | ||
250 | bool persist_tun; /* Don't close/reopen TUN/TAP dev on SIGUSR1 or PING_RESTART */ | |
251 | bool persist_local_ip; /* Don't re-resolve local address on SIGUSR1 or PING_RESTART */ | |
252 | bool persist_remote_ip; /* Don't re-resolve remote address on SIGUSR1 or PING_RESTART */ | |
253 | bool persist_key; /* Don't re-read key files on SIGUSR1 or PING_RESTART */ | |
254 | ||
255 | int mssfix; /* Upper bound on TCP MSS */ | |
256 | bool mssfix_default; /* true if --mssfix was supplied without a parameter */ | |
257 | ||
258 | #if PASSTOS_CAPABILITY | |
259 | bool passtos; | |
260 | #endif | |
261 | ||
262 | int resolve_retry_seconds; /* If hostname resolve fails, retry for n seconds */ | |
263 | ||
264 | struct tuntap_options tuntap_options; | |
265 | ||
266 | /* Misc parms */ | |
267 | const char *username; | |
268 | const char *groupname; | |
269 | const char *chroot_dir; | |
270 | const char *cd_dir; | |
99385447 JY |
271 | #ifdef HAVE_SETCON |
272 | char *selinux_context; | |
273 | #endif | |
6fbf66fa JY |
274 | const char *writepid; |
275 | const char *up_script; | |
276 | const char *down_script; | |
277 | bool down_pre; | |
278 | bool up_delay; | |
279 | bool up_restart; | |
280 | bool daemon; | |
281 | ||
282 | int remap_sigusr1; | |
283 | ||
284 | /* inetd modes defined in socket.h */ | |
285 | int inetd; | |
286 | ||
287 | bool log; | |
288 | bool suppress_timestamps; | |
289 | int nice; | |
290 | int verbosity; | |
291 | int mute; | |
292 | ||
293 | #ifdef ENABLE_DEBUG | |
294 | int gremlin; | |
295 | #endif | |
296 | ||
297 | const char *status_file; | |
298 | int status_file_version; | |
299 | int status_file_update_freq; | |
300 | ||
301 | /* optimize TUN/TAP/UDP writes */ | |
302 | bool fast_io; | |
303 | ||
304 | #ifdef USE_LZO | |
537073fd JY |
305 | /* LZO_x flags from lzo.h */ |
306 | unsigned int lzo; | |
6fbf66fa JY |
307 | #endif |
308 | ||
309 | /* buffer sizes */ | |
310 | int rcvbuf; | |
311 | int sndbuf; | |
312 | ||
00d39170 JY |
313 | /* socket flags */ |
314 | unsigned int sockflags; | |
315 | ||
6fbf66fa JY |
316 | /* route management */ |
317 | const char *route_script; | |
318 | const char *route_default_gateway; | |
40ac3d7a | 319 | int route_default_metric; |
6fbf66fa JY |
320 | bool route_noexec; |
321 | int route_delay; | |
322 | int route_delay_window; | |
323 | bool route_delay_defined; | |
673f583f | 324 | int max_routes; |
6fbf66fa | 325 | struct route_option_list *routes; |
3c7f2f55 | 326 | bool route_nopull; |
03731db3 | 327 | bool route_gateway_via_dhcp; |
0a838de8 | 328 | bool allow_pull_fqdn; /* as a client, allow server to push a FQDN for certain parameters */ |
6fbf66fa | 329 | |
6fbf66fa JY |
330 | #ifdef ENABLE_OCC |
331 | /* Enable options consistency check between peers */ | |
332 | bool occ; | |
333 | #endif | |
334 | ||
335 | #ifdef ENABLE_MANAGEMENT | |
336 | const char *management_addr; | |
337 | int management_port; | |
338 | const char *management_user_pass; | |
339 | int management_log_history_cache; | |
340 | int management_echo_buffer_size; | |
341 | int management_state_buffer_size; | |
8d33c060 | 342 | const char *management_write_peer_info_file; |
90efcacb | 343 | |
bb564a59 JY |
344 | const char *management_client_user; |
345 | const char *management_client_group; | |
346 | ||
90efcacb JY |
347 | /* Mask of MF_ values of manage.h */ |
348 | unsigned int management_flags; | |
6fbf66fa JY |
349 | #endif |
350 | ||
351 | #ifdef ENABLE_PLUGIN | |
352 | struct plugin_option_list *plugin_list; | |
353 | #endif | |
354 | ||
355 | #ifdef USE_PTHREAD | |
356 | int n_threads; | |
357 | int nice_work; | |
358 | #endif | |
359 | ||
360 | #if P2MP | |
361 | ||
362 | #if P2MP_SERVER | |
363 | bool server_defined; | |
364 | in_addr_t server_network; | |
365 | in_addr_t server_netmask; | |
366 | ||
3c7f2f55 | 367 | # define SF_NOPOOL (1<<0) |
ae3b3746 | 368 | # define SF_TCP_NODELAY_HELPER (1<<1) |
148329ca | 369 | # define SF_NO_PUSH_ROUTE_GATEWAY (1<<2) |
3c7f2f55 JY |
370 | unsigned int server_flags; |
371 | ||
03731db3 JY |
372 | bool server_bridge_proxy_dhcp; |
373 | ||
6fbf66fa JY |
374 | bool server_bridge_defined; |
375 | in_addr_t server_bridge_ip; | |
376 | in_addr_t server_bridge_netmask; | |
377 | in_addr_t server_bridge_pool_start; | |
378 | in_addr_t server_bridge_pool_end; | |
379 | ||
3eee126e | 380 | struct push_list push_list; |
6fbf66fa JY |
381 | bool ifconfig_pool_defined; |
382 | in_addr_t ifconfig_pool_start; | |
383 | in_addr_t ifconfig_pool_end; | |
384 | in_addr_t ifconfig_pool_netmask; | |
385 | const char *ifconfig_pool_persist_filename; | |
386 | int ifconfig_pool_persist_refresh_freq; | |
6fbf66fa JY |
387 | int real_hash_size; |
388 | int virtual_hash_size; | |
389 | const char *client_connect_script; | |
390 | const char *client_disconnect_script; | |
391 | const char *learn_address_script; | |
392 | const char *tmp_dir; | |
393 | const char *client_config_dir; | |
394 | bool ccd_exclusive; | |
395 | bool disable; | |
396 | int n_bcast_buf; | |
397 | int tcp_queue_limit; | |
398 | struct iroute *iroutes; | |
399 | bool push_ifconfig_defined; | |
400 | in_addr_t push_ifconfig_local; | |
401 | in_addr_t push_ifconfig_remote_netmask; | |
3c7f2f55 JY |
402 | bool push_ifconfig_constraint_defined; |
403 | in_addr_t push_ifconfig_constraint_network; | |
404 | in_addr_t push_ifconfig_constraint_netmask; | |
6fbf66fa JY |
405 | bool enable_c2c; |
406 | bool duplicate_cn; | |
407 | int cf_max; | |
408 | int cf_per; | |
409 | int max_clients; | |
410 | int max_routes_per_client; | |
411 | ||
6fbf66fa JY |
412 | const char *auth_user_pass_verify_script; |
413 | bool auth_user_pass_verify_script_via_file; | |
24ce3b27 | 414 | unsigned int ssl_flags; /* set to SSLF_x flags from ssl.h */ |
6add6b2f JY |
415 | #if PORT_SHARE |
416 | char *port_share_host; | |
417 | int port_share_port; | |
418 | #endif | |
6fbf66fa JY |
419 | #endif |
420 | ||
421 | bool client; | |
422 | bool pull; /* client pull of config options from server */ | |
3eee126e | 423 | int push_continuation; |
6fbf66fa JY |
424 | const char *auth_user_pass_file; |
425 | struct options_pre_pull *pre_pull; | |
426 | ||
e1e977f3 JY |
427 | int server_poll_timeout; |
428 | ||
6fbf66fa JY |
429 | int scheduled_exit_interval; |
430 | ||
431 | #endif | |
432 | ||
433 | #ifdef USE_CRYPTO | |
434 | /* Cipher parms */ | |
435 | const char *shared_secret_file; | |
c959fc74 JY |
436 | #if ENABLE_INLINE_FILES |
437 | const char *shared_secret_file_inline; | |
438 | #endif | |
6fbf66fa JY |
439 | int key_direction; |
440 | bool ciphername_defined; | |
441 | const char *ciphername; | |
442 | bool authname_defined; | |
443 | const char *authname; | |
444 | int keysize; | |
03bfb228 JY |
445 | const char *prng_hash; |
446 | int prng_nonce_secret_len; | |
6fbf66fa JY |
447 | const char *engine; |
448 | bool replay; | |
449 | bool mute_replay_warnings; | |
450 | int replay_window; | |
451 | int replay_time; | |
452 | const char *packet_id_file; | |
453 | bool use_iv; | |
454 | bool test_crypto; | |
455 | ||
456 | #ifdef USE_SSL | |
457 | /* TLS (control channel) parms */ | |
458 | bool tls_server; | |
459 | bool tls_client; | |
460 | const char *ca_file; | |
e9c5e170 | 461 | const char *ca_path; |
6fbf66fa JY |
462 | const char *dh_file; |
463 | const char *cert_file; | |
464 | const char *priv_key_file; | |
465 | const char *pkcs12_file; | |
466 | const char *cipher_list; | |
467 | const char *tls_verify; | |
468 | const char *tls_remote; | |
469 | const char *crl_file; | |
d40f2b20 JY |
470 | |
471 | #if ENABLE_INLINE_FILES | |
472 | const char *ca_file_inline; | |
473 | const char *cert_file_inline; | |
474 | char *priv_key_file_inline; | |
475 | const char *dh_file_inline; | |
2e8ff6c1 | 476 | const char *pkcs12_file_inline; /* contains the base64 encoding of pkcs12 file */ |
d40f2b20 JY |
477 | #endif |
478 | ||
6fbf66fa | 479 | int ns_cert_type; /* set to 0, NS_SSL_SERVER, or NS_SSL_CLIENT */ |
411e89ae JY |
480 | unsigned remote_cert_ku[MAX_PARMS]; |
481 | const char *remote_cert_eku; | |
bed73623 JY |
482 | |
483 | #ifdef ENABLE_PKCS11 | |
ce98fd24 | 484 | const char *pkcs11_providers[MAX_PARMS]; |
718526e0 | 485 | unsigned pkcs11_private_mode[MAX_PARMS]; |
18597b93 JY |
486 | bool pkcs11_protected_authentication[MAX_PARMS]; |
487 | bool pkcs11_cert_private[MAX_PARMS]; | |
488 | int pkcs11_pin_cache_period; | |
ce98fd24 | 489 | const char *pkcs11_id; |
1bda73a7 | 490 | bool pkcs11_id_management; |
bed73623 JY |
491 | #endif |
492 | ||
6fbf66fa JY |
493 | #ifdef WIN32 |
494 | const char *cryptoapi_cert; | |
495 | #endif | |
496 | ||
497 | /* data channel key exchange method */ | |
498 | int key_method; | |
499 | ||
500 | /* Per-packet timeout on control channel */ | |
501 | int tls_timeout; | |
502 | ||
503 | /* Data channel key renegotiation parameters */ | |
504 | int renegotiate_bytes; | |
505 | int renegotiate_packets; | |
506 | int renegotiate_seconds; | |
507 | ||
508 | /* Data channel key handshake must finalize | |
509 | within n seconds of handshake initiation. */ | |
510 | int handshake_window; | |
511 | ||
512 | /* Old key allowed to live n seconds after new key goes active */ | |
513 | int transition_window; | |
514 | ||
515 | /* Special authentication MAC for TLS control channel */ | |
516 | const char *tls_auth_file; /* shared secret */ | |
c959fc74 JY |
517 | #if ENABLE_INLINE_FILES |
518 | const char *tls_auth_file_inline; | |
519 | #endif | |
6fbf66fa JY |
520 | |
521 | /* Allow only one session */ | |
522 | bool single_session; | |
523 | ||
aaf72974 JY |
524 | #ifdef ENABLE_PUSH_PEER_INFO |
525 | bool push_peer_info; | |
526 | #endif | |
527 | ||
6fbf66fa JY |
528 | bool tls_exit; |
529 | ||
530 | #endif /* USE_SSL */ | |
531 | #endif /* USE_CRYPTO */ | |
532 | ||
533 | /* special state parms */ | |
534 | int foreign_option_index; | |
535 | ||
536 | #ifdef WIN32 | |
537 | const char *exit_event_name; | |
538 | bool exit_event_initial_state; | |
539 | bool show_net_up; | |
540 | int route_method; | |
541 | #endif | |
542 | }; | |
543 | ||
544 | #define streq(x, y) (!strcmp((x), (y))) | |
545 | ||
546 | /* | |
547 | * Option classes. | |
548 | */ | |
549 | #define OPT_P_GENERAL (1<<0) | |
550 | #define OPT_P_UP (1<<1) | |
551 | #define OPT_P_ROUTE (1<<2) | |
552 | #define OPT_P_IPWIN32 (1<<3) | |
553 | #define OPT_P_SCRIPT (1<<4) | |
554 | #define OPT_P_SETENV (1<<5) | |
555 | #define OPT_P_SHAPER (1<<6) | |
556 | #define OPT_P_TIMER (1<<7) | |
557 | #define OPT_P_PERSIST (1<<8) | |
558 | #define OPT_P_PERSIST_IP (1<<9) | |
559 | #define OPT_P_COMP (1<<10) /* TODO */ | |
560 | #define OPT_P_MESSAGES (1<<11) | |
561 | #define OPT_P_CRYPTO (1<<12) /* TODO */ | |
562 | #define OPT_P_TLS_PARMS (1<<13) /* TODO */ | |
563 | #define OPT_P_MTU (1<<14) /* TODO */ | |
564 | #define OPT_P_NICE (1<<15) | |
565 | #define OPT_P_PUSH (1<<16) | |
566 | #define OPT_P_INSTANCE (1<<17) | |
567 | #define OPT_P_CONFIG (1<<18) | |
568 | #define OPT_P_EXPLICIT_NOTIFY (1<<19) | |
569 | #define OPT_P_ECHO (1<<20) | |
570 | #define OPT_P_INHERIT (1<<21) | |
3c7f2f55 JY |
571 | #define OPT_P_ROUTE_EXTRAS (1<<22) |
572 | #define OPT_P_PULL_MODE (1<<23) | |
573 | #define OPT_P_PLUGIN (1<<24) | |
00d39170 JY |
574 | #define OPT_P_SOCKBUF (1<<25) |
575 | #define OPT_P_SOCKFLAGS (1<<26) | |
4e9a51d7 | 576 | #define OPT_P_CONNECTION (1<<27) |
6fbf66fa | 577 | |
3c7f2f55 | 578 | #define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE)) |
6fbf66fa JY |
579 | |
580 | #if P2MP | |
581 | #define PULL_DEFINED(opt) ((opt)->pull) | |
582 | #if P2MP_SERVER | |
583 | #define PUSH_DEFINED(opt) ((opt)->push_list) | |
584 | #endif | |
585 | #endif | |
586 | ||
587 | #ifndef PULL_DEFINED | |
588 | #define PULL_DEFINED(opt) (false) | |
589 | #endif | |
590 | ||
591 | #ifndef PUSH_DEFINED | |
592 | #define PUSH_DEFINED(opt) (false) | |
593 | #endif | |
594 | ||
595 | #ifdef WIN32 | |
596 | #define ROUTE_OPTION_FLAGS(o) ((o)->route_method & ROUTE_METHOD_MASK) | |
597 | #else | |
598 | #define ROUTE_OPTION_FLAGS(o) (0) | |
599 | #endif | |
600 | ||
601 | #ifdef HAVE_GETTIMEOFDAY | |
602 | #define SHAPER_DEFINED(opt) ((opt)->shaper) | |
603 | #else | |
604 | #define SHAPER_DEFINED(opt) (false) | |
605 | #endif | |
606 | ||
607 | #ifdef ENABLE_PLUGIN | |
608 | #define PLUGIN_OPTION_LIST(opt) ((opt)->plugin_list) | |
609 | #else | |
610 | #define PLUGIN_OPTION_LIST(opt) (NULL) | |
611 | #endif | |
612 | ||
90efcacb JY |
613 | #ifdef MANAGEMENT_DEF_AUTH |
614 | #define MAN_CLIENT_AUTH_ENABLED(opt) ((opt)->management_flags & MF_CLIENT_AUTH) | |
615 | #else | |
616 | #define MAN_CLIENT_AUTH_ENABLED(opt) (false) | |
617 | #endif | |
618 | ||
6fbf66fa JY |
619 | void parse_argv (struct options *options, |
620 | const int argc, | |
621 | char *argv[], | |
622 | const int msglevel, | |
623 | const unsigned int permission_mask, | |
624 | unsigned int *option_types_found, | |
625 | struct env_set *es); | |
626 | ||
627 | void notnull (const char *arg, const char *description); | |
628 | ||
629 | void usage_small (void); | |
630 | ||
4e9a51d7 | 631 | void init_options (struct options *o, const bool init_gc); |
6fbf66fa JY |
632 | void uninit_options (struct options *o); |
633 | ||
634 | void setenv_settings (struct env_set *es, const struct options *o); | |
635 | void show_settings (const struct options *o); | |
636 | ||
637 | bool string_defined_equal (const char *s1, const char *s2); | |
638 | ||
639 | #ifdef ENABLE_OCC | |
640 | ||
641 | const char *options_string_version (const char* s, struct gc_arena *gc); | |
642 | ||
643 | char *options_string (const struct options *o, | |
644 | const struct frame *frame, | |
645 | struct tuntap *tt, | |
646 | bool remote, | |
647 | struct gc_arena *gc); | |
648 | ||
bb564a59 | 649 | bool options_cmp_equal_safe (char *actual, const char *expected, size_t actual_n); |
6fbf66fa | 650 | void options_warning_safe (char *actual, const char *expected, size_t actual_n); |
bb564a59 | 651 | bool options_cmp_equal (char *actual, const char *expected); |
6fbf66fa JY |
652 | void options_warning (char *actual, const char *expected); |
653 | ||
654 | #endif | |
655 | ||
4e9a51d7 | 656 | void options_postprocess (struct options *options); |
6fbf66fa JY |
657 | |
658 | void pre_pull_save (struct options *o); | |
659 | void pre_pull_restore (struct options *o); | |
660 | ||
661 | bool apply_push_options (struct options *options, | |
662 | struct buffer *buf, | |
663 | unsigned int permission_mask, | |
664 | unsigned int *option_types_found, | |
665 | struct env_set *es); | |
666 | ||
667 | bool is_persist_option (const struct options *o); | |
668 | bool is_stateful_restart (const struct options *o); | |
669 | ||
670 | void options_detach (struct options *o); | |
671 | ||
672 | void options_server_import (struct options *o, | |
673 | const char *filename, | |
674 | int msglevel, | |
675 | unsigned int permission_mask, | |
676 | unsigned int *option_types_found, | |
677 | struct env_set *es); | |
678 | ||
679 | void pre_pull_default (struct options *o); | |
680 | ||
681 | void rol_check_alloc (struct options *options); | |
682 | ||
683 | int parse_line (const char *line, | |
684 | char *p[], | |
685 | const int n, | |
686 | const char *file, | |
687 | const int line_num, | |
688 | int msglevel, | |
689 | struct gc_arena *gc); | |
690 | ||
3c7f2f55 JY |
691 | /* |
692 | * parse/print topology coding | |
693 | */ | |
694 | ||
695 | int parse_topology (const char *str, const int msglevel); | |
696 | const char *print_topology (const int topology); | |
697 | ||
6fbf66fa JY |
698 | /* |
699 | * Manage auth-retry variable | |
700 | */ | |
701 | ||
702 | #if P2MP | |
703 | ||
704 | #define AR_NONE 0 | |
705 | #define AR_INTERACT 1 | |
706 | #define AR_NOINTERACT 2 | |
707 | ||
708 | int auth_retry_get (void); | |
709 | bool auth_retry_set (const int msglevel, const char *option); | |
710 | const char *auth_retry_print (void); | |
711 | ||
712 | #endif | |
713 | ||
90efcacb | 714 | void options_string_import (struct options *options, |
3c7f2f55 JY |
715 | const char *config, |
716 | const int msglevel, | |
717 | const unsigned int permission_mask, | |
718 | unsigned int *option_types_found, | |
719 | struct env_set *es); | |
720 | ||
4e9a51d7 JY |
721 | /* |
722 | * inline functions | |
723 | */ | |
724 | static inline bool | |
725 | connection_list_defined (const struct options *o) | |
726 | { | |
727 | #ifdef ENABLE_CONNECTION | |
728 | return o->connection_list != NULL; | |
729 | #else | |
730 | return false; | |
731 | #endif | |
732 | } | |
733 | ||
734 | static inline void | |
735 | connection_list_set_no_advance (struct options *o) | |
736 | { | |
737 | #ifdef ENABLE_CONNECTION | |
738 | if (o->connection_list) | |
739 | o->connection_list->no_advance = true; | |
740 | #endif | |
741 | } | |
742 | ||
3cf6c932 JY |
743 | #if HTTP_PROXY_FALLBACK |
744 | ||
745 | struct http_proxy_options * | |
746 | parse_http_proxy_fallback (struct context *c, | |
747 | const char *server, | |
748 | const char *port, | |
749 | const char *flags, | |
750 | const int msglevel); | |
751 | ||
752 | #endif /* HTTP_PROXY_FALLBACK */ | |
753 | ||
3c7f2f55 | 754 | #endif |