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-2021 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 */
#define ETT_DEFAULT
Definition: interval.h:213
struct event_timeout ping_rec_interval
Definition: openvpn.h:285
struct options options
Options loaded from command line or configuration file.
Definition: openvpn.h:463
Contains all state information for one tunnel.
Definition: openvpn.h:461
static void check_ping_restart(struct context *c)
Definition: ping.h:60
struct link_socket_addr link_socket_addr
Local and remote addresses on the external network.
Definition: openvpn.h:154
int ping_rec_timeout
Definition: options.h:300
struct event_timeout ping_send_interval
Definition: openvpn.h:284
struct context_1 c1
Level 1 context.
Definition: openvpn.h:501
bool event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et_const_retry)
Definition: interval.c:45
struct timeval timeval
Definition: openvpn.h:384
#define PING_STRING_SIZE
Definition: ping.h:38
#define TO_LINK_DEF(c)
Definition: forward.h:48
static bool link_socket_actual_defined(const struct link_socket_actual *act)
Definition: socket.h:685
Interface functions to the internal and external multiplexers.
int ping_send_timeout
Definition: options.h:299
struct context_2 c2
Level 2 context.
Definition: openvpn.h:502
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 (SIGU...
Definition: ping.c:50
static bool buf_string_match(const struct buffer *src, const void *match, int size)
Compare src buffer contents with match.
Definition: buffer.h:869
static bool is_ping_msg(const struct buffer *buf)
Definition: ping.h:41
void check_ping_send_dowork(struct context *c)
Definition: ping.c:79
static void check_ping_send(struct context *c)
Definition: ping.h:77
Wrapper structure for dynamically allocated memory.
Definition: buffer.h:60
const uint8_t ping_string[]
Definition: ping.c:44
bool ping_timer_remote
Definition: options.h:301