-
Notifications
You must be signed in to change notification settings - Fork 23
/
Driver.h
113 lines (87 loc) · 3.04 KB
/
Driver.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* ovpn-dco-win OpenVPN protocol accelerator for Windows
*
* Copyright (C) 2020-2021 OpenVPN Inc <[email protected]>
*
* Author: Lev Stipakov <[email protected]>
*
* This program 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.
*
* This program 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.
*/
#pragma once
#include <ntddk.h>
#include <wdf.h>
#include <netadaptercx.h>
#include <initguid.h>
#include <Ndisguid.h>
#include <wsk.h>
#include "adapter.h"
#include "bufferpool.h"
#include "crypto.h"
#include "socket.h"
#include "uapi\ovpn-dco.h"
extern "C" {
DRIVER_INITIALIZE DriverEntry;
}
EVT_WDF_DRIVER_DEVICE_ADD OvpnEvtDeviceAdd;
EVT_WDF_IO_QUEUE_IO_READ OvpnEvtIoRead;
EVT_WDF_IO_QUEUE_IO_WRITE OvpnEvtIoWrite;
EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL OvpnEvtIoDeviceControl;
typedef struct _OVPN_DRIVER {
WSK_PROVIDER_NPI WskProviderNpi;
WSK_REGISTRATION WskRegistration;
WDFDEVICE ControlDevice;
LONG DeviceCount;
} OVPN_DRIVER, * POVPN_DRIVER;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(OVPN_DRIVER, OvpnGetDriverContext)
struct OVPN_DEVICE {
EX_SPIN_LOCK SpinLock;
// WDF handle associated with this context
WDFDEVICE WdfDevice;
WDFQUEUE PendingReadsQueue;
WDFQUEUE PendingWritesQueue;
// NEW_PEER request may be enqueued here if TCP connect doesn't finish immediatelly
WDFQUEUE PendingNewPeerQueue;
// buffer queue for received decrypted data channel packets
OVPN_BUFFER_QUEUE DataRxBufferQueue;
// buffer queue for received control channel packets
OVPN_BUFFER_QUEUE ControlRxBufferQueue;
// pool for OVPN_RX_BUFFER entries
OVPN_RX_BUFFER_POOL RxBufferPool;
// buffer pool for encrypted data channel and control channel packets to be sent
OVPN_TX_BUFFER_POOL TxBufferPool;
OVPN_STATS Stats;
// keepalive interval in seconds
_Guarded_by_(SpinLock)
LONG KeepaliveInterval;
// keepalive timeout in seconds
_Guarded_by_(SpinLock)
LONG KeepaliveTimeout;
// 1-sec timer which handles ping intervals and keepalive timeouts
_Guarded_by_(SpinLock)
WDFTIMER Timer;
// set from the userspace, defines TCP Maximum Segment Size
_Guarded_by_(SpinLock)
UINT16 MSS;
_Guarded_by_(SpinLock)
OvpnCryptoContext CryptoContext;
_Guarded_by_(SpinLock)
OvpnSocket Socket;
_Guarded_by_(SpinLock)
NETADAPTER Adapter;
// pid of userspace process which called NEW_PEER
_Interlocked_
LONG UserspacePid;
};
typedef OVPN_DEVICE * POVPN_DEVICE;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(OVPN_DEVICE, OvpnGetDeviceContext)