OpenVPN
Data Structures | Macros | Functions
ring_buffer.h File Reference
#include <windows.h>
#include <winioctl.h>
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for ring_buffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tun_ring
 Wintun ring buffer See https://github.com/WireGuard/wintun#ring-layout. More...
 
struct  tun_register_rings
 Struct for ring buffers registration See https://github.com/WireGuard/wintun#registering-rings. More...
 
struct  TUN_PACKET_HEADER
 
struct  TUN_PACKET
 

Macros

#define WINTUN_RING_CAPACITY   0x800000
 
#define WINTUN_RING_TRAILING_BYTES   0x10000
 
#define WINTUN_MAX_PACKET_SIZE   0xffff
 
#define WINTUN_PACKET_ALIGN   4
 
#define TUN_IOCTL_REGISTER_RINGS   CTL_CODE(51820U, 0x970U, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
 

Functions

static 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 driver, see https://github.com/WireGuard/wintun#registering-rings. More...
 

Macro Definition Documentation

◆ TUN_IOCTL_REGISTER_RINGS

#define TUN_IOCTL_REGISTER_RINGS   CTL_CODE(51820U, 0x970U, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)

Definition at line 44 of file ring_buffer.h.

Referenced by register_ring_buffers().

◆ WINTUN_MAX_PACKET_SIZE

#define WINTUN_MAX_PACKET_SIZE   0xffff

Definition at line 41 of file ring_buffer.h.

Referenced by read_wintun().

◆ WINTUN_PACKET_ALIGN

#define WINTUN_PACKET_ALIGN   4

Definition at line 42 of file ring_buffer.h.

Referenced by wintun_ring_packet_align(), and write_wintun().

◆ WINTUN_RING_CAPACITY

#define WINTUN_RING_CAPACITY   0x800000

Definition at line 39 of file ring_buffer.h.

Referenced by read_wintun(), wintun_ring_wrap(), and write_wintun().

◆ WINTUN_RING_TRAILING_BYTES

#define WINTUN_RING_TRAILING_BYTES   0x10000

Definition at line 40 of file ring_buffer.h.

Function Documentation

◆ register_ring_buffers()

static bool register_ring_buffers ( HANDLE  device,
struct tun_ring send_ring,
struct tun_ring receive_ring,
HANDLE  send_tail_moved,
HANDLE  receive_tail_moved 
)
static

Registers ring buffers used to exchange data between userspace openvpn process and wintun kernel driver, see https://github.com/WireGuard/wintun#registering-rings.

Parameters
devicehandle to opened wintun device
send_ringpointer to send ring
receive_ringpointer to receive ring
send_tail_movedevent set by wintun to signal openvpn that data is available for reading in send ring
receive_tail_movedevent set by openvpn to signal wintun that data has been written to receive ring
Returns
true if registration is successful, false otherwise - use GetLastError()

Definition at line 98 of file ring_buffer.h.

References tun_register_rings::receive, tun_register_rings::ring, tun_register_rings::ring_size, tun_register_rings::send, tun_register_rings::tail_moved, and TUN_IOCTL_REGISTER_RINGS.

Referenced by HandleRegisterRingBuffers(), and wintun_register_ring_buffer().