diff --git a/include/openthread/udp.h b/include/openthread/udp.h index 1d18fea95..496239985 100644 --- a/include/openthread/udp.h +++ b/include/openthread/udp.h @@ -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. * diff --git a/src/core/api/udp_api.cpp b/src/core/api/udp_api.cpp index 785a1ef5d..6d955222c 100644 --- a/src/core/api/udp_api.cpp +++ b/src/core/api/udp_api.cpp @@ -150,3 +150,11 @@ otError otUdpRemoveReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver) return instance.Get().RemoveReceiver(*static_cast(aUdpReceiver)); } + +otError otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo) +{ + Instance &instance = *static_cast(aInstance); + + return instance.Get().SendDatagram(*static_cast(aMessage), + *static_cast(aMessageInfo), Ip6::kProtoUdp); +}