From 743e91361c6f90026c23f893cfcfcd8cd5666bc2 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 5 Apr 2021 14:13:24 -0700 Subject: [PATCH] [style] harmonize feature check and header includes (#6399) This commit harmonizes how the feature config checks are done within OT core modules. In header `.hpp` files, any related `#if` config check is done immediately after the `"openthread-core-config.h"` is included. This way the rest of definitions are skipped over if the feature is not being used. In `cpp` source files the `#if` check is done immediately after including the related header file. --- include/openthread/instance.h | 2 +- include/openthread/platform/udp.h | 2 ++ src/core/api/backbone_router_api.cpp | 1 + src/core/api/backbone_router_ftd_api.cpp | 3 ++- src/core/api/border_agent_api.cpp | 4 ++-- src/core/api/channel_manager_api.cpp | 5 +++-- src/core/api/channel_monitor_api.cpp | 5 +++-- src/core/api/child_supervision_api.cpp | 5 +++-- src/core/api/coap_api.cpp | 4 ++-- src/core/api/coap_secure_api.cpp | 4 ++-- src/core/api/commissioner_api.cpp | 3 ++- src/core/api/crypto_api.cpp | 1 + src/core/api/dataset_updater_api.cpp | 4 ++-- src/core/api/diags_api.cpp | 4 ++-- src/core/api/jam_detection_api.cpp | 4 ++-- src/core/api/joiner_api.cpp | 3 ++- src/core/api/link_metrics_api.cpp | 4 ++-- src/core/api/link_raw_api.cpp | 4 ++-- src/core/api/multi_radio_api.cpp | 4 ++-- src/core/api/netdiag_api.cpp | 4 ++-- src/core/api/sntp_api.cpp | 6 ++++-- src/core/api/srp_client_api.cpp | 4 ++-- src/core/api/thread_api.cpp | 4 +++- src/core/backbone_router/backbone_tmf.hpp | 6 ++++++ src/core/backbone_router/bbr_leader.hpp | 1 + src/core/backbone_router/bbr_manager.hpp | 1 + src/core/coap/coap_secure.cpp | 4 ++-- src/core/coap/coap_secure.hpp | 4 ++++ src/core/common/extension.hpp | 4 ++-- src/core/crypto/ecdsa.cpp | 8 ++++---- src/core/crypto/ecdsa.hpp | 8 ++++---- src/core/diags/factory_diags.cpp | 7 ++++--- src/core/diags/factory_diags.hpp | 8 ++++---- src/core/mac/data_poll_handler.cpp | 4 ++-- src/core/mac/data_poll_handler.hpp | 4 ++++ src/core/mac/link_raw.cpp | 4 ++-- src/core/mac/link_raw.hpp | 8 ++++---- src/core/mac/mac_filter.cpp | 4 ++-- src/core/mac/mac_filter.hpp | 4 ++-- src/core/meshcop/announce_begin_client.cpp | 4 ++-- src/core/meshcop/announce_begin_client.hpp | 4 ++++ src/core/meshcop/border_agent.cpp | 4 ++-- src/core/meshcop/border_agent.hpp | 4 ++++ src/core/meshcop/commissioner.cpp | 4 ++-- src/core/meshcop/commissioner.hpp | 4 ++++ src/core/meshcop/dataset_manager_ftd.cpp | 4 +++- src/core/meshcop/dataset_updater.cpp | 4 ++-- src/core/meshcop/dataset_updater.hpp | 8 ++++---- src/core/meshcop/energy_scan_client.cpp | 4 ++-- src/core/meshcop/energy_scan_client.hpp | 4 ++++ src/core/meshcop/joiner.cpp | 4 ++-- src/core/meshcop/joiner.hpp | 4 ++++ src/core/meshcop/joiner_router.cpp | 4 ++-- src/core/meshcop/joiner_router.hpp | 4 ++++ src/core/meshcop/meshcop_leader.cpp | 4 ++-- src/core/meshcop/meshcop_leader.hpp | 4 ++++ src/core/meshcop/panid_query_client.cpp | 4 ++-- src/core/meshcop/panid_query_client.hpp | 4 ++++ src/core/net/dhcp6_client.cpp | 4 ++-- src/core/net/dhcp6_client.hpp | 10 +++++----- src/core/net/dhcp6_server.cpp | 4 ++-- src/core/net/dhcp6_server.hpp | 8 ++++---- src/core/net/dns_client.cpp | 4 ++-- src/core/net/dns_client.hpp | 4 ++++ src/core/net/sntp_client.cpp | 4 ++-- src/core/net/sntp_client.hpp | 4 ++++ src/core/net/srp_client.cpp | 4 ++-- src/core/net/srp_client.hpp | 4 ++-- src/core/radio/trel_interface.cpp | 4 ++-- src/core/radio/trel_interface.hpp | 4 ++-- src/core/radio/trel_link.cpp | 4 ++-- src/core/radio/trel_link.hpp | 4 ++-- src/core/radio/trel_packet.cpp | 4 ++-- src/core/radio/trel_packet.hpp | 4 ++-- src/core/thread/address_resolver.cpp | 4 ++-- src/core/thread/address_resolver.hpp | 4 ++++ src/core/thread/child_table.cpp | 8 ++++---- src/core/thread/csl_tx_scheduler.hpp | 8 ++++---- src/core/thread/indirect_sender.cpp | 4 ++-- src/core/thread/indirect_sender.hpp | 4 ++++ src/core/thread/link_metrics_tlvs.hpp | 6 ++++-- src/core/thread/mesh_forwarder.hpp | 2 ++ src/core/thread/mesh_forwarder_ftd.cpp | 4 ++-- src/core/thread/mesh_forwarder_mtd.cpp | 4 ++-- src/core/thread/mle.hpp | 1 + src/core/thread/mle_router.cpp | 4 ++-- src/core/thread/neighbor_table.cpp | 2 ++ src/core/thread/network_data_leader_ftd.cpp | 4 ++-- src/core/thread/network_data_leader_ftd.hpp | 4 ++++ src/core/thread/network_data_local.cpp | 4 ++-- src/core/thread/network_data_local.hpp | 4 ++-- src/core/thread/network_diagnostic.cpp | 4 ++-- src/core/thread/network_diagnostic.hpp | 4 ++++ src/core/thread/radio_selector.cpp | 4 ++-- src/core/thread/radio_selector.hpp | 4 ++-- src/core/thread/src_match_controller.hpp | 4 ++++ src/core/thread/time_sync_service.hpp | 1 + src/core/thread/topology.cpp | 8 ++++++-- src/core/thread/topology.hpp | 6 +++++- src/core/utils/channel_manager.cpp | 4 ++-- src/core/utils/channel_manager.hpp | 8 ++++---- src/core/utils/channel_monitor.cpp | 6 +++--- src/core/utils/channel_monitor.hpp | 8 ++++---- src/core/utils/child_supervision.hpp | 1 + src/core/utils/flash.cpp | 4 ++-- src/core/utils/flash.hpp | 4 ++++ src/core/utils/jam_detector.cpp | 4 ++-- src/core/utils/jam_detector.hpp | 4 ++++ src/core/utils/otns.hpp | 1 + src/core/utils/slaac_address.cpp | 4 ++-- src/core/utils/slaac_address.hpp | 4 ++++ 111 files changed, 299 insertions(+), 176 deletions(-) diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 29919e319..677649af1 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 (93) +#define OPENTHREAD_API_VERSION (94) /** * @addtogroup api-instance diff --git a/include/openthread/platform/udp.h b/include/openthread/platform/udp.h index 042e38a0d..936b0c71e 100644 --- a/include/openthread/platform/udp.h +++ b/include/openthread/platform/udp.h @@ -35,6 +35,8 @@ #ifndef OPENTHREAD_PLATFORM_UDP_H_ #define OPENTHREAD_PLATFORM_UDP_H_ +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/core/api/backbone_router_api.cpp b/src/core/api/backbone_router_api.cpp index a27a621de..4ebb76572 100644 --- a/src/core/api/backbone_router_api.cpp +++ b/src/core/api/backbone_router_api.cpp @@ -34,6 +34,7 @@ #include "openthread-core-config.h" #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) + #include #include "common/instance.hpp" diff --git a/src/core/api/backbone_router_ftd_api.cpp b/src/core/api/backbone_router_ftd_api.cpp index 79ccdf500..92f28462e 100644 --- a/src/core/api/backbone_router_ftd_api.cpp +++ b/src/core/api/backbone_router_ftd_api.cpp @@ -34,9 +34,10 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + #include -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE #include "common/instance.hpp" using namespace ot; diff --git a/src/core/api/border_agent_api.cpp b/src/core/api/border_agent_api.cpp index 8154d44b6..3ec414fcc 100644 --- a/src/core/api/border_agent_api.cpp +++ b/src/core/api/border_agent_api.cpp @@ -33,13 +33,13 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE + #include #include "common/instance.hpp" #include "common/locator-getters.hpp" -#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE - using namespace ot; otBorderAgentState otBorderAgentGetState(otInstance *aInstance) diff --git a/src/core/api/channel_manager_api.cpp b/src/core/api/channel_manager_api.cpp index 142af7cdc..a3cf842ca 100644 --- a/src/core/api/channel_manager_api.cpp +++ b/src/core/api/channel_manager_api.cpp @@ -32,6 +32,9 @@ */ #include "openthread-core-config.h" + +#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD + #include #include "common/instance.hpp" @@ -40,8 +43,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD - void otChannelManagerRequestChannelChange(otInstance *aInstance, uint8_t aChannel) { Instance &instance = *static_cast(aInstance); diff --git a/src/core/api/channel_monitor_api.cpp b/src/core/api/channel_monitor_api.cpp index f1d6b98d5..b61ddec02 100644 --- a/src/core/api/channel_monitor_api.cpp +++ b/src/core/api/channel_monitor_api.cpp @@ -32,6 +32,9 @@ */ #include "openthread-core-config.h" + +#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE + #include #include "common/instance.hpp" @@ -39,8 +42,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE - otError otChannelMonitorSetEnabled(otInstance *aInstance, bool aEnabled) { Utils::ChannelMonitor &monitor = static_cast(aInstance)->Get(); diff --git a/src/core/api/child_supervision_api.cpp b/src/core/api/child_supervision_api.cpp index 2799209e1..a85ae6b2f 100644 --- a/src/core/api/child_supervision_api.cpp +++ b/src/core/api/child_supervision_api.cpp @@ -32,6 +32,9 @@ */ #include "openthread-core-config.h" + +#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE + #include #include "common/instance.hpp" @@ -39,8 +42,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE - uint16_t otChildSupervisionGetInterval(otInstance *aInstance) { Instance &instance = *static_cast(aInstance); diff --git a/src/core/api/coap_api.cpp b/src/core/api/coap_api.cpp index 8507fcb61..47a17defd 100644 --- a/src/core/api/coap_api.cpp +++ b/src/core/api/coap_api.cpp @@ -33,14 +33,14 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_COAP_API_ENABLE + #include #include "coap/coap_message.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" -#if OPENTHREAD_CONFIG_COAP_API_ENABLE - using namespace ot; otMessage *otCoapNewMessage(otInstance *aInstance, const otMessageSettings *aSettings) diff --git a/src/core/api/coap_secure_api.cpp b/src/core/api/coap_secure_api.cpp index 699131697..6ba531150 100644 --- a/src/core/api/coap_secure_api.cpp +++ b/src/core/api/coap_secure_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE + #include #include @@ -41,8 +43,6 @@ #include "common/instance.hpp" #include "common/locator-getters.hpp" -#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE - using namespace ot; otError otCoapSecureStart(otInstance *aInstance, uint16_t aPort) diff --git a/src/core/api/commissioner_api.cpp b/src/core/api/commissioner_api.cpp index cda781bd6..58a61e7f8 100644 --- a/src/core/api/commissioner_api.cpp +++ b/src/core/api/commissioner_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE + #include #include "common/instance.hpp" @@ -40,7 +42,6 @@ using namespace ot; -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE otError otCommissionerStart(otInstance * aInstance, otCommissionerStateCallback aStateCallback, otCommissionerJoinerCallback aJoinerCallback, diff --git a/src/core/api/crypto_api.cpp b/src/core/api/crypto_api.cpp index 0f5df3cc3..a48be7613 100644 --- a/src/core/api/crypto_api.cpp +++ b/src/core/api/crypto_api.cpp @@ -32,6 +32,7 @@ */ #include "openthread-core-config.h" + #include #include diff --git a/src/core/api/dataset_updater_api.cpp b/src/core/api/dataset_updater_api.cpp index fd9b8626f..73211e188 100644 --- a/src/core/api/dataset_updater_api.cpp +++ b/src/core/api/dataset_updater_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE && OPENTHREAD_FTD + #include #include "common/instance.hpp" @@ -41,8 +43,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE && OPENTHREAD_FTD - otError otDatasetUpdaterRequestUpdate(otInstance * aInstance, const otOperationalDataset *aDataset, otDatasetUpdaterCallback aCallback, diff --git a/src/core/api/diags_api.cpp b/src/core/api/diags_api.cpp index 77f8a898e..c1922d8e9 100644 --- a/src/core/api/diags_api.cpp +++ b/src/core/api/diags_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_DIAG_ENABLE + #include #include "common/instance.hpp" @@ -40,8 +42,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_DIAG_ENABLE - void otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen) { Instance &instance = *static_cast(aInstance); diff --git a/src/core/api/jam_detection_api.cpp b/src/core/api/jam_detection_api.cpp index c1a5bc5d6..c50f1ba18 100644 --- a/src/core/api/jam_detection_api.cpp +++ b/src/core/api/jam_detection_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE + #include #include "common/instance.hpp" @@ -40,8 +42,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE - otError otJamDetectionSetRssiThreshold(otInstance *aInstance, int8_t aRssiThreshold) { Instance &instance = *static_cast(aInstance); diff --git a/src/core/api/joiner_api.cpp b/src/core/api/joiner_api.cpp index 5562f41b7..99e90c5fd 100644 --- a/src/core/api/joiner_api.cpp +++ b/src/core/api/joiner_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_JOINER_ENABLE + #include #include "common/instance.hpp" @@ -40,7 +42,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_JOINER_ENABLE otError otJoinerStart(otInstance * aInstance, const char * aPskd, const char * aProvisioningUrl, diff --git a/src/core/api/link_metrics_api.cpp b/src/core/api/link_metrics_api.cpp index 06180c245..5e82c02c2 100644 --- a/src/core/api/link_metrics_api.cpp +++ b/src/core/api/link_metrics_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE + #include #include "common/instance.hpp" @@ -40,8 +42,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE - otError otLinkMetricsQuery(otInstance * aInstance, const otIp6Address * aDestination, uint8_t aSeriesId, diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index 6d9224301..edea5e72b 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE + #include #include #include @@ -45,8 +47,6 @@ #include "common/random.hpp" #include "mac/mac_frame.hpp" -#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE - using namespace ot; otError otLinkRawSetReceiveDone(otInstance *aInstance, otLinkRawReceiveDone aCallback) diff --git a/src/core/api/multi_radio_api.cpp b/src/core/api/multi_radio_api.cpp index dd70ea6e2..d69dd2cf9 100644 --- a/src/core/api/multi_radio_api.cpp +++ b/src/core/api/multi_radio_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_MULTI_RADIO + #include #include "common/code_utils.hpp" @@ -43,8 +45,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_MULTI_RADIO - otError otMultiRadioGetNeighborInfo(otInstance * aInstance, const otExtAddress * aExtAddress, otMultiRadioNeighborInfo *aInfo) diff --git a/src/core/api/netdiag_api.cpp b/src/core/api/netdiag_api.cpp index 3e8b83643..9430efdd2 100644 --- a/src/core/api/netdiag_api.cpp +++ b/src/core/api/netdiag_api.cpp @@ -33,14 +33,14 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE + #include #include "common/instance.hpp" using namespace ot; -#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE - otError otThreadGetNextDiagnosticTlv(const otMessage * aMessage, otNetworkDiagIterator *aIterator, otNetworkDiagTlv * aNetworkDiagTlv) diff --git a/src/core/api/sntp_api.cpp b/src/core/api/sntp_api.cpp index 2c1cab8ba..862a98fea 100644 --- a/src/core/api/sntp_api.cpp +++ b/src/core/api/sntp_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE + #include #include "common/instance.hpp" @@ -40,7 +42,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE otError otSntpClientQuery(otInstance * aInstance, const otSntpQuery * aQuery, otSntpResponseHandler aHandler, @@ -57,4 +58,5 @@ void otSntpClientSetUnixEra(otInstance *aInstance, uint32_t aUnixEra) return instance.Get().SetUnixEra(aUnixEra); } -#endif + +#endif // OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE diff --git a/src/core/api/srp_client_api.cpp b/src/core/api/srp_client_api.cpp index 45a192129..e97865283 100644 --- a/src/core/api/srp_client_api.cpp +++ b/src/core/api/srp_client_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE + #include #include "common/instance.hpp" @@ -41,8 +43,6 @@ using namespace ot; -#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE - otError otSrpClientStart(otInstance *aInstance, const otSockAddr *aServerSockAddr) { Instance &instance = *static_cast(aInstance); diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index 14693364a..7f57efc94 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD || OPENTHREAD_MTD + #include #include "common/debug.hpp" @@ -42,7 +44,6 @@ using namespace ot; -#if OPENTHREAD_FTD || OPENTHREAD_MTD uint32_t otThreadGetChildTimeout(otInstance *aInstance) { Instance &instance = *static_cast(aInstance); @@ -515,4 +516,5 @@ void otThreadRegisterParentResponseCallback(otInstance * aInst instance.Get().RegisterParentResponseStatsCallback(aCallback, aContext); } + #endif // OPENTHREAD_FTD || OPENTHREAD_MTD diff --git a/src/core/backbone_router/backbone_tmf.hpp b/src/core/backbone_router/backbone_tmf.hpp index cfa1bdae0..1d1d03c4f 100644 --- a/src/core/backbone_router/backbone_tmf.hpp +++ b/src/core/backbone_router/backbone_tmf.hpp @@ -34,6 +34,10 @@ #ifndef OT_CORE_THREAD_BACKBONE_TMF_HPP_ #define OT_CORE_THREAD_BACKBONE_TMF_HPP_ +#include "openthread-core-config.h" + +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + #include "coap/coap.hpp" namespace ot { @@ -104,4 +108,6 @@ private: } // namespace BackboneRouter } // namespace ot +#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + #endif // OT_CORE_THREAD_BACKBONE_TMF_HPP_ diff --git a/src/core/backbone_router/bbr_leader.hpp b/src/core/backbone_router/bbr_leader.hpp index f437d9d4f..d79306043 100644 --- a/src/core/backbone_router/bbr_leader.hpp +++ b/src/core/backbone_router/bbr_leader.hpp @@ -37,6 +37,7 @@ #include "openthread-core-config.h" #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) + #include #include diff --git a/src/core/backbone_router/bbr_manager.hpp b/src/core/backbone_router/bbr_manager.hpp index ae1301b04..3ef10210f 100644 --- a/src/core/backbone_router/bbr_manager.hpp +++ b/src/core/backbone_router/bbr_manager.hpp @@ -37,6 +37,7 @@ #include "openthread-core-config.h" #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + #include #include diff --git a/src/core/coap/coap_secure.cpp b/src/core/coap/coap_secure.cpp index 1ab1c4fb5..afc12ee89 100644 --- a/src/core/coap/coap_secure.cpp +++ b/src/core/coap/coap_secure.cpp @@ -28,6 +28,8 @@ #include "coap_secure.hpp" +#if OPENTHREAD_CONFIG_DTLS_ENABLE + #include "common/instance.hpp" #include "common/locator-getters.hpp" #include "common/logging.hpp" @@ -35,8 +37,6 @@ #include "meshcop/dtls.hpp" #include "thread/thread_netif.hpp" -#if OPENTHREAD_CONFIG_DTLS_ENABLE - /** * @file * This file implements the secure CoAP agent. diff --git a/src/core/coap/coap_secure.hpp b/src/core/coap/coap_secure.hpp index 272a1d6f1..c4e37653a 100644 --- a/src/core/coap/coap_secure.hpp +++ b/src/core/coap/coap_secure.hpp @@ -31,6 +31,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_DTLS_ENABLE + #include "coap/coap.hpp" #include "meshcop/dtls.hpp" #include "meshcop/meshcop.hpp" @@ -410,4 +412,6 @@ private: } // namespace Coap } // namespace ot +#endif // OPENTHREAD_CONFIG_DTLS_ENABLE + #endif // COAP_SECURE_HPP_ diff --git a/src/core/common/extension.hpp b/src/core/common/extension.hpp index 8ed87f2bd..d88d92177 100644 --- a/src/core/common/extension.hpp +++ b/src/core/common/extension.hpp @@ -36,12 +36,12 @@ #include "openthread-core-config.h" +#if OPENTHREAD_ENABLE_VENDOR_EXTENSION + #include "common/locator.hpp" #include "common/non_copyable.hpp" #include "common/notifier.hpp" -#if OPENTHREAD_ENABLE_VENDOR_EXTENSION - namespace ot { namespace Ncp { class NcpBase; diff --git a/src/core/crypto/ecdsa.cpp b/src/core/crypto/ecdsa.cpp index 216dfd336..08248b551 100644 --- a/src/core/crypto/ecdsa.cpp +++ b/src/core/crypto/ecdsa.cpp @@ -33,6 +33,8 @@ #include "ecdsa.hpp" +#if OPENTHREAD_CONFIG_ECDSA_ENABLE + #include #include @@ -48,8 +50,6 @@ namespace ot { namespace Crypto { namespace Ecdsa { -#if OPENTHREAD_CONFIG_ECDSA_ENABLE - Error P256::KeyPair::Generate(void) { mbedtls_pk_context pk; @@ -246,8 +246,8 @@ exit: return error; } -#endif // OPENTHREAD_CONFIG_ECDSA_ENABLE - } // namespace Ecdsa } // namespace Crypto } // namespace ot + +#endif // OPENTHREAD_CONFIG_ECDSA_ENABLE diff --git a/src/core/crypto/ecdsa.hpp b/src/core/crypto/ecdsa.hpp index 8cf326555..6cf731311 100644 --- a/src/core/crypto/ecdsa.hpp +++ b/src/core/crypto/ecdsa.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_ECDSA_ENABLE + #include #include @@ -46,8 +48,6 @@ namespace ot { namespace Crypto { namespace Ecdsa { -#if OPENTHREAD_CONFIG_ECDSA_ENABLE - /** * @addtogroup core-security * @@ -297,10 +297,10 @@ Error Sign(uint8_t * aOutput, * */ -#endif // OPENTHREAD_CONFIG_ECDSA_ENABLE - } // namespace Ecdsa } // namespace Crypto } // namespace ot +#endif // OPENTHREAD_CONFIG_ECDSA_ENABLE + #endif // ECDSA_HPP_ diff --git a/src/core/diags/factory_diags.cpp b/src/core/diags/factory_diags.cpp index 11c908784..248c0584f 100644 --- a/src/core/diags/factory_diags.cpp +++ b/src/core/diags/factory_diags.cpp @@ -33,6 +33,8 @@ #include "factory_diags.hpp" +#if OPENTHREAD_CONFIG_DIAG_ENABLE + #include #include @@ -64,7 +66,6 @@ otError otPlatDiagProcess(otInstance *aInstance, namespace ot { namespace FactoryDiags { -#if OPENTHREAD_CONFIG_DIAG_ENABLE #if OPENTHREAD_RADIO const struct Diags::Command Diags::sCommands[] = { @@ -607,7 +608,7 @@ bool Diags::IsEnabled(void) return otPlatDiagModeGet(); } -#endif // OPENTHREAD_CONFIG_DIAG_ENABLE - } // namespace FactoryDiags } // namespace ot + +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/src/core/diags/factory_diags.hpp b/src/core/diags/factory_diags.hpp index 78f7814c1..b6c068265 100644 --- a/src/core/diags/factory_diags.hpp +++ b/src/core/diags/factory_diags.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_DIAG_ENABLE + #include #include @@ -47,8 +49,6 @@ namespace ot { namespace FactoryDiags { -#if OPENTHREAD_CONFIG_DIAG_ENABLE - class Diags : public InstanceLocator, private NonCopyable { public: @@ -169,9 +169,9 @@ private: #endif }; -#endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE - } // namespace FactoryDiags } // namespace ot +#endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE + #endif // FACTORY_DIAGS_HPP_ diff --git a/src/core/mac/data_poll_handler.cpp b/src/core/mac/data_poll_handler.cpp index b4074798f..bb0f33037 100644 --- a/src/core/mac/data_poll_handler.cpp +++ b/src/core/mac/data_poll_handler.cpp @@ -31,10 +31,10 @@ * This file includes the implementation for handling of data polls and indirect frame transmission. */ -#if OPENTHREAD_FTD - #include "data_poll_handler.hpp" +#if OPENTHREAD_FTD + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" diff --git a/src/core/mac/data_poll_handler.hpp b/src/core/mac/data_poll_handler.hpp index 1e962b0e4..4fc7a2f89 100644 --- a/src/core/mac/data_poll_handler.hpp +++ b/src/core/mac/data_poll_handler.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD + #include "common/code_utils.hpp" #include "common/locator.hpp" #include "common/non_copyable.hpp" @@ -295,4 +297,6 @@ private: } // namespace ot +#endif // OPENTHREAD_FTD + #endif // DATA_POLL_HANDLER_HPP_ diff --git a/src/core/mac/link_raw.cpp b/src/core/mac/link_raw.cpp index 4abd37262..7ca2fa139 100644 --- a/src/core/mac/link_raw.cpp +++ b/src/core/mac/link_raw.cpp @@ -33,6 +33,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE + #include #include #include @@ -44,8 +46,6 @@ #include "common/random.hpp" #include "mac/mac_frame.hpp" -#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE - namespace ot { namespace Mac { diff --git a/src/core/mac/link_raw.hpp b/src/core/mac/link_raw.hpp index ed0fecf37..318acc8b8 100644 --- a/src/core/mac/link_raw.hpp +++ b/src/core/mac/link_raw.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE + #include #include "common/locator.hpp" @@ -46,8 +48,6 @@ namespace ot { namespace Mac { -#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE - /** * This class defines the raw link-layer object. * @@ -311,9 +311,9 @@ private: #endif }; -#endif // OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE - } // namespace Mac } // namespace ot +#endif // OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE + #endif // LINK_RAW_HPP_ diff --git a/src/core/mac/mac_filter.cpp b/src/core/mac/mac_filter.cpp index 568c9470f..f557a8bcd 100644 --- a/src/core/mac/mac_filter.cpp +++ b/src/core/mac/mac_filter.cpp @@ -33,10 +33,10 @@ #include "mac_filter.hpp" -#include "common/code_utils.hpp" - #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE +#include "common/code_utils.hpp" + namespace ot { namespace Mac { diff --git a/src/core/mac/mac_filter.hpp b/src/core/mac/mac_filter.hpp index 31d2e4568..70465648f 100644 --- a/src/core/mac/mac_filter.hpp +++ b/src/core/mac/mac_filter.hpp @@ -36,13 +36,13 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE + #include #include "common/non_copyable.hpp" #include "mac/mac_frame.hpp" -#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE - namespace ot { namespace Mac { diff --git a/src/core/meshcop/announce_begin_client.cpp b/src/core/meshcop/announce_begin_client.cpp index 84ff93bf6..425c538df 100644 --- a/src/core/meshcop/announce_begin_client.cpp +++ b/src/core/meshcop/announce_begin_client.cpp @@ -33,6 +33,8 @@ #include "announce_begin_client.hpp" +#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #include "coap/coap_message.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" @@ -44,8 +46,6 @@ #include "thread/thread_netif.hpp" #include "thread/uri_paths.hpp" -#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD - namespace ot { AnnounceBeginClient::AnnounceBeginClient(Instance &aInstance) diff --git a/src/core/meshcop/announce_begin_client.hpp b/src/core/meshcop/announce_begin_client.hpp index a351a2ffa..1960a5072 100644 --- a/src/core/meshcop/announce_begin_client.hpp +++ b/src/core/meshcop/announce_begin_client.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #include "coap/coap.hpp" #include "common/locator.hpp" #include "net/ip6_address.hpp" @@ -77,4 +79,6 @@ public: } // namespace ot +#endif // OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #endif // ANNOUNCE_BEGIN_CLIENT_HPP_ diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index fb33647e0..821bd5d71 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -33,6 +33,8 @@ #include "border_agent.hpp" +#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE + #include "coap/coap_message.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" @@ -43,8 +45,6 @@ #include "thread/thread_tlvs.hpp" #include "thread/uri_paths.hpp" -#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE - namespace ot { namespace MeshCoP { diff --git a/src/core/meshcop/border_agent.hpp b/src/core/meshcop/border_agent.hpp index 43ee78fb5..4a0d8d451 100644 --- a/src/core/meshcop/border_agent.hpp +++ b/src/core/meshcop/border_agent.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE + #include #include "coap/coap.hpp" @@ -190,4 +192,6 @@ private: } // namespace MeshCoP } // namespace ot +#endif // OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE + #endif // BORDER_AGENT_HPP_ diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index 010d5ed7b..6b9ea33bf 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -33,6 +33,8 @@ #include "commissioner.hpp" +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE + #include #include "coap/coap_message.hpp" @@ -49,8 +51,6 @@ #include "thread/thread_tlvs.hpp" #include "thread/uri_paths.hpp" -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE - namespace ot { namespace MeshCoP { diff --git a/src/core/meshcop/commissioner.hpp b/src/core/meshcop/commissioner.hpp index 8a21c43b8..b88056674 100644 --- a/src/core/meshcop/commissioner.hpp +++ b/src/core/meshcop/commissioner.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE + #include #include "coap/coap.hpp" @@ -477,4 +479,6 @@ private: } // namespace MeshCoP } // namespace ot +#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE + #endif // COMMISSIONER_HPP_ diff --git a/src/core/meshcop/dataset_manager_ftd.cpp b/src/core/meshcop/dataset_manager_ftd.cpp index e8e5ffba3..98647c018 100644 --- a/src/core/meshcop/dataset_manager_ftd.cpp +++ b/src/core/meshcop/dataset_manager_ftd.cpp @@ -31,6 +31,9 @@ * This file implements MeshCoP Datasets manager to process commands. * */ + +#include "meshcop/dataset_manager.hpp" + #if OPENTHREAD_FTD #include @@ -46,7 +49,6 @@ #include "common/random.hpp" #include "common/timer.hpp" #include "meshcop/dataset.hpp" -#include "meshcop/dataset_manager.hpp" #include "meshcop/meshcop.hpp" #include "meshcop/meshcop_leader.hpp" #include "meshcop/meshcop_tlvs.hpp" diff --git a/src/core/meshcop/dataset_updater.cpp b/src/core/meshcop/dataset_updater.cpp index 9c70e4564..6b86f4e0f 100644 --- a/src/core/meshcop/dataset_updater.cpp +++ b/src/core/meshcop/dataset_updater.cpp @@ -34,14 +34,14 @@ #include "dataset_updater.hpp" +#if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" #include "common/logging.hpp" #include "common/random.hpp" -#if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD - namespace ot { namespace MeshCoP { diff --git a/src/core/meshcop/dataset_updater.hpp b/src/core/meshcop/dataset_updater.hpp index 7d7719663..1ddc4eab4 100644 --- a/src/core/meshcop/dataset_updater.hpp +++ b/src/core/meshcop/dataset_updater.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD + #include #include "common/locator.hpp" @@ -49,8 +51,6 @@ namespace ot { namespace MeshCoP { -#if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD - /** * This class implements the Dataset Updater. * @@ -138,9 +138,9 @@ private: Message * mDataset; }; -#endif // (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD - } // namespace MeshCoP } // namespace ot +#endif // (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD + #endif // DATASET_UPDATER_HPP_ diff --git a/src/core/meshcop/energy_scan_client.cpp b/src/core/meshcop/energy_scan_client.cpp index f40e5ab05..763468f3c 100644 --- a/src/core/meshcop/energy_scan_client.cpp +++ b/src/core/meshcop/energy_scan_client.cpp @@ -33,6 +33,8 @@ #include "energy_scan_client.hpp" +#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #include "coap/coap_message.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" @@ -45,8 +47,6 @@ #include "thread/thread_netif.hpp" #include "thread/uri_paths.hpp" -#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD - namespace ot { EnergyScanClient::EnergyScanClient(Instance &aInstance) diff --git a/src/core/meshcop/energy_scan_client.hpp b/src/core/meshcop/energy_scan_client.hpp index 6e14842ac..238344cbe 100644 --- a/src/core/meshcop/energy_scan_client.hpp +++ b/src/core/meshcop/energy_scan_client.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #include #include "coap/coap.hpp" @@ -97,4 +99,6 @@ private: } // namespace ot +#endif // OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #endif // ENERGY_SCAN_CLIENT_HPP_ diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index 176bbdd4f..a9905f97b 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -33,6 +33,8 @@ #include "joiner.hpp" +#if OPENTHREAD_CONFIG_JOINER_ENABLE + #include #include "common/code_utils.hpp" @@ -48,8 +50,6 @@ #include "thread/uri_paths.hpp" #include "utils/otns.hpp" -#if OPENTHREAD_CONFIG_JOINER_ENABLE - namespace ot { namespace MeshCoP { diff --git a/src/core/meshcop/joiner.hpp b/src/core/meshcop/joiner.hpp index 904a3ed52..0f9677370 100644 --- a/src/core/meshcop/joiner.hpp +++ b/src/core/meshcop/joiner.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_JOINER_ENABLE + #include #include "coap/coap.hpp" @@ -243,4 +245,6 @@ private: } // namespace MeshCoP } // namespace ot +#endif // OPENTHREAD_CONFIG_JOINER_ENABLE + #endif // JOINER_HPP_ diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp index 7216ad675..a410cb6dc 100644 --- a/src/core/meshcop/joiner_router.cpp +++ b/src/core/meshcop/joiner_router.cpp @@ -31,10 +31,10 @@ * This file implements the Joiner Router role. */ -#if OPENTHREAD_FTD - #include "joiner_router.hpp" +#if OPENTHREAD_FTD + #include #include "common/code_utils.hpp" diff --git a/src/core/meshcop/joiner_router.hpp b/src/core/meshcop/joiner_router.hpp index 47323f75a..851c28f64 100644 --- a/src/core/meshcop/joiner_router.hpp +++ b/src/core/meshcop/joiner_router.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD + #include "coap/coap.hpp" #include "coap/coap_message.hpp" #include "common/locator.hpp" @@ -134,4 +136,6 @@ private: } // namespace MeshCoP } // namespace ot +#endif // OPENTHREAD_FTD + #endif // JOINER_ROUTER_HPP_ diff --git a/src/core/meshcop/meshcop_leader.cpp b/src/core/meshcop/meshcop_leader.cpp index 8ef87310b..808e1ad34 100644 --- a/src/core/meshcop/meshcop_leader.cpp +++ b/src/core/meshcop/meshcop_leader.cpp @@ -31,10 +31,10 @@ * This file implements a MeshCoP Leader. */ -#if OPENTHREAD_FTD - #include "meshcop_leader.hpp" +#if OPENTHREAD_FTD + #include #include "coap/coap_message.hpp" diff --git a/src/core/meshcop/meshcop_leader.hpp b/src/core/meshcop/meshcop_leader.hpp index 47e239357..a489acc61 100644 --- a/src/core/meshcop/meshcop_leader.hpp +++ b/src/core/meshcop/meshcop_leader.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD + #include "coap/coap.hpp" #include "common/locator.hpp" #include "common/non_copyable.hpp" @@ -144,4 +146,6 @@ private: } // namespace MeshCoP } // namespace ot +#endif // OPENTHREAD_FTD + #endif // MESHCOP_LEADER_HPP_ diff --git a/src/core/meshcop/panid_query_client.cpp b/src/core/meshcop/panid_query_client.cpp index 47b49b1ef..1efa55e31 100644 --- a/src/core/meshcop/panid_query_client.cpp +++ b/src/core/meshcop/panid_query_client.cpp @@ -33,6 +33,8 @@ #include "panid_query_client.hpp" +#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #include "coap/coap_message.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" @@ -44,8 +46,6 @@ #include "thread/thread_netif.hpp" #include "thread/uri_paths.hpp" -#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD - namespace ot { PanIdQueryClient::PanIdQueryClient(Instance &aInstance) diff --git a/src/core/meshcop/panid_query_client.hpp b/src/core/meshcop/panid_query_client.hpp index 4ad1b4359..35071508f 100644 --- a/src/core/meshcop/panid_query_client.hpp +++ b/src/core/meshcop/panid_query_client.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #include #include "coap/coap.hpp" @@ -93,4 +95,6 @@ private: } // namespace ot +#endif // OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD + #endif // PANID_QUERY_CLIENT_HPP_ diff --git a/src/core/net/dhcp6_client.cpp b/src/core/net/dhcp6_client.cpp index 4a617033f..13ab59a9a 100644 --- a/src/core/net/dhcp6_client.cpp +++ b/src/core/net/dhcp6_client.cpp @@ -33,6 +33,8 @@ #include "dhcp6_client.hpp" +#if OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE + #include "common/code_utils.hpp" #include "common/encoding.hpp" #include "common/instance.hpp" @@ -42,8 +44,6 @@ #include "net/dhcp6.hpp" #include "thread/thread_netif.hpp" -#if OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE - namespace ot { namespace Dhcp6 { diff --git a/src/core/net/dhcp6_client.hpp b/src/core/net/dhcp6_client.hpp index cb298803b..89dfabcad 100644 --- a/src/core/net/dhcp6_client.hpp +++ b/src/core/net/dhcp6_client.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE + #include "common/locator.hpp" #include "common/message.hpp" #include "common/non_copyable.hpp" @@ -51,8 +53,6 @@ namespace ot { namespace Dhcp6 { -#if OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE - /** * @addtogroup core-dhcp6 * @@ -159,6 +159,9 @@ private: * */ +} // namespace Dhcp6 +} // namespace ot + #else // OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE #if OPENTHREAD_ENABLE_DHCP6_MULTICAST_SOLICIT @@ -167,7 +170,4 @@ private: #endif // OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE -} // namespace Dhcp6 -} // namespace ot - #endif // DHCP6_CLIENT_HPP_ diff --git a/src/core/net/dhcp6_server.cpp b/src/core/net/dhcp6_server.cpp index f441ada17..4aea287b9 100644 --- a/src/core/net/dhcp6_server.cpp +++ b/src/core/net/dhcp6_server.cpp @@ -33,6 +33,8 @@ #include "dhcp6_server.hpp" +#if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE + #include "common/code_utils.hpp" #include "common/encoding.hpp" #include "common/instance.hpp" @@ -41,8 +43,6 @@ #include "thread/mle.hpp" #include "thread/thread_netif.hpp" -#if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE - namespace ot { namespace Dhcp6 { diff --git a/src/core/net/dhcp6_server.hpp b/src/core/net/dhcp6_server.hpp index a7ab47079..d077e17f8 100644 --- a/src/core/net/dhcp6_server.hpp +++ b/src/core/net/dhcp6_server.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE + #include "common/locator.hpp" #include "common/non_copyable.hpp" #include "mac/mac.hpp" @@ -47,8 +49,6 @@ namespace ot { namespace Dhcp6 { -#if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE - #if OPENTHREAD_ENABLE_DHCP6_MULTICAST_SOLICIT #error "OPENTHREAD_ENABLE_DHCP6_MULTICAST_SOLICIT requires DHCPv6 server on Border Router side to be enabled." #endif @@ -229,9 +229,9 @@ private: * */ -#endif // OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE - } // namespace Dhcp6 } // namespace ot +#endif // OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE + #endif // DHCP6_SERVER_HPP_ diff --git a/src/core/net/dns_client.cpp b/src/core/net/dns_client.cpp index 1211db5f0..401a336c1 100644 --- a/src/core/net/dns_client.cpp +++ b/src/core/net/dns_client.cpp @@ -28,6 +28,8 @@ #include "dns_client.hpp" +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/instance.hpp" @@ -36,8 +38,6 @@ #include "net/udp6.hpp" #include "thread/thread_netif.hpp" -#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE - /** * @file * This file implements the DNS client. diff --git a/src/core/net/dns_client.hpp b/src/core/net/dns_client.hpp index 0b5227aef..e44a8f9af 100644 --- a/src/core/net/dns_client.hpp +++ b/src/core/net/dns_client.hpp @@ -31,6 +31,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE + #include #include "common/clearable.hpp" @@ -685,4 +687,6 @@ private: } // namespace Dns } // namespace ot +#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE + #endif // DNS_CLIENT_HPP_ diff --git a/src/core/net/sntp_client.cpp b/src/core/net/sntp_client.cpp index c2be9eedf..f4c15a273 100644 --- a/src/core/net/sntp_client.cpp +++ b/src/core/net/sntp_client.cpp @@ -29,6 +29,8 @@ #include "sntp_client.hpp" +#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/instance.hpp" @@ -37,8 +39,6 @@ #include "net/udp6.hpp" #include "thread/thread_netif.hpp" -#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE - /** * @file * This file implements the SNTP client. diff --git a/src/core/net/sntp_client.hpp b/src/core/net/sntp_client.hpp index ed1eb59d4..618be5cb7 100644 --- a/src/core/net/sntp_client.hpp +++ b/src/core/net/sntp_client.hpp @@ -31,6 +31,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE + #include #include "common/message.hpp" @@ -591,4 +593,6 @@ private: } // namespace Sntp } // namespace ot +#endif // OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE + #endif // SNTP_CLIENT_HPP_ diff --git a/src/core/net/srp_client.cpp b/src/core/net/srp_client.cpp index 235a24cbd..7e38f57f8 100644 --- a/src/core/net/srp_client.cpp +++ b/src/core/net/srp_client.cpp @@ -28,6 +28,8 @@ #include "srp_client.hpp" +#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/instance.hpp" @@ -38,8 +40,6 @@ #include "common/string.hpp" #include "thread/network_data_service.hpp" -#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE - /** * @file * This file implements the SRP client. diff --git a/src/core/net/srp_client.hpp b/src/core/net/srp_client.hpp index 070513df7..a69cf5f68 100644 --- a/src/core/net/srp_client.hpp +++ b/src/core/net/srp_client.hpp @@ -31,6 +31,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE + #include #include "common/clearable.hpp" @@ -45,8 +47,6 @@ #include "net/ip6.hpp" #include "net/udp6.hpp" -#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE - /** * @file * This file includes definitions for the SRP (Service Registration Protocol) client. diff --git a/src/core/radio/trel_interface.cpp b/src/core/radio/trel_interface.cpp index 8c756214d..03b43ad64 100644 --- a/src/core/radio/trel_interface.cpp +++ b/src/core/radio/trel_interface.cpp @@ -32,6 +32,8 @@ #include "trel_interface.hpp" +#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE + #include #include "common/code_utils.hpp" @@ -39,8 +41,6 @@ #include "common/locator-getters.hpp" #include "common/logging.hpp" -#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - namespace ot { namespace Trel { diff --git a/src/core/radio/trel_interface.hpp b/src/core/radio/trel_interface.hpp index ebdd40d90..ea9fcf19d 100644 --- a/src/core/radio/trel_interface.hpp +++ b/src/core/radio/trel_interface.hpp @@ -36,13 +36,13 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE + #include "common/locator.hpp" #include "mac/mac_types.hpp" #include "net/ip6_address.hpp" #include "radio/trel_packet.hpp" -#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - namespace ot { namespace Trel { diff --git a/src/core/radio/trel_link.cpp b/src/core/radio/trel_link.cpp index e2e9d56ad..776a65965 100644 --- a/src/core/radio/trel_link.cpp +++ b/src/core/radio/trel_link.cpp @@ -32,14 +32,14 @@ #include "trel_link.hpp" +#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" #include "common/logging.hpp" -#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - namespace ot { namespace Trel { diff --git a/src/core/radio/trel_link.hpp b/src/core/radio/trel_link.hpp index 4f597ff8f..c36f8fdef 100644 --- a/src/core/radio/trel_link.hpp +++ b/src/core/radio/trel_link.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE + #include "common/encoding.hpp" #include "common/locator.hpp" #include "common/tasklet.hpp" @@ -45,8 +47,6 @@ #include "radio/trel_interface.hpp" #include "radio/trel_packet.hpp" -#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - namespace ot { class Neighbor; diff --git a/src/core/radio/trel_packet.cpp b/src/core/radio/trel_packet.cpp index 59f9d93a2..71471323e 100644 --- a/src/core/radio/trel_packet.cpp +++ b/src/core/radio/trel_packet.cpp @@ -32,14 +32,14 @@ #include "trel_packet.hpp" +#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" #include "common/logging.hpp" -#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - namespace ot { namespace Trel { diff --git a/src/core/radio/trel_packet.hpp b/src/core/radio/trel_packet.hpp index 4f706e1d5..578cdaa43 100644 --- a/src/core/radio/trel_packet.hpp +++ b/src/core/radio/trel_packet.hpp @@ -36,13 +36,13 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE + #include "common/encoding.hpp" #include "common/locator.hpp" #include "common/string.hpp" #include "mac/mac_types.hpp" -#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - namespace ot { namespace Trel { diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index 14f131460..a4af93266 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -31,10 +31,10 @@ * This file implements Thread's EID-to-RLOC mapping and caching. */ -#if OPENTHREAD_FTD - #include "address_resolver.hpp" +#if OPENTHREAD_FTD + #include "coap/coap_message.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" diff --git a/src/core/thread/address_resolver.hpp b/src/core/thread/address_resolver.hpp index 13f0d7070..853622f59 100644 --- a/src/core/thread/address_resolver.hpp +++ b/src/core/thread/address_resolver.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD + #include "coap/coap.hpp" #include "common/linked_list.hpp" #include "common/locator.hpp" @@ -363,4 +365,6 @@ private: } // namespace ot +#endif // OPENTHREAD_FTD + #endif // ADDRESS_RESOLVER_HPP_ diff --git a/src/core/thread/child_table.cpp b/src/core/thread/child_table.cpp index 9df285a5f..9b8c8090e 100644 --- a/src/core/thread/child_table.cpp +++ b/src/core/thread/child_table.cpp @@ -33,14 +33,14 @@ #include "child_table.hpp" +#if OPENTHREAD_FTD + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" namespace ot { -#if OPENTHREAD_FTD - ChildTable::Iterator::Iterator(Instance &aInstance, Child::StateFilter aFilter) : InstanceLocator(aInstance) , ItemPtrIterator(nullptr) @@ -330,6 +330,6 @@ bool ChildTable::HasSleepyChildWithAddress(const Ip6::Address &aIp6Address) cons return hasChild; } -#endif // OPENTHREAD_FTD - } // namespace ot + +#endif // OPENTHREAD_FTD diff --git a/src/core/thread/csl_tx_scheduler.hpp b/src/core/thread/csl_tx_scheduler.hpp index 718aed3ec..873175f85 100644 --- a/src/core/thread/csl_tx_scheduler.hpp +++ b/src/core/thread/csl_tx_scheduler.hpp @@ -31,6 +31,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE + #include "common/locator.hpp" #include "common/message.hpp" #include "common/non_copyable.hpp" @@ -50,8 +52,6 @@ namespace ot { * @{ */ -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE - class Child; /** @@ -208,8 +208,6 @@ private: Callbacks mCallbacks; }; -#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE - /** * @} * @@ -217,4 +215,6 @@ private: } // namespace ot +#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE + #endif // CSL_TX_SCHEDULER_HPP_ diff --git a/src/core/thread/indirect_sender.cpp b/src/core/thread/indirect_sender.cpp index bea98179a..b2d239074 100644 --- a/src/core/thread/indirect_sender.cpp +++ b/src/core/thread/indirect_sender.cpp @@ -31,10 +31,10 @@ * This file includes definitions for handling indirect transmission. */ -#if OPENTHREAD_FTD - #include "indirect_sender.hpp" +#if OPENTHREAD_FTD + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" diff --git a/src/core/thread/indirect_sender.hpp b/src/core/thread/indirect_sender.hpp index 53cb7f15e..8788ca97c 100644 --- a/src/core/thread/indirect_sender.hpp +++ b/src/core/thread/indirect_sender.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD + #include "common/locator.hpp" #include "common/message.hpp" #include "common/non_copyable.hpp" @@ -237,4 +239,6 @@ private: } // namespace ot +#endif // OPENTHREAD_FTD + #endif // INDIRECT_SENDER_HPP_ diff --git a/src/core/thread/link_metrics_tlvs.hpp b/src/core/thread/link_metrics_tlvs.hpp index 696a52c83..1c910ccb1 100644 --- a/src/core/thread/link_metrics_tlvs.hpp +++ b/src/core/thread/link_metrics_tlvs.hpp @@ -35,14 +35,16 @@ #ifndef LINK_METRICS_TLVS_HPP_ #define LINK_METRICS_TLVS_HPP_ +#include "openthread-core-config.h" + +#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE + #include #include "common/encoding.hpp" #include "common/message.hpp" #include "common/tlvs.hpp" -#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE - namespace ot { /** diff --git a/src/core/thread/mesh_forwarder.hpp b/src/core/thread/mesh_forwarder.hpp index 3758de45a..beed901bf 100644 --- a/src/core/thread/mesh_forwarder.hpp +++ b/src/core/thread/mesh_forwarder.hpp @@ -235,6 +235,7 @@ public: */ void SetDiscoverParameters(const Mac::ChannelMask &aScanChannels); +#if OPENTHREAD_FTD /** * This method frees any messages queued for an existing child. * @@ -244,6 +245,7 @@ public: * */ void RemoveMessages(Child &aChild, Message::SubType aSubType); +#endif /** * This method frees unicast/multicast MLE Data Responses from Send Message Queue if any. diff --git a/src/core/thread/mesh_forwarder_ftd.cpp b/src/core/thread/mesh_forwarder_ftd.cpp index 0ce2f4ddd..9f43fb966 100644 --- a/src/core/thread/mesh_forwarder_ftd.cpp +++ b/src/core/thread/mesh_forwarder_ftd.cpp @@ -31,10 +31,10 @@ * This file implements FTD-specific mesh forwarding of IPv6/6LoWPAN messages. */ -#if OPENTHREAD_FTD - #include "mesh_forwarder.hpp" +#if OPENTHREAD_FTD + #include "common/locator-getters.hpp" #include "common/logging.hpp" #include "meshcop/meshcop.hpp" diff --git a/src/core/thread/mesh_forwarder_mtd.cpp b/src/core/thread/mesh_forwarder_mtd.cpp index 677179158..76db595f9 100644 --- a/src/core/thread/mesh_forwarder_mtd.cpp +++ b/src/core/thread/mesh_forwarder_mtd.cpp @@ -31,10 +31,10 @@ * This file implements MTD-specific mesh forwarding of IPv6/6LoWPAN messages. */ -#if OPENTHREAD_MTD - #include "mesh_forwarder.hpp" +#if OPENTHREAD_MTD + namespace ot { Error MeshForwarder::SendMessage(Message &aMessage) diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 62a599d85..0f50e8fd5 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -39,6 +39,7 @@ #include "common/encoding.hpp" #include "common/locator.hpp" #include "common/non_copyable.hpp" +#include "common/notifier.hpp" #include "common/timer.hpp" #include "mac/mac.hpp" #include "meshcop/joiner_router.hpp" diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 7bd03696f..0ebe627a5 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -30,10 +30,10 @@ * This file implements MLE functionality required for the Thread Router and Leader roles. */ -#if OPENTHREAD_FTD - #include "mle_router.hpp" +#if OPENTHREAD_FTD + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/encoding.hpp" diff --git a/src/core/thread/neighbor_table.cpp b/src/core/thread/neighbor_table.cpp index 6d86a1b31..cbf58b07e 100644 --- a/src/core/thread/neighbor_table.cpp +++ b/src/core/thread/neighbor_table.cpp @@ -267,7 +267,9 @@ void NeighborTable::Signal(Event aEvent, const Neighbor &aNeighbor) { case OT_NEIGHBOR_TABLE_EVENT_CHILD_ADDED: case OT_NEIGHBOR_TABLE_EVENT_CHILD_REMOVED: +#if OPENTHREAD_FTD static_cast(info.mInfo.mChild).SetFrom(static_cast(aNeighbor)); +#endif break; case OT_NEIGHBOR_TABLE_EVENT_ROUTER_ADDED: diff --git a/src/core/thread/network_data_leader_ftd.cpp b/src/core/thread/network_data_leader_ftd.cpp index f3fc96559..f863df5d8 100644 --- a/src/core/thread/network_data_leader_ftd.cpp +++ b/src/core/thread/network_data_leader_ftd.cpp @@ -31,10 +31,10 @@ * This file implements the Thread Network Data managed by the Thread Leader. */ -#if OPENTHREAD_FTD - #include "network_data_leader.hpp" +#if OPENTHREAD_FTD + #include "coap/coap_message.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" diff --git a/src/core/thread/network_data_leader_ftd.hpp b/src/core/thread/network_data_leader_ftd.hpp index 0643947b2..b40699a57 100644 --- a/src/core/thread/network_data_leader_ftd.hpp +++ b/src/core/thread/network_data_leader_ftd.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD + #include #include "coap/coap.hpp" @@ -317,4 +319,6 @@ private: } // namespace NetworkData } // namespace ot +#endif // OPENTHREAD_FTD + #endif // NETWORK_DATA_LEADER_FTD_HPP_ diff --git a/src/core/thread/network_data_local.cpp b/src/core/thread/network_data_local.cpp index bef1b2661..65076c6ab 100644 --- a/src/core/thread/network_data_local.cpp +++ b/src/core/thread/network_data_local.cpp @@ -33,6 +33,8 @@ #include "network_data_local.hpp" +#if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/instance.hpp" @@ -42,8 +44,6 @@ #include "thread/mle_types.hpp" #include "thread/thread_netif.hpp" -#if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE - namespace ot { namespace NetworkData { diff --git a/src/core/thread/network_data_local.hpp b/src/core/thread/network_data_local.hpp index a0985f143..fa1dbd5cf 100644 --- a/src/core/thread/network_data_local.hpp +++ b/src/core/thread/network_data_local.hpp @@ -37,11 +37,11 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE + #include "common/non_copyable.hpp" #include "thread/network_data.hpp" -#if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE - namespace ot { /** diff --git a/src/core/thread/network_diagnostic.cpp b/src/core/thread/network_diagnostic.cpp index 49418406a..743a4799c 100644 --- a/src/core/thread/network_diagnostic.cpp +++ b/src/core/thread/network_diagnostic.cpp @@ -33,6 +33,8 @@ #include "network_diagnostic.hpp" +#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE + #include "coap/coap_message.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" @@ -48,8 +50,6 @@ #include "thread/thread_tlvs.hpp" #include "thread/uri_paths.hpp" -#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE - namespace ot { namespace NetworkDiagnostic { diff --git a/src/core/thread/network_diagnostic.hpp b/src/core/thread/network_diagnostic.hpp index e5a2b6815..641e9115b 100644 --- a/src/core/thread/network_diagnostic.hpp +++ b/src/core/thread/network_diagnostic.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE + #include #include "coap/coap.hpp" @@ -163,4 +165,6 @@ private: } // namespace ot +#endif // OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE + #endif // NETWORK_DIAGNOSTIC_HPP_ diff --git a/src/core/thread/radio_selector.cpp b/src/core/thread/radio_selector.cpp index e7d7c0a33..219ef6e96 100644 --- a/src/core/thread/radio_selector.cpp +++ b/src/core/thread/radio_selector.cpp @@ -33,14 +33,14 @@ #include "radio_selector.hpp" +#if OPENTHREAD_CONFIG_MULTI_RADIO + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" #include "common/logging.hpp" #include "common/random.hpp" -#if OPENTHREAD_CONFIG_MULTI_RADIO - namespace ot { // This array defines the order in which different radio link types are diff --git a/src/core/thread/radio_selector.hpp b/src/core/thread/radio_selector.hpp index 30471ab33..b244a60eb 100644 --- a/src/core/thread/radio_selector.hpp +++ b/src/core/thread/radio_selector.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_MULTI_RADIO + #include #include "common/locator.hpp" @@ -44,8 +46,6 @@ #include "mac/mac_links.hpp" #include "mac/mac_types.hpp" -#if OPENTHREAD_CONFIG_MULTI_RADIO - namespace ot { /** diff --git a/src/core/thread/src_match_controller.hpp b/src/core/thread/src_match_controller.hpp index f41d1e81c..860caa05e 100644 --- a/src/core/thread/src_match_controller.hpp +++ b/src/core/thread/src_match_controller.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_FTD + #include "common/error.hpp" #include "common/locator.hpp" #include "common/non_copyable.hpp" @@ -194,4 +196,6 @@ private: } // namespace ot +#endif // OPENTHREAD_FTD + #endif // SOURCE_MATCH_CONTROLLER_HPP_ diff --git a/src/core/thread/time_sync_service.hpp b/src/core/thread/time_sync_service.hpp index bbcee3281..d1c551190 100644 --- a/src/core/thread/time_sync_service.hpp +++ b/src/core/thread/time_sync_service.hpp @@ -37,6 +37,7 @@ #include "openthread-core-config.h" #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE + #include #include "common/locator.hpp" diff --git a/src/core/thread/topology.cpp b/src/core/thread/topology.cpp index f169ee48a..54d38fc13 100644 --- a/src/core/thread/topology.cpp +++ b/src/core/thread/topology.cpp @@ -214,6 +214,8 @@ const char *Neighbor::StateToString(State aState) return static_cast(aState) < OT_ARRAY_LENGTH(kStateStrings) ? kStateStrings[aState] : "Unknown"; } +#if OPENTHREAD_FTD + void Child::Info::SetFrom(const Child &aChild) { Clear(); @@ -428,7 +430,7 @@ void Child::GenerateChallenge(void) IgnoreError(Random::Crypto::FillBuffer(mAttachChallenge, sizeof(mAttachChallenge))); } -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE +#if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE bool Child::HasMlrRegisteredAddress(const Ip6::Address &aAddress) const { bool has = false; @@ -471,7 +473,9 @@ void Child::SetAddressMlrState(const Ip6::Address &aAddress, MlrState aState) mMlrToRegisterMask.Set(addressIndex, aState == kMlrStateToRegister); mMlrRegisteredMask.Set(addressIndex, aState == kMlrStateRegistered); } -#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE +#endif // OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE + +#endif // OPENTHREAD_FTD void Router::Info::SetFrom(const Router &aRouter) { diff --git a/src/core/thread/topology.hpp b/src/core/thread/topology.hpp index 0120c5200..1b24ae10d 100644 --- a/src/core/thread/topology.hpp +++ b/src/core/thread/topology.hpp @@ -811,6 +811,8 @@ private: #endif }; +#if OPENTHREAD_FTD + /** * This class represents a Thread Child. * @@ -818,7 +820,7 @@ private: class Child : public Neighbor, public IndirectSender::ChildInfo, public DataPollHandler::ChildInfo -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE +#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE , public CslTxScheduler::ChildInfo #endif @@ -1308,6 +1310,8 @@ private: static_assert(OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS < 8192, "mQueuedMessageCount cannot fit max required!"); }; +#endif // OPENTHREAD_FTD + /** * This class represents a Thread Router * diff --git a/src/core/utils/channel_manager.cpp b/src/core/utils/channel_manager.cpp index 70b05cb44..afb85d74f 100644 --- a/src/core/utils/channel_manager.cpp +++ b/src/core/utils/channel_manager.cpp @@ -34,6 +34,8 @@ #include "channel_manager.hpp" +#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" @@ -42,8 +44,6 @@ #include "meshcop/dataset_updater.hpp" #include "radio/radio.hpp" -#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD - namespace ot { namespace Utils { diff --git a/src/core/utils/channel_manager.hpp b/src/core/utils/channel_manager.hpp index 8027647ec..467e5f1a2 100644 --- a/src/core/utils/channel_manager.hpp +++ b/src/core/utils/channel_manager.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD + #include #include "common/locator.hpp" @@ -55,8 +57,6 @@ namespace Utils { * @{ */ -#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD - /** * This class implements the Channel Manager. * @@ -283,8 +283,6 @@ private: bool mAutoSelectEnabled; }; -#endif // OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD - /** * @} * @@ -293,4 +291,6 @@ private: } // namespace Utils } // namespace ot +#endif // OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD + #endif // CHANNEL_MANAGER_HPP_ diff --git a/src/core/utils/channel_monitor.cpp b/src/core/utils/channel_monitor.cpp index 9fef24fe7..c72337d8d 100644 --- a/src/core/utils/channel_monitor.cpp +++ b/src/core/utils/channel_monitor.cpp @@ -33,13 +33,13 @@ #include "channel_monitor.hpp" +#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE + #include "common/code_utils.hpp" #include "common/locator-getters.hpp" #include "common/logging.hpp" #include "common/random.hpp" -#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE - namespace ot { namespace Utils { @@ -236,4 +236,4 @@ Mac::ChannelMask ChannelMonitor::FindBestChannels(const Mac::ChannelMask &aMask, } // namespace Utils } // namespace ot -#endif // #if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE +#endif // OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE diff --git a/src/core/utils/channel_monitor.hpp b/src/core/utils/channel_monitor.hpp index 3f8c90049..540b5f8f9 100644 --- a/src/core/utils/channel_monitor.hpp +++ b/src/core/utils/channel_monitor.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE + #include #include "common/locator.hpp" @@ -56,8 +58,6 @@ namespace Utils { * @{ */ -#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE - /** * This class implements the channel monitoring logic. * @@ -213,8 +213,6 @@ private: TimerMilli mTimer; }; -#endif // OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE - /** * @} * @@ -223,4 +221,6 @@ private: } // namespace Utils } // namespace ot +#endif // OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE + #endif // CHANNEL_MONITOR_HPP_ diff --git a/src/core/utils/child_supervision.hpp b/src/core/utils/child_supervision.hpp index 0ec42dc78..e11148f6f 100644 --- a/src/core/utils/child_supervision.hpp +++ b/src/core/utils/child_supervision.hpp @@ -51,6 +51,7 @@ namespace ot { class ThreadNetif; +class Child; namespace Utils { diff --git a/src/core/utils/flash.cpp b/src/core/utils/flash.cpp index f7ba54030..3e4558640 100644 --- a/src/core/utils/flash.cpp +++ b/src/core/utils/flash.cpp @@ -28,6 +28,8 @@ #include "flash.hpp" +#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE + #include #include @@ -35,8 +37,6 @@ #include "common/code_utils.hpp" #include "common/instance.hpp" -#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE - namespace ot { const uint32_t ot::Flash::sSwapActive; diff --git a/src/core/utils/flash.hpp b/src/core/utils/flash.hpp index 5bb7ed390..49c355468 100644 --- a/src/core/utils/flash.hpp +++ b/src/core/utils/flash.hpp @@ -31,6 +31,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE + #include #include @@ -232,4 +234,6 @@ private: } // namespace ot +#endif // OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE + #endif // FLASH_HPP_ diff --git a/src/core/utils/jam_detector.cpp b/src/core/utils/jam_detector.cpp index 75b1ab135..995ba7b19 100644 --- a/src/core/utils/jam_detector.cpp +++ b/src/core/utils/jam_detector.cpp @@ -33,6 +33,8 @@ #include "jam_detector.hpp" +#if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" @@ -40,8 +42,6 @@ #include "common/random.hpp" #include "thread/thread_netif.hpp" -#if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE - namespace ot { namespace Utils { diff --git a/src/core/utils/jam_detector.hpp b/src/core/utils/jam_detector.hpp index e0ab57dec..4e4c960c6 100644 --- a/src/core/utils/jam_detector.hpp +++ b/src/core/utils/jam_detector.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE + #include #include "common/locator.hpp" @@ -217,4 +219,6 @@ private: } // namespace Utils } // namespace ot +#endif // OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE + #endif // JAM_DETECTOR_HPP_ diff --git a/src/core/utils/otns.hpp b/src/core/utils/otns.hpp index ac4379b58..ce9b2ef16 100644 --- a/src/core/utils/otns.hpp +++ b/src/core/utils/otns.hpp @@ -46,6 +46,7 @@ #include "common/locator.hpp" #include "common/non_copyable.hpp" #include "common/notifier.hpp" +#include "mac/mac_frame.hpp" #include "mac/mac_types.hpp" #include "net/ip6_address.hpp" #include "thread/neighbor_table.hpp" diff --git a/src/core/utils/slaac_address.cpp b/src/core/utils/slaac_address.cpp index 168d3c0c6..032977986 100644 --- a/src/core/utils/slaac_address.cpp +++ b/src/core/utils/slaac_address.cpp @@ -33,6 +33,8 @@ #include "slaac_address.hpp" +#if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE + #include "common/code_utils.hpp" #include "common/instance.hpp" #include "common/locator-getters.hpp" @@ -42,8 +44,6 @@ #include "crypto/sha256.hpp" #include "net/ip6_address.hpp" -#if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE - namespace ot { namespace Utils { diff --git a/src/core/utils/slaac_address.hpp b/src/core/utils/slaac_address.hpp index 1b0d3cfb6..b8ea2eadf 100644 --- a/src/core/utils/slaac_address.hpp +++ b/src/core/utils/slaac_address.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE + #include "common/locator.hpp" #include "common/non_copyable.hpp" #include "common/notifier.hpp" @@ -181,4 +183,6 @@ private: } // namespace Utils } // namespace ot +#endif // OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE + #endif // SLAAC_ADDRESS_HPP_