OpenVPN
init.h
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/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-2024 OpenVPN 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 along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifndef INIT_H
25 #define INIT_H
26 
27 #include "openvpn.h"
28 
29 /*
30  * Baseline maximum number of events
31  * to wait for.
32  */
33 #define BASE_N_EVENTS 5
34 
35 void context_clear(struct context *c);
36 
37 void context_clear_1(struct context *c);
38 
39 void context_clear_2(struct context *c);
40 
41 void context_init_1(struct context *c);
42 
44 
45 bool init_static(void);
46 
47 void uninit_static(void);
48 
49 #define IVM_LEVEL_1 (1<<0)
50 #define IVM_LEVEL_2 (1<<1)
51 void init_verb_mute(struct context *c, unsigned int flags);
52 
53 void init_options_dev(struct options *options);
54 
55 bool print_openssl_info(const struct options *options);
56 
57 bool do_genkey(const struct options *options);
58 
60 
61 bool possibly_become_daemon(const struct options *options);
62 
63 void pre_setup(const struct options *options);
64 
65 void init_instance_handle_signals(struct context *c, const struct env_set *env, const unsigned int flags);
66 
67 void init_instance(struct context *c, const struct env_set *env, const unsigned int flags);
68 
72 void init_query_passwords(const struct context *c);
73 
74 bool do_route(const struct options *options, struct route_list *route_list,
75  struct route_ipv6_list *route_ipv6_list, const struct tuntap *tt,
76  const struct plugin_list *plugins, struct env_set *es,
77  openvpn_net_ctx_t *ctx);
78 
79 void close_instance(struct context *c);
80 
81 bool do_test_crypto(const struct options *o);
82 
83 void context_gc_free(struct context *c);
84 
85 bool do_up(struct context *c,
86  bool pulled_options,
87  unsigned int option_types_found);
88 
89 unsigned int pull_permission_mask(const struct context *c);
90 
91 const char *format_common_name(struct context *c, struct gc_arena *gc);
92 
93 void reset_coarse_timers(struct context *c);
94 
95 bool do_deferred_options(struct context *c, const unsigned int found);
96 
97 void inherit_context_child(struct context *dest,
98  const struct context *src);
99 
100 void inherit_context_top(struct context *dest,
101  const struct context *src);
102 
103 #define CC_GC_FREE (1<<0)
104 #define CC_USR1_TO_HUP (1<<1)
105 #define CC_HARD_USR1_TO_HUP (1<<2)
106 #define CC_NO_CLOSE (1<<3)
107 
108 void close_context(struct context *c, int sig, unsigned int flags);
109 
110 struct context_buffers *init_context_buffers(const struct frame *frame);
111 
112 void free_context_buffers(struct context_buffers *b);
113 
114 #define ISC_ERRORS (1<<0)
115 #define ISC_SERVER (1<<1)
116 #define ISC_ROUTE_ERRORS (1<<2)
117 void initialization_sequence_completed(struct context *c, const unsigned int flags);
118 
119 #ifdef ENABLE_MANAGEMENT
120 
121 void init_management(void);
122 
123 bool open_management(struct context *c);
124 
125 void close_management(void);
126 
127 void management_show_net_callback(void *arg, const int msglevel);
128 
129 #endif
130 
131 void init_management_callback_p2p(struct context *c);
132 
133 void uninit_management_callback(void);
134 
135 #ifdef ENABLE_PLUGIN
136 void init_plugins(struct context *c);
137 
138 void open_plugins(struct context *c, const bool import_options, int init_point);
139 
140 #endif
141 
142 void tun_abort(void);
143 
144 void write_pid_file(const char *filename, const char *chroot_dir);
145 
146 void remove_pid_file(void);
147 
148 void persist_client_stats(struct context *c);
149 
150 #endif /* ifndef INIT_H */
init_context_buffers
struct context_buffers * init_context_buffers(const struct frame *frame)
Definition: init.c:3642
inherit_context_child
void inherit_context_child(struct context *dest, const struct context *src)
Definition: init.c:4786
init_plugins
void init_plugins(struct context *c)
Definition: init.c:4128
init_verb_mute
void init_verb_mute(struct context *c, unsigned int flags)
Definition: init.c:940
context_clear_all_except_first_time
void context_clear_all_except_first_time(struct context *c)
Definition: init.c:94
route_list
Definition: route.h:206
context
Contains all state information for one tunnel.
Definition: openvpn.h:476
es
struct env_set * es
Definition: test_pkcs11.c:133
context::plugins
struct plugin_list * plugins
List of plug-ins.
Definition: openvpn.h:505
openvpn.h
route_ipv6_list
Definition: route.h:219
open_management
bool open_management(struct context *c)
Definition: init.c:4295
close_context
void close_context(struct context *c, int sig, unsigned int flags)
Definition: init.c:4914
tun_abort
void tun_abort(void)
Definition: init.c:2154
print_openssl_info
bool print_openssl_info(const struct options *options)
Definition: init.c:973
openvpn_net_ctx_t
void * openvpn_net_ctx_t
Definition: networking.h:28
do_deferred_options
bool do_deferred_options(struct context *c, const unsigned int found)
Definition: init.c:2593
possibly_become_daemon
bool possibly_become_daemon(const struct options *options)
Definition: init.c:1158
frame
Packet geometry parameters.
Definition: mtu.h:98
uninit_management_callback
void uninit_management_callback(void)
Definition: init.c:4358
free_context_buffers
void free_context_buffers(struct context_buffers *b)
Definition: init.c:3667
persist_client_stats
void persist_client_stats(struct context *c)
Definition: init.c:4369
context::gc
struct gc_arena gc
Garbage collection arena for allocations done in the scope of this context structure.
Definition: openvpn.h:495
do_persist_tuntap
bool do_persist_tuntap(struct options *options, openvpn_net_ctx_t *ctx)
Definition: init.c:1095
close_management
void close_management(void)
Definition: init.c:4345
management_show_net_callback
void management_show_net_callback(void *arg, const int msglevel)
Definition: init.c:4207
reset_coarse_timers
void reset_coarse_timers(struct context *c)
Definition: init.c:1323
uninit_static
void uninit_static(void)
Definition: init.c:922
do_genkey
bool do_genkey(const struct options *options)
Definition: init.c:1012
context_buffers
Definition: openvpn.h:94
inherit_context_top
void inherit_context_top(struct context *dest, const struct context *src)
Definition: init.c:4864
options
Definition: options.h:236
init_management_callback_p2p
void init_management_callback_p2p(struct context *c)
Definition: init.c:4260
pre_setup
void pre_setup(const struct options *options)
Definition: init.c:1295
init_query_passwords
void init_query_passwords(const struct context *c)
Query for private key and auth-user-pass username/passwords.
Definition: init.c:641
init_instance_handle_signals
void init_instance_handle_signals(struct context *c, const struct env_set *env, const unsigned int flags)
Definition: init.c:4384
remove_pid_file
void remove_pid_file(void)
Definition: init.c:4976
init_management
void init_management(void)
Definition: init.c:4286
init_static
bool init_static(void)
Definition: init.c:816
initialization_sequence_completed
void initialization_sequence_completed(struct context *c, const unsigned int flags)
Definition: init.c:1571
write_pid_file
void write_pid_file(const char *filename, const char *chroot_dir)
Definition: init.c:4946
format_common_name
const char * format_common_name(struct context *c, struct gc_arena *gc)
Definition: init.c:1284
close_instance
void close_instance(struct context *c)
Definition: init.c:4711
do_test_crypto
bool do_test_crypto(const struct options *o)
Definition: init.c:5013
context_clear_2
void context_clear_2(struct context *c)
Definition: init.c:88
init_options_dev
void init_options_dev(struct options *options)
Definition: init.c:963
do_route
bool do_route(const struct options *options, struct route_list *route_list, struct route_ipv6_list *route_ipv6_list, const struct tuntap *tt, const struct plugin_list *plugins, struct env_set *es, openvpn_net_ctx_t *ctx)
Definition: init.c:1686
context_gc_free
void context_gc_free(struct context *c)
Definition: init.c:777
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
context::sig
struct signal_info * sig
Internal error signaling object.
Definition: openvpn.h:503
do_up
bool do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
Definition: init.c:2372
env_set
Definition: env_set.h:42
plugin_list
Definition: plugin.h:94
context_clear_1
void context_clear_1(struct context *c)
Definition: init.c:82
init_instance
void init_instance(struct context *c, const struct env_set *env, const unsigned int flags)
Definition: init.c:4406
tuntap
Definition: tun.h:171
context_clear
void context_clear(struct context *c)
Definition: init.c:76
context_init_1
void context_init_1(struct context *c)
Definition: init.c:730
pull_permission_mask
unsigned int pull_permission_mask(const struct context *c)
Definition: init.c:2516
open_plugins
void open_plugins(struct context *c, const bool import_options, int init_point)
Definition: init.c:4138