TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
IP v6 socket address class (IP v6 address & port). More...
#include <tsIPv6SocketAddress.h>
Public Types | |
using | Port = uint16_t |
The concept of port is used by TCP and UDP over IP networks. | |
Public Member Functions | |
IPv6SocketAddress ()=default | |
Default constructor. | |
IPv6SocketAddress (const ByteBlock &bb, uint16_t port=AnyPort) | |
Constructor from 16 bytes address and optional port. | |
IPv6SocketAddress (const IPv6Address &addr, uint16_t port=AnyPort) | |
Constructor from an IPv6 address and optional port. | |
IPv6SocketAddress (const uint8_t *addr, size_t size, uint16_t port=AnyPort) | |
Constructor from 16 bytes address and optional port. | |
IPv6SocketAddress (const UString &name, Report &report) | |
Constructor from a string "[addr]:port". | |
IPv6SocketAddress (uint16_t h1, uint16_t h2, uint16_t h3, uint16_t h4, uint16_t h5, uint16_t h6, uint16_t h7, uint16_t h8, uint16_t port=AnyPort) | |
Constructor from 8 hexlets and optional port. | |
IPv6SocketAddress (uint64_t net, uint64_t ifid, uint16_t port=AnyPort) | |
Constructor from network prefix and interface identifier. | |
virtual size_t | binarySize () const override |
Get the maximum binary size for an address of that class. | |
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. | |
virtual const UChar * | familyName () const override |
Get a human-readable family name for an address of that class. | |
void | getAddress (ByteBlock &bb) const |
Get the IP address as a byte block. | |
virtual size_t | getAddress (void *addr, size_t size) const override |
Get the network address as binary data. | |
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 | hexlet (size_t i) const |
Get one of the 16-bit hexlets in the address. | |
uint64_t | interfaceIdentifier () const |
Get the interface identifier (64 least significant bits) of the IPv6 address. | |
virtual bool | isMulticast () const override |
Check if the address is a multicast address. | |
bool | match (const IPv6Address &other) const |
Check if this address "matches" another one. | |
bool | match (const IPv6SocketAddress &other) const |
Check if this socket address "matches" another one. | |
uint64_t | networkPrefix () const |
Get the network prefix (64 most significant bits) of the IPv6 address. | |
bool | operator< (const IPv6Address &other) const |
Comparison "less than" operator. | |
bool | operator< (const IPv6SocketAddress &other) const |
Comparison "less than" operator. | |
bool | operator== (const IPv6Address &other) const |
Equality operator. | |
bool | operator== (const IPv6SocketAddress &other) const |
Equality operator. | |
virtual Port | port () const override |
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 | set (const ByteBlock &bb, uint16_t port) |
Set the socket address from 16 bytes and port. | |
void | set (const uint8_t *addr, size_t size, uint16_t port) |
Set the socket address from 16 bytes andport. | |
void | set (uint16_t h1, uint16_t h2, uint16_t h3, uint16_t h4, uint16_t h5, uint16_t h6, uint16_t h7, uint16_t h8, uint16_t port) |
Set the socket address from 8 hexlets and port. | |
void | set (uint64_t net, uint64_t ifid, uint16_t port) |
Set the socket address from network prefix and interface identifier and port. | |
void | setAddress (const ByteBlock &bb) |
Set the IP address from 16 bytes. | |
virtual bool | setAddress (const void *addr, size_t size) override |
Set the network address from binary data. | |
void | setAddress (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 8 hexlets. | |
void | setAddress (uint64_t net, uint64_t ifid) |
Set the IP address from network prefix and interface identifier. | |
virtual void | setPort (Port port) override |
Set the port. | |
ByteBlock | toBytes () const |
Get the IP address as a byte block. | |
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 Attributes | |
static const IPv6Address | AnyAddress |
Wildcard integer value for "any IP address". | |
static constexpr Port | AnyPort = 0 |
Wildcard integer value for "any port" or "no port". | |
static const IPv6SocketAddress | AnySocketAddress |
Wildcard socket address, unspecified address and port. | |
static constexpr size_t | BITS = 128 |
Size in bits of an IPv6 address. | |
static constexpr size_t | BYTES = 16 |
Size in bytes of an IPv6 address. | |
static const IPv6Address | LocalHost |
Local host address (::1). | |
IP v6 socket address class (IP v6 address & port).
The string representation is "[addr]:port". In the template string "[addr]:port", the square brackets do not mean that "addr" is optional. According to IPv6 URL representation, the square brackets are actual characters in the string. The address and port fields are optional. If the address is specified alone, without port, the square brackets may be omitted.
|
inline |
Constructor from an IPv6 address and optional port.
[in] | addr | The IPv6 address. |
[in] | port | The port number as an integer in host byte order. |
|
inline |
Constructor from 16 bytes address and optional port.
[in] | addr | Address of the memory area containing the IPv6 bytes. |
[in] | size | Size of the memory area. If the size is shorter than 16, the IPv6 is padded on the left (most significant bytes) with zeroes. If the size is larger than 16, extra bytes are ignored. |
[in] | port | The port number as an integer in host byte order. |
Constructor from 16 bytes address and optional port.
[in] | bb | Byte block containing the IPv6 bytes. If the size is shorter than 16, the IPv6 is padded on the left (most significant bytes) with zeroes. If the size is larger than 16, extra bytes are ignored. |
[in] | port | The port number as an integer in host byte order. |
|
inline |
Constructor from 8 hexlets and optional port.
[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] | port | The port number as an integer in host byte order. |
|
inline |
Constructor from network prefix and interface identifier.
[in] | net | Network prefix. |
[in] | ifid | Interface identifier. |
[in] | port | The port number as an integer in host byte order. |
Constructor from a string "[addr]:port".
[in] | name | A string containing either a host name or a numerical representation of the address and optional port. In case of error, the integer value of the address is set to AnyAddress and port to AnyPort. |
[in] | report | Where to report errors. |
Get the port if there is one.
The default implementation returns AnyPort.
Reimplemented from ts::AbstractNetworkAddress.
Set the port.
The default implementation does nothing.
[in] | port | The port number as an integer in host byte order. |
Reimplemented from ts::AbstractNetworkAddress.
|
overridevirtual |
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. |
Reimplemented from ts::IPv6Address.
Convert to a string object.
Reimplemented from ts::IPv6Address.
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::IPv6Address.
|
inline |
Set the socket address from 16 bytes andport.
[in] | addr | Address of the memory area containing the IPv6 bytes. |
[in] | size | Size of the memory area. If the size is shorter than 16, the IPv6 is padded on the left (most significant bytes) with zeroes. If the size is larger than 16, extra bytes are ignored. |
[in] | port | The port number as an integer in host byte order. |
|
inline |
Set the socket address from 16 bytes and port.
[in] | bb | Byte block containing the IPv6 bytes. If the size is shorter than 16, the IPv6 is padded on the left (most significant bytes) with zeroes. If the size is larger than 16, extra bytes are ignored. |
[in] | port | The port number as an integer in host byte order. |
|
inline |
Set the socket address from 8 hexlets and port.
[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] | port | The port number as an integer in host byte order. |
|
inline |
Set the socket address from network prefix and interface identifier and port.
[in] | net | Network prefix. |
[in] | ifid | Interface identifier. |
[in] | port | The port number as an integer in host byte order. |
bool ts::IPv6SocketAddress::match | ( | const IPv6SocketAddress & | other | ) | const |
Check if this socket address "matches" another one.
[in] | other | Another instance to compare. |
|
inline |
Equality operator.
[in] | other | Another instance to compare with. |
bool ts::IPv6SocketAddress::operator< | ( | const IPv6SocketAddress & | 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. |
Get the maximum binary size for an address of that class.
Implements ts::AbstractNetworkAddress.
Get a human-readable family name for an address of that class.
This is typically something like "IPv4" or "IPv6".
Implements ts::AbstractNetworkAddress.
Check if this object is set to a valid address.
Implements ts::AbstractNetworkAddress.
|
overridevirtualinherited |
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.
Get the IP address as a byte block.
[out] | bb | Byte block containing the IPv6 bytes. |
|
overridevirtualinherited |
Set the network address from binary data.
[in] | addr | Address of binary data. |
[in] | size | Size in bytes of binary data. |
Implements ts::AbstractNetworkAddress.
Set the IP address from 16 bytes.
[in] | bb | Byte block containing the IPv6 bytes. If the size is shorter than 16, the IPv6 is padded on the left (most significant bytes) with zeroes. If the size is larger than 16, extra bytes are ignored. |
|
inherited |
Set the IP 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. |
|
inherited |
Set the IP address from network prefix and interface identifier.
[in] | net | Network prefix. |
[in] | ifid | Interface identifier. |
Clear the address field.
Implements ts::AbstractNetworkAddress.
Check if the address is a multicast address.
Implements ts::AbstractNetworkAddress.
|
inlineinherited |
Get the network prefix (64 most significant bits) of the IPv6 address.
|
inlineinherited |
Get the interface identifier (64 least significant bits) of the IPv6 address.
|
inherited |
Get one of the 16-bit hexlets in the address.
[in] | i | Hexlet index, from 0 to 7. |
|
inherited |
Check if this address "matches" another one.
[in] | other | Another instance to compare. |
|
inlineinherited |
Get the IP address as a byte block.
|
inlineinherited |
Equality operator.
[in] | other | Another instance to compare with. |
|
inlineinherited |
Comparison "less than" operator.
It does not really makes sense. Only defined to allow usage in containers.
[in] | other | Other instance to compare. |
Check if a port is set.
Clear the port.
The default implementatio sets the port to AnyPort
|
staticinherited |
Local host address (::1).
Usually resolves to the host name "localhost".