llarp::SockAddr
A simple SockAddr wrapper which provides a sockaddr_in (IPv4). More...
#include <sock_addr.hpp>
Public Functions
| Name | |
|---|---|
| SockAddr() | |
| SockAddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, huint16_t port ={0}) | |
| SockAddr(nuint32_t ip, nuint16_t port ={0}) | |
| SockAddr(huint32_t ip, huint16_t port ={0}) | |
| SockAddr(huint128_t ip, huint16_t port ={0}) | |
| SockAddr(nuint128_t ip, nuint16_t port ={0}) | |
| SockAddr(std::string_view addr) | |
| SockAddr(std::string_view addr, huint16_t port) | |
| SockAddr(const AddressInfo & ) | |
| SockAddr(const SockAddr & ) | |
| SockAddr & | operator=(const SockAddr & ) |
| SockAddr(const sockaddr & addr) | |
| SockAddr & | operator=(const sockaddr & addr) |
| SockAddr(const sockaddr_in & addr) | |
| SockAddr & | operator=(const sockaddr_in & addr) |
| SockAddr(const sockaddr_in6 & addr) | |
| SockAddr & | operator=(const sockaddr_in6 & addr) |
| SockAddr(const in6_addr & addr) | |
| SockAddr & | operator=(const in6_addr & addr) |
| operator const sockaddr *() const | |
| operator const sockaddr_in *() const | |
| operator const sockaddr_in6 *() const | |
| size_t | sockaddr_len() const |
| bool | operator<(const SockAddr & other) const |
| bool | operator==(const SockAddr & other) const |
| bool | operator!=(const SockAddr & other) const |
| void | fromString(std::string_view str, bool allow_port =true) |
| std::string | ToString() const |
| std::string | hostString(bool ipv6_brackets =true) const convert ip address to string; ipv6_brackets - if true or omitted we add [...] around the IPv6 address, otherwise we return it bare. |
| int | Family() const |
| bool | isEmpty() const Returns true if this is an empty SockAddr, defined by having no IP address set. |
| void | setIPv4(uint8_t a, uint8_t b, uint8_t c, uint8_t d) |
| void | setIP(std::variant< nuint32_t, nuint128_t > ip) |
| void | setIPv4(nuint32_t ip) |
| void | setIPv4(huint32_t ip) |
| void | setIPv6(huint128_t ip) |
| void | setIPv6(nuint128_t ip) |
| void | setPort(huint16_t port) |
| void | setPort(nuint16_t port) |
| void | setPort(uint16_t port) |
| net::port_t | port() const get the port of this sockaddr in network order |
| uint16_t | getPort() const port is always returned in host order |
| bool | isIPv6() const True if this stores an IPv6 address, false if IPv4. |
| bool | isIPv4() const !isIPv6() |
| nuint128_t | getIPv6() const in network order |
| nuint32_t | getIPv4() const |
| std::variant< nuint32_t, nuint128_t > | getIP() const |
Detailed Description
struct llarp::SockAddr;
A simple SockAddr wrapper which provides a sockaddr_in (IPv4).
Memory management is handled in constructor and destructor (if needed) and copying is disabled.
Public Functions Documentation
function SockAddr
SockAddr()
function SockAddr
SockAddr(
uint8_t a,
uint8_t b,
uint8_t c,
uint8_t d,
huint16_t port ={0}
)
function SockAddr
SockAddr(
nuint32_t ip,
nuint16_t port ={0}
)
function SockAddr
SockAddr(
huint32_t ip,
huint16_t port ={0}
)
function SockAddr
SockAddr(
huint128_t ip,
huint16_t port ={0}
)
function SockAddr
SockAddr(
nuint128_t ip,
nuint16_t port ={0}
)
function SockAddr
SockAddr(
std::string_view addr
)
function SockAddr
SockAddr(
std::string_view addr,
huint16_t port
)
function SockAddr
SockAddr(
const AddressInfo &
)
function SockAddr
SockAddr(
const SockAddr &
)
function operator=
SockAddr & operator=(
const SockAddr &
)
function SockAddr
SockAddr(
const sockaddr & addr
)
function operator=
SockAddr & operator=(
const sockaddr & addr
)
function SockAddr
SockAddr(
const sockaddr_in & addr
)
function operator=
SockAddr & operator=(
const sockaddr_in & addr
)
function SockAddr
SockAddr(
const sockaddr_in6 & addr
)
function operator=
SockAddr & operator=(
const sockaddr_in6 & addr
)
function SockAddr
SockAddr(
const in6_addr & addr
)
function operator=
SockAddr & operator=(
const in6_addr & addr
)
function operator const sockaddr *
explicit operator const sockaddr *() const
function operator const sockaddr_in *
explicit operator const sockaddr_in *() const
function operator const sockaddr_in6 *
explicit operator const sockaddr_in6 *() const
function sockaddr_len
size_t sockaddr_len() const
function operator<
bool operator<(
const SockAddr & other
) const
function operator==
bool operator==(
const SockAddr & other
) const
function operator!=
inline bool operator!=(
const SockAddr & other
) const
function fromString
void fromString(
std::string_view str,
bool allow_port =true
)
function ToString
std::string ToString() const
function hostString
std::string hostString(
bool ipv6_brackets =true
) const
convert ip address to string; ipv6_brackets - if true or omitted we add [...] around the IPv6 address, otherwise we return it bare.
function Family
inline int Family() const
function isEmpty
bool isEmpty() const
Returns true if this is an empty SockAddr, defined by having no IP address set.
Return: true if this is empty, false otherwise
An empty IP address with a valid port is still considered empty.
function setIPv4
void setIPv4(
uint8_t a,
uint8_t b,
uint8_t c,
uint8_t d
)
function setIP
inline void setIP(
std::variant< nuint32_t, nuint128_t > ip
)
function setIPv4
void setIPv4(
nuint32_t ip
)
function setIPv4
void setIPv4(
huint32_t ip
)
function setIPv6
void setIPv6(
huint128_t ip
)
function setIPv6
void setIPv6(
nuint128_t ip
)
function setPort
void setPort(
huint16_t port
)
function setPort
void setPort(
nuint16_t port
)
function setPort
inline void setPort(
uint16_t port
)
function port
net::port_t port() const
get the port of this sockaddr in network order
function getPort
inline uint16_t getPort() const
port is always returned in host order
function isIPv6
bool isIPv6() const
True if this stores an IPv6 address, false if IPv4.
function isIPv4
bool isIPv4() const
!isIPv6()
function getIPv6
nuint128_t getIPv6() const
in network order
function getIPv4
nuint32_t getIPv4() const
function getIP
std::variant< nuint32_t, nuint128_t > getIP() const
Updated on 2026-01-10 at 22:49:45 +0000