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