OpenVPN
sig.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 SIG_H
25#define SIG_H
26
27#include "status.h"
28#include "win32.h"
29
30#define SIG_SOURCE_SOFT 0
31#define SIG_SOURCE_HARD 1
32/* CONNECTION_FAILED is also a "soft" status,
33 * It is thrown if a connection attempt fails
34 */
35#define SIG_SOURCE_CONNECTION_FAILED 2
36
37/*
38 * Signal information, including signal code
39 * and descriptive text.
40 */
42{
43 volatile int signal_received;
44 volatile int source;
45 const char *signal_text;
46};
47
48#define IS_SIG(c) ((c)->sig->signal_received)
49
50struct context;
51
52extern struct signal_info siginfo_static;
53
54int parse_signal(const char *signame);
55
56const char *signal_name(const int sig, const bool upper);
57
58const char *signal_description(const int signum, const char *sigtext);
59
60void throw_signal(const int signum);
61
62void throw_signal_soft(const int signum, const char *signal_text);
63
64void pre_init_signal_catch(void);
65
66void post_init_signal_catch(void);
67
68void restore_signal_state(void);
69
70void print_signal(const struct signal_info *si, const char *title, int msglevel);
71
72void print_status(struct context *c, struct status_output *so);
73
74void remap_signal(struct context *c);
75
76void signal_restart_status(const struct signal_info *si);
77
78bool process_signal(struct context *c);
79
80void register_signal(struct signal_info *si, int sig, const char *text);
81
83
89int signal_reset(struct signal_info *si, int signum);
90
91static inline void
93{
94#ifdef _WIN32
96#endif
97}
98
109static inline void
110get_signal(volatile int *sig)
111{
112#ifdef _WIN32
113 const int i = win32_signal_get(&win32_signal);
114#else
115 const int i = siginfo_static.signal_received;
116#endif
117 if (i && sig != &siginfo_static.signal_received)
118 {
119 *sig = i;
120 }
121}
122
123#endif /* ifndef SIG_H */
static void halt_non_edge_triggered_signals(void)
Definition sig.h:92
bool process_signal(struct context *c)
Definition sig.c:640
void signal_restart_status(const struct signal_info *si)
Definition sig.c:348
void post_init_signal_catch(void)
Definition sig.c:427
void throw_signal_soft(const int signum, const char *signal_text)
Throw a soft global signal.
Definition sig.c:206
void print_status(struct context *c, struct status_output *so)
Definition sig.c:484
const char * signal_name(const int sig, const bool upper)
Definition sig.c:93
void register_signal(struct signal_info *si, int sig, const char *text)
Register a soft signal in the signal_info struct si respecting priority.
Definition sig.c:231
int signal_reset(struct signal_info *si, int signum)
Clear the signal if its current value equals signum.
Definition sig.c:266
void process_explicit_exit_notification_timer_wakeup(struct context *c)
Definition sig.c:567
void pre_init_signal_catch(void)
Definition sig.c:398
void remap_signal(struct context *c)
Definition sig.c:591
const char * signal_description(const int signum, const char *sigtext)
Definition sig.c:107
void restore_signal_state(void)
Definition sig.c:466
void throw_signal(const int signum)
Throw a hard signal.
Definition sig.c:177
int parse_signal(const char *signame)
Definition sig.c:66
struct signal_info siginfo_static
Definition sig.c:45
void print_signal(const struct signal_info *si, const char *title, int msglevel)
Definition sig.c:294
static void get_signal(volatile int *sig)
Copy the global signal_received (if non-zero) to the passed-in argument sig.
Definition sig.h:110
Contains all state information for one tunnel.
Definition openvpn.h:474
const char * signal_text
Definition sig.h:45
volatile int signal_received
Definition sig.h:43
volatile int source
Definition sig.h:44
Definition sig.c:47
void win32_signal_close(struct win32_signal *ws)
Definition win32.c:605
int win32_signal_get(struct win32_signal *ws)
Definition win32.c:639