nl::Inet::InterfaceIterator

#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

mIntfArray

struct if_nameindex * mIntfArray

mIntfFlags

short mIntfFlags

mIntfFlagsCached

bool mIntfFlagsCached

公用函式

GetInterface

InterfaceId GetInterface(
  void
)

已淘汰的 GetInterfaceId(void) 別名

GetInterfaceId

InterfaceId GetInterfaceId(
  void
)

傳回目前疊代器位置的網路介面 ID。

詳細說明
傳回值
INET_NULL_INTERFACEID
如果在清單結尾處更進一步
id
目前的網路介面 ID

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_INCORRECT_STATE
疊代器位於清單結尾以外的位置
INET_ERROR_NO_MEMORY
名稱過大,無法寫入緩衝區
other
其他系統或平台錯誤

HasBroadcastAddress

bool HasBroadcastAddress(
  void
)

傳回目前網路介面是否有廣播位址。

詳細說明
傳回
如果目前的網路介面有廣播位址,則為 true;如果不是,則為 false;或者疊代器位於清單結尾以外的位置。

HasCurrent

bool HasCurrent(
  void
)

測試疊代器是否在介面上。

測試疊代器是否在介面位址上。

詳細說明
傳回
如果疊代器位於介面上,則為 true;如果位於介面清單超出範圍時,則為 false
傳回
如果疊代器位於介面位址上,則為 true;如果位於地址清單結尾以外的位置,則為 false

InterfaceIterator

 InterfaceIterator(
  void
)

建構 InterfaceIterator 物件。

在第一個網路介面啟動疊代器。在部分平台上,這個建構函式可能會分配解構函式回收的資源。

IsUp

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

SupportsMulticast

bool SupportsMulticast(
  void
)

傳回目前的網路介面是否支援多點傳播。

詳細說明
傳回
如果目前的網路介面支援多點傳播,則為 true;如果疊代器位於清單結尾以外的位置,則為 false

~InterfaceIterator

 ~InterfaceIterator(
  void
)

刪除 InterfaceIterator 物件。

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

受保護的函式

GetFlags

short GetFlags(
  void
)

傳回目前介面的 ifr_flags 值。