Skip to content

Commit

Permalink
[message] add API functions to enable multicast looping of a message
Browse files Browse the repository at this point in the history
At the moment, C API does not allow to get/set the configuration flag
which the message to be looped back to the Thread interface. It is
important within the context of sending already prepared IPv6 mutlicast
packets with `otIp6Send()`.
  • Loading branch information
konradderda committed Oct 17, 2023
1 parent 1d81283 commit 130f1fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
22 changes: 22 additions & 0 deletions include/openthread/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 10 additions & 0 deletions src/core/api/message_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 130f1fe

Please sign in to comment.