UDP
這個模組包含用來控制 UDP 通訊的函式。
摘要
列舉 |
|
---|---|
otNetifIdentifier{
|
enum 這個列舉會定義 OpenThread 網路介面 ID。 |
類型 |
|
---|---|
otNetifIdentifier
|
typedefenum otNetifIdentifier
這個列舉會定義 OpenThread 網路介面 ID。 |
otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
typedefbool(*
這個回呼可讓 OpenThread 為某些 UDP 訊息提供特定處理常式。 |
otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
typedefvoid(*
這個回呼可讓 OpenThread 通知收到的 UDP 訊息訊息。 |
otUdpReceiver
|
typedefstruct otUdpReceiver
這個結構代表 UDP 接收器。 |
otUdpSocket
|
typedefstruct otUdpSocket
這個結構代表 UDP 通訊端。 |
函式 |
|
---|---|
otUdpAddReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver)
|
這個函式會新增 UDP 接收器。
|
otUdpBind(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName, otNetifIdentifier aNetif)
|
繫結 UDP/IPv6 通訊端。
|
otUdpClose(otInstance *aInstance, otUdpSocket *aSocket)
|
關閉 UDP/IPv6 通訊端。
|
otUdpConnect(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName)
|
連接 UDP/IPv6 通訊端。
|
otUdpGetSockets(otInstance *aInstance)
|
這個函式會取得 UDP 通訊端連結清單的標題。
|
otUdpIsOpen(otInstance *aInstance, const otUdpSocket *aSocket)
|
bool
檢查 UDP 通訊端是否開啟。
|
otUdpNewMessage(otInstance *aInstance, const otMessageSettings *aSettings)
|
分配新的訊息緩衝區傳送 UDP 訊息。
|
otUdpOpen(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext)
|
開啟 UDP/IPv6 通訊端。
|
otUdpRemoveReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver)
|
這個指令會移除 UDP 接收器。
|
otUdpSend(otInstance *aInstance, otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
傳送 UDP/IPv6 訊息。
|
otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo)
|
這個函式可以傳送不含通訊端的 UDP 訊息。
|
結構 |
|
---|---|
otUdpReceiver |
這個結構代表 UDP 接收器。 |
otUdpSocket |
這個結構代表 UDP 通訊端。 |
列舉
otNetifIdentifier
otNetifIdentifier
這個列舉會定義 OpenThread 網路介面 ID。
屬性 | |
---|---|
OT_NETIF_BACKBONE
|
骨幹介面。 |
OT_NETIF_THREAD
|
會話串介面。 |
OT_NETIF_UNSPECIFIED
|
未指定網路介面。 |
類型
otUdpHandler
bool(* otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo)
這個回呼可讓 OpenThread 為某些 UDP 訊息提供特定處理常式。
說明 | |||||
---|---|---|---|---|---|
傳回值 |
|
otUdp 接收
void(* otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
這個回呼可讓 OpenThread 通知收到的 UDP 訊息訊息。
函式
otUdpAddReceiver
otError otUdpAddReceiver( otInstance *aInstance, otUdpReceiver *aUdpReceiver )
這個函式會新增 UDP 接收器。
說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otUdp 繫結
otError otUdpBind( otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName, otNetifIdentifier aNetif )
繫結 UDP/IPv6 通訊端。
說明 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otUdp 關閉
otError otUdpClose( otInstance *aInstance, otUdpSocket *aSocket )
關閉 UDP/IPv6 通訊端。
說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otUdpConnect
otError otUdpConnect( otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName )
連接 UDP/IPv6 通訊端。
說明 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otUdpGetSockets
otUdpSocket * otUdpGetSockets( otInstance *aInstance )
這個函式會取得 UDP 通訊端連結清單的標題。
說明 | |||
---|---|---|---|
參數 |
|
||
退貨 |
將遊標移至 UDP Socket 連結清單開頭的內容。
|
otUdpIsOpen
bool otUdpIsOpen( otInstance *aInstance, const otUdpSocket *aSocket )
檢查 UDP 通訊端是否開啟。
說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
退貨 |
UDP 通訊端是否開啟。
|
otUdpNewMessage
otMessage * otUdpNewMessage( otInstance *aInstance, const otMessageSettings *aSettings )
分配新的訊息緩衝區傳送 UDP 訊息。
說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
退貨 |
沒有可用的訊息緩衝區或參數無效時,指向訊息緩衝區或 NULL 的指標。
|
otMessageFree
otUdp 開啟
otError otUdpOpen( otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext )
開啟 UDP/IPv6 通訊端。
說明 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otUdpRemoveReceiver
otError otUdpRemoveReceiver( otInstance *aInstance, otUdpReceiver *aUdpReceiver )
這個指令會移除 UDP 接收器。
說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otUdpSend
otError otUdpSend( otInstance *aInstance, otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo )
傳送 UDP/IPv6 訊息。
如果傳回值為 OT_ERROR_NONE,OpenThread 會取得 aMessage
的擁有權,且呼叫者不應再參照 aMessage
。如果傳回值不是 OT_ERROR_NONE,呼叫者將保留 aMessage
的擁有權;如果不再需要訊息緩衝區,則釋出 aMessage
。
說明 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
說明 | |||||||
---|---|---|---|---|---|---|---|
傳回值 |
|
otUdpSendDatagram
otError otUdpSendDatagram( otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo )
這個函式可以傳送不含通訊端的 UDP 訊息。
說明 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|