UDP
This module includes functions that control UDP communication.
Summary
Enumerations |
|
|---|---|
otNetifIdentifier{
|
enum Defines the OpenThread network interface identifiers. |
Typedefs |
|
|---|---|
otNetifIdentifier
|
typedefenum otNetifIdentifier
Defines the OpenThread network interface identifiers. |
otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
typedefbool(*
Represents a callback to handle a received UDP message. |
otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
typedefvoid(*
Callback function pointer to notify the application of a received UDP message on a UDP socket. |
otUdpReceiver
|
typedefstruct otUdpReceiver
Represents a UDP receiver. |
otUdpSocket
|
typedefstruct otUdpSocket
Represents a UDP socket. |
Functions |
|
|---|---|
otUdpAddReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver)
|
Adds a UDP receiver.
|
otUdpBind(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName, otNetifIdentifier aNetif)
|
Bind a UDP/IPv6 socket.
|
otUdpClose(otInstance *aInstance, otUdpSocket *aSocket)
|
Close a UDP/IPv6 socket.
|
otUdpConnect(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName)
|
Connect a UDP/IPv6 socket.
|
otUdpGetSockets(otInstance *aInstance)
|
Gets the head of linked list of UDP Sockets.
|
otUdpIsOpen(otInstance *aInstance, const otUdpSocket *aSocket)
|
bool
Check if a UDP socket is open.
|
otUdpNewMessage(otInstance *aInstance, const otMessageSettings *aSettings)
|
Allocate a new message buffer for sending a UDP message.
|
otUdpOpen(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext)
|
Open a UDP/IPv6 socket.
|
otUdpRemoveReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver)
|
Removes a UDP receiver.
|
otUdpSend(otInstance *aInstance, otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
Send a UDP/IPv6 message.
|
otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo)
|
Sends a UDP message without socket.
|
Structs |
|
|---|---|
| otUdpReceiver |
Represents a UDP receiver. |
| otUdpSocket |
Represents a UDP socket. |
Enumerations
otNetifIdentifier
otNetifIdentifier
Defines the OpenThread network interface identifiers.
Typedefs
otNetifIdentifier
enum otNetifIdentifier otNetifIdentifier
Defines the OpenThread network interface identifiers.
otUdpHandler
bool(* otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo)
Represents a callback to handle a received UDP message.
This callback is used by a UDP receiver (see otUdpAddReceiver()) to process an incoming UDP message.
This callback does not transfer ownership of aMessage. The callback implementation must not modify the message content. The message is guaranteed to be valid only within the context of the callback.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||
| Return Values |
|
otUdpReceive
void(* otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
Callback function pointer to notify the application of a received UDP message on a UDP socket.
This callback does not transfer ownership of aMessage. The callback implementation must not modify the message content. The message is guaranteed to be valid only within the context of the callback.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
Functions
otUdpAddReceiver
otError otUdpAddReceiver( otInstance *aInstance, otUdpReceiver *aUdpReceiver )
Adds a UDP receiver.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otUdpBind
otError otUdpBind( otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName, otNetifIdentifier aNetif )
Bind a UDP/IPv6 socket.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||||
| Return Values |
|
otUdpClose
otError otUdpClose( otInstance *aInstance, otUdpSocket *aSocket )
Close a UDP/IPv6 socket.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otUdpConnect
otError otUdpConnect( otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName )
Connect a UDP/IPv6 socket.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||
| Return Values |
|
otUdpGetSockets
otUdpSocket * otUdpGetSockets( otInstance *aInstance )
Gets the head of linked list of UDP Sockets.
| Details | |||
|---|---|---|---|
| Parameters |
|
||
| Returns |
A pointer to the head of UDP Socket linked list.
|
otUdpIsOpen
bool otUdpIsOpen( otInstance *aInstance, const otUdpSocket *aSocket )
Check if a UDP socket is open.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Returns |
Whether the UDP socket is open.
|
otUdpNewMessage
otMessage * otUdpNewMessage( otInstance *aInstance, const otMessageSettings *aSettings )
Allocate a new message buffer for sending a UDP message.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Returns |
A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
|
otMessageFree
otUdpOpen
otError otUdpOpen( otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext )
Open a UDP/IPv6 socket.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||||
| Return Values |
|
otUdpRemoveReceiver
otError otUdpRemoveReceiver( otInstance *aInstance, otUdpReceiver *aUdpReceiver )
Removes a UDP receiver.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otUdpSend
otError otUdpSend( otInstance *aInstance, otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo )
Send a UDP/IPv6 message.
If the return value is OT_ERROR_NONE, OpenThread takes ownership of aMessage, and the caller should no longer reference aMessage. If the return value is not OT_ERROR_NONE, the caller retains ownership of aMessage, including freeing aMessage if the message buffer is no longer needed.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Return Values |
|
otUdpSendDatagram
otError otUdpSendDatagram( otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo )
Sends a UDP message without socket.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||
| Return Values |
|
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.