diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index 92b9578c1..ab893c82d 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -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_ diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 34b50ea00..addfbf0f7 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -4292,8 +4292,8 @@ void MleRouter::FillConnectivityTlv(ConnectivityTlv &aTlv) aTlv.SetLeaderCost((cost < kMaxRouteCost) ? cost : static_cast(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) diff --git a/src/core/thread/mle_tlvs.hpp b/src/core/thread/mle_tlvs.hpp index 54f22bb73..231165e51 100644 --- a/src/core/thread/mle_tlvs.hpp +++ b/src/core/thread/mle_tlvs.hpp @@ -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.