mirror of
https://github.com/espressif/openthread.git
synced 2026-08-31 22:39:54 +00:00
[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:
committed by
Jonathan Hui
parent
7b084eca71
commit
4cb17495b2
@@ -87,7 +87,7 @@ otInstance::otInstance(void) :
|
||||
mTimerMicroScheduler(*this),
|
||||
#endif
|
||||
mIp6(*this),
|
||||
mThreadNetif(mIp6),
|
||||
mThreadNetif(*this),
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
mLinkRaw(*this),
|
||||
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
@@ -48,15 +48,15 @@
|
||||
namespace ot {
|
||||
namespace Coap {
|
||||
|
||||
CoapBase::CoapBase(ThreadNetif &aNetif, Timer::Handler aRetransmissionTimerHandler,
|
||||
CoapBase::CoapBase(otInstance &aInstance, Timer::Handler aRetransmissionTimerHandler,
|
||||
Timer::Handler aResponsesQueueTimerHandler):
|
||||
ThreadNetifLocator(aNetif),
|
||||
mSocket(aNetif.GetIp6().mUdp),
|
||||
mRetransmissionTimer(aNetif.GetInstance(), aRetransmissionTimerHandler, this),
|
||||
InstanceLocator(aInstance),
|
||||
mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
|
||||
mRetransmissionTimer(aInstance, aRetransmissionTimerHandler, this),
|
||||
mResources(NULL),
|
||||
mContext(NULL),
|
||||
mInterceptor(NULL),
|
||||
mResponsesQueue(aNetif.GetInstance(), aResponsesQueueTimerHandler, this),
|
||||
mResponsesQueue(aInstance, aResponsesQueueTimerHandler, this),
|
||||
mDefaultHandler(NULL),
|
||||
mDefaultHandlerContext(NULL)
|
||||
{
|
||||
@@ -911,8 +911,8 @@ uint32_t EnqueuedResponseHeader::GetRemainingTime(void) const
|
||||
return remainingTime >= 0 ? static_cast<uint32_t>(remainingTime) : 0;
|
||||
}
|
||||
|
||||
Coap::Coap(ThreadNetif &aNetif):
|
||||
CoapBase(aNetif, &Coap::HandleRetransmissionTimer, &Coap::HandleResponsesQueueTimer)
|
||||
Coap::Coap(otInstance &aInstance):
|
||||
CoapBase(aInstance, &Coap::HandleRetransmissionTimer, &Coap::HandleResponsesQueueTimer)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -940,8 +940,7 @@ void Coap::HandleResponsesQueueTimer(Timer &aTimer)
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
|
||||
ApplicationCoap::ApplicationCoap(otInstance &aInstance):
|
||||
CoapBase(aInstance.mThreadNetif, &ApplicationCoap::HandleRetransmissionTimer,
|
||||
&ApplicationCoap::HandleResponsesQueueTimer)
|
||||
CoapBase(aInstance, &ApplicationCoap::HandleRetransmissionTimer, &ApplicationCoap::HandleResponsesQueueTimer)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@ private:
|
||||
* This class implements the common base for CoAP client and server.
|
||||
*
|
||||
*/
|
||||
class CoapBase: public ThreadNetifLocator
|
||||
class CoapBase: public InstanceLocator
|
||||
{
|
||||
friend class ResponsesQueue;
|
||||
|
||||
@@ -651,12 +651,12 @@ protected:
|
||||
/**
|
||||
* 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] 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);
|
||||
|
||||
/**
|
||||
@@ -744,10 +744,10 @@ public:
|
||||
/**
|
||||
* 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:
|
||||
static Coap &GetOwner(const Context &aContext);
|
||||
@@ -767,7 +767,7 @@ public:
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@@ -45,14 +45,14 @@
|
||||
namespace ot {
|
||||
namespace Coap {
|
||||
|
||||
CoapSecure::CoapSecure(ThreadNetif &aNetif):
|
||||
CoapBase(aNetif, &CoapSecure::HandleRetransmissionTimer, &CoapSecure::HandleResponsesQueueTimer),
|
||||
CoapSecure::CoapSecure(otInstance &aInstance):
|
||||
CoapBase(aInstance, &CoapSecure::HandleRetransmissionTimer, &CoapSecure::HandleResponsesQueueTimer),
|
||||
mConnectedCallback(NULL),
|
||||
mConnectedContext(NULL),
|
||||
mTransportCallback(NULL),
|
||||
mTransportContext(NULL),
|
||||
mTransmitMessage(NULL),
|
||||
mTransmitTask(aNetif.GetInstance(), &CoapSecure::HandleUdpTransmit, this)
|
||||
mTransmitTask(aInstance, &CoapSecure::HandleUdpTransmit, this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -40,23 +40,14 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
|
||||
otInstance &ThreadNetifLocator::GetInstance(void) const
|
||||
Ip6::Ip6 &InstanceLocator::GetIp6(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
|
||||
|
||||
+32
-156
@@ -43,175 +43,24 @@
|
||||
namespace ot {
|
||||
|
||||
class ThreadNetif;
|
||||
class MeshForwarder;
|
||||
class TaskletScheduler;
|
||||
namespace Ip6 { class Ip6; }
|
||||
|
||||
/**
|
||||
* @addtogroup core-locator
|
||||
*
|
||||
* @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>
|
||||
{
|
||||
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>
|
||||
class InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -221,11 +70,27 @@ public:
|
||||
*
|
||||
*/
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
otInstance &GetInstance(void) const { return mLocatorObject; }
|
||||
otInstance &GetInstance(void) const { return mInstance; }
|
||||
#else
|
||||
otInstance &GetInstance(void) const { return *otGetInstance(); }
|
||||
#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:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
@@ -233,7 +98,18 @@ protected:
|
||||
* @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
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -136,11 +136,11 @@ void Mac::StartCsmaBackoff(void)
|
||||
}
|
||||
}
|
||||
|
||||
Mac::Mac(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mMacTimer(aThreadNetif.GetInstance(), &Mac::HandleMacTimer, this),
|
||||
mBackoffTimer(aThreadNetif.GetInstance(), &Mac::HandleBeginTransmit, this),
|
||||
mReceiveTimer(aThreadNetif.GetInstance(), &Mac::HandleReceiveTimer, this),
|
||||
Mac::Mac(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mMacTimer(aInstance, &Mac::HandleMacTimer, this),
|
||||
mBackoffTimer(aInstance, &Mac::HandleBeginTransmit, this),
|
||||
mReceiveTimer(aInstance, &Mac::HandleReceiveTimer, this),
|
||||
mShortAddress(kShortAddrInvalid),
|
||||
mPanId(kPanIdBroadcast),
|
||||
mChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL),
|
||||
@@ -170,13 +170,13 @@ Mac::Mac(ThreadNetif &aThreadNetif):
|
||||
mEnergyScanCurrentMaxRssi(kInvalidRssiValue),
|
||||
mScanContext(NULL),
|
||||
mActiveScanHandler(NULL), // Initialize `mActiveScanHandler` and `mEnergyScanHandler` union
|
||||
mEnergyScanSampleRssiTask(aThreadNetif.GetInstance(), &Mac::HandleEnergyScanSampleRssi, this),
|
||||
mEnergyScanSampleRssiTask(aInstance, &Mac::HandleEnergyScanSampleRssi, this),
|
||||
mPcapCallback(NULL),
|
||||
mPcapCallbackContext(NULL),
|
||||
#if OPENTHREAD_ENABLE_MAC_FILTER
|
||||
mFilter(),
|
||||
#endif // OPENTHREAD_ENABLE_MAC_FILTER
|
||||
mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(&aThreadNetif.GetInstance()))),
|
||||
mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(&aInstance))),
|
||||
mKeyIdMode2FrameCounter(0)
|
||||
{
|
||||
GenerateExtAddress(&mExtAddress);
|
||||
|
||||
@@ -211,16 +211,16 @@ private:
|
||||
* This class implements the IEEE 802.15.4 MAC.
|
||||
*
|
||||
*/
|
||||
class Mac: public ThreadNetifLocator
|
||||
class Mac: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
AnnounceBeginClient::AnnounceBeginClient(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif)
|
||||
AnnounceBeginClient::AnnounceBeginClient(otInstance &aInstance):
|
||||
InstanceLocator(aInstance)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ namespace ot {
|
||||
* This class implements handling Announce Begin Requests.
|
||||
*
|
||||
*/
|
||||
class AnnounceBeginClient: public ThreadNetifLocator
|
||||
class AnnounceBeginClient: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
AnnounceBeginClient(ThreadNetif &aThreadNetif);
|
||||
AnnounceBeginClient(otInstance &aInstance);
|
||||
|
||||
/**
|
||||
* This method sends a Announce Begin message.
|
||||
|
||||
@@ -60,16 +60,16 @@ using ot::Encoding::BigEndian::HostSwap64;
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
Commissioner::Commissioner(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mAnnounceBegin(aThreadNetif),
|
||||
mEnergyScan(aThreadNetif),
|
||||
mPanIdQuery(aThreadNetif),
|
||||
Commissioner::Commissioner(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mAnnounceBegin(aInstance),
|
||||
mEnergyScan(aInstance),
|
||||
mPanIdQuery(aInstance),
|
||||
mState(OT_COMMISSIONER_STATE_DISABLED),
|
||||
mJoinerPort(0),
|
||||
mJoinerRloc(0),
|
||||
mJoinerExpirationTimer(aThreadNetif.GetInstance(), HandleJoinerExpirationTimer, this),
|
||||
mTimer(aThreadNetif.GetInstance(), HandleTimer, this),
|
||||
mJoinerExpirationTimer(aInstance, HandleJoinerExpirationTimer, this),
|
||||
mTimer(aInstance, HandleTimer, this),
|
||||
mSessionId(0),
|
||||
mTransmitAttempts(0),
|
||||
mRelayReceive(OT_URI_PATH_RELAY_RX, &Commissioner::HandleRelayReceive, this),
|
||||
|
||||
@@ -56,16 +56,16 @@ class ThreadNetif;
|
||||
|
||||
namespace MeshCoP {
|
||||
|
||||
class Commissioner: public ThreadNetifLocator
|
||||
class Commissioner: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -59,12 +59,12 @@
|
||||
namespace ot {
|
||||
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):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mLocal(aThreadNetif.GetInstance(), aType),
|
||||
InstanceLocator(aInstance),
|
||||
mLocal(aInstance, aType),
|
||||
mNetwork(aType),
|
||||
mTimer(aThreadNetif.GetInstance(), aTimerHandler, this),
|
||||
mTimer(aInstance, aTimerHandler, this),
|
||||
mUriSet(aUriSet),
|
||||
mUriGet(aUriGet)
|
||||
{
|
||||
@@ -959,12 +959,12 @@ static ActiveDatasetBase &GetActiveDatasetOwner(const Context &aContext)
|
||||
return activeDataset;
|
||||
}
|
||||
|
||||
ActiveDatasetBase::ActiveDatasetBase(ThreadNetif &aThreadNetif):
|
||||
DatasetManager(aThreadNetif, Tlv::kActiveTimestamp, OT_URI_PATH_ACTIVE_SET, OT_URI_PATH_ACTIVE_GET,
|
||||
ActiveDatasetBase::ActiveDatasetBase(otInstance &aInstance):
|
||||
DatasetManager(aInstance, Tlv::kActiveTimestamp, OT_URI_PATH_ACTIVE_SET, OT_URI_PATH_ACTIVE_GET,
|
||||
&ActiveDatasetBase::HandleTimer),
|
||||
mResourceGet(OT_URI_PATH_ACTIVE_GET, &ActiveDatasetBase::HandleGet, this)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mResourceGet);
|
||||
GetNetif().GetCoap().AddResource(mResourceGet);
|
||||
}
|
||||
|
||||
otError ActiveDatasetBase::Restore(void)
|
||||
@@ -1057,13 +1057,13 @@ static PendingDatasetBase &GetPendingDatasetOwner(const Context &aContext)
|
||||
return pendingDataset;
|
||||
}
|
||||
|
||||
PendingDatasetBase::PendingDatasetBase(ThreadNetif &aThreadNetif):
|
||||
DatasetManager(aThreadNetif, Tlv::kPendingTimestamp, OT_URI_PATH_PENDING_SET, OT_URI_PATH_PENDING_GET,
|
||||
PendingDatasetBase::PendingDatasetBase(otInstance &aInstance):
|
||||
DatasetManager(aInstance, Tlv::kPendingTimestamp, OT_URI_PATH_PENDING_SET, OT_URI_PATH_PENDING_GET,
|
||||
&PendingDatasetBase::HandleTimer),
|
||||
mDelayTimer(aThreadNetif.GetInstance(), &PendingDatasetBase::HandleDelayTimer, this),
|
||||
mDelayTimer(aInstance, &PendingDatasetBase::HandleDelayTimer, this),
|
||||
mResourceGet(OT_URI_PATH_PENDING_GET, &PendingDatasetBase::HandleGet, this)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mResourceGet);
|
||||
GetNetif().GetCoap().AddResource(mResourceGet);
|
||||
}
|
||||
|
||||
otError PendingDatasetBase::Restore(void)
|
||||
|
||||
@@ -54,7 +54,7 @@ class ThreadNetif;
|
||||
|
||||
namespace MeshCoP {
|
||||
|
||||
class DatasetManager: public ThreadNetifLocator
|
||||
class DatasetManager: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -125,14 +125,14 @@ protected:
|
||||
/**
|
||||
* 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] aUriSet The URI-PATH for setting the Operational Dataset.
|
||||
* @param[in] aUriGet The URI-PATH for getting the Operational Dataset.
|
||||
* @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);
|
||||
|
||||
/**
|
||||
@@ -279,10 +279,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
@@ -364,7 +364,7 @@ public:
|
||||
* @param[in] The Thread network interface.
|
||||
*
|
||||
*/
|
||||
PendingDatasetBase(ThreadNetif &aThreadNetif);
|
||||
PendingDatasetBase(otInstance &aInstance);
|
||||
|
||||
/**
|
||||
* This method restores the Operational Dataset from non-volatile memory.
|
||||
|
||||
@@ -60,8 +60,8 @@
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
ActiveDataset::ActiveDataset(ThreadNetif &aThreadNetif):
|
||||
ActiveDatasetBase(aThreadNetif),
|
||||
ActiveDataset::ActiveDataset(otInstance &aInstance):
|
||||
ActiveDatasetBase(aInstance),
|
||||
mResourceSet(OT_URI_PATH_ACTIVE_SET, &ActiveDataset::HandleSet, this)
|
||||
{
|
||||
}
|
||||
@@ -207,8 +207,8 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
PendingDataset::PendingDataset(ThreadNetif &aThreadNetif):
|
||||
PendingDatasetBase(aThreadNetif),
|
||||
PendingDataset::PendingDataset(otInstance &aInstance):
|
||||
PendingDatasetBase(aInstance),
|
||||
mResourceSet(OT_URI_PATH_PENDING_SET, &PendingDataset::HandleSet, this)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace MeshCoP {
|
||||
class ActiveDataset: public ActiveDatasetBase
|
||||
{
|
||||
public:
|
||||
ActiveDataset(ThreadNetif &aThreadNetif);
|
||||
ActiveDataset(otInstance &aInstance);
|
||||
|
||||
otError GenerateLocal(void);
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
class PendingDataset: public PendingDatasetBase
|
||||
{
|
||||
public:
|
||||
PendingDataset(ThreadNetif &aThreadNetif);
|
||||
PendingDataset(otInstance &aInstance);
|
||||
|
||||
void StartLeader(void);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace MeshCoP {
|
||||
class ActiveDataset: public ActiveDatasetBase
|
||||
{
|
||||
public:
|
||||
ActiveDataset(ThreadNetif &aThreadNetif) : ActiveDatasetBase(aThreadNetif) { }
|
||||
ActiveDataset(otInstance &aInstance) : ActiveDatasetBase(aInstance) { }
|
||||
|
||||
otError GenerateLocal(void) { return OT_ERROR_NOT_IMPLEMENTED; }
|
||||
};
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
class PendingDataset: public PendingDatasetBase
|
||||
{
|
||||
public:
|
||||
PendingDataset(ThreadNetif &aThreadNetif) : PendingDatasetBase(aThreadNetif) { }
|
||||
PendingDataset(otInstance &aInstance) : PendingDatasetBase(aInstance) { }
|
||||
};
|
||||
|
||||
} // namespace MeshCoP
|
||||
|
||||
@@ -52,11 +52,11 @@
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
Dtls::Dtls(ThreadNetif &aNetif):
|
||||
ThreadNetifLocator(aNetif),
|
||||
Dtls::Dtls(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mPskLength(0),
|
||||
mStarted(false),
|
||||
mTimer(aNetif.GetInstance(), &Dtls::HandleTimer, this),
|
||||
mTimer(aInstance, &Dtls::HandleTimer, this),
|
||||
mTimerIntermediate(0),
|
||||
mTimerSet(false),
|
||||
mReceiveMessage(NULL),
|
||||
|
||||
@@ -57,7 +57,7 @@ class ThreadNetif;
|
||||
|
||||
namespace MeshCoP {
|
||||
|
||||
class Dtls: public ThreadNetifLocator
|
||||
class Dtls: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
* @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.
|
||||
|
||||
@@ -54,13 +54,13 @@ using ot::Encoding::BigEndian::HostSwap32;
|
||||
|
||||
namespace ot {
|
||||
|
||||
EnergyScanClient::EnergyScanClient(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
EnergyScanClient::EnergyScanClient(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mEnergyScan(OT_URI_PATH_ENERGY_REPORT, &EnergyScanClient::HandleReport, this)
|
||||
{
|
||||
mContext = NULL;
|
||||
mCallback = NULL;
|
||||
aThreadNetif.GetCoap().AddResource(mEnergyScan);
|
||||
GetNetif().GetCoap().AddResource(mEnergyScan);
|
||||
}
|
||||
|
||||
otError EnergyScanClient::SendQuery(uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod,
|
||||
|
||||
@@ -51,14 +51,14 @@ class ThreadNetif;
|
||||
* This class implements handling PANID Query Requests.
|
||||
*
|
||||
*/
|
||||
class EnergyScanClient: public ThreadNetifLocator
|
||||
class EnergyScanClient: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
EnergyScanClient(ThreadNetif &aThreadNetif);
|
||||
EnergyScanClient(otInstance &aInstance);
|
||||
|
||||
/**
|
||||
* This method sends an Energy Scan Query message.
|
||||
|
||||
@@ -58,8 +58,8 @@ using ot::Encoding::BigEndian::HostSwap64;
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
Joiner::Joiner(ThreadNetif &aNetif):
|
||||
ThreadNetifLocator(aNetif),
|
||||
Joiner::Joiner(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mState(OT_JOINER_STATE_IDLE),
|
||||
mCallback(NULL),
|
||||
mContext(NULL),
|
||||
@@ -69,11 +69,11 @@ Joiner::Joiner(ThreadNetif &aNetif):
|
||||
mVendorModel(NULL),
|
||||
mVendorSwVersion(NULL),
|
||||
mVendorData(NULL),
|
||||
mTimer(aNetif.GetInstance(), &Joiner::HandleTimer, this),
|
||||
mTimer(aInstance, &Joiner::HandleTimer, this),
|
||||
mJoinerEntrust(OT_URI_PATH_JOINER_ENTRUST, &Joiner::HandleJoinerEntrust, this)
|
||||
{
|
||||
memset(mJoinerRouters, 0, sizeof(mJoinerRouters));
|
||||
aNetif.GetCoap().AddResource(mJoinerEntrust);
|
||||
GetNetif().GetCoap().AddResource(mJoinerEntrust);
|
||||
}
|
||||
|
||||
otError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl,
|
||||
|
||||
@@ -54,16 +54,16 @@ class ThreadNetif;
|
||||
|
||||
namespace MeshCoP {
|
||||
|
||||
class Joiner: public ThreadNetifLocator
|
||||
class Joiner: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -55,19 +55,19 @@ using ot::Encoding::BigEndian::HostSwap64;
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
JoinerRouter::JoinerRouter(ThreadNetif &aNetif):
|
||||
ThreadNetifLocator(aNetif),
|
||||
mSocket(aNetif.GetIp6().mUdp),
|
||||
JoinerRouter::JoinerRouter(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
|
||||
mRelayTransmit(OT_URI_PATH_RELAY_TX, &JoinerRouter::HandleRelayTransmit, this),
|
||||
mTimer(aNetif.GetInstance(), &JoinerRouter::HandleTimer, this),
|
||||
mTimer(aInstance, &JoinerRouter::HandleTimer, this),
|
||||
mJoinerUdpPort(0),
|
||||
mIsJoinerPortConfigured(false),
|
||||
mExpectJoinEntRsp(false)
|
||||
{
|
||||
mSocket.GetSockName().mPort = OPENTHREAD_CONFIG_JOINER_UDP_PORT;
|
||||
aNetif.GetCoap().AddResource(mRelayTransmit);
|
||||
GetNetif().GetCoap().AddResource(mRelayTransmit);
|
||||
mNetifCallback.Set(HandleNetifStateChanged, this);
|
||||
aNetif.RegisterCallback(mNetifCallback);
|
||||
GetNetif().RegisterCallback(mNetifCallback);
|
||||
}
|
||||
|
||||
void JoinerRouter::HandleNetifStateChanged(uint32_t aFlags, void *aContext)
|
||||
|
||||
@@ -54,16 +54,16 @@ class ThreadNetif;
|
||||
|
||||
namespace MeshCoP {
|
||||
|
||||
class JoinerRouter: public ThreadNetifLocator
|
||||
class JoinerRouter: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -54,16 +54,16 @@
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
Leader::Leader(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
Leader::Leader(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mPetition(OT_URI_PATH_LEADER_PETITION, Leader::HandlePetition, this),
|
||||
mKeepAlive(OT_URI_PATH_LEADER_KEEP_ALIVE, Leader::HandleKeepAlive, this),
|
||||
mTimer(aThreadNetif.GetInstance(), HandleTimer, this),
|
||||
mTimer(aInstance, HandleTimer, this),
|
||||
mDelayTimerMinimal(DelayTimerTlv::kDelayTimerMinimal),
|
||||
mSessionId(0xffff)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mPetition);
|
||||
aThreadNetif.GetCoap().AddResource(mKeepAlive);
|
||||
GetNetif().GetCoap().AddResource(mPetition);
|
||||
GetNetif().GetCoap().AddResource(mKeepAlive);
|
||||
}
|
||||
|
||||
void Leader::HandlePetition(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
|
||||
|
||||
@@ -61,16 +61,16 @@ public:
|
||||
SteeringDataTlv mSteeringData;
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
class Leader: public ThreadNetifLocator
|
||||
class Leader: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -50,13 +50,13 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
PanIdQueryClient::PanIdQueryClient(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
PanIdQueryClient::PanIdQueryClient(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mCallback(NULL),
|
||||
mContext(NULL),
|
||||
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,
|
||||
|
||||
@@ -51,14 +51,14 @@ class ThreadNetif;
|
||||
* This class implements handling PANID Query Requests.
|
||||
*
|
||||
*/
|
||||
class PanIdQueryClient: public ThreadNetifLocator
|
||||
class PanIdQueryClient: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
PanIdQueryClient(ThreadNetif &aThreadNetif);
|
||||
PanIdQueryClient(otInstance &aInstance);
|
||||
|
||||
/**
|
||||
* This method sends a PAN ID Query message.
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/random.h>
|
||||
|
||||
#include "openthread-instance.h"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/logging.hpp"
|
||||
@@ -55,10 +56,10 @@ namespace ot {
|
||||
|
||||
namespace Dhcp6 {
|
||||
|
||||
Dhcp6Client::Dhcp6Client(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mTrickleTimer(aThreadNetif.GetInstance(), &Dhcp6Client::HandleTrickleTimer, NULL, this),
|
||||
mSocket(aThreadNetif.GetIp6().mUdp),
|
||||
Dhcp6Client::Dhcp6Client(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mTrickleTimer(aInstance, &Dhcp6Client::HandleTrickleTimer, NULL, this),
|
||||
mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
|
||||
mStartTime(0),
|
||||
mAddresses(NULL),
|
||||
mNumAddresses(0)
|
||||
|
||||
@@ -170,16 +170,16 @@ private:
|
||||
* This class implements DHCPv6 Client.
|
||||
*
|
||||
*/
|
||||
class Dhcp6Client: public ThreadNetifLocator
|
||||
class Dhcp6Client: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -51,9 +51,9 @@ using ot::Encoding::BigEndian::HostSwap32;
|
||||
namespace ot {
|
||||
namespace Dhcp6 {
|
||||
|
||||
Dhcp6Server::Dhcp6Server(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mSocket(aThreadNetif.GetIp6().mUdp)
|
||||
Dhcp6Server::Dhcp6Server(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mSocket(GetNetif().GetIp6().mUdp)
|
||||
{
|
||||
for (uint8_t i = 0; i < OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES; i++)
|
||||
{
|
||||
|
||||
@@ -102,16 +102,16 @@ private:
|
||||
otIp6Prefix mIp6Prefix; ///< prefix
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
class Dhcp6Server: public ThreadNetifLocator
|
||||
class Dhcp6Server: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -48,8 +48,8 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
namespace ot {
|
||||
namespace Ip6 {
|
||||
|
||||
Icmp::Icmp(Ip6 &aIp6):
|
||||
Ip6Locator(aIp6),
|
||||
Icmp::Icmp(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mHandlers(NULL),
|
||||
mEchoSequence(1),
|
||||
mIsEchoEnabled(true)
|
||||
|
||||
@@ -222,16 +222,16 @@ private:
|
||||
* This class implements ICMPv6.
|
||||
*
|
||||
*/
|
||||
class Icmp: public Ip6Locator
|
||||
class Icmp: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace Ip6 {
|
||||
|
||||
Ip6::Ip6(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mRoutes(*this),
|
||||
mIcmp(*this),
|
||||
mUdp(*this),
|
||||
mMpl(*this),
|
||||
mRoutes(aInstance),
|
||||
mIcmp(aInstance),
|
||||
mUdp(aInstance),
|
||||
mMpl(aInstance),
|
||||
mForwardingEnabled(false),
|
||||
mSendQueueTask(aInstance, HandleSendQueue, this),
|
||||
mReceiveIp6DatagramCallback(NULL),
|
||||
|
||||
@@ -53,10 +53,10 @@ void MplBufferedMessageMetadata::GenerateNextTransmissionTime(uint32_t aCurrentT
|
||||
SetIntervalOffset(aInterval - t);
|
||||
}
|
||||
|
||||
Mpl::Mpl(Ip6 &aIp6):
|
||||
Ip6Locator(aIp6),
|
||||
mSeedSetTimer(aIp6.GetInstance(), &Mpl::HandleSeedSetTimer, this),
|
||||
mRetransmissionTimer(aIp6.GetInstance(), &Mpl::HandleRetransmissionTimer, this),
|
||||
Mpl::Mpl(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mSeedSetTimer(aInstance, &Mpl::HandleSeedSetTimer, this),
|
||||
mRetransmissionTimer(aInstance, &Mpl::HandleRetransmissionTimer, this),
|
||||
mTimerExpirations(0),
|
||||
mSequence(0),
|
||||
mSeedId(0),
|
||||
|
||||
@@ -430,16 +430,16 @@ private:
|
||||
* This class implements MPL message processing.
|
||||
*
|
||||
*/
|
||||
class Mpl: public Ip6Locator
|
||||
class Mpl: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
namespace ot {
|
||||
namespace Ip6 {
|
||||
|
||||
Routes::Routes(Ip6 &aIp6):
|
||||
Ip6Locator(aIp6),
|
||||
Routes::Routes(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mRoutes(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,16 +71,16 @@ struct Route
|
||||
* This class implements IPv6 route management.
|
||||
*
|
||||
*/
|
||||
class Routes: public Ip6Locator
|
||||
class Routes: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -90,14 +90,14 @@ const otNetifMulticastAddress Netif::kLinkLocalAllRoutersMulticastAddress =
|
||||
};
|
||||
|
||||
|
||||
Netif::Netif(Ip6 &aIp6, int8_t aInterfaceId):
|
||||
Ip6Locator(aIp6),
|
||||
Netif::Netif(otInstance &aInstance, int8_t aInterfaceId):
|
||||
InstanceLocator(aInstance),
|
||||
mCallbacks(NULL),
|
||||
mUnicastAddresses(NULL),
|
||||
mMulticastAddresses(NULL),
|
||||
mInterfaceId(aInterfaceId),
|
||||
mMulticastPromiscuous(false),
|
||||
mStateChangedTask(aIp6.GetInstance(), &Netif::HandleStateChangedTask, this),
|
||||
mStateChangedTask(aInstance, &Netif::HandleStateChangedTask, this),
|
||||
mNext(NULL),
|
||||
mStateChangedFlags(0)
|
||||
{
|
||||
|
||||
@@ -252,7 +252,7 @@ private:
|
||||
* This class implements an IPv6 network interface.
|
||||
*
|
||||
*/
|
||||
class Netif: public Ip6Locator
|
||||
class Netif: public InstanceLocator
|
||||
{
|
||||
friend class Ip6;
|
||||
|
||||
@@ -260,11 +260,11 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
Netif(Ip6 &aIp6, int8_t aInterfaceId);
|
||||
Netif(otInstance &aInstance, int8_t aInterfaceId);
|
||||
|
||||
/**
|
||||
* This method returns the next network interface in the list.
|
||||
|
||||
@@ -138,8 +138,8 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Udp::Udp(Ip6 &aIp6):
|
||||
Ip6Locator(aIp6),
|
||||
Udp::Udp(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mEphemeralPort(kDynamicPortMin),
|
||||
mSockets(NULL)
|
||||
{
|
||||
|
||||
@@ -164,7 +164,7 @@ private:
|
||||
* This class implements core UDP message handling.
|
||||
*
|
||||
*/
|
||||
class Udp: public Ip6Locator
|
||||
class Udp: public InstanceLocator
|
||||
{
|
||||
friend class UdpSocket;
|
||||
|
||||
@@ -172,10 +172,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -108,14 +108,4 @@ typedef struct 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_
|
||||
|
||||
@@ -56,21 +56,21 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
|
||||
namespace ot {
|
||||
|
||||
AddressResolver::AddressResolver(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
AddressResolver::AddressResolver(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mAddressError(OT_URI_PATH_ADDRESS_ERROR, &AddressResolver::HandleAddressError, this),
|
||||
mAddressQuery(OT_URI_PATH_ADDRESS_QUERY, &AddressResolver::HandleAddressQuery, this),
|
||||
mAddressNotification(OT_URI_PATH_ADDRESS_NOTIFY, &AddressResolver::HandleAddressNotification, this),
|
||||
mIcmpHandler(&AddressResolver::HandleIcmpReceive, this),
|
||||
mTimer(aThreadNetif.GetInstance(), &AddressResolver::HandleTimer, this)
|
||||
mTimer(aInstance, &AddressResolver::HandleTimer, this)
|
||||
{
|
||||
Clear();
|
||||
|
||||
aThreadNetif.GetCoap().AddResource(mAddressError);
|
||||
aThreadNetif.GetCoap().AddResource(mAddressQuery);
|
||||
aThreadNetif.GetCoap().AddResource(mAddressNotification);
|
||||
GetNetif().GetCoap().AddResource(mAddressError);
|
||||
GetNetif().GetCoap().AddResource(mAddressQuery);
|
||||
GetNetif().GetCoap().AddResource(mAddressNotification);
|
||||
|
||||
aThreadNetif.GetIp6().mIcmp.RegisterHandler(mIcmpHandler);
|
||||
GetNetif().GetIp6().mIcmp.RegisterHandler(mIcmpHandler);
|
||||
}
|
||||
|
||||
void AddressResolver::Clear()
|
||||
|
||||
@@ -66,14 +66,14 @@ class ThreadTargetTlv;
|
||||
* This class implements the EID-to-RLOC mapping and caching.
|
||||
*
|
||||
*/
|
||||
class AddressResolver: public ThreadNetifLocator
|
||||
class AddressResolver: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
explicit AddressResolver(ThreadNetif &aThreadNetif);
|
||||
explicit AddressResolver(otInstance &aInstance);
|
||||
|
||||
/**
|
||||
* This method clears the EID-to-RLOC cache.
|
||||
|
||||
@@ -50,16 +50,16 @@ using ot::Encoding::BigEndian::HostSwap32;
|
||||
|
||||
namespace ot {
|
||||
|
||||
AnnounceBeginServer::AnnounceBeginServer(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
AnnounceBeginServer::AnnounceBeginServer(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mChannelMask(0),
|
||||
mPeriod(0),
|
||||
mCount(0),
|
||||
mChannel(0),
|
||||
mTimer(aThreadNetif.GetInstance(), &AnnounceBeginServer::HandleTimer, this),
|
||||
mTimer(aInstance, &AnnounceBeginServer::HandleTimer, this),
|
||||
mAnnounceBegin(OT_URI_PATH_ANNOUNCE_BEGIN, &AnnounceBeginServer::HandleRequest, this)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mAnnounceBegin);
|
||||
GetNetif().GetCoap().AddResource(mAnnounceBegin);
|
||||
}
|
||||
|
||||
otError AnnounceBeginServer::SendAnnounce(uint32_t aChannelMask)
|
||||
|
||||
@@ -49,14 +49,14 @@ namespace ot {
|
||||
* This class implements handling Announce Begin Requests.
|
||||
*
|
||||
*/
|
||||
class AnnounceBeginServer: public ThreadNetifLocator
|
||||
class AnnounceBeginServer: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
DataPollManager::DataPollManager(MeshForwarder &aMeshForwarder):
|
||||
MeshForwarderLocator(aMeshForwarder),
|
||||
mTimer(aMeshForwarder.GetInstance(), &DataPollManager::HandlePollTimer, this),
|
||||
DataPollManager::DataPollManager(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mTimer(aInstance, &DataPollManager::HandlePollTimer, this),
|
||||
mTimerStartTime(0),
|
||||
mExternalPollPeriod(0),
|
||||
mPollPeriod(0),
|
||||
@@ -70,7 +70,7 @@ otError DataPollManager::StartPolling(void)
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
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);
|
||||
|
||||
mEnabled = true;
|
||||
@@ -94,20 +94,20 @@ void DataPollManager::StopPolling(void)
|
||||
|
||||
otError DataPollManager::SendDataPoll(void)
|
||||
{
|
||||
MeshForwarder &meshForwarder = GetMeshForwarder();
|
||||
ThreadNetif &netif = GetNetif();
|
||||
otError error;
|
||||
Message *message;
|
||||
Neighbor *parent;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ otError DataPollManager::SendDataPoll(void)
|
||||
message = GetInstance().mMessagePool.New(Message::kTypeMacDataPoll, 0);
|
||||
VerifyOrExit(message != NULL, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
error = meshForwarder.SendMessage(*message);
|
||||
error = netif.GetMeshForwarder().SendMessage(*message);
|
||||
|
||||
if (error != OT_ERROR_NONE)
|
||||
{
|
||||
@@ -426,7 +426,7 @@ DataPollManager &DataPollManager::GetOwner(Context &aContext)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace ot {
|
||||
*
|
||||
*/
|
||||
|
||||
class DataPollManager: public MeshForwarderLocator
|
||||
class DataPollManager: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -71,10 +71,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
EnergyScanServer::EnergyScanServer(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
EnergyScanServer::EnergyScanServer(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mChannelMask(0),
|
||||
mChannelMaskCurrent(0),
|
||||
mPeriod(0),
|
||||
@@ -58,13 +58,13 @@ EnergyScanServer::EnergyScanServer(ThreadNetif &aThreadNetif) :
|
||||
mCount(0),
|
||||
mActive(false),
|
||||
mScanResultsLength(0),
|
||||
mTimer(aThreadNetif.GetInstance(), &EnergyScanServer::HandleTimer, this),
|
||||
mTimer(aInstance, &EnergyScanServer::HandleTimer, this),
|
||||
mEnergyScan(OT_URI_PATH_ENERGY_SCAN, &EnergyScanServer::HandleRequest, 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,
|
||||
|
||||
@@ -56,14 +56,14 @@ class ThreadTargetTlv;
|
||||
* This class implements handling Energy Scan Requests.
|
||||
*
|
||||
*/
|
||||
class EnergyScanServer: public ThreadNetifLocator
|
||||
class EnergyScanServer: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
EnergyScanServer(ThreadNetif &aThreadNetif);
|
||||
EnergyScanServer(otInstance &aInstance);
|
||||
|
||||
private:
|
||||
enum
|
||||
|
||||
@@ -47,8 +47,8 @@ static const uint8_t kThreadString[] =
|
||||
'T', 'h', 'r', 'e', 'a', 'd',
|
||||
};
|
||||
|
||||
KeyManager::KeyManager(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
KeyManager::KeyManager(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mKeySequence(0),
|
||||
mMacFrameCounter(0),
|
||||
mMleFrameCounter(0),
|
||||
@@ -58,7 +58,7 @@ KeyManager::KeyManager(ThreadNetif &aThreadNetif):
|
||||
mKeyRotationTime(kDefaultKeyRotationTime),
|
||||
mKeySwitchGuardTime(kDefaultKeySwitchGuardTime),
|
||||
mKeySwitchGuardEnabled(false),
|
||||
mKeyRotationTimer(aThreadNetif.GetInstance(), &KeyManager::HandleKeyRotationTimer, this),
|
||||
mKeyRotationTimer(aInstance, &KeyManager::HandleKeyRotationTimer, this),
|
||||
mKekFrameCounter(0),
|
||||
mSecurityPolicyFlags(0xff)
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace ot {
|
||||
* @{
|
||||
*/
|
||||
|
||||
class KeyManager: public ThreadNetifLocator
|
||||
class KeyManager: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -66,10 +66,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -46,8 +46,8 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
namespace ot {
|
||||
namespace Lowpan {
|
||||
|
||||
Lowpan::Lowpan(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif)
|
||||
Lowpan::Lowpan(otInstance &aInstance):
|
||||
InstanceLocator(aInstance)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -78,16 +78,16 @@ struct Context
|
||||
* This class implements LOWPAN_IPHC header compression.
|
||||
*
|
||||
*/
|
||||
class Lowpan: public ThreadNetifLocator
|
||||
class Lowpan: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -56,12 +56,12 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
|
||||
namespace ot {
|
||||
|
||||
MeshForwarder::MeshForwarder(ThreadNetif &aThreadNetif):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
MeshForwarder::MeshForwarder(otInstance &aInstance):
|
||||
InstanceLocator(aInstance),
|
||||
mMacReceiver(&MeshForwarder::HandleReceivedFrame, &MeshForwarder::HandleDataPollTimeout, this),
|
||||
mMacSender(&MeshForwarder::HandleFrameRequest, &MeshForwarder::HandleSentFrame, this),
|
||||
mDiscoverTimer(aThreadNetif.GetInstance(), &MeshForwarder::HandleDiscoverTimer, this),
|
||||
mReassemblyTimer(aThreadNetif.GetInstance(), &MeshForwarder::HandleReassemblyTimer, this),
|
||||
mDiscoverTimer(aInstance, &MeshForwarder::HandleDiscoverTimer, this),
|
||||
mReassemblyTimer(aInstance, &MeshForwarder::HandleReassemblyTimer, this),
|
||||
mMessageNextOffset(0),
|
||||
mSendMessageFrameCounter(0),
|
||||
mSendMessage(NULL),
|
||||
@@ -74,18 +74,18 @@ MeshForwarder::MeshForwarder(ThreadNetif &aThreadNetif):
|
||||
mMeshDest(Mac::kShortAddrInvalid),
|
||||
mAddMeshHeader(false),
|
||||
mSendBusy(false),
|
||||
mScheduleTransmissionTask(aThreadNetif.GetInstance(), ScheduleTransmissionTask, this),
|
||||
mScheduleTransmissionTask(aInstance, ScheduleTransmissionTask, this),
|
||||
mEnabled(false),
|
||||
mScanChannels(0),
|
||||
mScanChannel(0),
|
||||
mRestoreChannel(0),
|
||||
mRestorePanId(Mac::kPanIdBroadcast),
|
||||
mScanning(false),
|
||||
mDataPollManager(*this),
|
||||
mSourceMatchController(*this)
|
||||
mDataPollManager(aInstance),
|
||||
mSourceMatchController(aInstance)
|
||||
{
|
||||
mFragTag = static_cast<uint16_t>(otPlatRandomGet());
|
||||
aThreadNetif.GetMac().RegisterReceiver(mMacReceiver);
|
||||
GetNetif().GetMac().RegisterReceiver(mMacReceiver);
|
||||
mMacSource.mLength = 0;
|
||||
mMacDest.mLength = 0;
|
||||
|
||||
|
||||
@@ -71,16 +71,16 @@ class MleRouter;
|
||||
* This class implements mesh forwarding within Thread.
|
||||
*
|
||||
*/
|
||||
class MeshForwarder: public ThreadNetifLocator
|
||||
class MeshForwarder: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
+11
-11
@@ -60,15 +60,15 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
namespace ot {
|
||||
namespace Mle {
|
||||
|
||||
Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
Mle::Mle(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mRetrieveNewNetworkData(false),
|
||||
mRole(OT_DEVICE_ROLE_DISABLED),
|
||||
mDeviceMode(ModeTlv::kModeRxOnWhenIdle | ModeTlv::kModeSecureDataRequest),
|
||||
mParentRequestState(kParentIdle),
|
||||
mReattachState(kReattachStop),
|
||||
mParentRequestTimer(aThreadNetif.GetInstance(), &Mle::HandleParentRequestTimer, this),
|
||||
mDelayedResponseTimer(aThreadNetif.GetInstance(), &Mle::HandleDelayedResponseTimer, this),
|
||||
mParentRequestTimer(aInstance, &Mle::HandleParentRequestTimer, this),
|
||||
mDelayedResponseTimer(aInstance, &Mle::HandleDelayedResponseTimer, this),
|
||||
mLastPartitionId(0),
|
||||
mLastPartitionRouterIdSequence(0),
|
||||
mLastPartitionIdTimeout(0),
|
||||
@@ -81,9 +81,9 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
mChildUpdateAttempts(0),
|
||||
mParentLinkMargin(0),
|
||||
mParentIsSingleton(false),
|
||||
mSocket(aThreadNetif.GetIp6().mUdp),
|
||||
mSocket(aInstance.mThreadNetif.GetIp6().mUdp),
|
||||
mTimeout(kMleEndDeviceTimeout),
|
||||
mSendChildUpdateRequest(aThreadNetif.GetInstance(), &Mle::HandleSendChildUpdateRequest, this),
|
||||
mSendChildUpdateRequest(aInstance, &Mle::HandleSendChildUpdateRequest, this),
|
||||
mDiscoverHandler(NULL),
|
||||
mDiscoverContext(NULL),
|
||||
mIsDiscoverInProgress(false),
|
||||
@@ -111,11 +111,11 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
|
||||
// link-local 64
|
||||
mLinkLocal64.GetAddress().mFields.m16[0] = HostSwap16(0xfe80);
|
||||
mLinkLocal64.GetAddress().SetIid(*aThreadNetif.GetMac().GetExtAddress());
|
||||
mLinkLocal64.GetAddress().SetIid(*GetNetif().GetMac().GetExtAddress());
|
||||
mLinkLocal64.mPrefixLength = 64;
|
||||
mLinkLocal64.mPreferred = true;
|
||||
mLinkLocal64.mValid = true;
|
||||
aThreadNetif.AddUnicastAddress(mLinkLocal64);
|
||||
GetNetif().AddUnicastAddress(mLinkLocal64);
|
||||
|
||||
// Leader Aloc
|
||||
mLeaderAloc.mPrefixLength = 128;
|
||||
@@ -126,7 +126,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
|
||||
// initialize Mesh Local Prefix
|
||||
meshLocalPrefix[0] = 0xfd;
|
||||
memcpy(meshLocalPrefix + 1, aThreadNetif.GetMac().GetExtendedPanId(), 5);
|
||||
memcpy(meshLocalPrefix + 1, GetNetif().GetMac().GetExtendedPanId(), 5);
|
||||
meshLocalPrefix[6] = 0x00;
|
||||
meshLocalPrefix[7] = 0x00;
|
||||
|
||||
@@ -154,7 +154,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
mMeshLocal16.mRloc = true;
|
||||
|
||||
// Store RLOC address reference in MPL module.
|
||||
aThreadNetif.GetIp6().mMpl.SetMatchingAddress(mMeshLocal16.GetAddress());
|
||||
GetNetif().GetIp6().mMpl.SetMatchingAddress(mMeshLocal16.GetAddress());
|
||||
|
||||
// link-local all thread nodes
|
||||
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.
|
||||
|
||||
mNetifCallback.Set(&Mle::HandleNetifStateChanged, this);
|
||||
aThreadNetif.RegisterCallback(mNetifCallback);
|
||||
GetNetif().RegisterCallback(mNetifCallback);
|
||||
}
|
||||
|
||||
otError Mle::Enable(void)
|
||||
|
||||
@@ -449,16 +449,16 @@ private:
|
||||
* This class implements MLE functionality required by the Thread EndDevices, Router, and Leader roles.
|
||||
*
|
||||
*/
|
||||
class Mle: public ThreadNetifLocator
|
||||
class Mle: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -56,10 +56,10 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
namespace ot {
|
||||
namespace Mle {
|
||||
|
||||
MleRouter::MleRouter(ThreadNetif &aThreadNetif):
|
||||
Mle(aThreadNetif),
|
||||
mAdvertiseTimer(aThreadNetif.GetInstance(), &MleRouter::HandleAdvertiseTimer, NULL, this),
|
||||
mStateUpdateTimer(aThreadNetif.GetInstance(), &MleRouter::HandleStateUpdateTimer, this),
|
||||
MleRouter::MleRouter(otInstance &aInstance):
|
||||
Mle(aInstance),
|
||||
mAdvertiseTimer(aInstance, &MleRouter::HandleAdvertiseTimer, NULL, this),
|
||||
mStateUpdateTimer(aInstance, &MleRouter::HandleStateUpdateTimer, this),
|
||||
mAddressSolicit(OT_URI_PATH_ADDRESS_SOLICIT, &MleRouter::HandleAddressSolicit, this),
|
||||
mAddressRelease(OT_URI_PATH_ADDRESS_RELEASE, &MleRouter::HandleAddressRelease, this),
|
||||
mRouterIdSequence(0),
|
||||
|
||||
@@ -79,10 +79,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -50,7 +50,7 @@ class MleRouter: public Mle
|
||||
friend class Mle;
|
||||
|
||||
public:
|
||||
explicit MleRouter(ThreadNetif &aThreadNetif) : Mle(aThreadNetif) { }
|
||||
explicit MleRouter(otInstance &aInstance) : Mle(aInstance) { }
|
||||
|
||||
bool IsSingleton(void) { return false; }
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
namespace ot {
|
||||
namespace NetworkData {
|
||||
|
||||
NetworkData::NetworkData(ThreadNetif &aThreadNetif, bool aLocal):
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
NetworkData::NetworkData(otInstance &aInstance, bool aLocal):
|
||||
InstanceLocator(aInstance),
|
||||
mLocal(aLocal),
|
||||
mLastAttemptWait(false),
|
||||
mLastAttempt(0)
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace NetworkData {
|
||||
* This class implements Network Data processing.
|
||||
*
|
||||
*/
|
||||
class NetworkData: public ThreadNetifLocator
|
||||
class NetworkData: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
NetworkData(ThreadNetif &aThreadNetif, bool aLocal);
|
||||
NetworkData(otInstance &aInstance, bool aLocal);
|
||||
|
||||
/**
|
||||
* This method clears the network data.
|
||||
|
||||
@@ -56,8 +56,8 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
namespace ot {
|
||||
namespace NetworkData {
|
||||
|
||||
LeaderBase::LeaderBase(ThreadNetif &aThreadNetif):
|
||||
NetworkData(aThreadNetif, false)
|
||||
LeaderBase::LeaderBase(otInstance &aInstance):
|
||||
NetworkData(aInstance, false)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
@@ -70,10 +70,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -61,9 +61,9 @@ using ot::Encoding::BigEndian::HostSwap16;
|
||||
namespace ot {
|
||||
namespace NetworkData {
|
||||
|
||||
Leader::Leader(ThreadNetif &aThreadNetif):
|
||||
LeaderBase(aThreadNetif),
|
||||
mTimer(aThreadNetif.GetInstance(), &Leader::HandleTimer, this),
|
||||
Leader::Leader(otInstance &aInstance):
|
||||
LeaderBase(aInstance),
|
||||
mTimer(aInstance, &Leader::HandleTimer, this),
|
||||
mServerData(OT_URI_PATH_SERVER_DATA, &Leader::HandleServerData, this),
|
||||
mCommissioningDataGet(OT_URI_PATH_COMMISSIONER_GET, &Leader::HandleCommissioningGet, this),
|
||||
mCommissioningDataSet(OT_URI_PATH_COMMISSIONER_SET, &Leader::HandleCommissioningSet, this)
|
||||
|
||||
@@ -70,10 +70,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace NetworkData {
|
||||
class Leader: public LeaderBase
|
||||
{
|
||||
public:
|
||||
explicit Leader(ThreadNetif &aThreadNetif) : LeaderBase(aThreadNetif) { }
|
||||
explicit Leader(otInstance &aInstance) : LeaderBase(aInstance) { }
|
||||
|
||||
void Start(void) { }
|
||||
void Stop(void) { }
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
namespace ot {
|
||||
namespace NetworkData {
|
||||
|
||||
Local::Local(ThreadNetif &aThreadNetif):
|
||||
NetworkData(aThreadNetif, true),
|
||||
Local::Local(otInstance &aInstance):
|
||||
NetworkData(aInstance, true),
|
||||
mOldRloc(Mac::kShortAddrInvalid)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
* @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.
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace ot {
|
||||
|
||||
namespace NetworkDiagnostic {
|
||||
|
||||
NetworkDiagnostic::NetworkDiagnostic(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
NetworkDiagnostic::NetworkDiagnostic(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mDiagnosticGetRequest(OT_URI_PATH_DIAGNOSTIC_GET_REQUEST, &NetworkDiagnostic::HandleDiagnosticGetRequest, this),
|
||||
mDiagnosticGetQuery(OT_URI_PATH_DIAGNOSTIC_GET_QUERY, &NetworkDiagnostic::HandleDiagnosticGetQuery, this),
|
||||
mDiagnosticGetAnswer(OT_URI_PATH_DIAGNOSTIC_GET_ANSWER, &NetworkDiagnostic::HandleDiagnosticGetAnswer, this),
|
||||
@@ -68,10 +68,10 @@ NetworkDiagnostic::NetworkDiagnostic(ThreadNetif &aThreadNetif) :
|
||||
mReceiveDiagnosticGetCallback(NULL),
|
||||
mReceiveDiagnosticGetCallbackContext(NULL)
|
||||
{
|
||||
aThreadNetif.GetCoap().AddResource(mDiagnosticGetRequest);
|
||||
aThreadNetif.GetCoap().AddResource(mDiagnosticGetQuery);
|
||||
aThreadNetif.GetCoap().AddResource(mDiagnosticGetAnswer);
|
||||
aThreadNetif.GetCoap().AddResource(mDiagnosticReset);
|
||||
GetNetif().GetCoap().AddResource(mDiagnosticGetRequest);
|
||||
GetNetif().GetCoap().AddResource(mDiagnosticGetQuery);
|
||||
GetNetif().GetCoap().AddResource(mDiagnosticGetAnswer);
|
||||
GetNetif().GetCoap().AddResource(mDiagnosticReset);
|
||||
}
|
||||
|
||||
void NetworkDiagnostic::SetReceiveDiagnosticGetCallback(otReceiveDiagnosticGetCallback aCallback,
|
||||
|
||||
@@ -63,14 +63,14 @@ class NetworkDiagnosticTlv;
|
||||
* This class implements the Network Diagnostic processing.
|
||||
*
|
||||
*/
|
||||
class NetworkDiagnostic: public ThreadNetifLocator
|
||||
class NetworkDiagnostic: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -49,14 +49,14 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
PanIdQueryServer::PanIdQueryServer(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
PanIdQueryServer::PanIdQueryServer(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mChannelMask(0),
|
||||
mPanId(Mac::kPanIdBroadcast),
|
||||
mTimer(aThreadNetif.GetInstance(), &PanIdQueryServer::HandleTimer, this),
|
||||
mTimer(aInstance, &PanIdQueryServer::HandleTimer, 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,
|
||||
|
||||
@@ -56,14 +56,14 @@ class ThreadTargetTlv;
|
||||
* This class implements handling PANID Query Requests.
|
||||
*
|
||||
*/
|
||||
class PanIdQueryServer: public ThreadNetifLocator
|
||||
class PanIdQueryServer: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
PanIdQueryServer(ThreadNetif &aThreadNetif);
|
||||
PanIdQueryServer(otInstance &aInstance);
|
||||
|
||||
private:
|
||||
enum
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
|
||||
namespace ot {
|
||||
|
||||
SourceMatchController::SourceMatchController(MeshForwarder &aMeshForwarder) :
|
||||
MeshForwarderLocator(aMeshForwarder),
|
||||
SourceMatchController::SourceMatchController(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mEnabled(false)
|
||||
{
|
||||
ClearTable();
|
||||
@@ -220,7 +220,7 @@ otError SourceMatchController::AddPendingEntries(void)
|
||||
uint8_t numChildren;
|
||||
Child *child;
|
||||
|
||||
child = GetMeshForwarder().GetNetif().GetMle().GetChildren(&numChildren);
|
||||
child = GetNetif().GetMle().GetChildren(&numChildren);
|
||||
|
||||
for (uint8_t i = 0; i < numChildren; i++, child++)
|
||||
{
|
||||
|
||||
@@ -65,16 +65,16 @@ namespace ot {
|
||||
* address or an extended/long address can be added to the source address match table.
|
||||
*
|
||||
*/
|
||||
class SourceMatchController: public MeshForwarderLocator
|
||||
class SourceMatchController: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -57,58 +57,58 @@ static const otMasterKey kThreadMasterKey =
|
||||
}
|
||||
};
|
||||
|
||||
ThreadNetif::ThreadNetif(Ip6::Ip6 &aIp6):
|
||||
Netif(aIp6, OT_NETIF_INTERFACE_ID_THREAD),
|
||||
mCoap(*this),
|
||||
ThreadNetif::ThreadNetif(otInstance &aInstance):
|
||||
Netif(aInstance, OT_NETIF_INTERFACE_ID_THREAD),
|
||||
mCoap(aInstance),
|
||||
#if OPENTHREAD_ENABLE_DHCP6_CLIENT
|
||||
mDhcp6Client(*this),
|
||||
mDhcp6Client(aInstance),
|
||||
#endif // OPENTHREAD_ENABLE_DHCP6_CLIENT
|
||||
#if OPENTHREAD_ENABLE_DHCP6_SERVER
|
||||
mDhcp6Server(*this),
|
||||
mDhcp6Server(aInstance),
|
||||
#endif // OPENTHREAD_ENABLE_DHCP6_SERVER
|
||||
#if OPENTHREAD_ENABLE_DNS_CLIENT
|
||||
mDnsClient(*this),
|
||||
mDnsClient(aInstance.mThreadNetif),
|
||||
#endif // OPENTHREAD_ENABLE_DNS_CLIENT
|
||||
mActiveDataset(*this),
|
||||
mPendingDataset(*this),
|
||||
mKeyManager(*this),
|
||||
mLowpan(*this),
|
||||
mMac(*this),
|
||||
mMeshForwarder(*this),
|
||||
mMleRouter(*this),
|
||||
mActiveDataset(aInstance),
|
||||
mPendingDataset(aInstance),
|
||||
mKeyManager(aInstance),
|
||||
mLowpan(aInstance),
|
||||
mMac(aInstance),
|
||||
mMeshForwarder(aInstance),
|
||||
mMleRouter(aInstance),
|
||||
#if OPENTHREAD_ENABLE_BORDER_ROUTER
|
||||
mNetworkDataLocal(*this),
|
||||
mNetworkDataLocal(aInstance),
|
||||
#endif
|
||||
mNetworkDataLeader(*this),
|
||||
mNetworkDataLeader(aInstance),
|
||||
#if OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC
|
||||
mNetworkDiagnostic(*this),
|
||||
mNetworkDiagnostic(aInstance),
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
mCommissioner(*this),
|
||||
mCommissioner(aInstance),
|
||||
#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
#if OPENTHREAD_ENABLE_DTLS
|
||||
mDtls(*this),
|
||||
mCoapSecure(*this),
|
||||
mDtls(aInstance),
|
||||
mCoapSecure(aInstance),
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_JOINER
|
||||
mJoiner(*this),
|
||||
mJoiner(aInstance),
|
||||
#endif // OPENTHREAD_ENABLE_JOINER
|
||||
#if OPENTHREAD_ENABLE_JAM_DETECTION
|
||||
mJamDetector(*this),
|
||||
mJamDetector(aInstance),
|
||||
#endif // OPENTHREAD_ENABLE_JAM_DETECTTION
|
||||
#if OPENTHREAD_FTD
|
||||
#if OPENTHREAD_ENABLE_TMF_PROXY
|
||||
mTmfProxy(mMleRouter.GetMeshLocal16(), mCoap),
|
||||
#endif // OPENTHREAD_ENABLE_TMF_PROXY
|
||||
mJoinerRouter(*this),
|
||||
mLeader(*this),
|
||||
mAddressResolver(*this),
|
||||
mJoinerRouter(aInstance),
|
||||
mLeader(aInstance),
|
||||
mAddressResolver(aInstance),
|
||||
#endif // OPENTHREAD_FTD
|
||||
mChildSupervisor(*this),
|
||||
mSupervisionListener(*this),
|
||||
mAnnounceBegin(*this),
|
||||
mPanIdQuery(*this),
|
||||
mEnergyScan(*this)
|
||||
mChildSupervisor(aInstance),
|
||||
mSupervisionListener(aInstance),
|
||||
mAnnounceBegin(aInstance),
|
||||
mPanIdQuery(aInstance),
|
||||
mEnergyScan(aInstance)
|
||||
|
||||
{
|
||||
mKeyManager.SetMasterKey(kThreadMasterKey);
|
||||
|
||||
@@ -101,10 +101,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -48,9 +48,9 @@ namespace Utils {
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
ChildSupervisor::ChildSupervisor(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mTimer(aThreadNetif.GetInstance(), &ChildSupervisor::HandleTimer, this),
|
||||
ChildSupervisor::ChildSupervisor(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mTimer(aInstance, &ChildSupervisor::HandleTimer, this),
|
||||
mSupervisionInterval(kDefaultSupervisionInterval)
|
||||
{
|
||||
}
|
||||
@@ -178,9 +178,9 @@ ChildSupervisor &ChildSupervisor::GetOwner(const Context &aContext)
|
||||
|
||||
#endif // #if OPENTHREAD_FTD
|
||||
|
||||
SupervisionListener::SupervisionListener(ThreadNetif &aThreadNetif) :
|
||||
ThreadNetifLocator(aThreadNetif),
|
||||
mTimer(aThreadNetif.GetInstance(), &SupervisionListener::HandleTimer, this),
|
||||
SupervisionListener::SupervisionListener(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mTimer(aInstance, &SupervisionListener::HandleTimer, this),
|
||||
mTimeout(0)
|
||||
{
|
||||
SetTimeout(kDefaultTimeout);
|
||||
|
||||
@@ -86,16 +86,16 @@ namespace Utils {
|
||||
* This class implements a child supervisor.
|
||||
*
|
||||
*/
|
||||
class ChildSupervisor: public ThreadNetifLocator
|
||||
class ChildSupervisor: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
@@ -168,7 +168,7 @@ private:
|
||||
class ChildSupervisor
|
||||
{
|
||||
public:
|
||||
explicit ChildSupervisor(ThreadNetif &) { }
|
||||
explicit ChildSupervisor(otInstance &) { }
|
||||
void Start(void) { }
|
||||
void Stop(void) { }
|
||||
void SetSupervisionInterval(uint16_t) { }
|
||||
@@ -185,16 +185,16 @@ public:
|
||||
* This class implements a child supervision listener.
|
||||
*
|
||||
*/
|
||||
class SupervisionListener: public ThreadNetifLocator
|
||||
class SupervisionListener: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* 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.
|
||||
@@ -260,7 +260,7 @@ private:
|
||||
class SupervisionListener
|
||||
{
|
||||
public:
|
||||
SupervisionListener(ThreadNetif &) { }
|
||||
SupervisionListener(otInstance &) { }
|
||||
void Start(void) { }
|
||||
void Stop(void) { }
|
||||
void SetTimeout(uint16_t) { }
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
namespace ot {
|
||||
namespace Utils {
|
||||
|
||||
JamDetector::JamDetector(ThreadNetif &aNetif) :
|
||||
ThreadNetifLocator(aNetif),
|
||||
JamDetector::JamDetector(otInstance &aInstance) :
|
||||
InstanceLocator(aInstance),
|
||||
mHandler(NULL),
|
||||
mContext(NULL),
|
||||
mRssiThreshold(kDefaultRssiThreshold),
|
||||
mTimer(aNetif.GetInstance(), &JamDetector::HandleTimer, this),
|
||||
mTimer(aInstance, &JamDetector::HandleTimer, this),
|
||||
mHistoryBitmap(0),
|
||||
mCurSecondStartTime(0),
|
||||
mSampleInterval(0),
|
||||
|
||||
@@ -46,7 +46,7 @@ class ThreadNetif;
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class JamDetector: public ThreadNetifLocator
|
||||
class JamDetector: public InstanceLocator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -62,10 +62,10 @@ public:
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestNetworkData: public NetworkData::NetworkData
|
||||
{
|
||||
public:
|
||||
TestNetworkData(otInstance *aInstance, const uint8_t *aTlvs, uint8_t aTlvsLength):
|
||||
NetworkData::NetworkData(aInstance->mThreadNetif, false) {
|
||||
NetworkData::NetworkData(*aInstance, false) {
|
||||
memcpy(mTlvs, aTlvs, aTlvsLength);
|
||||
mLength = aTlvsLength;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user