OpenVPN
ring_buffer.c
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single 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-2019 OpenVPN Inc <sales@openvpn.net>
9  * 2019 Lev Stipakov <lev@openvpn.net>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #include "ring_buffer.h"
26 
27 #ifdef _WIN32
28 
29 bool
30 register_ring_buffers(HANDLE device,
31  struct tun_ring *send_ring,
32  struct tun_ring *receive_ring,
33  HANDLE send_tail_moved,
34  HANDLE receive_tail_moved)
35 {
36  struct tun_register_rings rr;
37  BOOL res;
38  DWORD bytes_returned;
39 
40  ZeroMemory(&rr, sizeof(rr));
41 
42  rr.send.ring = send_ring;
43  rr.send.ring_size = sizeof(struct tun_ring);
44  rr.send.tail_moved = send_tail_moved;
45 
46  rr.receive.ring = receive_ring;
47  rr.receive.ring_size = sizeof(struct tun_ring);
48  rr.receive.tail_moved = receive_tail_moved;
49 
50  res = DeviceIoControl(device, TUN_IOCTL_REGISTER_RINGS, &rr, sizeof(rr),
51  NULL, 0, &bytes_returned, NULL);
52 
53  return res != FALSE;
54 }
55 
56 #endif /* ifdef _WIN32 */
#define TUN_IOCTL_REGISTER_RINGS
Definition: ring_buffer.h:44
bool register_ring_buffers(HANDLE device, struct tun_ring *send_ring, struct tun_ring *receive_ring, HANDLE send_tail_moved, HANDLE receive_tail_moved)
Registers ring buffers used to exchange data between userspace openvpn process and wintun kernel driv...
Definition: ring_buffer.c:30
struct tun_register_rings::@9 receive
struct tun_ring * ring
Definition: ring_buffer.h:67
Wintun ring buffer See https://github.com/WireGuard/wintun#ring-layout.
Definition: ring_buffer.h:50
Struct for ring buffers registration See https://github.com/WireGuard/wintun#registering-rings.
Definition: ring_buffer.h:62
struct tun_register_rings::@9 send