mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 13:17:48 +00:00
[mle] add field-specific length methods to Challenge/Response TLVs (#3937)
This commit is contained in:
@@ -2384,7 +2384,7 @@ otError Mle::SendChildUpdateResponse(const uint8_t *aTlvs, uint8_t aNumTlvs, con
|
||||
break;
|
||||
|
||||
case Tlv::kResponse:
|
||||
SuccessOrExit(error = AppendResponse(*message, aChallenge.GetChallenge(), aChallenge.GetLength()));
|
||||
SuccessOrExit(error = AppendResponse(*message, aChallenge.GetChallenge(), aChallenge.GetChallengeLength()));
|
||||
break;
|
||||
|
||||
case Tlv::kLinkFrameCounter:
|
||||
@@ -3212,7 +3212,7 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf
|
||||
// Response
|
||||
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kResponse, sizeof(response), response));
|
||||
VerifyOrExit(response.IsValid() &&
|
||||
memcmp(response.GetResponse(), mParentRequest.mChallenge, response.GetLength()) == 0,
|
||||
memcmp(response.GetResponse(), mParentRequest.mChallenge, response.GetResponseLength()) == 0,
|
||||
error = OT_ERROR_PARSE);
|
||||
|
||||
aMessageInfo.GetPeerAddr().ToExtAddress(extAddress);
|
||||
|
||||
@@ -691,7 +691,7 @@ otError MleRouter::SendLinkAccept(const Ip6::MessageInfo &aMessageInfo,
|
||||
SuccessOrExit(error = AppendHeader(*message, command));
|
||||
SuccessOrExit(error = AppendVersion(*message));
|
||||
SuccessOrExit(error = AppendSourceAddress(*message));
|
||||
SuccessOrExit(error = AppendResponse(*message, aChallenge.GetChallenge(), aChallenge.GetLength()));
|
||||
SuccessOrExit(error = AppendResponse(*message, aChallenge.GetChallenge(), aChallenge.GetChallengeLength()));
|
||||
SuccessOrExit(error = AppendLinkFrameCounter(*message));
|
||||
SuccessOrExit(error = AppendMleFrameCounter(*message));
|
||||
|
||||
@@ -1898,7 +1898,7 @@ void MleRouter::SendParentResponse(Child *aChild, const ChallengeTlv &aChallenge
|
||||
SuccessOrExit(error = AppendLeaderData(*message));
|
||||
SuccessOrExit(error = AppendLinkFrameCounter(*message));
|
||||
SuccessOrExit(error = AppendMleFrameCounter(*message));
|
||||
SuccessOrExit(error = AppendResponse(*message, aChallenge.GetChallenge(), aChallenge.GetLength()));
|
||||
SuccessOrExit(error = AppendResponse(*message, aChallenge.GetChallenge(), aChallenge.GetChallengeLength()));
|
||||
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
|
||||
if (aChild->IsTimeSyncEnabled())
|
||||
{
|
||||
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
/**
|
||||
* This method indicates whether or not the TLV appears to be well-formed.
|
||||
*
|
||||
* OpenThread only generates Challenge values with 8-byte length. As a result, a Response value lengths must also
|
||||
* OpenThread only generates Challenge values with 8-byte length. As a result, Response value lengths must also
|
||||
* have 8-byte length.
|
||||
*
|
||||
* @retval TRUE If the TLV appears to be well-formed.
|
||||
@@ -420,6 +420,14 @@ public:
|
||||
*/
|
||||
bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); }
|
||||
|
||||
/**
|
||||
* This method returns the Response length.
|
||||
*
|
||||
* @returns The Response length.
|
||||
*
|
||||
*/
|
||||
uint8_t GetResponseLength(void) const { return GetLength() <= sizeof(mResponse) ? GetLength() : sizeof(mResponse); }
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the Response value.
|
||||
*
|
||||
@@ -434,7 +442,7 @@ public:
|
||||
* @param[in] aResponse A pointer to the Response value.
|
||||
*
|
||||
*/
|
||||
void SetResponse(const uint8_t *aResponse) { memcpy(mResponse, aResponse, GetLength()); }
|
||||
void SetResponse(const uint8_t *aResponse) { memcpy(mResponse, aResponse, GetResponseLength()); }
|
||||
|
||||
private:
|
||||
uint8_t mResponse[kMaxSize];
|
||||
|
||||
Reference in New Issue
Block a user