OpenVPN 3 Core Library
Loading...
Searching...
No Matches
oob_probe.hpp File Reference
#include <cstdint>
#include <cstring>
#include <optional>
#include <openvpn/buffer/buffer.hpp>
#include <openvpn/buffer/bufbe.hpp>
#include <openvpn/ssl/psid.hpp>
Include dependency graph for oob_probe.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openvpn::oob::TlvHeader
 A decoded TLV header. More...
 
struct  openvpn::oob::ProbeParameter
 probe parameter TLV (sent by the client in a SERVER_PROBE). More...
 
struct  openvpn::oob::ProbeReply
 probe reply TLV (sent by the server in a PROBE_REPLY). More...
 

Namespaces

namespace  openvpn
 
namespace  openvpn::oob
 

Enumerations

enum  : std::uint16_t { openvpn::oob::MSG_SERVER_PROBE = 0x100 , openvpn::oob::MSG_PROBE_REPLY = 0x101 }
 OOB message types: the 16-bit value at the start of an OOB payload. More...
 
enum  : std::uint16_t { openvpn::oob::TLV_OPTIONAL_FLAG = 0x8000 , openvpn::oob::TLV_TYPE_MASK = 0x7fff , openvpn::oob::TLV_PROBE_PARAMETER = 0x200 , openvpn::oob::TLV_PROBE_REPLY = 0x201 }
 TLV header bit layout of the first 16-bit field, and the TLV type space (0x2xx). More...
 
enum  : std::uint32_t { openvpn::oob::REPLY_FLAG_RESEND_WKC = 0x1 }
 

Functions

bool openvpn::oob::msg_write_header (Buffer &buf, std::uint16_t msg_type)
 Write an OOB message-type header (the 16-bit type preceding the TLVs).
 
bool openvpn::oob::msg_read_header (Buffer &buf, std::uint16_t expected_msg_type)
 
bool openvpn::oob::tlv_write_header (Buffer &buf, std::uint16_t type, bool optional, std::uint16_t value_len)
 Write a TLV header (type + optional flag + value length) to buf.
 
std::optional< TlvHeaderopenvpn::oob::tlv_read_header (Buffer &buf)
 
bool openvpn::oob::skip_trailing (Buffer &buf, std::uint16_t value_len, std::size_t consumed)
 
std::optional< std::uint16_t > openvpn::oob::find_tlv (Buffer &buf, std::uint16_t wanted_type)
 
bool openvpn::oob::server_probe_write (Buffer &buf, const ProbeParameter &param)
 Write a complete SERVER_PROBE (message header + probe_parameter TLV). Client.
 
std::optional< ProbeParameteropenvpn::oob::server_probe_read (Buffer &buf)
 
bool openvpn::oob::client_reply_write (Buffer &buf, const ProbeReply &reply)
 Write a complete PROBE_REPLY (message header + probe_reply TLV). Server.
 
std::optional< ProbeReplyopenvpn::oob::client_reply_read (Buffer &buf)
 

Detailed Description

Encoding/decoding of out-of-band (CONTROL_OOB_V1) control messages, used for server latency probing and best-server selection.

An OOB message payload starts with a 16-bit message type (the 0x1xx space: SERVER_PROBE, PROBE_REPLY, ...) followed by a sequence of TLV entries. Each TLV starts with a 4-byte header: a 16-bit field whose most significant bit is the "optional" flag and whose remaining 15 bits are the type (the 0x2xx space), followed by a 16-bit length. Unknown/trailing bytes are ignored on read, so the format is forward-compatible.

All multi-byte integers are big-endian (network byte order), matching the community C implementation (buf_write_u16 = htons, etc.) for on-the-wire interop. Read paths parse unsolicited datagrams from the network, where malformed input is the expected case rather than the exception, so they are bounds-checked and return std::nullopt / false instead of throwing.

Definition in file oob_probe.hpp.