Trivial ::sockaddr structures enhanced with methods. More...
#include <sockaddr.hpp>
Public Member Functions | |
| SSockaddr (const SSockaddr &) | |
| Copy constructor, also needed for copy assignment operator. | |
| SSockaddr & | operator= (SSockaddr) |
| Copy assignment operator, needs user defined copy contructor. | |
| bool | is_loopback () const |
| Get if the socket address is a loopback address. | |
Setter | |
| void | operator= (std::string_view a_addr_str) |
| Set socket address from a netaddress. | |
| void | operator= (const in_port_t a_port) |
| Set port number from integer. | |
| void | operator= (const ::sockaddr_storage &a_ss) |
| Set socket address from a trivial socket address structure. | |
Getter | |
| bool | operator== (const SSockaddr &) const |
| Test if another socket address is logical equal to this. | |
| const std::string | netaddr () noexcept |
| Get the assosiated netaddress without port. | |
| const std::string | netaddrp () noexcept |
| Get the assosiated netaddress with port. | |
| in_port_t | port () const |
| Get the numeric port. | |
| socklen_t | sizeof_saddr () const |
| Get sizeof the current filled (sin6 or sin) Sockaddr Structure. | |
Public Attributes | |
| sockaddr_storage & | ss = m_sa_union.ss |
| Reference to sockaddr_storage struct. | |
| sockaddr_un & | sun = m_sa_union.sun |
| Reference to sockaddr_un struct. | |
| sockaddr_in6 & | sin6 = m_sa_union.sin6 |
| Reference to sockaddr_in6 struct. | |
| sockaddr_in & | sin = m_sa_union.sin |
| Reference to sockaddr_in struct. | |
| sockaddr & | sa = m_sa_union.sa |
| Reference to sockaddr struct. | |
Trivial ::sockaddr structures enhanced with methods.
This structure should be usable on a low level like the trival C struct ::sockaddr_storage but provides additional methods to manage its data. When ever this SDK manage a network address it uses an object of this class.
Definition at line 133 of file sockaddr.hpp.
| UPnPsdk::SSockaddr::SSockaddr | ( | ) |
Definition at line 316 of file sockaddr.cpp.
|
virtual |
Definition at line 321 of file sockaddr.cpp.
| UPnPsdk::SSockaddr::SSockaddr | ( | const SSockaddr & | that | ) |
Copy constructor, also needed for copy assignment operator.
Definition at line 335 of file sockaddr.cpp.
Copy assignment operator, needs user defined copy contructor.
Definition at line 342 of file sockaddr.cpp.
| void UPnPsdk::SSockaddr::operator= | ( | std::string_view | a_addr_str | ) |
Set socket address from a netaddress.
Assign rules are:
a netaddress consists of two parts, ip address and port. A netaddress has always a port. A cleared socket address is empty. On an empty socket address
SSockaddr::netaddr() returns "" (empty string)
SSockaddr::netaddrp() returns ":0"
Valid special cases are these well defined unspecified addresses:
"" results to ":0" ":0" results to ":0" "65535" results to ":65535" "::" results to "[::]:0" "[::]" results to "[::]:0" "[::]:" results to "[::]:0" "[::]:0" results to "[::]:0" "[::]:65535" results to "[::]:65535" // port 0 to 65535 "0.0.0.0" results to "0.0.0.0:0" "0.0.0.0:" results to "0.0.0.0:0" "0.0.0.0:0" results to "0.0.0.0:0" "0.0.0.0:65535" results to "0.0.0.0:65535" // port 0 to 65535
A valid address with an invalid port results to port 0, for example
"[2001:db8::51]:98765" results to "[2001:db8::51]:0"
Setting only the port number does not modify the address part.
"[2001:db8::52]:50001" results to "[2001:db8::52]:50001"
":55555" results to "[2001:db8::52]:55555" (address prev setting)
"55556" same as before with leading colon.
| std::invalid_argument | Invalid netaddress. |
| [in] | a_addr_str | String with a possible netaddress |
Definition at line 352 of file sockaddr.cpp.
Here is the call graph for this function:| void UPnPsdk::SSockaddr::operator= | ( | const in_port_t | a_port | ) |
Set port number from integer.
Definition at line 411 of file sockaddr.cpp.
| void UPnPsdk::SSockaddr::operator= | ( | const ::sockaddr_storage & | a_ss | ) |
Set socket address from a trivial socket address structure.
Definition at line 420 of file sockaddr.cpp.
| bool UPnPsdk::SSockaddr::operator== | ( | const SSockaddr & | a_saddr | ) | const |
Test if another socket address is logical equal to this.
It only supports AF_INET6 and AF_INET. For all other address families false is returned.
Definition at line 426 of file sockaddr.cpp.
|
noexcept |
Get the assosiated netaddress without port.
Definition at line 433 of file sockaddr.cpp.
Here is the caller graph for this function:
|
noexcept |
Get the assosiated netaddress with port.
Definition at line 484 of file sockaddr.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| in_port_t UPnPsdk::SSockaddr::port | ( | ) | const |
Get the numeric port.
Definition at line 510 of file sockaddr.cpp.
Here is the caller graph for this function:| socklen_t UPnPsdk::SSockaddr::sizeof_saddr | ( | ) | const |
Get sizeof the current filled (sin6 or sin) Sockaddr Structure.
Definition at line 520 of file sockaddr.cpp.
Here is the caller graph for this function:| bool UPnPsdk::SSockaddr::is_loopback | ( | ) | const |
Get if the socket address is a loopback address.
Definition at line 536 of file sockaddr.cpp.
Here is the caller graph for this function:| sockaddr_storage& UPnPsdk::SSockaddr::ss = m_sa_union.ss |
Reference to sockaddr_storage struct.
Definition at line 135 of file sockaddr.hpp.
| sockaddr_un& UPnPsdk::SSockaddr::sun = m_sa_union.sun |
Reference to sockaddr_un struct.
Definition at line 137 of file sockaddr.hpp.
| sockaddr_in6& UPnPsdk::SSockaddr::sin6 = m_sa_union.sin6 |
Reference to sockaddr_in6 struct.
Definition at line 139 of file sockaddr.hpp.
| sockaddr_in& UPnPsdk::SSockaddr::sin = m_sa_union.sin |
Reference to sockaddr_in struct.
Definition at line 141 of file sockaddr.hpp.
| sockaddr& UPnPsdk::SSockaddr::sa = m_sa_union.sa |
Reference to sockaddr struct.
Definition at line 143 of file sockaddr.hpp.