mirror of
https://github.com/espressif/openthread.git
synced 2026-08-14 22:57:46 +00:00
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:
committed by
Jonathan Hui
parent
5dbf96833e
commit
b6ebabf2e4
+1
-11
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user