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

公共职能

获取接口

InterfaceId GetInterface(
  void
)

对于弃用别名GetInterfaceId(void)

获取接口 ID

InterfaceId GetInterfaceId(
  void
)

返回当前迭代器位置的网络接口 ID。

细节
返回值
INET_NULL_INTERFACEID
如果超出列表末尾。
id
当前网络接口 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.

细节
参数
[in] nameBuf
写入接口名称的内存区域
[in] nameBufSize
由表示的区域的大小nameBuf
返回值
INET_NO_ERROR
结果成功,接口名称写入
INET_ERROR_INCORRECT_STATE
迭代器位于列表末尾之外
INET_ERROR_NO_MEMORY
名称太大而无法写入缓冲区
other
另一个系统或平台错误

有广播地址

bool HasBroadcastAddress(
  void
)

返回当前网络接口是否有广播地址。

细节
退货
true如果当前网络接口都有一个广播地址, false ,如果没有,或者如果迭代定位超出了列表的末尾。

有电流

bool HasCurrent(
  void
)

测试迭代器是否定位在接口上。

测试迭代器是否定位在接口地址上。

细节
退货
true如果迭代被定位在接口上; false如果定位超出接口列表的末尾。
退货
true如果迭代被定位在接口地址; false如果定位超出地址列表的末尾。

接口迭代器

 InterfaceIterator(
  void
)

构造一个InterfaceIterator对象。

在第一个网络接口启动迭代器。在某些平台上,此构造函数可能会分配由析构函数回收的资源。

正在运行

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如果不是,或者如果迭代定位超出列表的末尾。

~接口迭代器

 ~InterfaceIterator(
  void
)

销毁一个InterfaceIterator对象。

回收构造函数分配的任何资源。

受保护的功能

获取标志

short GetFlags(
  void
)

返回当前接口的 ifr_flags 值。