forked from ambrop72/badvpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeepaliveIO.h
81 lines (74 loc) · 2.36 KB
/
KeepaliveIO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* @file KeepaliveIO.h
* @author Ambroz Bizjak <[email protected]>
*
* @section LICENSE
*
* This file is part of BadVPN.
*
* BadVPN is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* BadVPN is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @section DESCRIPTION
*
* A {@link PacketPassInterface} layer for sending keep-alive packets.
*/
#ifndef BADVPN_KEEPALIVEIO
#define BADVPN_KEEPALIVEIO
#include <misc/debug.h>
#include <base/DebugObject.h>
#include <system/BReactor.h>
#include <flow/PacketPassInterface.h>
#include <flow/PacketRecvInterface.h>
#include <flow/PacketPassPriorityQueue.h>
#include <flow/SinglePacketBuffer.h>
#include <flow/PacketRecvBlocker.h>
#include <flowextra/PacketPassInactivityMonitor.h>
/**
* A {@link PacketPassInterface} layer for sending keep-alive packets.
*/
typedef struct {
BReactor *reactor;
PacketPassInactivityMonitor kasender;
PacketPassPriorityQueue queue;
PacketPassPriorityQueueFlow user_qflow;
PacketPassPriorityQueueFlow ka_qflow;
SinglePacketBuffer ka_buffer;
PacketRecvBlocker ka_blocker;
DebugObject d_obj;
} KeepaliveIO;
/**
* Initializes the object.
*
* @param o the object
* @param reactor reactor we live in
* @param output output interface
* @param keepalive_input keepalive input interface. Its MTU must be <= MTU of output.
* @param keepalive_interval_ms keepalive interval in milliseconds. Must be >0.
* @return 1 on success, 0 on failure
*/
int KeepaliveIO_Init (KeepaliveIO *o, BReactor *reactor, PacketPassInterface *output, PacketRecvInterface *keepalive_input, btime_t keepalive_interval_ms) WARN_UNUSED;
/**
* Frees the object.
*
* @param o the object
*/
void KeepaliveIO_Free (KeepaliveIO *o);
/**
* Returns the input interface.
*
* @param o the object
* @return input interface
*/
PacketPassInterface * KeepaliveIO_GetInput (KeepaliveIO *o);
#endif