TSDuck v3.38-3696
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::AbstractNetworkAddress Class Referenceabstract

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

#include <tsAbstractNetworkAddress.h>

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

Public Types

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

Public Member Functions

 AbstractNetworkAddress ()=default
 Default constructor.
 
virtual size_t binarySize () const =0
 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 ()=0
 Clear the address field.
 
virtual void clearPort ()
 Clear the port.
 
virtual size_t getAddress (void *addr, size_t size) const =0
 Get the network address as binary data.
 
virtual bool hasAddress () const =0
 Check if this object is set to a valid address.
 
virtual bool hasPort () const
 Check if a port is set.
 
virtual bool isMulticast () const =0
 Check if the address is a multicast address.
 
virtual Port port () const
 Get the port if there is one.
 
virtual bool resolve (const UString &name, Report &report)=0
 Decode a string containing a network address in family-specific format.
 
virtual bool setAddress (const void *addr, size_t size)=0
 Set the network address from binary data.
 
virtual void setPort (Port port)
 Set the port.
 
virtual UString toFullString () const
 Convert to a string object in numeric format without the default compaction.
 
virtual UString toString () const =0
 Convert to a string object.
 

Static Public Attributes

static constexpr 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::IPv4Address, ts::IPv6Address, and ts::MACAddress.

◆ 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::IPv4Address, ts::IPv6Address, and ts::MACAddress.

◆ 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::IPv4Address, ts::IPv6Address, and ts::MACAddress.

◆ 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::IPv4Address, ts::IPv6Address, and ts::MACAddress.

◆ clearAddress()

virtual void ts::AbstractNetworkAddress::clearAddress ( )
pure virtual

Clear the address field.

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

◆ 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::IPv4Address, ts::IPv6Address, and ts::MACAddress.

◆ 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::IPv4SocketAddress, and ts::IPv6SocketAddress.

◆ 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::IPv4SocketAddress, and ts::IPv6SocketAddress.

◆ 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::IPv4Address, ts::IPv4SocketAddress, ts::IPv6Address, ts::IPv6SocketAddress, and ts::MACAddress.

◆ 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::IPv6Address, and ts::IPv6SocketAddress.

◆ toString()


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