llarp::net

Namespaces

Name
llarp::net::detail

Classes

Name
struct llarp::net::InterfaceInfo
info about a network interface lokinet does not own
struct llarp::net::ip_header_be
struct llarp::net::ip_header_le
struct llarp::net::IPPacket
an Packet
struct llarp::net::IPRangeMap
a container that maps an ip range to a value that allows you to lookup key by range hit
struct llarp::net::ipv6_header
struct llarp::net::ipv6_header_preamble_be
struct llarp::net::ipv6_header_preamble_le
class llarp::net::Platform
network platform (all methods virtual so it can be mocked by unit tests)
struct llarp::net::ProtocolInfo
information about an IP protocol
struct llarp::net::TrafficPolicy
information about what traffic an endpoint will carry

Types

Name
enum class uint8_t IPProtocol { ICMP = 0x01, IGMP = 0x02, IPIP = 0x04, TCP = 0x06, UDP = 0x11, GRE = 0x2F, ICMP6 = 0x3A, OSFP = 0x59, PGM = 0x71}
"well known" ip protocols TODO: extend this to non "well known values"
using std::conditional_t< oxenc::little_endian, ip_header_le, ip_header_be > ip_header
using std::conditional_t< oxenc::little_endian, ipv6_header_preamble_le, ipv6_header_preamble_be > ipv6_header_preamble
using n_uint16_t port_t
using n_uint32_t ipv4addr_t
using n_uint32_t flowlabel_t
using n_uint128_t ipv6addr_t
using std::variant< ipv4addr_t, ipv6addr_t > ipaddr_t

Functions

Name
huint128_t In6ToHUInt(in6_addr addr)
in6_addr HUIntToIn6(huint128_t x)
ipv6addr_t ExpandV4(ipv4addr_t x)
ipv6addr_t ExpandV4Lan(ipv4addr_t x)
ipv4addr_t TruncateV6(ipv6addr_t x)
std::string IPProtocolName(IPProtocol proto)
get string representation of this protocol throws std::invalid_argument if we don't know the name of this ip protocol
IPProtocol ParseIPProtocol(std::string data)
parse a string to an ip protocol throws std::invalid_argument if cannot be parsed
uint16_t ipchksum(const byte_t * buf, size_t sz, uint32_t sum =0)
generate ip checksum
ipv6addr_t ipaddr_netmask_bits(uint32_t bits, int af)
ipv6addr_t netmask_ipv6_bits(uint32_t bits)
ipv4addr_t ipaddr_ipv4_bits(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
std::string LoopbackInterfaceName()
get the name of the loopback interface
std::string ToString(const ipaddr_t & ip)
huint16_t ToHost(port_t )
huint32_t ToHost(ipv4addr_t )
huint128_t ToHost(ipv6addr_t )
port_t ToNet(huint16_t )
ipv4addr_t ToNet(huint32_t )
ipv6addr_t ToNet(huint128_t )

Attributes

Name
constexpr std::array< uint8_t, 12 > ipv4_map_prefix

Types Documentation

enum IPProtocol

Enumerator Value Description
ICMP 0x01
IGMP 0x02
IPIP 0x04
TCP 0x06
UDP 0x11
GRE 0x2F
ICMP6 0x3A
OSFP 0x59
PGM 0x71

"well known" ip protocols TODO: extend this to non "well known values"

using ip_header

using llarp::net::ip_header = typedef std::conditional_t<oxenc::little_endian, ip_header_le, ip_header_be>;

using ipv6_header_preamble

using llarp::net::ipv6_header_preamble = typedef std::conditional_t<oxenc::little_endian, ipv6_header_preamble_le, ipv6_header_preamble_be>;

using port_t

using llarp::net::port_t = typedef n_uint16_t;

using ipv4addr_t

using llarp::net::ipv4addr_t = typedef n_uint32_t;

using flowlabel_t

using llarp::net::flowlabel_t = typedef n_uint32_t;

using ipv6addr_t

using llarp::net::ipv6addr_t = typedef n_uint128_t;

using ipaddr_t

using llarp::net::ipaddr_t = typedef std::variant<ipv4addr_t, ipv6addr_t>;

Functions Documentation

function In6ToHUInt

huint128_t In6ToHUInt(
    in6_addr addr
)

function HUIntToIn6

in6_addr HUIntToIn6(
    huint128_t x
)

function ExpandV4

inline ipv6addr_t ExpandV4(
    ipv4addr_t x
)

function ExpandV4Lan

inline ipv6addr_t ExpandV4Lan(
    ipv4addr_t x
)

function TruncateV6

inline ipv4addr_t TruncateV6(
    ipv6addr_t x
)

function IPProtocolName

std::string IPProtocolName(
    IPProtocol proto
)

get string representation of this protocol throws std::invalid_argument if we don't know the name of this ip protocol

function ParseIPProtocol

IPProtocol ParseIPProtocol(
    std::string data
)

parse a string to an ip protocol throws std::invalid_argument if cannot be parsed

function ipchksum

uint16_t ipchksum(
    const byte_t * buf,
    size_t sz,
    uint32_t sum =0
)

generate ip checksum

function ipaddr_netmask_bits

inline ipv6addr_t ipaddr_netmask_bits(
    uint32_t bits,
    int af
)

function netmask_ipv6_bits

inline ipv6addr_t netmask_ipv6_bits(
    uint32_t bits
)

function ipaddr_ipv4_bits

inline ipv4addr_t ipaddr_ipv4_bits(
    uint32_t a,
    uint32_t b,
    uint32_t c,
    uint32_t d
)

function LoopbackInterfaceName

std::string LoopbackInterfaceName()

get the name of the loopback interface

function ToString

std::string ToString(
    const ipaddr_t & ip
)

function ToHost

huint16_t ToHost(
    port_t 
)

function ToHost

huint32_t ToHost(
    ipv4addr_t 
)

function ToHost

huint128_t ToHost(
    ipv6addr_t 
)

function ToNet

port_t ToNet(
    huint16_t 
)

function ToNet

ipv4addr_t ToNet(
    huint32_t 
)

function ToNet

ipv6addr_t ToNet(
    huint128_t 
)

Attributes Documentation

variable ipv4_map_prefix

constexpr std::array< uint8_t, 12 > ipv4_map_prefix {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff};

Updated on 2026-01-10 at 22:49:45 +0000