nl:: Inet:: InterfaceAddressIterator
#include <src/inet/InetInterface.h>
系统网络接口 IP 地址列表的迭代器。
摘要
使用此类的对象可迭代系统网络接口 IP 地址的列表。
此类的单个实例上的方法不是线程安全的;但是多个线程可以同时使用单独的实例。
在多线程 LwIP 系统中,相对于访问全局 LwIP 状态的其他线程而言,实例是线程安全的:1) 其他线程持有 LwIP 核心锁,同时更改 netif 列表;2) netif 对象本身永远不会被销毁。
在基于套接字的系统上,面对底层系统的接口和/或地址更改,迭代会始终保持稳定。
在 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 对象。
在第一个网络地址处启动迭代器。在某些平台上,此构造函数可能会分配析构函数回收的资源。
IsUp
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 。 |
SupportsMulticast
bool SupportsMulticast( void )
返回与当前接口地址关联的网络接口是否支持多播。
具体说明 | |
---|---|
返回值 |
如果支持多播,则为
true ;如果不支持,或者迭代器未放置在接口地址上,则为 false 。 |
~InterfaceAddressIterator
~InterfaceAddressIterator( void )
销毁 InterfaceAddressIterator 对象。
回收由构造函数分配的任何资源。