UDP

This module includes functions that control UDP communication.

Summary

Typedefs

otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo) typedef
bool(*
This callback allows OpenThread to provide specific handlers for certain UDP messages.
otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo) typedef
void(*
This callback allows OpenThread to inform the application of a received UDP message.
otUdpReceiver typedef
struct otUdpReceiver
This structure represents a UDP receiver.
otUdpSocket typedef
struct otUdpSocket
This structure represents a UDP socket.

Functions

otUdpBind(otUdpSocket *aSocket, otSockAddr *aSockName)
Bind a UDP/IPv6 socket.
otUdpClose(otUdpSocket *aSocket)
Close a UDP/IPv6 socket.
otUdpConnect(otUdpSocket *aSocket, otSockAddr *aSockName)
Connect a UDP/IPv6 socket.
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.
otUdpSend(otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo)
Send a UDP/IPv6 message.

Structs

otUdpReceiver

This structure represents a UDP receiver.

otUdpSocket

This structure represents a UDP socket.

Typedefs

otUdpHandler

bool(* otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo)

This callback allows OpenThread to provide specific handlers for certain UDP messages.

Details
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.

otUdpReceive

void(* otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)

This callback allows OpenThread to inform the application of a received UDP message.

otUdpReceiver

struct otUdpReceiver otUdpReceiver

This structure represents a UDP receiver.

otUdpSocket

struct otUdpSocket otUdpSocket

This structure represents a UDP socket.

Functions

otUdpBind

otError otUdpBind(
  otUdpSocket *aSocket,
  otSockAddr *aSockName
)

Bind a UDP/IPv6 socket.

Details
Parameters
[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.
See also:
otUdpNewMessage
otUdpOpen
otUdpConnect
otUdpClose
otUdpSend

otUdpClose

otError otUdpClose(
  otUdpSocket *aSocket
)

Close a UDP/IPv6 socket.

Details
Parameters
[in] aSocket
A pointer to a UDP socket structure.
Return Values
OT_ERROR_NONE
Successfully closed the socket.
See also:
otUdpNewMessage
otUdpOpen
otUdpBind
otUdpConnect
otUdpSend

otUdpConnect

otError otUdpConnect(
  otUdpSocket *aSocket,
  otSockAddr *aSockName
)

Connect a UDP/IPv6 socket.

Details
Parameters
[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.
See also:
otUdpNewMessage
otUdpOpen
otUdpBind
otUdpClose
otUdpSend

otUdpNewMessage

otMessage * otUdpNewMessage(
  otInstance *aInstance,
  const otMessageSettings *aSettings
)

Allocate a new message buffer for sending a UDP message.

Details
Parameters
[in] aInstance
A pointer to an OpenThread instance.
[in] aSettings
A pointer to the message settings or NULL to set default settings.
Returns
A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
See also:
otFreeMessage

otUdpOpen

otError otUdpOpen(
  otInstance *aInstance,
  otUdpSocket *aSocket,
  otUdpReceive aCallback,
  void *aContext
)

Open a UDP/IPv6 socket.

Details
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_INVALID_ARGS
Given socket structure was already opened.
See also:
otUdpNewMessage
otUdpClose
otUdpBind
otUdpConnect
otUdpSend

otUdpSend

otError otUdpSend(
  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
[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.

Details
Return Values
OT_ERROR_NONE
The message is successfully scheduled for sending.
OT_ERROR_INVALID_ARGS
Invalid arguments are given.
See also:
otUdpNewMessage
otUdpOpen
otUdpClose
otUdpBind
otUdpConnect
otUdpSend