OpenVPN
ping.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 PING_H
25 #define PING_H
26 
27 #include "init.h"
28 #include "forward.h"
29 
30 /*
31  * Initial default --ping-restart before --pull
32  */
33 #define PRE_PULL_INITIAL_PING_RESTART 120 /* in seconds */
34 
35 extern const uint8_t ping_string[];
36 
37 /* PING_STRING_SIZE must be sizeof (ping_string) */
38 #define PING_STRING_SIZE 16
39 
40 static inline bool
41 is_ping_msg(const struct buffer *buf)
42 {
44 }
45 
51 void trigger_ping_timeout_signal(struct context *c);
52 
53 void check_ping_send_dowork(struct context *c);
54 
55 /*
56  * Should we exit or restart due to ping (or other authenticated packet)
57  * not received in n seconds?
58  */
59 static inline void
61 {
64  &c->c2.timeval,
67  ? ETT_DEFAULT : 15))
68  {
70  }
71 }
72 
73 /*
74  * Should we ping the remote?
75  */
76 static inline void
78 {
81  &c->c2.timeval,
82  !TO_LINK_DEF(c) ? ETT_DEFAULT : 1))
83  {
85  }
86 }
87 
88 #endif /* ifndef PING_H */
ping_string
const uint8_t ping_string[]
Definition: ping.c:42
forward.h
context
Contains all state information for one tunnel.
Definition: openvpn.h:476
context::c2
struct context_2 c2
Level 2 context.
Definition: openvpn.h:517
check_ping_send_dowork
void check_ping_send_dowork(struct context *c)
Definition: ping.c:75
link_socket_actual_defined
static bool link_socket_actual_defined(const struct link_socket_actual *act)
Definition: socket.h:713
trigger_ping_timeout_signal
void trigger_ping_timeout_signal(struct context *c)
Trigger the correct signal on a –ping timeout depending if –ping-exit is set (SIGTERM) or not (SIGUSR...
Definition: ping.c:48
options::ping_send_timeout
int ping_send_timeout
Definition: options.h:335
context_1::link_socket_addr
struct link_socket_addr link_socket_addr
Local and remote addresses on the external network.
Definition: openvpn.h:157
init.h
buf_string_match
static bool buf_string_match(const struct buffer *src, const void *match, int size)
Compare src buffer contents with match.
Definition: buffer.h:852
is_ping_msg
static bool is_ping_msg(const struct buffer *buf)
Definition: ping.h:41
check_ping_send
static void check_ping_send(struct context *c)
Definition: ping.h:77
context::options
struct options options
Options loaded from command line or configuration file.
Definition: openvpn.h:478
context_2::ping_send_interval
struct event_timeout ping_send_interval
Definition: openvpn.h:286
check_ping_restart
static void check_ping_restart(struct context *c)
Definition: ping.h:60
options::ping_rec_timeout
int ping_rec_timeout
Definition: options.h:336
buffer
Wrapper structure for dynamically allocated memory.
Definition: buffer.h:60
options::ping_timer_remote
bool ping_timer_remote
Definition: options.h:337
context_2::timeval
struct timeval timeval
Time to next event of timers and similar.
Definition: openvpn.h:399
TO_LINK_DEF
#define TO_LINK_DEF(c)
Definition: forward.h:48
ETT_DEFAULT
#define ETT_DEFAULT
Definition: interval.h:224
event_timeout_trigger
bool event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et_const_retry)
This is the principal function for testing and triggering recurring timers.
Definition: interval.c:43
PING_STRING_SIZE
#define PING_STRING_SIZE
Definition: ping.h:38
context_2::ping_rec_interval
struct event_timeout ping_rec_interval
Definition: openvpn.h:287
context::c1
struct context_1 c1
Level 1 context.
Definition: openvpn.h:516