mirror of
https://github.com/espressif/openthread.git
synced 2026-07-22 12:04:06 +00:00
Update otNewUdpMessage() to allow user to enable/disable layer 2 security (#812)
This commit is contained in:
committed by
Jonathan Hui
parent
86deb6e868
commit
5dbf96833e
@@ -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
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user