[ncp] only allow promiscuous mode in link raw mode (#5245)

Many existing IEEE 802.15.4 radios do not support both promiscuous
mode and auto generation of immediate ACKs. This commit prevents
promiscuous mode when the interface is up.
This commit is contained in:
Jonathan Hui
2020-07-17 08:49:51 -07:00
committed by GitHub
parent a1f0b21c16
commit c394080617
+19 -4
View File
@@ -1372,8 +1372,15 @@ exit:
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_MAC_PROMISCUOUS_MODE>(void)
{
return mEncoder.WriteUint8(otPlatRadioGetPromiscuous(mInstance) ? SPINEL_MAC_PROMISCUOUS_MODE_FULL
: SPINEL_MAC_PROMISCUOUS_MODE_OFF);
bool isPromiscuous;
#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
isPromiscuous = otLinkRawGetPromiscuous(mInstance);
#else
isPromiscuous = otLinkIsPromiscuous(mInstance);
#endif
return mEncoder.WriteUint8(isPromiscuous ? SPINEL_MAC_PROMISCUOUS_MODE_FULL : SPINEL_MAC_PROMISCUOUS_MODE_OFF);
}
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_MAC_PROMISCUOUS_MODE>(void)
@@ -1386,12 +1393,20 @@ template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_MAC_PROMISCUOUS_MODE>
switch (mode)
{
case SPINEL_MAC_PROMISCUOUS_MODE_OFF:
otPlatRadioSetPromiscuous(mInstance, false);
#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
error = otLinkRawSetPromiscuous(mInstance, false);
#else
error = otLinkSetPromiscuous(mInstance, false);
#endif
break;
case SPINEL_MAC_PROMISCUOUS_MODE_NETWORK:
case SPINEL_MAC_PROMISCUOUS_MODE_FULL:
otPlatRadioSetPromiscuous(mInstance, true);
#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
error = otLinkRawSetPromiscuous(mInstance, true);
#else
error = otLinkSetPromiscuous(mInstance, true);
#endif
break;
default: