TSDuck v3.40-3968
MPEG Transport Stream Toolkit
|
A generic representation of an IP address, IPv4 or IPv6. More...
#include <tsIPAddress.h>
Classes | |
class | IncompatibleIPAddress |
This exception is thrown when assigning incompatible IP addresses. More... | |
Public Types | |
using | Port = uint16_t |
The concept of port is used by TCP and UDP over IP networks. | |
Public Member Functions | |
IPAddress ()=default | |
Default constructor with no initial value. | |
IPAddress (const ::in6_addr &a, bool bound=false) | |
IPv6 constructor from a system "struct in6_addr" structure (IPv6 socket API). | |
IPAddress (const ::in_addr &a, bool bound=false) | |
IPv4 constructor from a system "struct in_addr" structure (IPv4 socket API). | |
IPAddress (const ::sockaddr &a) | |
Generic constructor from a system "struct sockaddr" structure (IPv4 or IPv6). | |
IPAddress (const ::sockaddr_in &a, bool bound=false) | |
IPv4 constructor from a system "struct sockaddr_in" structure (IPv4 socket API). | |
IPAddress (const ::sockaddr_in6 &a, bool bound=false) | |
IPv6 constructor from a system "struct sockaddr_in6" structure (IPv6 socket API). | |
IPAddress (const ::sockaddr_storage &a) | |
Generic constructor from a system "struct sockaddr_storage" structure (IPv4 or IPv6). | |
IPAddress (const ByteBlock &bb, bool bound=false) | |
Generic constructor from an address in binary format. | |
IPAddress (const IPAddress &other) | |
Copy constructor. | |
IPAddress (const uint8_t *addr, size_t size, bool bound=false) | |
Generic constructor from an address in binary format. | |
IPAddress (const UString &name, Report &report, IP bound=IP::Any) | |
Constructor from a string, host name or integer format. | |
IPAddress (IP bound) | |
Constructor with no initial value but optionally bound to a generation. | |
IPAddress (uint16_t h1, uint16_t h2, uint16_t h3, uint16_t h4, uint16_t h5, uint16_t h6, uint16_t h7, uint16_t h8, bool bound=false) | |
IPv6 constructor of an IPv6 address from 8 hexlets. | |
IPAddress (uint32_t addr, bool bound=false) | |
IPv4 constructor from an integer IPv4 address. | |
IPAddress (uint64_t net, uint64_t ifid, bool bound=false) | |
IPv6 constructor of an IPv6 address from network prefix and interface identifier. | |
IPAddress (uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, bool bound=false) | |
IPv4 constructor from 4 bytes (classical IPv4 notation). | |
virtual | ~IPAddress () override |
Destructor. | |
uint32_t | address4 () const |
Get the IPv4 address as a 32-bit integer value in host byte order. | |
ByteBlock | address6 () const |
Get the IPv6 address as a byte block. | |
virtual size_t | binarySize () const override |
Get the maximum binary size in bytes for an address of that class. | |
IP | boundGeneration () const |
Get the generation of IP addresses this instance is bound to. | |
void | checkCompatibility (const IPAddress &other) |
Check if this object can hold a value of a specific IP generation and throw an exception if not. | |
void | checkCompatibility (IP gen) |
Check if this object can hold a value of a specific IP generation and throw an exception if not. | |
virtual void | clear () |
Clear the object, address and port if there is any. | |
virtual void | clearAddress () override |
Clear the address field. | |
virtual void | clearPort () |
Clear the port. | |
bool | convert (IP gen) |
Convert an IP address to another generation, when possible. | |
virtual const UChar * | familyName () const override |
Get a human-readable family name for an address of that class. | |
IP | generation () const |
Get the current generation of IP addresses. | |
size_t | getAddress (::sockaddr_storage *a, size_t size, Port port) const |
Copy the address into a system "struct sockaddr_storage" structure (socket API). | |
virtual size_t | getAddress (void *addr, size_t size) const override |
Get the network address as binary data. | |
void | getAddress4 (::in_addr &a) const |
Copy the IPv4 address into a system "struct in_addr" structure (socket API). | |
void | getAddress4 (::sockaddr_in &a, Port port) const |
Copy the IPv4 address into a system "struct sockaddr_in" structure (socket API). | |
void | getAddress6 (::in6_addr &a) const |
Copy the IPv6 address into a system "struct in6_addr" structure (socket API). | |
void | getAddress6 (::sockaddr_in6 &a, Port port) const |
Copy the IPv6 address into a system "struct sockaddr_in6" structure (socket API). | |
virtual bool | hasAddress () const override |
Check if this object is set to a valid address. | |
virtual bool | hasPort () const |
Check if a port is set. | |
uint16_t | hexlet6 (size_t i) const |
Get one of the 16-bit hexlets in the IPv6 address. | |
uint64_t | interfaceIdentifier6 () const |
Get the IPv6 interface identifier (64 least significant bits) of the IPv6 address. | |
bool | isBound () const |
Check if the address is bound to a specific generation of IP addresses. | |
bool | isCompatible (const IPAddress &other) |
Check if this object can hold a value of a specific IP generation. | |
bool | isCompatible (IP gen) |
Check if this object can hold a value of a specific IP generation. | |
bool | isIPv4Mapped () const |
Check if the address is an IPv6 address which is mapped to an IPv4 one. | |
virtual bool | isMulticast () const override |
Check if the address is a multicast address. | |
bool | isSSM () const |
Check if the address is a source specific multicast (SSM) address. | |
bool | match (const IPAddress &other) const |
Check if this address "matches" another one. | |
uint64_t | networkPrefix6 () const |
Get the IPv6 network prefix (64 most significant bits) of the IPv6 address. | |
bool | operator< (const IPAddress &other) const |
Comparison "less than" operator. | |
IPAddress & | operator= (const IPAddress &other) |
Assignment operator. | |
bool | operator== (const IPAddress &other) const |
Equality operator. | |
virtual Port | port () const |
Get the port if there is one. | |
virtual bool | resolve (const UString &name, Report &report) override |
Decode a string containing a network address in family-specific format. | |
void | setAddress (const ::sockaddr &a) |
Set the IP address from a system "struct sockaddr" structure (IPv4 or IPv6). | |
void | setAddress (const ::sockaddr_storage &a) |
Set the IP address from a system "struct sockaddr_storage" structure (IPv4 or IPv6). | |
void | setAddress (const IPAddress &other) |
Set the IP address from another IPAddress object. | |
virtual bool | setAddress (const void *addr, size_t size) override |
Set the network address from binary data. | |
void | setAddress4 (const ::in_addr &a) |
Set the IPv4 address from a system "struct in_addr" structure. | |
void | setAddress4 (const ::sockaddr_in &a) |
Set the IPv4 address from a system "struct sockaddr_in" structure. | |
void | setAddress4 (uint32_t addr) |
Set the IP address from an IPv4 address as a 32-bit integer value in host byte order. | |
void | setAddress4 (uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) |
Set the IP address from 4 bytes (classical IPv4 notation). | |
void | setAddress6 (const ::in6_addr &a) |
Set the IPv6 address from a system "struct in6_addr" structure. | |
void | setAddress6 (const ::sockaddr_in6 &a) |
Set the IPv6 address from a system "struct sockaddr_in6" structure. | |
void | setAddress6 (uint16_t h1, uint16_t h2, uint16_t h3, uint16_t h4, uint16_t h5, uint16_t h6, uint16_t h7, uint16_t h8) |
Set the IP address from an IPv6 address as 8 hexlets. | |
void | setAddress6 (uint64_t net, uint64_t ifid) |
Set the IP address from an IPv6 address as network prefix and interface identifier. | |
virtual void | setPort (Port port) |
Set the port. | |
virtual UString | toFullString () const override |
Convert to a string object in numeric format without the default compaction. | |
virtual UString | toString () const override |
Convert to a string object. | |
Static Public Member Functions | |
static size_t | AddressBits (IP gen) |
Get the address size in bits for a given generation of IP protocols. | |
static const IPAddress & | AnyAddress (IP gen) |
Get the "any address" template for a given generation of IP protocols. | |
static const IPAddress & | LocalHost (IP gen) |
Get the "local host" address for a given generation of IP protocols. | |
static bool | ResolveAllAddresses (IPAddressVector &addresses, const UString &name, Report &report, IP gen=IP::Any) |
Decode a host name and get all possible addresses for that host. | |
Static Public Attributes | |
static const IPAddress | AnyAddress4 |
Wildcard value for "any IPv4 address". | |
static const IPAddress | AnyAddress6 |
Wildcard value for "any IPv6 address". | |
static constexpr Port | AnyPort = 0 |
Wildcard integer value for "any port" or "no port". | |
static constexpr size_t | BITS4 = 32 |
Size in bits of an IPv4 address. | |
static constexpr size_t | BITS6 = 128 |
Size in bits of an IPv6 address. | |
static constexpr size_t | BYTES4 = 4 |
Size in bytes of an IPv4 address. | |
static constexpr size_t | BYTES6 = 16 |
Size in bytes of an IPv6 address. | |
static const IPAddress | LocalHost4 |
Local host IPv4 address ("localhost"). | |
static const IPAddress | LocalHost6 |
Local host IPv6 address (::1, "localhost"). | |
A generic representation of an IP address, IPv4 or IPv6.
An instance of this class can hold an IPv4 or an IPv6 address.
An instance can optionally be bound by construction to a given generation. If it is bound to a given generation, trying to assign an address of a different generation will throw an exception.
An instance always have a generation IPv4 or IPv6. The default initial value is the IPv4 generic address for "any address".
In this class, methods which apply to only one generation, IPv4 or IPv6, have a name ending in 4 or 6, respectively. Some constructors implicitly build one generation of address, IPv4 or IPv6, but their names remain IPAddress() without trailing 4 or 6 by design of C++.
IP v4 addresses are sometimes manipulated as 32-bit integer values. There is always some ambiguity in the operating system interface about the byte order of these integer values. In this class, all publicly available integer values are in the natural host byte order. Whenever a conversion is required, the internal guts of this class will do it for you (and hide it from you).
An IPv6 address is made of 128 bits (16 bytes). It can be manipulated as
|
default |
Default constructor with no initial value.
The default initial value is AnyAddress4.
ts::IPAddress::IPAddress | ( | IP | bound | ) |
Constructor with no initial value but optionally bound to a generation.
The default initial value is AnyAddress4, unless bound is IP::v6 in which case the default initial value is AnyAddress6.
[in] | bound | Bound generation of the IP address. When set to IP::Any, this instance can receive any generation of IP address. Otherwise, this instance can only receive addresses of the specified generation. In that case, trying to assign an address from a different generation thows the exception IncompatibleIPAddress. |
ts::IPAddress::IPAddress | ( | const IPAddress & | other | ) |
Copy constructor.
[in] | other | Another instance to copy. If other is bound to an IP generation, this object is bound to the same generation. |
ts::IPAddress::IPAddress | ( | const uint8_t * | addr, |
size_t | size, | ||
bool | bound = false |
||
) |
Generic constructor from an address in binary format.
[in] | addr | Address of the memory area containing the address in binary format. |
[in] | size | Size of the memory area. If the size is 4, this is an IPv4 address. If the size is 16, this is an IPv6 address. For all other sizes, the address is AnyAddress4. |
[in] | bound | If true, this instance is bound to it generation. Otherwise, it can receive any address. |
|
inline |
Generic constructor from an address in binary format.
[in] | bb | Byte block containing the address in binary format. If the size is 4, this is an IPv4 address. If the size is 16, this is an IPv6 address. For all other sizes, the address is AnyAddress4. |
[in] | bound | If true, this instance is bound to it generation. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | uint32_t | addr, |
bool | bound = false |
||
) |
IPv4 constructor from an integer IPv4 address.
[in] | addr | The IP v4 address as an integer in host byte order. |
[in] | bound | If true, this instance is bound to IPv4. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | uint8_t | b1, |
uint8_t | b2, | ||
uint8_t | b3, | ||
uint8_t | b4, | ||
bool | bound = false |
||
) |
IPv4 constructor from 4 bytes (classical IPv4 notation).
[in] | b1 | First address byte. |
[in] | b2 | Second address byte. |
[in] | b3 | Third address byte. |
[in] | b4 | Fourth address byte. |
[in] | bound | If true, this instance is bound to IPv4. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | uint16_t | h1, |
uint16_t | h2, | ||
uint16_t | h3, | ||
uint16_t | h4, | ||
uint16_t | h5, | ||
uint16_t | h6, | ||
uint16_t | h7, | ||
uint16_t | h8, | ||
bool | bound = false |
||
) |
IPv6 constructor of an IPv6 address from 8 hexlets.
[in] | h1 | First address hexlet. |
[in] | h2 | 2nd address hexlet. |
[in] | h3 | 3rd address hexlet. |
[in] | h4 | 4th address hexlet. |
[in] | h5 | 5th address hexlet. |
[in] | h6 | 6th address hexlet. |
[in] | h7 | 7th address hexlet. |
[in] | h8 | 8th address hexlet. |
[in] | bound | If true, this instance is bound to IPv6. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | uint64_t | net, |
uint64_t | ifid, | ||
bool | bound = false |
||
) |
IPv6 constructor of an IPv6 address from network prefix and interface identifier.
[in] | net | Network prefix. |
[in] | ifid | Interface identifier. |
[in] | bound | If true, this instance is bound to IPv6. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | const ::sockaddr & | a | ) |
Generic constructor from a system "struct sockaddr" structure (IPv4 or IPv6).
[in] | a | A system "struct sockaddr" structure. Note: the structure "sockaddr" is deprecated because it cannot hold an IPv6 socket address. The structure "sockaddr_storage" should be used instead. |
|
inline |
Generic constructor from a system "struct sockaddr_storage" structure (IPv4 or IPv6).
[in] | a | A system "struct sockaddr_storage" structure. |
ts::IPAddress::IPAddress | ( | const ::in_addr & | a, |
bool | bound = false |
||
) |
IPv4 constructor from a system "struct in_addr" structure (IPv4 socket API).
[in] | a | A system "struct in_addr" structure. |
[in] | bound | If true, this instance is bound to IPv4. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | const ::sockaddr_in & | a, |
bool | bound = false |
||
) |
IPv4 constructor from a system "struct sockaddr_in" structure (IPv4 socket API).
[in] | a | A system "struct sockaddr_in" structure. |
[in] | bound | If true, this instance is bound to IPv4. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | const ::in6_addr & | a, |
bool | bound = false |
||
) |
IPv6 constructor from a system "struct in6_addr" structure (IPv6 socket API).
[in] | a | A system "struct in6_addr" structure. |
[in] | bound | If true, this instance is bound to IPv6. Otherwise, it can receive any address. |
ts::IPAddress::IPAddress | ( | const ::sockaddr_in6 & | a, |
bool | bound = false |
||
) |
IPv6 constructor from a system "struct sockaddr_in6" structure (IPv6 socket API).
[in] | a | A system "struct sockaddr_in6" structure. |
[in] | bound | If true, this instance is bound to IPv6. Otherwise, it can receive any address. |
Constructor from a string, host name or integer format.
If name cannot be resolved, the address is set to AnyAddress4.
[in] | name | A string containing either a host name or a numerical representation of the address. |
[in] | report | Where to report errors. |
[in] | bound | Bound generation of the IP address. If not set to IP::Any (the default), this instance becomes bound to that IP generation and the name resolution can only produce an address of that generation. |
Get the "any address" template for a given generation of IP protocols.
[in] | gen | Generation of IP protocols. |
Get the "local host" address for a given generation of IP protocols.
[in] | gen | Generation of IP protocols. |
|
inlinestatic |
Get the address size in bits for a given generation of IP protocols.
[in] | gen | Generation of IP protocols. |
Assignment operator.
The binding of this object to an IP generation is not changed.
[in] | other | Another instance to copy. |
bool ts::IPAddress::operator== | ( | const IPAddress & | other | ) | const |
Equality operator.
[in] | other | Another instance to compare with. |
bool ts::IPAddress::operator< | ( | const IPAddress & | other | ) | const |
Comparison "less than" operator.
It does not really makes sense. Only defined to allow usage in containers.
[in] | other | Other instance to compare. |
bool ts::IPAddress::match | ( | const IPAddress & | other | ) | const |
Check if this address "matches" another one.
[in] | other | Another instance to compare. |
|
inline |
Get the current generation of IP addresses.
|
inline |
Check if the address is bound to a specific generation of IP addresses.
|
inline |
Get the generation of IP addresses this instance is bound to.
|
inline |
Check if this object can hold a value of a specific IP generation.
[in] | gen | The IP generation to check. |
|
inline |
Check if this object can hold a value of a specific IP generation.
[in] | other | Another IP to check. |
void ts::IPAddress::checkCompatibility | ( | IP | gen | ) |
Check if this object can hold a value of a specific IP generation and throw an exception if not.
[in] | gen | The IP generation to check. |
IncompatibleIPAddress | when this object is bound to another IP generation. |
|
inline |
Check if this object can hold a value of a specific IP generation and throw an exception if not.
[in] | other | Another IP to check. |
IncompatibleIPAddress | when this object is bound to an IP generation other than the current generation of other. |
bool ts::IPAddress::isIPv4Mapped | ( | ) | const |
Check if the address is an IPv6 address which is mapped to an IPv4 one.
bool ts::IPAddress::convert | ( | IP | gen | ) |
Convert an IP address to another generation, when possible.
[in] | gen | New IP generation to apply. If gen is incompatible with the object (bound to another generation), return false. If gen is IP::Any or the same as the current generation, return true. A conversion from IPv4 to IPv6 always works (IPv4-mapped address). The conversion of an IPv6 address is only possible if it is an IPv4-mapped address. For convenience, the IPv4 and IPv6 loopback addressses are converted to each other. |
|
overridevirtual |
Get the maximum binary size in bytes for an address of that class.
Implements ts::AbstractNetworkAddress.
|
overridevirtual |
Get a human-readable family name for an address of that class.
This is typically something like "IPv4" or "IPv6".
Implements ts::AbstractNetworkAddress.
|
overridevirtual |
Check if this object is set to a valid address.
Implements ts::AbstractNetworkAddress.
|
overridevirtual |
Get the network address as binary data.
[out] | addr | Address of binary buffer to receive binary data. |
[in] | size | Size in bytes of buffer. |
Implements ts::AbstractNetworkAddress.
|
overridevirtual |
Set the network address from binary data.
[in] | addr | Address of binary data. |
[in] | size | Size in bytes of binary data. |
Implements ts::AbstractNetworkAddress.
|
overridevirtual |
Clear the address field.
Implements ts::AbstractNetworkAddress.
|
overridevirtual |
Check if the address is a multicast address.
Implements ts::AbstractNetworkAddress.
Decode a string containing a network address in family-specific format.
[in] | name | A string containing either a host name or a numerical representation of the address. |
[in] | report | Where to report errors. |
Implements ts::AbstractNetworkAddress.
Reimplemented in ts::IPSocketAddress.
|
overridevirtual |
Convert to a string object in numeric format without the default compaction.
The method toString() (inherited from StringifyInterface) returns a default representation of the string, with possible compaction of omitted defaults. This method returns a complete version of the address representation. The default implementation returns the same value as toString().
Reimplemented from ts::AbstractNetworkAddress.
Reimplemented in ts::IPAddressMask, and ts::IPSocketAddress.
|
overridevirtual |
Convert to a string object.
Implements ts::StringifyInterface.
Reimplemented in ts::IPAddressMask, and ts::IPSocketAddress.
bool ts::IPAddress::isSSM | ( | ) | const |
Check if the address is a source specific multicast (SSM) address.
|
inline |
Get the IPv4 address as a 32-bit integer value in host byte order.
ByteBlock ts::IPAddress::address6 | ( | ) | const |
Get the IPv6 address as a byte block.
uint64_t ts::IPAddress::networkPrefix6 | ( | ) | const |
Get the IPv6 network prefix (64 most significant bits) of the IPv6 address.
uint64_t ts::IPAddress::interfaceIdentifier6 | ( | ) | const |
Get the IPv6 interface identifier (64 least significant bits) of the IPv6 address.
uint16_t ts::IPAddress::hexlet6 | ( | size_t | i | ) | const |
Get one of the 16-bit hexlets in the IPv6 address.
[in] | i | Hexlet index, from 0 to 7. |
void ts::IPAddress::setAddress | ( | const IPAddress & | other | ) |
Set the IP address from another IPAddress object.
Useful for subclasses to assign the address part only.
[in] | other | Another IP address. |
void ts::IPAddress::setAddress4 | ( | uint32_t | addr | ) |
Set the IP address from an IPv4 address as a 32-bit integer value in host byte order.
[in] | addr | The IP v4 address as an integer in host byte order. |
void ts::IPAddress::setAddress4 | ( | uint8_t | b1, |
uint8_t | b2, | ||
uint8_t | b3, | ||
uint8_t | b4 | ||
) |
Set the IP address from 4 bytes (classical IPv4 notation).
[in] | b1 | First address byte. |
[in] | b2 | Second address byte. |
[in] | b3 | Third address byte. |
[in] | b4 | Fourth address byte. |
void ts::IPAddress::setAddress6 | ( | uint16_t | h1, |
uint16_t | h2, | ||
uint16_t | h3, | ||
uint16_t | h4, | ||
uint16_t | h5, | ||
uint16_t | h6, | ||
uint16_t | h7, | ||
uint16_t | h8 | ||
) |
Set the IP address from an IPv6 address as 8 hexlets.
[in] | h1 | First address hexlet. |
[in] | h2 | 2nd address hexlet. |
[in] | h3 | 3rd address hexlet. |
[in] | h4 | 4th address hexlet. |
[in] | h5 | 5th address hexlet. |
[in] | h6 | 6th address hexlet. |
[in] | h7 | 7th address hexlet. |
[in] | h8 | 8th address hexlet. |
void ts::IPAddress::setAddress6 | ( | uint64_t | net, |
uint64_t | ifid | ||
) |
Set the IP address from an IPv6 address as network prefix and interface identifier.
[in] | net | Network prefix. |
[in] | ifid | Interface identifier. |
void ts::IPAddress::setAddress | ( | const ::sockaddr & | a | ) |
Set the IP address from a system "struct sockaddr" structure (IPv4 or IPv6).
[in] | a | A system "struct sockaddr" structure. Note: the structure "sockaddr" is deprecated because it cannot hold an IPv6 socket address. The structure "sockaddr_storage" should be used instead. |
|
inline |
Set the IP address from a system "struct sockaddr_storage" structure (IPv4 or IPv6).
[in] | a | A system "struct sockaddr_storage" structure. |
void ts::IPAddress::setAddress4 | ( | const ::in_addr & | a | ) |
Set the IPv4 address from a system "struct in_addr" structure.
[in] | a | A system "struct in_addr" structure. |
void ts::IPAddress::setAddress4 | ( | const ::sockaddr_in & | a | ) |
Set the IPv4 address from a system "struct sockaddr_in" structure.
[in] | a | A system "struct sockaddr_in" structure. |
void ts::IPAddress::setAddress6 | ( | const ::in6_addr & | a | ) |
Set the IPv6 address from a system "struct in6_addr" structure.
[in] | a | A system "struct in6_addr" structure. |
void ts::IPAddress::setAddress6 | ( | const ::sockaddr_in6 & | a | ) |
Set the IPv6 address from a system "struct sockaddr_in6" structure.
[in] | a | A system "struct sockaddr_in6" structure. |
size_t ts::IPAddress::getAddress | ( | ::sockaddr_storage * | a, |
size_t | size, | ||
Port | port | ||
) | const |
Copy the address into a system "struct sockaddr_storage" structure (socket API).
Note: the structure "sockaddr" is deprecated because it cannot hold an IPv6 socket address. The structure "sockaddr_storage" should be used instead.
[out] | a | Address of a system socket address structure. |
[in] | size | Size in bytes of the system socket address structure. |
[in] | port | Port number for the socket address. |
void ts::IPAddress::getAddress4 | ( | ::sockaddr_in & | a, |
Port | port | ||
) | const |
Copy the IPv4 address into a system "struct sockaddr_in" structure (socket API).
[out] | a | A system "struct sockaddr_in" structure. |
[in] | port | Port number for the socket address. |
void ts::IPAddress::getAddress4 | ( | ::in_addr & | a | ) | const |
Copy the IPv4 address into a system "struct in_addr" structure (socket API).
[out] | a | A system "struct in_addr" structure. |
void ts::IPAddress::getAddress6 | ( | ::sockaddr_in6 & | a, |
Port | port | ||
) | const |
Copy the IPv6 address into a system "struct sockaddr_in6" structure (socket API).
[out] | a | A system "struct sockaddr_in6" structure. |
[in] | port | Port number for the socket address. |
void ts::IPAddress::getAddress6 | ( | ::in6_addr & | a | ) | const |
Copy the IPv6 address into a system "struct in6_addr" structure (socket API).
[out] | a | A system "struct in6_addr" structure. |
|
static |
Decode a host name and get all possible addresses for that host.
[out] | addresses | List of possible addresses for name. If name is a valid numerical addresse, only this one is returned. |
[in] | name | A string containing either a host name or a numerical representation of the address. |
[in,out] | report | Where to report errors. |
[in] | gen | IP generation of the returned address. Can be used to restrict the result to IPv4 or IPv6 addresses. Return all by default. |
|
virtualinherited |
Check if a port is set.
|
virtualinherited |
Get the port if there is one.
The default implementation returns AnyPort.
Reimplemented in ts::IPSocketAddress.
|
virtualinherited |
Set the port.
The default implementation does nothing.
[in] | port | The port number as an integer in host byte order. |
Reimplemented in ts::IPSocketAddress.
|
virtualinherited |
Clear the port.
The default implementatio sets the port to AnyPort