1 /*
2  *  Copyright (c) 2016-2017, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * @file
31  *  This file defines OpenThread instance class.
32  */
33 
34 #ifndef INSTANCE_HPP_
35 #define INSTANCE_HPP_
36 
37 #include "openthread-core-config.h"
38 
39 #include <stdbool.h>
40 #include <stdint.h>
41 
42 #include <openthread/heap.h>
43 #if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
44 #include <openthread/platform/memory.h>
45 #endif
46 
47 #include "common/array.hpp"
48 #include "common/as_core_type.hpp"
49 #include "common/error.hpp"
50 #include "common/log.hpp"
51 #include "common/message.hpp"
52 #include "common/non_copyable.hpp"
53 #include "common/random.hpp"
54 #include "common/tasklet.hpp"
55 #include "common/time_ticker.hpp"
56 #include "common/timer.hpp"
57 #include "common/uptime.hpp"
58 #include "diags/factory_diags.hpp"
59 #include "instance/extension.hpp"
60 #include "mac/link_raw.hpp"
61 #include "radio/radio.hpp"
62 #include "utils/otns.hpp"
63 #include "utils/power_calibration.hpp"
64 
65 #if OPENTHREAD_FTD || OPENTHREAD_MTD
66 #include "backbone_router/backbone_tmf.hpp"
67 #include "backbone_router/bbr_leader.hpp"
68 #include "backbone_router/bbr_local.hpp"
69 #include "backbone_router/bbr_manager.hpp"
70 #include "border_router/routing_manager.hpp"
71 #include "coap/coap_secure.hpp"
72 #include "common/code_utils.hpp"
73 #include "common/notifier.hpp"
74 #include "common/settings.hpp"
75 #include "crypto/mbedtls.hpp"
76 #include "mac/mac.hpp"
77 #include "meshcop/border_agent.hpp"
78 #include "meshcop/commissioner.hpp"
79 #include "meshcop/dataset_manager.hpp"
80 #include "meshcop/dataset_updater.hpp"
81 #include "meshcop/extended_panid.hpp"
82 #include "meshcop/joiner.hpp"
83 #include "meshcop/joiner_router.hpp"
84 #include "meshcop/meshcop_leader.hpp"
85 #include "meshcop/network_name.hpp"
86 #include "net/dhcp6.hpp"
87 #include "net/dhcp6_client.hpp"
88 #include "net/dhcp6_server.hpp"
89 #include "net/dns_client.hpp"
90 #include "net/dns_dso.hpp"
91 #include "net/dnssd.hpp"
92 #include "net/dnssd_server.hpp"
93 #include "net/ip6.hpp"
94 #include "net/ip6_filter.hpp"
95 #include "net/mdns.hpp"
96 #include "net/nat64_translator.hpp"
97 #include "net/nd_agent.hpp"
98 #include "net/netif.hpp"
99 #include "net/sntp_client.hpp"
100 #include "net/srp_advertising_proxy.hpp"
101 #include "net/srp_client.hpp"
102 #include "net/srp_server.hpp"
103 #include "radio/ble_secure.hpp"
104 #include "thread/address_resolver.hpp"
105 #include "thread/announce_begin_server.hpp"
106 #include "thread/announce_sender.hpp"
107 #include "thread/anycast_locator.hpp"
108 #include "thread/child_supervision.hpp"
109 #include "thread/discover_scanner.hpp"
110 #include "thread/dua_manager.hpp"
111 #include "thread/energy_scan_server.hpp"
112 #include "thread/key_manager.hpp"
113 #include "thread/link_metrics.hpp"
114 #include "thread/link_quality.hpp"
115 #include "thread/mesh_forwarder.hpp"
116 #include "thread/mle.hpp"
117 #include "thread/mle_router.hpp"
118 #include "thread/mlr_manager.hpp"
119 #include "thread/network_data_local.hpp"
120 #include "thread/network_data_notifier.hpp"
121 #include "thread/network_data_publisher.hpp"
122 #include "thread/network_data_service.hpp"
123 #include "thread/network_diagnostic.hpp"
124 #include "thread/panid_query_server.hpp"
125 #include "thread/radio_selector.hpp"
126 #include "thread/thread_netif.hpp"
127 #include "thread/time_sync_service.hpp"
128 #include "thread/tmf.hpp"
129 #include "utils/channel_manager.hpp"
130 #include "utils/channel_monitor.hpp"
131 #include "utils/heap.hpp"
132 #include "utils/history_tracker.hpp"
133 #include "utils/jam_detector.hpp"
134 #include "utils/link_metrics_manager.hpp"
135 #include "utils/mesh_diag.hpp"
136 #include "utils/ping_sender.hpp"
137 #include "utils/slaac_address.hpp"
138 #include "utils/srp_client_buffers.hpp"
139 #endif // OPENTHREAD_FTD || OPENTHREAD_MTD
140 
141 /**
142  * @addtogroup core-instance
143  *
144  * @brief
145  *   This module includes definitions for OpenThread instance.
146  *
147  * @{
148  *
149  */
150 
151 /**
152  * Represents an opaque (and empty) type corresponding to an OpenThread instance object.
153  *
154  */
155 typedef struct otInstance
156 {
157 } otInstance;
158 
159 namespace ot {
160 
161 /**
162  * Represents an OpenThread instance.
163  *
164  * Contains all the components used by OpenThread.
165  *
166  */
167 class Instance : public otInstance, private NonCopyable
168 {
169 public:
170     /**
171      * Represents the message buffer information (number of messages/buffers in all OT stack message queues).
172      *
173      */
174     class BufferInfo : public otBufferInfo, public Clearable<BufferInfo>
175     {
176     };
177 
178 #if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
179     /**
180       * Initializes the OpenThread instance.
181       *
182       * Must be called before any other calls on OpenThread instance.
183       *
184       * @param[in]     aBuffer      The buffer for OpenThread to use for allocating the Instance.
185       * @param[in,out] aBufferSize  On input, the size of `aBuffer`. On output, if not enough space for `Instance`, the
186                                     number of bytes required for `Instance`.
187       *
188       * @returns  A pointer to the new OpenThread instance.
189       *
190       */
191     static Instance *Init(void *aBuffer, size_t *aBufferSize);
192 
193 #if OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE
194     /**
195      * This static method initializes the OpenThread instance.
196      *
197      * This method utilizes static buffer to initialize the OpenThread instance.
198      * This function must be called before any other calls on OpenThread instance.
199      *
200      * @param[in] aIdx The index of the OpenThread instance to initialize.
201      *
202      * @returns  A pointer to the new OpenThread instance.
203      *
204      */
205     static Instance *InitMultiple(uint8_t aIdx);
206 
207     /**
208      * Returns a reference to the OpenThread instance.
209      *
210      * @param[in] aIdx The index of the OpenThread instance to get.
211      *
212      * @returns A reference to the OpenThread instance.
213      *
214      */
215     static Instance &Get(uint8_t aIdx);
216 
217     /**
218      * Returns the index of the OpenThread instance.
219      *
220      * @param[in] aInstance The reference of the OpenThread instance to get index.
221      *
222      * @returns The index of the OpenThread instance.
223      *
224      */
225     static uint8_t GetIdx(Instance *aInstance);
226 #endif
227 
228 #else // OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
229 
230     /**
231      * Initializes the single OpenThread instance.
232      *
233      * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be
234      * called before any other calls to OpenThread.
235      *
236      * @returns A reference to the single OpenThread instance.
237      *
238      */
239     static Instance &InitSingle(void);
240 
241     /**
242      * Returns a reference to the single OpenThread instance.
243      *
244      * @returns A reference to the single OpenThread instance.
245      *
246      */
247     static Instance &Get(void);
248 #endif
249 
250     /**
251      * Gets the instance identifier.
252      *
253      * The instance identifier is set to a random value when the instance is constructed, and then its value will not
254      * change after initialization.
255      *
256      * @returns The instance identifier.
257      *
258      */
GetId(void) const259     uint32_t GetId(void) const { return mId; }
260 
261     /**
262      * Indicates whether or not the instance is valid/initialized and not yet finalized.
263      *
264      * @returns TRUE if the instance is valid/initialized, FALSE otherwise.
265      *
266      */
IsInitialized(void) const267     bool IsInitialized(void) const { return mIsInitialized; }
268 
269     /**
270      * Triggers a platform reset.
271      *
272      * The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that
273      * this method does not erase any persistent state/info saved in non-volatile memory.
274      *
275      */
276     void Reset(void);
277 
278 #if OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
279     /**
280      * Triggers a platform reset to bootloader mode, if supported.
281      *
282      * @retval kErrorNone        Reset to bootloader successfully.
283      * @retval kErrorBusy        Failed due to another operation is ongoing.
284      * @retval kErrorNotCapable  Not capable of resetting to bootloader.
285      *
286      */
287     Error ResetToBootloader(void);
288 #endif
289 
290 #if OPENTHREAD_RADIO
291     /**
292      * Resets the internal states of the radio.
293      *
294      */
295     void ResetRadioStack(void);
296 #endif
297 
298     /**
299      * Returns the active log level.
300      *
301      * @returns The log level.
302      *
303      */
GetLogLevel(void)304     static LogLevel GetLogLevel(void)
305 #if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
306     {
307         return sLogLevel;
308     }
309 #else
310     {
311         return static_cast<LogLevel>(OPENTHREAD_CONFIG_LOG_LEVEL);
312     }
313 #endif
314 
315 #if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
316     /**
317      * Sets the log level.
318      *
319      * @param[in] aLogLevel  A log level.
320      *
321      */
322     static void SetLogLevel(LogLevel aLogLevel);
323 #endif
324 
325     /**
326      * Finalizes the OpenThread instance.
327      *
328      * Should be called when OpenThread instance is no longer in use.
329      *
330      */
331     void Finalize(void);
332 
333 #if OPENTHREAD_MTD || OPENTHREAD_FTD
334     /**
335      * Deletes all the settings stored in non-volatile memory, and then triggers a platform reset.
336      *
337      */
338     void FactoryReset(void);
339 
340     /**
341      * Erases all the OpenThread persistent info (network settings) stored in non-volatile memory.
342      *
343      * Erase is successful/allowed only if the device is in `disabled` state/role.
344      *
345      * @retval kErrorNone          All persistent info/state was erased successfully.
346      * @retval kErrorInvalidState  Device is not in `disabled` state/role.
347      *
348      */
349     Error ErasePersistentInfo(void);
350 
351 #if !OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
352     /**
353      * Returns a reference to the Heap object.
354      *
355      * @returns A reference to the Heap object.
356      *
357      */
358     static Utils::Heap &GetHeap(void);
359 #endif
360 
361 #if OPENTHREAD_CONFIG_COAP_API_ENABLE
362     /**
363      * Returns a reference to application COAP object.
364      *
365      * @returns A reference to the application COAP object.
366      *
367      */
GetApplicationCoap(void)368     Coap::Coap &GetApplicationCoap(void) { return mApplicationCoap; }
369 #endif
370 
371 #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
372     /**
373      * Returns a reference to application COAP Secure object.
374      *
375      * @returns A reference to the application COAP Secure object.
376      *
377      */
GetApplicationCoapSecure(void)378     Coap::CoapSecure &GetApplicationCoapSecure(void) { return mApplicationCoapSecure; }
379 #endif
380 
381 #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
382     /**
383      * Enables/disables the "DNS name compressions" mode.
384      *
385      * By default DNS name compression is enabled. When disabled, DNS names are appended as full and never compressed.
386      * This is applicable to OpenThread's DNS and SRP client/server modules.
387      *
388      * This is intended for testing only and available under a `REFERENCE_DEVICE` config.
389      *
390      * @param[in] aEnabled   TRUE to enable the "DNS name compression" mode, FALSE to disable.
391      *
392      */
SetDnsNameCompressionEnabled(bool aEnabled)393     static void SetDnsNameCompressionEnabled(bool aEnabled) { sDnsNameCompressionEnabled = aEnabled; }
394 
395     /**
396      * Indicates whether the "DNS name compression" mode is enabled or not.
397      *
398      * @returns TRUE if the "DNS name compressions" mode is enabled, FALSE otherwise.
399      *
400      */
IsDnsNameCompressionEnabled(void)401     static bool IsDnsNameCompressionEnabled(void) { return sDnsNameCompressionEnabled; }
402 #endif
403 
404     /**
405      * Retrieves the the Message Buffer information.
406      *
407      * @param[out]  aInfo  A `BufferInfo` where information is written.
408      *
409      */
410     void GetBufferInfo(BufferInfo &aInfo);
411 
412     /**
413      * Resets the Message Buffer information counter tracking maximum number buffers in use at the same
414      * time.
415      *
416      * Resets `mMaxUsedBuffers` in `BufferInfo`.
417      *
418      */
419     void ResetBufferInfo(void);
420 
421 #endif // OPENTHREAD_MTD || OPENTHREAD_FTD
422 
423     /**
424      * Returns a reference to a given `Type` object belonging to the OpenThread instance.
425      *
426      * For example, `Get<MeshForwarder>()` returns a reference to the `MeshForwarder` object of the instance.
427      *
428      * Note that any `Type` for which the `Get<Type>` is defined MUST be uniquely accessible from the OpenThread
429      * `Instance` through the member variable property hierarchy.
430      *
431      * Specializations of the `Get<Type>()` method are defined in this file after the `Instance` class definition.
432      *
433      * @returns A reference to the `Type` object of the instance.
434      *
435      */
436     template <typename Type> inline Type &Get(void);
437 
438 private:
439     Instance(void);
440     void AfterInit(void);
441 
442     // Order of variables (their initialization in `Instance`)
443     // is important.
444     //
445     // Tasklet and Timer Schedulers are first to ensure other
446     // objects/classes can use them from their constructors.
447 
448     Tasklet::Scheduler    mTaskletScheduler;
449     TimerMilli::Scheduler mTimerMilliScheduler;
450 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
451     TimerMicro::Scheduler mTimerMicroScheduler;
452 #endif
453 
454 #if OPENTHREAD_MTD || OPENTHREAD_FTD
455     // Random::Manager is initialized before other objects. Note that it
456     // requires MbedTls which itself may use Heap.
457 #if !OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
458     static Utils::Heap *sHeap;
459 #endif
460     Crypto::MbedTls mMbedTls;
461 #endif // OPENTHREAD_MTD || OPENTHREAD_FTD
462 
463     Random::Manager mRandomManager;
464 
465     // Radio is initialized before other member variables
466     // (particularly, SubMac and Mac) to allow them to use its methods
467     // from their constructor.
468     Radio mRadio;
469 
470 #if OPENTHREAD_CONFIG_UPTIME_ENABLE
471     Uptime mUptime;
472 #endif
473 
474 #if OPENTHREAD_MTD || OPENTHREAD_FTD
475     // Notifier, TimeTicker, Settings, and MessagePool are initialized
476     // before other member variables since other classes/objects from
477     // their constructor may use them.
478     Notifier       mNotifier;
479     TimeTicker     mTimeTicker;
480     Settings       mSettings;
481     SettingsDriver mSettingsDriver;
482     MessagePool    mMessagePool;
483 
484 #if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
485     // DNS-SD (mDNS) platform is initialized early to
486     // allow other modules to use it.
487     Dnssd mDnssd;
488 #endif
489 
490     Ip6::Ip6    mIp6;
491     ThreadNetif mThreadNetif;
492     Tmf::Agent  mTmfAgent;
493 
494 #if OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE
495     Dhcp6::Client mDhcp6Client;
496 #endif
497 
498 #if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE
499     Dhcp6::Server mDhcp6Server;
500 #endif
501 
502 #if OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE
503     NeighborDiscovery::Agent mNeighborDiscoveryAgent;
504 #endif
505 
506 #if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
507     Utils::Slaac mSlaac;
508 #endif
509 
510 #if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
511     Dns::Client mDnsClient;
512 #endif
513 
514 #if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
515     Srp::Client mSrpClient;
516 #endif
517 
518 #if OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE
519     Utils::SrpClientBuffers mSrpClientBuffers;
520 #endif
521 
522 #if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE
523     Dns::ServiceDiscovery::Server mDnssdServer;
524 #endif
525 
526 #if OPENTHREAD_CONFIG_DNS_DSO_ENABLE
527     Dns::Dso mDnsDso;
528 #endif
529 
530 #if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
531     Dns::Multicast::Core mMdnsCore;
532 #endif
533 
534 #if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
535     Sntp::Client mSntpClient;
536 #endif
537 
538 #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
539     BackboneRouter::Local mBackboneRouterLocal;
540 #endif
541 
542     MeshCoP::ActiveDatasetManager  mActiveDataset;
543     MeshCoP::PendingDatasetManager mPendingDataset;
544     MeshCoP::ExtendedPanIdManager  mExtendedPanIdManager;
545     MeshCoP::NetworkNameManager    mNetworkNameManager;
546     Ip6::Filter                    mIp6Filter;
547     KeyManager                     mKeyManager;
548     Lowpan::Lowpan                 mLowpan;
549     Mac::Mac                       mMac;
550     MeshForwarder                  mMeshForwarder;
551     Mle::MleRouter                 mMleRouter;
552     Mle::DiscoverScanner           mDiscoverScanner;
553     AddressResolver                mAddressResolver;
554 
555 #if OPENTHREAD_CONFIG_MULTI_RADIO
556     RadioSelector mRadioSelector;
557 #endif
558 
559 #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
560     NetworkData::Local mNetworkDataLocal;
561 #endif
562 
563     NetworkData::Leader mNetworkDataLeader;
564 
565 #if OPENTHREAD_FTD || OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
566     NetworkData::Notifier mNetworkDataNotifier;
567 #endif
568 
569 #if OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE
570     NetworkData::Publisher mNetworkDataPublisher;
571 #endif
572 
573     NetworkData::Service::Manager mNetworkDataServiceManager;
574 
575     NetworkDiagnostic::Server mNetworkDiagnosticServer;
576 #if OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE
577     NetworkDiagnostic::Client mNetworkDiagnosticClient;
578 #endif
579 
580 #if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
581     MeshCoP::BorderAgent mBorderAgent;
582 #endif
583 
584 #if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
585     MeshCoP::Commissioner mCommissioner;
586 #endif
587 
588 #if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
589     Tmf::SecureAgent mTmfSecureAgent;
590 #endif
591 
592 #if OPENTHREAD_CONFIG_JOINER_ENABLE
593     MeshCoP::Joiner mJoiner;
594 #endif
595 
596 #if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE
597     Utils::JamDetector mJamDetector;
598 #endif
599 
600 #if OPENTHREAD_FTD
601     MeshCoP::JoinerRouter mJoinerRouter;
602     MeshCoP::Leader       mLeader;
603 #endif
604 
605 #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
606     BackboneRouter::Leader mBackboneRouterLeader;
607 #endif
608 
609 #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
610     BackboneRouter::Manager mBackboneRouterManager;
611 #endif
612 
613 #if OPENTHREAD_CONFIG_MLR_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE)
614     MlrManager mMlrManager;
615 #endif
616 
617 #if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
618     DuaManager mDuaManager;
619 #endif
620 
621 #if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
622     Srp::Server mSrpServer;
623 #if OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
624     Srp::AdvertisingProxy mSrpAdvertisingProxy;
625 #endif
626 #endif
627 
628 #if OPENTHREAD_FTD
629     ChildSupervisor mChildSupervisor;
630 #endif
631     SupervisionListener mSupervisionListener;
632 
633     AnnounceBeginServer mAnnounceBegin;
634     PanIdQueryServer    mPanIdQuery;
635     EnergyScanServer    mEnergyScan;
636 
637 #if OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
638     AnycastLocator mAnycastLocator;
639 #endif
640 
641 #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
642     TimeSync mTimeSync;
643 #endif
644 
645 #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
646     LinkMetrics::Initiator mInitiator;
647 #endif
648 
649 #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
650     LinkMetrics::Subject mSubject;
651 #endif
652 
653 #if OPENTHREAD_CONFIG_COAP_API_ENABLE
654     Coap::Coap mApplicationCoap;
655 #endif
656 
657 #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
658     Coap::CoapSecure mApplicationCoapSecure;
659 #endif
660 
661 #if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
662     Ble::BleSecure mApplicationBleSecure;
663 #endif
664 
665 #if OPENTHREAD_CONFIG_PING_SENDER_ENABLE
666     Utils::PingSender mPingSender;
667 #endif
668 
669 #if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
670     Utils::ChannelMonitor mChannelMonitor;
671 #endif
672 
673 #if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && \
674     (OPENTHREAD_FTD ||                          \
675      (OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE))
676     Utils::ChannelManager mChannelManager;
677 #endif
678 
679 #if OPENTHREAD_CONFIG_MESH_DIAG_ENABLE && OPENTHREAD_FTD
680     Utils::MeshDiag mMeshDiag;
681 #endif
682 
683 #if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE
684     Utils::HistoryTracker mHistoryTracker;
685 #endif
686 
687 #if OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE
688     Utils::LinkMetricsManager mLinkMetricsManager;
689 #endif
690 
691 #if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD
692     MeshCoP::DatasetUpdater mDatasetUpdater;
693 #endif
694 
695 #if OPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE
696     AnnounceSender mAnnounceSender;
697 #endif
698 
699 #if OPENTHREAD_CONFIG_OTNS_ENABLE
700     Utils::Otns mOtns;
701 #endif
702 
703 #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
704     BorderRouter::RoutingManager mRoutingManager;
705 #endif
706 
707 #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
708     Nat64::Translator mNat64Translator;
709 #endif
710 
711 #endif // OPENTHREAD_MTD || OPENTHREAD_FTD
712 
713 #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
714     Mac::LinkRaw mLinkRaw;
715 #endif
716 
717 #if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
718     static LogLevel sLogLevel;
719 #endif
720 
721 #if OPENTHREAD_ENABLE_VENDOR_EXTENSION
722     Extension::ExtensionBase &mExtension;
723 #endif
724 
725 #if OPENTHREAD_CONFIG_DIAG_ENABLE
726     FactoryDiags::Diags mDiags;
727 #endif
728 #if OPENTHREAD_CONFIG_POWER_CALIBRATION_ENABLE && OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE
729     Utils::PowerCalibration mPowerCalibration;
730 #endif
731 
732     bool mIsInitialized;
733 
734 #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD)
735     static bool sDnsNameCompressionEnabled;
736 #endif
737 
738     uint32_t mId;
739 };
740 
741 DefineCoreType(otInstance, Instance);
742 DefineCoreType(otBufferInfo, Instance::BufferInfo);
743 
744 // Specializations of the `Get<Type>()` method.
745 
Get(void)746 template <> inline Instance &Instance::Get(void) { return *this; }
747 
Get(void)748 template <> inline Radio &Instance::Get(void) { return mRadio; }
749 
Get(void)750 template <> inline Radio::Callbacks &Instance::Get(void) { return mRadio.mCallbacks; }
751 
752 #if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD)
Get(void)753 template <> inline RadioStatistics &Instance::Get(void) { return mRadio.mRadioStatistics; }
754 #endif
755 
756 #if OPENTHREAD_CONFIG_UPTIME_ENABLE
Get(void)757 template <> inline Uptime &Instance::Get(void) { return mUptime; }
758 #endif
759 
760 #if OPENTHREAD_MTD || OPENTHREAD_FTD
Get(void)761 template <> inline Notifier &Instance::Get(void) { return mNotifier; }
762 
Get(void)763 template <> inline TimeTicker &Instance::Get(void) { return mTimeTicker; }
764 
Get(void)765 template <> inline Settings &Instance::Get(void) { return mSettings; }
766 
Get(void)767 template <> inline SettingsDriver &Instance::Get(void) { return mSettingsDriver; }
768 
Get(void)769 template <> inline MeshForwarder &Instance::Get(void) { return mMeshForwarder; }
770 
771 #if OPENTHREAD_CONFIG_MULTI_RADIO
Get(void)772 template <> inline RadioSelector &Instance::Get(void) { return mRadioSelector; }
773 #endif
774 
Get(void)775 template <> inline Mle::Mle &Instance::Get(void) { return mMleRouter; }
776 
777 #if OPENTHREAD_FTD
Get(void)778 template <> inline Mle::MleRouter &Instance::Get(void) { return mMleRouter; }
779 #endif
780 
Get(void)781 template <> inline Mle::DiscoverScanner &Instance::Get(void) { return mDiscoverScanner; }
782 
Get(void)783 template <> inline NeighborTable &Instance::Get(void) { return mMleRouter.mNeighborTable; }
784 
785 #if OPENTHREAD_FTD
Get(void)786 template <> inline ChildTable &Instance::Get(void) { return mMleRouter.mChildTable; }
787 
Get(void)788 template <> inline RouterTable &Instance::Get(void) { return mMleRouter.mRouterTable; }
789 #endif
790 
Get(void)791 template <> inline Ip6::Netif &Instance::Get(void) { return mThreadNetif; }
792 
Get(void)793 template <> inline ThreadNetif &Instance::Get(void) { return mThreadNetif; }
794 
Get(void)795 template <> inline Ip6::Ip6 &Instance::Get(void) { return mIp6; }
796 
Get(void)797 template <> inline Mac::Mac &Instance::Get(void) { return mMac; }
798 
Get(void)799 template <> inline Mac::SubMac &Instance::Get(void) { return mMac.mLinks.mSubMac; }
800 
801 #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
Get(void)802 template <> inline Trel::Link &Instance::Get(void) { return mMac.mLinks.mTrel; }
803 
Get(void)804 template <> inline Trel::Interface &Instance::Get(void) { return mMac.mLinks.mTrel.mInterface; }
805 #endif
806 
807 #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE
Get(void)808 template <> inline Mac::Filter &Instance::Get(void) { return mMac.mFilter; }
809 #endif
810 
Get(void)811 template <> inline Lowpan::Lowpan &Instance::Get(void) { return mLowpan; }
812 
Get(void)813 template <> inline KeyManager &Instance::Get(void) { return mKeyManager; }
814 
Get(void)815 template <> inline Ip6::Filter &Instance::Get(void) { return mIp6Filter; }
816 
Get(void)817 template <> inline AddressResolver &Instance::Get(void) { return mAddressResolver; }
818 
819 #if OPENTHREAD_FTD
820 
Get(void)821 template <> inline IndirectSender &Instance::Get(void) { return mMeshForwarder.mIndirectSender; }
822 
Get(void)823 template <> inline SourceMatchController &Instance::Get(void)
824 {
825     return mMeshForwarder.mIndirectSender.mSourceMatchController;
826 }
827 
Get(void)828 template <> inline DataPollHandler &Instance::Get(void) { return mMeshForwarder.mIndirectSender.mDataPollHandler; }
829 
830 #if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
Get(void)831 template <> inline CslTxScheduler &Instance::Get(void) { return mMeshForwarder.mIndirectSender.mCslTxScheduler; }
832 #endif
833 
Get(void)834 template <> inline MeshCoP::Leader &Instance::Get(void) { return mLeader; }
835 
Get(void)836 template <> inline MeshCoP::JoinerRouter &Instance::Get(void) { return mJoinerRouter; }
837 #endif // OPENTHREAD_FTD
838 
Get(void)839 template <> inline AnnounceBeginServer &Instance::Get(void) { return mAnnounceBegin; }
840 
Get(void)841 template <> inline DataPollSender &Instance::Get(void) { return mMeshForwarder.mDataPollSender; }
842 
Get(void)843 template <> inline EnergyScanServer &Instance::Get(void) { return mEnergyScan; }
844 
Get(void)845 template <> inline PanIdQueryServer &Instance::Get(void) { return mPanIdQuery; }
846 
847 #if OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
Get(void)848 template <> inline AnycastLocator &Instance::Get(void) { return mAnycastLocator; }
849 #endif
850 
851 #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
Get(void)852 template <> inline NetworkData::Local &Instance::Get(void) { return mNetworkDataLocal; }
853 #endif
854 
Get(void)855 template <> inline NetworkData::Leader &Instance::Get(void) { return mNetworkDataLeader; }
856 
857 #if OPENTHREAD_FTD || OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
Get(void)858 template <> inline NetworkData::Notifier &Instance::Get(void) { return mNetworkDataNotifier; }
859 #endif
860 
861 #if OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE
Get(void)862 template <> inline NetworkData::Publisher &Instance::Get(void) { return mNetworkDataPublisher; }
863 #endif
864 
Get(void)865 template <> inline NetworkData::Service::Manager &Instance::Get(void) { return mNetworkDataServiceManager; }
866 
867 #if OPENTHREAD_CONFIG_TCP_ENABLE
Get(void)868 template <> inline Ip6::Tcp &Instance::Get(void) { return mIp6.mTcp; }
869 #endif
870 
Get(void)871 template <> inline Ip6::Udp &Instance::Get(void) { return mIp6.mUdp; }
872 
Get(void)873 template <> inline Ip6::Icmp &Instance::Get(void) { return mIp6.mIcmp; }
874 
Get(void)875 template <> inline Ip6::Mpl &Instance::Get(void) { return mIp6.mMpl; }
876 
Get(void)877 template <> inline Tmf::Agent &Instance::Get(void) { return mTmfAgent; }
878 
879 #if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
Get(void)880 template <> inline Tmf::SecureAgent &Instance::Get(void) { return mTmfSecureAgent; }
881 #endif
882 
Get(void)883 template <> inline MeshCoP::ExtendedPanIdManager &Instance::Get(void) { return mExtendedPanIdManager; }
884 
Get(void)885 template <> inline MeshCoP::NetworkNameManager &Instance::Get(void) { return mNetworkNameManager; }
886 
Get(void)887 template <> inline MeshCoP::ActiveDatasetManager &Instance::Get(void) { return mActiveDataset; }
888 
Get(void)889 template <> inline MeshCoP::PendingDatasetManager &Instance::Get(void) { return mPendingDataset; }
890 
891 #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
Get(void)892 template <> inline TimeSync &Instance::Get(void) { return mTimeSync; }
893 #endif
894 
895 #if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
Get(void)896 template <> inline MeshCoP::Commissioner &Instance::Get(void) { return mCommissioner; }
897 
Get(void)898 template <> inline AnnounceBeginClient &Instance::Get(void) { return mCommissioner.GetAnnounceBeginClient(); }
899 
Get(void)900 template <> inline EnergyScanClient &Instance::Get(void) { return mCommissioner.GetEnergyScanClient(); }
901 
Get(void)902 template <> inline PanIdQueryClient &Instance::Get(void) { return mCommissioner.GetPanIdQueryClient(); }
903 #endif
904 
905 #if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
Get(void)906 template <> inline Dnssd &Instance::Get(void) { return mDnssd; }
907 #endif
908 
909 #if OPENTHREAD_CONFIG_JOINER_ENABLE
Get(void)910 template <> inline MeshCoP::Joiner &Instance::Get(void) { return mJoiner; }
911 #endif
912 
913 #if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
Get(void)914 template <> inline Dns::Client &Instance::Get(void) { return mDnsClient; }
915 #endif
916 
917 #if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
Get(void)918 template <> inline Srp::Client &Instance::Get(void) { return mSrpClient; }
919 #endif
920 
921 #if OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE
Get(void)922 template <> inline Utils::SrpClientBuffers &Instance::Get(void) { return mSrpClientBuffers; }
923 #endif
924 
925 #if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE
Get(void)926 template <> inline Dns::ServiceDiscovery::Server &Instance::Get(void) { return mDnssdServer; }
927 #endif
928 
929 #if OPENTHREAD_CONFIG_DNS_DSO_ENABLE
Get(void)930 template <> inline Dns::Dso &Instance::Get(void) { return mDnsDso; }
931 #endif
932 
933 #if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
Get(void)934 template <> inline Dns::Multicast::Core &Instance::Get(void) { return mMdnsCore; }
935 #endif
936 
Get(void)937 template <> inline NetworkDiagnostic::Server &Instance::Get(void) { return mNetworkDiagnosticServer; }
938 
939 #if OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE
Get(void)940 template <> inline NetworkDiagnostic::Client &Instance::Get(void) { return mNetworkDiagnosticClient; }
941 #endif
942 
943 #if OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE
Get(void)944 template <> inline Dhcp6::Client &Instance::Get(void) { return mDhcp6Client; }
945 #endif
946 
947 #if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE
Get(void)948 template <> inline Dhcp6::Server &Instance::Get(void) { return mDhcp6Server; }
949 #endif
950 
951 #if OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE
Get(void)952 template <> inline NeighborDiscovery::Agent &Instance::Get(void) { return mNeighborDiscoveryAgent; }
953 #endif
954 
955 #if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
Get(void)956 template <> inline Utils::Slaac &Instance::Get(void) { return mSlaac; }
957 #endif
958 
959 #if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE
Get(void)960 template <> inline Utils::JamDetector &Instance::Get(void) { return mJamDetector; }
961 #endif
962 
963 #if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
Get(void)964 template <> inline Sntp::Client &Instance::Get(void) { return mSntpClient; }
965 #endif
966 
967 #if OPENTHREAD_FTD
Get(void)968 template <> inline ChildSupervisor &Instance::Get(void) { return mChildSupervisor; }
969 #endif
Get(void)970 template <> inline SupervisionListener &Instance::Get(void) { return mSupervisionListener; }
971 
972 #if OPENTHREAD_CONFIG_PING_SENDER_ENABLE
Get(void)973 template <> inline Utils::PingSender &Instance::Get(void) { return mPingSender; }
974 #endif
975 
976 #if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
Get(void)977 template <> inline Utils::ChannelMonitor &Instance::Get(void) { return mChannelMonitor; }
978 #endif
979 
980 #if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && \
981     (OPENTHREAD_FTD ||                          \
982      (OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE))
Get(void)983 template <> inline Utils::ChannelManager &Instance::Get(void) { return mChannelManager; }
984 #endif
985 
986 #if OPENTHREAD_CONFIG_MESH_DIAG_ENABLE && OPENTHREAD_FTD
Get(void)987 template <> inline Utils::MeshDiag &Instance::Get(void) { return mMeshDiag; }
988 #endif
989 
990 #if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE
Get(void)991 template <> inline Utils::HistoryTracker &Instance::Get(void) { return mHistoryTracker; }
992 #endif
993 
994 #if OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE
Get(void)995 template <> inline Utils::LinkMetricsManager &Instance::Get(void) { return mLinkMetricsManager; }
996 #endif
997 
998 #if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD
Get(void)999 template <> inline MeshCoP::DatasetUpdater &Instance::Get(void) { return mDatasetUpdater; }
1000 #endif
1001 
1002 #if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
Get(void)1003 template <> inline MeshCoP::BorderAgent &Instance::Get(void) { return mBorderAgent; }
1004 #endif
1005 
1006 #if OPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE
Get(void)1007 template <> inline AnnounceSender &Instance::Get(void) { return mAnnounceSender; }
1008 #endif
1009 
Get(void)1010 template <> inline MessagePool &Instance::Get(void) { return mMessagePool; }
1011 
1012 #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
1013 
Get(void)1014 template <> inline BackboneRouter::Leader &Instance::Get(void) { return mBackboneRouterLeader; }
1015 
1016 #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
Get(void)1017 template <> inline BackboneRouter::Local   &Instance::Get(void) { return mBackboneRouterLocal; }
Get(void)1018 template <> inline BackboneRouter::Manager &Instance::Get(void) { return mBackboneRouterManager; }
1019 
1020 #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
Get(void)1021 template <> inline BackboneRouter::MulticastListenersTable &Instance::Get(void)
1022 {
1023     return mBackboneRouterManager.GetMulticastListenersTable();
1024 }
1025 #endif
1026 
1027 #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE
Get(void)1028 template <> inline BackboneRouter::NdProxyTable &Instance::Get(void)
1029 {
1030     return mBackboneRouterManager.GetNdProxyTable();
1031 }
1032 #endif
1033 
Get(void)1034 template <> inline BackboneRouter::BackboneTmfAgent &Instance::Get(void)
1035 {
1036     return mBackboneRouterManager.GetBackboneTmfAgent();
1037 }
1038 #endif
1039 
1040 #if OPENTHREAD_CONFIG_MLR_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE)
Get(void)1041 template <> inline MlrManager &Instance::Get(void) { return mMlrManager; }
1042 #endif
1043 
1044 #if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
Get(void)1045 template <> inline DuaManager &Instance::Get(void) { return mDuaManager; }
1046 #endif
1047 
1048 #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
Get(void)1049 template <> inline LinkMetrics::Initiator &Instance::Get(void) { return mInitiator; }
1050 #endif
1051 
1052 #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
Get(void)1053 template <> inline LinkMetrics::Subject &Instance::Get(void) { return mSubject; }
1054 #endif
1055 
1056 #endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
1057 
1058 #if OPENTHREAD_CONFIG_OTNS_ENABLE
Get(void)1059 template <> inline Utils::Otns &Instance::Get(void) { return mOtns; }
1060 #endif
1061 
1062 #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
Get(void)1063 template <> inline BorderRouter::RoutingManager &Instance::Get(void) { return mRoutingManager; }
1064 
Get(void)1065 template <> inline BorderRouter::InfraIf &Instance::Get(void) { return mRoutingManager.mInfraIf; }
1066 #endif
1067 
1068 #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
Get(void)1069 template <> inline Nat64::Translator &Instance::Get(void) { return mNat64Translator; }
1070 #endif
1071 
1072 #if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
Get(void)1073 template <> inline Srp::Server &Instance::Get(void) { return mSrpServer; }
1074 #if OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
Get(void)1075 template <> inline Srp::AdvertisingProxy &Instance::Get(void) { return mSrpAdvertisingProxy; }
1076 #endif
1077 #endif // OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
1078 
1079 #if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
Get(void)1080 template <> inline Ble::BleSecure &Instance::Get(void) { return mApplicationBleSecure; }
1081 #endif
1082 
1083 #endif // OPENTHREAD_MTD || OPENTHREAD_FTD
1084 
1085 #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
Get(void)1086 template <> inline Mac::LinkRaw &Instance::Get(void) { return mLinkRaw; }
1087 
1088 #if OPENTHREAD_RADIO
Get(void)1089 template <> inline Mac::SubMac &Instance::Get(void) { return mLinkRaw.mSubMac; }
1090 #endif
1091 
1092 #endif // OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
1093 
Get(void)1094 template <> inline Tasklet::Scheduler &Instance::Get(void) { return mTaskletScheduler; }
1095 
Get(void)1096 template <> inline TimerMilli::Scheduler &Instance::Get(void) { return mTimerMilliScheduler; }
1097 
1098 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
Get(void)1099 template <> inline TimerMicro::Scheduler &Instance::Get(void) { return mTimerMicroScheduler; }
1100 #endif
1101 
1102 #if OPENTHREAD_ENABLE_VENDOR_EXTENSION
Get(void)1103 template <> inline Extension::ExtensionBase &Instance::Get(void) { return mExtension; }
1104 #endif
1105 
1106 #if OPENTHREAD_CONFIG_DIAG_ENABLE
Get(void)1107 template <> inline FactoryDiags::Diags &Instance::Get(void) { return mDiags; }
1108 #endif
1109 
1110 #if OPENTHREAD_CONFIG_POWER_CALIBRATION_ENABLE && OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE
Get(void)1111 template <> inline Utils::PowerCalibration &Instance::Get(void) { return mPowerCalibration; }
1112 #endif
1113 
1114 /**
1115  * @}
1116  *
1117  */
1118 
1119 } // namespace ot
1120 
1121 #endif // INSTANCE_HPP_
1122