[network-diagnostic] fix sed capacity when skipped in Connectivity Tlv (#4654)

This commit is contained in:
kangping
2020-03-09 09:19:17 -07:00
committed by GitHub
parent dcfc0bca13
commit c54238fdd6
+31 -5
View File
@@ -368,11 +368,19 @@ public:
*/
bool IsValid(void) const
{
return ((GetLength() >= sizeof(*this) - sizeof(NetworkDiagnosticTlv)) ||
(GetLength() ==
sizeof(*this) - sizeof(NetworkDiagnosticTlv) - sizeof(mSedBufferSize) - sizeof(mSedDatagramCount)));
return IsSedBufferingIncluded() || (GetLength() == sizeof(*this) - sizeof(NetworkDiagnosticTlv) -
sizeof(mSedBufferSize) - sizeof(mSedDatagramCount));
}
/**
* This method indicates whether or not the sed buffer size and datagram count are included.
*
* @retval TRUE If the sed buffer size and datagram count are included.
* @retval FALSE If the sed buffer size and datagram count are not included.
*
*/
bool IsSedBufferingIncluded(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); }
/**
* This method returns the Parent Priority value.
*
@@ -494,7 +502,16 @@ public:
* @returns The SED Buffer Size value.
*
*/
uint16_t GetSedBufferSize(void) const { return HostSwap16(mSedBufferSize); }
uint16_t GetSedBufferSize(void) const
{
uint16_t buffersize = OPENTHREAD_CONFIG_DEFAULT_SED_BUFFER_SIZE;
if (IsSedBufferingIncluded())
{
buffersize = HostSwap16(mSedBufferSize);
}
return buffersize;
}
/**
* This method sets the SED Buffer Size value.
@@ -510,7 +527,16 @@ public:
* @returns The SED Datagram Count value.
*
*/
uint8_t GetSedDatagramCount(void) const { return mSedDatagramCount; }
uint8_t GetSedDatagramCount(void) const
{
uint8_t count = OPENTHREAD_CONFIG_DEFAULT_SED_DATAGRAM_COUNT;
if (IsSedBufferingIncluded())
{
count = mSedDatagramCount;
}
return count;
}
/**
* This method sets the SED Datagram Count value.