[spinel] update domain prefix spinel property (#6174)

This commit update the spinel domain prefix property with new Nd Dns
and Domain Prefix flags.
This commit is contained in:
Paweł Wańczyk
2021-02-19 09:33:57 -08:00
committed by GitHub
parent cf0640973e
commit a906e14732
2 changed files with 43 additions and 2 deletions
+10 -1
View File
@@ -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,
+33 -1
View File
@@ -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<SPINEL_PROP_THREAD_ON_MESH_NETS>(
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<SPINEL_PROP_THREAD_ON_MESH_NETS>(
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<SPINEL_PROP_THREAD_ON_MESH_NET
otError error = OT_ERROR_NONE;
otBorderRouterConfig borderRouterConfig;
bool stable = false;
uint8_t flags = 0;
bool isLocal;
uint8_t flags = 0;
uint8_t flagsExtended = 0;
uint8_t prefixLength;
uint16_t rloc16;
memset(&borderRouterConfig, 0, sizeof(otBorderRouterConfig));
@@ -824,6 +846,16 @@ template <> otError NcpBase::HandlePropertyInsert<SPINEL_PROP_THREAD_ON_MESH_NET
borderRouterConfig.mDefaultRoute = ((flags & SPINEL_NET_FLAG_DEFAULT_ROUTE) != 0);
borderRouterConfig.mOnMesh = ((flags & SPINEL_NET_FLAG_ON_MESH) != 0);
// A new field 'TLV flags extended' has been added to the SPINEL_PROP_THREAD_ON_MESH_NETS property.
// To correctly handle a new field for INSERT command, the additional fields 'isLocal' and 'rloc16' are read and
// ignored.
if ((mDecoder.ReadBool(isLocal) == OT_ERROR_NONE) && (mDecoder.ReadUint16(rloc16) == OT_ERROR_NONE) &&
(mDecoder.ReadUint8(flagsExtended) == OT_ERROR_NONE))
{
borderRouterConfig.mNdDns = ((flagsExtended & SPINEL_NET_FLAG_EXT_DNS) != 0);
borderRouterConfig.mDp = ((flagsExtended & SPINEL_NET_FLAG_EXT_DP) != 0);
}
error = otBorderRouterAddOnMeshPrefix(mInstance, &borderRouterConfig);
exit: