nl:: Inet:: InterfaceIterator
#include <src/inet/InetInterface.h>
Iterator for the list of system network interfaces.
Summary
Use objects of this class to iterate the list of system network interfaces.
Methods on an individual instance of this class are not thread-safe; however separate instances may be used simultaneously by multiple threads.
On multi-threaded LwIP systems, instances are thread-safe relative to other threads accessing the global LwIP state provided that the other threads hold the LwIP core lock while mutating the list of netifs, and that netif object themselves are never destroyed.
On sockets-based systems, iteration is always stable in the face of changes to the underlying system's interfaces.
On LwIP systems, iteration is stable except in the case where the currently selected interface is removed from the list, in which case iteration ends immediately.
Constructors and Destructors |
|
---|---|
InterfaceIterator(void)
Constructs an InterfaceIterator object.
|
|
~InterfaceIterator(void)
Destroys an InterfaceIterator object.
|
Protected attributes |
|
---|---|
mCurIntf
|
size_t
|
mCurNetif
|
struct netif *
|
mIntfArray
|
struct if_nameindex *
|
mIntfFlags
|
short
|
mIntfFlagsCached
|
bool
|
Public functions |
|
---|---|
GetInterface(void)
|
InterfaceId
Deprecated alias for
GetInterfaceId(void) |
GetInterfaceId(void)
|
InterfaceId
Returns the network interface id at the current iterator position.
|
GetInterfaceName(char *nameBuf, size_t nameBufSize)
|
Get the name of the current network interface.
|
HasBroadcastAddress(void)
|
bool
Returns whether the current network interface has a broadcast address.
|
HasCurrent(void)
|
bool
Test whether the iterator is positioned on an interface.
|
IsUp(void)
|
bool
Returns whether the current network interface is up.
|
Next(void)
|
bool
Advance the iterator to the next network interface.
|
SupportsMulticast(void)
|
bool
Returns whether the current network interface supports multicast.
|
Protected functions |
|
---|---|
GetFlags(void)
|
short
Returns the ifr_flags value for the current interface.
|
Protected attributes
mCurIntf
size_t mCurIntf
mCurNetif
struct netif * mCurNetif
mIntfArray
struct if_nameindex * mIntfArray
mIntfFlags
short mIntfFlags
mIntfFlagsCached
bool mIntfFlagsCached
Public functions
GetInterfaceId
InterfaceId GetInterfaceId( void )
Returns the network interface id at the current iterator position.
Details | |||||
---|---|---|---|---|---|
Return Values |
|
GetInterfaceName
INET_ERROR GetInterfaceName( char *nameBuf, size_t nameBufSize )
Get the name of the current network interface.
Writes the name of the network interface as \c NUL terminated text string at \c nameBuf.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
HasBroadcastAddress
bool HasBroadcastAddress( void )
Returns whether the current network interface has a broadcast address.
Details | |
---|---|
Returns |
true if current network interface has a broadcast address, false if not, or if the iterator is positioned beyond the end of the list. |
HasCurrent
bool HasCurrent( void )
Test whether the iterator is positioned on an interface.
Test whether the iterator is positioned on an interface address.
Details | |
---|---|
Returns |
true if the iterator is positioned on an interface; false if positioned beyond the end of the interface list. |
Returns |
true if the iterator is positioned on an interface address; false if positioned beyond the end of the address list. |
InterfaceIterator
InterfaceIterator( void )
Constructs an InterfaceIterator object.
Starts the iterator at the first network interface. On some platforms, this constructor may allocate resources recycled by the destructor.
IsUp
bool IsUp( void )
Returns whether the current network interface is up.
Details | |
---|---|
Returns |
true if current network interface is up, false if not or if the iterator is positioned beyond the end of the list. |
Next
bool Next( void )
Advance the iterator to the next network interface.
Advances the internal iterator to the next network interface or to a position beyond the end of the interface list. On multi-threaded LwIP systems, this method is thread-safe relative to other threads accessing the global LwIP state provided that: 1) the other threads hold the LwIP core lock while mutating the list of netifs; and 2) netif objects themselves are never destroyed. Iteration is stable in the face of changes to the underlying system's interfaces, *except* in the case of LwIP systems when the currently selected interface is removed from the list, which causes iteration to end immediately.
Details | |
---|---|
Returns |
false if advanced beyond the end, else true . |
SupportsMulticast
bool SupportsMulticast( void )
Returns whether the current network interface supports multicast.
Details | |
---|---|
Returns |
true if current network interface supports multicast, false if not, or if the iterator is positioned beyond the end of the list. |
~InterfaceIterator
~InterfaceIterator( void )
Destroys an InterfaceIterator object.
Recycles any resources allocated by the constructor.
Protected functions
GetFlags
short GetFlags( void )
Returns the ifr_flags value for the current interface.