From 1d9b7fd23f0fd9ef32179d86c938a9f8587b48fe Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 9 Feb 2017 09:46:45 -0800 Subject: [PATCH] `MeshForwader`: Add comments and modify handling of (insecure) MLE message requiring fragmentation (#1285) - This commit add comments to clarify how the `SendFragment()` handles (insecure) MLE messages requiring fragmentation and modifies the logic to have the caller enable security when trying again. --- src/core/thread/mesh_forwarder.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index 77584d446..c97a10c9e 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -1056,11 +1056,18 @@ ThreadError MeshForwarder::HandleFrameRequest(Mac::Frame &aFrame) } } - if (SendFragment(*mSendMessage, aFrame) == kThreadError_NotCapable) + error = SendFragment(*mSendMessage, aFrame); + + // `SendFragment()` fails with `NotCapable` error if the message is MLE (with + // no link layer security) and also requires fragmentation. + if (error == kThreadError_NotCapable) { - SendFragment(*mSendMessage, aFrame); + // Enable security and try again. + mSendMessage->SetLinkSecurityEnabled(true); + error = SendFragment(*mSendMessage, aFrame); } + assert(error == kThreadError_None); assert(aFrame.GetLength() != 7); break; @@ -1340,7 +1347,6 @@ ThreadError MeshForwarder::SendFragment(Message &aMessage, Mac::Frame &aFrame) { if ((!aMessage.IsLinkSecurityEnabled()) && aMessage.IsSubTypeMle()) { - aMessage.SetLinkSecurityEnabled(true); aMessage.SetOffset(0); ExitNow(error = kThreadError_NotCapable); }