TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
A basic representation of an IPv6 address. More...
#include <tsIPv6Address.h>
Public Types | |
using | Port = uint16_t |
The concept of port is used by TCP and UDP over IP networks. | |
Public Member Functions | |
IPv6Address () | |
Default constructor. | |
IPv6Address (const ByteBlock &bb) | |
Constructor from 16 bytes. | |
IPv6Address (const uint8_t *addr, size_t size) | |
Constructor from 16 bytes. | |
IPv6Address (const UString &name, Report &report) | |
Constructor from a string in standard IPv6 numerical format. | |
IPv6Address (uint16_t h1, uint16_t h2, uint16_t h3, uint16_t h4, uint16_t h5, uint16_t h6, uint16_t h7, uint16_t h8) | |
Constructor from 8 hexlets. | |
IPv6Address (uint64_t net, uint64_t ifid) | |
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. | |
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 IPv6Address &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 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) |
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 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). | |
A basic representation of an IPv6 address.
An IPv6 address is made of 128 bits (16 bytes). It can be manipulated as
This class is incomplete. Currently, it does not allow IPv6 networking. It is only designed to manipulate IPv6 addresses in DVB signalization.
|
inline |
Default constructor.
The default value is AnyAddress.
|
inline |
Constructor from 16 bytes.
[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. |
|
inline |
Constructor 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. |
|
inline |
Constructor 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. |
|
inline |
Constructor from network prefix and interface identifier.
[in] | net | Network prefix. |
[in] | ifid | Interface identifier. |
Constructor from a string in standard IPv6 numerical format.
If name cannot be resolved, the address is set to AnyAddress.
[in] | name | A string containing a string in standard IPv6 numerical format. |
[in] | report | Where to report errors. |
|
overridevirtual |
Get the maximum binary size 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::IPv6SocketAddress.
|
overridevirtual |
Convert to a string object.
Implements ts::StringifyInterface.
Reimplemented in ts::IPv6SocketAddress.
|
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::IPv6SocketAddress.
|
inline |
Get the IP address as a byte block.
[out] | bb | Byte block containing the IPv6 bytes. |
|
inline |
Get the network prefix (64 most significant bits) of the IPv6 address.
|
inline |
Get the interface identifier (64 least significant bits) of the IPv6 address.
uint16_t ts::IPv6Address::hexlet | ( | size_t | i | ) | const |
Get one of the 16-bit hexlets in the address.
[in] | i | Hexlet index, from 0 to 7. |
|
inline |
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. |
void ts::IPv6Address::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.
[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::IPv6Address::setAddress | ( | uint64_t | net, |
uint64_t | ifid | ||
) |
Set the IP address from network prefix and interface identifier.
[in] | net | Network prefix. |
[in] | ifid | Interface identifier. |
bool ts::IPv6Address::match | ( | const IPv6Address & | other | ) | const |
Check if this address "matches" another one.
[in] | other | Another instance to compare. |
|
inline |
Get the IP address as a byte block.
|
inline |
Equality operator.
[in] | other | Another instance to compare with. |
|
inline |
Comparison "less than" operator.
It does not really makes sense. Only defined to allow usage in containers.
[in] | other | Other instance to compare. |
|
virtualinherited |
Check if a port is set.
|
virtualinherited |
Get the port if there is one.
The default implementation returns AnyPort.
Reimplemented in ts::IPv4SocketAddress, and ts::IPv6SocketAddress.
|
virtualinherited |
Set the port.
The default implementation does nothing.
[in] | port | The port number as an integer in host byte order. |
Reimplemented in ts::IPv4SocketAddress, and ts::IPv6SocketAddress.
|
virtualinherited |
Clear the port.
The default implementatio sets the port to AnyPort
|
static |
Local host address (::1).
Usually resolves to the host name "localhost".