OpenVPN
ovpn_dco_win.h
Go to the documentation of this file.
1 /*
2  * ovpn-dco-win OpenVPN protocol accelerator for Windows
3  *
4  * Copyright (C) 2020-2021 OpenVPN Inc <sales@openvpn.net>
5  *
6  * Author: Lev Stipakov <lev@openvpn.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * This particular file (uapi.h) is also licensed using the MIT license (see COPYRIGHT.MIT).
22  */
23 
24 #pragma once
25 #ifndef _KERNEL_MODE
26 #include <winsock2.h>
27 #endif
28 #include <ws2def.h>
29 #include <ws2ipdef.h>
30 
31 typedef enum {
34 } OVPN_PROTO;
35 
36 typedef struct _OVPN_NEW_PEER {
37  union {
38  SOCKADDR_IN Addr4;
39  SOCKADDR_IN6 Addr6;
40  } Local;
41 
42  union {
43  SOCKADDR_IN Addr4;
44  SOCKADDR_IN6 Addr6;
45  } Remote;
46 
49 
50 typedef struct _OVPN_MP_NEW_PEER {
51  union {
52  SOCKADDR_IN Addr4;
53  SOCKADDR_IN6 Addr6;
54  } Local;
55 
56  union {
57  SOCKADDR_IN Addr4;
58  SOCKADDR_IN6 Addr6;
59  } Remote;
60 
61  IN_ADDR VpnAddr4;
62  IN6_ADDR VpnAddr6;
63 
64  int PeerId;
66 
67 typedef struct _OVPN_STATS {
70 
73 
76 
79 
82 
83  LONG64 TunBytesSent;
86 
87 typedef enum _OVPN_KEY_SLOT {
91 
92 typedef enum _OVPN_CIPHER_ALG {
97 
98 typedef struct _OVPN_KEY_DIRECTION
99 {
100  unsigned char Key[32];
101  unsigned char KeyLen; // 16/24/32 -> AES-128-GCM/AES-192-GCM/AES-256-GCM
102  unsigned char NonceTail[8];
104 
105 typedef struct _OVPN_CRYPTO_DATA {
110  unsigned char KeyId;
111  int PeerId;
113 
114 typedef struct _OVPN_MP_SET_PEER {
115  int PeerId;
118  LONG MSS;
120 
121 typedef struct _OVPN_SET_PEER {
124  LONG MSS;
126 
127 typedef struct _OVPN_VERSION {
128  LONG Major;
129  LONG Minor;
130  LONG Patch;
132 
133 typedef enum {
136 } OVPN_MODE;
137 
138 typedef struct _OVPN_SET_MODE {
141 
142 typedef struct _OVPN_MP_START_VPN {
143  union {
144  SOCKADDR_IN Addr4;
145  SOCKADDR_IN6 Addr6;
146  } ListenAddress;
147  int IPv6Only;
149 
150 typedef enum {
154 
155 typedef enum {
162 
163 typedef struct _OVPN_NOTIFY_EVENT {
165  int PeerId;
168 
169 typedef struct _OVPN_MP_DEL_PEER {
170  int PeerId;
172 
173 typedef struct _OVPN_MP_SWAP_KEYS {
174  int PeerId;
176 
177 typedef struct _OVPN_MP_IROUTE {
178  union {
179  IN_ADDR Addr4;
180  IN6_ADDR Addr6;
181  } Addr;
182  int Netbits;
183  int PeerId;
184  int IPv6;
186 
187 #define OVPN_IOCTL_NEW_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
188 #define OVPN_IOCTL_GET_STATS CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
189 #define OVPN_IOCTL_NEW_KEY CTL_CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
190 #define OVPN_IOCTL_SWAP_KEYS CTL_CODE(FILE_DEVICE_UNKNOWN, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
191 #define OVPN_IOCTL_SET_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
192 #define OVPN_IOCTL_START_VPN CTL_CODE(FILE_DEVICE_UNKNOWN, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
193 #define OVPN_IOCTL_DEL_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
194 #define OVPN_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
195 #define OVPN_IOCTL_NEW_KEY_V2 CTL_CODE(FILE_DEVICE_UNKNOWN, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
196 #define OVPN_IOCTL_SET_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
197 
198 #define OVPN_IOCTL_MP_START_VPN CTL_CODE(FILE_DEVICE_UNKNOWN, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
199 #define OVPN_IOCTL_MP_NEW_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
200 #define OVPN_IOCTL_MP_SET_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
201 
202 #define OVPN_IOCTL_NOTIFY_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
203 
204 #define OVPN_IOCTL_MP_DEL_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
205 #define OVPN_IOCTL_MP_SWAP_KEYS CTL_CODE(FILE_DEVICE_UNKNOWN, 16, METHOD_BUFFERED, FILE_ANY_ACCESS)
206 
207 #define OVPN_IOCTL_MP_ADD_IROUTE CTL_CODE(FILE_DEVICE_UNKNOWN, 17, METHOD_BUFFERED, FILE_ANY_ACCESS)
208 #define OVPN_IOCTL_MP_DEL_IROUTE CTL_CODE(FILE_DEVICE_UNKNOWN, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
OVPN_MP_NEW_PEER
struct _OVPN_MP_NEW_PEER OVPN_MP_NEW_PEER
_OVPN_NEW_PEER::Proto
OVPN_PROTO Proto
Definition: ovpn_dco_win.h:47
_OVPN_MP_SET_PEER::KeepaliveInterval
LONG KeepaliveInterval
Definition: ovpn_dco_win.h:116
_OVPN_MP_IROUTE::Addr6
IN6_ADDR Addr6
Definition: ovpn_dco_win.h:180
_OVPN_STATS::ReceivedDataPackets
LONG ReceivedDataPackets
Definition: ovpn_dco_win.h:74
OVPN_MP_SET_PEER
struct _OVPN_MP_SET_PEER OVPN_MP_SET_PEER
POVPN_MP_IROUTE
struct _OVPN_MP_IROUTE * POVPN_MP_IROUTE
POVPN_MP_START_VPN
struct _OVPN_MP_START_VPN * POVPN_MP_START_VPN
OVPN_CMD_DEL_PEER
@ OVPN_CMD_DEL_PEER
Definition: ovpn_dco_win.h:151
_OVPN_STATS
Definition: ovpn_dco_win.h:67
_OVPN_MP_START_VPN::Addr6
SOCKADDR_IN6 Addr6
Definition: ovpn_dco_win.h:145
OVPN_DEL_PEER_REASON_EXPIRED
@ OVPN_DEL_PEER_REASON_EXPIRED
Definition: ovpn_dco_win.h:158
_OVPN_MP_NEW_PEER::Addr4
SOCKADDR_IN Addr4
Definition: ovpn_dco_win.h:52
_OVPN_VERSION::Minor
LONG Minor
Definition: ovpn_dco_win.h:129
_OVPN_STATS::LostInDataPackets
LONG LostInDataPackets
Definition: ovpn_dco_win.h:71
_OVPN_MP_SET_PEER::MSS
LONG MSS
Definition: ovpn_dco_win.h:118
_OVPN_SET_PEER::MSS
LONG MSS
Definition: ovpn_dco_win.h:124
OVPN_DEL_PEER_REASON
OVPN_DEL_PEER_REASON
Definition: ovpn_dco_win.h:155
_OVPN_SET_MODE::Mode
OVPN_MODE Mode
Definition: ovpn_dco_win.h:139
_OVPN_STATS::TunBytesReceived
LONG64 TunBytesReceived
Definition: ovpn_dco_win.h:84
_OVPN_STATS::TransportBytesReceived
LONG64 TransportBytesReceived
Definition: ovpn_dco_win.h:81
_OVPN_MP_START_VPN::Addr4
SOCKADDR_IN Addr4
Definition: ovpn_dco_win.h:144
_OVPN_STATS::ReceivedControlPackets
LONG ReceivedControlPackets
Definition: ovpn_dco_win.h:75
_OVPN_NEW_PEER::Remote
union _OVPN_NEW_PEER::@11 Remote
OVPN_DEL_PEER_REASON_TRANSPORT_ERROR
@ OVPN_DEL_PEER_REASON_TRANSPORT_ERROR
Definition: ovpn_dco_win.h:159
OVPN_VERSION
struct _OVPN_VERSION OVPN_VERSION
OVPN_DEL_PEER_REASON_USERSPACE
@ OVPN_DEL_PEER_REASON_USERSPACE
Definition: ovpn_dco_win.h:157
_OVPN_SET_PEER
Definition: ovpn_dco_win.h:121
OVPN_PROTO_UDP
@ OVPN_PROTO_UDP
Definition: ovpn_dco_win.h:32
OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT
@ OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT
Definition: ovpn_dco_win.h:160
_OVPN_MP_DEL_PEER::PeerId
int PeerId
Definition: ovpn_dco_win.h:170
_OVPN_KEY_SLOT
_OVPN_KEY_SLOT
Definition: ovpn_dco_win.h:87
POVPN_MP_SET_PEER
struct _OVPN_MP_SET_PEER * POVPN_MP_SET_PEER
_OVPN_STATS::LostOutDataPackets
LONG LostOutDataPackets
Definition: ovpn_dco_win.h:72
OVPN_PROTO
OVPN_PROTO
Definition: ovpn_dco_win.h:31
_OVPN_STATS::TransportBytesSent
LONG64 TransportBytesSent
Definition: ovpn_dco_win.h:80
POVPN_MP_NEW_PEER
struct _OVPN_MP_NEW_PEER * POVPN_MP_NEW_PEER
OVPN_CIPHER_ALG_CHACHA20_POLY1305
@ OVPN_CIPHER_ALG_CHACHA20_POLY1305
Definition: ovpn_dco_win.h:95
_OVPN_MP_IROUTE::Netbits
int Netbits
Definition: ovpn_dco_win.h:182
OVPN_MP_IROUTE
struct _OVPN_MP_IROUTE OVPN_MP_IROUTE
_OVPN_NOTIFY_EVENT::DelPeerReason
OVPN_DEL_PEER_REASON DelPeerReason
Definition: ovpn_dco_win.h:166
_OVPN_CRYPTO_DATA::PeerId
int PeerId
Definition: ovpn_dco_win.h:111
OVPN_CIPHER_ALG
enum _OVPN_CIPHER_ALG OVPN_CIPHER_ALG
_OVPN_NOTIFY_EVENT
Definition: ovpn_dco_win.h:163
OVPN_STATS
struct _OVPN_STATS OVPN_STATS
OVPN_MP_START_VPN
struct _OVPN_MP_START_VPN OVPN_MP_START_VPN
_OVPN_SET_PEER::KeepaliveTimeout
LONG KeepaliveTimeout
Definition: ovpn_dco_win.h:123
_OVPN_CRYPTO_DATA::KeyId
unsigned char KeyId
Definition: ovpn_dco_win.h:110
POVPN_MP_DEL_PEER
struct _OVPN_MP_DEL_PEER * POVPN_MP_DEL_PEER
_OVPN_MP_NEW_PEER::Remote
union _OVPN_MP_NEW_PEER::@13 Remote
_OVPN_MP_NEW_PEER::VpnAddr6
IN6_ADDR VpnAddr6
Definition: ovpn_dco_win.h:62
_OVPN_MP_NEW_PEER
Definition: ovpn_dco_win.h:50
_OVPN_STATS::TunBytesSent
LONG64 TunBytesSent
Definition: ovpn_dco_win.h:83
POVPN_SET_PEER
struct _OVPN_SET_PEER * POVPN_SET_PEER
_OVPN_NEW_PEER
Definition: ovpn_dco_win.h:36
_OVPN_MP_NEW_PEER::Local
union _OVPN_MP_NEW_PEER::@12 Local
POVPN_VERSION
struct _OVPN_VERSION * POVPN_VERSION
_OVPN_STATS::SentDataPackets
LONG SentDataPackets
Definition: ovpn_dco_win.h:78
OVPN_KEY_SLOT_SECONDARY
@ OVPN_KEY_SLOT_SECONDARY
Definition: ovpn_dco_win.h:89
_OVPN_KEY_DIRECTION
Definition: ovpn_dco_win.h:98
OVPN_CRYPTO_DATA
struct _OVPN_CRYPTO_DATA OVPN_CRYPTO_DATA
OVPN_NOTIFY_EVENT
struct _OVPN_NOTIFY_EVENT OVPN_NOTIFY_EVENT
_OVPN_MP_SWAP_KEYS::PeerId
int PeerId
Definition: ovpn_dco_win.h:174
_OVPN_MP_NEW_PEER::VpnAddr4
IN_ADDR VpnAddr4
Definition: ovpn_dco_win.h:61
_OVPN_NEW_PEER::Addr4
SOCKADDR_IN Addr4
Definition: ovpn_dco_win.h:38
OVPN_SET_PEER
struct _OVPN_SET_PEER OVPN_SET_PEER
POVPN_MP_SWAP_KEYS
struct _OVPN_MP_SWAP_KEYS * POVPN_MP_SWAP_KEYS
_OVPN_CRYPTO_DATA::KeySlot
OVPN_KEY_SLOT KeySlot
Definition: ovpn_dco_win.h:108
_OVPN_VERSION
Definition: ovpn_dco_win.h:127
_OVPN_CIPHER_ALG
_OVPN_CIPHER_ALG
Definition: ovpn_dco_win.h:92
OVPN_CMD_SWAP_KEYS
@ OVPN_CMD_SWAP_KEYS
Definition: ovpn_dco_win.h:152
_OVPN_NOTIFY_EVENT::Cmd
OVPN_NOTIFY_CMD Cmd
Definition: ovpn_dco_win.h:164
_OVPN_MP_SET_PEER
Definition: ovpn_dco_win.h:114
OVPN_KEY_SLOT
enum _OVPN_KEY_SLOT OVPN_KEY_SLOT
_OVPN_CRYPTO_DATA
Definition: ovpn_dco_win.h:105
_OVPN_MP_START_VPN::IPv6Only
int IPv6Only
Definition: ovpn_dco_win.h:147
OVPN_KEY_DIRECTION
struct _OVPN_KEY_DIRECTION OVPN_KEY_DIRECTION
OVPN_SET_MODE
struct _OVPN_SET_MODE OVPN_SET_MODE
_OVPN_SET_PEER::KeepaliveInterval
LONG KeepaliveInterval
Definition: ovpn_dco_win.h:122
_OVPN_CRYPTO_DATA::Decrypt
OVPN_KEY_DIRECTION Decrypt
Definition: ovpn_dco_win.h:107
_OVPN_MP_IROUTE::Addr4
IN_ADDR Addr4
Definition: ovpn_dco_win.h:179
POVPN_CRYPTO_DATA
struct _OVPN_CRYPTO_DATA * POVPN_CRYPTO_DATA
_OVPN_STATS::LostOutControlPackets
LONG LostOutControlPackets
Definition: ovpn_dco_win.h:69
_OVPN_CRYPTO_DATA::Encrypt
OVPN_KEY_DIRECTION Encrypt
Definition: ovpn_dco_win.h:106
_OVPN_KEY_DIRECTION::NonceTail
unsigned char NonceTail[8]
Definition: ovpn_dco_win.h:102
_OVPN_VERSION::Major
LONG Major
Definition: ovpn_dco_win.h:128
_OVPN_MP_IROUTE::IPv6
int IPv6
Definition: ovpn_dco_win.h:184
OVPN_MODE_MP
@ OVPN_MODE_MP
Definition: ovpn_dco_win.h:135
POVPN_NEW_PEER
struct _OVPN_NEW_PEER * POVPN_NEW_PEER
_OVPN_MP_IROUTE
Definition: ovpn_dco_win.h:177
OVPN_MP_DEL_PEER
struct _OVPN_MP_DEL_PEER OVPN_MP_DEL_PEER
OVPN_PROTO_TCP
@ OVPN_PROTO_TCP
Definition: ovpn_dco_win.h:33
OVPN_CIPHER_ALG_NONE
@ OVPN_CIPHER_ALG_NONE
Definition: ovpn_dco_win.h:93
_OVPN_MP_NEW_PEER::PeerId
int PeerId
Definition: ovpn_dco_win.h:64
_OVPN_KEY_DIRECTION::KeyLen
unsigned char KeyLen
Definition: ovpn_dco_win.h:101
_OVPN_KEY_DIRECTION::Key
unsigned char Key[32]
Definition: ovpn_dco_win.h:100
_OVPN_MP_SET_PEER::KeepaliveTimeout
LONG KeepaliveTimeout
Definition: ovpn_dco_win.h:117
OVPN_NOTIFY_CMD
OVPN_NOTIFY_CMD
Definition: ovpn_dco_win.h:150
OVPN_DEL_PEER_REASON_TEARDOWN
@ OVPN_DEL_PEER_REASON_TEARDOWN
Definition: ovpn_dco_win.h:156
_OVPN_SET_MODE
Definition: ovpn_dco_win.h:138
_OVPN_STATS::SentControlPackets
LONG SentControlPackets
Definition: ovpn_dco_win.h:77
OVPN_CIPHER_ALG_AES_GCM
@ OVPN_CIPHER_ALG_AES_GCM
Definition: ovpn_dco_win.h:94
_OVPN_MP_NEW_PEER::Addr6
SOCKADDR_IN6 Addr6
Definition: ovpn_dco_win.h:53
OVPN_KEY_SLOT_PRIMARY
@ OVPN_KEY_SLOT_PRIMARY
Definition: ovpn_dco_win.h:88
OVPN_MP_SWAP_KEYS
struct _OVPN_MP_SWAP_KEYS OVPN_MP_SWAP_KEYS
_OVPN_NEW_PEER::Addr6
SOCKADDR_IN6 Addr6
Definition: ovpn_dco_win.h:39
POVPN_NOTIFY_EVENT
struct _OVPN_NOTIFY_EVENT * POVPN_NOTIFY_EVENT
_OVPN_VERSION::Patch
LONG Patch
Definition: ovpn_dco_win.h:130
_OVPN_NEW_PEER::Local
union _OVPN_NEW_PEER::@10 Local
POVPN_SET_MODE
struct _OVPN_SET_MODE * POVPN_SET_MODE
_OVPN_CRYPTO_DATA::CipherAlg
OVPN_CIPHER_ALG CipherAlg
Definition: ovpn_dco_win.h:109
_OVPN_MP_IROUTE::PeerId
int PeerId
Definition: ovpn_dco_win.h:183
_OVPN_MP_SET_PEER::PeerId
int PeerId
Definition: ovpn_dco_win.h:115
_OVPN_MP_DEL_PEER
Definition: ovpn_dco_win.h:169
_OVPN_STATS::LostInControlPackets
LONG LostInControlPackets
Definition: ovpn_dco_win.h:68
_OVPN_MP_SWAP_KEYS
Definition: ovpn_dco_win.h:173
_OVPN_MP_START_VPN::ListenAddress
union _OVPN_MP_START_VPN::@14 ListenAddress
POVPN_STATS
struct _OVPN_STATS * POVPN_STATS
OVPN_NEW_PEER
struct _OVPN_NEW_PEER OVPN_NEW_PEER
_OVPN_NOTIFY_EVENT::PeerId
int PeerId
Definition: ovpn_dco_win.h:165
OVPN_MODE_P2P
@ OVPN_MODE_P2P
Definition: ovpn_dco_win.h:134
_OVPN_MP_IROUTE::Addr
union _OVPN_MP_IROUTE::@15 Addr
_OVPN_MP_START_VPN
Definition: ovpn_dco_win.h:142
OVPN_MODE
OVPN_MODE
Definition: ovpn_dco_win.h:133