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
数组
struct if_nameindex * mIntfArray
标志
short mIntfFlags
mintfFlagsCached
bool mIntfFlagsCached
公共职能
获取接口 ID
InterfaceId GetInterfaceId( void )
返回当前迭代器位置的网络接口 ID。
细节 | |||||
---|---|---|---|---|---|
返回值 |
|
获取接口名称
INET_ERROR GetInterfaceName( char *nameBuf, size_t nameBufSize )
获取当前网络接口的名称。
Writes the name of the network interface as \c NUL terminated text string at \c nameBuf.
细节 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
| ||||||||
返回值 |
|
有广播地址
bool HasBroadcastAddress( void )
返回当前网络接口是否有广播地址。
细节 | |
---|---|
退货 | true 如果当前网络接口都有一个广播地址, false ,如果没有,或者如果迭代定位超出了列表的末尾。 |
有电流
bool HasCurrent( void )
测试迭代器是否定位在接口上。
测试迭代器是否定位在接口地址上。
细节 | |
---|---|
退货 | true 如果迭代被定位在接口上; false 如果定位超出接口列表的末尾。 |
退货 | true 如果迭代被定位在接口地址; false 如果定位超出地址列表的末尾。 |
正在运行
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 。 |
支持组播
bool SupportsMulticast( void )
返回当前网络接口是否支持多播。
细节 | |
---|---|
退货 | true 如果当前网络接口支持组播, false 如果不是,或者如果迭代定位超出列表的末尾。 |
受保护的功能
获取标志
short GetFlags( void )
返回当前接口的 ifr_flags 值。