OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::PacketIDData Struct Reference

#include <packet_id_data.hpp>

Inheritance diagram for openvpn::PacketIDData:
[legend]

Public Types

typedef std::uint64_t data_id_t
 

Public Member Functions

constexpr std::size_t size () const
 
 PacketIDData (bool wide_arg)
 
 PacketIDData (bool wide_arg, data_id_t id_arg)
 
bool is_valid () const
 
void reset ()
 
uint16_t get_epoch ()
 
void read (ConstBuffer &buf)
 
void write (Buffer &buf) const
 
void write_prepend (Buffer &buf) const
 
std::string str () const
 

Static Public Member Functions

static constexpr size_t size (bool wide)
 

Public Attributes

data_id_t id = 0
 
bool wide = false
 

Static Public Attributes

static constexpr data_id_t epoch_packet_id_mask = 0x0000ffffffffffffull
 
static constexpr std::size_t short_id_size = sizeof(std::uint32_t)
 
static constexpr std::size_t long_id_size = sizeof(std::uint64_t)
 

Detailed Description

Communicate packet-id over the wire for data channel packets A short packet-id is just a 32 bit sequence number. A long packet-id is a 16 bit epoch + 48 bit sequence number. This sequence number is reused for AEAD IV when AEAD is used as a cipher. CBC transmits an additional IV.

This data structure is always sent over the net in network byte order,

This class is different from PacketIDControl in the way that it always uses a "flat" packet id that is either 32 or 64 bit while PacketIDControl has a long packet id that is 32bit + 32bit but follow different rules and includes a timestamp. Merging PacketIData and PacketIDControl would result in a much more convoluted and hard to understand class than keeping them separate.

Definition at line 50 of file packet_id_data.hpp.

Member Typedef Documentation

◆ data_id_t

typedef std::uint64_t openvpn::PacketIDData::data_id_t

Definition at line 52 of file packet_id_data.hpp.

Constructor & Destructor Documentation

◆ PacketIDData() [1/2]

openvpn::PacketIDData::PacketIDData ( bool  wide_arg)
inlineexplicit

Definition at line 80 of file packet_id_data.hpp.

◆ PacketIDData() [2/2]

openvpn::PacketIDData::PacketIDData ( bool  wide_arg,
data_id_t  id_arg 
)
inlineexplicit

Definition at line 85 of file packet_id_data.hpp.

Member Function Documentation

◆ get_epoch()

uint16_t openvpn::PacketIDData::get_epoch ( )
inline

Definition at line 103 of file packet_id_data.hpp.

◆ is_valid()

bool openvpn::PacketIDData::is_valid ( ) const
inline

Definition at line 93 of file packet_id_data.hpp.

Here is the caller graph for this function:

◆ read()

void openvpn::PacketIDData::read ( ConstBuffer buf)
inline

Reads the packet id from the specified buffer.

Parameters
bufthe buffer to read the packet id from

Definition at line 112 of file packet_id_data.hpp.

Here is the caller graph for this function:

◆ reset()

void openvpn::PacketIDData::reset ( )
inline

Definition at line 98 of file packet_id_data.hpp.

◆ size() [1/2]

constexpr std::size_t openvpn::PacketIDData::size ( ) const
inlineconstexpr

Returns the size of the packet id. This is either 4 or 8 depending on the mode in use

Returns
4 or 8

Definition at line 66 of file packet_id_data.hpp.

Here is the caller graph for this function:

◆ size() [2/2]

static constexpr size_t openvpn::PacketIDData::size ( bool  wide)
inlinestaticconstexpr

Definition at line 71 of file packet_id_data.hpp.

◆ str()

std::string openvpn::PacketIDData::str ( ) const
inline

Definition at line 159 of file packet_id_data.hpp.

Here is the caller graph for this function:

◆ write()

void openvpn::PacketIDData::write ( Buffer buf) const
inline

Writes the packet id to a buffer

Definition at line 129 of file packet_id_data.hpp.

Here is the caller graph for this function:

◆ write_prepend()

void openvpn::PacketIDData::write_prepend ( Buffer buf) const
inline

Prepend the packet id to a buffer

Definition at line 144 of file packet_id_data.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ epoch_packet_id_mask

constexpr data_id_t openvpn::PacketIDData::epoch_packet_id_mask = 0x0000ffffffffffffull
inlinestaticconstexpr

Definition at line 56 of file packet_id_data.hpp.

◆ id

data_id_t openvpn::PacketIDData::id = 0

Definition at line 59 of file packet_id_data.hpp.

◆ long_id_size

constexpr std::size_t openvpn::PacketIDData::long_id_size = sizeof(std::uint64_t)
staticconstexpr

Definition at line 91 of file packet_id_data.hpp.

◆ short_id_size

constexpr std::size_t openvpn::PacketIDData::short_id_size = sizeof(std::uint32_t)
staticconstexpr

Definition at line 90 of file packet_id_data.hpp.

◆ wide

bool openvpn::PacketIDData::wide = false

Definition at line 60 of file packet_id_data.hpp.


The documentation for this struct was generated from the following file: