UDP
這個模組內含控管 UDP 通訊的函式。
摘要
列舉 |
|
|---|---|
otNetifIdentifier{
|
列舉 定義 OpenThread 網路介面 ID。 |
Typedefs |
|
|---|---|
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
|
Backbone 介面。 |
OT_NETIF_THREAD
|
Thread 介面。 |
OT_NETIF_UNSPECIFIED
|
未指定的網路介面。 |
Typedefs
otUdpHandler
bool(* otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo)
這個回呼可讓 OpenThread 為特定 UDP 訊息提供特定處理常式。
| 詳細說明 | |||||
|---|---|---|---|---|---|
| 傳回值 |
|
||||
otUdpReceive
void(* otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
這個回呼可讓 OpenThread 通知應用程式已收到 UDP 訊息。
函式
otUdpAddReceiver
otError otUdpAddReceiver( otInstance *aInstance, otUdpReceiver *aUdpReceiver )
新增 UDP 接收器。
| 詳細說明 | |||||
|---|---|---|---|---|---|
| 參數 |
|
||||
| 傳回值 |
|
||||
otUdpBind
otError otUdpBind( otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName, otNetifIdentifier aNetif )
繫結 UDP/IPv6 通訊端。
| 詳細說明 | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| 參數 |
|
||||||||
| 傳回值 |
|
||||||||
otUdpClose
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 通訊端連結清單標頭的指標。
|
||
otUdpIsOpen
bool otUdpIsOpen( otInstance *aInstance, const otUdpSocket *aSocket )
檢查 UDP 通訊端是否開啟。
| 詳細說明 | |||||
|---|---|---|---|---|---|
| 參數 |
|
||||
| 傳回 |
UDP 通訊端是否開啟。
|
||||
otUdpNewMessage
otMessage * otUdpNewMessage( otInstance *aInstance, const otMessageSettings *aSettings )
分配新的訊息緩衝區以傳送 UDP 訊息。
| 詳細說明 | |||||
|---|---|---|---|---|---|
| 參數 |
|
||||
| 傳回 |
如果沒有可用訊息緩衝區或參數無效,這個指標指向訊息緩衝區或 NULL。
|
||||
otMessageFree
otUdpOpen
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 訊息。
| 詳細說明 | |||||||
|---|---|---|---|---|---|---|---|
| 參數 |
|
||||||
| 傳回值 |
|
||||||
資源
OpenThread API 參考資料主題源自原始碼,請前往 GitHub 取得。如要瞭解詳情或對說明文件做出貢獻,請參閱資源。