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.
This commit is contained in:
Abtin Keshavarzian
2017-02-09 09:46:45 -08:00
committed by Jonathan Hui
parent f22d9dbcec
commit 1d9b7fd23f
+9 -3
View File
@@ -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);
}