UDP Forward

This module includes functions for UDP forward feature.

Typedefs

typedef void(* otUdpForwarder) (otMessage *aMessage, uint16_t aPeerPort, otIp6Address *aPeerAddr, uint16_t aSockPort, void *aContext)
 This function pointer delivers the UDP packet to host and host should send the packet through its own network stack.

Functions

void otUdpForwardSetForwarder (otInstance *aInstance, otUdpForwarder aForwarder, void *aContext)
 Set UDP forward callback to deliver UDP packets to host.
 
void otUdpForwardReceive (otInstance *aInstance, otMessage *aMessage, uint16_t aPeerPort, const otIp6Address *aPeerAddr, uint16_t aSockPort)
 Handle a UDP packet received from host.
 
bool otUdpIsPortInUse (otInstance *aInstance, uint16_t port)
 Determines if the given UDP port is exclusively opened by OpenThread API.

Detailed Description

This module includes functions for UDP forward feature.

The functions in this module are available when udp-forward feature (OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE) is enabled.

Typedef Documentation

◆ otUdpForwarder

typedef void(* otUdpForwarder) (otMessage *aMessage, uint16_t aPeerPort, otIp6Address *aPeerAddr, uint16_t aSockPort, void *aContext)

This function pointer delivers the UDP packet to host and host should send the packet through its own network stack.

Parameters
[in]aMessageA pointer to the UDP Message.
[in]aPeerPortThe destination UDP port.
[in]aPeerAddrA pointer to the destination IPv6 address.
[in]aSockPortThe source UDP port.
[in]aContextA pointer to application-specific context.

Function Documentation

◆ otUdpForwardReceive()

void otUdpForwardReceive ( otInstance aInstance,
otMessage aMessage,
uint16_t  aPeerPort,
const otIp6Address aPeerAddr,
uint16_t  aSockPort 
)

Handle a UDP packet received from host.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aMessageA pointer to the UDP Message.
[in]aPeerPortThe source UDP port.
[in]aPeerAddrA pointer to the source address.
[in]aSockPortThe destination UDP port.
Warning
No matter the call success or fail, the message is freed.

◆ otUdpForwardSetForwarder()

void otUdpForwardSetForwarder ( otInstance aInstance,
otUdpForwarder  aForwarder,
void *  aContext 
)

Set UDP forward callback to deliver UDP packets to host.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aForwarderA pointer to a function called to forward UDP packet to host.
[in]aContextA pointer to application-specific context.

◆ otUdpIsPortInUse()

bool otUdpIsPortInUse ( otInstance aInstance,
uint16_t  port 
)

Determines if the given UDP port is exclusively opened by OpenThread API.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]portUDP port number to verify.
Return values
trueThe port is being used exclusively by OpenThread.
falseThe port is not used by any of the OpenThread API or is shared (e.g. is Backbone socket).