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-2026 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, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef INIT_H
24#define INIT_H
25
26#include "openvpn.h"
27
28/*
29 * Baseline maximum number of events
30 * to wait for.
31 */
32#define BASE_N_EVENTS 5
33
34void context_clear_2(struct context *c);
35
36void context_init_1(struct context *c);
37
39
40bool init_static(void);
41
42void uninit_static(void);
43
44#define IVM_LEVEL_1 (1 << 0)
45#define IVM_LEVEL_2 (1 << 1)
46void init_verb_mute(struct context *c, unsigned int flags);
47
48void init_options_dev(struct options *options);
49
50bool print_openssl_info(const struct options *options);
51
52bool do_genkey(const struct options *options);
53
55
56bool possibly_become_daemon(const struct options *options);
57
58void pre_setup(const struct options *options);
59
60void init_instance_handle_signals(struct context *c, const struct env_set *env,
61 const unsigned int flags);
62
66void init_query_passwords(const struct context *c);
67
68bool do_route(const struct options *options, struct route_list *route_list,
69 struct route_ipv6_list *route_ipv6_list, const struct tuntap *tt,
70 const struct plugin_list *plugins, struct env_set *es, openvpn_net_ctx_t *ctx);
71
72void close_instance(struct context *c);
73
74void do_test_crypto(struct context *o);
75
76void context_gc_free(struct context *c);
77
78bool do_up(struct context *c, bool pulled_options, uint64_t option_types_found);
79
90bool do_update(struct context *c, uint64_t option_types_found);
91
92unsigned int pull_permission_mask(const struct context *c);
93
94const char *format_common_name(struct context *c, struct gc_arena *gc);
95
96void reset_coarse_timers(struct context *c);
97
98/*
99 * Handle non-tun-related pulled options.
100 * Set `is_update` param to true to skip NCP check.
101 */
102bool do_deferred_options(struct context *c, const uint64_t found, const bool is_update);
103
104void inherit_context_child(struct context *dest, const struct context *src,
105 struct link_socket *sock);
106
107void inherit_context_top(struct context *dest, const struct context *src);
108
109#define CC_GC_FREE (1 << 0)
110#define CC_USR1_TO_HUP (1 << 1)
111#define CC_HARD_USR1_TO_HUP (1 << 2)
112#define CC_NO_CLOSE (1 << 3)
113
114void close_context(struct context *c, int sig, unsigned int flags);
115
116struct context_buffers *init_context_buffers(const struct frame *frame);
117
119
120#define ISC_ERRORS (1 << 0)
121#define ISC_SERVER (1 << 1)
122#define ISC_ROUTE_ERRORS (1 << 2)
123void initialization_sequence_completed(struct context *c, const unsigned int flags);
124
125#ifdef ENABLE_MANAGEMENT
126
127void init_management(void);
128
129bool open_management(struct context *c);
130
131void close_management(void);
132
133void management_show_net_callback(void *arg, const msglvl_t msglevel);
134
135#endif
136
138
140
141#ifdef ENABLE_PLUGIN
142void init_plugins(struct context *c);
143
144void open_plugins(struct context *c, const bool import_options, int init_point);
145
146#endif
147
148void tun_abort(void);
149
150void write_pid_file(const char *filename, const char *chroot_dir);
151
152void remove_pid_file(void);
153
154void persist_client_stats(struct context *c);
155
156#endif /* ifndef INIT_H */
void uninit_management_callback(void)
Definition init.c:4401
bool open_management(struct context *c)
Definition init.c:4348
bool do_genkey(const struct options *options)
Definition init.c:1010
void initialization_sequence_completed(struct context *c, const unsigned int flags)
Definition init.c:1534
void open_plugins(struct context *c, const bool import_options, int init_point)
Definition init.c:4185
bool do_update(struct context *c, uint64_t option_types_found)
A simplified version of the do_up() function.
Definition init.c:2473
void init_verb_mute(struct context *c, unsigned int flags)
Definition init.c:938
const char * format_common_name(struct context *c, struct gc_arena *gc)
Definition init.c:1268
void close_instance(struct context *c)
Definition init.c:4735
void do_test_crypto(struct context *o)
Definition init.c:5022
void persist_client_stats(struct context *c)
Definition init.c:4412
void inherit_context_top(struct context *dest, const struct context *src)
Definition init.c:4896
void init_plugins(struct context *c)
Definition init.c:4175
void free_context_buffers(struct context_buffers *b)
Definition init.c:3699
void context_init_1(struct context *c)
Definition init.c:750
void pre_setup(const struct options *options)
Definition init.c:1279
void reset_coarse_timers(struct context *c)
Definition init.c:1302
void init_management(void)
Definition init.c:4339
void uninit_static(void)
Definition init.c:920
void init_instance_handle_signals(struct context *c, const struct env_set *env, const unsigned int flags)
Definition init.c:4713
void write_pid_file(const char *filename, const char *chroot_dir)
Definition init.c:4974
void context_gc_free(struct context *c)
Definition init.c:801
void init_options_dev(struct options *options)
Definition init.c:961
void init_query_passwords(const struct context *c)
Query for private key and auth-user-pass username/passwords.
Definition init.c:655
void inherit_context_child(struct context *dest, const struct context *src, struct link_socket *sock)
Definition init.c:4808
void context_clear_2(struct context *c)
Definition init.c:88
void remove_pid_file(void)
Definition init.c:5008
bool print_openssl_info(const struct options *options)
Definition init.c:972
void close_context(struct context *c, int sig, unsigned int flags)
Definition init.c:4942
bool do_persist_tuntap(struct options *options, openvpn_net_ctx_t *ctx)
Definition init.c:1091
void tun_abort(void)
Definition init.c:2141
bool do_deferred_options(struct context *c, const uint64_t found, const bool is_update)
Definition init.c:2587
bool init_static(void)
Definition init.c:839
bool possibly_become_daemon(const struct options *options)
Definition init.c:1150
unsigned int pull_permission_mask(const struct context *c)
Definition init.c:2526
bool do_up(struct context *c, bool pulled_options, uint64_t option_types_found)
Definition init.c:2338
void init_management_callback_p2p(struct context *c)
Definition init.c:4313
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:1655
void context_clear_all_except_first_time(struct context *c)
Definition init.c:94
struct context_buffers * init_context_buffers(const struct frame *frame)
Definition init.c:3674
void close_management(void)
Definition init.c:4388
void management_show_net_callback(void *arg, const msglvl_t msglevel)
Definition init.c:4251
void * openvpn_net_ctx_t
Definition networking.h:38
unsigned int msglvl_t
Definition error.h:77
Contains all state information for one tunnel.
Definition openvpn.h:471
Packet geometry parameters.
Definition mtu.h:113
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:117
Definition tun.h:181
struct env_set * es
struct gc_arena gc
Definition test_ssl.c:133