[mle] fix connectivity parse if default sed capacity is not included (#3061)

This commit is contained in:
rongli
2018-09-11 14:49:47 -10:00
committed by Jonathan Hui
parent cd6b9e835c
commit 952542ae35
3 changed files with 56 additions and 6 deletions
+23
View File
@@ -1807,4 +1807,27 @@
#define OPENTHREAD_CONFIG_RETX_POLL_PERIOD 1000
#endif
/**
* @def OPENTHREAD_CONFIG_DEFAULT_SED_BUFFER_SIZE
*
* This setting configures the default buffer size for IPv6 datagram destined for an attached SED.
* A Thread Router MUST be able to buffer at least one 1280-octet IPv6 datagram for an attached SED according to
* the Thread Conformance Specification.
*
*/
#ifndef OPENTHREAD_CONFIG_DEFAULT_SED_BUFFER_SIZE
#define OPENTHREAD_CONFIG_DEFAULT_SED_BUFFER_SIZE 1280
#endif
/**
* @def OPENTHREAD_CONFIG_DEFAULT_SED_DATAGRAM_COUNT
*
* This setting configures the default datagram count of 106-octet IPv6 datagram per attached SED.
* A Thread Router MUST be able to buffer at least one 106-octet IPv6 datagram per attached SED according to
* the Thread Conformance Specification.
*
*/
#ifndef OPENTHREAD_CONFIG_DEFAULT_SED_DATAGRAM_COUNT
#define OPENTHREAD_CONFIG_DEFAULT_SED_DATAGRAM_COUNT 1
#endif
#endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_
+2 -2
View File
@@ -4292,8 +4292,8 @@ void MleRouter::FillConnectivityTlv(ConnectivityTlv &aTlv)
aTlv.SetLeaderCost((cost < kMaxRouteCost) ? cost : static_cast<uint8_t>(kMaxRouteCost));
aTlv.SetIdSequence(mRouterTable.GetRouterIdSequence());
aTlv.SetSedBufferSize(1280);
aTlv.SetSedDatagramCount(1);
aTlv.SetSedBufferSize(OPENTHREAD_CONFIG_DEFAULT_SED_BUFFER_SIZE);
aTlv.SetSedDatagramCount(OPENTHREAD_CONFIG_DEFAULT_SED_DATAGRAM_COUNT);
}
otError MleRouter::AppendConnectivity(Message &aMessage)
+31 -4
View File
@@ -1294,10 +1294,19 @@ public:
*/
bool IsValid(void) const
{
return (GetLength() == sizeof(*this) - sizeof(Tlv) ||
GetLength() == sizeof(*this) - sizeof(Tlv) - sizeof(mSedBufferSize) - sizeof(mSedDatagramCount));
return IsSedBufferingIncluded() ||
(GetLength() == sizeof(*this) - sizeof(Tlv) - 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.
*
@@ -1422,7 +1431,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.
@@ -1438,7 +1456,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.