mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[mesh-forwarder] restore FrameData in GetForwardFramePriority() (#10459)
This commit updates `GetForwardFramePriority()` to save the original `aRxInfo.mFrameData` before parsing the fragment header. The header parsing may modify `mFrameData` to skip over the parsed portion. The original `FrameData` is restored before returning, ensuring that forwarded frames include the fragment header and eliminating the need to create a copy of `aRxInfo`.
This commit is contained in:
@@ -575,7 +575,7 @@ private:
|
||||
Error GetFragmentPriority(Lowpan::FragmentHeader &aFragmentHeader,
|
||||
uint16_t aSrcRloc16,
|
||||
Message::Priority &aPriority);
|
||||
void GetForwardFramePriority(const RxInfo &aRxInfo, Message::Priority &aPriority);
|
||||
void GetForwardFramePriority(RxInfo &aRxInfo, Message::Priority &aPriority);
|
||||
|
||||
bool CalcIePresent(const Message *aMessage);
|
||||
Mac::Frame::Version CalcFrameVersion(const Neighbor *aNeighbor, bool aIePresent) const;
|
||||
|
||||
@@ -965,39 +965,52 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MeshForwarder::GetForwardFramePriority(const RxInfo &aRxInfo, Message::Priority &aPriority)
|
||||
void MeshForwarder::GetForwardFramePriority(RxInfo &aRxInfo, Message::Priority &aPriority)
|
||||
{
|
||||
// Determines the message priority to use for forwarding a
|
||||
// received mesh-header LowPAN frame towards its final
|
||||
// destination.
|
||||
|
||||
Error error = kErrorNone;
|
||||
RxInfo rxInfo = aRxInfo;
|
||||
bool isFragment = false;
|
||||
Lowpan::FragmentHeader fragmentHeader;
|
||||
FrameData savedFrameData;
|
||||
|
||||
if (fragmentHeader.ParseFrom(rxInfo.mFrameData) == kErrorNone)
|
||||
// We save the `aRxInfo.mFrameData` before parsing the fragment
|
||||
// header which may update it to skip over the parsed header. We
|
||||
// restore the original frame data on `aRxInfo` before
|
||||
// returning.
|
||||
|
||||
savedFrameData = aRxInfo.mFrameData;
|
||||
|
||||
if (fragmentHeader.ParseFrom(aRxInfo.mFrameData) == kErrorNone)
|
||||
{
|
||||
isFragment = true;
|
||||
|
||||
if (fragmentHeader.GetDatagramOffset() > 0)
|
||||
{
|
||||
// Get priority from the pre-buffered info
|
||||
ExitNow(error = GetFragmentPriority(fragmentHeader, rxInfo.GetSrcAddr().GetShort(), aPriority));
|
||||
ExitNow(error = GetFragmentPriority(fragmentHeader, aRxInfo.GetSrcAddr().GetShort(), aPriority));
|
||||
}
|
||||
}
|
||||
|
||||
// Get priority from IPv6 header or UDP destination port directly
|
||||
error = GetFramePriority(rxInfo, aPriority);
|
||||
error = GetFramePriority(aRxInfo, aPriority);
|
||||
|
||||
exit:
|
||||
if (error != kErrorNone)
|
||||
{
|
||||
LogNote("Failed to get forwarded frame priority, error:%s, len:%d, src:%s, dst:%s", ErrorToString(error),
|
||||
rxInfo.mFrameData.GetLength(), rxInfo.GetSrcAddr().ToString().AsCString(),
|
||||
rxInfo.GetDstAddr().ToString().AsCString());
|
||||
aRxInfo.mFrameData.GetLength(), aRxInfo.GetSrcAddr().ToString().AsCString(),
|
||||
aRxInfo.GetDstAddr().ToString().AsCString());
|
||||
}
|
||||
else if (isFragment)
|
||||
{
|
||||
UpdateFragmentPriority(fragmentHeader, rxInfo.mFrameData.GetLength(), rxInfo.GetSrcAddr().GetShort(),
|
||||
UpdateFragmentPriority(fragmentHeader, aRxInfo.mFrameData.GetLength(), aRxInfo.GetSrcAddr().GetShort(),
|
||||
aPriority);
|
||||
}
|
||||
|
||||
aRxInfo.mFrameData = savedFrameData;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
|
||||
Reference in New Issue
Block a user