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-2018 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 
31 
32 #define SIG_SOURCE_SOFT 0
33 #define SIG_SOURCE_HARD 1
34 /* CONNECTION_FAILED is also a "soft" status,
35  * It is thrown if a connection attempt fails
36  */
37 #define SIG_SOURCE_CONNECTION_FAILED 2
38 
39 /*
40  * Signal information, including signal code
41  * and descriptive text.
42  */
44 {
45  volatile int signal_received;
46  volatile int source;
47  const char *signal_text;
48 };
49 
50 #define IS_SIG(c) ((c)->sig->signal_received)
51 
52 struct context;
53 
54 extern struct signal_info siginfo_static;
55 
56 int parse_signal(const char *signame);
57 
58 const char *signal_name(const int sig, const bool upper);
59 
60 const char *signal_description(const int signum, const char *sigtext);
61 
62 void throw_signal(const int signum);
63 
64 void throw_signal_soft(const int signum, const char *signal_text);
65 
66 void pre_init_signal_catch(void);
67 
68 void post_init_signal_catch(void);
69 
70 void restore_signal_state(void);
71 
72 void print_signal(const struct signal_info *si, const char *title, int msglevel);
73 
74 void print_status(const struct context *c, struct status_output *so);
75 
76 void remap_signal(struct context *c);
77 
78 void signal_restart_status(const struct signal_info *si);
79 
80 bool process_signal(struct context *c);
81 
82 void register_signal(struct context *c, int sig, const char *text);
83 
84 #ifdef ENABLE_OCC
86 
87 #endif
88 
89 #ifdef _WIN32
90 
91 static inline void
92 get_signal(volatile int *sig)
93 {
95 }
96 
97 static inline void
99 {
101 }
102 
103 #else /* ifdef _WIN32 */
104 
105 static inline void
106 get_signal(volatile int *sig)
107 {
108  const int i = siginfo_static.signal_received;
109  if (i)
110  {
111  *sig = i;
112  }
113 }
114 
115 static inline void
117 {
118 }
119 
120 #endif /* ifdef _WIN32 */
121 
122 #endif /* ifndef SIG_H */
bool process_signal(struct context *c)
Definition: sig.c:439
const char * signal_name(const int sig, const bool upper)
Definition: sig.c:77
void restore_signal_state(void)
Definition: sig.c:272
static void halt_non_edge_triggered_signals(void)
Definition: sig.h:98
struct signal_info siginfo_static
Definition: sig.c:46
Contains all state information for one tunnel.
Definition: openvpn.h:500
int parse_signal(const char *signame)
Definition: sig.c:63
void process_explicit_exit_notification_timer_wakeup(struct context *c)
Definition: sig.c:348
static void get_signal(volatile int *sig)
Definition: sig.h:92
void register_signal(struct context *c, int sig, const char *text)
Definition: sig.c:460
void pre_init_signal_catch(void)
Definition: sig.c:239
void signal_restart_status(const struct signal_info *si)
Definition: sig.c:184
void throw_signal_soft(const int signum, const char *signal_text)
Definition: sig.c:111
void remap_signal(struct context *c)
Definition: sig.c:374
volatile int source
Definition: sig.h:46
void win32_signal_close(struct win32_signal *ws)
Definition: win32.c:599
volatile int signal_received
Definition: sig.h:45
const char * signal_description(const int signum, const char *sigtext)
Definition: sig.c:91
void throw_signal(const int signum)
Definition: sig.c:104
Definition: sig.c:48
void print_signal(const struct signal_info *si, const char *title, int msglevel)
Definition: sig.c:130
int win32_signal_get(struct win32_signal *ws)
Definition: win32.c:633
void print_status(const struct context *c, struct status_output *so)
Definition: sig.c:292
const char * signal_text
Definition: sig.h:47
void post_init_signal_catch(void)
Definition: sig.c:255