TSDuck Version 3.32-2820 (TSDuck - The MPEG Transport Stream Toolkit)
ts::AbstractNetworkAddress Class Referenceabstract

Abstract base class for all network address and socket address classes. More...

Inheritance diagram for ts::AbstractNetworkAddress:
Collaboration diagram for ts::AbstractNetworkAddress:

Public Types

typedef uint16_t Port
 The concept of port is used by TCP and UDP over IP networks.
 

Public Member Functions

virtual ~AbstractNetworkAddress () override
 Virtual destructor.
 
virtual size_t binarySize () const =0
 Get the maximum binary size for an address of that class. More...
 
virtual void clear ()
 Clear the object, address and port if there is any.
 
virtual void clearAddress ()=0
 Clear the address field.
 
virtual void clearPort ()
 Clear the port. More...
 
virtual size_t getAddress (void *addr, size_t size) const =0
 Get the network address as binary data. More...
 
virtual bool hasAddress () const =0
 Check if this object is set to a valid address. More...
 
virtual bool hasPort () const
 Check if a port is set. More...
 
virtual bool isMulticast () const =0
 Check if the address is a multicast address. More...
 
virtual Port port () const
 Get the port if there is one. More...
 
virtual bool resolve (const UString &name, Report &report)=0
 Decode a string containing a network address in family-specific format. More...
 
virtual bool setAddress (const void *addr, size_t size)=0
 Set the network address from binary data. More...
 
virtual void setPort (Port port)
 Set the port. More...
 
virtual UString toFullString () const
 Convert to a string object in numeric format without the default compaction. More...
 
virtual UString toString () const =0
 Convert to a string object. More...
 

Static Public Attributes

static const Port AnyPort = 0
 Wildcard integer value for "any port" or "no port".
 

Detailed Description

Abstract base class for all network address and socket address classes.

For each family (IPv4, IPv6, MAC), there is a binary representation of the address (4, 16 or 7 bytes). In the IP families, socket addresses are subclasses of the address class, with the addition of a "port" value.

Member Function Documentation

◆ binarySize()

virtual size_t ts::AbstractNetworkAddress::binarySize ( ) const
pure virtual

Get the maximum binary size for an address of that class.

Returns
The maximum binary size for an address of that class.

Implemented in ts::MACAddress, ts::IPv6Address, and ts::IPv4Address.

◆ hasAddress()

virtual bool ts::AbstractNetworkAddress::hasAddress ( ) const
pure virtual

Check if this object is set to a valid address.

Returns
True if this object is set to a valid address, false otherwise.

Implemented in ts::MACAddress, ts::IPv6Address, and ts::IPv4Address.

◆ getAddress()

virtual size_t ts::AbstractNetworkAddress::getAddress ( void *  addr,
size_t  size 
) const
pure virtual

Get the network address as binary data.

Parameters
[out]addrAddress of binary buffer to receive binary data.
[in]sizeSize in bytes of buffer.
Returns
Number of copied bytes on success, zero on error (data too short).

Implemented in ts::MACAddress, ts::IPv6Address, and ts::IPv4Address.

◆ setAddress()

virtual bool ts::AbstractNetworkAddress::setAddress ( const void *  addr,
size_t  size 
)
pure virtual

Set the network address from binary data.

Parameters
[in]addrAddress of binary data.
[in]sizeSize in bytes of binary data.
Returns
True on success, false on error (data too short).

Implemented in ts::MACAddress, ts::IPv6Address, and ts::IPv4Address.

◆ isMulticast()

virtual bool ts::AbstractNetworkAddress::isMulticast ( ) const
pure virtual

Check if the address is a multicast address.

Returns
True if the address is a multicast address, false otherwise.

Implemented in ts::MACAddress, ts::IPv6Address, and ts::IPv4Address.

◆ hasPort()

virtual bool ts::AbstractNetworkAddress::hasPort ( ) const
virtual

Check if a port is set.

Returns
True if port is set.

◆ port()

virtual Port ts::AbstractNetworkAddress::port ( ) const
virtual

Get the port if there is one.

The default implementation returns AnyPort.

Returns
The port number or AnyPort if there is none.

Reimplemented in ts::IPv6SocketAddress, and ts::IPv4SocketAddress.

◆ setPort()

virtual void ts::AbstractNetworkAddress::setPort ( Port  port)
virtual

Set the port.

The default implementation does nothing.

Parameters
[in]portThe port number as an integer in host byte order.

Reimplemented in ts::IPv6SocketAddress, and ts::IPv4SocketAddress.

◆ clearPort()

virtual void ts::AbstractNetworkAddress::clearPort ( )
virtual

Clear the port.

The default implementatio sets the port to AnyPort

◆ resolve()

virtual bool ts::AbstractNetworkAddress::resolve ( const UString name,
Report report 
)
pure virtual

Decode a string containing a network address in family-specific format.

Parameters
[in]nameA string containing either a host name or a numerical representation of the address.
[in]reportWhere to report errors.
Returns
True if name was successfully resolved, false otherwise. In the later case, the address is invalidated.

Implemented in ts::MACAddress, ts::IPv6SocketAddress, ts::IPv6Address, ts::IPv4SocketAddress, and ts::IPv4Address.

◆ toFullString()

virtual UString ts::AbstractNetworkAddress::toFullString ( ) const
virtual

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().

Returns
This object, converted as a string.

Reimplemented in ts::IPv6SocketAddress, and ts::IPv6Address.

◆ toString()


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