Update otNewUdpMessage() to allow user to enable/disable layer 2 security (#812)

This commit is contained in:
Abtin Keshavarzian
2016-10-14 09:35:32 -07:00
committed by Jonathan Hui
parent 86deb6e868
commit 5dbf96833e
3 changed files with 13 additions and 5 deletions
+3 -2
View File
@@ -2244,13 +2244,14 @@ uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond
/**
* Allocate a new message buffer for sending a UDP message.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aLinkSecurityEnabled TRUE if the message should be secured at Layer 2.
*
* @returns A pointer to the message buffer or NULL if no message buffers are available.
*
* @sa otFreeMessage
*/
otMessage otNewUdpMessage(otInstance *aInstance);
otMessage otNewUdpMessage(otInstance *aInstance, bool aLinkSecurityEnabled);
/**
* Open a UDP/IPv6 socket.
+1 -1
View File
@@ -99,7 +99,7 @@ int Udp::Output(const char *aBuf, uint16_t aBufLength)
ThreadError error = kThreadError_None;
otMessage message;
VerifyOrExit((message = otNewUdpMessage(mInstance)) != NULL, error = kThreadError_NoBufs);
VerifyOrExit((message = otNewUdpMessage(mInstance, true)) != NULL, error = kThreadError_NoBufs);
SuccessOrExit(error = otSetMessageLength(message, aBufLength));
otWriteMessage(message, 0, aBuf, aBufLength);
SuccessOrExit(error = otSendUdp(&mSocket, message, &mPeer));
+9 -2
View File
@@ -1225,9 +1225,16 @@ ThreadError otSendIp6Datagram(otInstance *aInstance, otMessage aMessage)
NULL, true);
}
otMessage otNewUdpMessage(otInstance *aInstance)
otMessage otNewUdpMessage(otInstance *aInstance, bool aLinkSecurityEnabled)
{
return aInstance->mIp6.mUdp.NewMessage(0);
Message *message = aInstance->mIp6.mUdp.NewMessage(0);
if (message)
{
message->SetLinkSecurityEnabled(aLinkSecurityEnabled);
}
return message;
}
otMessage otNewIp6Message(otInstance *aInstance, bool aLinkSecurityEnabled)