IPv6 socket address. More...

#include <senf/Socket/Protocols/INet/INetAddressing.hh>

Inheritance diagram for senf::INet6SocketAddress:

Public Member Functions

INet6Address address () const
 Get printable address representation. More...
 
void address (INet6Address const &addr)
 Change address. More...
 
unsigned port () const
 Get port number. More...
 
void port (unsigned port)
 Change port number. More...
 
std::string iface () const
 Get interface name. More...
 
void iface (std::string const &iface)
 Change interface. More...
 
- Public Member Functions inherited from senf::BSDSocketAddress
bool operator== (BSDSocketAddress const &other) const
 Compare two arbitrary addresses. More...
 
bool operator< (BSDSocketAddress const &other) const
 Compare two arbitrary addresses. More...
 
bool boolean_test () const
 Return true, if address is not empty. More...
 
short family () const
 Return the address family. More...
 
struct sockaddr const * sockaddr_p () const
 
socklen_t socklen () const
 
socklen_t const * socklen_p () const
 
- Public Member Functions inherited from senf::comparable_safe_bool< BSDSocketAddress >
 operator bool_type () const
 
bool operator! () const
 

Static Public Attributes

static short const addressFamily = AF_INET6
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, INet6SocketAddress const &addr)
 Output INet6SocketAddress instance as it's string representation. More...
 

Structors and default members

 INet6SocketAddress ()
 Create empty instance. More...
 
 INet6SocketAddress (std::string const &addr, INet6Address::Resolve_t resolve=INet6Address::ResolveINet6)
 Initialize/convert from string representation. More...
 
 INet6SocketAddress (INet6Address const &addr, unsigned port)
 Initialize from address and port. More...
 
 INet6SocketAddress (INet6Address const &addr, unsigned port, std::string const &iface)
 Initialize explicitly from given parameters. More...
 
 INet6SocketAddress (unsigned port)
 Initialize from port and set to 'unspecified' addr. More...
 
 INet6SocketAddress (const INet6SocketAddress &other)
 
INet6SocketAddressoperator= (const INet6SocketAddress &other)
 

Additional Inherited Members

- Protected Types inherited from senf::safe_bool_base
typedef void(safe_bool_base::* bool_type) () const
 
- Protected Member Functions inherited from senf::BSDSocketAddress
 BSDSocketAddress (socklen_t len, short family)
 
 BSDSocketAddress (BSDSocketAddress const &other)
 
BSDSocketAddressoperator= (BSDSocketAddress const &other)
 
struct sockaddr * sockaddr_p ()
 
socklen_t * socklen_p ()
 
void socklen (socklen_t len)
 
- Protected Member Functions inherited from senf::comparable_safe_bool< BSDSocketAddress >
 ~comparable_safe_bool ()
 
- Protected Member Functions inherited from senf::safe_bool_base
void this_type_does_not_support_comparisons () const
 
 safe_bool_base ()
 
 safe_bool_base (const safe_bool_base &)
 
safe_bool_baseoperator= (const safe_bool_base &)
 
 ~safe_bool_base ()
 

Detailed Description

IPv6 socket address.

This class wraps the standard sockaddr_in6 structure. INet6SocketAddress provides access to all members of the sockaddr_in6 structure. Additionally, INet6SocketAddress supports the string representations

[ address [ % zone-id ] ]: port
hostname : port

Where address is an arbitrary numeric IPv6 address, zone-id is an optional network interface name and port is the port number. So some example addresses are

[2001:db8:1::1]:80
www.go6.net:80
[fe80::1%eth0]:443
Implementation note:
The sockaddr_in6 structure has an sin6_flowinfo member. However RFC3493 does not give the use of this field and specifies, that the field should be ignored ... so that's what we do. Furthermore, the GNU libc reference states, that this field is not implemented in the library.
Idea:
Implement a INet6Address_ref class which has an interface identical to INet6Address and is convertible to INet6Address (the latter has a conversion constructor taking the former as arg). This class however references an external in6_addr instead of containing one itself. This can be used in INet6SocketAddress to increase the performance of some operations.

Definition at line 132 of file INetAddressing.hh.

Constructor & Destructor Documentation

◆ INet6SocketAddress() [1/6]

senf::INet6SocketAddress::INet6SocketAddress ( )

Create empty instance.

◆ INet6SocketAddress() [2/6]

senf::INet6SocketAddress::INet6SocketAddress ( std::string const &  addr,
INet6Address::Resolve_t  resolve = INet6Address::ResolveINet6 
)
explicit

Initialize/convert from string representation.

Exceptions
AddressSyntaxExceptionif the address syntax is invalid
UnknownHostnameExceptionif the address cannot be resolved.
Parameters
[in]addrAddress to parse
[in]resolveIf this is INet6Address::ResolveINet4, support IPv4 addresses. See INet6Address.

Definition at line 88 of file INetAddressing.cc.

◆ INet6SocketAddress() [3/6]

senf::INet6SocketAddress::INet6SocketAddress ( INet6Address const &  addr,
unsigned  port 
)

Initialize from address and port.

◆ INet6SocketAddress() [4/6]

senf::INet6SocketAddress::INet6SocketAddress ( INet6Address const &  addr,
unsigned  port,
std::string const &  iface 
)

Initialize explicitly from given parameters.

Exceptions
AddressSyntaxExceptionif the given iface cannot be resolved.

◆ INet6SocketAddress() [5/6]

senf::INet6SocketAddress::INet6SocketAddress ( unsigned  port)
explicit

Initialize from port and set to 'unspecified' addr.

The address is set to [::]

Parameters
[in]portport number

◆ INet6SocketAddress() [6/6]

senf::INet6SocketAddress::INet6SocketAddress ( const INet6SocketAddress other)

Member Function Documentation

◆ address() [1/2]

INet6Address senf::INet6SocketAddress::address ( ) const

Get printable address representation.

◆ address() [2/2]

void senf::INet6SocketAddress::address ( INet6Address const &  addr)

Change address.

◆ iface() [1/2]

std::string senf::INet6SocketAddress::iface ( ) const

Get interface name.

Definition at line 120 of file INetAddressing.cc.

◆ iface() [2/2]

void senf::INet6SocketAddress::iface ( std::string const &  iface)

Change interface.

Exceptions
AddressSyntaxExceptionif the given iface cannot be resolved.

◆ operator=()

INet6SocketAddress& senf::INet6SocketAddress::operator= ( const INet6SocketAddress other)

◆ port() [1/2]

unsigned senf::INet6SocketAddress::port ( ) const

Get port number.

◆ port() [2/2]

void senf::INet6SocketAddress::port ( unsigned  port)

Change port number.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
INet6SocketAddress const &  addr 
)
related

Output INet6SocketAddress instance as it's string representation.

Member Data Documentation

◆ addressFamily

short const senf::INet6SocketAddress::addressFamily = AF_INET6
static

Definition at line 136 of file INetAddressing.hh.


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