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 || OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE)
675     Utils::ChannelManager mChannelManager;
676 #endif
677 
678 #if OPENTHREAD_CONFIG_MESH_DIAG_ENABLE && OPENTHREAD_FTD
679     Utils::MeshDiag mMeshDiag;
680 #endif
681 
682 #if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE
683     Utils::HistoryTracker mHistoryTracker;
684 #endif
685 
686 #if OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE
687     Utils::LinkMetricsManager mLinkMetricsManager;
688 #endif
689 
690 #if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD
691     MeshCoP::DatasetUpdater mDatasetUpdater;
692 #endif
693 
694 #if OPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE
695     AnnounceSender mAnnounceSender;
696 #endif
697 
698 #if OPENTHREAD_CONFIG_OTNS_ENABLE
699     Utils::Otns mOtns;
700 #endif
701 
702 #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
703     BorderRouter::RoutingManager mRoutingManager;
704 #endif
705 
706 #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
707     Nat64::Translator mNat64Translator;
708 #endif
709 
710 #endif // OPENTHREAD_MTD || OPENTHREAD_FTD
711 
712 #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
713     Mac::LinkRaw mLinkRaw;
714 #endif
715 
716 #if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
717     static LogLevel sLogLevel;
718 #endif
719 
720 #if OPENTHREAD_ENABLE_VENDOR_EXTENSION
721     Extension::ExtensionBase &mExtension;
722 #endif
723 
724 #if OPENTHREAD_CONFIG_DIAG_ENABLE
725     FactoryDiags::Diags mDiags;
726 #endif
727 #if OPENTHREAD_CONFIG_POWER_CALIBRATION_ENABLE && OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE
728     Utils::PowerCalibration mPowerCalibration;
729 #endif
730 
731     bool mIsInitialized;
732 
733 #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD)
734     static bool sDnsNameCompressionEnabled;
735 #endif
736 
737     uint32_t mId;
738 };
739 
740 DefineCoreType(otInstance, Instance);
741 DefineCoreType(otBufferInfo, Instance::BufferInfo);
742 
743 // Specializations of the `Get<Type>()` method.
744 
Get(void)745 template <> inline Instance &Instance::Get(void) { return *this; }
746 
Get(void)747 template <> inline Radio &Instance::Get(void) { return mRadio; }
748 
Get(void)749 template <> inline Radio::Callbacks &Instance::Get(void) { return mRadio.mCallbacks; }
750 
751 #if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD)
Get(void)752 template <> inline RadioStatistics &Instance::Get(void) { return mRadio.mRadioStatistics; }
753 #endif
754 
755 #if OPENTHREAD_CONFIG_UPTIME_ENABLE
Get(void)756 template <> inline Uptime &Instance::Get(void) { return mUptime; }
757 #endif
758 
759 #if OPENTHREAD_MTD || OPENTHREAD_FTD
Get(void)760 template <> inline Notifier &Instance::Get(void) { return mNotifier; }
761 
Get(void)762 template <> inline TimeTicker &Instance::Get(void) { return mTimeTicker; }
763 
Get(void)764 template <> inline Settings &Instance::Get(void) { return mSettings; }
765 
Get(void)766 template <> inline SettingsDriver &Instance::Get(void) { return mSettingsDriver; }
767 
Get(void)768 template <> inline MeshForwarder &Instance::Get(void) { return mMeshForwarder; }
769 
770 #if OPENTHREAD_CONFIG_MULTI_RADIO
Get(void)771 template <> inline RadioSelector &Instance::Get(void) { return mRadioSelector; }
772 #endif
773 
Get(void)774 template <> inline Mle::Mle &Instance::Get(void) { return mMleRouter; }
775 
776 #if OPENTHREAD_FTD
Get(void)777 template <> inline Mle::MleRouter &Instance::Get(void) { return mMleRouter; }
778 #endif
779 
Get(void)780 template <> inline Mle::DiscoverScanner &Instance::Get(void) { return mDiscoverScanner; }
781 
Get(void)782 template <> inline NeighborTable &Instance::Get(void) { return mMleRouter.mNeighborTable; }
783 
784 #if OPENTHREAD_FTD
Get(void)785 template <> inline ChildTable &Instance::Get(void) { return mMleRouter.mChildTable; }
786 
Get(void)787 template <> inline RouterTable &Instance::Get(void) { return mMleRouter.mRouterTable; }
788 #endif
789 
Get(void)790 template <> inline Ip6::Netif &Instance::Get(void) { return mThreadNetif; }
791 
Get(void)792 template <> inline ThreadNetif &Instance::Get(void) { return mThreadNetif; }
793 
Get(void)794 template <> inline Ip6::Ip6 &Instance::Get(void) { return mIp6; }
795 
Get(void)796 template <> inline Mac::Mac &Instance::Get(void) { return mMac; }
797 
Get(void)798 template <> inline Mac::SubMac &Instance::Get(void) { return mMac.mLinks.mSubMac; }
799 
800 #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
Get(void)801 template <> inline Trel::Link &Instance::Get(void) { return mMac.mLinks.mTrel; }
802 
Get(void)803 template <> inline Trel::Interface &Instance::Get(void) { return mMac.mLinks.mTrel.mInterface; }
804 #endif
805 
806 #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE
Get(void)807 template <> inline Mac::Filter &Instance::Get(void) { return mMac.mFilter; }
808 #endif
809 
Get(void)810 template <> inline Lowpan::Lowpan &Instance::Get(void) { return mLowpan; }
811 
Get(void)812 template <> inline KeyManager &Instance::Get(void) { return mKeyManager; }
813 
Get(void)814 template <> inline Ip6::Filter &Instance::Get(void) { return mIp6Filter; }
815 
Get(void)816 template <> inline AddressResolver &Instance::Get(void) { return mAddressResolver; }
817 
818 #if OPENTHREAD_FTD
819 
Get(void)820 template <> inline IndirectSender &Instance::Get(void) { return mMeshForwarder.mIndirectSender; }
821 
Get(void)822 template <> inline SourceMatchController &Instance::Get(void)
823 {
824     return mMeshForwarder.mIndirectSender.mSourceMatchController;
825 }
826 
Get(void)827 template <> inline DataPollHandler &Instance::Get(void) { return mMeshForwarder.mIndirectSender.mDataPollHandler; }
828 
829 #if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
Get(void)830 template <> inline CslTxScheduler &Instance::Get(void) { return mMeshForwarder.mIndirectSender.mCslTxScheduler; }
831 #endif
832 
Get(void)833 template <> inline MeshCoP::Leader &Instance::Get(void) { return mLeader; }
834 
Get(void)835 template <> inline MeshCoP::JoinerRouter &Instance::Get(void) { return mJoinerRouter; }
836 #endif // OPENTHREAD_FTD
837 
Get(void)838 template <> inline AnnounceBeginServer &Instance::Get(void) { return mAnnounceBegin; }
839 
Get(void)840 template <> inline DataPollSender &Instance::Get(void) { return mMeshForwarder.mDataPollSender; }
841 
Get(void)842 template <> inline EnergyScanServer &Instance::Get(void) { return mEnergyScan; }
843 
Get(void)844 template <> inline PanIdQueryServer &Instance::Get(void) { return mPanIdQuery; }
845 
846 #if OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
Get(void)847 template <> inline AnycastLocator &Instance::Get(void) { return mAnycastLocator; }
848 #endif
849 
850 #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
Get(void)851 template <> inline NetworkData::Local &Instance::Get(void) { return mNetworkDataLocal; }
852 #endif
853 
Get(void)854 template <> inline NetworkData::Leader &Instance::Get(void) { return mNetworkDataLeader; }
855 
856 #if OPENTHREAD_FTD || OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
Get(void)857 template <> inline NetworkData::Notifier &Instance::Get(void) { return mNetworkDataNotifier; }
858 #endif
859 
860 #if OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE
Get(void)861 template <> inline NetworkData::Publisher &Instance::Get(void) { return mNetworkDataPublisher; }
862 #endif
863 
Get(void)864 template <> inline NetworkData::Service::Manager &Instance::Get(void) { return mNetworkDataServiceManager; }
865 
866 #if OPENTHREAD_CONFIG_TCP_ENABLE
Get(void)867 template <> inline Ip6::Tcp &Instance::Get(void) { return mIp6.mTcp; }
868 #endif
869 
Get(void)870 template <> inline Ip6::Udp &Instance::Get(void) { return mIp6.mUdp; }
871 
Get(void)872 template <> inline Ip6::Icmp &Instance::Get(void) { return mIp6.mIcmp; }
873 
Get(void)874 template <> inline Ip6::Mpl &Instance::Get(void) { return mIp6.mMpl; }
875 
Get(void)876 template <> inline Tmf::Agent &Instance::Get(void) { return mTmfAgent; }
877 
878 #if OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE
Get(void)879 template <> inline Tmf::SecureAgent &Instance::Get(void) { return mTmfSecureAgent; }
880 #endif
881 
Get(void)882 template <> inline MeshCoP::ExtendedPanIdManager &Instance::Get(void) { return mExtendedPanIdManager; }
883 
Get(void)884 template <> inline MeshCoP::NetworkNameManager &Instance::Get(void) { return mNetworkNameManager; }
885 
Get(void)886 template <> inline MeshCoP::ActiveDatasetManager &Instance::Get(void) { return mActiveDataset; }
887 
Get(void)888 template <> inline MeshCoP::PendingDatasetManager &Instance::Get(void) { return mPendingDataset; }
889 
890 #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
Get(void)891 template <> inline TimeSync &Instance::Get(void) { return mTimeSync; }
892 #endif
893 
894 #if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
Get(void)895 template <> inline MeshCoP::Commissioner &Instance::Get(void) { return mCommissioner; }
896 
Get(void)897 template <> inline AnnounceBeginClient &Instance::Get(void) { return mCommissioner.GetAnnounceBeginClient(); }
898 
Get(void)899 template <> inline EnergyScanClient &Instance::Get(void) { return mCommissioner.GetEnergyScanClient(); }
900 
Get(void)901 template <> inline PanIdQueryClient &Instance::Get(void) { return mCommissioner.GetPanIdQueryClient(); }
902 #endif
903 
904 #if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
Get(void)905 template <> inline Dnssd &Instance::Get(void) { return mDnssd; }
906 #endif
907 
908 #if OPENTHREAD_CONFIG_JOINER_ENABLE
Get(void)909 template <> inline MeshCoP::Joiner &Instance::Get(void) { return mJoiner; }
910 #endif
911 
912 #if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
Get(void)913 template <> inline Dns::Client &Instance::Get(void) { return mDnsClient; }
914 #endif
915 
916 #if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
Get(void)917 template <> inline Srp::Client &Instance::Get(void) { return mSrpClient; }
918 #endif
919 
920 #if OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_ENABLE
Get(void)921 template <> inline Utils::SrpClientBuffers &Instance::Get(void) { return mSrpClientBuffers; }
922 #endif
923 
924 #if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE
Get(void)925 template <> inline Dns::ServiceDiscovery::Server &Instance::Get(void) { return mDnssdServer; }
926 #endif
927 
928 #if OPENTHREAD_CONFIG_DNS_DSO_ENABLE
Get(void)929 template <> inline Dns::Dso &Instance::Get(void) { return mDnsDso; }
930 #endif
931 
932 #if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
Get(void)933 template <> inline Dns::Multicast::Core &Instance::Get(void) { return mMdnsCore; }
934 #endif
935 
Get(void)936 template <> inline NetworkDiagnostic::Server &Instance::Get(void) { return mNetworkDiagnosticServer; }
937 
938 #if OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE
Get(void)939 template <> inline NetworkDiagnostic::Client &Instance::Get(void) { return mNetworkDiagnosticClient; }
940 #endif
941 
942 #if OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE
Get(void)943 template <> inline Dhcp6::Client &Instance::Get(void) { return mDhcp6Client; }
944 #endif
945 
946 #if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE
Get(void)947 template <> inline Dhcp6::Server &Instance::Get(void) { return mDhcp6Server; }
948 #endif
949 
950 #if OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE
Get(void)951 template <> inline NeighborDiscovery::Agent &Instance::Get(void) { return mNeighborDiscoveryAgent; }
952 #endif
953 
954 #if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
Get(void)955 template <> inline Utils::Slaac &Instance::Get(void) { return mSlaac; }
956 #endif
957 
958 #if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE
Get(void)959 template <> inline Utils::JamDetector &Instance::Get(void) { return mJamDetector; }
960 #endif
961 
962 #if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
Get(void)963 template <> inline Sntp::Client &Instance::Get(void) { return mSntpClient; }
964 #endif
965 
966 #if OPENTHREAD_FTD
Get(void)967 template <> inline ChildSupervisor &Instance::Get(void) { return mChildSupervisor; }
968 #endif
Get(void)969 template <> inline SupervisionListener &Instance::Get(void) { return mSupervisionListener; }
970 
971 #if OPENTHREAD_CONFIG_PING_SENDER_ENABLE
Get(void)972 template <> inline Utils::PingSender &Instance::Get(void) { return mPingSender; }
973 #endif
974 
975 #if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
Get(void)976 template <> inline Utils::ChannelMonitor &Instance::Get(void) { return mChannelMonitor; }
977 #endif
978 
979 #if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && \
980     (OPENTHREAD_FTD || OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE)
Get(void)981 template <> inline Utils::ChannelManager &Instance::Get(void) { return mChannelManager; }
982 #endif
983 
984 #if OPENTHREAD_CONFIG_MESH_DIAG_ENABLE && OPENTHREAD_FTD
Get(void)985 template <> inline Utils::MeshDiag &Instance::Get(void) { return mMeshDiag; }
986 #endif
987 
988 #if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE
Get(void)989 template <> inline Utils::HistoryTracker &Instance::Get(void) { return mHistoryTracker; }
990 #endif
991 
992 #if OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE
Get(void)993 template <> inline Utils::LinkMetricsManager &Instance::Get(void) { return mLinkMetricsManager; }
994 #endif
995 
996 #if (OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE || OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE) && OPENTHREAD_FTD
Get(void)997 template <> inline MeshCoP::DatasetUpdater &Instance::Get(void) { return mDatasetUpdater; }
998 #endif
999 
1000 #if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
Get(void)1001 template <> inline MeshCoP::BorderAgent &Instance::Get(void) { return mBorderAgent; }
1002 #endif
1003 
1004 #if OPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE
Get(void)1005 template <> inline AnnounceSender &Instance::Get(void) { return mAnnounceSender; }
1006 #endif
1007 
Get(void)1008 template <> inline MessagePool &Instance::Get(void) { return mMessagePool; }
1009 
1010 #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
1011 
Get(void)1012 template <> inline BackboneRouter::Leader &Instance::Get(void) { return mBackboneRouterLeader; }
1013 
1014 #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
Get(void)1015 template <> inline BackboneRouter::Local   &Instance::Get(void) { return mBackboneRouterLocal; }
Get(void)1016 template <> inline BackboneRouter::Manager &Instance::Get(void) { return mBackboneRouterManager; }
1017 
1018 #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
Get(void)1019 template <> inline BackboneRouter::MulticastListenersTable &Instance::Get(void)
1020 {
1021     return mBackboneRouterManager.GetMulticastListenersTable();
1022 }
1023 #endif
1024 
1025 #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE
Get(void)1026 template <> inline BackboneRouter::NdProxyTable &Instance::Get(void)
1027 {
1028     return mBackboneRouterManager.GetNdProxyTable();
1029 }
1030 #endif
1031 
Get(void)1032 template <> inline BackboneRouter::BackboneTmfAgent &Instance::Get(void)
1033 {
1034     return mBackboneRouterManager.GetBackboneTmfAgent();
1035 }
1036 #endif
1037 
1038 #if OPENTHREAD_CONFIG_MLR_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE)
Get(void)1039 template <> inline MlrManager &Instance::Get(void) { return mMlrManager; }
1040 #endif
1041 
1042 #if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
Get(void)1043 template <> inline DuaManager &Instance::Get(void) { return mDuaManager; }
1044 #endif
1045 
1046 #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
Get(void)1047 template <> inline LinkMetrics::Initiator &Instance::Get(void) { return mInitiator; }
1048 #endif
1049 
1050 #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
Get(void)1051 template <> inline LinkMetrics::Subject &Instance::Get(void) { return mSubject; }
1052 #endif
1053 
1054 #endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
1055 
1056 #if OPENTHREAD_CONFIG_OTNS_ENABLE
Get(void)1057 template <> inline Utils::Otns &Instance::Get(void) { return mOtns; }
1058 #endif
1059 
1060 #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
Get(void)1061 template <> inline BorderRouter::RoutingManager &Instance::Get(void) { return mRoutingManager; }
1062 
Get(void)1063 template <> inline BorderRouter::InfraIf &Instance::Get(void) { return mRoutingManager.mInfraIf; }
1064 #endif
1065 
1066 #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
Get(void)1067 template <> inline Nat64::Translator &Instance::Get(void) { return mNat64Translator; }
1068 #endif
1069 
1070 #if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
Get(void)1071 template <> inline Srp::Server &Instance::Get(void) { return mSrpServer; }
1072 #if OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
Get(void)1073 template <> inline Srp::AdvertisingProxy &Instance::Get(void) { return mSrpAdvertisingProxy; }
1074 #endif
1075 #endif // OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
1076 
1077 #if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
Get(void)1078 template <> inline Ble::BleSecure &Instance::Get(void) { return mApplicationBleSecure; }
1079 #endif
1080 
1081 #endif // OPENTHREAD_MTD || OPENTHREAD_FTD
1082 
1083 #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
Get(void)1084 template <> inline Mac::LinkRaw &Instance::Get(void) { return mLinkRaw; }
1085 
1086 #if OPENTHREAD_RADIO
Get(void)1087 template <> inline Mac::SubMac &Instance::Get(void) { return mLinkRaw.mSubMac; }
1088 #endif
1089 
1090 #endif // OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE
1091 
Get(void)1092 template <> inline Tasklet::Scheduler &Instance::Get(void) { return mTaskletScheduler; }
1093 
Get(void)1094 template <> inline TimerMilli::Scheduler &Instance::Get(void) { return mTimerMilliScheduler; }
1095 
1096 #if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
Get(void)1097 template <> inline TimerMicro::Scheduler &Instance::Get(void) { return mTimerMicroScheduler; }
1098 #endif
1099 
1100 #if OPENTHREAD_ENABLE_VENDOR_EXTENSION
Get(void)1101 template <> inline Extension::ExtensionBase &Instance::Get(void) { return mExtension; }
1102 #endif
1103 
1104 #if OPENTHREAD_CONFIG_DIAG_ENABLE
Get(void)1105 template <> inline FactoryDiags::Diags &Instance::Get(void) { return mDiags; }
1106 #endif
1107 
1108 #if OPENTHREAD_CONFIG_POWER_CALIBRATION_ENABLE && OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE
Get(void)1109 template <> inline Utils::PowerCalibration &Instance::Get(void) { return mPowerCalibration; }
1110 #endif
1111 
1112 /**
1113  * @}
1114  *
1115  */
1116 
1117 } // namespace ot
1118 
1119 #endif // INSTANCE_HPP_
1120