Reduce MTD code size by removing some unused MeshCoP features (#1361)

* Seperate FTD-only dataset APIs;

* Remove some unused MeshCoP functions from MTD build;

* Remove some unused CLI functions from MTD build.
This commit is contained in:
Shu Chen
2017-04-25 11:51:12 -07:00
committed by Jonathan Hui
parent 6043cd8f1b
commit 0a830ecefe
32 changed files with 846 additions and 735 deletions
+3 -1
View File
@@ -62,6 +62,7 @@
<ItemGroup>
<ClCompile Include="..\..\src\core\api\commissioner_api.cpp" />
<ClCompile Include="..\..\src\core\api\dataset_api.cpp" />
<ClCompile Include="..\..\src\core\api\dataset_ftd_api.cpp" />
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp" />
<ClCompile Include="..\..\src\core\api\icmp6_api.cpp" />
<ClCompile Include="..\..\src\core\api\ip6_api.cpp" />
@@ -73,6 +74,7 @@
<ClCompile Include="..\..\src\core\api\netdata_api.cpp" />
<ClCompile Include="..\..\src\core\api\tasklet_api.cpp" />
<ClCompile Include="..\..\src\core\api\thread_api.cpp" />
<ClCompile Include="..\..\src\core\api\thread_ftd_api.cpp" />
<ClCompile Include="..\..\src\core\coap\coap_base.cpp" />
<ClCompile Include="..\..\src\core\coap\coap_client.cpp" />
<ClCompile Include="..\..\src\core\coap\coap_header.cpp" />
@@ -230,4 +232,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
@@ -75,6 +75,9 @@
<ClCompile Include="..\..\src\core\api\dataset_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\dataset_ftd_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
@@ -108,6 +111,9 @@
<ClCompile Include="..\..\src\core\api\thread_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\thread_ftd_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\coap\coap_base.cpp">
<Filter>Source Files\coap</Filter>
</ClCompile>
@@ -564,4 +570,4 @@
<Filter>Header Files\missing</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
+5 -1
View File
@@ -69,6 +69,7 @@
<ItemGroup>
<ClCompile Include="..\..\src\core\api\commissioner_api.cpp" />
<ClCompile Include="..\..\src\core\api\dataset_api.cpp" />
<ClCompile Include="..\..\src\core\api\dataset_ftd_api.cpp" />
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp" />
<ClCompile Include="..\..\src\core\api\icmp6_api.cpp" />
<ClCompile Include="..\..\src\core\api\ip6_api.cpp" />
@@ -79,6 +80,7 @@
<ClCompile Include="..\..\src\core\api\netdata_api.cpp" />
<ClCompile Include="..\..\src\core\api\tasklet_api.cpp" />
<ClCompile Include="..\..\src\core\api\thread_api.cpp" />
<ClCompile Include="..\..\src\core\api\thread_ftd_api.cpp" />
<ClCompile Include="..\..\src\core\coap\coap_base.cpp" />
<ClCompile Include="..\..\src\core\coap\coap_client.cpp" />
<ClCompile Include="..\..\src\core\coap\coap_header.cpp" />
@@ -152,6 +154,7 @@
<ClInclude Include="..\..\include\openthread\commissioner.h" />
<ClInclude Include="..\..\include\openthread\crypto.h" />
<ClInclude Include="..\..\include\openthread\dataset.h" />
<ClInclude Include="..\..\include\openthread\dataset_ftd.h" />
<ClInclude Include="..\..\include\openthread\dhcp6_client.h" />
<ClInclude Include="..\..\include\openthread\dhcp6_server.h" />
<ClInclude Include="..\..\include\openthread\icmp6.h" />
@@ -165,6 +168,7 @@
<ClInclude Include="..\..\include\openthread\openthread.h" />
<ClInclude Include="..\..\include\openthread\tasklet.h" />
<ClInclude Include="..\..\include\openthread\thread.h" />
<ClInclude Include="..\..\include\openthread\thread_ftd.h" />
<ClInclude Include="..\..\include\openthread\types.h" />
<ClInclude Include="..\..\include\openthread-windows-config.h" />
<ClInclude Include="..\..\include\openthread\udp.h" />
@@ -258,4 +262,4 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>
@@ -78,6 +78,9 @@
<ClCompile Include="..\..\src\core\api\dataset_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\dataset_ftd_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\dhcp6_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
@@ -108,6 +111,9 @@
<ClCompile Include="..\..\src\core\api\thread_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\api\thread_ftd_api.cpp">
<Filter>Source Files\api</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\coap\coap_base.cpp">
<Filter>Source Files\coap</Filter>
</ClCompile>
@@ -581,6 +587,9 @@
<ClInclude Include="..\..\include\openthread\dataset.h">
<Filter>Header Files\openthread</Filter>
</ClInclude>
<ClInclude Include="..\..\include\openthread\dataset_ftd.h">
<Filter>Header Files\openthread</Filter>
</ClInclude>
<ClInclude Include="..\..\include\openthread\dhcp6_client.h">
<Filter>Header Files\openthread</Filter>
</ClInclude>
@@ -620,6 +629,9 @@
<ClInclude Include="..\..\include\openthread\thread.h">
<Filter>Header Files\openthread</Filter>
</ClInclude>
<ClInclude Include="..\..\include\openthread\thread_ftd.h">
<Filter>Header Files\openthread</Filter>
</ClInclude>
<ClInclude Include="..\..\include\openthread\udp.h">
<Filter>Header Files\openthread</Filter>
</ClInclude>
@@ -633,4 +645,4 @@
<Filter>Header Files\missing</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
+2
View File
@@ -22,6 +22,8 @@
#define OTAPI EXTERN_C __declspec(dllexport)
#include <openthread/openthread.h>
#include <openthread/dataset_ftd.h>
#include <openthread/thread_ftd.h>
#include <openthread/commissioner.h>
#include <openthread/joiner.h>
#include <openthread/platform/logging-windows.h>
+2
View File
@@ -62,6 +62,8 @@ RtlCopyBufferToMdl(
#include <openthread-windows-config.h>
#include <openthread-core-config.h>
#include <openthread/openthread.h>
#include <openthread/dataset_ftd.h>
#include <openthread/thread_ftd.h>
#include <openthread/icmp6.h>
#include <openthread/ip6.h>
#include <openthread/tasklet.h>
@@ -50,6 +50,8 @@ using namespace std;
#define OTNODEAPI EXTERN_C __declspec(dllexport)
#include <openthread/openthread.h>
#include <openthread/dataset_ftd.h>
#include <openthread/thread_ftd.h>
#include <openthread/commissioner.h>
#include <openthread/joiner.h>
#include <openthread/platform/logging-windows.h>
+2
View File
@@ -52,6 +52,7 @@ openthread_headers = \
commissioner.h \
crypto.h \
dataset.h \
dataset_ftd.h \
diag.h \
dhcp6_client.h \
dhcp6_server.h \
@@ -69,6 +70,7 @@ openthread_headers = \
openthread.h \
tasklet.h \
thread.h \
thread_ftd.h \
types.h \
udp.h \
$(NULL)
+1 -109
View File
@@ -29,7 +29,7 @@
/**
* @file
* @brief
* This file defines the OpenThread Operational Dataset API.
* This file defines the OpenThread Operational Dataset API (for both FTD and MTD).
*/
#ifndef OPENTHREAD_DATASET_H_
@@ -73,19 +73,6 @@ OTAPI bool OTCALL otDatasetIsCommissioned(otInstance *aInstance);
*/
OTAPI ThreadError OTCALL otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset);
/**
* This function sets the Active Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Active Operational Dataset.
*
* @retval kThreadError_None Successfully set the Active Operational Dataset.
* @retval kThreadError_NoBufs Insufficient buffer space to set the Active Operational Datset.
* @retval kThreadError_InvalidArgs @p aDataset was NULL.
*
*/
OTAPI ThreadError OTCALL otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset);
/**
* This function gets the Pending Operational Dataset.
*
@@ -98,101 +85,6 @@ OTAPI ThreadError OTCALL otDatasetSetActive(otInstance *aInstance, const otOpera
*/
OTAPI ThreadError OTCALL otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset);
/**
* This function sets the Pending Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Pending Operational Dataset.
*
* @retval kThreadError_None Successfully set the Pending Operational Dataset.
* @retval kThreadError_NoBufs Insufficient buffer space to set the Pending Operational Dataset.
* @retval kThreadError_InvalidArgs @p aDataset was NULL.
*
*/
OTAPI ThreadError OTCALL otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset);
/**
* This function sends MGMT_ACTIVE_GET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTlvTypes A pointer to the TLV Types.
* @param[in] aLength The length of TLV Types.
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress);
/**
* This function sends MGMT_ACTIVE_SET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to operational dataset.
* @param[in] aTlvs A pointer to TLVs.
* @param[in] aLength The length of TLVs.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtActiveSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength);
/**
* This function sends MGMT_PENDING_GET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTlvTypes A pointer to the TLV Types.
* @param[in] aLength The length of TLV Types.
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress);
/**
* This function sends MGMT_PENDING_SET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to operational dataset.
* @param[in] aTlvs A pointer to TLVs.
* @param[in] aLength The length of TLVs.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtPendingSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength);
/**
* Get minimal delay timer.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval the value of minimal delay timer (in ms).
*
*/
OTAPI uint32_t OTCALL otDatasetGetDelayTimerMinimal(otInstance *aInstance);
/**
* Set minimal delay timer.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
*
* @retval kThreadError_None Successfully set minimal delay timer.
* @retval kThreadError_InvalidArgs If @p aDelayTimerMinimal is not valid.
*
*/
OTAPI ThreadError OTCALL otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal);
/**
* @}
*
+171
View File
@@ -0,0 +1,171 @@
/*
* Copyright (c) 2016-2017, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file defines the OpenThread Operational Dataset API (FTD only).
*/
#ifndef OPENTHREAD_DATASET_FTD_H_
#define OPENTHREAD_DATASET_FTD_H_
#include "openthread/types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup dataset Operational Dataset
*
* @brief
* This module includes functions for Operational Dataset configuration for FTD.
*
* @{
*
*/
/**
* This function sets the Active Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Active Operational Dataset.
*
* @retval kThreadError_None Successfully set the Active Operational Dataset.
* @retval kThreadError_NoBufs Insufficient buffer space to set the Active Operational Datset.
* @retval kThreadError_InvalidArgs @p aDataset was NULL.
*
*/
OTAPI ThreadError OTCALL otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset);
/**
* This function sets the Pending Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Pending Operational Dataset.
*
* @retval kThreadError_None Successfully set the Pending Operational Dataset.
* @retval kThreadError_NoBufs Insufficient buffer space to set the Pending Operational Dataset.
* @retval kThreadError_InvalidArgs @p aDataset was NULL.
*
*/
OTAPI ThreadError OTCALL otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset);
/**
* This function sends MGMT_ACTIVE_GET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTlvTypes A pointer to the TLV Types.
* @param[in] aLength The length of TLV Types.
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress);
/**
* This function sends MGMT_ACTIVE_SET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to operational dataset.
* @param[in] aTlvs A pointer to TLVs.
* @param[in] aLength The length of TLVs.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtActiveSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength);
/**
* This function sends MGMT_PENDING_GET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTlvTypes A pointer to the TLV Types.
* @param[in] aLength The length of TLV Types.
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress);
/**
* This function sends MGMT_PENDING_SET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to operational dataset.
* @param[in] aTlvs A pointer to TLVs.
* @param[in] aLength The length of TLVs.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
OTAPI ThreadError OTCALL otDatasetSendMgmtPendingSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength);
/**
* Get minimal delay timer.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval the value of minimal delay timer (in ms).
*
*/
OTAPI uint32_t OTCALL otDatasetGetDelayTimerMinimal(otInstance *aInstance);
/**
* Set minimal delay timer.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
*
* @retval kThreadError_None Successfully set minimal delay timer.
* @retval kThreadError_InvalidArgs If @p aDelayTimerMinimal is not valid.
*
*/
OTAPI ThreadError OTCALL otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal);
/**
* @}
*
*/
#ifdef __cplusplus
} // extern "C"
#endif
#endif // OPENTHREAD_DATASET_FTD_H_
-23
View File
@@ -442,29 +442,6 @@ OTAPI uint32_t OTCALL otThreadGetLocalLeaderPartitionId(otInstance *aInstance);
*/
OTAPI void OTCALL otThreadSetLocalLeaderPartitionId(otInstance *aInstance, uint32_t aPartitionId);
/**
* Get the Joiner UDP Port.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns The Joiner UDP Port number.
*
* @sa otThreadSetJoinerUdpPort
*/
OTAPI uint16_t OTCALL otThreadGetJoinerUdpPort(otInstance *aInstance);
/**
* Set the Joiner UDP Port
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aJoinerUdpPort The Joiner UDP Port number.
*
* @retval kThreadErrorNone Successfully set the Joiner UDP Port.
*
* @sa otThreadGetJoinerUdpPort
*/
OTAPI ThreadError OTCALL otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort);
/**
* @}
*/
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* Copyright (c) 2016-2017, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,24 +28,61 @@
/**
* @file
* This file includes definitions for the Joiner Router role.
* @brief
* This file defines the OpenThread Thread API (FTD only).
*/
#ifndef JOINER_ROUTER_HPP_
#define JOINER_ROUTER_HPP_
#ifndef OPENTHREAD_THREAD_FTD_H_
#define OPENTHREAD_THREAD_FTD_H_
namespace Thread {
namespace MeshCoP {
#include "openthread/types.h"
#include "openthread/link.h"
#include "openthread/message.h"
class JoinerRouter
{
public:
JoinerRouter(ThreadNetif &) { }
uint16_t GetJoinerUdpPort(void) { return 0; }
ThreadError SetJoinerUdpPort(uint16_t) { return kThreadError_NotImplemented; }
};
#ifdef __cplusplus
extern "C" {
#endif
} // namespace MeshCoP
} // namespace Thread
/**
* @addtogroup thread Thread
*
* @brief
* This module includes functions that control Thread-specific functions.
*
* @{
*
*/
#endif // JOINER_ROUTER_HPP_
/**
* Get the Joiner UDP Port.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns The Joiner UDP Port number.
*
* @sa otThreadSetJoinerUdpPort
*/
OTAPI uint16_t OTCALL otThreadGetJoinerUdpPort(otInstance *aInstance);
/**
* Set the Joiner UDP Port
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aJoinerUdpPort The Joiner UDP Port number.
*
* @retval kThreadErrorNone Successfully set the Joiner UDP Port.
*
* @sa otThreadGetJoinerUdpPort
*/
OTAPI ThreadError OTCALL otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort);
/**
* @}
*
*/
#ifdef __cplusplus
} // extern "C"
#endif
#endif // OPENTHREAD_THREAD_FTD_H_
+13
View File
@@ -49,6 +49,11 @@
#include "openthread/commissioner.h"
#include "openthread/joiner.h"
#if OPENTHREAD_FTD
#include "openthread/dataset_ftd.h"
#include "openthread/thread_ftd.h"
#endif
#ifndef OTDLL
#include <openthread-instance.h>
#include "openthread/diag.h"
@@ -96,7 +101,9 @@ const struct Command Interpreter::sCommands[] =
{ "contextreusedelay", &Interpreter::ProcessContextIdReuseDelay },
{ "counter", &Interpreter::ProcessCounters },
{ "dataset", &Interpreter::ProcessDataset },
#if OPENTHREAD_FTD
{ "delaytimermin", &Interpreter::ProcessDelayTimerMin},
#endif
#if OPENTHREAD_ENABLE_DIAG
{ "diag", &Interpreter::ProcessDiag },
#endif
@@ -125,7 +132,9 @@ const struct Command Interpreter::sCommands[] =
#if OPENTHREAD_ENABLE_JOINER
{ "joiner", &Interpreter::ProcessJoiner },
#endif
#if OPENTHREAD_FTD
{ "joinerport", &Interpreter::ProcessJoinerPort },
#endif
{ "keysequence", &Interpreter::ProcessKeySequence },
{ "leaderdata", &Interpreter::ProcessLeaderData },
{ "leaderpartitionid", &Interpreter::ProcessLeaderPartitionId },
@@ -701,6 +710,7 @@ void Interpreter::ProcessDataset(int argc, char *argv[])
AppendResult(error);
}
#if OPENTHREAD_FTD
void Interpreter::ProcessDelayTimerMin(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
@@ -723,6 +733,7 @@ void Interpreter::ProcessDelayTimerMin(int argc, char *argv[])
exit:
AppendResult(error);
}
#endif
void Interpreter::ProcessDiscover(int argc, char *argv[])
{
@@ -2753,6 +2764,7 @@ void Interpreter::HandleJoinerCallback(ThreadError aError)
}
}
#if OPENTHREAD_FTD
void Interpreter::ProcessJoinerPort(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
@@ -2771,6 +2783,7 @@ void Interpreter::ProcessJoinerPort(int argc, char *argv[])
exit:
AppendResult(error);
}
#endif
void Interpreter::ProcessWhitelist(int argc, char *argv[])
{
+20 -10
View File
@@ -43,6 +43,10 @@
#include "openthread/openthread.h"
#if OPENTHREAD_FTD
#include "openthread/dataset_ftd.h"
#endif
#include "cli.hpp"
#include "cli_dataset.hpp"
@@ -53,6 +57,7 @@ const DatasetCommand Dataset::sCommands[] =
{
{ "help", &ProcessHelp },
{ "active", &ProcessActive },
#if OPENTHREAD_FTD
{ "activetimestamp", &ProcessActiveTimestamp },
{ "channel", &ProcessChannel },
{ "channelmask", &ProcessChannelMask },
@@ -66,10 +71,13 @@ const DatasetCommand Dataset::sCommands[] =
{ "mgmtsetcommand", &ProcessMgmtSetCommand },
{ "networkname", &ProcessNetworkName },
{ "panid", &ProcessPanId },
#endif
{ "pending", &ProcessPending },
#if OPENTHREAD_FTD
{ "pendingtimestamp", &ProcessPendingTimestamp },
{ "pskc", &ProcessPSKc },
{ "securitypolicy", &ProcessSecurityPolicy },
#endif
};
Server *Dataset::sServer;
@@ -234,6 +242,17 @@ ThreadError Dataset::ProcessActive(otInstance *aInstance, int argc, char *argv[]
return Print(dataset);
}
ThreadError Dataset::ProcessPending(otInstance *aInstance, int argc, char *argv[])
{
otOperationalDataset dataset;
otDatasetGetPending(aInstance, &dataset);
(void)argc;
(void)argv;
return Print(dataset);
}
#if OPENTHREAD_FTD
ThreadError Dataset::ProcessActiveTimestamp(otInstance *aInstance, int argc, char *argv[])
{
ThreadError error = kThreadError_None;
@@ -418,16 +437,6 @@ exit:
return error;
}
ThreadError Dataset::ProcessPending(otInstance *aInstance, int argc, char *argv[])
{
otOperationalDataset dataset;
otDatasetGetPending(aInstance, &dataset);
(void)argc;
(void)argv;
return Print(dataset);
}
ThreadError Dataset::ProcessPendingTimestamp(otInstance *aInstance, int argc, char *argv[])
{
ThreadError error = kThreadError_None;
@@ -729,6 +738,7 @@ ThreadError Dataset::ProcessSecurityPolicy(otInstance *aInstance, int argc, char
exit:
return error;
}
#endif // OPENTHREAD_FTD
} // namespace Cli
} // namespace Thread
+2 -4
View File
@@ -95,6 +95,7 @@ SOURCES_COMMON = \
api/commissioner_api.cpp \
api/crypto_api.cpp \
api/dataset_api.cpp \
api/dataset_ftd_api.cpp \
api/dhcp6_api.cpp \
api/dhcp6_api.cpp \
api/dns_api.cpp \
@@ -109,6 +110,7 @@ SOURCES_COMMON = \
api/netdata_api.cpp \
api/tasklet_api.cpp \
api/thread_api.cpp \
api/thread_ftd_api.cpp \
api/udp_api.cpp \
coap/coap_base.cpp \
coap/coap_client.cpp \
@@ -275,11 +277,7 @@ HEADERS_COMMON = \
meshcop/energy_scan_client.hpp \
meshcop/joiner.hpp \
meshcop/joiner_router.hpp \
meshcop/joiner_router_ftd.hpp \
meshcop/joiner_router_mtd.hpp \
meshcop/leader.hpp \
meshcop/leader_ftd.hpp \
meshcop/leader_mtd.hpp \
meshcop/meshcop.hpp \
meshcop/panid_query_client.hpp \
meshcop/timestamp.hpp \
+1 -59
View File
@@ -28,7 +28,7 @@
/**
* @file
* This file implements the OpenThread Operational Dataset API.
* This file implements the OpenThread Operational Dataset API (for both FTD and MTD).
*/
#include "openthread/dataset.h"
@@ -64,18 +64,6 @@ exit:
return error;
}
ThreadError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset)
{
ThreadError error;
VerifyOrExit(aDataset != NULL, error = kThreadError_InvalidArgs);
error = aInstance->mThreadNetif.GetActiveDataset().Set(*aDataset);
exit:
return error;
}
ThreadError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset)
{
ThreadError error = kThreadError_None;
@@ -87,49 +75,3 @@ ThreadError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDa
exit:
return error;
}
ThreadError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset)
{
ThreadError error;
VerifyOrExit(aDataset != NULL, error = kThreadError_InvalidArgs);
error = aInstance->mThreadNetif.GetPendingDataset().Set(*aDataset);
exit:
return error;
}
ThreadError otDatasetSendMgmtActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.GetActiveDataset().SendGetRequest(aTlvTypes, aLength, aAddress);
}
ThreadError otDatasetSendMgmtActiveSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength)
{
return aInstance->mThreadNetif.GetActiveDataset().SendSetRequest(*aDataset, aTlvs, aLength);
}
ThreadError otDatasetSendMgmtPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.GetPendingDataset().SendGetRequest(aTlvTypes, aLength, aAddress);
}
ThreadError otDatasetSendMgmtPendingSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength)
{
return aInstance->mThreadNetif.GetPendingDataset().SendSetRequest(*aDataset, aTlvs, aLength);
}
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetLeader().GetDelayTimerMinimal();
}
ThreadError otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal)
{
return aInstance->mThreadNetif.GetLeader().SetDelayTimerMinimal(aDelayTimerMinimal);
}
+100
View File
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2016-2017, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread Operational Dataset API (FTD only).
*/
#include "openthread/dataset_ftd.h"
#include "openthread-instance.h"
using namespace Thread;
#if OPENTHREAD_FTD
ThreadError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset)
{
ThreadError error;
VerifyOrExit(aDataset != NULL, error = kThreadError_InvalidArgs);
error = aInstance->mThreadNetif.GetActiveDataset().Set(*aDataset);
exit:
return error;
}
ThreadError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset)
{
ThreadError error;
VerifyOrExit(aDataset != NULL, error = kThreadError_InvalidArgs);
error = aInstance->mThreadNetif.GetPendingDataset().Set(*aDataset);
exit:
return error;
}
ThreadError otDatasetSendMgmtActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.GetActiveDataset().SendGetRequest(aTlvTypes, aLength, aAddress);
}
ThreadError otDatasetSendMgmtActiveSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength)
{
return aInstance->mThreadNetif.GetActiveDataset().SendSetRequest(*aDataset, aTlvs, aLength);
}
ThreadError otDatasetSendMgmtPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.GetPendingDataset().SendGetRequest(aTlvTypes, aLength, aAddress);
}
ThreadError otDatasetSendMgmtPendingSet(otInstance *aInstance, const otOperationalDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength)
{
return aInstance->mThreadNetif.GetPendingDataset().SendSetRequest(*aDataset, aTlvs, aLength);
}
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetLeader().GetDelayTimerMinimal();
}
ThreadError otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal)
{
return aInstance->mThreadNetif.GetLeader().SetDelayTimerMinimal(aDelayTimerMinimal);
}
#endif // OPENTHREAD_FTD
+1 -11
View File
@@ -28,7 +28,7 @@
/**
* @file
* This file implements the OpenThread Thread API.
* This file implements the OpenThread Thread API (for both FTD and MTD).
*/
#define WPP_NAME "thread_api.tmh"
@@ -258,16 +258,6 @@ void otThreadSetLocalLeaderPartitionId(otInstance *aInstance, uint32_t aPartitio
return aInstance->mThreadNetif.GetMle().SetLeaderPartitionId(aPartitionId);
}
uint16_t otThreadGetJoinerUdpPort(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetJoinerRouter().GetJoinerUdpPort();
}
ThreadError otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort)
{
return aInstance->mThreadNetif.GetJoinerRouter().SetJoinerUdpPort(aJoinerUdpPort);
}
uint32_t otThreadGetContextIdReuseDelay(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetNetworkDataLeader().GetContextIdReuseDelay();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* Copyright (c) 2016-2017, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,27 +28,27 @@
/**
* @file
* This file includes definitions for a MeshCoP Leader.
* This file implements the OpenThread Thread API (FTD only).
*/
#ifndef MESHCOP_LEADER_HPP_
#define MESHCOP_LEADER_HPP_
#define WPP_NAME "thread_ftd_api.tmh"
#include <net/ip6_address.hpp>
#include "openthread/thread_ftd.h"
namespace Thread {
namespace MeshCoP {
#include "openthread-instance.h"
class Leader
using namespace Thread;
#if OPENTHREAD_FTD
uint16_t otThreadGetJoinerUdpPort(otInstance *aInstance)
{
public:
Leader(ThreadNetif &) { }
ThreadError SendDatasetChanged(const Ip6::Address &) { return kThreadError_NotImplemented; }
ThreadError SetDelayTimerMinimal(uint32_t) { return kThreadError_NotImplemented; }
uint32_t GetDelayTimerMinimal(void) { return 0; }
};
return aInstance->mThreadNetif.GetJoinerRouter().GetJoinerUdpPort();
}
} // namespace MeshCoP
} // namespace Thread
ThreadError otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort)
{
return aInstance->mThreadNetif.GetJoinerRouter().SetJoinerUdpPort(aJoinerUdpPort);
}
#endif // MESHCOP_LEADER_HPP_
#endif // OPENTHREAD_FTD
+2
View File
@@ -252,6 +252,7 @@ ThreadError Dataset::Set(const Dataset &aDataset)
return kThreadError_None;
}
#if OPENTHREAD_FTD
ThreadError Dataset::Set(const otOperationalDataset &aDataset)
{
ThreadError error = kThreadError_None;
@@ -361,6 +362,7 @@ ThreadError Dataset::Set(const otOperationalDataset &aDataset)
exit:
return error;
}
#endif // OPENTHREAD_FTD
const Timestamp *Dataset::GetTimestamp(void) const
{
+2
View File
@@ -164,7 +164,9 @@ public:
ThreadError Set(const Dataset &aDataset);
#if OPENTHREAD_FTD
ThreadError Set(const otOperationalDataset &aDataset);
#endif
/**
* This method removes a TLV from the Dataset.
+8 -39
View File
@@ -156,6 +156,7 @@ ThreadError DatasetManager::ApplyConfiguration(void)
return error;
}
#if OPENTHREAD_FTD
ThreadError DatasetManager::Set(const otOperationalDataset &aDataset, uint8_t &aFlags)
{
ThreadError error = kThreadError_None;
@@ -185,6 +186,7 @@ ThreadError DatasetManager::Set(const otOperationalDataset &aDataset, uint8_t &a
exit:
return error;
}
#endif // OPENTHREAD_FTD
ThreadError DatasetManager::Clear(uint8_t &aFlags, bool aOnlyClearNetwork)
{
@@ -342,6 +344,7 @@ void DatasetManager::Get(Coap::Header &aHeader, Message &aMessage, const Ip6::Me
SendGetResponse(aHeader, aMessageInfo, tlvs, length);
}
#if OPENTHREAD_FTD
ThreadError DatasetManager::Set(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
Tlv tlv;
@@ -813,6 +816,7 @@ exit:
message->Free();
}
}
#endif // OPENTHREAD_FTD
void DatasetManager::SendGetResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
uint8_t *aTlvs, uint8_t aLength)
@@ -910,6 +914,7 @@ exit:
return error;
}
#if OPENTHREAD_FTD
ThreadError ActiveDatasetBase::Set(const otOperationalDataset &aDataset)
{
ThreadError error = kThreadError_None;
@@ -921,6 +926,7 @@ ThreadError ActiveDatasetBase::Set(const otOperationalDataset &aDataset)
exit:
return error;
}
#endif // OPENTHREAD_FTD
ThreadError ActiveDatasetBase::Set(const Dataset &aDataset)
{
@@ -999,6 +1005,7 @@ exit:
return error;
}
#if OPENTHREAD_FTD
ThreadError PendingDatasetBase::Set(const otOperationalDataset &aDataset)
{
ThreadError error = kThreadError_None;
@@ -1010,6 +1017,7 @@ ThreadError PendingDatasetBase::Set(const otOperationalDataset &aDataset)
exit:
return error;
}
#endif // OPENTHREAD_FTD
ThreadError PendingDatasetBase::Set(const Dataset &aDataset)
{
@@ -1120,45 +1128,6 @@ void PendingDatasetBase::HandleTimer(void)
Clear(false);
}
void PendingDatasetBase::ApplyActiveDataset(const Timestamp &aTimestamp, Message &aMessage)
{
uint16_t offset = aMessage.GetOffset();
DelayTimerTlv delayTimer;
uint8_t flags;
VerifyOrExit(mNetif.GetMle().IsAttached());
while (offset < aMessage.GetLength())
{
OT_TOOL_PACKED_BEGIN
struct
{
Tlv tlv;
uint8_t value[Dataset::kMaxValueSize];
} OT_TOOL_PACKED_END data;
aMessage.Read(offset, sizeof(Tlv), &data.tlv);
aMessage.Read(offset + sizeof(Tlv), data.tlv.GetLength(), data.value);
mNetwork.Set(data.tlv);
offset += sizeof(Tlv) + data.tlv.GetLength();
}
// add delay timer tlv
delayTimer.Init();
delayTimer.SetDelayTimer(mNetif.GetLeader().GetDelayTimerMinimal());
mNetwork.Set(delayTimer);
// add pending timestamp tlv
mNetwork.SetTimestamp(aTimestamp);
HandleNetworkUpdate(flags);
// reset delay timer
ResetDelayTimer(kFlagNetworkUpdated);
exit:
return;
}
void PendingDatasetBase::HandleNetworkUpdate(uint8_t &aFlags)
{
DatasetManager::HandleNetworkUpdate(aFlags);
+17 -10
View File
@@ -67,9 +67,6 @@ public:
ThreadError ApplyConfiguration(void);
ThreadError SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength);
ThreadError SendGetRequest(const uint8_t *aTlvTypes, uint8_t aLength, const otIp6Address *aAddress);
protected:
enum
{
@@ -81,8 +78,6 @@ protected:
ThreadError Clear(uint8_t &aFlags, bool aOnlyClearNetwork);
ThreadError Set(const otOperationalDataset &aDataset, uint8_t &aFlags);
ThreadError Set(const Dataset &aDataset);
ThreadError Set(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength,
@@ -92,8 +87,6 @@ protected:
void HandleNetworkUpdate(uint8_t &aFlags);
ThreadError Set(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
Dataset mLocal;
Dataset mNetwork;
@@ -107,7 +100,6 @@ private:
void HandleTimer(void);
ThreadError Register(void);
void SendSetResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo, StateTlv::State aState);
void SendGetResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
uint8_t *aTlvs, uint8_t aLength);
@@ -115,6 +107,19 @@ private:
const char *mUriSet;
const char *mUriGet;
#if OPENTHREAD_FTD
public:
ThreadError SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength);
ThreadError SendGetRequest(const uint8_t *aTlvTypes, uint8_t aLength, const otIp6Address *aAddress);
protected:
ThreadError Set(const otOperationalDataset &aDataset, uint8_t &aFlags);
ThreadError Set(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
private:
void SendSetResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo, StateTlv::State aState);
#endif
};
class ActiveDatasetBase: public DatasetManager
@@ -126,7 +131,9 @@ public:
ThreadError Clear(bool aOnlyClearNetwork);
#if OPENTHREAD_FTD
ThreadError Set(const otOperationalDataset &aDataset);
#endif
ThreadError Set(const Dataset &aDataset);
@@ -149,7 +156,9 @@ public:
ThreadError Clear(bool aOnlyClearNetwork);
#if OPENTHREAD_FTD
ThreadError Set(const otOperationalDataset &aDataset);
#endif
ThreadError Set(const Dataset &aDataset);
@@ -157,8 +166,6 @@ public:
void UpdateDelayTimer(void);
void ApplyActiveDataset(const Timestamp &aTimestamp, Message &aMessage);
protected:
static void HandleTimer(void *aContext);
void HandleTimer(void);
+39
View File
@@ -252,6 +252,45 @@ exit:
return;
}
void PendingDataset::ApplyActiveDataset(const Timestamp &aTimestamp, Message &aMessage)
{
uint16_t offset = aMessage.GetOffset();
DelayTimerTlv delayTimer;
uint8_t flags;
VerifyOrExit(mNetif.GetMle().IsAttached());
while (offset < aMessage.GetLength())
{
OT_TOOL_PACKED_BEGIN
struct
{
Tlv tlv;
uint8_t value[Dataset::kMaxValueSize];
} OT_TOOL_PACKED_END data;
aMessage.Read(offset, sizeof(Tlv), &data.tlv);
aMessage.Read(offset + sizeof(Tlv), data.tlv.GetLength(), data.value);
mNetwork.Set(data.tlv);
offset += sizeof(Tlv) + data.tlv.GetLength();
}
// add delay timer tlv
delayTimer.Init();
delayTimer.SetDelayTimer(mNetif.GetLeader().GetDelayTimerMinimal());
mNetwork.Set(delayTimer);
// add pending timestamp tlv
mNetwork.SetTimestamp(aTimestamp);
HandleNetworkUpdate(flags);
// reset delay timer
ResetDelayTimer(kFlagNetworkUpdated);
exit:
return;
}
} // namespace MeshCoP
} // namespace Thread
+2
View File
@@ -75,6 +75,8 @@ public:
void StopLeader(void);
void ApplyActiveDataset(const Timestamp &aTimestamp, Message &aMessage);
private:
static void HandleSet(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);
-8
View File
@@ -49,20 +49,12 @@ public:
ActiveDataset(ThreadNetif &aThreadNetif) : ActiveDatasetBase(aThreadNetif) { }
ThreadError GenerateLocal(void) { return kThreadError_NotImplemented; }
void StartLeader(void) { }
void StopLeader(void) { }
};
class PendingDataset: public PendingDatasetBase
{
public:
PendingDataset(ThreadNetif &aThreadNetif) : PendingDatasetBase(aThreadNetif) { }
void StartLeader(void) { }
void StopLeader(void) { }
};
} // namespace MeshCoP
+227 -7
View File
@@ -26,10 +26,230 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if OPENTHREAD_MTD
#include "joiner_router_mtd.hpp"
#elif OPENTHREAD_FTD
#include "joiner_router_ftd.hpp"
#else
#error "Please define OPENTHREAD_MTD=1, or OPENTHREAD_FTD=1"
#endif
/**
* @file
* This file includes definitions for the Joiner Router role.
*/
#ifndef JOINER_ROUTER_HPP_
#define JOINER_ROUTER_HPP_
#include "openthread/types.h"
#include <coap/coap_header.hpp>
#include <coap/coap_client.hpp>
#include <coap/coap_server.hpp>
#include <coap/coap_base.hpp>
#include <common/message.hpp>
#include <common/timer.hpp>
#include <mac/mac_frame.hpp>
#include <meshcop/tlvs.hpp>
#include <net/udp6.hpp>
#include <thread/key_manager.hpp>
namespace Thread {
class ThreadNetif;
namespace MeshCoP {
class JoinerRouter
{
public:
/**
* This constructor initializes the Joiner Router object.
*
* @param[in] aThreadNetif A reference to the Thread network interface.
*
*/
JoinerRouter(ThreadNetif &aNetif);
/**
* This method returns the pointer to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure.
*
*/
otInstance *GetInstance(void);
/**
* This method returns the Joiner UDP Port.
*
* @returns The Joiner UDP Port number .
*
*/
uint16_t GetJoinerUdpPort(void);
/**
* This method sets the Joiner UDP Port.
*
* @param[in] The Joiner UDP Port number.
*
* @retval kThreadError_None Successfully set the Joiner UDP Port.
*
*/
ThreadError SetJoinerUdpPort(uint16_t aJoinerUdpPort);
private:
enum
{
kDelayJoinEnt = 50, ///< milliseconds
};
static void HandleNetifStateChanged(uint32_t aFlags, void *aContext);
void HandleNetifStateChanged(uint32_t aFlags);
static void HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
static void HandleRelayTransmit(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);
void HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
static void HandleJoinerEntrustResponse(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo, ThreadError result);
void HandleJoinerEntrustResponse(Coap::Header *aHeader, Message *aMessage,
const Ip6::MessageInfo *aMessageInfo, ThreadError result);
static void HandleTimer(void *aContext);
void HandleTimer(void);
ThreadError DelaySendingJoinerEntrust(const Ip6::MessageInfo &aMessageInfo, const JoinerRouterKekTlv &aKek);
void SendDelayedJoinerEntrust(void);
ThreadError SendJoinerEntrust(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError GetBorderAgentRloc(uint16_t &aRloc);
Ip6::NetifCallback mNetifCallback;
Ip6::UdpSocket mSocket;
Coap::Resource mRelayTransmit;
ThreadNetif &mNetif;
Timer mTimer;
MessageQueue mDelayedJoinEnts;
uint16_t mJoinerUdpPort;
bool mIsJoinerPortConfigured : 1;
bool mExpectJoinEntRsp : 1;
};
/**
* This class implements functionality required for delaying JOIN_ENT.ntf messages.
*
*/
class DelayedJoinEntHeader
{
public:
/**
* Default constructor for the object.
*
*/
DelayedJoinEntHeader(void) { memset(this, 0, sizeof(*this)); }
/**
* This constructor initializes the object with specific values.
*
* @param[in] aSendTime Time when the message shall be sent.
* @param[in] aDestination IPv6 address of the message destination.
*
*/
DelayedJoinEntHeader(uint32_t aSendTime, Ip6::MessageInfo &aMessageInfo, const uint8_t *aKek) {
mSendTime = aSendTime;
mMessageInfo = aMessageInfo;
memcpy(&mKek, aKek, sizeof(mKek));
}
/**
* This method appends delayed response header to the message.
*
* @param[in] aMessage A reference to the message.
*
* @retval kThreadError_None Successfully appended the bytes.
* @retval kThreadError_NoBufs Insufficient available buffers to grow the message.
*
*/
ThreadError AppendTo(Message &aMessage) {
return aMessage.Append(this, sizeof(*this));
}
/**
* This method reads delayed response header from the message.
*
* @param[in] aMessage A reference to the message.
*
* @returns The number of bytes read.
*
*/
uint16_t ReadFrom(Message &aMessage) {
return aMessage.Read(aMessage.GetLength() - sizeof(*this), sizeof(*this), this);
}
/**
* This method removes delayed response header from the message.
*
* @param[in] aMessage A reference to the message.
*
* @retval kThreadError_None Successfully removed the header.
*
*/
static ThreadError RemoveFrom(Message &aMessage) {
return aMessage.SetLength(aMessage.GetLength() - sizeof(DelayedJoinEntHeader));
}
/**
* This method returns a time when the message shall be sent.
*
* @returns A time when the message shall be sent.
*
*/
uint32_t GetSendTime(void) const { return mSendTime; }
/**
* This method returns a destination of the delayed message.
*
* @returns A destination of the delayed message.
*
*/
const Ip6::MessageInfo *GetMessageInfo(void) const { return &mMessageInfo; }
/**
* This method returns a pointer to the KEK that should be used to send the delayed message.
*
* @returns A pointer to the KEK.
*
*/
const uint8_t *GetKek(void) const { return mKek; }
/**
* This method checks if the message shall be sent before the given time.
*
* @param[in] aTime A time to compare.
*
* @retval TRUE If the message shall be sent before the given time.
* @retval FALSE Otherwise.
*/
bool IsEarlier(uint32_t aTime) { return (static_cast<int32_t>(aTime - mSendTime) > 0); }
/**
* This method checks if the message shall be sent after the given time.
*
* @param[in] aTime A time to compare.
*
* @retval TRUE If the message shall be sent after the given time.
* @retval FALSE Otherwise.
*/
bool IsLater(uint32_t aTime) { return (static_cast<int32_t>(aTime - mSendTime) < 0); }
private:
Ip6::MessageInfo mMessageInfo; ///< Message info of the message to send.
uint32_t mSendTime; ///< Time when the message shall be sent.
uint8_t mKek[KeyManager::kMaxKeyLength]; ///< KEK used by MAC layer to encode this message.
};
} // namespace MeshCoP
} // namespace Thread
#endif // JOINER_ROUTER_HPP_
-255
View File
@@ -1,255 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes definitions for the Joiner Router role.
*/
#ifndef JOINER_ROUTER_HPP_
#define JOINER_ROUTER_HPP_
#include "openthread/types.h"
#include <coap/coap_header.hpp>
#include <coap/coap_client.hpp>
#include <coap/coap_server.hpp>
#include <coap/coap_base.hpp>
#include <common/message.hpp>
#include <common/timer.hpp>
#include <mac/mac_frame.hpp>
#include <meshcop/tlvs.hpp>
#include <net/udp6.hpp>
#include <thread/key_manager.hpp>
namespace Thread {
class ThreadNetif;
namespace MeshCoP {
class JoinerRouter
{
public:
/**
* This constructor initializes the Joiner Router object.
*
* @param[in] aThreadNetif A reference to the Thread network interface.
*
*/
JoinerRouter(ThreadNetif &aNetif);
/**
* This method returns the pointer to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure.
*
*/
otInstance *GetInstance(void);
/**
* This method returns the Joiner UDP Port.
*
* @returns The Joiner UDP Port number .
*
*/
uint16_t GetJoinerUdpPort(void);
/**
* This method sets the Joiner UDP Port.
*
* @param[in] The Joiner UDP Port number.
*
* @retval kThreadError_None Successfully set the Joiner UDP Port.
*
*/
ThreadError SetJoinerUdpPort(uint16_t aJoinerUdpPort);
private:
enum
{
kDelayJoinEnt = 50, ///< milliseconds
};
static void HandleNetifStateChanged(uint32_t aFlags, void *aContext);
void HandleNetifStateChanged(uint32_t aFlags);
static void HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
static void HandleRelayTransmit(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);
void HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
static void HandleJoinerEntrustResponse(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo, ThreadError result);
void HandleJoinerEntrustResponse(Coap::Header *aHeader, Message *aMessage,
const Ip6::MessageInfo *aMessageInfo, ThreadError result);
static void HandleTimer(void *aContext);
void HandleTimer(void);
ThreadError DelaySendingJoinerEntrust(const Ip6::MessageInfo &aMessageInfo, const JoinerRouterKekTlv &aKek);
void SendDelayedJoinerEntrust(void);
ThreadError SendJoinerEntrust(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError GetBorderAgentRloc(uint16_t &aRloc);
Ip6::NetifCallback mNetifCallback;
Ip6::UdpSocket mSocket;
Coap::Resource mRelayTransmit;
ThreadNetif &mNetif;
Timer mTimer;
MessageQueue mDelayedJoinEnts;
uint16_t mJoinerUdpPort;
bool mIsJoinerPortConfigured : 1;
bool mExpectJoinEntRsp : 1;
};
/**
* This class implements functionality required for delaying JOIN_ENT.ntf messages.
*
*/
class DelayedJoinEntHeader
{
public:
/**
* Default constructor for the object.
*
*/
DelayedJoinEntHeader(void) { memset(this, 0, sizeof(*this)); }
/**
* This constructor initializes the object with specific values.
*
* @param[in] aSendTime Time when the message shall be sent.
* @param[in] aDestination IPv6 address of the message destination.
*
*/
DelayedJoinEntHeader(uint32_t aSendTime, Ip6::MessageInfo &aMessageInfo, const uint8_t *aKek) {
mSendTime = aSendTime;
mMessageInfo = aMessageInfo;
memcpy(&mKek, aKek, sizeof(mKek));
}
/**
* This method appends delayed response header to the message.
*
* @param[in] aMessage A reference to the message.
*
* @retval kThreadError_None Successfully appended the bytes.
* @retval kThreadError_NoBufs Insufficient available buffers to grow the message.
*
*/
ThreadError AppendTo(Message &aMessage) {
return aMessage.Append(this, sizeof(*this));
}
/**
* This method reads delayed response header from the message.
*
* @param[in] aMessage A reference to the message.
*
* @returns The number of bytes read.
*
*/
uint16_t ReadFrom(Message &aMessage) {
return aMessage.Read(aMessage.GetLength() - sizeof(*this), sizeof(*this), this);
}
/**
* This method removes delayed response header from the message.
*
* @param[in] aMessage A reference to the message.
*
* @retval kThreadError_None Successfully removed the header.
*
*/
static ThreadError RemoveFrom(Message &aMessage) {
return aMessage.SetLength(aMessage.GetLength() - sizeof(DelayedJoinEntHeader));
}
/**
* This method returns a time when the message shall be sent.
*
* @returns A time when the message shall be sent.
*
*/
uint32_t GetSendTime(void) const { return mSendTime; }
/**
* This method returns a destination of the delayed message.
*
* @returns A destination of the delayed message.
*
*/
const Ip6::MessageInfo *GetMessageInfo(void) const { return &mMessageInfo; }
/**
* This method returns a pointer to the KEK that should be used to send the delayed message.
*
* @returns A pointer to the KEK.
*
*/
const uint8_t *GetKek(void) const { return mKek; }
/**
* This method checks if the message shall be sent before the given time.
*
* @param[in] aTime A time to compare.
*
* @retval TRUE If the message shall be sent before the given time.
* @retval FALSE Otherwise.
*/
bool IsEarlier(uint32_t aTime) { return (static_cast<int32_t>(aTime - mSendTime) > 0); }
/**
* This method checks if the message shall be sent after the given time.
*
* @param[in] aTime A time to compare.
*
* @retval TRUE If the message shall be sent after the given time.
* @retval FALSE Otherwise.
*/
bool IsLater(uint32_t aTime) { return (static_cast<int32_t>(aTime - mSendTime) < 0); }
private:
Ip6::MessageInfo mMessageInfo; ///< Message info of the message to send.
uint32_t mSendTime; ///< Time when the message shall be sent.
uint8_t mKek[KeyManager::kMaxKeyLength]; ///< KEK used by MAC layer to encode this message.
};
} // namespace MeshCoP
} // namespace Thread
#endif // JOINER_ROUTER_HPP_
+127 -7
View File
@@ -26,11 +26,131 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if OPENTHREAD_MTD
#include "leader_mtd.hpp"
#elif OPENTHREAD_FTD
#include "leader_ftd.hpp"
#else
#error "Please define OPENTHREAD_MTD=1 or OPENTHREAD_FTD=1"
#endif
/**
* @file
* This file includes definitions for a MeshCoP Leader.
*/
#ifndef MESHCOP_LEADER_HPP_
#define MESHCOP_LEADER_HPP_
#include <coap/coap_client.hpp>
#include <coap/coap_server.hpp>
#include <common/timer.hpp>
#include <meshcop/tlvs.hpp>
#include <net/udp6.hpp>
#include <thread/mle.hpp>
namespace Thread {
namespace MeshCoP {
OT_TOOL_PACKED_BEGIN
class CommissioningData
{
public:
uint8_t GetLength(void) const {
return sizeof(Tlv) + mBorderAgentLocator.GetLength() +
sizeof(Tlv) + mCommissionerSessionId.GetLength() +
sizeof(Tlv) + mSteeringData.GetLength();
}
BorderAgentLocatorTlv mBorderAgentLocator;
CommissionerSessionIdTlv mCommissionerSessionId;
SteeringDataTlv mSteeringData;
} OT_TOOL_PACKED_END;
class Leader
{
public:
/**
* This constructor initializes the Leader object.
*
* @param[in] aThreadNetif A reference to the Thread network interface.
*
*/
Leader(ThreadNetif &aThreadNetif);
/**
* This method returns the pointer to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure.
*
*/
otInstance *GetInstance(void);
/**
* This method sends a MGMT_DATASET_CHANGED message to commissioner.
*
* @param[in] aAddress The IPv6 address of destination.
*
* @retval kThreadError_None Successfully send MGMT_DATASET_CHANGED message.
* @retval kThreadError_NoBufs Insufficient buffers to generate a MGMT_DATASET_CHANGED message.
*
*/
ThreadError SendDatasetChanged(const Ip6::Address &aAddress);
/**
* This method sets minimal delay timer.
*
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
*
* @retval kThreadError_None Successfully set the minimal delay timer.
* @retval kThreadError_InvalidArgs If @p aDelayTimerMinimal is not valid.
*
*/
ThreadError SetDelayTimerMinimal(uint32_t aDelayTimerMinimal);
/**
* This method gets minimal delay timer.
*
* @retval the miniaml delay timer (in ms).
*
*/
uint32_t GetDelayTimerMinimal(void) const;
/**
* This method sets empty Commissioner Data TLV in the Thread Network Data.
*
*/
void SetEmptyCommissionerData(void);
private:
enum
{
kTimeoutLeaderPetition = 50, ///< TIMEOUT_LEAD_PET (seconds)
};
static void HandleTimer(void *aContext);
void HandleTimer(void);
static void HandlePetition(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);
void HandlePetition(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError SendPetitionResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
StateTlv::State aState);
static void HandleKeepAlive(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);
void HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError SendKeepAliveResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
StateTlv::State aState);
static void HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void ResignCommissioner(void);
Coap::Resource mPetition;
Coap::Resource mKeepAlive;
Timer mTimer;
uint32_t mDelayTimerMinimal;
CommissionerIdTlv mCommissionerId;
uint16_t mSessionId;
ThreadNetif &mNetif;
};
} // namespace MeshCoP
} // namespace Thread
#endif // MESHCOP_LEADER_HPP_
-156
View File
@@ -1,156 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes definitions for a MeshCoP Leader.
*/
#ifndef MESHCOP_LEADER_HPP_
#define MESHCOP_LEADER_HPP_
#include <coap/coap_client.hpp>
#include <coap/coap_server.hpp>
#include <common/timer.hpp>
#include <meshcop/tlvs.hpp>
#include <net/udp6.hpp>
#include <thread/mle.hpp>
namespace Thread {
namespace MeshCoP {
OT_TOOL_PACKED_BEGIN
class CommissioningData
{
public:
uint8_t GetLength(void) const {
return sizeof(Tlv) + mBorderAgentLocator.GetLength() +
sizeof(Tlv) + mCommissionerSessionId.GetLength() +
sizeof(Tlv) + mSteeringData.GetLength();
}
BorderAgentLocatorTlv mBorderAgentLocator;
CommissionerSessionIdTlv mCommissionerSessionId;
SteeringDataTlv mSteeringData;
} OT_TOOL_PACKED_END;
class Leader
{
public:
/**
* This constructor initializes the Leader object.
*
* @param[in] aThreadNetif A reference to the Thread network interface.
*
*/
Leader(ThreadNetif &aThreadNetif);
/**
* This method returns the pointer to the parent otInstance structure.
*
* @returns The pointer to the parent otInstance structure.
*
*/
otInstance *GetInstance(void);
/**
* This method sends a MGMT_DATASET_CHANGED message to commissioner.
*
* @param[in] aAddress The IPv6 address of destination.
*
* @retval kThreadError_None Successfully send MGMT_DATASET_CHANGED message.
* @retval kThreadError_NoBufs Insufficient buffers to generate a MGMT_DATASET_CHANGED message.
*
*/
ThreadError SendDatasetChanged(const Ip6::Address &aAddress);
/**
* This method sets minimal delay timer.
*
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
*
* @retval kThreadError_None Successfully set the minimal delay timer.
* @retval kThreadError_InvalidArgs If @p aDelayTimerMinimal is not valid.
*
*/
ThreadError SetDelayTimerMinimal(uint32_t aDelayTimerMinimal);
/**
* This method gets minimal delay timer.
*
* @retval the miniaml delay timer (in ms).
*
*/
uint32_t GetDelayTimerMinimal(void) const;
/**
* This method sets empty Commissioner Data TLV in the Thread Network Data.
*
*/
void SetEmptyCommissionerData(void);
private:
enum
{
kTimeoutLeaderPetition = 50, ///< TIMEOUT_LEAD_PET (seconds)
};
static void HandleTimer(void *aContext);
void HandleTimer(void);
static void HandlePetition(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);
void HandlePetition(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError SendPetitionResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
StateTlv::State aState);
static void HandleKeepAlive(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);
void HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
ThreadError SendKeepAliveResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
StateTlv::State aState);
static void HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void ResignCommissioner(void);
Coap::Resource mPetition;
Coap::Resource mKeepAlive;
Timer mTimer;
uint32_t mDelayTimerMinimal;
CommissionerIdTlv mCommissionerId;
uint16_t mSessionId;
ThreadNetif &mNetif;
};
} // namespace MeshCoP
} // namespace Thread
#endif // MESHCOP_LEADER_HPP_
+2
View File
@@ -92,8 +92,10 @@ ThreadNetif::ThreadNetif(Ip6::Ip6 &aIp6):
#if OPENTHREAD_ENABLE_JAM_DETECTION
mJamDetector(*this),
#endif // OPENTHREAD_ENABLE_JAM_DETECTTION
#if OPENTHREAD_FTD
mJoinerRouter(*this),
mLeader(*this),
#endif // OPENTHREAD_FTD
mAnnounceBegin(*this),
mPanIdQuery(*this),
mEnergyScan(*this)
+5
View File
@@ -287,9 +287,11 @@ public:
MeshCoP::PendingDataset &GetPendingDataset(void) { return mPendingDataset; }
#if OPENTHREAD_FTD
MeshCoP::JoinerRouter &GetJoinerRouter(void) { return mJoinerRouter; }
MeshCoP::Leader &GetLeader(void) { return mLeader; }
#endif // OPENTHREAD_FTD
AnnounceBeginServer &GetAnnounceBeginServer(void) { return mAnnounceBegin; }
@@ -371,8 +373,11 @@ private:
Utils::JamDetector mJamDetector;
#endif // OPENTHREAD_ENABLE_JAM_DETECTION
#if OPENTHREAD_FTD
MeshCoP::JoinerRouter mJoinerRouter;
MeshCoP::Leader mLeader;
#endif // OPENTHREAD_FTD
AnnounceBeginServer mAnnounceBegin;
PanIdQueryServer mPanIdQuery;
EnergyScanServer mEnergyScan;