-
Notifications
You must be signed in to change notification settings - Fork 22
/
socket.h
77 lines (63 loc) · 2.17 KB
/
socket.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
/*
* 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 <wsk.h>
#include <wdf.h>
#include "bufferpool.h"
struct OvpnSocketTcpState
{
// filled with 2-bytes length which prepends OpenVPN TCP packet
UCHAR LenBuf[2];
USHORT PacketLength;
// how many bytes already read for header or buffer
USHORT BytesRead;
// packet buffer if packet is scattered across MDLs
UCHAR PacketBuf[OVPN_SOCKET_RX_PACKET_BUFFER_SIZE];
};
struct OvpnSocketUdpState
{
// packet buffer if datagram scattered across MDLs
// this seems to only happen in unlikely case when datagram is fragmented
UCHAR PacketBuf[OVPN_SOCKET_RX_PACKET_BUFFER_SIZE];
};
struct OvpnSocket
{
BOOLEAN Tcp;
PWSK_SOCKET Socket;
OvpnSocketTcpState TcpState;
OvpnSocketUdpState UdpState;
};
_Must_inspect_result_
_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
OvpnSocketInit(_In_ WSK_PROVIDER_NPI* wskProviderNpi, _In_ WSK_REGISTRATION* wskRegistration, ADDRESS_FAMILY addrFamily,
BOOLEAN tcp, _In_ PSOCKADDR localAddr, _In_ PSOCKADDR remoteAddr, SIZE_T remoteAddrSize,
_In_ PVOID deviceContext, _Out_ PWSK_SOCKET* socket);
_Must_inspect_result_
_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
OvpnSocketClose(_In_ PWSK_SOCKET socket);
_Must_inspect_result_
NTSTATUS
OvpnSocketSend(_In_ OvpnSocket* ovpnSocket, _In_ OVPN_TX_BUFFER* buffer);
_Must_inspect_result_
NTSTATUS
OvpnSocketTcpConnect(_In_ PWSK_SOCKET socket, _In_ PVOID context, _In_ PSOCKADDR remote);