nl::Inet::InterfaceAddressIterator

#include <src/inet/InetInterface.h>

系統網路介面 IP 位址清單的疊代器。

摘要

使用此類別的物件以疊代系統網路介面 IP 位址的清單。

對此類別的個別執行個體方法「並非」安全執行緒,但不同的執行個體可由多個執行緒同時使用。

在多執行緒 LwIP 系統中,執行個體為執行緒安全 (與其他存取全域 LwIP 狀態的執行緒相比):1) 其他執行緒在異動 Netifs 清單時會保留 LwIP 核心鎖定;以及 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
)

取得目前的介面位址。

詳細說明
傳回
目前的介面位址;如果疊代器位於地址清單結尾以外的位置,則為 IPAddress::Any

GetAddressWithPrefix

void GetAddressWithPrefix(
  IPPrefix & addrWithPrefix
)

傳回包含目前位址位址和前置字串長度的 IPPrefix

GetIPv6PrefixLength

uint8_t GetIPv6PrefixLength(
  void
)

已淘汰的 GetPrefixLength(void) 別名

GetInterface

InterfaceId GetInterface(
  void
)

已淘汰的 GetInterfaceId(void) 別名

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.

詳細說明
參數
[in] nameBuf
寫入介面名稱的記憶體區域
[in] nameBufSize
nameBuf 表示的區域大小
傳回值
INET_NO_ERROR
成功的結果,已寫入介面名稱
INET_ERROR_NO_MEMORY
名稱過大,無法寫入緩衝區
INET_ERROR_INCORRECT_STATE
疊代器目前不在介面位址上
other
其他系統或平台錯誤

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 物件。

回收建構函式分配的任何資源。