[style] make parameter names consistent across decls and defs (#3705)

This commit is contained in:
Jonathan Hui
2019-03-22 08:12:26 -07:00
committed by Jonathan Hui
parent d32ca03a8b
commit 49c4b63491
53 changed files with 354 additions and 348 deletions
+4 -4
View File
@@ -106,9 +106,9 @@ void otPlatDebugUart_vprintf(const char *fmt, va_list ap);
*
* This function MUST be implemented by the platform
*
* @param[in] the_byte what to transmit
* @param[in] c what to transmit
*/
void otPlatDebugUart_putchar_raw(int the_byte);
void otPlatDebugUart_putchar_raw(int c);
/**
* Poll/test debug uart if a key has been pressed.
@@ -138,9 +138,9 @@ int otPlatDebugUart_getc(void);
* A WEAK default implementation is provided
* that can be overridden as needed.
*
* @param[in] the_byte the byte to transmit
* @param[in] c the byte to transmit
*/
void otPlatDebugUart_putchar(int the_byte);
void otPlatDebugUart_putchar(int c);
/**
* identical to "man 3 puts" - terminates with lf
+4 -4
View File
@@ -404,17 +404,17 @@ void Interpreter::OutputBytes(const uint8_t *aBytes, uint8_t aLength) const
}
}
otError Interpreter::ParseLong(char *argv, long &value)
otError Interpreter::ParseLong(char *aString, long &aLong)
{
char *endptr;
value = strtol(argv, &endptr, 0);
aLong = strtol(aString, &endptr, 0);
return (*endptr == '\0') ? OT_ERROR_NONE : OT_ERROR_PARSE;
}
otError Interpreter::ParseUnsignedLong(char *argv, unsigned long &value)
otError Interpreter::ParseUnsignedLong(char *aString, unsigned long &aUnsignedLong)
{
char *endptr;
value = strtoul(argv, &endptr, 0);
aUnsignedLong = strtoul(aString, &endptr, 0);
return (*endptr == '\0') ? OT_ERROR_NONE : OT_ERROR_PARSE;
}
+1 -1
View File
@@ -162,7 +162,7 @@ public:
*
* @param[in] aError Error code value.
*/
void AppendResult(otError error) const;
void AppendResult(otError aError) const;
/**
* Write a number of bytes to the CLI console as a hex string.
+2 -2
View File
@@ -62,11 +62,11 @@ uint16_t otChannelManagerGetDelay(otInstance *aInstance)
return instance.GetChannelManager().GetDelay();
}
otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aMinDelay)
otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aDelay)
{
Instance &instance = *static_cast<Instance *>(aInstance);
return instance.GetChannelManager().SetDelay(aMinDelay);
return instance.GetChannelManager().SetDelay(aDelay);
}
otError otChannelManagerRequestChannelSelect(otInstance *aInstance, bool aSkipQualityCheck)
+3 -3
View File
@@ -88,14 +88,14 @@ exit:
return error;
}
otError otThreadGetLeaderRloc(otInstance *aInstance, otIp6Address *aAddress)
otError otThreadGetLeaderRloc(otInstance *aInstance, otIp6Address *aLeaderRloc)
{
otError error;
Instance &instance = *static_cast<Instance *>(aInstance);
VerifyOrExit(aAddress != NULL, error = OT_ERROR_INVALID_ARGS);
VerifyOrExit(aLeaderRloc != NULL, error = OT_ERROR_INVALID_ARGS);
error = instance.GetThreadNetif().GetMle().GetLeaderAddress(*static_cast<Ip6::Address *>(aAddress));
error = instance.GetThreadNetif().GetMle().GetLeaderAddress(*static_cast<Ip6::Address *>(aLeaderRloc));
exit:
return error;
+2 -2
View File
@@ -57,13 +57,13 @@ exit:
return message;
}
otError otUdpOpen(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aCallbackContext)
otError otUdpOpen(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext)
{
otError error = OT_ERROR_INVALID_ARGS;
Instance & instance = *static_cast<Instance *>(aInstance);
Ip6::UdpSocket &socket = *new (aSocket) Ip6::UdpSocket(instance.GetIp6().GetUdp());
error = socket.Open(aCallback, aCallbackContext);
error = socket.Open(aCallback, aContext);
return error;
}
+2 -2
View File
@@ -412,10 +412,10 @@ public:
/**
* This method sets a default response header based on request header.
*
* @param[in] aRequestHeader Request header to base on.
* @param[in] aRequest The request message.
*
*/
void SetDefaultResponseHeader(const Message &aRequestHeader);
void SetDefaultResponseHeader(const Message &aRequest);
/**
* This method checks if a header is an empty message header.
+6 -6
View File
@@ -1881,14 +1881,14 @@ extern "C" {
/**
* This method dumps bytes to the log in a human-readable fashion.
*
* @param[in] aLevel The log level.
* @param[in] aRegion The log region.
* @param[in] aId A pointer to a NULL-terminated string that is printed before the bytes.
* @param[in] aBuf A pointer to the buffer.
* @param[in] aLength Number of bytes to print.
* @param[in] aLogLevel The log level.
* @param[in] aLogRegion The log region.
* @param[in] aId A pointer to a NULL-terminated string that is printed before the bytes.
* @param[in] aBuf A pointer to the buffer.
* @param[in] aLength Number of bytes to print.
*
*/
void otDump(otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void *aBuf, size_t aLength);
void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const void *aBuf, size_t aLength);
/**
* This function converts a log level to a prefix string for appending to log message.
+34 -34
View File
@@ -65,7 +65,7 @@ MessagePool::MessagePool(Instance &aInstance)
#endif
}
Message *MessagePool::New(uint8_t aType, uint16_t aReserved, uint8_t aPriority)
Message *MessagePool::New(uint8_t aType, uint16_t aReserveHeader, uint8_t aPriority)
{
otError error = OT_ERROR_NONE;
Message *message = NULL;
@@ -75,7 +75,7 @@ Message *MessagePool::New(uint8_t aType, uint16_t aReserved, uint8_t aPriority)
memset(message, 0, sizeof(*message));
message->SetMessagePool(this);
message->SetType(aType);
message->SetReserved(aReserved);
message->SetReserved(aReserveHeader);
message->SetLinkSecurityEnabled(true);
SuccessOrExit(error = message->SetPriority(aPriority));
@@ -91,7 +91,7 @@ exit:
return message;
}
Message *MessagePool::New(uint8_t aType, uint16_t aReserved, const otMessageSettings *aSettings)
Message *MessagePool::New(uint8_t aType, uint16_t aReserveHeader, const otMessageSettings *aSettings)
{
Message *message;
bool linkSecurityEnabled;
@@ -108,7 +108,7 @@ Message *MessagePool::New(uint8_t aType, uint16_t aReserved, const otMessageSett
priority = aSettings->mPriority;
}
message = New(aType, aReserved, priority);
message = New(aType, aReserveHeader, priority);
if (message)
{
message->SetLinkSecurityEnabled(linkSecurityEnabled);
@@ -850,26 +850,26 @@ MessageQueue::MessageQueue(void)
SetTail(NULL);
}
void MessageQueue::AddToList(uint8_t aList, Message &aMessage, QueuePosition aPosition)
void MessageQueue::AddToList(uint8_t aListId, Message &aMessage, QueuePosition aPosition)
{
assert((aMessage.Next(aList) == NULL) && (aMessage.Prev(aList) == NULL));
assert((aMessage.Next(aListId) == NULL) && (aMessage.Prev(aListId) == NULL));
if (GetTail() == NULL)
{
aMessage.Next(aList) = &aMessage;
aMessage.Prev(aList) = &aMessage;
aMessage.Next(aListId) = &aMessage;
aMessage.Prev(aListId) = &aMessage;
SetTail(&aMessage);
}
else
{
Message *head = GetTail()->Next(aList);
Message *head = GetTail()->Next(aListId);
aMessage.Next(aList) = head;
aMessage.Prev(aList) = GetTail();
aMessage.Next(aListId) = head;
aMessage.Prev(aListId) = GetTail();
head->Prev(aList) = &aMessage;
GetTail()->Next(aList) = &aMessage;
head->Prev(aListId) = &aMessage;
GetTail()->Next(aListId) = &aMessage;
if (aPosition == kQueuePositionTail)
{
@@ -878,13 +878,13 @@ void MessageQueue::AddToList(uint8_t aList, Message &aMessage, QueuePosition aPo
}
}
void MessageQueue::RemoveFromList(uint8_t aList, Message &aMessage)
void MessageQueue::RemoveFromList(uint8_t aListId, Message &aMessage)
{
assert((aMessage.Next(aList) != NULL) && (aMessage.Prev(aList) != NULL));
assert((aMessage.Next(aListId) != NULL) && (aMessage.Prev(aListId) != NULL));
if (&aMessage == GetTail())
{
SetTail(GetTail()->Prev(aList));
SetTail(GetTail()->Prev(aListId));
if (&aMessage == GetTail())
{
@@ -892,11 +892,11 @@ void MessageQueue::RemoveFromList(uint8_t aList, Message &aMessage)
}
}
aMessage.Prev(aList)->Next(aList) = aMessage.Next(aList);
aMessage.Next(aList)->Prev(aList) = aMessage.Prev(aList);
aMessage.Prev(aListId)->Next(aListId) = aMessage.Next(aListId);
aMessage.Next(aListId)->Prev(aListId) = aMessage.Prev(aListId);
aMessage.Prev(aList) = NULL;
aMessage.Next(aList) = NULL;
aMessage.Prev(aListId) = NULL;
aMessage.Next(aListId) = NULL;
}
Message *MessageQueue::GetHead(void) const
@@ -1012,7 +1012,7 @@ Message *PriorityQueue::GetTail(void) const
return FindFirstNonNullTail(0);
}
void PriorityQueue::AddToList(uint8_t aList, Message &aMessage)
void PriorityQueue::AddToList(uint8_t aListId, Message &aMessage)
{
uint8_t priority;
Message *tail;
@@ -1024,23 +1024,23 @@ void PriorityQueue::AddToList(uint8_t aList, Message &aMessage)
if (tail != NULL)
{
next = tail->Next(aList);
next = tail->Next(aListId);
aMessage.Next(aList) = next;
aMessage.Prev(aList) = tail;
next->Prev(aList) = &aMessage;
tail->Next(aList) = &aMessage;
aMessage.Next(aListId) = next;
aMessage.Prev(aListId) = tail;
next->Prev(aListId) = &aMessage;
tail->Next(aListId) = &aMessage;
}
else
{
aMessage.Next(aList) = &aMessage;
aMessage.Prev(aList) = &aMessage;
aMessage.Next(aListId) = &aMessage;
aMessage.Prev(aListId) = &aMessage;
}
mTails[priority] = &aMessage;
}
void PriorityQueue::RemoveFromList(uint8_t aList, Message &aMessage)
void PriorityQueue::RemoveFromList(uint8_t aListId, Message &aMessage)
{
uint8_t priority;
Message *tail;
@@ -1051,7 +1051,7 @@ void PriorityQueue::RemoveFromList(uint8_t aList, Message &aMessage)
if (&aMessage == tail)
{
tail = tail->Prev(aList);
tail = tail->Prev(aListId);
if ((&aMessage == tail) || (tail->GetPriority() != priority))
{
@@ -1061,10 +1061,10 @@ void PriorityQueue::RemoveFromList(uint8_t aList, Message &aMessage)
mTails[priority] = tail;
}
aMessage.Next(aList)->Prev(aList) = aMessage.Prev(aList);
aMessage.Prev(aList)->Next(aList) = aMessage.Next(aList);
aMessage.Next(aList) = NULL;
aMessage.Prev(aList) = NULL;
aMessage.Next(aListId)->Prev(aListId) = aMessage.Prev(aListId);
aMessage.Prev(aListId)->Next(aListId) = aMessage.Next(aListId);
aMessage.Next(aListId) = NULL;
aMessage.Prev(aListId) = NULL;
}
otError PriorityQueue::Enqueue(Message &aMessage)
+4 -4
View File
@@ -316,14 +316,14 @@ exit:
return error;
}
otError Settings::Save(Key aKey, const void *aBuffer, uint16_t aSize)
otError Settings::Save(Key aKey, const void *aValue, uint16_t aSize)
{
return otPlatSettingsSet(&GetInstance(), aKey, reinterpret_cast<const uint8_t *>(aBuffer), aSize);
return otPlatSettingsSet(&GetInstance(), aKey, reinterpret_cast<const uint8_t *>(aValue), aSize);
}
otError Settings::Add(Key aKey, const void *aBuffer, uint16_t aSize)
otError Settings::Add(Key aKey, const void *aValue, uint16_t aSize)
{
return otPlatSettingsAdd(&GetInstance(), aKey, reinterpret_cast<const uint8_t *>(aBuffer), aSize);
return otPlatSettingsAdd(&GetInstance(), aKey, reinterpret_cast<const uint8_t *>(aValue), aSize);
}
otError Settings::Delete(Key aKey)
+1 -1
View File
@@ -470,7 +470,7 @@ public:
};
private:
otError ReadFixedSize(Key aKey, void *aBuffer, uint16_t aExpectedLength) const;
otError ReadFixedSize(Key aKey, void *aBuffer, uint16_t aExpectedSize) const;
otError Read(Key aKey, void *aBuffer, uint16_t aMaxBufferSize, uint16_t &aReadSize) const;
otError Save(Key aKey, const void *aValue, uint16_t aSize);
otError Add(Key aKey, const void *aValue, uint16_t aSize);
+3 -3
View File
@@ -120,14 +120,14 @@ protected:
/**
* This method indicates if the fire time of this timer is strictly before the fire time of a second given timer.
*
* @param[in] aTimer A reference to the second timer object.
* @param[in] aNow The current time (may in milliseconds or microsecond, which depends on the timer type).
* @param[in] aSecondTimer A reference to the second timer object.
* @param[in] aNow The current time (milliseconds or microsecond, depending on timer type).
*
* @retval TRUE If the fire time of this timer object is strictly before aTimer's fire time
* @retval FALSE If the fire time of this timer object is the same or after aTimer's fire time.
*
*/
bool DoesFireBefore(const Timer &aTimer, uint32_t aNow);
bool DoesFireBefore(const Timer &aSecondTimer, uint32_t aNow);
void Fired(void) { mHandler(*this); }
+8 -8
View File
@@ -200,15 +200,15 @@ void AesCcm::Header(const void *aHeader, uint32_t aHeaderLength)
}
}
void AesCcm::Payload(void *plaintext, void *ciphertext, uint32_t len, bool aEncrypt)
void AesCcm::Payload(void *aPlainText, void *aCipherText, uint32_t aLength, bool aEncrypt)
{
uint8_t *plaintextBytes = reinterpret_cast<uint8_t *>(plaintext);
uint8_t *ciphertextBytes = reinterpret_cast<uint8_t *>(ciphertext);
uint8_t *plaintextBytes = reinterpret_cast<uint8_t *>(aPlainText);
uint8_t *ciphertextBytes = reinterpret_cast<uint8_t *>(aCipherText);
uint8_t byte;
assert(mPlainTextCur + len <= mPlainTextLength);
assert(mPlainTextCur + aLength <= mPlainTextLength);
for (unsigned i = 0; i < len; i++)
for (unsigned i = 0; i < aLength; i++)
{
if (mCtrLength == 16)
{
@@ -244,7 +244,7 @@ void AesCcm::Payload(void *plaintext, void *ciphertext, uint32_t len, bool aEncr
mBlock[mBlockLength++] ^= byte;
}
mPlainTextCur += len;
mPlainTextCur += aLength;
if (mPlainTextCur >= mPlainTextLength)
{
@@ -261,9 +261,9 @@ void AesCcm::Payload(void *plaintext, void *ciphertext, uint32_t len, bool aEncr
}
}
void AesCcm::Finalize(void *tag, uint8_t *aTagLength)
void AesCcm::Finalize(void *aTag, uint8_t *aTagLength)
{
uint8_t *tagBytes = reinterpret_cast<uint8_t *>(tag);
uint8_t *tagBytes = reinterpret_cast<uint8_t *>(aTag);
assert(mPlainTextCur == mPlainTextLength);
+2 -2
View File
@@ -303,9 +303,9 @@ void Mac::ReportEnergyScanResult(int8_t aRssi)
}
}
void Mac::EnergyScanDone(int8_t aRssi)
void Mac::EnergyScanDone(int8_t aEnergyScanMaxRssi)
{
ReportEnergyScanResult(aRssi);
ReportEnergyScanResult(aEnergyScanMaxRssi);
PerformEnergyScan();
}
+8 -8
View File
@@ -432,7 +432,7 @@ uint8_t Frame::FindSrcAddrIndex(void) const
return index;
}
otError Frame::GetSrcAddr(Address &address) const
otError Frame::GetSrcAddr(Address &aAddress) const
{
otError error = OT_ERROR_NONE;
uint8_t index = FindSrcAddrIndex();
@@ -443,15 +443,15 @@ otError Frame::GetSrcAddr(Address &address) const
switch (fcf & kFcfSrcAddrMask)
{
case kFcfSrcAddrShort:
address.SetShort(Encoding::LittleEndian::ReadUint16(GetPsdu() + index));
aAddress.SetShort(Encoding::LittleEndian::ReadUint16(GetPsdu() + index));
break;
case kFcfSrcAddrExt:
address.SetExtended(GetPsdu() + index, /* reverse */ true);
aAddress.SetExtended(GetPsdu() + index, /* reverse */ true);
break;
default:
address.SetNone();
aAddress.SetNone();
break;
}
@@ -1031,12 +1031,12 @@ exit:
}
#endif // OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
void Frame::CopyFrom(const Frame &aAnotherFrame)
void Frame::CopyFrom(const Frame &aFromFrame)
{
uint8_t * psduBuffer = mPsdu;
otRadioIeInfo *ieInfoBuffer = mIeInfo;
memcpy(this, &aAnotherFrame, sizeof(Frame));
memcpy(this, &aFromFrame, sizeof(Frame));
// Set the original buffer pointers back on the frame
// which were overwritten by above `memcpy()`.
@@ -1044,8 +1044,8 @@ void Frame::CopyFrom(const Frame &aAnotherFrame)
mPsdu = psduBuffer;
mIeInfo = ieInfoBuffer;
memcpy(mPsdu, aAnotherFrame.mPsdu, aAnotherFrame.GetPsduLength());
memcpy(mIeInfo, aAnotherFrame.mIeInfo, sizeof(otRadioIeInfo));
memcpy(mPsdu, aFromFrame.mPsdu, aFromFrame.GetPsduLength());
memcpy(mIeInfo, aFromFrame.mIeInfo, sizeof(otRadioIeInfo));
}
Frame::InfoString Frame::ToInfoString(void) const
+5 -5
View File
@@ -549,11 +549,11 @@ public:
/**
* This method initializes the MAC header.
*
* @param[in] aFcf The Frame Control field.
* @param[in] aSecCtl The Security Control field.
* @param[in] aFcf The Frame Control field.
* @param[in] aSecurityCtl The Security Control field.
*
*/
void InitMacHeader(uint16_t aFcf, uint8_t aSecCtl);
void InitMacHeader(uint16_t aFcf, uint8_t aSecurityControl);
/**
* This method validates the frame.
@@ -1247,10 +1247,10 @@ public:
* @note This method performs a deep copy meaning the content of PSDU buffer from the given frame is copied into
* the PSDU buffer of the current frame.
* @param[in] aFrame The frame to copy from.
* @param[in] aFromFrame The frame to copy from.
*
*/
void CopyFrom(const Frame &aFrame);
void CopyFrom(const Frame &aFromFrame);
/**
* This method returns information about the frame object as an `InfoString` object.
+2 -1
View File
@@ -62,12 +62,13 @@ public:
* @param[in] aChannelMask The channel mask value.
* @param[in] aCount The number of Announce messages sent per channel.
* @param[in] aPeriod The time between two successive MLE Announce transmissions (in milliseconds).
* @param[in] aAddress The destination address.
*
* @retval OT_ERROR_NONE Successfully enqueued the Announce Begin message.
* @retval OT_ERROR_NO_BUFS Insufficient buffers to generate a Announce Begin message.
*
*/
otError SendRequest(uint32_t aChannelMask, uint8_t aCount, uint16_t mPeriod, const Ip6::Address &aAddress);
otError SendRequest(uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod, const Ip6::Address &aAddress);
};
/**
+5 -5
View File
@@ -477,17 +477,17 @@ exit:
}
}
otError BorderAgent::ForwardToCommissioner(Coap::Message &aNewMessage, const Message &aMessage)
otError BorderAgent::ForwardToCommissioner(Coap::Message &aForwardMessage, const Message &aMessage)
{
ThreadNetif &netif = GetNetif();
otError error = OT_ERROR_NONE;
uint16_t offset = 0;
offset = aNewMessage.GetLength();
SuccessOrExit(error = aNewMessage.SetLength(offset + aMessage.GetLength() - aMessage.GetOffset()));
aMessage.CopyTo(aMessage.GetOffset(), offset, aMessage.GetLength() - aMessage.GetOffset(), aNewMessage);
offset = aForwardMessage.GetLength();
SuccessOrExit(error = aForwardMessage.SetLength(offset + aMessage.GetLength() - aMessage.GetOffset()));
aMessage.CopyTo(aMessage.GetOffset(), offset, aMessage.GetLength() - aMessage.GetOffset(), aForwardMessage);
SuccessOrExit(error = netif.GetCoapSecure().SendMessage(aNewMessage, netif.GetCoapSecure().GetPeerAddress()));
SuccessOrExit(error = netif.GetCoapSecure().SendMessage(aForwardMessage, netif.GetCoapSecure().GetPeerAddress()));
otLogInfoMeshCoP("Sent to commissioner");
+3 -3
View File
@@ -193,11 +193,11 @@ exit:
return error;
}
int DatasetLocal::Compare(const Timestamp *aCompareTimestamp)
int DatasetLocal::Compare(const Timestamp *aCompare)
{
int rval = 1;
if (aCompareTimestamp == NULL)
if (aCompare == NULL)
{
if (!mTimestampPresent)
{
@@ -216,7 +216,7 @@ int DatasetLocal::Compare(const Timestamp *aCompareTimestamp)
}
else
{
rval = mTimestamp.Compare(*aCompareTimestamp);
rval = mTimestamp.Compare(*aCompare);
}
}
+2 -2
View File
@@ -96,8 +96,8 @@ private:
static void HandleJoinerEntrustResponse(void * aContext,
otMessage * aMessage,
const otMessageInfo *aMessageInfo,
otError result);
void HandleJoinerEntrustResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, otError result);
otError aResult);
void HandleJoinerEntrustResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, otError aResult);
static void HandleTimer(Timer &aTimer);
void HandleTimer(void);
+16 -16
View File
@@ -252,13 +252,13 @@ uint16_t Dhcp6Server::FindOption(Message &aMessage, uint16_t aOffset, uint16_t a
exit:
return rval;
}
otError Dhcp6Server::ProcessClientIdentifier(Message &aMessage, uint16_t aOffset, ClientIdentifier &aClient)
otError Dhcp6Server::ProcessClientIdentifier(Message &aMessage, uint16_t aOffset, ClientIdentifier &aClientId)
{
otError error = OT_ERROR_NONE;
VerifyOrExit(((aMessage.Read(aOffset, sizeof(aClient), &aClient) == sizeof(aClient)) &&
(aClient.GetLength() == (sizeof(aClient) - sizeof(Dhcp6Option))) &&
(aClient.GetDuidType() == kDuidLL) && (aClient.GetDuidHardwareType() == kHardwareTypeEui64)),
VerifyOrExit(((aMessage.Read(aOffset, sizeof(aClientId), &aClientId) == sizeof(aClientId)) &&
(aClientId.GetLength() == (sizeof(aClientId) - sizeof(Dhcp6Option))) &&
(aClientId.GetDuidType() == kDuidLL) && (aClientId.GetDuidHardwareType() == kHardwareTypeEui64)),
error = OT_ERROR_PARSE);
exit:
return error;
@@ -327,7 +327,7 @@ exit:
return error;
}
otError Dhcp6Server::SendReply(otIp6Address &aDst, uint8_t *aTransactionId, ClientIdentifier &aClient, IaNa &aIaNa)
otError Dhcp6Server::SendReply(otIp6Address &aDst, uint8_t *aTransactionId, ClientIdentifier &aClientId, IaNa &aIaNa)
{
otError error = OT_ERROR_NONE;
Ip6::MessageInfo messageInfo;
@@ -336,10 +336,10 @@ otError Dhcp6Server::SendReply(otIp6Address &aDst, uint8_t *aTransactionId, Clie
VerifyOrExit((message = mSocket.NewMessage(0)) != NULL, error = OT_ERROR_NO_BUFS);
SuccessOrExit(error = AppendHeader(*message, aTransactionId));
SuccessOrExit(error = AppendServerIdentifier(*message));
SuccessOrExit(error = AppendClientIdentifier(*message, aClient));
SuccessOrExit(error = AppendClientIdentifier(*message, aClientId));
SuccessOrExit(error = AppendIaNa(*message, aIaNa));
SuccessOrExit(error = AppendStatusCode(*message, kStatusSuccess));
SuccessOrExit(error = AppendIaAddress(*message, aClient));
SuccessOrExit(error = AppendIaAddress(*message, aClientId));
SuccessOrExit(error = AppendRapidCommit(*message));
memcpy(messageInfo.GetPeerAddr().mFields.m8, &aDst, sizeof(otIp6Address));
@@ -366,9 +366,9 @@ otError Dhcp6Server::AppendHeader(Message &aMessage, uint8_t *aTransactionId)
return aMessage.Append(&header, sizeof(header));
}
otError Dhcp6Server::AppendClientIdentifier(Message &aMessage, ClientIdentifier &aClient)
otError Dhcp6Server::AppendClientIdentifier(Message &aMessage, ClientIdentifier &aClientId)
{
return aMessage.Append(&aClient, sizeof(aClient));
return aMessage.Append(&aClientId, sizeof(aClientId));
}
otError Dhcp6Server::AppendServerIdentifier(Message &aMessage)
@@ -420,16 +420,16 @@ exit:
return error;
}
otError Dhcp6Server::AppendStatusCode(Message &aMessage, Status aStatus)
otError Dhcp6Server::AppendStatusCode(Message &aMessage, Status aStatusCode)
{
StatusCode option;
option.Init();
option.SetStatusCode(aStatus);
option.SetStatusCode(aStatusCode);
return aMessage.Append(&option, sizeof(option));
}
otError Dhcp6Server::AppendIaAddress(Message &aMessage, ClientIdentifier &aClient)
otError Dhcp6Server::AppendIaAddress(Message &aMessage, ClientIdentifier &aClientId)
{
otError error = OT_ERROR_NONE;
@@ -440,7 +440,7 @@ otError Dhcp6Server::AppendIaAddress(Message &aMessage, ClientIdentifier &aClien
{
if (mPrefixAgentsMask & (1 << i))
{
SuccessOrExit(error = AddIaAddress(aMessage, mPrefixAgents[i].GetPrefix(), aClient));
SuccessOrExit(error = AddIaAddress(aMessage, mPrefixAgents[i].GetPrefix(), aClientId));
}
}
}
@@ -451,7 +451,7 @@ otError Dhcp6Server::AppendIaAddress(Message &aMessage, ClientIdentifier &aClien
{
if (mPrefixAgents[i].IsValid())
{
SuccessOrExit(error = AddIaAddress(aMessage, mPrefixAgents[i].GetPrefix(), aClient));
SuccessOrExit(error = AddIaAddress(aMessage, mPrefixAgents[i].GetPrefix(), aClientId));
}
}
}
@@ -460,14 +460,14 @@ exit:
return error;
}
otError Dhcp6Server::AddIaAddress(Message &aMessage, const Ip6::Address &aPrefix, ClientIdentifier &aClient)
otError Dhcp6Server::AddIaAddress(Message &aMessage, const Ip6::Address &aPrefix, ClientIdentifier &aClientId)
{
otError error = OT_ERROR_NONE;
IaAddress option;
option.Init();
memcpy(option.GetAddress().mFields.m8, &aPrefix, OT_IP6_PREFIX_SIZE);
option.GetAddress().SetIid(*reinterpret_cast<Mac::ExtAddress *>(aClient.GetDuidLinkLayerAddress()));
option.GetAddress().SetIid(*reinterpret_cast<Mac::ExtAddress *>(aClientId.GetDuidLinkLayerAddress()));
option.SetPreferredLifetime(OT_DHCP6_DEFAULT_PREFERRED_LIFETIME);
option.SetValidLifetime(OT_DHCP6_DEFAULT_VALID_LIFETIME);
SuccessOrExit(error = aMessage.Append(&option, sizeof(option)));
+5 -5
View File
@@ -189,15 +189,15 @@ private:
otError AddPrefixAgent(const otIp6Prefix &aIp6Prefix, const Lowpan::Context &aContext);
otError AppendHeader(Message &aMessage, uint8_t *aTransactionId);
otError AppendClientIdentifier(Message &aMessage, ClientIdentifier &aClient);
otError AppendClientIdentifier(Message &aMessage, ClientIdentifier &aClientId);
otError AppendServerIdentifier(Message &aMessage);
otError AppendIaNa(Message &aMessage, IaNa &aIaNa);
otError AppendStatusCode(Message &aMessage, Status aStatusCode);
otError AppendIaAddress(Message &aMessage, ClientIdentifier &aClient);
otError AppendIaAddress(Message &aMessage, ClientIdentifier &aClientId);
otError AppendRapidCommit(Message &aMessage);
otError AppendVendorSpecificInformation(Message &aMessage);
otError AddIaAddress(Message &aMessage, const Ip6::Address &aPrefix, ClientIdentifier &aClient);
otError AddIaAddress(Message &aMessage, const Ip6::Address &aPrefix, ClientIdentifier &aClientId);
static void HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
@@ -205,12 +205,12 @@ private:
void ProcessSolicit(Message &aMessage, otIp6Address &aDst, uint8_t *aTransactionId);
uint16_t FindOption(Message &aMessage, uint16_t aOffset, uint16_t aLength, Code aCode);
otError ProcessClientIdentifier(Message &aMessage, uint16_t aOffset, ClientIdentifier &aClient);
otError ProcessClientIdentifier(Message &aMessage, uint16_t aOffset, ClientIdentifier &aClientId);
otError ProcessIaNa(Message &aMessage, uint16_t aOffset, IaNa &aIaNa);
otError ProcessIaAddress(Message &aMessage, uint16_t aOffset);
otError ProcessElapsedTime(Message &aMessage, uint16_t aOffset);
otError SendReply(otIp6Address &aDst, uint8_t *aTransactionId, ClientIdentifier &aClientIdentifier, IaNa &aIaNa);
otError SendReply(otIp6Address &aDst, uint8_t *aTransactionId, ClientIdentifier &aClientId, IaNa &aIaNa);
Ip6::UdpSocket mSocket;
+4 -4
View File
@@ -309,11 +309,11 @@ public:
/**
* This method updates the ICMPv6 checksum.
*
* @param[in] aMessage A reference to the ICMPv6 message.
* @param[in] aPseudoHeaderChecksum The pseudo-header checksum value.
* @param[in] aMessage A reference to the ICMPv6 message.
* @param[in] aChecksum The pseudo-header checksum value.
*
*/
void UpdateChecksum(Message &aMessage, uint16_t aPseudoHeaderChecksum);
void UpdateChecksum(Message &aMessage, uint16_t aChecksum);
/**
* This method indicates whether or not ICMPv6 Echo processing is enabled.
@@ -342,7 +342,7 @@ public:
bool ShouldHandleEchoRequest(const MessageInfo &aMessageInfo);
private:
otError HandleEchoRequest(Message &aMessage, const MessageInfo &aMessageInfo);
otError HandleEchoRequest(Message &aRequestMessage, const MessageInfo &aMessageInfo);
IcmpHandler *mHandlers;
+14 -14
View File
@@ -248,18 +248,18 @@ exit:
return error;
}
otError Ip6::InsertMplOption(Message &aMessage, Header &aIp6Header, MessageInfo &aMessageInfo)
otError Ip6::InsertMplOption(Message &aMessage, Header &aHeader, MessageInfo &aMessageInfo)
{
otError error = OT_ERROR_NONE;
VerifyOrExit(aIp6Header.GetDestination().IsMulticast() &&
aIp6Header.GetDestination().GetScope() >= Address::kRealmLocalScope);
VerifyOrExit(aHeader.GetDestination().IsMulticast() &&
aHeader.GetDestination().GetScope() >= Address::kRealmLocalScope);
if (aIp6Header.GetDestination().IsRealmLocalMulticast())
if (aHeader.GetDestination().IsRealmLocalMulticast())
{
aMessage.RemoveHeader(sizeof(aIp6Header));
aMessage.RemoveHeader(sizeof(aHeader));
if (aIp6Header.GetNextHeader() == kProtoHopOpts)
if (aHeader.GetNextHeader() == kProtoHopOpts)
{
HopByHopHeader hbh;
uint16_t hbhLength = 0;
@@ -269,7 +269,7 @@ otError Ip6::InsertMplOption(Message &aMessage, Header &aIp6Header, MessageInfo
aMessage.Read(0, sizeof(hbh), &hbh);
hbhLength = (hbh.GetLength() + 1) * 8;
VerifyOrExit(hbhLength <= aIp6Header.GetPayloadLength(), error = OT_ERROR_PARSE);
VerifyOrExit(hbhLength <= aHeader.GetPayloadLength(), error = OT_ERROR_PARSE);
// increase existing hop-by-hop option header length by 8 bytes
hbh.SetLength(hbh.GetLength() + 1);
@@ -280,7 +280,7 @@ otError Ip6::InsertMplOption(Message &aMessage, Header &aIp6Header, MessageInfo
aMessage.CopyTo(8, 0, hbhLength, aMessage);
// insert MPL Option
mMpl.InitOption(mplOption, aIp6Header.GetSource());
mMpl.InitOption(mplOption, aHeader.GetSource());
aMessage.Write(hbhLength, mplOption.GetTotalLength(), &mplOption);
// insert Pad Option (if needed)
@@ -292,19 +292,19 @@ otError Ip6::InsertMplOption(Message &aMessage, Header &aIp6Header, MessageInfo
}
// increase IPv6 Payload Length
aIp6Header.SetPayloadLength(aIp6Header.GetPayloadLength() + 8);
aHeader.SetPayloadLength(aHeader.GetPayloadLength() + 8);
}
else
{
SuccessOrExit(error = AddMplOption(aMessage, aIp6Header));
SuccessOrExit(error = AddMplOption(aMessage, aHeader));
}
SuccessOrExit(error = aMessage.Prepend(&aIp6Header, sizeof(aIp6Header)));
SuccessOrExit(error = aMessage.Prepend(&aHeader, sizeof(aHeader)));
}
else
{
if (aIp6Header.GetDestination().IsMulticastLargerThanRealmLocal() &&
GetInstance().GetThreadNetif().GetMle().HasSleepyChildrenSubscribed(aIp6Header.GetDestination()))
if (aHeader.GetDestination().IsMulticastLargerThanRealmLocal() &&
GetInstance().GetThreadNetif().GetMle().HasSleepyChildrenSubscribed(aHeader.GetDestination()))
{
Message *messageCopy = NULL;
@@ -319,7 +319,7 @@ otError Ip6::InsertMplOption(Message &aMessage, Header &aIp6Header, MessageInfo
}
}
SuccessOrExit(error = AddTunneledMplOption(aMessage, aIp6Header, aMessageInfo));
SuccessOrExit(error = AddTunneledMplOption(aMessage, aHeader, aMessageInfo));
}
exit:
+3 -3
View File
@@ -315,11 +315,11 @@ public:
/**
* This method updates the UDP checksum.
*
* @param[in] aMessage A reference to the UDP message.
* @param[in] aPseudoHeaderChecksum The pseudo-header checksum value.
* @param[in] aMessage A reference to the UDP message.
* @param[in] aChecksum The pseudo-header checksum value.
*
*/
void UpdateChecksum(Message &aMessage, uint16_t aPseudoHeaderChecksum);
void UpdateChecksum(Message &aMessage, uint16_t aChecksum);
#if OPENTHREAD_ENABLE_PLATFORM_UDP
otUdpSocket *GetUdpSockets(void) { return mSockets; }
+2 -2
View File
@@ -637,7 +637,7 @@ exit:
}
void AddressResolver::SendAddressQueryResponse(const ThreadTargetTlv & aTargetTlv,
const ThreadMeshLocalEidTlv & aMlIidTlv,
const ThreadMeshLocalEidTlv & aMlEidTlv,
const ThreadLastTransactionTimeTlv *aLastTransactionTimeTlv,
const Ip6::Address & aDestination)
{
@@ -654,7 +654,7 @@ void AddressResolver::SendAddressQueryResponse(const ThreadTargetTlv &
message->SetPayloadMarker();
SuccessOrExit(error = message->Append(&aTargetTlv, sizeof(aTargetTlv)));
SuccessOrExit(error = message->Append(&aMlIidTlv, sizeof(aMlIidTlv)));
SuccessOrExit(error = message->Append(&aMlEidTlv, sizeof(aMlEidTlv)));
rloc16Tlv.Init();
rloc16Tlv.SetRloc16(netif.GetMle().GetRloc16());
+7 -4
View File
@@ -59,17 +59,20 @@ AnnounceSenderBase::AnnounceSenderBase(Instance &aInstance, Timer::Handler aHand
{
}
otError AnnounceSenderBase::SendAnnounce(Mac::ChannelMask aMask, uint8_t aCount, uint32_t aPeriod, uint16_t aJitter)
otError AnnounceSenderBase::SendAnnounce(Mac::ChannelMask aChannelMask,
uint8_t aCount,
uint32_t aPeriod,
uint16_t aJitter)
{
otError error = OT_ERROR_NONE;
VerifyOrExit(aPeriod != 0, error = OT_ERROR_INVALID_ARGS);
VerifyOrExit(aJitter < aPeriod, error = OT_ERROR_INVALID_ARGS);
aMask.Intersect(Mac::ChannelMask(Phy::kSupportedChannels));
VerifyOrExit(!aMask.IsEmpty(), error = OT_ERROR_INVALID_ARGS);
aChannelMask.Intersect(Mac::ChannelMask(Phy::kSupportedChannels));
VerifyOrExit(!aChannelMask.IsEmpty(), error = OT_ERROR_INVALID_ARGS);
mChannelMask = aMask;
mChannelMask = aChannelMask;
mCount = aCount;
mPeriod = aPeriod;
mJitter = aJitter;
+10 -10
View File
@@ -265,12 +265,12 @@ public:
/**
* This method decompresses a LOWPAN_IPHC header.
*
* @param[out] aMessage A reference where the IPv6 header will be placed.
* @param[in] aMacSource The MAC source address.
* @param[in] aMacDest The MAC destination address.
* @param[in] aBuf A pointer to the LOWPAN_IPHC header.
* @param[in] aBufLen The number of bytes in @p aBuf.
* @param[in] aDatagramLen The IPv6 datagram length.
* @param[out] aMessage A reference where the IPv6 header will be placed.
* @param[in] aMacSource The MAC source address.
* @param[in] aMacDest The MAC destination address.
* @param[in] aBuf A pointer to the LOWPAN_IPHC header.
* @param[in] aBufLength The number of bytes in @p aBuf.
* @param[in] aDatagramLength The IPv6 datagram length.
*
* @returns The size of the compressed header in bytes.
*
@@ -279,13 +279,13 @@ public:
const Mac::Address &aMacSource,
const Mac::Address &aMacDest,
const uint8_t * aBuf,
uint16_t aBufLen,
uint16_t aDatagramLen);
uint16_t aBufLength,
uint16_t aDatagramLength);
/**
* This method decompresses a LOWPAN_IPHC header.
*
* @param[out] aHeader A reference where the IPv6 header will be placed.
* @param[out] aIp6Header A reference where the IPv6 header will be placed.
* @param[out] aCommpressedNextHeader A boolean reference to output whether next header is compressed or not.
* @param[in] aMacSource The MAC source address.
* @param[in] aMacDest The MAC destination address.
@@ -295,7 +295,7 @@ public:
* @returns The size of the compressed header in bytes or -1 if decompression fails.
*
*/
int DecompressBaseHeader(Ip6::Header & aHeader,
int DecompressBaseHeader(Ip6::Header & aIp6Header,
bool & aCompressedNextHeader,
const Mac::Address &aMacSource,
const Mac::Address &aMacDest,
+4 -4
View File
@@ -400,16 +400,16 @@ private:
void PrepareIndirectTransmission(Message &aMessage, const Child &aChild);
otError PrepareDataPoll(void);
void HandleMesh(uint8_t * aFrame,
uint8_t aPayloadLength,
uint8_t aFrameLength,
const Mac::Address & aMacSource,
const otThreadLinkInfo &aLinkInfo);
void HandleFragment(uint8_t * aFrame,
uint8_t aPayloadLength,
uint8_t aFrameLength,
const Mac::Address & aMacSource,
const Mac::Address & aMacDest,
const otThreadLinkInfo &aLinkInfo);
void HandleLowpanHC(uint8_t * aFrame,
uint8_t aPayloadLength,
uint8_t aFrameLength,
const Mac::Address & aMacSource,
const Mac::Address & aMacDest,
const otThreadLinkInfo &aLinkInfo);
@@ -441,7 +441,7 @@ private:
void HandleReceivedFrame(Mac::Frame &aFrame);
otError HandleFrameRequest(Mac::Frame &aFrame);
void HandleSentFrame(Mac::Frame &aFrame, otError aError);
void HandleSentFrameToChild(const Mac::Frame &aFrame, otError aError, const Mac::Address &macDest);
void HandleSentFrameToChild(const Mac::Frame &aFrame, otError aError, const Mac::Address &aMacDest);
static void HandleDiscoverTimer(Timer &aTimer);
void HandleDiscoverTimer(void);
+12 -10
View File
@@ -636,11 +636,13 @@ public:
/**
* This method sets the Device Mode as reported in the Mode TLV.
*
* @param[in] aDeviceMode The device mode to set.
*
* @retval OT_ERROR_NONE Successfully set the Mode TLV.
* @retval OT_ERROR_INVALID_ARGS The mode combination specified in @p aMode is invalid.
*
*/
otError SetDeviceMode(uint8_t aMode);
otError SetDeviceMode(uint8_t aDeviceMode);
/**
* This method indicates whether or not the device is rx-on-when-idle.
@@ -700,10 +702,10 @@ public:
/**
* This method sets the Mesh Local Prefix.
*
* @param[in] aPrefix A reference to the Mesh Local Prefix.
* @param[in] aMeshLocalPrefix A reference to the Mesh Local Prefix.
*
*/
void SetMeshLocalPrefix(const otMeshLocalPrefix &aPrefix);
void SetMeshLocalPrefix(const otMeshLocalPrefix &aMeshLocalPrefix);
/**
* This method applies the Mesh Local Prefix.
@@ -1549,21 +1551,21 @@ protected:
/**
* This method prints an MLE log message with an IPv6 address.
*
* @param[in] aLogMessage The log message string.
* @param[in] aAddress The IPv6 address of the peer.
* @param[in] aLogString The log message string.
* @param[in] aAddress The IPv6 address of the peer.
*
*/
void LogMleMessage(const char *aLogMessage, const Ip6::Address &aAddress) const;
void LogMleMessage(const char *aLogString, const Ip6::Address &aAddress) const;
/**
* This method prints an MLE log message with an IPv6 address and RLOC16.
*
* @param[in] aLogMessage The log message string.
* @param[in] aAddress The IPv6 address of the peer.
* @param[in] aRloc The RLOC16.
* @param[in] aLogString The log message string.
* @param[in] aAddress The IPv6 address of the peer.
* @param[in] aRloc The RLOC16.
*
*/
void LogMleMessage(const char *aLogMessage, const Ip6::Address &aAddress, uint16_t aRloc) const;
void LogMleMessage(const char *aLogString, const Ip6::Address &aAddress, uint16_t aRloc) const;
/**
* This method triggers MLE Announce on previous channel after the Thread device successfully
+4 -4
View File
@@ -2977,7 +2977,7 @@ exit:
void MleRouter::SendChildUpdateResponse(Child * aChild,
const Ip6::MessageInfo &aMessageInfo,
const uint8_t * aTlvs,
uint8_t aTlvslength,
uint8_t aTlvsLength,
const ChallengeTlv * aChallenge)
{
otError error = OT_ERROR_NONE;
@@ -2986,7 +2986,7 @@ void MleRouter::SendChildUpdateResponse(Child * aChild,
VerifyOrExit((message = NewMleMessage()) != NULL, error = OT_ERROR_NO_BUFS);
SuccessOrExit(error = AppendHeader(*message, Header::kCommandChildUpdateResponse));
for (int i = 0; i < aTlvslength; i++)
for (int i = 0; i < aTlvsLength; i++)
{
switch (aTlvs[i])
{
@@ -4108,7 +4108,7 @@ exit:
}
}
void MleRouter::SendAddressSolicitResponse(const Coap::Message & aRequestHeader,
void MleRouter::SendAddressSolicitResponse(const Coap::Message & aRequest,
const Router * aRouter,
const Ip6::MessageInfo &aMessageInfo)
{
@@ -4121,7 +4121,7 @@ void MleRouter::SendAddressSolicitResponse(const Coap::Message & aRequestHeade
VerifyOrExit((message = netif.GetCoap().NewMessage()) != NULL, error = OT_ERROR_NO_BUFS);
message->SetDefaultResponseHeader(aRequestHeader);
message->SetDefaultResponseHeader(aRequest);
message->SetPayloadMarker();
statusTlv.Init();
+5 -5
View File
@@ -700,7 +700,7 @@ private:
otError HandleLinkAccept(const Message & aMessage,
const Ip6::MessageInfo &aMessageInfo,
uint32_t aKeySequence,
bool request);
bool aRequest);
otError HandleLinkAcceptAndRequest(const Message & aMessage,
const Ip6::MessageInfo &aMessageInfo,
uint32_t aKeySequence);
@@ -739,7 +739,7 @@ private:
const Ip6::MessageInfo &aMessageInfo,
const uint8_t * aTlvs,
uint8_t aTlvsLength,
const ChallengeTlv * challenge);
const ChallengeTlv * aChallenge);
otError SendDataResponse(const Ip6::Address &aDestination,
const uint8_t * aTlvs,
uint8_t aTlvsLength,
@@ -751,13 +751,13 @@ private:
void StopLeader(void);
void SynchronizeChildNetworkData(void);
otError UpdateChildAddresses(const Message &aMessage, uint16_t aOffset, Child &aChild);
void UpdateRoutes(const RouteTlv &aTlv, uint8_t aRouterId);
void UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId);
static void HandleAddressSolicitResponse(void * aContext,
otMessage * aMessage,
const otMessageInfo *aMessageInfo,
otError result);
void HandleAddressSolicitResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, otError result);
otError aResult);
void HandleAddressSolicitResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, otError aResult);
static void HandleAddressRelease(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void HandleAddressRelease(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
static void HandleAddressSolicit(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
+2 -2
View File
@@ -404,7 +404,7 @@ otError LeaderBase::DefaultRouteLookup(PrefixTlv &aPrefix, uint16_t *aRloc16)
otError LeaderBase::SetNetworkData(uint8_t aVersion,
uint8_t aStableVersion,
bool aStable,
bool aStableOnly,
const Message &aMessage,
uint16_t aMessageOffset)
{
@@ -422,7 +422,7 @@ otError LeaderBase::SetNetworkData(uint8_t aVersion,
mVersion = aVersion;
mStableVersion = aStableVersion;
if (aStable)
if (aStableOnly)
{
RemoveTemporaryData(mTlvs, mLength);
}
+13 -13
View File
@@ -1302,15 +1302,15 @@ void Leader::RemoveRloc(uint16_t aRloc16, MatchMode aMatchMode)
otDumpDebgNetData("remove done", mTlvs, mLength);
}
void Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatchMode)
void Leader::RemoveRloc(PrefixTlv &aPrefix, uint16_t aRloc16, MatchMode aMatchMode)
{
NetworkDataTlv *cur = prefix.GetSubTlvs();
NetworkDataTlv *cur = aPrefix.GetSubTlvs();
NetworkDataTlv *end;
ContextTlv * context;
while (1)
{
end = prefix.GetNext();
end = aPrefix.GetNext();
if (cur >= end)
{
@@ -1320,12 +1320,12 @@ void Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatchMod
switch (cur->GetType())
{
case NetworkDataTlv::kTypeHasRoute:
RemoveRloc(prefix, *static_cast<HasRouteTlv *>(cur), aRloc16, aMatchMode);
RemoveRloc(aPrefix, *static_cast<HasRouteTlv *>(cur), aRloc16, aMatchMode);
// remove has route tlv if empty
if (cur->GetLength() == 0)
{
prefix.SetSubTlvsLength(prefix.GetSubTlvsLength() - sizeof(HasRouteTlv));
aPrefix.SetSubTlvsLength(aPrefix.GetSubTlvsLength() - sizeof(HasRouteTlv));
Remove(reinterpret_cast<uint8_t *>(cur), sizeof(HasRouteTlv));
continue;
}
@@ -1333,12 +1333,12 @@ void Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatchMod
break;
case NetworkDataTlv::kTypeBorderRouter:
RemoveRloc(prefix, *static_cast<BorderRouterTlv *>(cur), aRloc16, aMatchMode);
RemoveRloc(aPrefix, *static_cast<BorderRouterTlv *>(cur), aRloc16, aMatchMode);
// remove border router tlv if empty
if (cur->GetLength() == 0)
{
prefix.SetSubTlvsLength(prefix.GetSubTlvsLength() - sizeof(BorderRouterTlv));
aPrefix.SetSubTlvsLength(aPrefix.GetSubTlvsLength() - sizeof(BorderRouterTlv));
Remove(reinterpret_cast<uint8_t *>(cur), sizeof(BorderRouterTlv));
continue;
}
@@ -1352,9 +1352,9 @@ void Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatchMod
cur = cur->GetNext();
}
if ((context = FindContext(prefix)) != NULL)
if ((context = FindContext(aPrefix)) != NULL)
{
if (prefix.GetSubTlvsLength() == sizeof(ContextTlv))
if (aPrefix.GetSubTlvsLength() == sizeof(ContextTlv))
{
context->ClearCompress();
StartContextReuseTimer(context->GetContextId());
@@ -1368,16 +1368,16 @@ void Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatchMod
}
#if OPENTHREAD_ENABLE_SERVICE
void Leader::RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMatchMode)
void Leader::RemoveRloc(ServiceTlv &aService, uint16_t aRloc16, MatchMode aMatchMode)
{
NetworkDataTlv *cur = service.GetSubTlvs();
NetworkDataTlv *cur = aService.GetSubTlvs();
NetworkDataTlv *end;
ServerTlv * server;
uint8_t removeLength;
while (1)
{
end = service.GetNext();
end = aService.GetNext();
if (cur >= end)
{
@@ -1392,7 +1392,7 @@ void Leader::RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMatchM
if (RlocMatch(server->GetServer16(), aRloc16, aMatchMode))
{
removeLength = sizeof(ServerTlv) + server->GetServerDataLength();
service.SetSubTlvsLength(service.GetSubTlvsLength() - removeLength);
aService.SetSubTlvsLength(aService.GetSubTlvsLength() - removeLength);
Remove(reinterpret_cast<uint8_t *>(cur), removeLength);
continue;
}
+3 -3
View File
@@ -182,10 +182,10 @@ private:
otError AddHasRoute(PrefixTlv &aPrefix, HasRouteTlv &aHasRoute);
otError AddBorderRouter(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter);
otError AddNetworkData(uint8_t *aTlvs, uint8_t aTlvsLength, uint8_t *aOldTlvs, uint8_t aOldTlvsLength);
otError AddPrefix(PrefixTlv &aTlv);
otError AddPrefix(PrefixTlv &aPrefix);
#if OPENTHREAD_ENABLE_SERVICE
otError AddServer(ServiceTlv &aService, ServerTlv &aServer, uint8_t *aOldTlvs, uint8_t aOldTlvsLength);
otError AddService(ServiceTlv &aTlv, uint8_t *aOldTlvs, uint8_t aOldTlvsLength);
otError AddService(ServiceTlv &aService, uint8_t *aOldTlvs, uint8_t aOldTlvsLength);
#endif
int AllocateContext(void);
@@ -201,7 +201,7 @@ private:
void RemoveRloc(uint16_t aRloc16, MatchMode aMatchMode);
void RemoveRloc(PrefixTlv &aPrefix, uint16_t aRloc16, MatchMode aMatchMode);
#if OPENTHREAD_ENABLE_SERVICE
void RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMatchMode);
void RemoveRloc(ServiceTlv &aService, uint16_t aRloc16, MatchMode aMatchMode);
#endif
void RemoveRloc(PrefixTlv &aPrefix, HasRouteTlv &aHasRoute, uint16_t aRloc16, MatchMode aMatchMode);
void RemoveRloc(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter, uint16_t aRloc16, MatchMode aMatchMode);
+1 -1
View File
@@ -172,7 +172,7 @@ private:
void UpdateRloc(BorderRouterTlv &aBorderRouter);
#if OPENTHREAD_ENABLE_SERVICE
void UpdateRloc(ServiceTlv &aService);
void UpdateRloc(ServerTlv &aService);
void UpdateRloc(ServerTlv &aServer);
#endif
bool IsOnMeshPrefixConsistent(void);
+3 -3
View File
@@ -312,10 +312,10 @@ public:
/**
* This method updates the router table with a received Route TLV.
*
* @param[in] aRoute A reference to the Route TLV.
* @param[in] aTlv A reference to the Route TLV.
*
*/
void ProcessTlv(const Mle::RouteTlv &aRoute);
void ProcessTlv(const Mle::RouteTlv &aTlv);
/**
* This method updates the router table with a received Router Mask TLV.
@@ -323,7 +323,7 @@ public:
* @param[in] aTlv A reference to the Router Mask TLV.
*
*/
void ProcessTlv(const ThreadRouterMaskTlv &Tlv);
void ProcessTlv(const ThreadRouterMaskTlv &aTlv);
/**
* This method updates the router table and must be called with a one second period.
+4 -4
View File
@@ -172,11 +172,11 @@ exit:
return;
}
otError ThreadNetif::GetLinkAddress(Ip6::LinkAddress &address) const
otError ThreadNetif::GetLinkAddress(Ip6::LinkAddress &aAddress) const
{
address.mType = Ip6::LinkAddress::kEui64;
address.mLength = sizeof(address.mExtAddress);
address.mExtAddress = mMac.GetExtAddress();
aAddress.mType = Ip6::LinkAddress::kEui64;
aAddress.mLength = sizeof(aAddress.mExtAddress);
aAddress.mExtAddress = mMac.GetExtAddress();
return OT_ERROR_NONE;
}
+4 -4
View File
@@ -255,14 +255,14 @@ void ChannelManager::HandleTimer(void)
}
}
void ChannelManager::HandleStateChanged(Notifier::Callback &aCallback, otChangedFlags aFlags)
void ChannelManager::HandleStateChanged(Notifier::Callback &aCallback, otChangedFlags aChangedFlags)
{
aCallback.GetOwner<ChannelManager>().HandleStateChanged(aFlags);
aCallback.GetOwner<ChannelManager>().HandleStateChanged(aChangedFlags);
}
void ChannelManager::HandleStateChanged(otChangedFlags aFlags)
void ChannelManager::HandleStateChanged(otChangedFlags aChangedFlags)
{
VerifyOrExit((aFlags & OT_CHANGED_THREAD_CHANNEL) != 0);
VerifyOrExit((aChangedFlags & OT_CHANGED_THREAD_CHANNEL) != 0);
VerifyOrExit(mChannel == GetInstance().Get<Mac::Mac>().GetPanChannel());
mState = kStateIdle;
+3 -3
View File
@@ -238,11 +238,11 @@ public:
/**
* This method updates the supervision listener state. It informs the listener of a received frame.
*
* @param[in] aSource The source MAC address of the received frame
* @param[in] aIsSecure TRUE to indicate that the received frame is secure, FALSE otherwise.
* @param[in] aSourceAddress The source MAC address of the received frame
* @param[in] aIsSecure TRUE to indicate that the received frame is secure, FALSE otherwise.
*
*/
void UpdateOnReceive(const Mac::Address &aSource, bool aIsSecure);
void UpdateOnReceive(const Mac::Address &aSourceAddress, bool aIsSecure);
private:
enum
+1 -1
View File
@@ -187,7 +187,7 @@ private:
void SetJamState(bool aNewState);
static void HandleTimer(Timer &aTimer);
void HandleTimer(void);
void UpdateHistory(bool aThresholdExceeded);
void UpdateHistory(bool aDidExceedThreshold);
void UpdateJamState(void);
static void HandleStateChanged(Notifier::Callback &aCallback, otChangedFlags aFlags);
void HandleStateChanged(otChangedFlags aFlags);
+4 -4
View File
@@ -27,13 +27,13 @@
#include "utils/wrap_string.h"
size_t missing_strlcat(char *dest, const char *src, size_t size)
size_t missing_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t len = strlen(dest);
size_t len = strlen(dst);
if (len < size - 1)
if (len < dstsize - 1)
{
return (len + strlcpy(dest + len, src, size - len));
return (len + strlcpy(dst + len, src, dstsize - len));
}
return len + strlen(src);
+8 -8
View File
@@ -27,25 +27,25 @@
#include "utils/wrap_string.h"
size_t missing_strlcpy(char *dest, const char *src, size_t size)
size_t missing_strlcpy(char *dst, const char *src, size_t dstsize)
{
const size_t slen = strlen(src);
if (size != 0)
if (dstsize != 0)
{
size--;
dstsize--;
if (slen < size)
if (slen < dstsize)
{
size = slen;
dstsize = slen;
}
if (size != 0)
if (dstsize != 0)
{
memcpy(dest, src, size);
memcpy(dst, src, dstsize);
}
dest[size] = 0;
dst[dstsize] = 0;
}
return slen;
+2 -2
View File
@@ -157,10 +157,10 @@ exit:
AppendErrorResult(error, aOutput, aOutputMaxLen);
}
otError Diag::ParseLong(char *aArgVector, long &aValue)
otError Diag::ParseLong(char *aString, long &aLong)
{
char *endptr;
aValue = strtol(aArgVector, &endptr, 0);
aLong = strtol(aString, &endptr, 0);
return (*endptr == '\0') ? OT_ERROR_NONE : OT_ERROR_PARSE;
}
+3 -3
View File
@@ -55,7 +55,7 @@ void otDiagProcessCmd(int aArgCount, char *aArgVector[], char *aOutput, size_t a
Diag::ProcessCmd(aArgCount, aArgVector, aOutput, aOutputMaxLen);
}
void otDiagProcessCmdLine(const char *aInput, char *aOutput, size_t aOutputMaxLen)
void otDiagProcessCmdLine(const char *aString, char *aOutput, size_t aOutputMaxLen)
{
enum
{
@@ -68,9 +68,9 @@ void otDiagProcessCmdLine(const char *aInput, char *aOutput, size_t aOutputMaxLe
char * argVector[kMaxArgs];
uint8_t argCount = 0;
VerifyOrExit(strnlen(aInput, kMaxCommandBuffer) < kMaxCommandBuffer, error = OT_ERROR_NO_BUFS);
VerifyOrExit(strnlen(aString, kMaxCommandBuffer) < kMaxCommandBuffer, error = OT_ERROR_NO_BUFS);
strcpy(buffer, aInput);
strcpy(buffer, aString);
error = ot::Utils::CmdLineParser::ParseCmd(buffer, argCount, argVector, kMaxArgs);
exit:
+2 -2
View File
@@ -201,9 +201,9 @@ exit:
return error;
}
Decoder::Decoder(FrameWritePointer &aWritePointer, FrameHandler aFrameHandler, void *aContext)
Decoder::Decoder(FrameWritePointer &aFrameWritePointer, FrameHandler aFrameHandler, void *aContext)
: mState(kStateNoSync)
, mWritePointer(aWritePointer)
, mWritePointer(aFrameWritePointer)
, mFrameHandler(aFrameHandler)
, mContext(aContext)
, mFcs(0)
+3 -3
View File
@@ -650,7 +650,7 @@ uint8_t NcpBase::GetWrappedResponseQueueIndex(uint8_t aPosition)
return aPosition;
}
otError NcpBase::EnqueueResponse(uint8_t aHeader, ResponseType aType, unsigned int aKeyOrStatus)
otError NcpBase::EnqueueResponse(uint8_t aHeader, ResponseType aType, unsigned int aPropKeyOrStatus)
{
otError error = OT_ERROR_NONE;
spinel_tid_t tid = SPINEL_HEADER_GET_TID(aHeader);
@@ -664,7 +664,7 @@ otError NcpBase::EnqueueResponse(uint8_t aHeader, ResponseType aType, unsigned i
if (aType == kResponseTypeLastStatus)
{
mChangedPropsSet.AddLastStatus(static_cast<spinel_status_t>(aKeyOrStatus));
mChangedPropsSet.AddLastStatus(static_cast<spinel_status_t>(aPropKeyOrStatus));
}
ExitNow();
@@ -709,7 +709,7 @@ otError NcpBase::EnqueueResponse(uint8_t aHeader, ResponseType aType, unsigned i
entry->mTid = tid;
entry->mIsInUse = true;
entry->mType = aType;
entry->mPropKeyOrStatus = aKeyOrStatus;
entry->mPropKeyOrStatus = aPropKeyOrStatus;
mResponseQueueTail++;
+15 -15
View File
@@ -985,7 +985,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
const uint8_t ** aTlvs,
uint8_t * aTlvsLength,
const otIp6Address ** aDestIpAddress,
bool aAllowEmptyValue)
bool aAllowEmptyValues)
{
otError error = OT_ERROR_NONE;
@@ -1017,7 +1017,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
{
case SPINEL_PROP_DATASET_ACTIVE_TIMESTAMP:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
SuccessOrExit(error = mDecoder.ReadUint64(aDataset.mActiveTimestamp));
}
@@ -1027,7 +1027,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_DATASET_PENDING_TIMESTAMP:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
SuccessOrExit(error = mDecoder.ReadUint64(aDataset.mPendingTimestamp));
}
@@ -1037,7 +1037,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_NET_MASTER_KEY:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
const uint8_t *key;
uint16_t len;
@@ -1052,7 +1052,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_NET_NETWORK_NAME:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
const char *name;
size_t len;
@@ -1068,7 +1068,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_NET_XPANID:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
const uint8_t *xpanid;
uint16_t len;
@@ -1083,7 +1083,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_IPV6_ML_PREFIX:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
const otIp6Address *addr;
uint8_t prefixLen;
@@ -1099,7 +1099,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_DATASET_DELAY_TIMER:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
SuccessOrExit(error = mDecoder.ReadUint32(aDataset.mDelay));
}
@@ -1109,7 +1109,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_MAC_15_4_PANID:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
SuccessOrExit(error = mDecoder.ReadUint16(aDataset.mPanId));
}
@@ -1119,7 +1119,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_PHY_CHAN:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
uint8_t channel;
@@ -1132,7 +1132,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_NET_PSKC:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
const uint8_t *psk;
uint16_t len;
@@ -1147,7 +1147,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_DATASET_SECURITY_POLICY:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
SuccessOrExit(error = mDecoder.ReadUint16(aDataset.mSecurityPolicy.mRotationTime));
SuccessOrExit(error = mDecoder.ReadUint8(aDataset.mSecurityPolicy.mFlags));
@@ -1158,7 +1158,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_PHY_CHAN_SUPPORTED:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
uint8_t channel;
@@ -1177,7 +1177,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_DATASET_RAW_TLVS:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
const uint8_t *tlvs;
uint16_t len;
@@ -1200,7 +1200,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
case SPINEL_PROP_DATASET_DEST_ADDRESS:
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
const otIp6Address *addr;
+5 -5
View File
@@ -41,10 +41,10 @@ namespace Ncp {
const NcpFrameBuffer::FrameTag NcpFrameBuffer::kInvalidTag = NULL;
NcpFrameBuffer::NcpFrameBuffer(uint8_t *aBuffer, uint16_t aBufferLen)
NcpFrameBuffer::NcpFrameBuffer(uint8_t *aBuffer, uint16_t aBufferLength)
: mBuffer(aBuffer)
, mBufferEnd(aBuffer + aBufferLen)
, mBufferLength(aBufferLen)
, mBufferEnd(aBuffer + aBufferLength)
, mBufferLength(aBufferLength)
{
for (uint8_t priority = 0; priority < kNumPrios; priority++)
{
@@ -268,7 +268,7 @@ exit:
}
// This function closes/ends the current segment.
void NcpFrameBuffer::InFrameEndSegment(uint16_t aHeaderFlags)
void NcpFrameBuffer::InFrameEndSegment(uint16_t aSegmentHeaderFlags)
{
uint16_t segmentLength;
uint16_t header;
@@ -283,7 +283,7 @@ void NcpFrameBuffer::InFrameEndSegment(uint16_t aHeaderFlags)
// Update the length and the flags in segment header (at segment head pointer).
header = ReadUint16At(mWriteSegmentHead, mWriteDirection);
header |= (segmentLength & kSegmentHeaderLengthMask);
header |= aHeaderFlags;
header |= aSegmentHeaderFlags;
WriteUint16At(mWriteSegmentHead, header, mWriteDirection);
// Move the segment head to current tail (to be ready for a possible next segment).
+1 -1
View File
@@ -121,7 +121,7 @@ private:
void HandleFrameAddedToNcpBuffer(void);
static void EncodeAndSendToUart(Tasklet &aTasklet);
static void HandleFrame(void *aConext, otError aError);
static void HandleFrame(void *aContext, otError aError);
static void HandleFrameAddedToNcpBuffer(void * aContext,
NcpFrameBuffer::FrameTag aTag,
NcpFrameBuffer::Priority aPriority,
+85 -85
View File
@@ -253,7 +253,7 @@ const char *spinel_next_packed_datatype(const char *pack_format)
}
static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
const uint8_t *data_ptr,
const uint8_t *data_in,
spinel_size_t data_len,
const char * pack_format,
va_list_obj * args)
@@ -280,11 +280,11 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
if (arg_ptr)
{
*arg_ptr = data_ptr[0] != 0;
*arg_ptr = data_in[0] != 0;
}
ret += sizeof(uint8_t);
data_ptr += sizeof(uint8_t);
data_in += sizeof(uint8_t);
data_len -= sizeof(uint8_t);
break;
}
@@ -297,11 +297,11 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
if (arg_ptr)
{
*arg_ptr = data_ptr[0];
*arg_ptr = data_in[0];
}
ret += sizeof(uint8_t);
data_ptr += sizeof(uint8_t);
data_in += sizeof(uint8_t);
data_len -= sizeof(uint8_t);
break;
}
@@ -314,11 +314,11 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
if (arg_ptr)
{
*arg_ptr = (uint16_t)((data_ptr[1] << 8) | data_ptr[0]);
*arg_ptr = (uint16_t)((data_in[1] << 8) | data_in[0]);
}
ret += sizeof(uint16_t);
data_ptr += sizeof(uint16_t);
data_in += sizeof(uint16_t);
data_len -= sizeof(uint16_t);
break;
}
@@ -331,11 +331,11 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
if (arg_ptr)
{
*arg_ptr = (uint32_t)((data_ptr[3] << 24) | (data_ptr[2] << 16) | (data_ptr[1] << 8) | data_ptr[0]);
*arg_ptr = (uint32_t)((data_in[3] << 24) | (data_in[2] << 16) | (data_in[1] << 8) | data_in[0]);
}
ret += sizeof(uint32_t);
data_ptr += sizeof(uint32_t);
data_in += sizeof(uint32_t);
data_len -= sizeof(uint32_t);
break;
}
@@ -348,14 +348,14 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
if (arg_ptr)
{
uint32_t l32 = (uint32_t)((data_ptr[3] << 24) | (data_ptr[2] << 16) | (data_ptr[1] << 8) | data_ptr[0]);
uint32_t h32 = (uint32_t)((data_ptr[7] << 24) | (data_ptr[6] << 16) | (data_ptr[5] << 8) | data_ptr[4]);
uint32_t l32 = (uint32_t)((data_in[3] << 24) | (data_in[2] << 16) | (data_in[1] << 8) | data_in[0]);
uint32_t h32 = (uint32_t)((data_in[7] << 24) | (data_in[6] << 16) | (data_in[5] << 8) | data_in[4]);
*arg_ptr = ((uint64_t)l32) | (((uint64_t)h32) << 32);
}
ret += sizeof(uint64_t);
data_ptr += sizeof(uint64_t);
data_in += sizeof(uint64_t);
data_len -= sizeof(uint64_t);
break;
}
@@ -369,7 +369,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
spinel_ipv6addr_t *arg = va_arg(args->obj, spinel_ipv6addr_t *);
if (arg)
{
memcpy(arg, data_ptr, sizeof(spinel_ipv6addr_t));
memcpy(arg, data_in, sizeof(spinel_ipv6addr_t));
}
}
else
@@ -377,12 +377,12 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
const spinel_ipv6addr_t **arg_ptr = va_arg(args->obj, const spinel_ipv6addr_t **);
if (arg_ptr)
{
*arg_ptr = (const spinel_ipv6addr_t *)data_ptr;
*arg_ptr = (const spinel_ipv6addr_t *)data_in;
}
}
ret += sizeof(spinel_ipv6addr_t);
data_ptr += sizeof(spinel_ipv6addr_t);
data_in += sizeof(spinel_ipv6addr_t);
data_len -= sizeof(spinel_ipv6addr_t);
break;
}
@@ -396,7 +396,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
spinel_eui64_t *arg = va_arg(args->obj, spinel_eui64_t *);
if (arg)
{
memcpy(arg, data_ptr, sizeof(spinel_eui64_t));
memcpy(arg, data_in, sizeof(spinel_eui64_t));
}
}
else
@@ -404,12 +404,12 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
const spinel_eui64_t **arg_ptr = va_arg(args->obj, const spinel_eui64_t **);
if (arg_ptr)
{
*arg_ptr = (const spinel_eui64_t *)data_ptr;
*arg_ptr = (const spinel_eui64_t *)data_in;
}
}
ret += sizeof(spinel_eui64_t);
data_ptr += sizeof(spinel_eui64_t);
data_in += sizeof(spinel_eui64_t);
data_len -= sizeof(spinel_eui64_t);
break;
}
@@ -423,7 +423,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
spinel_eui48_t *arg = va_arg(args->obj, spinel_eui48_t *);
if (arg)
{
memcpy(arg, data_ptr, sizeof(spinel_eui48_t));
memcpy(arg, data_in, sizeof(spinel_eui48_t));
}
}
else
@@ -431,12 +431,12 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
const spinel_eui48_t **arg_ptr = va_arg(args->obj, const spinel_eui48_t **);
if (arg_ptr)
{
*arg_ptr = (const spinel_eui48_t *)data_ptr;
*arg_ptr = (const spinel_eui48_t *)data_in;
}
}
ret += sizeof(spinel_eui48_t);
data_ptr += sizeof(spinel_eui48_t);
data_in += sizeof(spinel_eui48_t);
data_len -= sizeof(spinel_eui48_t);
break;
}
@@ -444,7 +444,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
case SPINEL_DATATYPE_UINT_PACKED_C:
{
unsigned int * arg_ptr = va_arg(args->obj, unsigned int *);
spinel_ssize_t pui_len = spinel_packed_uint_decode(data_ptr, data_len, arg_ptr);
spinel_ssize_t pui_len = spinel_packed_uint_decode(data_in, data_len, arg_ptr);
// Range check
require_action(NULL == arg_ptr || (*arg_ptr < SPINEL_MAX_UINT_PACKED), bail, (ret = -1, errno = ERANGE));
@@ -454,7 +454,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
require(pui_len <= (spinel_ssize_t)data_len, bail);
ret += pui_len;
data_ptr += pui_len;
data_in += pui_len;
data_len -= (spinel_size_t)pui_len;
break;
}
@@ -469,7 +469,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
// Add 1 for zero termination. If not zero terminated,
// len will then be data_len+1, which we will detect
// in the next check.
len = strnlen((const char *)data_ptr, data_len) + 1;
len = strnlen((const char *)data_in, data_len) + 1;
// Verify that the string is zero terminated.
require_action(len <= data_len, bail, (ret = -1, errno = EOVERFLOW));
@@ -481,7 +481,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
if (arg)
{
require_action(len_arg >= len, bail, (ret = -1, errno = ENOMEM));
memcpy(arg, data_ptr, len);
memcpy(arg, data_in, len);
}
}
else
@@ -489,12 +489,12 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
const char **arg_ptr = va_arg(args->obj, const char **);
if (arg_ptr)
{
*arg_ptr = (const char *)data_ptr;
*arg_ptr = (const char *)data_in;
}
}
ret += (spinel_size_t)len;
data_ptr += len;
data_in += len;
data_len -= (spinel_size_t)len;
break;
}
@@ -504,14 +504,14 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
{
spinel_ssize_t pui_len = 0;
uint16_t block_len = 0;
const uint8_t *block_ptr = data_ptr;
const uint8_t *block_ptr = data_in;
void * arg_ptr = va_arg(args->obj, void *);
unsigned int * block_len_ptr = va_arg(args->obj, unsigned int *);
char nextformat = *spinel_next_packed_datatype(pack_format);
if ((pack_format[0] == SPINEL_DATATYPE_DATA_WLEN_C) || ((nextformat != 0) && (nextformat != ')')))
{
pui_len = spinel_datatype_unpack(data_ptr, data_len, SPINEL_DATATYPE_UINT16_S, &block_len);
pui_len = spinel_datatype_unpack(data_in, data_len, SPINEL_DATATYPE_UINT16_S, &block_len);
block_ptr += pui_len;
require(pui_len > 0, bail);
@@ -546,7 +546,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
block_len += (uint16_t)pui_len;
ret += block_len;
data_ptr += block_len;
data_in += block_len;
data_len -= block_len;
break;
}
@@ -557,12 +557,12 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
spinel_ssize_t pui_len = 0;
uint16_t block_len = 0;
spinel_ssize_t actual_len = 0;
const uint8_t *block_ptr = data_ptr;
const uint8_t *block_ptr = data_in;
char nextformat = *spinel_next_packed_datatype(pack_format);
if ((pack_format[0] == SPINEL_DATATYPE_STRUCT_C) || ((nextformat != 0) && (nextformat != ')')))
{
pui_len = spinel_datatype_unpack(data_ptr, data_len, SPINEL_DATATYPE_UINT16_S, &block_len);
pui_len = spinel_datatype_unpack(data_in, data_len, SPINEL_DATATYPE_UINT16_S, &block_len);
block_ptr += pui_len;
require(pui_len > 0, bail);
@@ -590,7 +590,7 @@ static spinel_ssize_t spinel_datatype_vunpack_(bool in_place,
}
ret += block_len;
data_ptr += block_len;
data_in += block_len;
data_len -= block_len;
break;
}
@@ -614,7 +614,7 @@ bail:
return ret;
}
spinel_ssize_t spinel_datatype_unpack_in_place(const uint8_t *data_ptr,
spinel_ssize_t spinel_datatype_unpack_in_place(const uint8_t *data_in,
spinel_size_t data_len,
const char * pack_format,
...)
@@ -623,25 +623,25 @@ spinel_ssize_t spinel_datatype_unpack_in_place(const uint8_t *data_ptr,
va_list_obj args;
va_start(args.obj, pack_format);
ret = spinel_datatype_vunpack_(true, data_ptr, data_len, pack_format, &args);
ret = spinel_datatype_vunpack_(true, data_in, data_len, pack_format, &args);
va_end(args.obj);
return ret;
}
spinel_ssize_t spinel_datatype_unpack(const uint8_t *data_ptr, spinel_size_t data_len, const char *pack_format, ...)
spinel_ssize_t spinel_datatype_unpack(const uint8_t *data_in, spinel_size_t data_len, const char *pack_format, ...)
{
spinel_ssize_t ret;
va_list_obj args;
va_start(args.obj, pack_format);
ret = spinel_datatype_vunpack_(false, data_ptr, data_len, pack_format, &args);
ret = spinel_datatype_vunpack_(false, data_in, data_len, pack_format, &args);
va_end(args.obj);
return ret;
}
spinel_ssize_t spinel_datatype_vunpack_in_place(const uint8_t *data_ptr,
spinel_ssize_t spinel_datatype_vunpack_in_place(const uint8_t *data_in,
spinel_size_t data_len,
const char * pack_format,
va_list args)
@@ -650,13 +650,13 @@ spinel_ssize_t spinel_datatype_vunpack_in_place(const uint8_t *data_ptr,
va_list_obj args_obj;
va_copy(args_obj.obj, args);
ret = spinel_datatype_vunpack_(true, data_ptr, data_len, pack_format, &args_obj);
ret = spinel_datatype_vunpack_(true, data_in, data_len, pack_format, &args_obj);
va_end(args_obj.obj);
return ret;
}
spinel_ssize_t spinel_datatype_vunpack(const uint8_t *data_ptr,
spinel_ssize_t spinel_datatype_vunpack(const uint8_t *data_in,
spinel_size_t data_len,
const char * pack_format,
va_list args)
@@ -665,13 +665,13 @@ spinel_ssize_t spinel_datatype_vunpack(const uint8_t *data_ptr,
va_list_obj args_obj;
va_copy(args_obj.obj, args);
ret = spinel_datatype_vunpack_(false, data_ptr, data_len, pack_format, &args_obj);
ret = spinel_datatype_vunpack_(false, data_in, data_len, pack_format, &args_obj);
va_end(args_obj.obj);
return ret;
}
static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_out,
spinel_size_t data_len_max,
const char * pack_format,
va_list_obj * args)
@@ -698,8 +698,8 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(uint8_t))
{
data_ptr[0] = (arg != false);
data_ptr += sizeof(uint8_t);
data_out[0] = (arg != false);
data_out += sizeof(uint8_t);
data_len_max -= sizeof(uint8_t);
}
else
@@ -718,8 +718,8 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(uint8_t))
{
data_ptr[0] = arg;
data_ptr += sizeof(uint8_t);
data_out[0] = arg;
data_out += sizeof(uint8_t);
data_len_max -= sizeof(uint8_t);
}
else
@@ -738,9 +738,9 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(uint16_t))
{
data_ptr[1] = (arg >> 8) & 0xff;
data_ptr[0] = (arg >> 0) & 0xff;
data_ptr += sizeof(uint16_t);
data_out[1] = (arg >> 8) & 0xff;
data_out[0] = (arg >> 0) & 0xff;
data_out += sizeof(uint16_t);
data_len_max -= sizeof(uint16_t);
}
else
@@ -759,11 +759,11 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(uint32_t))
{
data_ptr[3] = (arg >> 24) & 0xff;
data_ptr[2] = (arg >> 16) & 0xff;
data_ptr[1] = (arg >> 8) & 0xff;
data_ptr[0] = (arg >> 0) & 0xff;
data_ptr += sizeof(uint32_t);
data_out[3] = (arg >> 24) & 0xff;
data_out[2] = (arg >> 16) & 0xff;
data_out[1] = (arg >> 8) & 0xff;
data_out[0] = (arg >> 0) & 0xff;
data_out += sizeof(uint32_t);
data_len_max -= sizeof(uint32_t);
}
else
@@ -783,15 +783,15 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(uint64_t))
{
data_ptr[7] = (arg >> 56) & 0xff;
data_ptr[6] = (arg >> 48) & 0xff;
data_ptr[5] = (arg >> 40) & 0xff;
data_ptr[4] = (arg >> 32) & 0xff;
data_ptr[3] = (arg >> 24) & 0xff;
data_ptr[2] = (arg >> 16) & 0xff;
data_ptr[1] = (arg >> 8) & 0xff;
data_ptr[0] = (arg >> 0) & 0xff;
data_ptr += sizeof(uint64_t);
data_out[7] = (arg >> 56) & 0xff;
data_out[6] = (arg >> 48) & 0xff;
data_out[5] = (arg >> 40) & 0xff;
data_out[4] = (arg >> 32) & 0xff;
data_out[3] = (arg >> 24) & 0xff;
data_out[2] = (arg >> 16) & 0xff;
data_out[1] = (arg >> 8) & 0xff;
data_out[0] = (arg >> 0) & 0xff;
data_out += sizeof(uint64_t);
data_len_max -= sizeof(uint64_t);
}
else
@@ -809,8 +809,8 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(spinel_ipv6addr_t))
{
*(spinel_ipv6addr_t *)data_ptr = *arg;
data_ptr += sizeof(spinel_ipv6addr_t);
*(spinel_ipv6addr_t *)data_out = *arg;
data_out += sizeof(spinel_ipv6addr_t);
data_len_max -= sizeof(spinel_ipv6addr_t);
}
else
@@ -828,8 +828,8 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(spinel_eui48_t))
{
*(spinel_eui48_t *)data_ptr = *arg;
data_ptr += sizeof(spinel_eui48_t);
*(spinel_eui48_t *)data_out = *arg;
data_out += sizeof(spinel_eui48_t);
data_len_max -= sizeof(spinel_eui48_t);
}
else
@@ -847,8 +847,8 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= sizeof(spinel_eui64_t))
{
*(spinel_eui64_t *)data_ptr = *arg;
data_ptr += sizeof(spinel_eui64_t);
*(spinel_eui64_t *)data_out = *arg;
data_out += sizeof(spinel_eui64_t);
data_len_max -= sizeof(spinel_eui64_t);
}
else
@@ -870,12 +870,12 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
errno = EINVAL;
});
encoded_size = spinel_packed_uint_encode(data_ptr, data_len_max, arg);
encoded_size = spinel_packed_uint_encode(data_out, data_len_max, arg);
ret += encoded_size;
if ((spinel_ssize_t)data_len_max >= encoded_size)
{
data_ptr += encoded_size;
data_out += encoded_size;
data_len_max -= (spinel_size_t)encoded_size;
}
else
@@ -905,9 +905,9 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= string_arg_len)
{
memcpy(data_ptr, string_arg, string_arg_len);
memcpy(data_out, string_arg, string_arg_len);
data_ptr += string_arg_len;
data_out += string_arg_len;
data_len_max -= (spinel_size_t)string_arg_len;
}
else
@@ -928,7 +928,7 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if ((pack_format[0] == SPINEL_DATATYPE_DATA_WLEN_C) || ((nextformat != 0) && (nextformat != ')')))
{
size_len = spinel_datatype_pack(data_ptr, data_len_max, SPINEL_DATATYPE_UINT16_S, data_size_arg);
size_len = spinel_datatype_pack(data_out, data_len_max, SPINEL_DATATYPE_UINT16_S, data_size_arg);
require_action(size_len > 0, bail, {
ret = -1;
errno = EINVAL;
@@ -939,12 +939,12 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (data_len_max >= (spinel_size_t)size_len + data_size_arg)
{
data_ptr += size_len;
data_out += size_len;
data_len_max -= (spinel_size_t)size_len;
memcpy(data_ptr, arg, data_size_arg);
memcpy(data_out, arg, data_size_arg);
data_ptr += data_size_arg;
data_out += data_size_arg;
data_len_max -= data_size_arg;
}
else
@@ -977,7 +977,7 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if ((pack_format[0] == SPINEL_DATATYPE_STRUCT_C) || ((nextformat != 0) && (nextformat != ')')))
{
size_len = spinel_datatype_pack(data_ptr, data_len_max, SPINEL_DATATYPE_UINT16_S, struct_len);
size_len = spinel_datatype_pack(data_out, data_len_max, SPINEL_DATATYPE_UINT16_S, struct_len);
require_action(size_len > 0, bail, {
ret = -1;
errno = EINVAL;
@@ -988,12 +988,12 @@ static spinel_ssize_t spinel_datatype_vpack_(uint8_t * data_ptr,
if (struct_len + size_len <= (spinel_ssize_t)data_len_max)
{
data_ptr += size_len;
data_out += size_len;
data_len_max -= (spinel_size_t)size_len;
struct_len = spinel_datatype_vpack_(data_ptr, data_len_max, pack_format + 2, args);
struct_len = spinel_datatype_vpack_(data_out, data_len_max, pack_format + 2, args);
data_ptr += struct_len;
data_out += struct_len;
data_len_max -= (spinel_size_t)struct_len;
}
else
@@ -1020,19 +1020,19 @@ bail:
return ret;
}
spinel_ssize_t spinel_datatype_pack(uint8_t *data_ptr, spinel_size_t data_len_max, const char *pack_format, ...)
spinel_ssize_t spinel_datatype_pack(uint8_t *data_out, spinel_size_t data_len_max, const char *pack_format, ...)
{
int ret;
va_list_obj args;
va_start(args.obj, pack_format);
ret = spinel_datatype_vpack_(data_ptr, data_len_max, pack_format, &args);
ret = spinel_datatype_vpack_(data_out, data_len_max, pack_format, &args);
va_end(args.obj);
return ret;
}
spinel_ssize_t spinel_datatype_vpack(uint8_t * data_ptr,
spinel_ssize_t spinel_datatype_vpack(uint8_t * data_out,
spinel_size_t data_len_max,
const char * pack_format,
va_list args)
@@ -1041,7 +1041,7 @@ spinel_ssize_t spinel_datatype_vpack(uint8_t * data_ptr,
va_list_obj args_obj;
va_copy(args_obj.obj, args);
ret = spinel_datatype_vpack_(data_ptr, data_len_max, pack_format, &args_obj);
ret = spinel_datatype_vpack_(data_out, data_len_max, pack_format, &args_obj);
va_end(args_obj.obj);
return ret;
+3 -3
View File
@@ -3530,11 +3530,11 @@ typedef char spinel_datatype_t;
#define SPINEL_MAX_UINT_PACKED 2097151
SPINEL_API_EXTERN spinel_ssize_t spinel_datatype_pack(uint8_t * data_out,
spinel_size_t data_len,
spinel_size_t data_len_max,
const char * pack_format,
...);
SPINEL_API_EXTERN spinel_ssize_t spinel_datatype_vpack(uint8_t * data_out,
spinel_size_t data_len,
spinel_size_t data_len_max,
const char * pack_format,
va_list args);
SPINEL_API_EXTERN spinel_ssize_t spinel_datatype_unpack(const uint8_t *data_in,
@@ -3602,7 +3602,7 @@ SPINEL_API_EXTERN spinel_ssize_t spinel_datatype_vunpack_in_place(const uint8_t
SPINEL_API_EXTERN spinel_ssize_t spinel_packed_uint_decode(const uint8_t *bytes,
spinel_size_t len,
unsigned int * value);
unsigned int * value_ptr);
SPINEL_API_EXTERN spinel_ssize_t spinel_packed_uint_encode(uint8_t *bytes, spinel_size_t len, unsigned int value);
SPINEL_API_EXTERN spinel_ssize_t spinel_packed_uint_size(unsigned int value);
+2 -2
View File
@@ -456,14 +456,14 @@ public:
*
* On success, the read position gets updated.
*
* @param[out] aUt8 Reference to a `char` pointer to output the string.
* @param[out] aUtf8 Reference to a `char` pointer to output the string.
* On success, the pointer variable is updated.
*
* @retval OT_ERROR_NONE Successfully read the value.
* @retval OT_ERROR_PARSE Failed to parse/decode the value.
*
*/
otError ReadUtf8(const char *&aUt8);
otError ReadUtf8(const char *&aUtf8);
/**
* This method decodes and reads a data blob (sequence of bytes) form the frame.