From 8f7024c3e9beb47a48cfc1e3185f5fce82fffba9 Mon Sep 17 00:00:00 2001 From: Jintao Lin Date: Wed, 3 Mar 2021 00:02:44 +0800 Subject: [PATCH] [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. --- src/core/thread/mesh_forwarder.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index 254c9e504..af20cc855 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -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(index)); } }