From 6e6a2ae1458b4240ab31f03104f51b94158cb38a Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Thu, 9 Feb 2023 14:36:53 +0800 Subject: [PATCH] [ncp] remove legacy network support (#8723) This commit removes legacy network support as it's not used anymore. --- etc/cmake/options.cmake | 1 - examples/Makefile-simulation | 1 - examples/README.md | 1 - examples/common-switches.mk | 5 - include/openthread/instance.h | 2 +- include/openthread/ncp.h | 85 --------- script/check-scan-build | 1 - script/check-simulation-build-autotools | 2 - script/cmake-build | 1 - script/make-pretty | 1 - src/cli/cli.cpp | 8 - src/core/BUILD.gn | 4 - src/core/config/misc.h | 10 -- .../config/openthread-core-config-check.h | 4 + src/lib/spinel/spinel.c | 4 - src/lib/spinel/spinel.h | 18 +- src/ncp/changed_props_set.cpp | 4 - src/ncp/ncp_base.cpp | 11 -- src/ncp/ncp_base.hpp | 44 ----- src/ncp/ncp_base_dispatcher.cpp | 7 - src/ncp/ncp_base_mtd.cpp | 166 +----------------- src/posix/Makefile-posix | 1 - tests/toranj/openthread-core-toranj-config.h | 8 - 23 files changed, 19 insertions(+), 370 deletions(-) diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index 8d0151efd..6798f46f5 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -112,7 +112,6 @@ ot_option(OT_HISTORY_TRACKER OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE "history t ot_option(OT_IP6_FRAGM OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE "ipv6 fragmentation") ot_option(OT_JAM_DETECTION OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE "jam detection") ot_option(OT_JOINER OPENTHREAD_CONFIG_JOINER_ENABLE "joiner") -ot_option(OT_LEGACY OPENTHREAD_CONFIG_LEGACY_ENABLE "legacy network") ot_option(OT_LINK_METRICS_INITIATOR OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE "link metrics initiator") ot_option(OT_LINK_METRICS_SUBJECT OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE "link metrics subject") ot_option(OT_LINK_RAW OPENTHREAD_CONFIG_LINK_RAW_ENABLE "link raw service") diff --git a/examples/Makefile-simulation b/examples/Makefile-simulation index f16ce8973..a803486c6 100644 --- a/examples/Makefile-simulation +++ b/examples/Makefile-simulation @@ -58,7 +58,6 @@ HISTORY_TRACKER ?= 1 IP6_FRAGM ?= 1 JAM_DETECTION ?= 1 JOINER ?= 1 -LEGACY ?= 1 LINK_RAW ?= 1 MAC_FILTER ?= 1 MTD_NETDIAG ?= 1 diff --git a/examples/README.md b/examples/README.md index e3f5c8c33..9b76704e9 100644 --- a/examples/README.md +++ b/examples/README.md @@ -46,7 +46,6 @@ This page lists the available common switches with description. Unless stated ot | IP6_FRAGM | OT_IP6_FRAGM | Enables support for IPv6 fragmentation. | | JAM_DETECTION | OT_JAM_DETECTION | Enables support for [Jam Detection](https://openthread.io/guides/build/features/jam-detection). Enable this switch if a device requires the ability to detect signal jamming on a specific channel. | | JOINER | OT_JOINER | Enables [support for Joiner](https://openthread.io/reference/group/api-joiner). Enable this switch on a device that has to be commissioned to join the network. | -| LEGACY | OT_LEGACY | Enables support for legacy network. | | LINK_RAW | OT_LINK_RAW | Enables the Link Raw service. | | LOG_OUTPUT | not implemented | Defines if the LOG output is to be created and where it goes. There are several options available: `NONE`, `DEBUG_UART`, `APP`, `PLATFORM_DEFINED` (default). See [Logging guide](https://openthread.io/guides/build/logs) to learn more. | | MAC_FILTER | OT_MAC_FILTER | Enables support for the MAC filter. | diff --git a/examples/common-switches.mk b/examples/common-switches.mk index 334433945..656ecdc13 100644 --- a/examples/common-switches.mk +++ b/examples/common-switches.mk @@ -61,7 +61,6 @@ HISTORY_TRACKER ?= 0 IP6_FRAGM ?= 0 JAM_DETECTION ?= 0 JOINER ?= 0 -LEGACY ?= 0 ifeq ($(REFERENCE_DEVICE),1) LOG_OUTPUT ?= APP endif @@ -248,10 +247,6 @@ ifeq ($(JOINER),1) COMMONCFLAGS += -DOPENTHREAD_CONFIG_JOINER_ENABLE=1 endif -ifeq ($(LEGACY),1) -COMMONCFLAGS += -DOPENTHREAD_CONFIG_LEGACY_ENABLE=1 -endif - ifeq ($(LINK_RAW),1) COMMONCFLAGS += -DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1 endif diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 2d39be70d..30443d8c0 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (283) +#define OPENTHREAD_API_VERSION (284) /** * @addtogroup api-instance diff --git a/include/openthread/ncp.h b/include/openthread/ncp.h index 72896723c..fb766ef9d 100644 --- a/include/openthread/ncp.h +++ b/include/openthread/ncp.h @@ -161,91 +161,6 @@ typedef bool (*otNcpDelegateAllowPeekPoke)(uint32_t aAddress, uint16_t aCount); void otNcpRegisterPeekPokeDelagates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate, otNcpDelegateAllowPeekPoke aAllowPokeDelegate); -//----------------------------------------------------------------------------------------- -// Legacy network APIs - -#define OT_NCP_LEGACY_ULA_PREFIX_LENGTH 8 ///< Legacy ULA size (in bytes) - -/** - * Defines handler (function pointer) type for starting legacy network - * - * Invoked to start the legacy network. - * - */ -typedef void (*otNcpHandlerStartLegacy)(void); - -/** - * Defines handler (function pointer) type for stopping legacy network - * - * Invoked to stop the legacy network. - * - */ -typedef void (*otNcpHandlerStopLegacy)(void); - -/** - * Defines handler (function pointer) type for initiating joining process. - * - * @param[in] aExtAddress A pointer to the extended address for the node to join - * or NULL if desired to join any neighboring node. - * - * Invoked to initiate a legacy join procedure to any or a specific node. - * - */ -typedef void (*otNcpHandlerJoinLegacyNode)(const otExtAddress *aExtAddress); - -/** - * Defines handler (function pointer) type for setting the legacy ULA prefix. - * - * @param[in] aUlaPrefix A pointer to buffer containing the legacy ULA prefix. - * - * Invoked to set the legacy ULA prefix. - * - */ -typedef void (*otNcpHandlerSetLegacyUlaPrefix)(const uint8_t *aUlaPrefix); - -/** - * Defines a struct containing all the legacy handlers (function pointers). - * - */ -typedef struct otNcpLegacyHandlers -{ - otNcpHandlerStartLegacy mStartLegacy; ///< Start handler - otNcpHandlerStopLegacy mStopLegacy; ///< Stop handler - otNcpHandlerJoinLegacyNode mJoinLegacyNode; ///< Join handler - otNcpHandlerSetLegacyUlaPrefix mSetLegacyUlaPrefix; ///< Set ULA handler -} otNcpLegacyHandlers; - -/** - * This callback is invoked by the legacy stack to notify that a new - * legacy node did join the network. - * - * @param[in] aExtAddr A pointer to the extended address of the joined node. - * - */ -void otNcpHandleLegacyNodeDidJoin(const otExtAddress *aExtAddr); - -/** - * This callback is invoked by the legacy stack to notify that the - * legacy ULA prefix has changed. - * - * @param[in] aUlaPrefix A pointer to the received ULA prefix. - * - */ -void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix); - -/** - * This method registers a set of legacy handlers with NCP. - * - * The set of handlers provided by the struct @p aHandlers are used by - * NCP code to start/stop legacy network. - * The @p aHandlers can be NULL to disable legacy support on NCP. - * Individual handlers in the given handlers struct can also be NULL. - * - * @param[in] aHandlers A pointer to a handler struct. - * - */ -void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers); - /** * @} * diff --git a/script/check-scan-build b/script/check-scan-build index 20064fe24..c93755b56 100755 --- a/script/check-scan-build +++ b/script/check-scan-build @@ -59,7 +59,6 @@ OT_BUILD_OPTIONS=( "-DOT_IP6_FRAGM=ON" "-DOT_JAM_DETECTION=ON" "-DOT_JOINER=ON" - "-DOT_LEGACY=ON" "-DOT_LOG_LEVEL_DYNAMIC=ON" "-DOT_MAC_FILTER=ON" "-DOT_MTD_NETDIAG=ON" diff --git a/script/check-simulation-build-autotools b/script/check-simulation-build-autotools index 5f62a1e02..075b20990 100755 --- a/script/check-simulation-build-autotools +++ b/script/check-simulation-build-autotools @@ -64,7 +64,6 @@ build_all_features() "-DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1" "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" "-DOPENTHREAD_CONFIG_JOINER_ENABLE=1" - "-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1" "-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1" "-DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1" "-DOPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE=1" @@ -149,7 +148,6 @@ build_nest_common() "-DOPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1" "-DOPENTHREAD_CONFIG_DIAG_ENABLE=1" "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" - "-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1" "-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1" "-DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1" "-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1" diff --git a/script/cmake-build b/script/cmake-build index b445bcd33..5aa172388 100755 --- a/script/cmake-build +++ b/script/cmake-build @@ -92,7 +92,6 @@ OT_POSIX_SIM_COMMON_OPTIONS=( "-DOT_IP6_FRAGM=ON" "-DOT_JAM_DETECTION=ON" "-DOT_JOINER=ON" - "-DOT_LEGACY=ON" "-DOT_MAC_FILTER=ON" "-DOT_MTD_NETDIAG=ON" "-DOT_NEIGHBOR_DISCOVERY_AGENT=ON" diff --git a/script/make-pretty b/script/make-pretty index 73756afda..030f1f7fb 100755 --- a/script/make-pretty +++ b/script/make-pretty @@ -116,7 +116,6 @@ OT_CLANG_TIDY_BUILD_OPTS=( '-DOT_IP6_FRAGM=ON' '-DOT_JAM_DETECTION=ON' '-DOT_JOINER=ON' - '-DOT_LEGACY=ON' '-DOT_LINK_RAW=ON' '-DOT_LINK_METRICS_INITIATOR=ON' '-DOT_LINK_METRICS_SUBJECT=ON' diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index e78b61b2d..e45c1ac5f 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -7831,11 +7831,3 @@ exit: } // namespace Cli } // namespace ot - -#if OPENTHREAD_CONFIG_LEGACY_ENABLE -OT_TOOL_WEAK void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers) { OT_UNUSED_VARIABLE(aHandlers); } - -OT_TOOL_WEAK void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix) { OT_UNUSED_VARIABLE(aUlaPrefix); } - -OT_TOOL_WEAK void otNcpHandleLegacyNodeDidJoin(const otExtAddress *aExtAddr) { OT_UNUSED_VARIABLE(aExtAddr); } -#endif diff --git a/src/core/BUILD.gn b/src/core/BUILD.gn index 997cd638a..47f3c2241 100644 --- a/src/core/BUILD.gn +++ b/src/core/BUILD.gn @@ -170,10 +170,6 @@ if (openthread_enable_core_config_args) { defines += [ "OPENTHREAD_CONFIG_JOINER_ENABLE=1" ] } - if (openthread_config_legacy_enable) { - defines += [ "OPENTHREAD_CONFIG_LEGACY_ENABLE=1" ] - } - if (openthread_config_link_metrics_initiator_enable) { defines += [ "DOPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE=1" ] } diff --git a/src/core/config/misc.h b/src/core/config/misc.h index 01d217577..69496ea46 100644 --- a/src/core/config/misc.h +++ b/src/core/config/misc.h @@ -581,16 +581,6 @@ #endif // OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT #endif // OPENTHREAD_CONFIG_DEFAULT_CHANNEL -/** - * @def OPENTHREAD_CONFIG_LEGACY_ENABLE - * - * Define to 1 to enable legacy network support. - * - */ -#ifndef OPENTHREAD_CONFIG_LEGACY_ENABLE -#define OPENTHREAD_CONFIG_LEGACY_ENABLE 0 -#endif - /** * @def OPENTHREAD_CONFIG_OTNS_ENABLE * diff --git a/src/core/config/openthread-core-config-check.h b/src/core/config/openthread-core-config-check.h index bfaf75c0a..29fdac250 100644 --- a/src/core/config/openthread-core-config-check.h +++ b/src/core/config/openthread-core-config-check.h @@ -145,6 +145,10 @@ #error "OPENTHREAD_ENABLE_LEGACY was replaced by OPENTHREAD_CONFIG_LEGACY_ENABLE." #endif +#ifdef OPENTHREAD_CONFIG_LEGACY_ENABLE +#error "OPENTHREAD_CONFIG_LEGACY_ENABLE was removed." +#endif + #ifdef OPENTHREAD_ENABLE_CHILD_SUPERVISION #error "OPENTHREAD_ENABLE_CHILD_SUPERVISION was replaced by OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE." #endif diff --git a/src/lib/spinel/spinel.c b/src/lib/spinel/spinel.c index 8c0eba952..5cf3836b7 100644 --- a/src/lib/spinel/spinel.c +++ b/src/lib/spinel/spinel.c @@ -1484,8 +1484,6 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key) {SPINEL_PROP_CNTR_ALL_IP_COUNTERS, "CNTR_ALL_IP_COUNTERS"}, {SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM, "CNTR_MAC_RETRY_HISTOGRAM"}, {SPINEL_PROP_NEST_STREAM_MFG, "NEST_STREAM_MFG"}, - {SPINEL_PROP_NEST_LEGACY_ULA_PREFIX, "NEST_LEGACY_ULA_PREFIX"}, - {SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED, "NEST_LEGACY_LAST_NODE_JOINED"}, {SPINEL_PROP_DEBUG_TEST_ASSERT, "DEBUG_TEST_ASSERT"}, {SPINEL_PROP_DEBUG_NCP_LOG_LEVEL, "DEBUG_NCP_LOG_LEVEL"}, {SPINEL_PROP_DEBUG_TEST_WATCHDOG, "DEBUG_TEST_WATCHDOG"}, @@ -1633,8 +1631,6 @@ const char *spinel_capability_to_cstr(spinel_capability_t capability) {SPINEL_CAP_THREAD_SERVICE, "THREAD_SERVICE"}, {SPINEL_CAP_THREAD_CSL_RECEIVER, "THREAD_CSL_RECEIVER"}, {SPINEL_CAP_THREAD_BACKBONE_ROUTER, "THREAD_BACKBONE_ROUTER"}, - {SPINEL_CAP_NEST_LEGACY_INTERFACE, "NEST_LEGACY_INTERFACE"}, - {SPINEL_CAP_NEST_LEGACY_NET_WAKE, "NEST_LEGACY_NET_WAKE"}, {SPINEL_CAP_NEST_TRANSMIT_HOOK, "NEST_TRANSMIT_HOOK"}, {0, NULL}, }; diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h index 433b0e9dd..6af510635 100644 --- a/src/lib/spinel/spinel.h +++ b/src/lib/spinel/spinel.h @@ -1319,8 +1319,8 @@ enum SPINEL_CAP_THREAD__END = 1152, SPINEL_CAP_NEST__BEGIN = 15296, - SPINEL_CAP_NEST_LEGACY_INTERFACE = (SPINEL_CAP_NEST__BEGIN + 0), - SPINEL_CAP_NEST_LEGACY_NET_WAKE = (SPINEL_CAP_NEST__BEGIN + 1), + SPINEL_CAP_NEST_LEGACY_INTERFACE = (SPINEL_CAP_NEST__BEGIN + 0), ///< deprecated + SPINEL_CAP_NEST_LEGACY_NET_WAKE = (SPINEL_CAP_NEST__BEGIN + 1), ///< deprecated SPINEL_CAP_NEST_TRANSMIT_HOOK = (SPINEL_CAP_NEST__BEGIN + 2), SPINEL_CAP_NEST__END = 15360, @@ -4839,12 +4839,20 @@ enum SPINEL_PROP_NEST_STREAM_MFG = SPINEL_PROP_NEST__BEGIN + 0, - /// The legacy network ULA prefix (8 bytes) - /** Format: 'D' */ + /// The legacy network ULA prefix (8 bytes). + /** Format: 'D' + * + * This property is deprecated. + * + */ SPINEL_PROP_NEST_LEGACY_ULA_PREFIX = SPINEL_PROP_NEST__BEGIN + 1, /// The EUI64 of last node joined using legacy protocol (if none, all zero EUI64 is returned). - /** Format: 'E' */ + /** Format: 'E' + * + * This property is deprecated. + * + */ SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED = SPINEL_PROP_NEST__BEGIN + 2, SPINEL_PROP_NEST__END = 0x3C00, diff --git a/src/ncp/changed_props_set.cpp b/src/ncp/changed_props_set.cpp index 3299c32eb..ceac025d9 100644 --- a/src/ncp/changed_props_set.cpp +++ b/src/ncp/changed_props_set.cpp @@ -67,10 +67,6 @@ const ChangedPropsSet::Entry ChangedPropsSet::mSupportedProps[] = { {SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_DROPPED, true}, #if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE {SPINEL_PROP_JAM_DETECTED, SPINEL_STATUS_OK, true}, -#endif -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - {SPINEL_PROP_NEST_LEGACY_ULA_PREFIX, SPINEL_STATUS_OK, true}, - {SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED, SPINEL_STATUS_OK, true}, #endif {SPINEL_PROP_LAST_STATUS, SPINEL_STATUS_JOIN_FAILURE, false}, {SPINEL_PROP_MAC_SCAN_STATE, SPINEL_STATUS_OK, false}, diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 522dd2308..a7e13a13a 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -290,12 +290,6 @@ NcpBase::NcpBase(Instance *aInstance) #if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE otSrpClientSetCallback(mInstance, HandleSrpClientCallback, this); #endif -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - mLegacyNodeDidJoin = false; - mLegacyHandlers = nullptr; - memset(mLegacyUlaPrefix, 0, sizeof(mLegacyUlaPrefix)); - memset(&mLegacyLastJoinedNode, 0, sizeof(mLegacyLastJoinedNode)); -#endif #endif // OPENTHREAD_MTD || OPENTHREAD_FTD mChangedPropsSet.AddLastStatus(SPINEL_STATUS_RESET_UNKNOWN); mUpdateChangedPropsTask.Post(); @@ -1917,10 +1911,6 @@ template <> otError NcpBase::HandlePropertyGet(void) SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_ROLE_SLEEPY)); -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_NEST_LEGACY_INTERFACE)); -#endif - #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_THREAD_COMMISSIONER)); #endif @@ -2048,7 +2038,6 @@ template <> otError NcpBase::HandlePropertySet(void if (otThreadGetDeviceRole(mInstance) != OT_DEVICE_ROLE_DISABLED) { IgnoreError(otThreadSetEnabled(mInstance, false)); - StopLegacy(); } if (otIp6IsEnabled(mInstance)) diff --git a/src/ncp/ncp_base.hpp b/src/ncp/ncp_base.hpp index 6b2963aff..d16693f50 100644 --- a/src/ncp/ncp_base.hpp +++ b/src/ncp/ncp_base.hpp @@ -130,36 +130,6 @@ public: otNcpDelegateAllowPeekPoke aAllowPokeDelegate); #endif -#if OPENTHREAD_MTD || OPENTHREAD_FTD -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - /** - * This callback is invoked by the legacy stack to notify that a new - * legacy node did join the network. - * - * @param[in] aExtAddr The extended address of the joined node. - * - */ - void HandleLegacyNodeDidJoin(const otExtAddress *aExtAddr); - - /** - * This callback is invoked by the legacy stack to notify that the - * legacy ULA prefix has changed. - * - * param[in] aUlaPrefix The changed ULA prefix. - * - */ - void HandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix); - - /** - * This method registers a set of legacy handlers with NCP. - * - * @param[in] aHandlers A pointer to a handler struct. - * - */ - void RegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers); -#endif -#endif // OPENTHREAD_MTD || OPENTHREAD_FTD - /** * This method is called by the framer whenever a framing error is detected. */ @@ -485,14 +455,6 @@ protected: void ResetCounters(void); -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - void StartLegacy(void); - void StopLegacy(void); -#else - void StartLegacy(void) {} - void StopLegacy(void) {} -#endif - static uint8_t ConvertLogLevel(otLogLevel aLogLevel); static unsigned int ConvertLogRegion(otLogRegion aLogRegion); @@ -662,12 +624,6 @@ protected: bool mSrpClientCallbackEnabled; #endif // OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - const otNcpLegacyHandlers *mLegacyHandlers; - uint8_t mLegacyUlaPrefix[OT_NCP_LEGACY_ULA_PREFIX_LENGTH]; - otExtAddress mLegacyLastJoinedNode; - bool mLegacyNodeDidJoin; -#endif #endif // OPENTHREAD_MTD || OPENTHREAD_FTD uint32_t mFramingErrorCounter; // Number of improperly formed received spinel frames. diff --git a/src/ncp/ncp_base_dispatcher.cpp b/src/ncp/ncp_base_dispatcher.cpp index 3d7ebe61c..361fcbea1 100644 --- a/src/ncp/ncp_base_dispatcher.cpp +++ b/src/ncp/ncp_base_dispatcher.cpp @@ -371,10 +371,6 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey) #endif #endif -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NEST_LEGACY_ULA_PREFIX), - OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED), -#endif #endif // OPENTHREAD_MTD || OPENTHREAD_FTD OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_DEBUG_TEST_ASSERT), OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_DEBUG_NCP_LOG_LEVEL), @@ -630,9 +626,6 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey) OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_SRP_CLIENT_SERVICE_KEY_ENABLED), #endif #endif -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_NEST_LEGACY_ULA_PREFIX), -#endif #endif // OPENTHREAD_MTD || OPENTHREAD_FTD #if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_DEBUG_NCP_LOG_LEVEL), diff --git a/src/ncp/ncp_base_mtd.cpp b/src/ncp/ncp_base_mtd.cpp index e853c4e04..bd4119a0b 100644 --- a/src/ncp/ncp_base_mtd.cpp +++ b/src/ncp/ncp_base_mtd.cpp @@ -520,12 +520,10 @@ template <> otError NcpBase::HandlePropertySet(void) if (enabled) { error = otThreadSetEnabled(mInstance, true); - StartLegacy(); } else { error = otThreadSetEnabled(mInstance, false); - StopLegacy(); } } @@ -4081,115 +4079,6 @@ exit: } #endif -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - -void NcpBase::RegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers) -{ - mLegacyHandlers = aHandlers; - bool isEnabled; - - VerifyOrExit(mLegacyHandlers != nullptr); - - isEnabled = (otThreadGetDeviceRole(mInstance) != OT_DEVICE_ROLE_DISABLED); - - if (isEnabled) - { - if (mLegacyHandlers->mStartLegacy) - { - mLegacyHandlers->mStartLegacy(); - } - } - else - { - if (mLegacyHandlers->mStopLegacy) - { - mLegacyHandlers->mStopLegacy(); - } - } - - if (mLegacyHandlers->mSetLegacyUlaPrefix) - { - mLegacyHandlers->mSetLegacyUlaPrefix(mLegacyUlaPrefix); - } - -exit: - return; -} - -void NcpBase::HandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix) -{ - memcpy(mLegacyUlaPrefix, aUlaPrefix, OT_NCP_LEGACY_ULA_PREFIX_LENGTH); - mChangedPropsSet.AddProperty(SPINEL_PROP_NEST_LEGACY_ULA_PREFIX); - mUpdateChangedPropsTask.Post(); -} - -void NcpBase::HandleLegacyNodeDidJoin(const otExtAddress *aExtAddr) -{ - mLegacyNodeDidJoin = true; - mLegacyLastJoinedNode = *aExtAddr; - mChangedPropsSet.AddProperty(SPINEL_PROP_NEST_LEGACY_LAST_NODE_JOINED); - mUpdateChangedPropsTask.Post(); -} - -template <> otError NcpBase::HandlePropertyGet(void) -{ - return mEncoder.WriteData(mLegacyUlaPrefix, sizeof(mLegacyUlaPrefix)); -} - -template <> otError NcpBase::HandlePropertySet(void) -{ - const uint8_t *ptr = nullptr; - uint16_t len; - otError error = OT_ERROR_NONE; - - SuccessOrExit(error = mDecoder.ReadData(ptr, len)); - - VerifyOrExit(len <= sizeof(mLegacyUlaPrefix), error = OT_ERROR_PARSE); - - memset(mLegacyUlaPrefix, 0, sizeof(mLegacyUlaPrefix)); - memcpy(mLegacyUlaPrefix, ptr, len); - - if ((mLegacyHandlers != nullptr) && (mLegacyHandlers->mSetLegacyUlaPrefix != nullptr)) - { - mLegacyHandlers->mSetLegacyUlaPrefix(mLegacyUlaPrefix); - } - -exit: - return error; -} - -template <> otError NcpBase::HandlePropertyGet(void) -{ - if (!mLegacyNodeDidJoin) - { - memset(&mLegacyLastJoinedNode, 0, sizeof(mLegacyLastJoinedNode)); - } - - return mEncoder.WriteEui64(mLegacyLastJoinedNode); -} - -void NcpBase::StartLegacy(void) -{ - mLegacyNodeDidJoin = false; - - if ((mLegacyHandlers != nullptr) && (mLegacyHandlers->mStartLegacy != nullptr)) - { - mLegacyHandlers->mStartLegacy(); - } -} - -void NcpBase::StopLegacy(void) -{ - mLegacyNodeDidJoin = false; - - if ((mLegacyHandlers != nullptr) && (mLegacyHandlers->mStopLegacy != nullptr)) - { - mLegacyHandlers->mStopLegacy(); - } -} - -#endif // OPENTHREAD_CONFIG_LEGACY_ENABLE - #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE template <> otError NcpBase::HandlePropertyGet(void) { @@ -4719,11 +4608,7 @@ void NcpBase::ProcessThreadChangedFlags(void) break; } - if ((otThreadGetDeviceRole(mInstance) == OT_DEVICE_ROLE_LEADER) && otThreadIsSingleton(mInstance) -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - && !mLegacyNodeDidJoin -#endif - ) + if ((otThreadGetDeviceRole(mInstance) == OT_DEVICE_ROLE_LEADER) && otThreadIsSingleton(mInstance)) { mThreadChangedFlags &= ~static_cast(OT_CHANGED_THREAD_PARTITION_ID); IgnoreError(otThreadSetEnabled(mInstance, false)); @@ -4786,53 +4671,4 @@ exit: } // namespace Ncp } // namespace ot -// ---------------------------------------------------------------------------- -// MARK: Legacy network APIs -// ---------------------------------------------------------------------------- - -void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers) -{ -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - ot::Ncp::NcpBase *ncp = ot::Ncp::NcpBase::GetNcpInstance(); - - if (ncp != nullptr) - { - ncp->RegisterLegacyHandlers(aHandlers); - } - -#else - OT_UNUSED_VARIABLE(aHandlers); -#endif -} - -void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix) -{ -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - ot::Ncp::NcpBase *ncp = ot::Ncp::NcpBase::GetNcpInstance(); - - if (ncp != nullptr) - { - ncp->HandleDidReceiveNewLegacyUlaPrefix(aUlaPrefix); - } - -#else - OT_UNUSED_VARIABLE(aUlaPrefix); -#endif -} - -void otNcpHandleLegacyNodeDidJoin(const otExtAddress *aExtAddr) -{ -#if OPENTHREAD_CONFIG_LEGACY_ENABLE - ot::Ncp::NcpBase *ncp = ot::Ncp::NcpBase::GetNcpInstance(); - - if (ncp != nullptr) - { - ncp->HandleLegacyNodeDidJoin(aExtAddr); - } - -#else - OT_UNUSED_VARIABLE(aExtAddr); -#endif -} - #endif // OPENTHREAD_MTD || OPENTHREAD_FTD diff --git a/src/posix/Makefile-posix b/src/posix/Makefile-posix index 7d7b9a8e7..0a26c848a 100644 --- a/src/posix/Makefile-posix +++ b/src/posix/Makefile-posix @@ -58,7 +58,6 @@ HISTORY_TRACKER ?= 1 IP6_FRAGM ?= 1 JAM_DETECTION ?= 1 JOINER ?= 1 -LEGACY ?= 1 LINK_RAW ?= 0 LOG_OUTPUT ?= PLATFORM_DEFINED MAC_FILTER ?= 1 diff --git a/tests/toranj/openthread-core-toranj-config.h b/tests/toranj/openthread-core-toranj-config.h index 7ee4ce53c..eda319da3 100644 --- a/tests/toranj/openthread-core-toranj-config.h +++ b/tests/toranj/openthread-core-toranj-config.h @@ -147,14 +147,6 @@ */ #define OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE 1 -/** - * @def OPENTHREAD_CONFIG_LEGACY_ENABLE - * - * Define to 1 to enable legacy network support. - * - */ -#define OPENTHREAD_CONFIG_LEGACY_ENABLE 1 - /** * @def OPENTHREAD_CONFIG_ECDSA_ENABLE *