The address module contains all classes and free functions to manage network addresses. More...
Classes | |
class | UPnPsdk::CAddrinfo |
Get information from the operating system about an internet address. More... | |
class | UPnPsdk::CNetadapter |
Get information from local network adapters. More... | |
union | UPnPsdk::sockaddr_t |
Helpful union of the different socket address structures. More... | |
struct | UPnPsdk::SSockaddr |
Trivial ::sockaddr structures enhanced with methods. More... | |
Functions | |
uint8_t | UPnPsdk::netmask_to_bitmask (const ::sockaddr_storage *a_netmask) |
Get prefix bit number from a network address mask. | |
void | UPnPsdk::bitmask_to_netmask (const ::sockaddr_storage *a_saddr, const unsigned int a_prefixlength, SSockaddr &a_saddrObj) |
Get network address mask from address prefix bit number. | |
void | UPnPsdk::split_addr_port (const std::string &a_addr_str, std::string &a_addr, std::string &a_serv) |
Free function to split inet address and port(service) | |
UPnPsdk_API::std::ostream & | UPnPsdk::operator<< (::std::ostream &os, SSockaddr &saddr) |
output the netaddress | |
bool | UPnPsdk::anonymous_namespace{sockaddr.cpp}::sockaddrcmp (const ::sockaddr_storage *a_ss1, const ::sockaddr_storage *a_ss2) noexcept |
logical compare two sockaddr structures | |
int | UPnPsdk::anonymous_namespace{sockaddr.cpp}::to_port (const std::string &a_port_str, in_port_t *const a_port_num=nullptr) noexcept |
Free function to check if a string represents a valid port number. | |
The address module contains all classes and free functions to manage network addresses.
References
union UPnPsdk::sockaddr_t |
Helpful union of the different socket address structures.
Never need to use type casts with pointer to different socket address structures. For details about using this helpful union have a look at sockaddr structures as union
Definition at line 34 of file sockaddr.hpp.
Class Members | ||
---|---|---|
::sockaddr_storage | ss | |
::sockaddr_un | sun | |
::sockaddr_in6 | sin6 | |
::sockaddr_in | sin | |
::sockaddr | sa |
uint8_t UPnPsdk::netmask_to_bitmask | ( | const ::sockaddr_storage * | a_netmask | ) |
Get prefix bit number from a network address mask.
Returns the length, in bits, of the prefix or network part of the IP address, e.g. 64 from "[2001:db8::1]/64". A value of 255 is commonly used to represent an illegal value but this function throws an exception instead.
std::runtime_error |
|
[in] | a_netmask | Pointer to a socket address structure containing the netmask. |
Definition at line 14 of file netadapter.cpp.
void UPnPsdk::bitmask_to_netmask | ( | const ::sockaddr_storage * | a_saddr, |
const unsigned int | a_prefixlength, | ||
SSockaddr & | a_saddrObj | ||
) |
Get network address mask from address prefix bit number.
std::runtime_error |
|
[in] | a_saddr | Pointer to a structure containing the socket address the netmask is associated. |
[in] | a_prefixlength | IPv6 or IPv4 address prefix length as number of set bits as given e.g. with 64 in [2001:db8::1]/64. |
[out] | a_saddrObj | Reference to a socket address object that will be filled with the netmask. |
Definition at line 108 of file netadapter.cpp.
void UPnPsdk::split_addr_port | ( | const std::string & | a_addr_str, |
std::string & | a_addr, | ||
std::string & | a_serv | ||
) |
Free function to split inet address and port(service)
This is a function for special use to prepare input for system call ::getaddrinfo(). Its results returned in a_addr and a_serv are only useful for ::getaddrinfo() and are not meant for general usage. For example returned IPv6 addresses never have brackets because ::getaddrinfo() does not accept them, port numbers are limited to 65535 because ::getaddrinfo() accepts also greater numbers with overrun to 65535 + 1 = 0.
[in] | a_addr_str | Any string. If it can be interpreted as an ip-address or -name with or without port number or name, its parts will be retured. |
[in,out] | a_addr | Reference of a string that will be filled with the ip address part. This can also be a alphanumeric name like "example.com" |
[in,out] | a_serv | Reference of a string that will be filled with the port part. |
Definition at line 210 of file sockaddr.cpp.
UPnPsdk_API::std::ostream & UPnPsdk::operator<< | ( | ::std::ostream & | os, |
SSockaddr & | saddr | ||
) |
output the netaddress
|
noexcept |
logical compare two sockaddr structures
To have logical equal socket addresses I compare the address family, the ip address, the scope, and the port.
Definition at line 32 of file sockaddr.cpp.
|
noexcept |
Free function to check if a string represents a valid port number.
[in] | a_port_str | String that may represent a port number. |
[in,out] | a_port_num | Optional: if given, pointer to a variable that will be filled with the binary port number in host byte order. |
Definition at line 114 of file sockaddr.cpp.