UDP
This module includes functions that control UDP communication.
Classes |
|
struct | otUdpReceiver |
This structure represents a UDP receiver.
|
|
struct | otUdpSocket |
This structure represents a UDP socket.
|
Typedefs |
|
typedef bool(* | otUdpHandler ) (void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo) |
This callback allows OpenThread to provide specific handlers for certain UDP messages.
|
|
typedef struct otUdpReceiver | otUdpReceiver |
This structure represents a UDP receiver.
|
|
typedef void(* | otUdpReceive ) (void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo) |
This callback allows OpenThread to inform the application of a received UDP message.
|
|
typedef struct otUdpSocket | otUdpSocket |
This structure represents a UDP socket.
|
Functions |
|
otError | otUdpAddReceiver ( otInstance *aInstance, otUdpReceiver *aUdpReceiver) |
This function adds a UDP receiver.
|
|
otError | otUdpRemoveReceiver ( otInstance *aInstance, otUdpReceiver *aUdpReceiver) |
This function removes a UDP receiver.
|
|
otError | otUdpSendDatagram ( otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo) |
This function sends a UDP message without socket.
|
|
otMessage * | otUdpNewMessage ( otInstance *aInstance, const otMessageSettings *aSettings) |
Allocate a new message buffer for sending a UDP message.
|
|
otError | otUdpOpen ( otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext) |
Open a UDP/IPv6 socket.
|
|
otError | otUdpClose ( otInstance *aInstance, otUdpSocket *aSocket) |
Close a UDP/IPv6 socket.
|
|
otError | otUdpBind ( otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName) |
Bind a UDP/IPv6 socket.
|
|
otError | otUdpConnect ( otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName) |
Connect a UDP/IPv6 socket.
|
|
otError | otUdpSend ( otInstance *aInstance, otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo) |
Send a UDP/IPv6 message.
|
|
otUdpSocket * | otUdpGetSockets ( otInstance *aInstance) |
This function gets the head of linked list of UDP Sockets.
|
Detailed Description
This module includes functions that control UDP communication.
Typedef Documentation
◆ otUdpHandler
typedef bool(* otUdpHandler) (void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo) |
This callback allows OpenThread to provide specific handlers for certain UDP messages.
- Return values
-
true
The message is handled by this receiver and should not be further processed. false
The message is not handled by this receiver.
Function Documentation
◆ otUdpAddReceiver()
otError otUdpAddReceiver | ( | otInstance * |
aInstance,
|
otUdpReceiver * |
aUdpReceiver
|
||
) |
This function adds a UDP receiver.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aUdpReceiver
A pointer to the UDP receiver.
- Return values
-
OT_ERROR_NONE
The receiver is successfully added. OT_ERROR_ALREADY
The UDP receiver was already added.
◆ otUdpBind()
otError otUdpBind | ( | otInstance * |
aInstance,
|
otUdpSocket * |
aSocket,
|
||
const otSockAddr * |
aSockName
|
||
) |
Bind a UDP/IPv6 socket.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aSocket
A pointer to a UDP socket structure. [in] aSockName
A pointer to an IPv6 socket address structure.
- Return values
-
OT_ERROR_NONE
Bind operation was successful. OT_ERROR_FAILED
Failed to bind UDP socket.
◆ otUdpClose()
otError otUdpClose | ( | otInstance * |
aInstance,
|
otUdpSocket * |
aSocket
|
||
) |
Close a UDP/IPv6 socket.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aSocket
A pointer to a UDP socket structure.
- Return values
-
OT_ERROR_NONE
Successfully closed the socket. OT_ERROR_FAILED
Failed to close UDP Socket.
◆ otUdpConnect()
otError otUdpConnect | ( | otInstance * |
aInstance,
|
otUdpSocket * |
aSocket,
|
||
const otSockAddr * |
aSockName
|
||
) |
Connect a UDP/IPv6 socket.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aSocket
A pointer to a UDP socket structure. [in] aSockName
A pointer to an IPv6 socket address structure.
- Return values
-
OT_ERROR_NONE
Connect operation was successful. OT_ERROR_FAILED
Failed to connect UDP socket.
◆ otUdpGetSockets()
otUdpSocket * otUdpGetSockets | ( | otInstance * |
aInstance
|
) |
This function gets the head of linked list of UDP Sockets.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance.
- Returns
- A pointer to the head of UDP Socket linked list.
◆ otUdpNewMessage()
otMessage * otUdpNewMessage | ( | otInstance * |
aInstance,
|
const otMessageSettings * |
aSettings
|
||
) |
Allocate a new message buffer for sending a UDP message.
- Note
-
If
aSettings
is 'NULL', the link layer security is enabled and the message priority is set to OT_MESSAGE_PRIORITY_NORMAL by default.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aSettings
A pointer to the message settings or NULL to use default settings.
- Returns
- A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
- See also
- otMessageFree
◆ otUdpOpen()
otError otUdpOpen | ( | otInstance * |
aInstance,
|
otUdpSocket * |
aSocket,
|
||
otUdpReceive |
aCallback,
|
||
void * |
aContext
|
||
) |
Open a UDP/IPv6 socket.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aSocket
A pointer to a UDP socket structure. [in] aCallback
A pointer to the application callback function. [in] aContext
A pointer to application-specific context.
- Return values
-
OT_ERROR_NONE
Successfully opened the socket. OT_ERROR_FAILED
Failed to open the socket.
◆ otUdpRemoveReceiver()
otError otUdpRemoveReceiver | ( | otInstance * |
aInstance,
|
otUdpReceiver * |
aUdpReceiver
|
||
) |
This function removes a UDP receiver.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aUdpReceiver
A pointer to the UDP receiver.
- Return values
-
OT_ERROR_NONE
The receiver is successfully removed. OT_ERROR_NOT_FOUND
The UDP receiver was not added.
◆ otUdpSend()
otError otUdpSend | ( | otInstance * |
aInstance,
|
otUdpSocket * |
aSocket,
|
||
otMessage * |
aMessage,
|
||
const otMessageInfo * |
aMessageInfo
|
||
) |
Send a UDP/IPv6 message.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aSocket
A pointer to a UDP socket structure. [in] aMessage
A pointer to a message buffer. [in] aMessageInfo
A pointer to a message info structure.
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.
- Return values
-
OT_ERROR_NONE
The message is successfully scheduled for sending. OT_ERROR_INVALID_ARGS
Invalid arguments are given. OT_ERROR_NO_BUFS
Insufficient available buffer to add the UDP and IPv6 headers.
◆ otUdpSendDatagram()
otError otUdpSendDatagram | ( | otInstance * |
aInstance,
|
otMessage * |
aMessage,
|
||
otMessageInfo * |
aMessageInfo
|
||
) |
This function sends a UDP message without socket.
- Parameters
-
[in] aInstance
A pointer to an OpenThread instance. [in] aMessage
A pointer to a message without UDP header. [in] aMessageInfo
A pointer to a message info associated with aMessage
.
- Return values
-
OT_ERROR_NONE
Successfully enqueued the message into an output interface. OT_ERROR_NO_BUFS
Insufficient available buffer to add the IPv6 headers.