mirror of
https://github.com/espressif/openthread.git
synced 2026-10-03 14:27:38 +00:00
[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:
+19
-4
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user