mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 11:17:46 +00:00
[udp] expose an API to send UDP datagram (#3822)
This commit exposes an API to send UDP datagram, this is usefully when the UDP receiver handler needs to send messages.
This commit is contained in:
@@ -97,6 +97,19 @@ otError otUdpAddReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver);
|
||||
*/
|
||||
otError otUdpRemoveReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver);
|
||||
|
||||
/**
|
||||
* This function sends a UDP message without socket.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMessage A pointer to a message without UDP header.
|
||||
* @param[in] aMessageInfo A pointer to a message info associated with @p aMessage.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enqueued the message into an output interface.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient available buffer to add the IPv6 headers.
|
||||
*
|
||||
*/
|
||||
otError otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo);
|
||||
|
||||
/**
|
||||
* This callback allows OpenThread to inform the application of a received UDP message.
|
||||
*
|
||||
|
||||
@@ -150,3 +150,11 @@ otError otUdpRemoveReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver)
|
||||
|
||||
return instance.Get<Ip6::Udp>().RemoveReceiver(*static_cast<Ip6::UdpReceiver *>(aUdpReceiver));
|
||||
}
|
||||
|
||||
otError otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<Ip6::Udp>().SendDatagram(*static_cast<ot::Message *>(aMessage),
|
||||
*static_cast<Ip6::MessageInfo *>(aMessageInfo), Ip6::kProtoUdp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user