[mac] only append header termination IE2 when data payload is present (#6223)

According to IEEE802.15.4, header termination IE2 is present only when
header IE and payload data is present.
This commit is contained in:
Jintao Lin
2021-03-02 08:02:44 -08:00
committed by GitHub
parent bec6213ded
commit 8f7024c3e9
+4 -3
View File
@@ -1553,8 +1553,8 @@ void MeshForwarder::AppendHeaderIe(const Message *aMessage, Mac::Frame &aFrame)
{
uint8_t index = 0;
bool iePresent = false;
OT_UNUSED_VARIABLE(aMessage);
bool payloadPresent =
(aFrame.GetType() == Mac::Frame::kFcfFrameMacCmd) || (aMessage != nullptr && aMessage->GetLength() != 0);
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
if (aMessage != nullptr && aMessage->IsTimeSync())
@@ -1571,8 +1571,9 @@ void MeshForwarder::AppendHeaderIe(const Message *aMessage, Mac::Frame &aFrame)
}
#endif
if (iePresent)
if (iePresent && payloadPresent)
{
// Assume no Payload IE in current implementation
IgnoreError(aFrame.AppendHeaderIeAt<Mac::Termination2Ie>(index));
}
}