nl:: Inet:: InterfaceAddressIterator
#include <src/inet/InetInterface.h>
系统网络接口 IP 地址列表的迭代器。
摘要
使用此类的对象遍历系统网络接口的 IP 地址列表。
此类的单个实例上的方法不是线程安全的;但是,多个实例可以同时使用单独的实例。
在多线程 LwIP 系统上,相对于访问全局 LwIP 状态的其他线程,实例是安全的
在基于套接字的系统上,如果底层系统接口和/或地址发生变化,迭代将始终保持稳定。
在 LwIP 系统中,迭代保持不变,除非移除了与当前地址关联的接口(在此情况下,迭代可能会提前结束)。
构造函数和构造函数 |
|
---|---|
InterfaceAddressIterator(void)
构造 InterfaceAddressIterator 对象。
|
|
~InterfaceAddressIterator(void)
销毁 InterfaceAddressIterator 对象。
|
公共函数 |
|
---|---|
GetAddress(void)
|
获取当前的接口地址。
|
GetAddressWithPrefix(IPPrefix & addrWithPrefix)
|
void
返回包含当前地址地址和前缀长度的 IPPrefix。
|
GetIPv6PrefixLength(void)
|
uint8_t
已弃用
GetPrefixLength(void) 的别名 |
GetInterface(void)
|
InterfaceId
已弃用
GetInterfaceId(void) 的别名 |
GetInterfaceId(void)
|
InterfaceId
返回与当前接口地址关联的网络接口 ID。
|
GetInterfaceName(char *nameBuf, size_t nameBufSize)
|
获取与当前接口地址关联的网络接口的名称。
|
GetPrefixLength(void)
|
uint8_t
获取与当前接口地址关联的网络前缀。
|
HasBroadcastAddress(void)
|
bool
返回与当前接口地址关联的网络接口是否具有 IPv4 广播地址。
|
HasCurrent(void)
|
bool
|
IsUp(void)
|
bool
返回与当前接口地址关联的网络接口是否正常运行。
|
Next(void)
|
bool
将迭代器转到下一个接口地址。
|
SupportsMulticast(void)
|
bool
返回与当前接口地址关联的网络接口是否支持多播。
|
公共函数
GetAddress
IPAddress GetAddress( void )
GetAddressWithPrefix
void GetAddressWithPrefix( IPPrefix & addrWithPrefix )
返回包含当前地址地址和前缀长度的 IPPrefix。
GetInterfaceId
InterfaceId GetInterfaceId( void )
返回与当前接口地址关联的网络接口 ID。
详细信息 | |
---|---|
返回值 |
接口 ID 或
INET_NULL_INTERFACEID (如果迭代器位于地址列表的末尾之外)。 |
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.
详细信息 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回值 |
|
GetPrefixLength
uint8_t GetPrefixLength( void )
获取与当前接口地址关联的网络前缀。
On LwIP, this method simply returns the hard-coded constant 64. 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.
详细信息 | |
---|---|
返回值 |
网络前缀(以位为单位)或 0(如果迭代器位于地址列表的末尾之外)。
|
HasBroadcastAddress
bool HasBroadcastAddress( void )
返回与当前接口地址关联的网络接口是否具有 IPv4 广播地址。
详细信息 | |
---|---|
返回值 |
true 如果接口具有广播地址,则为 false ;否则,如果接口上未定位迭代器。 |
HasCurrent
bool HasCurrent( void )
InterfaceAddressIterator
InterfaceAddressIterator( void )
构造 InterfaceAddressIterator 对象。
在第一个网络地址处启动迭代器。在某些平台上,此构造函数可能会分配由析构函数回收的资源。
向上
bool IsUp( void )
返回与当前接口地址关联的网络接口是否正常运行。
详细信息 | |
---|---|
返回值 |
如果当前的网络接口已启动,则为
true ;如果未连接到网络,则为 false ,或者迭代器不在接口地址上。 |
下一步
bool Next( void )
将迭代器转到下一个接口地址。
Advances the iterator to the next interface address or to a position beyond the end of the address list. On LwIP, this method is thread-safe provided that: 1) other threads hold the LwIP core lock while mutating the netif list; and 2) netif objects themselves are never destroyed. Additionally, iteration on LwIP systems will terminate early if the current interface is removed from the list.
详细信息 | |
---|---|
返回值 |
false (如果超出结尾),否则为 true 。 |
支持多播
bool SupportsMulticast( void )
返回与当前接口地址关联的网络接口是否支持多播。
详细信息 | |
---|---|
返回值 |
如果支持多播,则返回
true ;如果不支持多播,则为 false ;或者如果迭代器不在接口地址上。 |
~InterfaceAddressIterator
~InterfaceAddressIterator( void )
销毁 InterfaceAddressIterator 对象。
回收由构造函数分配的所有资源。