LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::IPSrv Class Reference

An IP address and host_order_port, modeled on an SRV type for DNS. More...

#include <IPSrv.h>

Collaboration diagram for swoc::IPSrv:
Collaboration graph

Classes

union  data
 Family specialized data. More...
 

Public Member Functions

 IPSrv ()=default
 Default constructor.
 
 IPSrv (IP4Addr addr, in_port_t port=0)
 
 IPSrv (IP6Addr addr, in_port_t port=0)
 Construct for IPv6 address and port.
 
 IPSrv (IPAddr addr, in_port_t port=0)
 Construct from generic address and port.
 
 IPSrv (sockaddr const *sa)
 Construct from socket address.
 
 IPSrv (sockaddr_in const *s)
 Construct IPv4 service from socket address.
 
 IPSrv (sockaddr_in6 const *s)
 Construct IPv6 service from socket address.
 
 IPSrv (IPEndpoint const &ep)
 Construct from Endpoint.
 
 IPSrv (swoc::TextView text)
 
bool load (swoc::TextView text)
 
IPAddr addr () const
 
constexpr in_port_t host_order_port () const
 
in_port_t network_order_port () const
 
constexpr sa_family_t family () const
 
bool is_valid () const
 
bool is_ip4 () const
 
bool is_ip6 () const
 
IP4Srv const & ip4 () const
 
IP6Srv const & ip6 () const
 
self_typeassign (IP4Addr const &addr)
 
self_typeassign (IP6Addr const &addr)
 
self_typeassign (IPAddr const &addr)
 
self_typeassign (in_port_t port)
 
self_typeassign (IP4Addr const &addr, in_port_t port)
 
self_typeassign (IP6Addr const &addr, in_port_t port)
 
self_typeassign (sockaddr const *sa)
 
self_typeassign (sockaddr_in const *s)
 
self_typeassign (sockaddr_in6 const *s)
 
self_typeassign (IPAddr const &addr, in_port_t port)
 
self_typeoperator= (self_type const &that)=default
 Copy assignment.
 
self_typeoperator= (IP4Srv const &that)
 Assign from IPv4.
 
self_typeoperator= (IP6Srv const &that)
 Assign from IPv6.
 
self_typeoperator= (sockaddr const *sa)
 Assign from generic socket address.
 
self_typeoperator= (sockaddr_in const *s)
 Assign from IPv4 socket address.
 
self_typeoperator= (sockaddr_in6 const *s)
 Assign from IPv6 socket address.
 

Protected Attributes

union swoc::IPSrv::data _srv
 
sa_family_t _family = AF_UNSPEC
 Protocol family.
 

Detailed Description

An IP address and host_order_port, modeled on an SRV type for DNS.

Definition at line 224 of file IPSrv.h.

Constructor & Destructor Documentation

◆ IPSrv() [1/8]

swoc::IPSrv::IPSrv ( IP4Addr addr,
in_port_t port = 0 )
inlineexplicit

Definition at line 230 of file IPSrv.h.

◆ IPSrv() [2/8]

swoc::IPSrv::IPSrv ( IP6Addr addr,
in_port_t port = 0 )
inlineexplicit

Construct for IPv6 address and port.

Definition at line 232 of file IPSrv.h.

◆ IPSrv() [3/8]

swoc::IPSrv::IPSrv ( IPAddr addr,
in_port_t port = 0 )
explicit

Construct from generic address and port.

Definition at line 816 of file swoc_ip.cc.

◆ IPSrv() [4/8]

swoc::IPSrv::IPSrv ( sockaddr const * sa)
inlineexplicit

Construct from socket address.

Definition at line 555 of file IPSrv.h.

◆ IPSrv() [5/8]

swoc::IPSrv::IPSrv ( sockaddr_in const * s)
inlineexplicit

Construct IPv4 service from socket address.

Definition at line 553 of file IPSrv.h.

◆ IPSrv() [6/8]

swoc::IPSrv::IPSrv ( sockaddr_in6 const * s)
inlineexplicit

Construct IPv6 service from socket address.

Definition at line 554 of file IPSrv.h.

◆ IPSrv() [7/8]

swoc::IPSrv::IPSrv ( IPEndpoint const & ep)
explicit

Construct from Endpoint.

Definition at line 826 of file swoc_ip.cc.

◆ IPSrv() [8/8]

swoc::IPSrv::IPSrv ( swoc::TextView text)
explicit

Construct from a string.

Parameters
textInput text.

If the port is not present it is set to zero.

Definition at line 790 of file swoc_ip.cc.

Member Function Documentation

◆ addr()

IPAddr swoc::IPSrv::addr ( ) const
inline
Returns
The address.

Definition at line 560 of file IPSrv.h.

◆ assign() [1/10]

auto swoc::IPSrv::assign ( in_port_t port)
inline

Assign port.

Parameters
portPort [host order].
Returns
this.

Definition at line 628 of file IPSrv.h.

◆ assign() [2/10]

auto swoc::IPSrv::assign ( IP4Addr const & addr)
inline

Change the address.

Parameters
addrAddress to assign.
Returns
this

Definition at line 621 of file IPSrv.h.

