37 int inet_pton_imp(
int f ,
const char * p ,
void * result ) ;
38 const char * inet_ntop_imp(
int f ,
void * ap ,
char * buffer ,
size_t n ) ;
63 bool operator==(
const Family & other )
const ;
64 bool operator!=(
const Family & other )
const ;
66 explicit Family(
bool is4_ ) ;
70 G_EXCEPTION( Error ,
"address error" ) ;
71 G_EXCEPTION( BadFamily ,
"unsupported address family" ) ;
72 G_EXCEPTION( BadString ,
"invalid address" ) ;
83 Address(
const sockaddr * addr , socklen_t len ) ;
92 explicit Address(
const std::string & display_string ) ;
96 Address(
const std::string & ip ,
unsigned int port ) ;
113 const sockaddr *
address()
const ;
132 unsigned int port()
const;
138 unsigned long scopeId(
unsigned long default_ = 0UL )
const ;
142 static bool validPort(
unsigned int n ) ;
146 static bool validString(
const std::string & display_string , std::string * reason =
nullptr ) ;
150 static bool validStrings(
const std::string & ip ,
const std::string & port_string , std::string * reason =
nullptr ) ;
155 static bool validData(
const sockaddr * , socklen_t len ) ;
176 bool isLocal( std::string & reason )
const ;
217 const sockaddr *
p()
const ;
220 socklen_t
n()
const ;
233 inline bool GNet::Address::Family::operator==(
const Family & other )
const {
return is4 == other.is4 ; }
234 inline bool GNet::Address::Family::operator!=(
const Family & other )
const {
return is4 != other.is4 ; }
235 inline GNet::Address::Family::Family(
bool is4_ ) : is4(is4_) {}
static Address loopback(Family, unsigned int port=0U)
Returns a loopback address.
Family family() const
Returns the address family.
static bool validData(const sockaddr *, socklen_t len)
Returns true if the sockaddr data is valid.
and hiding the definition of sockaddr_storage.
The GNet::Address class encapsulates a TCP/UDP transport address.
bool isLoopback() const
Returns true if this is a loopback address.
static bool validStrings(const std::string &ip, const std::string &port_string, std::string *reason=nullptr)
Returns true if the combined ip address string and port string is valid.
std::vector< std::string > StringArray
A std::vector of std::strings.
socklen_t * p2()
Returns the length pointer for accept()/getsockname()/getpeername() to write into.
sockaddr * p1()
Returns the sockaddr pointer for accept()/getsockname()/getpeername() to write into.
A pimple-pattern implementation class used by GNet::AddressStorage.
const sockaddr * address() const
Returns the sockaddr address.
bool sameHostPart(const Address &other) const
Returns true if the two addresses have the same host part (ie.
unsigned int port() const
Returns port part of the address.
bool operator==(const Address &) const
Comparison operator.
const sockaddr * p() const
Returns the pointer.
A 'sockaddr' wrapper class for IPv4 addresses.
AddressStorage()
Default constructor.
static Address defaultAddress()
Returns a default address, being the IPv4 wildcard address with a zero port number.
G::StringArray wildcards() const
Returns an ordered list of wildcard strings that match this address.
socklen_t length() const
Returns the size of the sockaddr address. See address().
std::string hostPartString() const
Returns a string which represents the network address for debugging and diagnostics purposes...
unsigned long scopeId(unsigned long default_=0UL) const
Returns the scope-id.
static bool validString(const std::string &display_string, std::string *reason=nullptr)
Returns true if the display string is valid.
int domain() const
Returns the address 'domain', eg. PF_INET.
~AddressStorage()
Destructor.
static bool validPort(unsigned int n)
Returns true if the port number is within the valid range.
A type-safe enumerator for IP address family.
bool isLocal(std::string &reason) const
Returns true if this seems to be a local address.
void operator=(const Address &addr)
Assignment operator.
Address(const Address &)
Copy constructor.
void setPort(unsigned int port)
Sets the port number.
socklen_t n() const
Returns the length.
static bool supports(Family)
Returns true if the implementation supports the given address family.
bool operator!=(const Address &) const
Comparison operator.
std::string displayString() const
Returns a string which represents the transport address for debugging and diagnostics purposes...
A 'sockaddr' wrapper class for IPv6 addresses.