[core] pass/locate otInstance to all OpenThread classes

This commit changes the model for OpenThread classes so that all
classes track/locate their owning/parent `otInstance` object (i.e.,
the owning `otInstance` object reference is expected to be passed  as
an input argument in the object constructor). This replaces and
simplifies current model where some of classes track/locate the parent
`ThreadNetif`, `MeshForwarder`, or `Ip6` object references instead.
This helps harmonize the model across OpenThread source and also
simplify the `Locator` class implementation.
This commit is contained in:
Abtin Keshavarzian
2017-10-25 09:00:14 -07:00
committed by Jonathan Hui
parent 7b084eca71
commit 4cb17495b2
87 changed files with 358 additions and 501 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ otInstance::otInstance(void) :
mTimerMicroScheduler(*this), mTimerMicroScheduler(*this),
#endif #endif
mIp6(*this), mIp6(*this),
mThreadNetif(mIp6), mThreadNetif(*this),
#if OPENTHREAD_ENABLE_RAW_LINK_API #if OPENTHREAD_ENABLE_RAW_LINK_API
mLinkRaw(*this), mLinkRaw(*this),
#endif // OPENTHREAD_ENABLE_RAW_LINK_API #endif // OPENTHREAD_ENABLE_RAW_LINK_API
+8 -9
View File
@@ -48,15 +48,15 @@
namespace ot { namespace ot {
namespace Coap { namespace Coap {
CoapBase::CoapBase(ThreadNetif &aNetif, Timer::Handler aRetransmissionTimerHandler, CoapBase::CoapBase(otInstance &aInstance, Timer::Handler aRetransmissionTimerHandler,
Timer::Handler aResponsesQueueTimerHandler): Timer::Handler aResponsesQueueTimerHandler):
ThreadNetifLocator(aNetif), InstanceLocator(aInstance),
mSocket(aNetif.GetIp6().mUdp), mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
mRetransmissionTimer(aNetif.GetInstance(), aRetransmissionTimerHandler, this), mRetransmissionTimer(aInstance, aRetransmissionTimerHandler, this),
mResources(NULL), mResources(NULL),
mContext(NULL), mContext(NULL),
mInterceptor(NULL), mInterceptor(NULL),
mResponsesQueue(aNetif.GetInstance(), aResponsesQueueTimerHandler, this), mResponsesQueue(aInstance, aResponsesQueueTimerHandler, this),
mDefaultHandler(NULL), mDefaultHandler(NULL),
mDefaultHandlerContext(NULL) mDefaultHandlerContext(NULL)
{ {
@@ -911,8 +911,8 @@ uint32_t EnqueuedResponseHeader::GetRemainingTime(void) const
return remainingTime >= 0 ? static_cast<uint32_t>(remainingTime) : 0; return remainingTime >= 0 ? static_cast<uint32_t>(remainingTime) : 0;
} }
Coap::Coap(ThreadNetif &aNetif): Coap::Coap(otInstance &aInstance):
CoapBase(aNetif, &Coap::HandleRetransmissionTimer, &Coap::HandleResponsesQueueTimer) CoapBase(aInstance, &Coap::HandleRetransmissionTimer, &Coap::HandleResponsesQueueTimer)
{ {
} }
@@ -940,8 +940,7 @@ void Coap::HandleResponsesQueueTimer(Timer &aTimer)
#if OPENTHREAD_ENABLE_APPLICATION_COAP #if OPENTHREAD_ENABLE_APPLICATION_COAP
ApplicationCoap::ApplicationCoap(otInstance &aInstance): ApplicationCoap::ApplicationCoap(otInstance &aInstance):
CoapBase(aInstance.mThreadNetif, &ApplicationCoap::HandleRetransmissionTimer, CoapBase(aInstance, &ApplicationCoap::HandleRetransmissionTimer, &ApplicationCoap::HandleResponsesQueueTimer)
&ApplicationCoap::HandleResponsesQueueTimer)
{ {
} }
+6 -6
View File
@@ -430,7 +430,7 @@ private:
* This class implements the common base for CoAP client and server. * This class implements the common base for CoAP client and server.
* *
*/ */
class CoapBase: public ThreadNetifLocator class CoapBase: public InstanceLocator
{ {
friend class ResponsesQueue; friend class ResponsesQueue;
@@ -651,12 +651,12 @@ protected:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aNetif A reference to the Netif object. * @param[in] aInstance A reference to the OpenThread instance.
* @param[in] aRetransmissionTimerHandler A timer handler provided by sub-class for `mRetranmissionTimer`. * @param[in] aRetransmissionTimerHandler A timer handler provided by sub-class for `mRetranmissionTimer`.
* @param[in] aResponsesQueueTimerHandler A timer handler provided by sub-class for `mReponsesQueue` timer. * @param[in] aResponsesQueueTimerHandler A timer handler provided by sub-class for `mReponsesQueue` timer.
* *
*/ */
CoapBase(ThreadNetif &aNetif, Timer::Handler aRetransmissionTimerHandler, CoapBase(otInstance &aInstance, Timer::Handler aRetransmissionTimerHandler,
Timer::Handler aResponsesQueueTimerHandler); Timer::Handler aResponsesQueueTimerHandler);
/** /**
@@ -744,10 +744,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aNetif A reference to the Netif object. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
Coap(ThreadNetif &aNetif); Coap(otInstance &aInstance);
private: private:
static Coap &GetOwner(const Context &aContext); static Coap &GetOwner(const Context &aContext);
@@ -767,7 +767,7 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aNetif A reference to the otInstance * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
ApplicationCoap(otInstance &aInstance); ApplicationCoap(otInstance &aInstance);
+3 -3
View File
@@ -45,14 +45,14 @@
namespace ot { namespace ot {
namespace Coap { namespace Coap {
CoapSecure::CoapSecure(ThreadNetif &aNetif): CoapSecure::CoapSecure(otInstance &aInstance):
CoapBase(aNetif, &CoapSecure::HandleRetransmissionTimer, &CoapSecure::HandleResponsesQueueTimer), CoapBase(aInstance, &CoapSecure::HandleRetransmissionTimer, &CoapSecure::HandleResponsesQueueTimer),
mConnectedCallback(NULL), mConnectedCallback(NULL),
mConnectedContext(NULL), mConnectedContext(NULL),
mTransportCallback(NULL), mTransportCallback(NULL),
mTransportContext(NULL), mTransportContext(NULL),
mTransmitMessage(NULL), mTransmitMessage(NULL),
mTransmitTask(aNetif.GetInstance(), &CoapSecure::HandleUdpTransmit, this) mTransmitTask(aInstance, &CoapSecure::HandleUdpTransmit, this)
{ {
} }
+2 -2
View File
@@ -70,10 +70,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aNetif A reference to the network interface that the secure CoAP agent is bound to. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
CoapSecure(ThreadNetif &aNetif); CoapSecure(otInstance &aInstance);
/** /**
* This method starts the secure CoAP agent. * This method starts the secure CoAP agent.
+4 -13
View File
@@ -40,23 +40,14 @@
namespace ot { namespace ot {
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES Ip6::Ip6 &InstanceLocator::GetIp6(void) const
otInstance &ThreadNetifLocator::GetInstance(void) const
{ {
return *otInstanceFromThreadNetif(&GetNetif()); return GetInstance().mIp6;
} }
otInstance &MeshForwarderLocator::GetInstance(void) const ThreadNetif &InstanceLocator::GetNetif(void) const
{ {
return *otInstanceFromThreadNetif(&GetMeshForwarder().GetNetif()); return GetInstance().mThreadNetif;
} }
otInstance &Ip6Locator::GetInstance(void) const
{
return *otInstanceFromIp6(&GetIp6());
}
#endif // #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
} // namespace ot } // namespace ot
+32 -156
View File
@@ -43,175 +43,24 @@
namespace ot { namespace ot {
class ThreadNetif; class ThreadNetif;
class MeshForwarder;
class TaskletScheduler;
namespace Ip6 { class Ip6; } namespace Ip6 { class Ip6; }
/** /**
* @addtogroup core-locator * @addtogroup core-locator
* *
* @brief * @brief
* This module includes definitions for locator base class for OpenThread objects. * This module includes definitions for OpenThread instance locator.
* *
* @{ * @{
* *
*/ */
/**
* This template class implements the base locator for OpenThread objects.
*
*/
template <typename Type>
class Locator
{
protected:
/**
* This constructor initializes the locator.
*
* @param[in] aObject A reference to the object.
*
*/
Locator(Type &aObject)
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
: mLocatorObject(aObject)
#endif
{
OT_UNUSED_VARIABLE(aObject);
}
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
Type &mLocatorObject;
#endif
};
/** /**
* This class implements a locator for ThreadNetif object. * This class implements locator for otInstance object.
* *
*/ */
class ThreadNetifLocator: private Locator<ThreadNetif> class InstanceLocator
{
public:
/**
* This method returns a reference to the thread network interface.
*
* @returns A reference to the thread network interface.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
ThreadNetif &GetNetif(void) const { return mLocatorObject; }
#else
ThreadNetif &GetNetif(void) const { return otGetThreadNetif(); }
#endif
/**
* This method returns the reference to the parent otInstance structure.
*
* @returns A reference to the parent otInstance structure.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance &GetInstance(void) const;
#else
otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif
protected:
/**
* This constructor initializes the object.
*
* @param[in] aThreadNetif A reference to the thread network interface.
*
*/
ThreadNetifLocator(ThreadNetif &aThreadNetif): Locator(aThreadNetif) { }
};
/**
* This class implements a locator for MeshForwarder object.
*
*/
class MeshForwarderLocator: private Locator<MeshForwarder>
{
public:
/**
* This method returns a reference to the MeshForwarder.
*
* @returns A reference to the MeshForwarder.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
MeshForwarder &GetMeshForwarder(void) const { return mLocatorObject; }
#else
MeshForwarder &GetMeshForwarder(void) const { return otGetMeshForwarder(); }
#endif
/**
* This method returns the reference to the parent otInstance structure.
*
* @returns A reference to the parent otInstance structure.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance &GetInstance(void) const;
#else
otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif
protected:
/**
* This constructor initializes the object.
*
* @param[in] aMeshForwarder A reference to the MeshForwarder.
*
*/
MeshForwarderLocator(MeshForwarder &aMeshForwarder): Locator(aMeshForwarder) { }
};
/**
* This class implements a locator for Ip6 object.
*
*/
class Ip6Locator: private Locator<Ip6::Ip6>
{
public:
/**
* This method returns a reference to the Ip6.
*
* @returns A reference to the Ip6.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
Ip6::Ip6 &GetIp6(void) const { return mLocatorObject; }
#else
Ip6::Ip6 &GetIp6(void) const { return otGetIp6(); }
#endif
/**
* This method returns the reference to the parent otInstance structure.
*
* @returns A reference to the parent otInstance structure.
*
*/
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance &GetInstance(void) const;
#else
otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif
protected:
/**
* This constructor initializes the object.
*
* @param[in] aIp6 A reference to the Ip6.
*
*/
Ip6Locator(Ip6::Ip6 &aIp6): Locator(aIp6) { }
};
/**
* This class implements locator for otInstance object
*
*/
class InstanceLocator: private Locator<otInstance>
{ {
public: public:
/** /**
@@ -221,11 +70,27 @@ public:
* *
*/ */
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
otInstance &GetInstance(void) const { return mLocatorObject; } otInstance &GetInstance(void) const { return mInstance; }
#else #else
otInstance &GetInstance(void) const { return *otGetInstance(); } otInstance &GetInstance(void) const { return *otGetInstance(); }
#endif #endif
/**
* This method returns a reference to the Ip6.
*
* @returns A reference to the Ip6.
*
*/
Ip6::Ip6 &GetIp6(void) const;
/**
* This method returns a reference to the thread network interface.
*
* @returns A reference to the thread network interface.
*
*/
ThreadNetif &GetNetif(void) const;
protected: protected:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
@@ -233,7 +98,18 @@ protected:
* @param[in] aInstance A pointer to the otInstance. * @param[in] aInstance A pointer to the otInstance.
* *
*/ */
InstanceLocator(otInstance &aInstance): Locator(aInstance) { } InstanceLocator(otInstance &aInstance)
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
: mInstance(aInstance)
#endif
{
OT_UNUSED_VARIABLE(aInstance);
}
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
private:
otInstance &mInstance;
#endif
}; };
/** /**
+7 -7
View File
@@ -136,11 +136,11 @@ void Mac::StartCsmaBackoff(void)
} }
} }
Mac::Mac(ThreadNetif &aThreadNetif): Mac::Mac(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mMacTimer(aThreadNetif.GetInstance(), &Mac::HandleMacTimer, this), mMacTimer(aInstance, &Mac::HandleMacTimer, this),
mBackoffTimer(aThreadNetif.GetInstance(), &Mac::HandleBeginTransmit, this), mBackoffTimer(aInstance, &Mac::HandleBeginTransmit, this),
mReceiveTimer(aThreadNetif.GetInstance(), &Mac::HandleReceiveTimer, this), mReceiveTimer(aInstance, &Mac::HandleReceiveTimer, this),
mShortAddress(kShortAddrInvalid), mShortAddress(kShortAddrInvalid),
mPanId(kPanIdBroadcast), mPanId(kPanIdBroadcast),
mChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL), mChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL),
@@ -170,13 +170,13 @@ Mac::Mac(ThreadNetif &aThreadNetif):
mEnergyScanCurrentMaxRssi(kInvalidRssiValue), mEnergyScanCurrentMaxRssi(kInvalidRssiValue),
mScanContext(NULL), mScanContext(NULL),
mActiveScanHandler(NULL), // Initialize `mActiveScanHandler` and `mEnergyScanHandler` union mActiveScanHandler(NULL), // Initialize `mActiveScanHandler` and `mEnergyScanHandler` union
mEnergyScanSampleRssiTask(aThreadNetif.GetInstance(), &Mac::HandleEnergyScanSampleRssi, this), mEnergyScanSampleRssiTask(aInstance, &Mac::HandleEnergyScanSampleRssi, this),
mPcapCallback(NULL), mPcapCallback(NULL),
mPcapCallbackContext(NULL), mPcapCallbackContext(NULL),
#if OPENTHREAD_ENABLE_MAC_FILTER #if OPENTHREAD_ENABLE_MAC_FILTER
mFilter(), mFilter(),
#endif // OPENTHREAD_ENABLE_MAC_FILTER #endif // OPENTHREAD_ENABLE_MAC_FILTER
mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(&aThreadNetif.GetInstance()))), mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(&aInstance))),
mKeyIdMode2FrameCounter(0) mKeyIdMode2FrameCounter(0)
{ {
GenerateExtAddress(&mExtAddress); GenerateExtAddress(&mExtAddress);
+3 -3
View File
@@ -211,16 +211,16 @@ private:
* This class implements the IEEE 802.15.4 MAC. * This class implements the IEEE 802.15.4 MAC.
* *
*/ */
class Mac: public ThreadNetifLocator class Mac: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the MAC object. * This constructor initializes the MAC object.
* *
* @param[in] aThreadNetif A reference to the network interface using this MAC. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit Mac(ThreadNetif &aThreadNetif); explicit Mac(otInstance &aInstance);
/** /**
* This function pointer is called on receiving an IEEE 802.15.4 Beacon during an Active Scan. * This function pointer is called on receiving an IEEE 802.15.4 Beacon during an Active Scan.
+2 -2
View File
@@ -51,8 +51,8 @@
namespace ot { namespace ot {
AnnounceBeginClient::AnnounceBeginClient(ThreadNetif &aThreadNetif): AnnounceBeginClient::AnnounceBeginClient(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif) InstanceLocator(aInstance)
{ {
} }
+2 -2
View File
@@ -47,14 +47,14 @@ namespace ot {
* This class implements handling Announce Begin Requests. * This class implements handling Announce Begin Requests.
* *
*/ */
class AnnounceBeginClient: public ThreadNetifLocator class AnnounceBeginClient: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
AnnounceBeginClient(ThreadNetif &aThreadNetif); AnnounceBeginClient(otInstance &aInstance);
/** /**
* This method sends a Announce Begin message. * This method sends a Announce Begin message.
+7 -7
View File
@@ -60,16 +60,16 @@ using ot::Encoding::BigEndian::HostSwap64;
namespace ot { namespace ot {
namespace MeshCoP { namespace MeshCoP {
Commissioner::Commissioner(ThreadNetif &aThreadNetif): Commissioner::Commissioner(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mAnnounceBegin(aThreadNetif), mAnnounceBegin(aInstance),
mEnergyScan(aThreadNetif), mEnergyScan(aInstance),
mPanIdQuery(aThreadNetif), mPanIdQuery(aInstance),
mState(OT_COMMISSIONER_STATE_DISABLED), mState(OT_COMMISSIONER_STATE_DISABLED),
mJoinerPort(0), mJoinerPort(0),
mJoinerRloc(0), mJoinerRloc(0),
mJoinerExpirationTimer(aThreadNetif.GetInstance(), HandleJoinerExpirationTimer, this), mJoinerExpirationTimer(aInstance, HandleJoinerExpirationTimer, this),
mTimer(aThreadNetif.GetInstance(), HandleTimer, this), mTimer(aInstance, HandleTimer, this),
mSessionId(0), mSessionId(0),
mTransmitAttempts(0), mTransmitAttempts(0),
mRelayReceive(OT_URI_PATH_RELAY_RX, &Commissioner::HandleRelayReceive, this), mRelayReceive(OT_URI_PATH_RELAY_RX, &Commissioner::HandleRelayReceive, this),
+3 -3
View File
@@ -56,16 +56,16 @@ class ThreadNetif;
namespace MeshCoP { namespace MeshCoP {
class Commissioner: public ThreadNetifLocator class Commissioner: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the Commissioner object. * This constructor initializes the Commissioner object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
Commissioner(ThreadNetif &aThreadNetif); Commissioner(otInstance &aInstance);
/** /**
* This method starts the Commissioner service. * This method starts the Commissioner service.
+11 -11
View File
@@ -59,12 +59,12 @@
namespace ot { namespace ot {
namespace MeshCoP { namespace MeshCoP {
DatasetManager::DatasetManager(ThreadNetif &aThreadNetif, const Tlv::Type aType, const char *aUriSet, DatasetManager::DatasetManager(otInstance &aInstance, const Tlv::Type aType, const char *aUriSet,
const char *aUriGet, Timer::Handler aTimerHandler): const char *aUriGet, Timer::Handler aTimerHandler):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mLocal(aThreadNetif.GetInstance(), aType), mLocal(aInstance, aType),
mNetwork(aType), mNetwork(aType),
mTimer(aThreadNetif.GetInstance(), aTimerHandler, this), mTimer(aInstance, aTimerHandler, this),
mUriSet(aUriSet), mUriSet(aUriSet),
mUriGet(aUriGet) mUriGet(aUriGet)
{ {
@@ -959,12 +959,12 @@ static ActiveDatasetBase &GetActiveDatasetOwner(const Context &aContext)
return activeDataset; return activeDataset;
} }
ActiveDatasetBase::ActiveDatasetBase(ThreadNetif &aThreadNetif): ActiveDatasetBase::ActiveDatasetBase(otInstance &aInstance):
DatasetManager(aThreadNetif, Tlv::kActiveTimestamp, OT_URI_PATH_ACTIVE_SET, OT_URI_PATH_ACTIVE_GET, DatasetManager(aInstance, Tlv::kActiveTimestamp, OT_URI_PATH_ACTIVE_SET, OT_URI_PATH_ACTIVE_GET,
&ActiveDatasetBase::HandleTimer), &ActiveDatasetBase::HandleTimer),
mResourceGet(OT_URI_PATH_ACTIVE_GET, &ActiveDatasetBase::HandleGet, this) mResourceGet(OT_URI_PATH_ACTIVE_GET, &ActiveDatasetBase::HandleGet, this)
{ {
aThreadNetif.GetCoap().AddResource(mResourceGet); GetNetif().GetCoap().AddResource(mResourceGet);
} }
otError ActiveDatasetBase::Restore(void) otError ActiveDatasetBase::Restore(void)
@@ -1057,13 +1057,13 @@ static PendingDatasetBase &GetPendingDatasetOwner(const Context &aContext)
return pendingDataset; return pendingDataset;
} }
PendingDatasetBase::PendingDatasetBase(ThreadNetif &aThreadNetif): PendingDatasetBase::PendingDatasetBase(otInstance &aInstance):
DatasetManager(aThreadNetif, Tlv::kPendingTimestamp, OT_URI_PATH_PENDING_SET, OT_URI_PATH_PENDING_GET, DatasetManager(aInstance, Tlv::kPendingTimestamp, OT_URI_PATH_PENDING_SET, OT_URI_PATH_PENDING_GET,
&PendingDatasetBase::HandleTimer), &PendingDatasetBase::HandleTimer),
mDelayTimer(aThreadNetif.GetInstance(), &PendingDatasetBase::HandleDelayTimer, this), mDelayTimer(aInstance, &PendingDatasetBase::HandleDelayTimer, this),
mResourceGet(OT_URI_PATH_PENDING_GET, &PendingDatasetBase::HandleGet, this) mResourceGet(OT_URI_PATH_PENDING_GET, &PendingDatasetBase::HandleGet, this)
{ {
aThreadNetif.GetCoap().AddResource(mResourceGet); GetNetif().GetCoap().AddResource(mResourceGet);
} }
otError PendingDatasetBase::Restore(void) otError PendingDatasetBase::Restore(void)
+6 -6
View File
@@ -54,7 +54,7 @@ class ThreadNetif;
namespace MeshCoP { namespace MeshCoP {
class DatasetManager: public ThreadNetifLocator class DatasetManager: public InstanceLocator
{ {
public: public:
/** /**
@@ -125,14 +125,14 @@ protected:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* @param[in] aType Identifies Active or Pending Operational Dataset. * @param[in] aType Identifies Active or Pending Operational Dataset.
* @param[in] aUriSet The URI-PATH for setting the Operational Dataset. * @param[in] aUriSet The URI-PATH for setting the Operational Dataset.
* @param[in] aUriGet The URI-PATH for getting the Operational Dataset. * @param[in] aUriGet The URI-PATH for getting the Operational Dataset.
* @param[in] aTimerHandler The registration timer handler. * @param[in] aTimerHandler The registration timer handler.
* *
*/ */
DatasetManager(ThreadNetif &aThreadNetif, const Tlv::Type aType, const char *aUriSet, const char *aUriGet, DatasetManager(otInstance &aInstance, const Tlv::Type aType, const char *aUriSet, const char *aUriGet,
TimerMilli::Handler aTimerHandler); TimerMilli::Handler aTimerHandler);
/** /**
@@ -279,10 +279,10 @@ public:
/** /**
* Constructor. * Constructor.
* *
* @param[in] aThreadNetif The Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
ActiveDatasetBase(ThreadNetif &aThreadNetif); ActiveDatasetBase(otInstance &aInstance);
/** /**
* This method restores the Active Operational Dataset from non-volatile memory. * This method restores the Active Operational Dataset from non-volatile memory.
@@ -364,7 +364,7 @@ public:
* @param[in] The Thread network interface. * @param[in] The Thread network interface.
* *
*/ */
PendingDatasetBase(ThreadNetif &aThreadNetif); PendingDatasetBase(otInstance &aInstance);
/** /**
* This method restores the Operational Dataset from non-volatile memory. * This method restores the Operational Dataset from non-volatile memory.
+4 -4
View File
@@ -60,8 +60,8 @@
namespace ot { namespace ot {
namespace MeshCoP { namespace MeshCoP {
ActiveDataset::ActiveDataset(ThreadNetif &aThreadNetif): ActiveDataset::ActiveDataset(otInstance &aInstance):
ActiveDatasetBase(aThreadNetif), ActiveDatasetBase(aInstance),
mResourceSet(OT_URI_PATH_ACTIVE_SET, &ActiveDataset::HandleSet, this) mResourceSet(OT_URI_PATH_ACTIVE_SET, &ActiveDataset::HandleSet, this)
{ {
} }
@@ -207,8 +207,8 @@ exit:
return; return;
} }
PendingDataset::PendingDataset(ThreadNetif &aThreadNetif): PendingDataset::PendingDataset(otInstance &aInstance):
PendingDatasetBase(aThreadNetif), PendingDatasetBase(aInstance),
mResourceSet(OT_URI_PATH_PENDING_SET, &PendingDataset::HandleSet, this) mResourceSet(OT_URI_PATH_PENDING_SET, &PendingDataset::HandleSet, this)
{ {
} }
+2 -2
View File
@@ -53,7 +53,7 @@ namespace MeshCoP {
class ActiveDataset: public ActiveDatasetBase class ActiveDataset: public ActiveDatasetBase
{ {
public: public:
ActiveDataset(ThreadNetif &aThreadNetif); ActiveDataset(otInstance &aInstance);
otError GenerateLocal(void); otError GenerateLocal(void);
@@ -74,7 +74,7 @@ private:
class PendingDataset: public PendingDatasetBase class PendingDataset: public PendingDatasetBase
{ {
public: public:
PendingDataset(ThreadNetif &aThreadNetif); PendingDataset(otInstance &aInstance);
void StartLeader(void); void StartLeader(void);
+2 -2
View File
@@ -48,7 +48,7 @@ namespace MeshCoP {
class ActiveDataset: public ActiveDatasetBase class ActiveDataset: public ActiveDatasetBase
{ {
public: public:
ActiveDataset(ThreadNetif &aThreadNetif) : ActiveDatasetBase(aThreadNetif) { } ActiveDataset(otInstance &aInstance) : ActiveDatasetBase(aInstance) { }
otError GenerateLocal(void) { return OT_ERROR_NOT_IMPLEMENTED; } otError GenerateLocal(void) { return OT_ERROR_NOT_IMPLEMENTED; }
}; };
@@ -56,7 +56,7 @@ public:
class PendingDataset: public PendingDatasetBase class PendingDataset: public PendingDatasetBase
{ {
public: public:
PendingDataset(ThreadNetif &aThreadNetif) : PendingDatasetBase(aThreadNetif) { } PendingDataset(otInstance &aInstance) : PendingDatasetBase(aInstance) { }
}; };
} // namespace MeshCoP } // namespace MeshCoP
+3 -3
View File
@@ -52,11 +52,11 @@
namespace ot { namespace ot {
namespace MeshCoP { namespace MeshCoP {
Dtls::Dtls(ThreadNetif &aNetif): Dtls::Dtls(otInstance &aInstance):
ThreadNetifLocator(aNetif), InstanceLocator(aInstance),
mPskLength(0), mPskLength(0),
mStarted(false), mStarted(false),
mTimer(aNetif.GetInstance(), &Dtls::HandleTimer, this), mTimer(aInstance, &Dtls::HandleTimer, this),
mTimerIntermediate(0), mTimerIntermediate(0),
mTimerSet(false), mTimerSet(false),
mReceiveMessage(NULL), mReceiveMessage(NULL),
+2 -2
View File
@@ -57,7 +57,7 @@ class ThreadNetif;
namespace MeshCoP { namespace MeshCoP {
class Dtls: public ThreadNetifLocator class Dtls: public InstanceLocator
{ {
public: public:
enum enum
@@ -72,7 +72,7 @@ public:
* @param[in] aNetif A reference to the Thread network interface. * @param[in] aNetif A reference to the Thread network interface.
* *
*/ */
Dtls(ThreadNetif &aNetif); Dtls(otInstance &aInstance);
/** /**
* This function pointer is called when a connection is established or torn down. * This function pointer is called when a connection is established or torn down.
+3 -3
View File
@@ -54,13 +54,13 @@ using ot::Encoding::BigEndian::HostSwap32;
namespace ot { namespace ot {
EnergyScanClient::EnergyScanClient(ThreadNetif &aThreadNetif) : EnergyScanClient::EnergyScanClient(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mEnergyScan(OT_URI_PATH_ENERGY_REPORT, &EnergyScanClient::HandleReport, this) mEnergyScan(OT_URI_PATH_ENERGY_REPORT, &EnergyScanClient::HandleReport, this)
{ {
mContext = NULL; mContext = NULL;
mCallback = NULL; mCallback = NULL;
aThreadNetif.GetCoap().AddResource(mEnergyScan); GetNetif().GetCoap().AddResource(mEnergyScan);
} }
otError EnergyScanClient::SendQuery(uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod, otError EnergyScanClient::SendQuery(uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod,
+2 -2
View File
@@ -51,14 +51,14 @@ class ThreadNetif;
* This class implements handling PANID Query Requests. * This class implements handling PANID Query Requests.
* *
*/ */
class EnergyScanClient: public ThreadNetifLocator class EnergyScanClient: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
EnergyScanClient(ThreadNetif &aThreadNetif); EnergyScanClient(otInstance &aInstance);
/** /**
* This method sends an Energy Scan Query message. * This method sends an Energy Scan Query message.
+4 -4
View File
@@ -58,8 +58,8 @@ using ot::Encoding::BigEndian::HostSwap64;
namespace ot { namespace ot {
namespace MeshCoP { namespace MeshCoP {
Joiner::Joiner(ThreadNetif &aNetif): Joiner::Joiner(otInstance &aInstance):
ThreadNetifLocator(aNetif), InstanceLocator(aInstance),
mState(OT_JOINER_STATE_IDLE), mState(OT_JOINER_STATE_IDLE),
mCallback(NULL), mCallback(NULL),
mContext(NULL), mContext(NULL),
@@ -69,11 +69,11 @@ Joiner::Joiner(ThreadNetif &aNetif):
mVendorModel(NULL), mVendorModel(NULL),
mVendorSwVersion(NULL), mVendorSwVersion(NULL),
mVendorData(NULL), mVendorData(NULL),
mTimer(aNetif.GetInstance(), &Joiner::HandleTimer, this), mTimer(aInstance, &Joiner::HandleTimer, this),
mJoinerEntrust(OT_URI_PATH_JOINER_ENTRUST, &Joiner::HandleJoinerEntrust, this) mJoinerEntrust(OT_URI_PATH_JOINER_ENTRUST, &Joiner::HandleJoinerEntrust, this)
{ {
memset(mJoinerRouters, 0, sizeof(mJoinerRouters)); memset(mJoinerRouters, 0, sizeof(mJoinerRouters));
aNetif.GetCoap().AddResource(mJoinerEntrust); GetNetif().GetCoap().AddResource(mJoinerEntrust);
} }
otError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl, otError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl,
+3 -3
View File
@@ -54,16 +54,16 @@ class ThreadNetif;
namespace MeshCoP { namespace MeshCoP {
class Joiner: public ThreadNetifLocator class Joiner: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the Joiner object. * This constructor initializes the Joiner object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
Joiner(ThreadNetif &aThreadNetif); Joiner(otInstance &aInstance);
/** /**
* This method starts the Joiner service. * This method starts the Joiner service.
+6 -6
View File
@@ -55,19 +55,19 @@ using ot::Encoding::BigEndian::HostSwap64;
namespace ot { namespace ot {
namespace MeshCoP { namespace MeshCoP {
JoinerRouter::JoinerRouter(ThreadNetif &aNetif): JoinerRouter::JoinerRouter(otInstance &aInstance):
ThreadNetifLocator(aNetif), InstanceLocator(aInstance),
mSocket(aNetif.GetIp6().mUdp), mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
mRelayTransmit(OT_URI_PATH_RELAY_TX, &JoinerRouter::HandleRelayTransmit, this), mRelayTransmit(OT_URI_PATH_RELAY_TX, &JoinerRouter::HandleRelayTransmit, this),
mTimer(aNetif.GetInstance(), &JoinerRouter::HandleTimer, this), mTimer(aInstance, &JoinerRouter::HandleTimer, this),
mJoinerUdpPort(0), mJoinerUdpPort(0),
mIsJoinerPortConfigured(false), mIsJoinerPortConfigured(false),
mExpectJoinEntRsp(false) mExpectJoinEntRsp(false)
{ {
mSocket.GetSockName().mPort = OPENTHREAD_CONFIG_JOINER_UDP_PORT; mSocket.GetSockName().mPort = OPENTHREAD_CONFIG_JOINER_UDP_PORT;
aNetif.GetCoap().AddResource(mRelayTransmit); GetNetif().GetCoap().AddResource(mRelayTransmit);
mNetifCallback.Set(HandleNetifStateChanged, this); mNetifCallback.Set(HandleNetifStateChanged, this);
aNetif.RegisterCallback(mNetifCallback); GetNetif().RegisterCallback(mNetifCallback);
} }
void JoinerRouter::HandleNetifStateChanged(uint32_t aFlags, void *aContext) void JoinerRouter::HandleNetifStateChanged(uint32_t aFlags, void *aContext)
+3 -3
View File
@@ -54,16 +54,16 @@ class ThreadNetif;
namespace MeshCoP { namespace MeshCoP {
class JoinerRouter: public ThreadNetifLocator class JoinerRouter: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the Joiner Router object. * This constructor initializes the Joiner Router object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
JoinerRouter(ThreadNetif &aNetif); JoinerRouter(otInstance &aInstance);
/** /**
* This method returns the Joiner UDP Port. * This method returns the Joiner UDP Port.
+5 -5
View File
@@ -54,16 +54,16 @@
namespace ot { namespace ot {
namespace MeshCoP { namespace MeshCoP {
Leader::Leader(ThreadNetif &aThreadNetif): Leader::Leader(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mPetition(OT_URI_PATH_LEADER_PETITION, Leader::HandlePetition, this), mPetition(OT_URI_PATH_LEADER_PETITION, Leader::HandlePetition, this),
mKeepAlive(OT_URI_PATH_LEADER_KEEP_ALIVE, Leader::HandleKeepAlive, this), mKeepAlive(OT_URI_PATH_LEADER_KEEP_ALIVE, Leader::HandleKeepAlive, this),
mTimer(aThreadNetif.GetInstance(), HandleTimer, this), mTimer(aInstance, HandleTimer, this),
mDelayTimerMinimal(DelayTimerTlv::kDelayTimerMinimal), mDelayTimerMinimal(DelayTimerTlv::kDelayTimerMinimal),
mSessionId(0xffff) mSessionId(0xffff)
{ {
aThreadNetif.GetCoap().AddResource(mPetition); GetNetif().GetCoap().AddResource(mPetition);
aThreadNetif.GetCoap().AddResource(mKeepAlive); GetNetif().GetCoap().AddResource(mKeepAlive);
} }
void Leader::HandlePetition(void *aContext, otCoapHeader *aHeader, otMessage *aMessage, void Leader::HandlePetition(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
+3 -3
View File
@@ -61,16 +61,16 @@ public:
SteeringDataTlv mSteeringData; SteeringDataTlv mSteeringData;
} OT_TOOL_PACKED_END; } OT_TOOL_PACKED_END;
class Leader: public ThreadNetifLocator class Leader: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the Leader object. * This constructor initializes the Leader object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
Leader(ThreadNetif &aThreadNetif); Leader(otInstance &aInstance);
/** /**
* This method sends a MGMT_DATASET_CHANGED message to commissioner. * This method sends a MGMT_DATASET_CHANGED message to commissioner.
+3 -3
View File
@@ -50,13 +50,13 @@
namespace ot { namespace ot {
PanIdQueryClient::PanIdQueryClient(ThreadNetif &aThreadNetif) : PanIdQueryClient::PanIdQueryClient(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mCallback(NULL), mCallback(NULL),
mContext(NULL), mContext(NULL),
mPanIdQuery(OT_URI_PATH_PANID_CONFLICT, &PanIdQueryClient::HandleConflict, this) mPanIdQuery(OT_URI_PATH_PANID_CONFLICT, &PanIdQueryClient::HandleConflict, this)
{ {
aThreadNetif.GetCoap().AddResource(mPanIdQuery); GetNetif().GetCoap().AddResource(mPanIdQuery);
} }
otError PanIdQueryClient::SendQuery(uint16_t aPanId, uint32_t aChannelMask, const Ip6::Address &aAddress, otError PanIdQueryClient::SendQuery(uint16_t aPanId, uint32_t aChannelMask, const Ip6::Address &aAddress,
+2 -2
View File
@@ -51,14 +51,14 @@ class ThreadNetif;
* This class implements handling PANID Query Requests. * This class implements handling PANID Query Requests.
* *
*/ */
class PanIdQueryClient: public ThreadNetifLocator class PanIdQueryClient: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
PanIdQueryClient(ThreadNetif &aThreadNetif); PanIdQueryClient(otInstance &aInstance);
/** /**
* This method sends a PAN ID Query message. * This method sends a PAN ID Query message.
+5 -4
View File
@@ -38,6 +38,7 @@
#include <openthread/types.h> #include <openthread/types.h>
#include <openthread/platform/random.h> #include <openthread/platform/random.h>
#include "openthread-instance.h"
#include "common/code_utils.hpp" #include "common/code_utils.hpp"
#include "common/encoding.hpp" #include "common/encoding.hpp"
#include "common/logging.hpp" #include "common/logging.hpp"
@@ -55,10 +56,10 @@ namespace ot {
namespace Dhcp6 { namespace Dhcp6 {
Dhcp6Client::Dhcp6Client(ThreadNetif &aThreadNetif) : Dhcp6Client::Dhcp6Client(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mTrickleTimer(aThreadNetif.GetInstance(), &Dhcp6Client::HandleTrickleTimer, NULL, this), mTrickleTimer(aInstance, &Dhcp6Client::HandleTrickleTimer, NULL, this),
mSocket(aThreadNetif.GetIp6().mUdp), mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
mStartTime(0), mStartTime(0),
mAddresses(NULL), mAddresses(NULL),
mNumAddresses(0) mNumAddresses(0)
+3 -3
View File
@@ -170,16 +170,16 @@ private:
* This class implements DHCPv6 Client. * This class implements DHCPv6 Client.
* *
*/ */
class Dhcp6Client: public ThreadNetifLocator class Dhcp6Client: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit Dhcp6Client(ThreadNetif &aThreadNetif); explicit Dhcp6Client(otInstance &aInstance);
/** /**
* This method update addresses that shall be automatically created using DHCP. * This method update addresses that shall be automatically created using DHCP.
+3 -3
View File
@@ -51,9 +51,9 @@ using ot::Encoding::BigEndian::HostSwap32;
namespace ot { namespace ot {
namespace Dhcp6 { namespace Dhcp6 {
Dhcp6Server::Dhcp6Server(ThreadNetif &aThreadNetif): Dhcp6Server::Dhcp6Server(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mSocket(aThreadNetif.GetIp6().mUdp) mSocket(GetNetif().GetIp6().mUdp)
{ {
for (uint8_t i = 0; i < OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES; i++) for (uint8_t i = 0; i < OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES; i++)
{ {
+3 -3
View File
@@ -102,16 +102,16 @@ private:
otIp6Prefix mIp6Prefix; ///< prefix otIp6Prefix mIp6Prefix; ///< prefix
} OT_TOOL_PACKED_END; } OT_TOOL_PACKED_END;
class Dhcp6Server: public ThreadNetifLocator class Dhcp6Server: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit Dhcp6Server(ThreadNetif &aThreadNetif); explicit Dhcp6Server(otInstance &aInstance);
/** /**
* This method updates DHCP Agents and DHCP Alocs. * This method updates DHCP Agents and DHCP Alocs.
+2 -2
View File
@@ -48,8 +48,8 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
namespace Ip6 { namespace Ip6 {
Icmp::Icmp(Ip6 &aIp6): Icmp::Icmp(otInstance &aInstance):
Ip6Locator(aIp6), InstanceLocator(aInstance),
mHandlers(NULL), mHandlers(NULL),
mEchoSequence(1), mEchoSequence(1),
mIsEchoEnabled(true) mIsEchoEnabled(true)
+3 -3
View File
@@ -222,16 +222,16 @@ private:
* This class implements ICMPv6. * This class implements ICMPv6.
* *
*/ */
class Icmp: public Ip6Locator class Icmp: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aIp6 A reference to the IPv6 network object. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
Icmp(Ip6 &aIp6); Icmp(otInstance &aInstance);
/** /**
* This method returns a new ICMP message with sufficient header space reserved. * This method returns a new ICMP message with sufficient header space reserved.
+4 -4
View File
@@ -52,10 +52,10 @@ namespace Ip6 {
Ip6::Ip6(otInstance &aInstance): Ip6::Ip6(otInstance &aInstance):
InstanceLocator(aInstance), InstanceLocator(aInstance),
mRoutes(*this), mRoutes(aInstance),
mIcmp(*this), mIcmp(aInstance),
mUdp(*this), mUdp(aInstance),
mMpl(*this), mMpl(aInstance),
mForwardingEnabled(false), mForwardingEnabled(false),
mSendQueueTask(aInstance, HandleSendQueue, this), mSendQueueTask(aInstance, HandleSendQueue, this),
mReceiveIp6DatagramCallback(NULL), mReceiveIp6DatagramCallback(NULL),
+4 -4
View File
@@ -53,10 +53,10 @@ void MplBufferedMessageMetadata::GenerateNextTransmissionTime(uint32_t aCurrentT
SetIntervalOffset(aInterval - t); SetIntervalOffset(aInterval - t);
} }
Mpl::Mpl(Ip6 &aIp6): Mpl::Mpl(otInstance &aInstance):
Ip6Locator(aIp6), InstanceLocator(aInstance),
mSeedSetTimer(aIp6.GetInstance(), &Mpl::HandleSeedSetTimer, this), mSeedSetTimer(aInstance, &Mpl::HandleSeedSetTimer, this),
mRetransmissionTimer(aIp6.GetInstance(), &Mpl::HandleRetransmissionTimer, this), mRetransmissionTimer(aInstance, &Mpl::HandleRetransmissionTimer, this),
mTimerExpirations(0), mTimerExpirations(0),
mSequence(0), mSequence(0),
mSeedId(0), mSeedId(0),
+3 -3
View File
@@ -430,16 +430,16 @@ private:
* This class implements MPL message processing. * This class implements MPL message processing.
* *
*/ */
class Mpl: public Ip6Locator class Mpl: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the MPL object. * This constructor initializes the MPL object.
* *
* @param[in] aIp6 A reference to the IPv6 network object. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
Mpl(Ip6 &aIp6); Mpl(otInstance &aInstance);
/** /**
* This method initializes the MPL option. * This method initializes the MPL option.
+2 -2
View File
@@ -41,8 +41,8 @@
namespace ot { namespace ot {
namespace Ip6 { namespace Ip6 {
Routes::Routes(Ip6 &aIp6): Routes::Routes(otInstance &aInstance):
Ip6Locator(aIp6), InstanceLocator(aInstance),
mRoutes(NULL) mRoutes(NULL)
{ {
} }
+3 -3
View File
@@ -71,16 +71,16 @@ struct Route
* This class implements IPv6 route management. * This class implements IPv6 route management.
* *
*/ */
class Routes: public Ip6Locator class Routes: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aIp6 A reference to the IPv6 network object. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
Routes(Ip6 &aIp6); Routes(otInstance &aInstance);
/** /**
* This method adds an IPv6 route. * This method adds an IPv6 route.
+3 -3
View File
@@ -90,14 +90,14 @@ const otNetifMulticastAddress Netif::kLinkLocalAllRoutersMulticastAddress =
}; };
Netif::Netif(Ip6 &aIp6, int8_t aInterfaceId): Netif::Netif(otInstance &aInstance, int8_t aInterfaceId):
Ip6Locator(aIp6), InstanceLocator(aInstance),
mCallbacks(NULL), mCallbacks(NULL),
mUnicastAddresses(NULL), mUnicastAddresses(NULL),
mMulticastAddresses(NULL), mMulticastAddresses(NULL),
mInterfaceId(aInterfaceId), mInterfaceId(aInterfaceId),
mMulticastPromiscuous(false), mMulticastPromiscuous(false),
mStateChangedTask(aIp6.GetInstance(), &Netif::HandleStateChangedTask, this), mStateChangedTask(aInstance, &Netif::HandleStateChangedTask, this),
mNext(NULL), mNext(NULL),
mStateChangedFlags(0) mStateChangedFlags(0)
{ {
+3 -3
View File
@@ -252,7 +252,7 @@ private:
* This class implements an IPv6 network interface. * This class implements an IPv6 network interface.
* *
*/ */
class Netif: public Ip6Locator class Netif: public InstanceLocator
{ {
friend class Ip6; friend class Ip6;
@@ -260,11 +260,11 @@ public:
/** /**
* This constructor initializes the network interface. * This constructor initializes the network interface.
* *
* @param[in] aIp6 A reference to the IPv6 network object. * @param[in] aInstance A reference to the OpenThread instance.
* @param[in] aInterfaceId The interface ID for this object. * @param[in] aInterfaceId The interface ID for this object.
* *
*/ */
Netif(Ip6 &aIp6, int8_t aInterfaceId); Netif(otInstance &aInstance, int8_t aInterfaceId);
/** /**
* This method returns the next network interface in the list. * This method returns the next network interface in the list.
+2 -2
View File
@@ -138,8 +138,8 @@ exit:
return error; return error;
} }
Udp::Udp(Ip6 &aIp6): Udp::Udp(otInstance &aInstance):
Ip6Locator(aIp6), InstanceLocator(aInstance),
mEphemeralPort(kDynamicPortMin), mEphemeralPort(kDynamicPortMin),
mSockets(NULL) mSockets(NULL)
{ {
+3 -3
View File
@@ -164,7 +164,7 @@ private:
* This class implements core UDP message handling. * This class implements core UDP message handling.
* *
*/ */
class Udp: public Ip6Locator class Udp: public InstanceLocator
{ {
friend class UdpSocket; friend class UdpSocket;
@@ -172,10 +172,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aIp6 A reference to the IPv6 network object. * @param[in] aIp6 A reference to OpenThread instance.
* *
*/ */
Udp(Ip6 &aIp6); Udp(otInstance &aInstance);
/** /**
* This method adds a UDP socket. * This method adds a UDP socket.
-10
View File
@@ -108,14 +108,4 @@ typedef struct otInstance
} otInstance; } otInstance;
static inline otInstance *otInstanceFromIp6(ot::Ip6::Ip6 *aIp6)
{
return (otInstance *)CONTAINING_RECORD(aIp6, otInstance, mIp6);
}
static inline otInstance *otInstanceFromThreadNetif(ot::ThreadNetif *aThreadNetif)
{
return (otInstance *)CONTAINING_RECORD(aThreadNetif, otInstance, mThreadNetif);
}
#endif // OPENTHREADINSTANCE_H_ #endif // OPENTHREADINSTANCE_H_
+7 -7
View File
@@ -56,21 +56,21 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
AddressResolver::AddressResolver(ThreadNetif &aThreadNetif) : AddressResolver::AddressResolver(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mAddressError(OT_URI_PATH_ADDRESS_ERROR, &AddressResolver::HandleAddressError, this), mAddressError(OT_URI_PATH_ADDRESS_ERROR, &AddressResolver::HandleAddressError, this),
mAddressQuery(OT_URI_PATH_ADDRESS_QUERY, &AddressResolver::HandleAddressQuery, this), mAddressQuery(OT_URI_PATH_ADDRESS_QUERY, &AddressResolver::HandleAddressQuery, this),
mAddressNotification(OT_URI_PATH_ADDRESS_NOTIFY, &AddressResolver::HandleAddressNotification, this), mAddressNotification(OT_URI_PATH_ADDRESS_NOTIFY, &AddressResolver::HandleAddressNotification, this),
mIcmpHandler(&AddressResolver::HandleIcmpReceive, this), mIcmpHandler(&AddressResolver::HandleIcmpReceive, this),
mTimer(aThreadNetif.GetInstance(), &AddressResolver::HandleTimer, this) mTimer(aInstance, &AddressResolver::HandleTimer, this)
{ {
Clear(); Clear();
aThreadNetif.GetCoap().AddResource(mAddressError); GetNetif().GetCoap().AddResource(mAddressError);
aThreadNetif.GetCoap().AddResource(mAddressQuery); GetNetif().GetCoap().AddResource(mAddressQuery);
aThreadNetif.GetCoap().AddResource(mAddressNotification); GetNetif().GetCoap().AddResource(mAddressNotification);
aThreadNetif.GetIp6().mIcmp.RegisterHandler(mIcmpHandler); GetNetif().GetIp6().mIcmp.RegisterHandler(mIcmpHandler);
} }
void AddressResolver::Clear() void AddressResolver::Clear()
+2 -2
View File
@@ -66,14 +66,14 @@ class ThreadTargetTlv;
* This class implements the EID-to-RLOC mapping and caching. * This class implements the EID-to-RLOC mapping and caching.
* *
*/ */
class AddressResolver: public ThreadNetifLocator class AddressResolver: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
explicit AddressResolver(ThreadNetif &aThreadNetif); explicit AddressResolver(otInstance &aInstance);
/** /**
* This method clears the EID-to-RLOC cache. * This method clears the EID-to-RLOC cache.
+4 -4
View File
@@ -50,16 +50,16 @@ using ot::Encoding::BigEndian::HostSwap32;
namespace ot { namespace ot {
AnnounceBeginServer::AnnounceBeginServer(ThreadNetif &aThreadNetif) : AnnounceBeginServer::AnnounceBeginServer(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mChannelMask(0), mChannelMask(0),
mPeriod(0), mPeriod(0),
mCount(0), mCount(0),
mChannel(0), mChannel(0),
mTimer(aThreadNetif.GetInstance(), &AnnounceBeginServer::HandleTimer, this), mTimer(aInstance, &AnnounceBeginServer::HandleTimer, this),
mAnnounceBegin(OT_URI_PATH_ANNOUNCE_BEGIN, &AnnounceBeginServer::HandleRequest, this) mAnnounceBegin(OT_URI_PATH_ANNOUNCE_BEGIN, &AnnounceBeginServer::HandleRequest, this)
{ {
aThreadNetif.GetCoap().AddResource(mAnnounceBegin); GetNetif().GetCoap().AddResource(mAnnounceBegin);
} }
otError AnnounceBeginServer::SendAnnounce(uint32_t aChannelMask) otError AnnounceBeginServer::SendAnnounce(uint32_t aChannelMask)
+2 -2
View File
@@ -49,14 +49,14 @@ namespace ot {
* This class implements handling Announce Begin Requests. * This class implements handling Announce Begin Requests.
* *
*/ */
class AnnounceBeginServer: public ThreadNetifLocator class AnnounceBeginServer: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
AnnounceBeginServer(ThreadNetif &aThreadNetif); AnnounceBeginServer(otInstance &aInstance);
/** /**
* This method begins the MLE Announce transmission process using Count=3 and Period=1s. * This method begins the MLE Announce transmission process using Count=3 and Period=1s.
+10 -10
View File
@@ -49,9 +49,9 @@
namespace ot { namespace ot {
DataPollManager::DataPollManager(MeshForwarder &aMeshForwarder): DataPollManager::DataPollManager(otInstance &aInstance):
MeshForwarderLocator(aMeshForwarder), InstanceLocator(aInstance),
mTimer(aMeshForwarder.GetInstance(), &DataPollManager::HandlePollTimer, this), mTimer(aInstance, &DataPollManager::HandlePollTimer, this),
mTimerStartTime(0), mTimerStartTime(0),
mExternalPollPeriod(0), mExternalPollPeriod(0),
mPollPeriod(0), mPollPeriod(0),
@@ -70,7 +70,7 @@ otError DataPollManager::StartPolling(void)
otError error = OT_ERROR_NONE; otError error = OT_ERROR_NONE;
VerifyOrExit(!mEnabled, error = OT_ERROR_ALREADY); VerifyOrExit(!mEnabled, error = OT_ERROR_ALREADY);
VerifyOrExit((GetMeshForwarder().GetNetif().GetMle().GetDeviceMode() & Mle::ModeTlv::kModeFFD) == 0, VerifyOrExit((GetNetif().GetMle().GetDeviceMode() & Mle::ModeTlv::kModeFFD) == 0,
error = OT_ERROR_INVALID_STATE); error = OT_ERROR_INVALID_STATE);
mEnabled = true; mEnabled = true;
@@ -94,20 +94,20 @@ void DataPollManager::StopPolling(void)
otError DataPollManager::SendDataPoll(void) otError DataPollManager::SendDataPoll(void)
{ {
MeshForwarder &meshForwarder = GetMeshForwarder(); ThreadNetif &netif = GetNetif();
otError error; otError error;
Message *message; Message *message;
Neighbor *parent; Neighbor *parent;
VerifyOrExit(mEnabled, error = OT_ERROR_INVALID_STATE); VerifyOrExit(mEnabled, error = OT_ERROR_INVALID_STATE);
VerifyOrExit(!meshForwarder.GetNetif().GetMac().GetRxOnWhenIdle(), error = OT_ERROR_INVALID_STATE); VerifyOrExit(!netif.GetMac().GetRxOnWhenIdle(), error = OT_ERROR_INVALID_STATE);
parent = meshForwarder.GetNetif().GetMle().GetParent(); parent = netif.GetMle().GetParent();
VerifyOrExit((parent != NULL) && parent->IsStateValidOrRestoring(), error = OT_ERROR_INVALID_STATE); VerifyOrExit((parent != NULL) && parent->IsStateValidOrRestoring(), error = OT_ERROR_INVALID_STATE);
mTimer.Stop(); mTimer.Stop();
for (message = meshForwarder.GetSendQueue().GetHead(); message; message = message->GetNext()) for (message = netif.GetMeshForwarder().GetSendQueue().GetHead(); message; message = message->GetNext())
{ {
VerifyOrExit(message->GetType() != Message::kTypeMacDataPoll, error = OT_ERROR_ALREADY); VerifyOrExit(message->GetType() != Message::kTypeMacDataPoll, error = OT_ERROR_ALREADY);
} }
@@ -115,7 +115,7 @@ otError DataPollManager::SendDataPoll(void)
message = GetInstance().mMessagePool.New(Message::kTypeMacDataPoll, 0); message = GetInstance().mMessagePool.New(Message::kTypeMacDataPoll, 0);
VerifyOrExit(message != NULL, error = OT_ERROR_NO_BUFS); VerifyOrExit(message != NULL, error = OT_ERROR_NO_BUFS);
error = meshForwarder.SendMessage(*message); error = netif.GetMeshForwarder().SendMessage(*message);
if (error != OT_ERROR_NONE) if (error != OT_ERROR_NONE)
{ {
@@ -426,7 +426,7 @@ DataPollManager &DataPollManager::GetOwner(Context &aContext)
uint32_t DataPollManager::GetDefaultPollPeriod(void) const uint32_t DataPollManager::GetDefaultPollPeriod(void) const
{ {
return TimerMilli::SecToMsec(GetMeshForwarder().GetNetif().GetMle().GetTimeout()) - return TimerMilli::SecToMsec(GetNetif().GetMle().GetTimeout()) -
static_cast<uint32_t>(kRetxPollPeriod) * kMaxPollRetxAttempts; static_cast<uint32_t>(kRetxPollPeriod) * kMaxPollRetxAttempts;
} }
+3 -3
View File
@@ -59,7 +59,7 @@ namespace ot {
* *
*/ */
class DataPollManager: public MeshForwarderLocator class DataPollManager: public InstanceLocator
{ {
public: public:
enum enum
@@ -71,10 +71,10 @@ public:
/** /**
* This constructor initializes the data poll manager object. * This constructor initializes the data poll manager object.
* *
* @param[in] aMeshForwarder A reference to the Mesh Forwarder. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit DataPollManager(MeshForwarder &aMeshForwarder); explicit DataPollManager(otInstance &aInstance);
/** /**
* This method instructs the data poll manager to start sending periodic data polls. * This method instructs the data poll manager to start sending periodic data polls.
+5 -5
View File
@@ -49,8 +49,8 @@
namespace ot { namespace ot {
EnergyScanServer::EnergyScanServer(ThreadNetif &aThreadNetif) : EnergyScanServer::EnergyScanServer(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mChannelMask(0), mChannelMask(0),
mChannelMaskCurrent(0), mChannelMaskCurrent(0),
mPeriod(0), mPeriod(0),
@@ -58,13 +58,13 @@ EnergyScanServer::EnergyScanServer(ThreadNetif &aThreadNetif) :
mCount(0), mCount(0),
mActive(false), mActive(false),
mScanResultsLength(0), mScanResultsLength(0),
mTimer(aThreadNetif.GetInstance(), &EnergyScanServer::HandleTimer, this), mTimer(aInstance, &EnergyScanServer::HandleTimer, this),
mEnergyScan(OT_URI_PATH_ENERGY_SCAN, &EnergyScanServer::HandleRequest, this) mEnergyScan(OT_URI_PATH_ENERGY_SCAN, &EnergyScanServer::HandleRequest, this)
{ {
mNetifCallback.Set(&EnergyScanServer::HandleNetifStateChanged, this); mNetifCallback.Set(&EnergyScanServer::HandleNetifStateChanged, this);
aThreadNetif.RegisterCallback(mNetifCallback); GetNetif().RegisterCallback(mNetifCallback);
aThreadNetif.GetCoap().AddResource(mEnergyScan); GetNetif().GetCoap().AddResource(mEnergyScan);
} }
void EnergyScanServer::HandleRequest(void *aContext, otCoapHeader *aHeader, otMessage *aMessage, void EnergyScanServer::HandleRequest(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
+2 -2
View File
@@ -56,14 +56,14 @@ class ThreadTargetTlv;
* This class implements handling Energy Scan Requests. * This class implements handling Energy Scan Requests.
* *
*/ */
class EnergyScanServer: public ThreadNetifLocator class EnergyScanServer: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
EnergyScanServer(ThreadNetif &aThreadNetif); EnergyScanServer(otInstance &aInstance);
private: private:
enum enum
+3 -3
View File
@@ -47,8 +47,8 @@ static const uint8_t kThreadString[] =
'T', 'h', 'r', 'e', 'a', 'd', 'T', 'h', 'r', 'e', 'a', 'd',
}; };
KeyManager::KeyManager(ThreadNetif &aThreadNetif): KeyManager::KeyManager(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mKeySequence(0), mKeySequence(0),
mMacFrameCounter(0), mMacFrameCounter(0),
mMleFrameCounter(0), mMleFrameCounter(0),
@@ -58,7 +58,7 @@ KeyManager::KeyManager(ThreadNetif &aThreadNetif):
mKeyRotationTime(kDefaultKeyRotationTime), mKeyRotationTime(kDefaultKeyRotationTime),
mKeySwitchGuardTime(kDefaultKeySwitchGuardTime), mKeySwitchGuardTime(kDefaultKeySwitchGuardTime),
mKeySwitchGuardEnabled(false), mKeySwitchGuardEnabled(false),
mKeyRotationTimer(aThreadNetif.GetInstance(), &KeyManager::HandleKeyRotationTimer, this), mKeyRotationTimer(aInstance, &KeyManager::HandleKeyRotationTimer, this),
mKekFrameCounter(0), mKekFrameCounter(0),
mSecurityPolicyFlags(0xff) mSecurityPolicyFlags(0xff)
{ {
+3 -3
View File
@@ -55,7 +55,7 @@ namespace ot {
* @{ * @{
*/ */
class KeyManager: public ThreadNetifLocator class KeyManager: public InstanceLocator
{ {
public: public:
enum enum
@@ -66,10 +66,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit KeyManager(ThreadNetif &aThreadNetif); explicit KeyManager(otInstance &aInstance);
/** /**
* This method starts KeyManager rotation timer and sets guard timer to initial value. * This method starts KeyManager rotation timer and sets guard timer to initial value.
+2 -2
View File
@@ -46,8 +46,8 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
namespace Lowpan { namespace Lowpan {
Lowpan::Lowpan(ThreadNetif &aThreadNetif): Lowpan::Lowpan(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif) InstanceLocator(aInstance)
{ {
} }
+3 -3
View File
@@ -78,16 +78,16 @@ struct Context
* This class implements LOWPAN_IPHC header compression. * This class implements LOWPAN_IPHC header compression.
* *
*/ */
class Lowpan: public ThreadNetifLocator class Lowpan: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit Lowpan(ThreadNetif &aThreadNetif); explicit Lowpan(otInstance &aInstance);
/** /**
* This method indicates whether or not the header is a LOWPAN_IPHC header. * This method indicates whether or not the header is a LOWPAN_IPHC header.
+8 -8
View File
@@ -56,12 +56,12 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
MeshForwarder::MeshForwarder(ThreadNetif &aThreadNetif): MeshForwarder::MeshForwarder(otInstance &aInstance):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mMacReceiver(&MeshForwarder::HandleReceivedFrame, &MeshForwarder::HandleDataPollTimeout, this), mMacReceiver(&MeshForwarder::HandleReceivedFrame, &MeshForwarder::HandleDataPollTimeout, this),
mMacSender(&MeshForwarder::HandleFrameRequest, &MeshForwarder::HandleSentFrame, this), mMacSender(&MeshForwarder::HandleFrameRequest, &MeshForwarder::HandleSentFrame, this),
mDiscoverTimer(aThreadNetif.GetInstance(), &MeshForwarder::HandleDiscoverTimer, this), mDiscoverTimer(aInstance, &MeshForwarder::HandleDiscoverTimer, this),
mReassemblyTimer(aThreadNetif.GetInstance(), &MeshForwarder::HandleReassemblyTimer, this), mReassemblyTimer(aInstance, &MeshForwarder::HandleReassemblyTimer, this),
mMessageNextOffset(0), mMessageNextOffset(0),
mSendMessageFrameCounter(0), mSendMessageFrameCounter(0),
mSendMessage(NULL), mSendMessage(NULL),
@@ -74,18 +74,18 @@ MeshForwarder::MeshForwarder(ThreadNetif &aThreadNetif):
mMeshDest(Mac::kShortAddrInvalid), mMeshDest(Mac::kShortAddrInvalid),
mAddMeshHeader(false), mAddMeshHeader(false),
mSendBusy(false), mSendBusy(false),
mScheduleTransmissionTask(aThreadNetif.GetInstance(), ScheduleTransmissionTask, this), mScheduleTransmissionTask(aInstance, ScheduleTransmissionTask, this),
mEnabled(false), mEnabled(false),
mScanChannels(0), mScanChannels(0),
mScanChannel(0), mScanChannel(0),
mRestoreChannel(0), mRestoreChannel(0),
mRestorePanId(Mac::kPanIdBroadcast), mRestorePanId(Mac::kPanIdBroadcast),
mScanning(false), mScanning(false),
mDataPollManager(*this), mDataPollManager(aInstance),
mSourceMatchController(*this) mSourceMatchController(aInstance)
{ {
mFragTag = static_cast<uint16_t>(otPlatRandomGet()); mFragTag = static_cast<uint16_t>(otPlatRandomGet());
aThreadNetif.GetMac().RegisterReceiver(mMacReceiver); GetNetif().GetMac().RegisterReceiver(mMacReceiver);
mMacSource.mLength = 0; mMacSource.mLength = 0;
mMacDest.mLength = 0; mMacDest.mLength = 0;
+3 -3
View File
@@ -71,16 +71,16 @@ class MleRouter;
* This class implements mesh forwarding within Thread. * This class implements mesh forwarding within Thread.
* *
*/ */
class MeshForwarder: public ThreadNetifLocator class MeshForwarder: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit MeshForwarder(ThreadNetif &aThreadNetif); explicit MeshForwarder(otInstance &aInstance);
/** /**
* This method enables mesh forwarding and the IEEE 802.15.4 MAC layer. * This method enables mesh forwarding and the IEEE 802.15.4 MAC layer.
+11 -11
View File
@@ -60,15 +60,15 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
namespace Mle { namespace Mle {
Mle::Mle(ThreadNetif &aThreadNetif) : Mle::Mle(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mRetrieveNewNetworkData(false), mRetrieveNewNetworkData(false),
mRole(OT_DEVICE_ROLE_DISABLED), mRole(OT_DEVICE_ROLE_DISABLED),
mDeviceMode(ModeTlv::kModeRxOnWhenIdle | ModeTlv::kModeSecureDataRequest), mDeviceMode(ModeTlv::kModeRxOnWhenIdle | ModeTlv::kModeSecureDataRequest),
mParentRequestState(kParentIdle), mParentRequestState(kParentIdle),
mReattachState(kReattachStop), mReattachState(kReattachStop),
mParentRequestTimer(aThreadNetif.GetInstance(), &Mle::HandleParentRequestTimer, this), mParentRequestTimer(aInstance, &Mle::HandleParentRequestTimer, this),
mDelayedResponseTimer(aThreadNetif.GetInstance(), &Mle::HandleDelayedResponseTimer, this), mDelayedResponseTimer(aInstance, &Mle::HandleDelayedResponseTimer, this),
mLastPartitionId(0), mLastPartitionId(0),
mLastPartitionRouterIdSequence(0), mLastPartitionRouterIdSequence(0),
mLastPartitionIdTimeout(0), mLastPartitionIdTimeout(0),
@@ -81,9 +81,9 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
mChildUpdateAttempts(0), mChildUpdateAttempts(0),
mParentLinkMargin(0), mParentLinkMargin(0),
mParentIsSingleton(false), mParentIsSingleton(false),
mSocket(aThreadNetif.GetIp6().mUdp), mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
mTimeout(kMleEndDeviceTimeout), mTimeout(kMleEndDeviceTimeout),
mSendChildUpdateRequest(aThreadNetif.GetInstance(), &Mle::HandleSendChildUpdateRequest, this), mSendChildUpdateRequest(aInstance, &Mle::HandleSendChildUpdateRequest, this),
mDiscoverHandler(NULL), mDiscoverHandler(NULL),
mDiscoverContext(NULL), mDiscoverContext(NULL),
mIsDiscoverInProgress(false), mIsDiscoverInProgress(false),
@@ -111,11 +111,11 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
// link-local 64 // link-local 64
mLinkLocal64.GetAddress().mFields.m16[0] = HostSwap16(0xfe80); mLinkLocal64.GetAddress().mFields.m16[0] = HostSwap16(0xfe80);
mLinkLocal64.GetAddress().SetIid(*aThreadNetif.GetMac().GetExtAddress()); mLinkLocal64.GetAddress().SetIid(*GetNetif().GetMac().GetExtAddress());
mLinkLocal64.mPrefixLength = 64; mLinkLocal64.mPrefixLength = 64;
mLinkLocal64.mPreferred = true; mLinkLocal64.mPreferred = true;
mLinkLocal64.mValid = true; mLinkLocal64.mValid = true;
aThreadNetif.AddUnicastAddress(mLinkLocal64); GetNetif().AddUnicastAddress(mLinkLocal64);
// Leader Aloc // Leader Aloc
mLeaderAloc.mPrefixLength = 128; mLeaderAloc.mPrefixLength = 128;
@@ -126,7 +126,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
// initialize Mesh Local Prefix // initialize Mesh Local Prefix
meshLocalPrefix[0] = 0xfd; meshLocalPrefix[0] = 0xfd;
memcpy(meshLocalPrefix + 1, aThreadNetif.GetMac().GetExtendedPanId(), 5); memcpy(meshLocalPrefix + 1, GetNetif().GetMac().GetExtendedPanId(), 5);
meshLocalPrefix[6] = 0x00; meshLocalPrefix[6] = 0x00;
meshLocalPrefix[7] = 0x00; meshLocalPrefix[7] = 0x00;
@@ -154,7 +154,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
mMeshLocal16.mRloc = true; mMeshLocal16.mRloc = true;
// Store RLOC address reference in MPL module. // Store RLOC address reference in MPL module.
aThreadNetif.GetIp6().mMpl.SetMatchingAddress(mMeshLocal16.GetAddress()); GetNetif().GetIp6().mMpl.SetMatchingAddress(mMeshLocal16.GetAddress());
// link-local all thread nodes // link-local all thread nodes
mLinkLocalAllThreadNodes.GetAddress().mFields.m16[0] = HostSwap16(0xff32); mLinkLocalAllThreadNodes.GetAddress().mFields.m16[0] = HostSwap16(0xff32);
@@ -172,7 +172,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
// to the Link- and Realm-Local All Thread Nodes multicast addresses. // to the Link- and Realm-Local All Thread Nodes multicast addresses.
mNetifCallback.Set(&Mle::HandleNetifStateChanged, this); mNetifCallback.Set(&Mle::HandleNetifStateChanged, this);
aThreadNetif.RegisterCallback(mNetifCallback); GetNetif().RegisterCallback(mNetifCallback);
} }
otError Mle::Enable(void) otError Mle::Enable(void)
+3 -3
View File
@@ -449,16 +449,16 @@ private:
* This class implements MLE functionality required by the Thread EndDevices, Router, and Leader roles. * This class implements MLE functionality required by the Thread EndDevices, Router, and Leader roles.
* *
*/ */
class Mle: public ThreadNetifLocator class Mle: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the MLE object. * This constructor initializes the MLE object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit Mle(ThreadNetif &aThreadNetif); explicit Mle(otInstance &aInstance);
/** /**
* This method enables MLE. * This method enables MLE.
+4 -4
View File
@@ -56,10 +56,10 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
namespace Mle { namespace Mle {
MleRouter::MleRouter(ThreadNetif &aThreadNetif): MleRouter::MleRouter(otInstance &aInstance):
Mle(aThreadNetif), Mle(aInstance),
mAdvertiseTimer(aThreadNetif.GetInstance(), &MleRouter::HandleAdvertiseTimer, NULL, this), mAdvertiseTimer(aInstance, &MleRouter::HandleAdvertiseTimer, NULL, this),
mStateUpdateTimer(aThreadNetif.GetInstance(), &MleRouter::HandleStateUpdateTimer, this), mStateUpdateTimer(aInstance, &MleRouter::HandleStateUpdateTimer, this),
mAddressSolicit(OT_URI_PATH_ADDRESS_SOLICIT, &MleRouter::HandleAddressSolicit, this), mAddressSolicit(OT_URI_PATH_ADDRESS_SOLICIT, &MleRouter::HandleAddressSolicit, this),
mAddressRelease(OT_URI_PATH_ADDRESS_RELEASE, &MleRouter::HandleAddressRelease, this), mAddressRelease(OT_URI_PATH_ADDRESS_RELEASE, &MleRouter::HandleAddressRelease, this),
mRouterIdSequence(0), mRouterIdSequence(0),
+2 -2
View File
@@ -79,10 +79,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit MleRouter(ThreadNetif &aThreadNetif); explicit MleRouter(otInstance &aInstance);
/** /**
* This method indicates whether or not the Router Role is enabled. * This method indicates whether or not the Router Role is enabled.
+1 -1
View File
@@ -50,7 +50,7 @@ class MleRouter: public Mle
friend class Mle; friend class Mle;
public: public:
explicit MleRouter(ThreadNetif &aThreadNetif) : Mle(aThreadNetif) { } explicit MleRouter(otInstance &aInstance) : Mle(aInstance) { }
bool IsSingleton(void) { return false; } bool IsSingleton(void) { return false; }
+2 -2
View File
@@ -49,8 +49,8 @@
namespace ot { namespace ot {
namespace NetworkData { namespace NetworkData {
NetworkData::NetworkData(ThreadNetif &aThreadNetif, bool aLocal): NetworkData::NetworkData(otInstance &aInstance, bool aLocal):
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mLocal(aLocal), mLocal(aLocal),
mLastAttemptWait(false), mLastAttemptWait(false),
mLastAttempt(0) mLastAttempt(0)
+3 -3
View File
@@ -86,7 +86,7 @@ namespace NetworkData {
* This class implements Network Data processing. * This class implements Network Data processing.
* *
*/ */
class NetworkData: public ThreadNetifLocator class NetworkData: public InstanceLocator
{ {
public: public:
enum enum
@@ -97,11 +97,11 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* @param[in] aLocal TRUE if this represents local network data, FALSE otherwise. * @param[in] aLocal TRUE if this represents local network data, FALSE otherwise.
* *
*/ */
NetworkData(ThreadNetif &aThreadNetif, bool aLocal); NetworkData(otInstance &aInstance, bool aLocal);
/** /**
* This method clears the network data. * This method clears the network data.
+2 -2
View File
@@ -56,8 +56,8 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
namespace NetworkData { namespace NetworkData {
LeaderBase::LeaderBase(ThreadNetif &aThreadNetif): LeaderBase::LeaderBase(otInstance &aInstance):
NetworkData(aThreadNetif, false) NetworkData(aInstance, false)
{ {
Reset(); Reset();
} }
+2 -2
View File
@@ -70,10 +70,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit LeaderBase(ThreadNetif &aThreadNetif); explicit LeaderBase(otInstance &aInstance);
/** /**
* This method reset the Thread Network Data. * This method reset the Thread Network Data.
+3 -3
View File
@@ -61,9 +61,9 @@ using ot::Encoding::BigEndian::HostSwap16;
namespace ot { namespace ot {
namespace NetworkData { namespace NetworkData {
Leader::Leader(ThreadNetif &aThreadNetif): Leader::Leader(otInstance &aInstance):
LeaderBase(aThreadNetif), LeaderBase(aInstance),
mTimer(aThreadNetif.GetInstance(), &Leader::HandleTimer, this), mTimer(aInstance, &Leader::HandleTimer, this),
mServerData(OT_URI_PATH_SERVER_DATA, &Leader::HandleServerData, this), mServerData(OT_URI_PATH_SERVER_DATA, &Leader::HandleServerData, this),
mCommissioningDataGet(OT_URI_PATH_COMMISSIONER_GET, &Leader::HandleCommissioningGet, this), mCommissioningDataGet(OT_URI_PATH_COMMISSIONER_GET, &Leader::HandleCommissioningGet, this),
mCommissioningDataSet(OT_URI_PATH_COMMISSIONER_SET, &Leader::HandleCommissioningSet, this) mCommissioningDataSet(OT_URI_PATH_COMMISSIONER_SET, &Leader::HandleCommissioningSet, this)
+2 -2
View File
@@ -70,10 +70,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit Leader(ThreadNetif &aThreadNetif); explicit Leader(otInstance &aInstance);
/** /**
* This method reset the Thread Network Data. * This method reset the Thread Network Data.
+1 -1
View File
@@ -47,7 +47,7 @@ namespace NetworkData {
class Leader: public LeaderBase class Leader: public LeaderBase
{ {
public: public:
explicit Leader(ThreadNetif &aThreadNetif) : LeaderBase(aThreadNetif) { } explicit Leader(otInstance &aInstance) : LeaderBase(aInstance) { }
void Start(void) { } void Start(void) { }
void Stop(void) { } void Stop(void) { }
+2 -2
View File
@@ -44,8 +44,8 @@
namespace ot { namespace ot {
namespace NetworkData { namespace NetworkData {
Local::Local(ThreadNetif &aThreadNetif): Local::Local(otInstance &aInstance):
NetworkData(aThreadNetif, true), NetworkData(aInstance, true),
mOldRloc(Mac::kShortAddrInvalid) mOldRloc(Mac::kShortAddrInvalid)
{ {
} }
+1 -1
View File
@@ -66,7 +66,7 @@ public:
* @param[in] aNetif A reference to the Thread network interface. * @param[in] aNetif A reference to the Thread network interface.
* *
*/ */
explicit Local(ThreadNetif &aNetif); explicit Local(otInstance &aInstance);
/** /**
* This method adds a Border Router entry to the Thread Network Data. * This method adds a Border Router entry to the Thread Network Data.
+6 -6
View File
@@ -59,8 +59,8 @@ namespace ot {
namespace NetworkDiagnostic { namespace NetworkDiagnostic {
NetworkDiagnostic::NetworkDiagnostic(ThreadNetif &aThreadNetif) : NetworkDiagnostic::NetworkDiagnostic(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mDiagnosticGetRequest(OT_URI_PATH_DIAGNOSTIC_GET_REQUEST, &NetworkDiagnostic::HandleDiagnosticGetRequest, this), mDiagnosticGetRequest(OT_URI_PATH_DIAGNOSTIC_GET_REQUEST, &NetworkDiagnostic::HandleDiagnosticGetRequest, this),
mDiagnosticGetQuery(OT_URI_PATH_DIAGNOSTIC_GET_QUERY, &NetworkDiagnostic::HandleDiagnosticGetQuery, this), mDiagnosticGetQuery(OT_URI_PATH_DIAGNOSTIC_GET_QUERY, &NetworkDiagnostic::HandleDiagnosticGetQuery, this),
mDiagnosticGetAnswer(OT_URI_PATH_DIAGNOSTIC_GET_ANSWER, &NetworkDiagnostic::HandleDiagnosticGetAnswer, this), mDiagnosticGetAnswer(OT_URI_PATH_DIAGNOSTIC_GET_ANSWER, &NetworkDiagnostic::HandleDiagnosticGetAnswer, this),
@@ -68,10 +68,10 @@ NetworkDiagnostic::NetworkDiagnostic(ThreadNetif &aThreadNetif) :
mReceiveDiagnosticGetCallback(NULL), mReceiveDiagnosticGetCallback(NULL),
mReceiveDiagnosticGetCallbackContext(NULL) mReceiveDiagnosticGetCallbackContext(NULL)
{ {
aThreadNetif.GetCoap().AddResource(mDiagnosticGetRequest); GetNetif().GetCoap().AddResource(mDiagnosticGetRequest);
aThreadNetif.GetCoap().AddResource(mDiagnosticGetQuery); GetNetif().GetCoap().AddResource(mDiagnosticGetQuery);
aThreadNetif.GetCoap().AddResource(mDiagnosticGetAnswer); GetNetif().GetCoap().AddResource(mDiagnosticGetAnswer);
aThreadNetif.GetCoap().AddResource(mDiagnosticReset); GetNetif().GetCoap().AddResource(mDiagnosticReset);
} }
void NetworkDiagnostic::SetReceiveDiagnosticGetCallback(otReceiveDiagnosticGetCallback aCallback, void NetworkDiagnostic::SetReceiveDiagnosticGetCallback(otReceiveDiagnosticGetCallback aCallback,
+2 -2
View File
@@ -63,14 +63,14 @@ class NetworkDiagnosticTlv;
* This class implements the Network Diagnostic processing. * This class implements the Network Diagnostic processing.
* *
*/ */
class NetworkDiagnostic: public ThreadNetifLocator class NetworkDiagnostic: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
explicit NetworkDiagnostic(ThreadNetif &aThreadNetif); explicit NetworkDiagnostic(otInstance &aInstance);
/** /**
* This method registers a callback to provide received raw DIAG_GET.rsp or an DIAG_GET.ans payload. * This method registers a callback to provide received raw DIAG_GET.rsp or an DIAG_GET.ans payload.
+4 -4
View File
@@ -49,14 +49,14 @@
namespace ot { namespace ot {
PanIdQueryServer::PanIdQueryServer(ThreadNetif &aThreadNetif) : PanIdQueryServer::PanIdQueryServer(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mChannelMask(0), mChannelMask(0),
mPanId(Mac::kPanIdBroadcast), mPanId(Mac::kPanIdBroadcast),
mTimer(aThreadNetif.GetInstance(), &PanIdQueryServer::HandleTimer, this), mTimer(aInstance, &PanIdQueryServer::HandleTimer, this),
mPanIdQuery(OT_URI_PATH_PANID_QUERY, &PanIdQueryServer::HandleQuery, this) mPanIdQuery(OT_URI_PATH_PANID_QUERY, &PanIdQueryServer::HandleQuery, this)
{ {
aThreadNetif.GetCoap().AddResource(mPanIdQuery); GetNetif().GetCoap().AddResource(mPanIdQuery);
} }
void PanIdQueryServer::HandleQuery(void *aContext, otCoapHeader *aHeader, otMessage *aMessage, void PanIdQueryServer::HandleQuery(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
+2 -2
View File
@@ -56,14 +56,14 @@ class ThreadTargetTlv;
* This class implements handling PANID Query Requests. * This class implements handling PANID Query Requests.
* *
*/ */
class PanIdQueryServer: public ThreadNetifLocator class PanIdQueryServer: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
*/ */
PanIdQueryServer(ThreadNetif &aThreadNetif); PanIdQueryServer(otInstance &aInstance);
private: private:
enum enum
+3 -3
View File
@@ -43,8 +43,8 @@
namespace ot { namespace ot {
SourceMatchController::SourceMatchController(MeshForwarder &aMeshForwarder) : SourceMatchController::SourceMatchController(otInstance &aInstance) :
MeshForwarderLocator(aMeshForwarder), InstanceLocator(aInstance),
mEnabled(false) mEnabled(false)
{ {
ClearTable(); ClearTable();
@@ -220,7 +220,7 @@ otError SourceMatchController::AddPendingEntries(void)
uint8_t numChildren; uint8_t numChildren;
Child *child; Child *child;
child = GetMeshForwarder().GetNetif().GetMle().GetChildren(&numChildren); child = GetNetif().GetMle().GetChildren(&numChildren);
for (uint8_t i = 0; i < numChildren; i++, child++) for (uint8_t i = 0; i < numChildren; i++, child++)
{ {
+3 -3
View File
@@ -65,16 +65,16 @@ namespace ot {
* address or an extended/long address can be added to the source address match table. * address or an extended/long address can be added to the source address match table.
* *
*/ */
class SourceMatchController: public MeshForwarderLocator class SourceMatchController: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aMeshForwarder A reference to the Mesh Forwarder. * @param[in] aInstance A reference to the OpenThread instance
* *
*/ */
explicit SourceMatchController(MeshForwarder &aMeshForwarder); explicit SourceMatchController(otInstance &aInstance);
/** /**
* This method returns the current state of source address matching. * This method returns the current state of source address matching.
+29 -29
View File
@@ -57,58 +57,58 @@ static const otMasterKey kThreadMasterKey =
} }
}; };
ThreadNetif::ThreadNetif(Ip6::Ip6 &aIp6): ThreadNetif::ThreadNetif(otInstance &aInstance):
Netif(aIp6, OT_NETIF_INTERFACE_ID_THREAD), Netif(aInstance, OT_NETIF_INTERFACE_ID_THREAD),
mCoap(*this), mCoap(aInstance),
#if OPENTHREAD_ENABLE_DHCP6_CLIENT #if OPENTHREAD_ENABLE_DHCP6_CLIENT
mDhcp6Client(*this), mDhcp6Client(aInstance),
#endif // OPENTHREAD_ENABLE_DHCP6_CLIENT #endif // OPENTHREAD_ENABLE_DHCP6_CLIENT
#if OPENTHREAD_ENABLE_DHCP6_SERVER #if OPENTHREAD_ENABLE_DHCP6_SERVER
mDhcp6Server(*this), mDhcp6Server(aInstance),
#endif // OPENTHREAD_ENABLE_DHCP6_SERVER #endif // OPENTHREAD_ENABLE_DHCP6_SERVER
#if OPENTHREAD_ENABLE_DNS_CLIENT #if OPENTHREAD_ENABLE_DNS_CLIENT
mDnsClient(*this), mDnsClient(aInstance.mThreadNetif),
#endif // OPENTHREAD_ENABLE_DNS_CLIENT #endif // OPENTHREAD_ENABLE_DNS_CLIENT
mActiveDataset(*this), mActiveDataset(aInstance),
mPendingDataset(*this), mPendingDataset(aInstance),
mKeyManager(*this), mKeyManager(aInstance),
mLowpan(*this), mLowpan(aInstance),
mMac(*this), mMac(aInstance),
mMeshForwarder(*this), mMeshForwarder(aInstance),
mMleRouter(*this), mMleRouter(aInstance),
#if OPENTHREAD_ENABLE_BORDER_ROUTER #if OPENTHREAD_ENABLE_BORDER_ROUTER
mNetworkDataLocal(*this), mNetworkDataLocal(aInstance),
#endif #endif
mNetworkDataLeader(*this), mNetworkDataLeader(aInstance),
#if OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC #if OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC
mNetworkDiagnostic(*this), mNetworkDiagnostic(aInstance),
#endif #endif
#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD #if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
mCommissioner(*this), mCommissioner(aInstance),
#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD #endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
#if OPENTHREAD_ENABLE_DTLS #if OPENTHREAD_ENABLE_DTLS
mDtls(*this), mDtls(aInstance),
mCoapSecure(*this), mCoapSecure(aInstance),
#endif #endif
#if OPENTHREAD_ENABLE_JOINER #if OPENTHREAD_ENABLE_JOINER
mJoiner(*this), mJoiner(aInstance),
#endif // OPENTHREAD_ENABLE_JOINER #endif // OPENTHREAD_ENABLE_JOINER
#if OPENTHREAD_ENABLE_JAM_DETECTION #if OPENTHREAD_ENABLE_JAM_DETECTION
mJamDetector(*this), mJamDetector(aInstance),
#endif // OPENTHREAD_ENABLE_JAM_DETECTTION #endif // OPENTHREAD_ENABLE_JAM_DETECTTION
#if OPENTHREAD_FTD #if OPENTHREAD_FTD
#if OPENTHREAD_ENABLE_TMF_PROXY #if OPENTHREAD_ENABLE_TMF_PROXY
mTmfProxy(mMleRouter.GetMeshLocal16(), mCoap), mTmfProxy(mMleRouter.GetMeshLocal16(), mCoap),
#endif // OPENTHREAD_ENABLE_TMF_PROXY #endif // OPENTHREAD_ENABLE_TMF_PROXY
mJoinerRouter(*this), mJoinerRouter(aInstance),
mLeader(*this), mLeader(aInstance),
mAddressResolver(*this), mAddressResolver(aInstance),
#endif // OPENTHREAD_FTD #endif // OPENTHREAD_FTD
mChildSupervisor(*this), mChildSupervisor(aInstance),
mSupervisionListener(*this), mSupervisionListener(aInstance),
mAnnounceBegin(*this), mAnnounceBegin(aInstance),
mPanIdQuery(*this), mPanIdQuery(aInstance),
mEnergyScan(*this) mEnergyScan(aInstance)
{ {
mKeyManager.SetMasterKey(kThreadMasterKey); mKeyManager.SetMasterKey(kThreadMasterKey);
+2 -2
View File
@@ -101,10 +101,10 @@ public:
/** /**
* This constructor initializes the Thread network interface. * This constructor initializes the Thread network interface.
* *
* @param[in] aIp6 A reference to the IPv6 network object. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
ThreadNetif(Ip6::Ip6 &aIp6); ThreadNetif(otInstance &aInstance);
/** /**
* This method enables the Thread network interface. * This method enables the Thread network interface.
+6 -6
View File
@@ -48,9 +48,9 @@ namespace Utils {
#if OPENTHREAD_FTD #if OPENTHREAD_FTD
ChildSupervisor::ChildSupervisor(ThreadNetif &aThreadNetif) : ChildSupervisor::ChildSupervisor(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mTimer(aThreadNetif.GetInstance(), &ChildSupervisor::HandleTimer, this), mTimer(aInstance, &ChildSupervisor::HandleTimer, this),
mSupervisionInterval(kDefaultSupervisionInterval) mSupervisionInterval(kDefaultSupervisionInterval)
{ {
} }
@@ -178,9 +178,9 @@ ChildSupervisor &ChildSupervisor::GetOwner(const Context &aContext)
#endif // #if OPENTHREAD_FTD #endif // #if OPENTHREAD_FTD
SupervisionListener::SupervisionListener(ThreadNetif &aThreadNetif) : SupervisionListener::SupervisionListener(otInstance &aInstance) :
ThreadNetifLocator(aThreadNetif), InstanceLocator(aInstance),
mTimer(aThreadNetif.GetInstance(), &SupervisionListener::HandleTimer, this), mTimer(aInstance, &SupervisionListener::HandleTimer, this),
mTimeout(0) mTimeout(0)
{ {
SetTimeout(kDefaultTimeout); SetTimeout(kDefaultTimeout);
+8 -8
View File
@@ -86,16 +86,16 @@ namespace Utils {
* This class implements a child supervisor. * This class implements a child supervisor.
* *
*/ */
class ChildSupervisor: public ThreadNetifLocator class ChildSupervisor: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit ChildSupervisor(ThreadNetif &aThreadNetif); explicit ChildSupervisor(otInstance &aInstance);
/** /**
* This method starts the child supervision process on parent. * This method starts the child supervision process on parent.
@@ -168,7 +168,7 @@ private:
class ChildSupervisor class ChildSupervisor
{ {
public: public:
explicit ChildSupervisor(ThreadNetif &) { } explicit ChildSupervisor(otInstance &) { }
void Start(void) { } void Start(void) { }
void Stop(void) { } void Stop(void) { }
void SetSupervisionInterval(uint16_t) { } void SetSupervisionInterval(uint16_t) { }
@@ -185,16 +185,16 @@ public:
* This class implements a child supervision listener. * This class implements a child supervision listener.
* *
*/ */
class SupervisionListener: public ThreadNetifLocator class SupervisionListener: public InstanceLocator
{ {
public: public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit SupervisionListener(ThreadNetif &aThreadNetif); explicit SupervisionListener(otInstance &aInstance);
/** /**
* This method starts the supervision listener operation. * This method starts the supervision listener operation.
@@ -260,7 +260,7 @@ private:
class SupervisionListener class SupervisionListener
{ {
public: public:
SupervisionListener(ThreadNetif &) { } SupervisionListener(otInstance &) { }
void Start(void) { } void Start(void) { }
void Stop(void) { } void Stop(void) { }
void SetTimeout(uint16_t) { } void SetTimeout(uint16_t) { }
+3 -3
View File
@@ -45,12 +45,12 @@
namespace ot { namespace ot {
namespace Utils { namespace Utils {
JamDetector::JamDetector(ThreadNetif &aNetif) : JamDetector::JamDetector(otInstance &aInstance) :
ThreadNetifLocator(aNetif), InstanceLocator(aInstance),
mHandler(NULL), mHandler(NULL),
mContext(NULL), mContext(NULL),
mRssiThreshold(kDefaultRssiThreshold), mRssiThreshold(kDefaultRssiThreshold),
mTimer(aNetif.GetInstance(), &JamDetector::HandleTimer, this), mTimer(aInstance, &JamDetector::HandleTimer, this),
mHistoryBitmap(0), mHistoryBitmap(0),
mCurSecondStartTime(0), mCurSecondStartTime(0),
mSampleInterval(0), mSampleInterval(0),
+3 -3
View File
@@ -46,7 +46,7 @@ class ThreadNetif;
namespace Utils { namespace Utils {
class JamDetector: public ThreadNetifLocator class JamDetector: public InstanceLocator
{ {
public: public:
@@ -62,10 +62,10 @@ public:
/** /**
* This constructor initializes the object. * This constructor initializes the object.
* *
* @param[in] aThreadNetif A reference to the Thread network interface. * @param[in] aInstance A reference to the OpenThread instance.
* *
*/ */
explicit JamDetector(ThreadNetif &aThreadNetif); explicit JamDetector(otInstance &aInstance);
/** /**
* Start the jamming detection. * Start the jamming detection.
+1 -1
View File
@@ -40,7 +40,7 @@ class TestNetworkData: public NetworkData::NetworkData
{ {
public: public:
TestNetworkData(otInstance *aInstance, const uint8_t *aTlvs, uint8_t aTlvsLength): TestNetworkData(otInstance *aInstance, const uint8_t *aTlvs, uint8_t aTlvsLength):
NetworkData::NetworkData(aInstance->mThreadNetif, false) { NetworkData::NetworkData(*aInstance, false) {
memcpy(mTlvs, aTlvs, aTlvsLength); memcpy(mTlvs, aTlvs, aTlvsLength);
mLength = aTlvsLength; mLength = aTlvsLength;
} }