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-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 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 
46 void check_ping_restart_dowork(struct context *c);
47 
48 void check_ping_send_dowork(struct context *c);
49 
50 /*
51  * Should we exit or restart due to ping (or other authenticated packet)
52  * not received in n seconds?
53  */
54 static inline void
56 {
57  void check_ping_restart_dowork(struct context *c);
58 
61  &c->c2.timeval,
64  ? ETT_DEFAULT : 15))
65  {
67  }
68 }
69 
70 /*
71  * Should we ping the remote?
72  */
73 static inline void
75 {
76  void check_ping_send_dowork(struct context *c);
77 
80  &c->c2.timeval,
81  !TO_LINK_DEF(c) ? ETT_DEFAULT : 1))
82  {
84  }
85 }
86 
87 #endif
#define ETT_DEFAULT
Definition: interval.h:213
struct event_timeout ping_rec_interval
Definition: openvpn.h:297
struct options options
Options loaded from command line or configuration file.
Definition: openvpn.h:500
void check_ping_restart_dowork(struct context *c)
Definition: ping.c:54
Contains all state information for one tunnel.
Definition: openvpn.h:498
static void check_ping_restart(struct context *c)
Definition: ping.h:55
struct link_socket_addr link_socket_addr
Local and remote addresses on the external network.
Definition: openvpn.h:152
int ping_rec_timeout
Definition: options.h:260
struct event_timeout ping_send_interval
Definition: openvpn.h:296
struct context_1 c1
Level 1 context.
Definition: openvpn.h:536
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:399
#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:696
Interface functions to the internal and external multiplexers.
int ping_send_timeout
Definition: options.h:259
struct context_2 c2
Level 2 context.
Definition: openvpn.h:537
unsigned __int8 uint8_t
Definition: config-msvc.h:123
static bool buf_string_match(const struct buffer *src, const void *match, int size)
Compare src buffer contents with match.
Definition: buffer.h:845
static bool is_ping_msg(const struct buffer *buf)
Definition: ping.h:41
void check_ping_send_dowork(struct context *c)
Definition: ping.c:83
static void check_ping_send(struct context *c)
Definition: ping.h:74
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:261