nl::
  #include <src/inet/InetInterface.h>
  系统网络接口列表的迭代器。
摘要
使用此类的对象来迭代系统网络接口的列表。
此类的各个实例上的方法不是线程安全的;不过,多个线程可以同时使用单独的实例。
在多线程 LwIP 系统中,相对于访问全局 LwIP 状态的其他线程,实例是线程安全的,前提是其他线程在更改 netif 列表时持有 LwIP 核心锁,并且该 netif 对象本身永远不会被销毁。
在基于套接字的系统上,当底层系统的接口发生更改时,迭代始终是稳定的。
在 LwIP 系统中,迭代是稳定的,但以下情况除外:当前选定的接口从列表中移除。在这种情况下,迭代会立即结束。
| 构造函数和析构函数 | |
|---|---|
| InterfaceIterator(void)构造一个 InterfaceIterator 对象。 | |
| ~InterfaceIterator(void)销毁 InterfaceIterator 对象。 | 
| 受保护的属性 | |
|---|---|
| mCurIntf | size_t | 
| mCurNetif | struct netif * | 
| mIntfArray | struct if_nameindex * | 
| mIntfFlags | short | 
| mIntfFlagsCached | bool | 
| 公共函数 | |
|---|---|
| GetInterface(void) | InterfaceId已弃用的  GetInterfaceId(void)别名 | 
| GetInterfaceId(void) | InterfaceId返回当前迭代器位置的网络接口 ID。 | 
| GetInterfaceName(char *nameBuf, size_t nameBufSize) | 获取当前网络接口的名称。 | 
| HasBroadcastAddress(void) | bool返回当前网络接口是否具有广播地址的指示值。 | 
| HasCurrent(void) | bool测试迭代器是否位于接口上。 | 
| IsUp(void) | bool返回当前网络接口是否已启动的指示值。 | 
| Next(void) | bool将迭代器前进到下一个网络接口。 | 
| SupportsMulticast(void) | bool返回当前网络接口是否支持多播的指示。 | 
| 受保护的函数 | |
|---|---|
| GetFlags(void) | short返回当前接口的 ifr_flags 值。 | 
受保护的属性
mCurIntf
size_t mCurIntf
mCurNetif
struct netif * mCurNetif
mIntfArray
struct if_nameindex * mIntfArray
mIntfFlags
short mIntfFlags
mIntfFlagsCached
bool mIntfFlagsCached
公共函数
GetInterfaceId
InterfaceId GetInterfaceId( void )
返回当前迭代器位置的网络接口 ID。
| 详细信息 | |||||
|---|---|---|---|---|---|
| 返回值 | 
 | ||||
GetInterfaceName
INET_ERROR GetInterfaceName( char *nameBuf, size_t nameBufSize )
获取当前网络接口的名称。
Writes the name of the network interface as \c NUL terminated text string at \c nameBuf.
| 详细信息 | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| 参数 | 
 | ||||||||
| 返回值 | 
 | ||||||||
HasBroadcastAddress
bool HasBroadcastAddress( void )
返回当前网络接口是否具有广播地址的指示值。
| 详细信息 | |
|---|---|
| 返回值 | 如果当前网络接口具有广播地址,则为  true;如果没有,或者迭代器的位置超出列表末尾,则为false。 | 
HasCurrent
bool HasCurrent( void )
测试迭代器是否位于接口上。
测试迭代器是否位于接口地址上。
| 详细信息 | |
|---|---|
| 返回值 | 如果迭代器位于接口上,则为  true;如果位置超出接口列表的末尾,则为false。 | 
| 返回值 | 如果迭代器位于接口地址上,则为  true;如果位置在地址列表的末尾之外,则为false。 | 
InterfaceIterator
InterfaceIterator( void )
构造一个 InterfaceIterator 对象。
在第一个网络接口上启动迭代器。在某些平台上,此构造函数可能会分配由析构函数回收的资源。
IsUp
bool IsUp( void )
返回当前网络接口是否已启动的指示值。
| 详细信息 | |
|---|---|
| 返回值 | 如果当前网络接口已打开,则为  true;否则为false,或者迭代器的位置超出了列表末尾。 | 
下一步
bool Next( void )
将迭代器前进到下一个网络接口。
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.
| 详细信息 | |
|---|---|
| 返回值 | 如果超过结束位置,则为  false,否则为true。 | 
SupportsMulticast
bool SupportsMulticast( void )
返回当前网络接口是否支持多播的结果。
| 详细信息 | |
|---|---|
| 返回值 | 如果当前网络接口支持多播,则为  true;如果不支持多播,则为false,或者迭代器的位置超出了列表末尾。 | 
受保护的函数
GetFlags
short GetFlags( void )
返回当前接口的 ifr_flags 值。