|
LibSWOC++ 1.5.14
Solid Wall of C++
|
#include <IPEndpoint.h>

Public Types | |
| using | self_type = IPEndpoint |
| Self reference type. | |
| using | string_view = std::string_view |
Public Member Functions | |
| IPEndpoint () | |
| Default construct invalid instance. | |
| IPEndpoint (self_type const &that) | |
| Copy constructor. | |
| IPEndpoint (string_view const &text) | |
| Construct from the text representation of an address. | |
| IPEndpoint (IPAddr const &addr) | |
| Construct from an address. | |
| IPEndpoint (IPSrv const &srv) | |
| Construct from address and port. | |
| IPEndpoint (sockaddr const *addr) | |
| Construct from generic socket address. | |
| IPEndpoint (sockaddr_in const *sin) | |
| Construct from sockaddr_in. | |
| IPEndpoint (sockaddr_in6 const *sin6) | |
| Construct from sockaddr_in6. | |
| self_type & | operator= (self_type const &that) |
| Copy assignment. | |
| bool | parse (string_view const &str) |
| self_type & | invalidate () |
| Invalidate this endpoint. | |
| self_type & | assign (sockaddr const *addr) |
| self_type & | assign (sockaddr_in const *sin) |
| self_type & | assign (sockaddr_in6 const *sin6) |
| self_type & | assign (IPAddr const &addr) |
| Assign from IP address. | |
| self_type & | assign (IPAddr const &addr, in_port_t port) |
| self_type & | assign (IP4Addr const &addr) |
| Assign from IPv4 address. | |
| self_type & | assign (IP6Addr const &addr) |
| Assign from IPv4 address. | |
| self_type & | assign (IP4Srv const &srv) |
| Assign from IPv4 service. | |
| self_type & | assign (IP6Srv const &srv) |
| Assign from IPv6 service. | |
| self_type & | assign (IPSrv const &srv) |
| Assign from IP service. | |
| const self_type & | copy_to (sockaddr *addr) const |
| Copy to sa. | |
| bool | is_valid () const |
| Test for valid IP address. | |
| bool | is_ip4 () const |
| Test for IPv4. | |
| bool | is_ip6 () const |
| Test for IPv6. | |
| socklen_t | size () const |
| sa_family_t | family () const |
| sockaddr_in * | ip4 () |
| sockaddr_in const * | ip4 () const |
| sockaddr_in6 * | ip6 () |
| sockaddr_in6 const * | ip6 () const |
| self_type & | set_to_any (int family) |
| bool | is_any () const |
| self_type & | set_to_loopback (int family) |
| bool | is_loopback () const |
| bool | is_link_local () const |
| bool | is_private () const |
| bool | is_multicast () const |
| in_port_t | network_order_port () const |
| in_port_t | host_order_port () const |
| operator sockaddr * () | |
Automatic conversion to sockaddr. | |
| operator sockaddr const * () const | |
Automatic conversion to sockaddr. | |
| size_t | sa_size () const |
| Size of the sockaddr variant based on the family. | |
| swoc::MemSpan< void const > | raw_addr () const |
Static Public Member Functions | |
| static bool | tokenize (string_view src, string_view *host=nullptr, string_view *port=nullptr, string_view *rest=nullptr) |
| static void | invalidate (sockaddr *addr) |
Invalidate a sockaddr. | |
| static bool | assign (sockaddr *dst, sockaddr const *src) |
| static bool | is_link_local (sockaddr const *sa) |
| static bool | is_private (sockaddr const *sa) |
| static bool | is_multicast (sockaddr const *sa) |
| static bool | is_valid (sockaddr const *sa) |
| static in_port_t & | port (sockaddr *sa) |
| static in_port_t | network_order_port (sockaddr const *sa) |
| static in_port_t | host_order_port (sockaddr const *sa) |
| static size_t | sa_size (sockaddr const *sa) |
| Size of the sockaddr based on the family. | |
| static string_view | family_name (sa_family_t family) |
| The string name of the address family. | |
Public Attributes | |
| struct sockaddr | sa |
| Generic address. | |
| struct sockaddr_in | sa4 |
| IPv4. | |
| struct sockaddr_in6 | sa6 |
| IPv6. | |
A union to hold sockaddr compliant IP address structures.
This class contains a number of static methods to perform operations on external sockaddr instances. These are all duplicates of methods that operate on the internal sockaddr and are provided primarily for backwards compatibility during the shift to using this class.
We use the term "endpoint" because these contain more than just the raw address, all of the data for an IP endpoint is present.
Definition at line 36 of file IPEndpoint.h.
Self reference type.
Definition at line 37 of file IPEndpoint.h.
| using swoc::IPEndpoint::string_view = std::string_view |
Definition at line 38 of file IPEndpoint.h.
|
inline |
Default construct invalid instance.
Definition at line 280 of file IPEndpoint.h.
|
inline |
Copy constructor.
Definition at line 296 of file IPEndpoint.h.
|
explicit |
Construct from the text representation of an address.
Definition at line 44 of file swoc_ip.cc.
|
inlineexplicit |
Construct from an address.
Definition at line 284 of file IPEndpoint.h.
|
inlineexplicit |
Construct from address and port.
Definition at line 288 of file IPEndpoint.h.
|
inline |
Construct from generic socket address.
Definition at line 292 of file IPEndpoint.h.
| IPEndpoint & swoc::IPEndpoint::assign | ( | IP4Addr const & | addr | ) |
Assign from IPv4 address.
Definition at line 70 of file swoc_ip.cc.
| IPEndpoint & swoc::IPEndpoint::assign | ( | IP4Srv const & | srv | ) |
Assign from IPv4 service.
Definition at line 117 of file swoc_ip.cc.
| IPEndpoint & swoc::IPEndpoint::assign | ( | IP6Addr const & | addr | ) |
Assign from IPv4 address.
Definition at line 79 of file swoc_ip.cc.
| IPEndpoint & swoc::IPEndpoint::assign | ( | IP6Srv const & | srv | ) |
Assign from IPv6 service.
Definition at line 127 of file swoc_ip.cc.
| IPEndpoint & swoc::IPEndpoint::assign | ( | IPAddr const & | addr | ) |
Assign from IP address.
Definition at line 88 of file swoc_ip.cc.
| IPEndpoint & swoc::IPEndpoint::assign | ( | IPAddr const & | addr, |
| in_port_t | port ) |
Definition at line 107 of file swoc_ip.cc.
| IPEndpoint & swoc::IPEndpoint::assign | ( | IPSrv const & | srv | ) |
Assign from IP service.
Definition at line 137 of file swoc_ip.cc.
|
static |
Copy (assign) the contents of src to dst.
The caller must ensure dst is large enough to hold the contents of src, the size of which can vary depending on the type of address in dst.
| dst | Destination. |
| src | Source. |
true if dst is a valid IP address, false otherwise. Definition at line 50 of file swoc_ip.cc.
|
inline |
Assign from a socket address. The entire address (all parts) are copied if the ip is valid.
Definition at line 333 of file IPEndpoint.h.
|
inline |
Assign from IPv4 socket address.
| sin | IPv4 socket address. |
Definition at line 321 of file IPEndpoint.h.
|
inline |
Assign from IPv6 socket address.
| sin6 | IPv6 socket address. |
Definition at line 327 of file IPEndpoint.h.
|
inline |
Copy to sa.
Definition at line 339 of file IPEndpoint.h.
|
inline |
Definition at line 355 of file IPEndpoint.h.
|
static |
The string name of the address family.
Definition at line 226 of file swoc_ip.cc.
|
inline |
Port in host order.
Definition at line 385 of file IPEndpoint.h.
|
inlinestatic |
Port in host order.
| sa | The socket address. |
Definition at line 412 of file IPEndpoint.h.
|
inline |
Invalidate this endpoint.
Definition at line 299 of file IPEndpoint.h.
|
inlinestatic |
Invalidate a sockaddr.
Definition at line 305 of file IPEndpoint.h.
|
inline |
sockaddr_in or nullptr if not IPv4. Definition at line 360 of file IPEndpoint.h.
|
inline |
sockaddr_in or nullptr if not IPv4. Definition at line 365 of file IPEndpoint.h.
|
inline |
sockaddr_in6 or nullptr if not IPv6. Definition at line 370 of file IPEndpoint.h.
|
inline |
sockaddr_in6 or nullptr if not IPv6. Definition at line 375 of file IPEndpoint.h.
| bool swoc::IPEndpoint::is_any | ( | ) | const |
true if this is the ANY address, false if not. Definition at line 256 of file swoc_ip.cc.
|
inline |
Test for IPv4.
Definition at line 345 of file IPEndpoint.h.
|
inline |
Test for IPv6.
Definition at line 350 of file IPEndpoint.h.
|
inline |
true if the address is in the link local network. Definition at line 427 of file IPEndpoint.h.
|
inlinestatic |
true if the address is in the link local network. Definition at line 431 of file IPEndpoint.h.
| bool swoc::IPEndpoint::is_loopback | ( | ) | const |
true if this is a loopback address, false if not. Definition at line 285 of file swoc_ip.cc.
|
inline |
true if the address is multicast. Definition at line 443 of file IPEndpoint.h.
|
inlinestatic |
true if the address is multicast. Definition at line 447 of file IPEndpoint.h.
|
inline |
true if the address is private. Definition at line 435 of file IPEndpoint.h.
|
inlinestatic |
true if the address is private. Definition at line 439 of file IPEndpoint.h.
|
inline |
Test for valid IP address.
Definition at line 310 of file IPEndpoint.h.
|
inlinestatic |
Test for valid IP address.
| sa | The socket address. |
true if sa contains a valid IP address, false if not. sa can be nullptr in which case false is returned. Definition at line 390 of file IPEndpoint.h.
|
inline |
Port in network order.
Definition at line 380 of file IPEndpoint.h.
|
inlinestatic |
Port in network order.
| sa | The socket address. |
Definition at line 407 of file IPEndpoint.h.
|
inline |
Automatic conversion to sockaddr.
Definition at line 451 of file IPEndpoint.h.
|
inline |
Automatic conversion to sockaddr.
Definition at line 453 of file IPEndpoint.h.
|
inline |
Copy assignment.
Definition at line 315 of file IPEndpoint.h.
| bool swoc::IPEndpoint::parse | ( | std::string_view const & | str | ) |
Parse a string for an IP address.
The address resulting from the parse is copied to this object if the conversion is successful, otherwise this object is invalidated.
true on success, false otherwise. Definition at line 205 of file swoc_ip.cc.
|
inlinestatic |
Direct access to port.
Definition at line 395 of file IPEndpoint.h.
|
inline |
The address as a byte sequence.
This is raw access. If the contained data is not a valid address family an empty span is returned.
Definition at line 417 of file IPEndpoint.h.
|
inline |
Size of the sockaddr variant based on the family.
Definition at line 455 of file IPEndpoint.h.
|
inlinestatic |
Size of the sockaddr based on the family.
Definition at line 459 of file IPEndpoint.h.
| IPEndpoint & swoc::IPEndpoint::set_to_any | ( | int | family | ) |
Set to be the ANY address for family family. family must be AF_INET or AF_INET6.
Definition at line 241 of file swoc_ip.cc.
| IPEndpoint & swoc::IPEndpoint::set_to_loopback | ( | int | family | ) |
Set to be loopback address for family family. family must be AF_INET or AF_INET6.
Definition at line 270 of file swoc_ip.cc.
| socklen_t swoc::IPEndpoint::size | ( | ) | const |
Effectively size of the address.
Definition at line 214 of file swoc_ip.cc.
|
static |
Break a string in to IP address relevant tokens.
| src | Source text. [in] |
| host | The host / address. [out] |
| port | The host_order_port. [out] |
| rest | Any text past the end of the IP address. [out] |
true if an IP address was found, false otherwise.Any of the out parameters can be nullptr in which case they are not updated. This parses and discards the IPv6 brackets.
Easier to work with for parsing.
Definition at line 147 of file swoc_ip.cc.
| struct sockaddr swoc::IPEndpoint::sa |
Generic address.
Definition at line 40 of file IPEndpoint.h.
| struct sockaddr_in swoc::IPEndpoint::sa4 |
IPv4.
Definition at line 41 of file IPEndpoint.h.
| struct sockaddr_in6 swoc::IPEndpoint::sa6 |
IPv6.
Definition at line 42 of file IPEndpoint.h.