nRF5 SDK for Thread and Zigbee v3.2.0
Data Structures | Typedefs | Functions
UDP

This module includes functions that control UDP communication. More...

Data Structures

struct  otUdpReceiver
 
struct  otUdpSocket
 

Typedefs

typedef bool(* otUdpHandler )(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo)
 
typedef struct otUdpReceiver otUdpReceiver
 
typedef void(* otUdpReceive )(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
 
typedef struct otUdpSocket otUdpSocket
 

Functions

otError otUdpAddReceiver (otInstance *aInstance, otUdpReceiver *aUdpReceiver)
 
otError otUdpRemoveReceiver (otInstance *aInstance, otUdpReceiver *aUdpReceiver)
 
otError otUdpSendDatagram (otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo)
 
otMessageotUdpNewMessage (otInstance *aInstance, const otMessageSettings *aSettings)
 
otError otUdpOpen (otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext)
 
otError otUdpClose (otUdpSocket *aSocket)
 
otError otUdpBind (otUdpSocket *aSocket, otSockAddr *aSockName)
 
otError otUdpConnect (otUdpSocket *aSocket, otSockAddr *aSockName)
 
otError otUdpSend (otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo)
 

Detailed Description

This module includes functions that control UDP communication.

Typedef Documentation

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
trueThe message is handled by this receiver and should not be further processed.
falseThe message is not handled by this 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 otUdpReceiver otUdpReceiver

This structure represents a UDP receiver.

typedef struct otUdpSocket otUdpSocket

This structure represents a UDP socket.

Function Documentation

otError otUdpAddReceiver ( otInstance aInstance,
otUdpReceiver aUdpReceiver 
)

This function adds a UDP receiver.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aUdpReceiverA pointer to the UDP receiver.
Return values
OT_ERROR_NONEThe receiver is successfully added.
OT_ERROR_ALREADYThe UDP receiver was already added.
otError otUdpBind ( otUdpSocket aSocket,
otSockAddr aSockName 
)

Bind a UDP/IPv6 socket.

Parameters
[in]aSocketA pointer to a UDP socket structure.
[in]aSockNameA pointer to an IPv6 socket address structure.
Return values
OT_ERROR_NONEBind operation was successful.
See also
otUdpNewMessage
otUdpOpen
otUdpConnect
otUdpClose
otUdpSend
otError otUdpClose ( otUdpSocket aSocket)

Close a UDP/IPv6 socket.

Parameters
[in]aSocketA pointer to a UDP socket structure.
Return values
OT_ERROR_NONESuccessfully closed the socket.
See also
otUdpNewMessage
otUdpOpen
otUdpBind
otUdpConnect
otUdpSend
otError otUdpConnect ( otUdpSocket aSocket,
otSockAddr aSockName 
)

Connect a UDP/IPv6 socket.

Parameters
[in]aSocketA pointer to a UDP socket structure.
[in]aSockNameA pointer to an IPv6 socket address structure.
Return values
OT_ERROR_NONEConnect operation was successful.
See also
otUdpNewMessage
otUdpOpen
otUdpBind
otUdpClose
otUdpSend
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]aInstanceA pointer to an OpenThread instance.
[in]aSettingsA 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
otMessageFree
otError otUdpOpen ( otInstance aInstance,
otUdpSocket aSocket,
otUdpReceive  aCallback,
void *  aContext 
)

Open a UDP/IPv6 socket.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aSocketA pointer to a UDP socket structure.
[in]aCallbackA pointer to the application callback function.
[in]aContextA pointer to application-specific context.
Return values
OT_ERROR_NONESuccessfully opened the socket.
OT_ERROR_INVALID_ARGSGiven socket structure was already opened.
See also
otUdpNewMessage
otUdpClose
otUdpBind
otUdpConnect
otUdpSend
otError otUdpRemoveReceiver ( otInstance aInstance,
otUdpReceiver aUdpReceiver 
)

This function removes a UDP receiver.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aUdpReceiverA pointer to the UDP receiver.
Return values
OT_ERROR_NONEThe receiver is successfully removed.
OT_ERROR_NOT_FOUNDThe UDP receiver was not added.
otError otUdpSend ( otUdpSocket aSocket,
otMessage aMessage,
const otMessageInfo aMessageInfo 
)

Send a UDP/IPv6 message.

Parameters
[in]aSocketA pointer to a UDP socket structure.
[in]aMessageA pointer to a message buffer.
[in]aMessageInfoA 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_NONEThe message is successfully scheduled for sending.
OT_ERROR_INVALID_ARGSInvalid arguments are given.
See also
otUdpNewMessage
otUdpOpen
otUdpClose
otUdpBind
otUdpConnect
otUdpSend
otError otUdpSendDatagram ( otInstance aInstance,
otMessage aMessage,
otMessageInfo aMessageInfo 
)

This function sends a UDP message without socket.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aMessageA pointer to a message without UDP header.
[in]aMessageInfoA pointer to a message info associated with aMessage.
Return values
OT_ERROR_NONESuccessfully enqueued the message into an output interface.
OT_ERROR_NO_BUFSInsufficient available buffer to add the IPv6 headers.

Documentation feedback | Developer Zone | Subscribe | Updated