mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 23:57:47 +00:00
[ncp] add SLAAC related spinel capability and property (#3667)
This commit adds `SPINEL_CAP_SLAAC` which indicates to host whether SLAAC feature is supported. It also adds `SPINEL_PROP_SLAAC_ENABLED` spinel property to let host enable/disable SLAAC module at run-time.
This commit is contained in:
committed by
Jonathan Hui
parent
cce16b6dda
commit
89396ab5d3
@@ -1787,6 +1787,10 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CAPS>(void)
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_OOB_STEERING_DATA));
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_SLAAC
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_SLAAC));
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_PEEK_POKE));
|
||||
#endif
|
||||
|
||||
@@ -511,6 +511,11 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_RCP_VERSION>;
|
||||
break;
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_ENABLE_SLAAC
|
||||
case SPINEL_PROP_SLAAC_ENABLED:
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_SLAAC_ENABLED>;
|
||||
break;
|
||||
#endif
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -842,6 +847,11 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_CHILD_SUPERVISION_CHECK_TIMEOUT>;
|
||||
break;
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_ENABLE_SLAAC
|
||||
case SPINEL_PROP_SLAAC_ENABLED:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_SLAAC_ENABLED>;
|
||||
break;
|
||||
#endif
|
||||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -2833,6 +2833,27 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_RCP_VERSION>(void)
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_POSIX_APP
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_SLAAC
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_SLAAC_ENABLED>(void)
|
||||
{
|
||||
return mEncoder.WriteBool(otIp6IsSlaacEnabled(mInstance));
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_SLAAC_ENABLED>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool enabled;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadBool(enabled));
|
||||
otIp6SetSlaacEnabled(mInstance, enabled);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_SLAAC
|
||||
|
||||
#if OPENTHREAD_ENABLE_LEGACY
|
||||
|
||||
void NcpBase::RegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers)
|
||||
|
||||
@@ -1851,6 +1851,10 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
|
||||
ret = "PARENT_RESPONSE_INFO";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_SLAAC_ENABLED:
|
||||
ret = "SLAAC_ENABLED";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_UART_BITRATE:
|
||||
ret = "UART_BITRATE";
|
||||
break;
|
||||
@@ -2480,6 +2484,10 @@ const char *spinel_capability_to_cstr(unsigned int capability)
|
||||
ret = "POSIX_APP";
|
||||
break;
|
||||
|
||||
case SPINEL_CAP_SLAAC:
|
||||
ret = "SLAAC";
|
||||
break;
|
||||
|
||||
case SPINEL_CAP_ERROR_RATE_TRACKING:
|
||||
ret = "ERROR_RATE_TRACKING";
|
||||
break;
|
||||
|
||||
@@ -778,6 +778,7 @@ enum
|
||||
SPINEL_CAP_TIME_SYNC = (SPINEL_CAP_OPENTHREAD__BEGIN + 7),
|
||||
SPINEL_CAP_CHILD_SUPERVISION = (SPINEL_CAP_OPENTHREAD__BEGIN + 8),
|
||||
SPINEL_CAP_POSIX_APP = (SPINEL_CAP_OPENTHREAD__BEGIN + 9),
|
||||
SPINEL_CAP_SLAAC = (SPINEL_CAP_OPENTHREAD__BEGIN + 10),
|
||||
SPINEL_CAP_OPENTHREAD__END = 640,
|
||||
|
||||
SPINEL_CAP_THREAD__BEGIN = 1024,
|
||||
@@ -3025,6 +3026,17 @@ typedef enum
|
||||
*/
|
||||
SPINEL_PROP_PARENT_RESPONSE_INFO = SPINEL_PROP_OPENTHREAD__BEGIN + 13,
|
||||
|
||||
/// SLAAC enabled
|
||||
/** Format `b` - Read-Write
|
||||
* Required capability: `SPINEL_CAP_SLAAC`
|
||||
*
|
||||
* This property allows the host to enable/disable SLAAC module on NCP at run-time. When SLAAC module is enabled,
|
||||
* SLAAC addresses (based on on-mesh prefixes in Network Data) are added to the interface. When SLAAC module is
|
||||
* disabled any previously added SLAAC address is removed.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_SLAAC_ENABLED = SPINEL_PROP_OPENTHREAD__BEGIN + 14,
|
||||
|
||||
SPINEL_PROP_OPENTHREAD__END = 0x2000,
|
||||
|
||||
SPINEL_PROP_INTERFACE__BEGIN = 0x100,
|
||||
|
||||
Reference in New Issue
Block a user