Wizard
Software Engineering Project - Wizard
Loading...
Searching...
No Matches
sockpp::inet6_address Class Reference

#include <inet6_address.h>

Inheritance diagram for sockpp::inet6_address:
sockpp::sock_address

Public Member Functions

 inet6_address ()
 
 inet6_address (in_port_t port)
 
 inet6_address (const std::string &saddr, in_port_t port)
 
 inet6_address (const sockaddr_storage &addr)
 
 inet6_address (const sock_address &addr)
 
 inet6_address (const sockaddr_in6 &addr)
 
 inet6_address (const inet6_address &addr)
 
bool is_set () const
 
void create (const in6_addr &addr, in_port_t port)
 
void create (const std::string &saddr, in_port_t port)
 
in6_addr address () const
 
uint8_t operator[] (int i) const
 
in_port_t port () const
 
socklen_t size () const override
 
const sockaddr * sockaddr_ptr () const override
 
sockaddr * sockaddr_ptr () override
 
const sockaddr_in6 * sockaddr_in6_ptr () const
 
sockaddr_in6 * sockaddr_in6_ptr ()
 
std::string to_string () const
 
- Public Member Functions inherited from sockpp::sock_address
virtual ~sock_address ()
 
virtual sa_family_t family () const
 

Static Public Member Functions

static inet6_address loopback (in_port_t port)
 
static in6_addr resolve_name (const std::string &saddr)
 

Static Public Attributes

static constexpr sa_family_t ADDRESS_FAMILY = AF_INET6
 

Detailed Description

Class that represents an internet (IPv6) address. This inherits from the IP-specific form of a socket address, sockaddr_in.

Constructor & Destructor Documentation

◆ inet6_address() [1/7]

sockpp::inet6_address::inet6_address ( )
inline

Constructs an empty address. The address is initialized to all zeroes.

◆ inet6_address() [2/7]

sockpp::inet6_address::inet6_address ( in_port_t port)
inlineexplicit

Constructs an address for any iface using the specified port. This is a convenient way for a server to specify an address that will bind to all interfaces.

Parameters
portThe port number in native/host byte order.

◆ inet6_address() [3/7]

sockpp::inet6_address::inet6_address ( const std::string & saddr,
in_port_t port )
inline

Constructs an address using the name of the host and the specified port. This attempts to resolve the host name to an address.

Parameters
saddrThe name of the host.
portThe port number in native/host byte order.

◆ inet6_address() [4/7]

sockpp::inet6_address::inet6_address ( const sockaddr_storage & addr)
inline

Constructs the address by copying the specified structure. TODO: Do we actually need a conversion from something that's cast to a sockaddr, but is really a sockaddr_in6?

Parameters
addrThe other address

◆ inet6_address() [5/7]

sockpp::inet6_address::inet6_address ( const sock_address & addr)
inline

Constructs the address by copying the specified structure.

Parameters
addrThe other address

◆ inet6_address() [6/7]

sockpp::inet6_address::inet6_address ( const sockaddr_in6 & addr)
inline

Constructs the address by copying the specified structure.

Parameters
addrThe other address

◆ inet6_address() [7/7]

sockpp::inet6_address::inet6_address ( const inet6_address & addr)
inline

Constructs the address by copying the specified address.

Parameters
addrThe other address

Member Function Documentation

◆ address()

in6_addr sockpp::inet6_address::address ( ) const
inline

Gets 128-bit IPv6 address. The address is usually stored in network byte order.

Returns
The IPv6 address.

◆ create() [1/2]

void sockpp::inet6_address::create ( const in6_addr & addr,
in_port_t port )

Creates the socket address using the specified host address and port number.

Parameters
addrThe host address (16-byte IPv6 address).
portThe host port number.

◆ create() [2/2]

void sockpp::inet6_address::create ( const std::string & saddr,
in_port_t port )

Creates the socket address using the specified host name and port number.

Parameters
saddrThe string host name.
portThe port number in native/host byte order.

◆ is_set()

bool sockpp::inet6_address::is_set ( ) const

Checks if the address is set to some value. This doesn't attempt to determine if the address is valid, simply that it's not all zero.

Returns
bool

◆ loopback()

static inet6_address sockpp::inet6_address::loopback ( in_port_t port)
inlinestatic

Creates an address on the loopback (localhost) interface.

Parameters
portThe port number (in native/host byte order).
Returns
The full address on the loopback interface.

◆ operator[]()

uint8_t sockpp::inet6_address::operator[] ( int i) const
inline
   Gets a byte of the 128-bit IPv6 Address.
   Note that the address is normally stored in network byte
   order.
   @param i The byte to read (0-7)

{ return addr_ != sockaddr_in6{};

Returns
The specified byte in the 128-bit IPv6 Address

◆ port()

in_port_t sockpp::inet6_address::port ( ) const
inline

Gets the port number.

Returns
The port number in native/host byte order.

◆ resolve_name()

in6_addr sockpp::inet6_address::resolve_name ( const std::string & saddr)
static

Attempts to resolve the host name into a 32-bit internet address.

Parameters
saddrThe string host name.
Returns
The internet address in network byte order.

◆ size()

socklen_t sockpp::inet6_address::size ( ) const
inlineoverridevirtual

Gets the size of this structure. This is equivalent to sizeof(this) but more convenient in some places.

Returns
The size of this structure.

Implements sockpp::sock_address.

◆ sockaddr_in6_ptr() [1/2]

sockaddr_in6 * sockpp::inet6_address::sockaddr_in6_ptr ( )
inline

Gets a pointer to this object cast to a sockaddr_in6.

Returns
sockaddr_in6 pointer to this object.

◆ sockaddr_in6_ptr() [2/2]

const sockaddr_in6 * sockpp::inet6_address::sockaddr_in6_ptr ( ) const
inline

Gets a const pointer to this object cast to a sockaddr_in6.

Returns
const sockaddr_in6 pointer to this object.

◆ sockaddr_ptr() [1/2]

const sockaddr * sockpp::inet6_address::sockaddr_ptr ( ) const
inlineoverridevirtual

Gets a pointer to this object cast to a sockaddr.

Returns
A pointer to this object cast to a sockaddr.

Implements sockpp::sock_address.

◆ sockaddr_ptr() [2/2]

sockaddr * sockpp::inet6_address::sockaddr_ptr ( )
inlineoverridevirtual

Gets a pointer to this object cast to a sockaddr.

Returns
A pointer to this object cast to a sockaddr.

Implements sockpp::sock_address.

◆ to_string()

string sockpp::inet6_address::to_string ( ) const

Gets a printable string for the address. This gets the address in the printable form "[addr]:port" using inet_ntop(). It does not attempt to find the host name using a lookup.

Returns
A string representation of the address in the form '[address]:port'

Member Data Documentation

◆ ADDRESS_FAMILY

sa_family_t sockpp::inet6_address::ADDRESS_FAMILY = AF_INET6
staticconstexpr

The address family for this type of address


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