Message: Add Clone method. (#804)

* Message: Add Clone method.

Packet cloning is done only inside ip6.cpp right now, but this method
might be useful for MPL and CoAP retransmissions in order to not repeat the same
code.
This commit is contained in:
Łukasz Duda
2016-10-14 09:37:26 -07:00
committed by Jonathan Hui
parent 5dbf96833e
commit b6ebabf2e4
3 changed files with 36 additions and 12 deletions
+1 -11
View File
@@ -412,20 +412,10 @@ ThreadError Ip6::ProcessReceiveCallback(const Message &aMessage, const MessageIn
}
// make a copy of the datagram to pass to host
VerifyOrExit((messageCopy = NewMessage(0)) != NULL, error = kThreadError_NoBufs);
SuccessOrExit(error = messageCopy->SetLength(aMessage.GetLength()));
aMessage.CopyTo(0, 0, aMessage.GetLength(), *messageCopy);
messageCopy->SetLinkSecurityEnabled(aMessage.IsLinkSecurityEnabled());
VerifyOrExit((messageCopy = aMessage.Clone()) != NULL, error = kThreadError_NoBufs);
mReceiveIp6DatagramCallback(messageCopy, mReceiveIp6DatagramCallbackContext);
exit:
if (error != kThreadError_None && messageCopy != NULL)
{
messageCopy->Free();
}
return error;
}