llarp::IPRange

Public Types

Name
using net::ipv6addr_t Addr_t

Public Functions

Name
constexpr IPRange() =default
constexpr IPRange(Addr_t address, Addr_t netmask)
IPRange(std::string _range)
bool IsV4() const
return true if this iprange is in the IPv4 mapping range for containing ipv4 addresses
int Family() const
get address family
int HostmaskBits() const
return the number of bits set in the hostmask
bool operator*(const IPRange & other) const
return true if our range and other intersect
bool Contains(const IPRange & other) const
return true if the other range is inside our range
constexpr bool Contains(const Addr_t & ip) const
return true if ip is contained in this ip range
bool Contains(const net::ipv4addr_t & ip) const
return true if we are a ipv4 range and contains this ip
net::ipaddr_t BaseAddr() const
bool Contains(const net::ipaddr_t & ip) const
Addr_t HighestAddr() const
get the highest address on this range
bool operator<(const IPRange & other) const
bool operator==(const IPRange & other) const
std::string ToString() const
std::string BaseAddressString() const
std::string NetmaskString() const
bool FromString(std::string str)
bool BEncode(llarp_buffer_t * buf) const
bool BDecode(llarp_buffer_t * buf)
IPRange V4MappedRange()
IPRange FromIPv4(byte_t a, byte_t b, byte_t c, byte_t d, byte_t mask)
IPRange FromIPv4(net::ipv4addr_t addr, net::ipv4addr_t netmask)
std::optional< IPRange > FindPrivateRange(const std::set< IPRange > & excluding)
Finds a free private use range not overlapping the given ranges.

Public Attributes

Name
Addr_t addr
Addr_t netmask_bits

Public Types Documentation

using Addr_t

using llarp::IPRange::Addr_t =  net::ipv6addr_t;

Public Functions Documentation

function IPRange

constexpr IPRange() =default

function IPRange

inline constexpr IPRange(
    Addr_t address,
    Addr_t netmask
)

function IPRange

inline explicit IPRange(
    std::string _range
)

function IsV4

inline bool IsV4() const

return true if this iprange is in the IPv4 mapping range for containing ipv4 addresses

function Family

inline int Family() const

get address family

function HostmaskBits

inline int HostmaskBits() const

return the number of bits set in the hostmask

function operator*

inline bool operator*(
    const IPRange & other
) const

return true if our range and other intersect

function Contains

inline bool Contains(
    const IPRange & other
) const

return true if the other range is inside our range

function Contains

inline constexpr bool Contains(
    const Addr_t & ip
) const

return true if ip is contained in this ip range

function Contains

inline bool Contains(
    const net::ipv4addr_t & ip
) const

return true if we are a ipv4 range and contains this ip

function BaseAddr

inline net::ipaddr_t BaseAddr() const

function Contains

inline bool Contains(
    const net::ipaddr_t & ip
) const

function HighestAddr

inline Addr_t HighestAddr() const

get the highest address on this range

function operator<

inline bool operator<(
    const IPRange & other
) const

function operator==

inline bool operator==(
    const IPRange & other
) const

function ToString

inline std::string ToString() const

function BaseAddressString

std::string BaseAddressString() const

function NetmaskString

std::string NetmaskString() const

function FromString

bool FromString(
    std::string str
)

function BEncode

bool BEncode(
    llarp_buffer_t * buf
) const

function BDecode

bool BDecode(
    llarp_buffer_t * buf
)

function V4MappedRange

static inline IPRange V4MappedRange()

function FromIPv4

static inline IPRange FromIPv4(
    byte_t a,
    byte_t b,
    byte_t c,
    byte_t d,
    byte_t mask
)

function FromIPv4

static inline IPRange FromIPv4(
    net::ipv4addr_t addr,
    net::ipv4addr_t netmask
)

function FindPrivateRange

static std::optional< IPRange > FindPrivateRange(
    const std::set< IPRange > & excluding
)

Finds a free private use range not overlapping the given ranges.

Public Attributes Documentation

variable addr

Addr_t addr = {0};

variable netmask_bits

Addr_t netmask_bits = {0};

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