diff --git a/include/openthread/instance.h b/include/openthread/instance.h index b60d8900cffb..7f9bc8915eb0 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (366) +#define OPENTHREAD_API_VERSION (367) /** * @addtogroup api-instance diff --git a/include/openthread/message.h b/include/openthread/message.h index 99dc49cf1848..3c2938c450d9 100644 --- a/include/openthread/message.h +++ b/include/openthread/message.h @@ -211,6 +211,28 @@ bool otMessageIsLoopbackToHostAllowed(const otMessage *aMessage); */ void otMessageSetLoopbackToHostAllowed(otMessage *aMessage, bool aAllowLoopbackToHost); +/** + * Indicates whether the given message may be looped back in a case of a multicast destination address. + * + * If @p aMessage is used along with an `otMessageInfo`, the `mMulticastLoop` field from `otMessageInfo` structure + * takes precedence and will be used instead of the the value set on @p aMessage. + * + * This API is mainly intended for use along with `otIp6Send()` which expects an already prepared IPv6 message. + * + * @param[in] aMessage A pointer to the message. + * + */ +bool otMessageIsMulticastLoopEnabled(otMessage *aMessage); + +/** + * Controls whether the given message may be looped back in a case of a multicast destination address. + * + * @param[in] aMessage A pointer to the message. + * @param[in] aEnabled The configuration value. + * + */ +void otMessageSetMulticastLoopEnabled(otMessage *aMessage, bool aEnabled); + /** * Gets the message origin. * diff --git a/src/core/api/message_api.cpp b/src/core/api/message_api.cpp index f564e3abd996..ab8a66798a4d 100644 --- a/src/core/api/message_api.cpp +++ b/src/core/api/message_api.cpp @@ -62,6 +62,16 @@ void otMessageSetLoopbackToHostAllowed(otMessage *aMessage, bool aAllowLoopbackT return AsCoreType(aMessage).SetLoopbackToHostAllowed(aAllowLoopbackToHost); } +bool otMessageIsMulticastLoopEnabled(otMessage *aMessage) +{ + return AsCoreType(aMessage).GetMulticastLoop(); +} + +void otIp6SetMulticastLoopEnabled(otMessage *aMessage, bool aEnabled) +{ + AsCoreType(aMessage).SetMulticastLoop(aEnabled); +} + otMessageOrigin otMessageGetOrigin(const otMessage *aMessage) { return MapEnum(AsCoreType(aMessage).GetOrigin()); } void otMessageSetOrigin(otMessage *aMessage, otMessageOrigin aOrigin)