[ip6-mpl] remove aIsOutbound input and use aMessage.GetOrigin() (#9510)

With the recent addition of `GetOrigin()`, the origin of a message is
tracked by `Message` itself. With this change, we no longer need to
pass `aIsOutbound` to `Ip6::Mpl` methods, as it can be determined
from the origin of `aMessage`. This commit simplifies the code by
removing the `aIsOutbound` input parameter.
This commit is contained in:
Abtin Keshavarzian
2023-10-10 14:14:44 -07:00
committed by GitHub
parent ca97cf7a0f
commit 0d0655ded9
4 changed files with 22 additions and 16 deletions
+6 -6
View File
@@ -516,7 +516,7 @@ void Ip6::HandleSendQueue(void)
}
}
Error Ip6::HandleOptions(Message &aMessage, Header &aHeader, bool aIsOutbound, bool &aReceive)
Error Ip6::HandleOptions(Message &aMessage, Header &aHeader, bool &aReceive)
{
Error error = kErrorNone;
HopByHopHeader hbhHeader;
@@ -542,7 +542,7 @@ Error Ip6::HandleOptions(Message &aMessage, Header &aHeader, bool aIsOutbound, b
if (option.GetType() == MplOption::kType)
{
SuccessOrExit(error = mMpl.ProcessOption(aMessage, offset, aHeader.GetSource(), aIsOutbound, aReceive));
SuccessOrExit(error = mMpl.ProcessOption(aMessage, offset, aHeader.GetSource(), aReceive));
continue;
}
@@ -829,8 +829,8 @@ Error Ip6::HandleExtensionHeaders(Message &aMessage,
uint8_t &aNextHeader,
bool &aReceive)
{
Error error = kErrorNone;
bool isOutbound = !aMessage.IsOriginThreadNetif();
Error error = kErrorNone;
ExtensionHeader extHeader;
while (aReceive || aNextHeader == kProtoHopOpts)
@@ -840,7 +840,7 @@ Error Ip6::HandleExtensionHeaders(Message &aMessage,
switch (aNextHeader)
{
case kProtoHopOpts:
SuccessOrExit(error = HandleOptions(aMessage, aHeader, isOutbound, aReceive));
SuccessOrExit(error = HandleOptions(aMessage, aHeader, aReceive));
break;
case kProtoFragment:
@@ -850,7 +850,7 @@ Error Ip6::HandleExtensionHeaders(Message &aMessage,
break;
case kProtoDstOpts:
SuccessOrExit(error = HandleOptions(aMessage, aHeader, isOutbound, aReceive));
SuccessOrExit(error = HandleOptions(aMessage, aHeader, aReceive));
break;
case kProtoIp6:
+1 -1
View File
@@ -390,7 +390,7 @@ private:
Error AddTunneledMplOption(Message &aMessage, Header &aHeader);
Error InsertMplOption(Message &aMessage, Header &aHeader);
Error RemoveMplOption(Message &aMessage);
Error HandleOptions(Message &aMessage, Header &aHeader, bool aIsOutbound, bool &aReceive);
Error HandleOptions(Message &aMessage, Header &aHeader, bool &aReceive);
Error HandlePayload(Header &aIp6Header,
Message &aMessage,
MessageInfo &aMessageInfo,
+13 -6
View File
@@ -90,7 +90,7 @@ void Mpl::InitOption(MplOption &aOption, const Address &aAddress)
aOption.SetSequence(mSequence++);
}
Error Mpl::ProcessOption(Message &aMessage, uint16_t aOffset, const Address &aAddress, bool aIsOutbound, bool &aReceive)
Error Mpl::ProcessOption(Message &aMessage, uint16_t aOffset, const Address &aAddress, bool &aReceive)
{
Error error;
MplOption option;
@@ -122,10 +122,10 @@ Error Mpl::ProcessOption(Message &aMessage, uint16_t aOffset, const Address &aAd
if (error == kErrorNone)
{
#if OPENTHREAD_FTD
AddBufferedMessage(aMessage, option.GetSeedId(), option.GetSequence(), aIsOutbound);
AddBufferedMessage(aMessage, option.GetSeedId(), option.GetSequence());
#endif
}
else if (aIsOutbound)
else if (!aMessage.IsOriginThreadNetif())
{
aReceive = false;
// In case MPL Data Message is generated locally, ignore potential error of the MPL Seed Set
@@ -334,7 +334,7 @@ uint8_t Mpl::DetermineMaxRetransmissions(void) const
return maxRetx;
}
void Mpl::AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSequence, bool aIsOutbound)
void Mpl::AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSequence)
{
Error error = kErrorNone;
Message *messageCopy = nullptr;
@@ -352,16 +352,23 @@ void Mpl::AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSeque
VerifyOrExit(DetermineMaxRetransmissions() > 0);
VerifyOrExit((messageCopy = aMessage.Clone()) != nullptr, error = kErrorNoBufs);
if (!aIsOutbound)
if (aMessage.IsOriginThreadNetif())
{
IgnoreError(aMessage.Read(Header::kHopLimitFieldOffset, hopLimit));
VerifyOrExit(hopLimit-- > 1, error = kErrorDrop);
messageCopy->Write(Header::kHopLimitFieldOffset, hopLimit);
}
// If the message originates from Thread Netif (i.e., it was
// received over Thread radio), set the `mTransmissionCount` to
// zero. Otherwise, the message originates from the host and will
// be forwarded by `Ip6` to the Thread mesh, so the message itself
// will be the first transmission and we set `mTransmissionCount`
// to one.
metadata.mSeedId = aSeedId;
metadata.mSequence = aSequence;
metadata.mTransmissionCount = aIsOutbound ? 1 : 0;
metadata.mTransmissionCount = aMessage.IsOriginThreadNetif() ? 0 : 1;
metadata.mIntervalOffset = 0;
metadata.GenerateNextTransmissionTime(TimerMilli::GetNow(), interval);
+2 -3
View File
@@ -194,7 +194,6 @@ public:
* @param[in] aMessage A reference to the message.
* @param[in] aOffset The offset in @p aMessage to read the MPL option.
* @param[in] aAddress A reference to the IPv6 Source Address.
* @param[in] aIsOutbound TRUE if this message was locally generated, FALSE otherwise.
* @param[out] aReceive Set to FALSE if the MPL message is a duplicate and must not
* go through the receiving process again, untouched otherwise.
*
@@ -202,7 +201,7 @@ public:
* @retval kErrorDrop The MPL message is a duplicate and should be dropped.
*
*/
Error ProcessOption(Message &aMessage, uint16_t aOffset, const Address &aAddress, bool aIsOutbound, bool &aReceive);
Error ProcessOption(Message &aMessage, uint16_t aOffset, const Address &aAddress, bool &aReceive);
#if OPENTHREAD_FTD
/**
@@ -254,7 +253,7 @@ private:
uint8_t DetermineMaxRetransmissions(void) const;
void HandleRetransmissionTimer(void);
void AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSequence, bool aIsOutbound);
void AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSequence);
using RetxTimer = TimerMilliIn<Mpl, &Mpl::HandleRetransmissionTimer>;