From 2ed522e48f5f6a525ff77fa0a8666d606cf79078 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 1 Jun 2017 08:53:50 -0700 Subject: [PATCH] NcpBase: Provide spinel whitelist properties only when whitelist support is enabled (#1856) --- src/ncp/ncp_base.cpp | 30 ++++++++++++++++++++++++++++-- src/ncp/ncp_base.hpp | 8 ++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 611ad7820..4ea3d8c3e 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -168,8 +168,10 @@ const NcpBase::GetPropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] = { SPINEL_PROP_THREAD_COMMISSIONER_ENABLED, &NcpBase::GetPropertyHandler_THREAD_COMMISSIONER_ENABLED }, #endif +#if OPENTHREAD_ENABLE_MAC_WHITELIST { SPINEL_PROP_MAC_WHITELIST, &NcpBase::GetPropertyHandler_MAC_WHITELIST }, { SPINEL_PROP_MAC_WHITELIST_ENABLED, &NcpBase::GetPropertyHandler_MAC_WHITELIST_ENABLED }, +#endif { SPINEL_PROP_THREAD_MODE, &NcpBase::GetPropertyHandler_THREAD_MODE }, { SPINEL_PROP_THREAD_CHILD_TIMEOUT, &NcpBase::GetPropertyHandler_THREAD_CHILD_TIMEOUT }, { SPINEL_PROP_THREAD_RLOC16, &NcpBase::GetPropertyHandler_THREAD_RLOC16 }, @@ -306,8 +308,11 @@ const NcpBase::SetPropertyHandlerEntry NcpBase::mSetPropertyHandlerTable[] = { SPINEL_PROP_IPV6_ICMP_PING_OFFLOAD, &NcpBase::SetPropertyHandler_IPV6_ICMP_PING_OFFLOAD }, { SPINEL_PROP_THREAD_RLOC16_DEBUG_PASSTHRU, &NcpBase::SetPropertyHandler_THREAD_RLOC16_DEBUG_PASSTHRU }, +#if OPENTHREAD_ENABLE_MAC_WHITELIST { SPINEL_PROP_MAC_WHITELIST, &NcpBase::SetPropertyHandler_MAC_WHITELIST }, { SPINEL_PROP_MAC_WHITELIST_ENABLED, &NcpBase::SetPropertyHandler_MAC_WHITELIST_ENABLED }, +#endif + #if OPENTHREAD_ENABLE_RAW_LINK_API { SPINEL_PROP_MAC_SRC_MATCH_ENABLED, &NcpBase::SetPropertyHandler_MAC_SRC_MATCH_ENABLED }, { SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES, &NcpBase::SetPropertyHandler_MAC_SRC_MATCH_SHORT_ADDRESSES }, @@ -375,14 +380,14 @@ const NcpBase::InsertPropertyHandlerEntry NcpBase::mInsertPropertyHandlerTable[] { SPINEL_PROP_THREAD_OFF_MESH_ROUTES, &NcpBase::InsertPropertyHandler_THREAD_OFF_MESH_ROUTES }, { SPINEL_PROP_THREAD_ON_MESH_NETS, &NcpBase::InsertPropertyHandler_THREAD_ON_MESH_NETS }, { SPINEL_PROP_THREAD_ASSISTING_PORTS, &NcpBase::InsertPropertyHandler_THREAD_ASSISTING_PORTS }, - #if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD { SPINEL_PROP_THREAD_JOINERS, &NcpBase::NcpBase::InsertPropertyHandler_THREAD_JOINERS }, #endif { SPINEL_PROP_CNTR_RESET, &NcpBase::SetPropertyHandler_CNTR_RESET }, - +#if OPENTHREAD_ENABLE_MAC_WHITELIST { SPINEL_PROP_MAC_WHITELIST, &NcpBase::InsertPropertyHandler_MAC_WHITELIST }, +#endif }; const NcpBase::RemovePropertyHandlerEntry NcpBase::mRemovePropertyHandlerTable[] = @@ -395,7 +400,9 @@ const NcpBase::RemovePropertyHandlerEntry NcpBase::mRemovePropertyHandlerTable[] { SPINEL_PROP_THREAD_OFF_MESH_ROUTES, &NcpBase::RemovePropertyHandler_THREAD_OFF_MESH_ROUTES }, { SPINEL_PROP_THREAD_ON_MESH_NETS, &NcpBase::RemovePropertyHandler_THREAD_ON_MESH_NETS }, { SPINEL_PROP_THREAD_ASSISTING_PORTS, &NcpBase::RemovePropertyHandler_THREAD_ASSISTING_PORTS }, +#if OPENTHREAD_ENABLE_MAC_WHITELIST { SPINEL_PROP_MAC_WHITELIST, &NcpBase::RemovePropertyHandler_MAC_WHITELIST }, +#endif #if OPENTHREAD_FTD { SPINEL_PROP_THREAD_ACTIVE_ROUTER_IDS, &NcpBase::RemovePropertyHandler_THREAD_ACTIVE_ROUTER_IDS }, #endif @@ -1999,7 +2006,10 @@ otError NcpBase::GetPropertyHandler_CAPS(uint8_t header, spinel_prop_key_t key) SuccessOrExit(errorCode = OutboundFrameFeedPacked(SPINEL_DATATYPE_UINT_PACKED_S, SPINEL_CAP_NET_THREAD_1_0)); SuccessOrExit(errorCode = OutboundFrameFeedPacked(SPINEL_DATATYPE_UINT_PACKED_S, SPINEL_CAP_COUNTERS)); + +#if OPENTHREAD_ENABLE_MAC_WHITELIST SuccessOrExit(errorCode = OutboundFrameFeedPacked(SPINEL_DATATYPE_UINT_PACKED_S, SPINEL_CAP_MAC_WHITELIST)); +#endif #if OPENTHREAD_ENABLE_RAW_LINK_API SuccessOrExit(errorCode = OutboundFrameFeedPacked(SPINEL_DATATYPE_UINT_PACKED_S, SPINEL_CAP_MAC_RAW)); @@ -3697,6 +3707,8 @@ otError NcpBase::GetPropertyHandler_DEBUG_NCP_LOG_LEVEL(uint8_t header, spinel_p ); } +#if OPENTHREAD_ENABLE_MAC_WHITELIST + otError NcpBase::GetPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key) { otMacWhitelistEntry entry; @@ -3759,6 +3771,8 @@ otError NcpBase::GetPropertyHandler_MAC_WHITELIST_ENABLED(uint8_t header, spinel ); } +#endif // OPENTHREAD_ENABLE_MAC_WHITELIST + #if OPENTHREAD_FTD otError NcpBase::GetPropertyHandler_NET_PSKC(uint8_t header, spinel_prop_key_t key) { @@ -5711,6 +5725,8 @@ otError NcpBase::SetPropertyHandler_THREAD_COMMISSIONER_ENABLED(uint8_t header, } #endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD +#if OPENTHREAD_ENABLE_MAC_WHITELIST + otError NcpBase::SetPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len) { @@ -5816,6 +5832,8 @@ otError NcpBase::SetPropertyHandler_MAC_WHITELIST_ENABLED(uint8_t header, spinel return errorCode; } +#endif // OPENTHREAD_ENABLE_MAC_WHITELIST + #if OPENTHREAD_ENABLE_RAW_LINK_API otError NcpBase::SetPropertyHandler_MAC_SRC_MATCH_ENABLED(uint8_t header, spinel_prop_key_t key, @@ -6987,6 +7005,8 @@ otError NcpBase::InsertPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, sp return errorCode; } +#if OPENTHREAD_ENABLE_MAC_WHITELIST + otError NcpBase::InsertPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len) { @@ -7050,6 +7070,8 @@ otError NcpBase::InsertPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop return errorCode; } +#endif // OPENTHREAD_ENABLE_MAC_WHITELIST + #if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD otError NcpBase::InsertPropertyHandler_THREAD_JOINERS(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len) @@ -7448,6 +7470,8 @@ otError NcpBase::RemovePropertyHandler_THREAD_ACTIVE_ROUTER_IDS(uint8_t header, } #endif // OPENTHREAD_FTD +#if OPENTHREAD_ENABLE_MAC_WHITELIST + otError NcpBase::RemovePropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len) { @@ -7482,6 +7506,8 @@ otError NcpBase::RemovePropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop return errorCode; } +#endif // OPENTHREAD_ENABLE_MAC_WHITELIST + #if OPENTHREAD_ENABLE_LEGACY void NcpBase::RegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers) diff --git a/src/ncp/ncp_base.hpp b/src/ncp/ncp_base.hpp index a3f3cf6f0..1ffb93467 100644 --- a/src/ncp/ncp_base.hpp +++ b/src/ncp/ncp_base.hpp @@ -404,8 +404,10 @@ private: otError GetPropertyHandler_MAC_CNTR(uint8_t header, spinel_prop_key_t key); otError GetPropertyHandler_NCP_CNTR(uint8_t header, spinel_prop_key_t key); otError GetPropertyHandler_MSG_BUFFER_COUNTERS(uint8_t header, spinel_prop_key_t key); +#if OPENTHREAD_ENABLE_MAC_WHITELIST otError GetPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key); otError GetPropertyHandler_MAC_WHITELIST_ENABLED(uint8_t header, spinel_prop_key_t key); +#endif otError GetPropertyHandler_THREAD_MODE(uint8_t header, spinel_prop_key_t key); otError GetPropertyHandler_THREAD_CHILD_TIMEOUT(uint8_t header, spinel_prop_key_t key); otError GetPropertyHandler_THREAD_RLOC16(uint8_t header, spinel_prop_key_t key); @@ -514,10 +516,12 @@ private: uint16_t value_len); otError SetPropertyHandler_MAC_SCAN_PERIOD(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); +#if OPENTHREAD_ENABLE_MAC_WHITELIST otError SetPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); otError SetPropertyHandler_MAC_WHITELIST_ENABLED(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); +#endif #if OPENTHREAD_ENABLE_RAW_LINK_API otError SetPropertyHandler_MAC_SRC_MATCH_ENABLED(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); @@ -619,8 +623,10 @@ private: const uint8_t *value_ptr, uint16_t value_len); otError InsertPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); +#if OPENTHREAD_ENABLE_MAC_WHITELIST otError InsertPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); +#endif #if OPENTHREAD_ENABLE_COMMISSIONER otError InsertPropertyHandler_THREAD_JOINERS(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); @@ -640,8 +646,10 @@ private: const uint8_t *value_ptr, uint16_t value_len); otError RemovePropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); +#if OPENTHREAD_ENABLE_MAC_WHITELIST otError RemovePropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len); +#endif #if OPENTHREAD_FTD otError RemovePropertyHandler_THREAD_ACTIVE_ROUTER_IDS(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr, uint16_t value_len);