From a906e147320f7d402b2f6bb32926c432f4990d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wa=C5=84czyk?= Date: Fri, 19 Feb 2021 18:33:57 +0100 Subject: [PATCH] [spinel] update domain prefix spinel property (#6174) This commit update the spinel domain prefix property with new Nd Dns and Domain Prefix flags. --- src/lib/spinel/spinel.h | 11 ++++++++++- src/ncp/ncp_base_mtd.cpp | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h index c8803fa24..3c1ef6f78 100644 --- a/src/lib/spinel/spinel.h +++ b/src/lib/spinel/spinel.h @@ -616,6 +616,12 @@ enum SPINEL_NET_FLAG_PREFERENCE_MASK = (3 << SPINEL_NET_FLAG_PREFERENCE_OFFSET), }; +enum +{ + SPINEL_NET_FLAG_EXT_DP = (1 << 6), + SPINEL_NET_FLAG_EXT_DNS = (1 << 7), +}; + enum { SPINEL_ROUTE_PREFERENCE_HIGH = (1 << SPINEL_NET_FLAG_PREFERENCE_OFFSET), @@ -2294,7 +2300,7 @@ enum SPINEL_PROP_THREAD_STABLE_NETWORK_DATA_VERSION = SPINEL_PROP_THREAD__BEGIN + 9, /// On-Mesh Prefixes - /** Format: `A(t(6CbCbS))` + /** Format: `A(t(6CbCbSC))` * * Data per item is: * @@ -2305,8 +2311,11 @@ enum * `b`: "Is defined locally" flag. Set if this network was locally * defined. Assumed to be true for set, insert and replace. Clear if * the on mesh network was defined by another node. + * This field is ignored for INSERT and REMOVE commands. * `S`: The RLOC16 of the device that registered this on-mesh prefix entry. * This value is not used and ignored when adding an on-mesh prefix. + * This field is ignored for INSERT and REMOVE commands. + * `C`: TLV flags extended (additional field for Thread 1.2 features). * */ SPINEL_PROP_THREAD_ON_MESH_NETS = SPINEL_PROP_THREAD__BEGIN + 10, diff --git a/src/ncp/ncp_base_mtd.cpp b/src/ncp/ncp_base_mtd.cpp index 6548231ad..3a4f1755c 100644 --- a/src/ncp/ncp_base_mtd.cpp +++ b/src/ncp/ncp_base_mtd.cpp @@ -111,6 +111,23 @@ static uint8_t BorderRouterConfigToFlagByte(const otBorderRouterConfig &aConfig) return flags; } +static uint8_t BorderRouterConfigToFlagByteExtended(const otBorderRouterConfig &aConfig) +{ + uint8_t flags(0); + + if (aConfig.mNdDns) + { + flags |= SPINEL_NET_FLAG_EXT_DNS; + } + + if (aConfig.mDp) + { + flags |= SPINEL_NET_FLAG_EXT_DP; + } + + return flags; +} + static uint8_t ExternalRoutePreferenceToFlagByte(int aPreference) { uint8_t flags; @@ -768,6 +785,7 @@ template <> otError NcpBase::HandlePropertyGet( SuccessOrExit(error = mEncoder.WriteUint8(BorderRouterConfigToFlagByte(borderRouterConfig))); SuccessOrExit(error = mEncoder.WriteBool(false)); // isLocal SuccessOrExit(error = mEncoder.WriteUint16(borderRouterConfig.mRloc16)); + SuccessOrExit(error = mEncoder.WriteUint8(BorderRouterConfigToFlagByteExtended(borderRouterConfig))); SuccessOrExit(error = mEncoder.CloseStruct()); } @@ -787,6 +805,7 @@ template <> otError NcpBase::HandlePropertyGet( SuccessOrExit(error = mEncoder.WriteUint8(BorderRouterConfigToFlagByte(borderRouterConfig))); SuccessOrExit(error = mEncoder.WriteBool(true)); // isLocal SuccessOrExit(error = mEncoder.WriteUint16(borderRouterConfig.mRloc16)); + SuccessOrExit(error = mEncoder.WriteUint8(BorderRouterConfigToFlagByteExtended(borderRouterConfig))); SuccessOrExit(error = mEncoder.CloseStruct()); } @@ -802,8 +821,11 @@ template <> otError NcpBase::HandlePropertyInsert otError NcpBase::HandlePropertyInsert