nl::Inet::InterfaceAddressIterator

#include <src/inet/InetInterface.h>

Iterator for the list of system network interface IP addresses.

Summary

Use objects of this class to iterate the list of system network interface interface IP addresses.

On LwIP systems, it is recommended that the LwIP stack lock be acquired and not released over the entire lifetime of an object of this class.

Constructors and Destructors

InterfaceAddressIterator(void)
Conventional default constructor.
~InterfaceAddressIterator(void)
Non-virtual destructor.

Public functions

GetAddress(void)
Extract the current interface IP address.
GetIPv6PrefixLength(void)
uint8_t
Extract the length of the subnet prefix for the current network interface IPv6 address.
GetInterface(void)
InterfaceId
Extract the indicator of the network interface for the current IP address.
HasCurrent(void) const
bool
Test whether the cursor has not yet advanced beyond the end.
Next(void)
bool
Advance the cursor to the next network interface IP address.
SupportsMulticast(void)
bool
Inspect whether the interface for the current IP address supports multicast.

Public functions

GetAddress

IPAddress GetAddress(
  void
)

Extract the current interface IP address.

On LwIP, this method must be called with the LwIP stack lock acquired.

Details
Returns
The current interface IP address, or IPAddress::Any if advanced beyond the end of the list.

GetIPv6PrefixLength

uint8_t GetIPv6PrefixLength(
  void
)

Extract the length of the subnet prefix for the current network interface IPv6 address.

On LwIP, this method simply returns the hard-coded constant 64.

Details
Returns
length of the subnet prefix for the current IPv6 address, or zero if the current address is IPv4 or the iterator has advanced beyond the end of the list.

Note Well: the standard subnet prefix on all links other than PPP links is 64 bits. On PPP links and some non-broadcast multipoint access links, the convention is either 127 bits or 128 bits, but it might be something else. On most platforms, the system's interface address structure can represent arbitrary prefix lengths between 0 and 128.

GetInterface

InterfaceId GetInterface(
  void
)

Extract the indicator of the network interface for the current IP address.

On LwIP, this method must be called with the LwIP stack lock acquired.

Details
Return Values
INET_NULL_INTERFACEID
if advanced beyond the end of the list.
id
the indicator of the current interface.

HasCurrent

bool HasCurrent(
  void
) const 

Test whether the cursor has not yet advanced beyond the end.

On LwIP, this method must be called with the LwIP stack lock acquired.

Details
Returns
false if advanced beyond the end, else true.

InterfaceAddressIterator

 InterfaceAddressIterator(
  void
)

Conventional default constructor.

Starts the cursor at the first network interface. On some platforms, this constructor may allocate resources recycled by the destructor.

On LwIP, this constructor must be called with the LwIP stack lock acquired.

Next

bool Next(
  void
)

Advance the cursor to the next network interface IP address.

Advances the internal cursor either to the next network interface address or to the distinguished position corresponding to no further interface addresses.

Details
Returns
false if advanced beyond the end, else true.

On LwIP, this method must be called with the LwIP stack lock acquired.

SupportsMulticast

bool SupportsMulticast(
  void
)

Inspect whether the interface for the current IP address supports multicast.

On LwIP, this method must be called with the LwIP stack lock acquired.

Details
Returns
false if the current interface does not support multicast or the iterator has advanced beyond the end of the list, else true.

~InterfaceAddressIterator

 ~InterfaceAddressIterator(
  void
)

Non-virtual destructor.

Recycles any resources allocated by the constructor.

On LwIP, this destructor must be called with the LwIP stack lock acquired.