◆ assign() [3/10]

auto swoc::IPSrv::assign ( IP4Addr const & addr,
in_port_t port )
inline

Assign an IPv4 address and port.

Parameters
addrAddress.
portPort [host order].
Returns
this

Definition at line 607 of file IPSrv.h.

◆ assign() [4/10]

auto swoc::IPSrv::assign ( IP6Addr const & addr)
inline

Change the address.

Parameters
addrAddress to assign.
Returns
this

Definition at line 600 of file IPSrv.h.

◆ assign() [5/10]

auto swoc::IPSrv::assign ( IP6Addr const & addr,
in_port_t port )
inline

Assign an IPv6 address and port.

Parameters
addrAddress.
portPort [host order].
Returns
this

Definition at line 614 of file IPSrv.h.

◆ assign() [6/10]

auto swoc::IPSrv::assign ( IPAddr const & addr)
inline

Assign an address.

Parameters
addrAddress.
Returns
this

If addr isn't valid then no assignment is made, otherwise the family is changed to that of addr.

Definition at line 638 of file IPSrv.h.

◆ assign() [7/10]

auto swoc::IPSrv::assign ( IPAddr const & addr,
in_port_t port )
inline

Assign an address and port.

Parameters
addrAddress.
portPort [host order].
Returns
this

If addr isn't valid then no assignment is made, otherwise the family is changed to match addr.

Definition at line 648 of file IPSrv.h.

◆ assign() [8/10]

auto swoc::IPSrv::assign ( sockaddr const * sa)

Assogm address amd [prt/

Parameters
saSocket address.
Returns
this

The assignment is ignored if sa is not a valid IP family, otherwise the family is changed to that of sa.

Definition at line 837 of file swoc_ip.cc.

◆ assign() [9/10]

auto swoc::IPSrv::assign ( sockaddr_in const * s)
inline

Assign an IPv4 address and port.

Parameters
sSocket address.
Returns
this

Definition at line 674 of file IPSrv.h.

◆ assign() [10/10]

auto swoc::IPSrv::assign ( sockaddr_in6 const * s)
inline

Assign an IPv6 address and port.

Parameters
sSocket address.
Returns
this

Definition at line 681 of file IPSrv.h.

◆ family()

sa_family_t swoc::IPSrv::family ( ) const
inlineconstexpr
Returns
The protocol of the current value.

Definition at line 565 of file IPSrv.h.

◆ host_order_port()

in_port_t swoc::IPSrv::host_order_port ( ) const
inlineconstexpr
Returns
The host_order_port in host order..

Definition at line 590 of file IPSrv.h.

◆ ip4()

IP4Srv const & swoc::IPSrv::ip4 ( ) const
inline
Returns
The IPv4 data.

Definition at line 581 of file IPSrv.h.

◆ ip6()

IP6Srv const & swoc::IPSrv::ip6 ( ) const
inline
Returns
The IPv6 data.

Definition at line 585 of file IPSrv.h.

◆ is_ip4()

bool swoc::IPSrv::is_ip4 ( ) const
inline
Returns
true if the data is IPv4, false if not.

Definition at line 572 of file IPSrv.h.

◆ is_ip6()

bool swoc::IPSrv::is_ip6 ( ) const
inline
Returns
true if hte data is IPv6, false if not.

Definition at line 577 of file IPSrv.h.

◆ is_valid()

bool swoc::IPSrv::is_valid ( ) const
inline
Returns
true if this is a valid service, false if not.

Definition at line 569 of file IPSrv.h.

◆ load()

bool swoc::IPSrv::load ( swoc::TextView text)

Load from a string.

Parameters
textInput string.
Returns
true if text in a valid format, false if not.

Definition at line 795 of file swoc_ip.cc.

◆ network_order_port()

in_port_t swoc::IPSrv::network_order_port ( ) const
inline
Returns
The host_order_port in network order.

Definition at line 595 of file IPSrv.h.

◆ operator=() [1/5]

auto swoc::IPSrv::operator= ( IP4Srv const & that)
inline

Assign from IPv4.

Definition at line 660 of file IPSrv.h.

◆ operator=() [2/5]

auto swoc::IPSrv::operator= ( IP6Srv const & that)
inline

Assign from IPv6.

Definition at line 667 of file IPSrv.h.

◆ operator=() [3/5]

IPSrv::self_type & swoc::IPSrv::operator= ( sockaddr const * sa)
inline

Assign from generic socket address.

Definition at line 687 of file IPSrv.h.

◆ operator=() [4/5]

IPSrv::self_type & swoc::IPSrv::operator= ( sockaddr_in const * s)
inline

Assign from IPv4 socket address.

Definition at line 691 of file IPSrv.h.

◆ operator=() [5/5]

IPSrv::self_type & swoc::IPSrv::operator= ( sockaddr_in6 const * s)
inline

Assign from IPv6 socket address.

Definition at line 695 of file IPSrv.h.

Member Data Documentation

◆ _family

sa_family_t swoc::IPSrv::_family = AF_UNSPEC
protected

Protocol family.

Definition at line 399 of file IPSrv.h.


The documentation for this class was generated from the following files: