UDP#

This module includes functions that control UDP communication.

Modules#

otUdpReceiver

otUdpSocket

Enumerations#

enum
OT_NETIF_UNSPECIFIED = 0
OT_NETIF_THREAD
OT_NETIF_BACKBONE
}

Defines the OpenThread network interface identifiers.

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

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

Represents a UDP socket.

typedef enum otNetifIdentifier

Defines the OpenThread network interface identifiers.

Functions#

otUdpAddReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver)

Adds a UDP receiver.

otUdpRemoveReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver)

Removes a UDP receiver.

otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo)

Sends a UDP message without 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.

bool
otUdpIsOpen(otInstance *aInstance, const otUdpSocket *aSocket)

Check if a UDP socket is open.

otUdpClose(otInstance *aInstance, otUdpSocket *aSocket)

Close a UDP/IPv6 socket.

otUdpBind(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName, otNetifIdentifier aNetif)

Bind a UDP/IPv6 socket.

otUdpConnect(otInstance *aInstance, otUdpSocket *aSocket, const otSockAddr *aSockName)

Connect a UDP/IPv6 socket.

otUdpSend(otInstance *aInstance, otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo)

Send a UDP/IPv6 message.

otUdpGetSockets(otInstance *aInstance)

Gets the head of linked list of UDP Sockets.

Enumeration Documentation#

otNetifIdentifier#

otNetifIdentifier

Defines the OpenThread network interface identifiers.

Enumerator
OT_NETIF_UNSPECIFIED

Unspecified network interface.

OT_NETIF_THREAD

The Thread interface.

OT_NETIF_BACKBONE

The Backbone interface.


Definition at line 138 of file include/openthread/udp.h

Typedef Documentation#

otUdpHandler#

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

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


Definition at line 63 of file include/openthread/udp.h

otUdpReceiver#

typedef struct otUdpReceiver otUdpReceiver

Represents a UDP receiver.


Definition at line 74 of file include/openthread/udp.h

otUdpReceive#

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

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


Definition at line 118 of file include/openthread/udp.h

otUdpSocket#

typedef struct otUdpSocket otUdpSocket

Represents a UDP socket.


Definition at line 132 of file include/openthread/udp.h

otNetifIdentifier#

typedef enum otNetifIdentifier otNetifIdentifier

Defines the OpenThread network interface identifiers.


Definition at line 143 of file include/openthread/udp.h

Function Documentation#

otUdpAddReceiver#

otError otUdpAddReceiver (otInstance * aInstance, otUdpReceiver * aUdpReceiver)

Adds a UDP receiver.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aUdpReceiver

A pointer to the UDP receiver.


Definition at line 86 of file include/openthread/udp.h

otUdpRemoveReceiver#

otError otUdpRemoveReceiver (otInstance * aInstance, otUdpReceiver * aUdpReceiver)

Removes a UDP receiver.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aUdpReceiver

A pointer to the UDP receiver.


Definition at line 98 of file include/openthread/udp.h

otUdpSendDatagram#

otError otUdpSendDatagram (otInstance * aInstance, otMessage * aMessage, otMessageInfo * aMessageInfo)

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.


Definition at line 112 of file include/openthread/udp.h

otUdpNewMessage#

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

Allocate a new message buffer for sending a UDP message.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aSettings

A pointer to the message settings or NULL to use default settings.

Note

  • If aSettings is 'NULL', the link layer security is enabled and the message priority is set to OT_MESSAGE_PRIORITY_NORMAL by default.

Returns

  • A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.

See Also


Definition at line 159 of file include/openthread/udp.h

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.


Definition at line 173 of file include/openthread/udp.h

otUdpIsOpen#

bool otUdpIsOpen (otInstance * aInstance, const otUdpSocket * aSocket)

Check if a UDP socket is open.

Parameters
[in]aInstance

A pointer to an OpenThread instance.

[in]aSocket

A pointer to a UDP socket structure.

Returns

  • Whether the UDP socket is open.


Definition at line 184 of file include/openthread/udp.h

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.


Definition at line 196 of file include/openthread/udp.h

otUdpBind#

otError otUdpBind (otInstance * aInstance, otUdpSocket * aSocket, const otSockAddr * aSockName, otNetifIdentifier aNetif)

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.

[in]aNetif

The network interface to bind.


Definition at line 210 of file include/openthread/udp.h

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.


Definition at line 223 of file include/openthread/udp.h

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.


Definition at line 242 of file include/openthread/udp.h

otUdpGetSockets#

otUdpSocket * otUdpGetSockets (otInstance * aInstance)

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.


Definition at line 252 of file include/openthread/udp.h