mirror of
https://github.com/espressif/openthread.git
synced 2026-08-30 22:09:54 +00:00
[meshcop] support operational dataset operations for MTD (#3339)
- This commit unties operational dataset operations from `OPENTHREAD_FTD` option. - This commit also updates THCI for MTD certification
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#define OPENTHREAD_DATASET_H_
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -286,6 +287,19 @@ OTAPI bool OTCALL otDatasetIsCommissioned(otInstance *aInstance);
|
||||
*/
|
||||
OTAPI otError 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 OT_ERROR_NONE Successfully set the Active Operational Dataset.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Active Operational Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* This function gets the Pending Operational Dataset.
|
||||
*
|
||||
@@ -298,6 +312,116 @@ OTAPI otError OTCALL otDatasetGetActive(otInstance *aInstance, otOperationalData
|
||||
*/
|
||||
OTAPI otError 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 OT_ERROR_NONE Successfully set the Pending Operational Dataset.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Pending Operational Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* This function sends MGMT_ACTIVE_GET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength The length of @p aTlvTypes.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSendMgmtActiveGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
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 OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError 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] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength The length of @p aTlvTypes.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSendMgmtPendingGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
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 OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError 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.
|
||||
*
|
||||
* @note This API is reserved for testing and demo purposes only. Changing settings with
|
||||
* this API will render a production application non-compliant with the Thread Specification.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set minimal delay timer.
|
||||
* @retval OT_ERROR_INVALID_ARGS If @p aDelayTimerMinimal is not valid.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
@@ -49,104 +49,6 @@ extern "C" {
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 OT_ERROR_NONE Successfully set the Active Operational Dataset.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Active Operational Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
|
||||
*
|
||||
*/
|
||||
OTAPI otError 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 OT_ERROR_NONE Successfully set the Pending Operational Dataset.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Pending Operational Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset);
|
||||
|
||||
/**
|
||||
* This function sends MGMT_ACTIVE_GET.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength The length of @p aTlvTypes.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSendMgmtActiveGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
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 OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError 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] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength The length of @p aTlvTypes.
|
||||
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSendMgmtPendingGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
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 OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otDatasetSendMgmtPendingSet(otInstance * aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
const uint8_t * aTlvs,
|
||||
uint8_t aLength);
|
||||
|
||||
/**
|
||||
* Get minimal delay timer.
|
||||
*
|
||||
|
||||
@@ -37,9 +37,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
#include <openthread/dataset_ftd.h>
|
||||
#endif
|
||||
#include <openthread/dataset.h>
|
||||
|
||||
#include "cli/cli.hpp"
|
||||
|
||||
@@ -49,7 +47,6 @@ namespace Cli {
|
||||
const DatasetCommand Dataset::sCommands[] = {
|
||||
{"help", &ProcessHelp},
|
||||
{"active", &ProcessActive},
|
||||
#if OPENTHREAD_FTD
|
||||
{"activetimestamp", &ProcessActiveTimestamp},
|
||||
{"channel", &ProcessChannel},
|
||||
{"channelmask", &ProcessChannelMask},
|
||||
@@ -63,13 +60,10 @@ 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;
|
||||
@@ -254,7 +248,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
otError Dataset::ProcessActiveTimestamp(otInstance *aInstance, int argc, char *argv[])
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
@@ -747,7 +740,6 @@ otError Dataset::ProcessSecurityPolicy(otInstance *aInstance, int argc, char *ar
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
} // namespace Cli
|
||||
} // namespace ot
|
||||
|
||||
@@ -63,6 +63,19 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset)
|
||||
{
|
||||
otError error;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
VerifyOrExit(aDataset != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
error = instance.GetThreadNetif().GetActiveDataset().Set(*aDataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -75,3 +88,60 @@ otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDatase
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset)
|
||||
{
|
||||
otError error;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
VerifyOrExit(aDataset != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
error = instance.GetThreadNetif().GetPendingDataset().Set(*aDataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtActiveGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetActiveDataset().SendGetRequest(*aDatasetComponents, aTlvTypes, aLength,
|
||||
aAddress);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
const uint8_t * aTlvs,
|
||||
uint8_t aLength)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetActiveDataset().SendSetRequest(*aDataset, aTlvs, aLength);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtPendingGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetPendingDataset().SendGetRequest(*aDatasetComponents, aTlvTypes, aLength,
|
||||
aAddress);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
const uint8_t * aTlvs,
|
||||
uint8_t aLength)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetPendingDataset().SendSetRequest(*aDataset, aTlvs, aLength);
|
||||
}
|
||||
|
||||
@@ -41,76 +41,6 @@
|
||||
|
||||
using namespace ot;
|
||||
|
||||
otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset)
|
||||
{
|
||||
otError error;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
VerifyOrExit(aDataset != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
error = instance.GetThreadNetif().GetActiveDataset().Set(*aDataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset)
|
||||
{
|
||||
otError error;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
VerifyOrExit(aDataset != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
error = instance.GetThreadNetif().GetPendingDataset().Set(*aDataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtActiveGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetActiveDataset().SendGetRequest(*aDatasetComponents, aTlvTypes, aLength,
|
||||
aAddress);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
const uint8_t * aTlvs,
|
||||
uint8_t aLength)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetActiveDataset().SendSetRequest(*aDataset, aTlvs, aLength);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtPendingGet(otInstance * aInstance,
|
||||
const otOperationalDatasetComponents *aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetPendingDataset().SendGetRequest(*aDatasetComponents, aTlvTypes, aLength,
|
||||
aAddress);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
|
||||
const otOperationalDataset *aDataset,
|
||||
const uint8_t * aTlvs,
|
||||
uint8_t aLength)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetPendingDataset().SendSetRequest(*aDataset, aTlvs, aLength);
|
||||
}
|
||||
|
||||
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
@@ -256,7 +256,6 @@ otError Dataset::Set(const Dataset &aDataset)
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
otError Dataset::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -369,7 +368,6 @@ otError Dataset::Set(const otOperationalDataset &aDataset)
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
const Timestamp *Dataset::GetTimestamp(void) const
|
||||
{
|
||||
|
||||
@@ -192,7 +192,6 @@ public:
|
||||
*/
|
||||
otError Set(const Dataset &aDataset);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
/**
|
||||
* This method sets the Dataset.
|
||||
*
|
||||
@@ -202,7 +201,6 @@ public:
|
||||
*
|
||||
*/
|
||||
otError Set(const otOperationalDataset &aDataset);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This method removes a TLV from the Dataset.
|
||||
|
||||
@@ -142,8 +142,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
otError DatasetLocal::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -159,8 +157,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
otError DatasetLocal::Set(const Dataset &aDataset)
|
||||
{
|
||||
const Timestamp *timestamp;
|
||||
|
||||
@@ -114,7 +114,6 @@ public:
|
||||
*/
|
||||
uint32_t GetUpdateTime(void) const { return mUpdateTime; }
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
/**
|
||||
* This method stores the dataset into non-volatile memory.
|
||||
*
|
||||
@@ -122,7 +121,6 @@ public:
|
||||
*
|
||||
*/
|
||||
otError Set(const otOperationalDataset &aDataset);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This method stores the dataset into non-volatile memory.
|
||||
|
||||
@@ -83,15 +83,6 @@ int DatasetManager::Compare(const Timestamp &aTimestamp) const
|
||||
return rval;
|
||||
}
|
||||
|
||||
otError DatasetManager::AppendMleDatasetTlv(Message &aMessage) const
|
||||
{
|
||||
Dataset dataset(mLocal.GetType());
|
||||
|
||||
mLocal.Get(dataset);
|
||||
|
||||
return dataset.AppendMleDatasetTlv(aMessage);
|
||||
}
|
||||
|
||||
otError DatasetManager::Restore(void)
|
||||
{
|
||||
otError error;
|
||||
@@ -187,6 +178,42 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetManager::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = mLocal.Set(aDataset));
|
||||
|
||||
switch (netif.GetMle().GetRole())
|
||||
{
|
||||
case OT_DEVICE_ROLE_DISABLED:
|
||||
Restore();
|
||||
break;
|
||||
|
||||
case OT_DEVICE_ROLE_CHILD:
|
||||
mTimer.Start(1000);
|
||||
break;
|
||||
#if OPENTHREAD_FTD
|
||||
case OT_DEVICE_ROLE_ROUTER:
|
||||
mTimer.Start(1000);
|
||||
break;
|
||||
|
||||
case OT_DEVICE_ROLE_LEADER:
|
||||
Restore();
|
||||
netif.GetNetworkDataLeader().IncrementVersion();
|
||||
netif.GetNetworkDataLeader().IncrementStableVersion();
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void DatasetManager::HandleTimer(void)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
@@ -369,6 +396,294 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
otError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength)
|
||||
{
|
||||
ThreadNetif & netif = GetNetif();
|
||||
otError error = OT_ERROR_NONE;
|
||||
Coap::Header header;
|
||||
Message * message;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(mUriSet);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
VerifyOrExit((message = NewMeshCoPMessage(netif.GetCoap(), header)) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
|
||||
if (netif.GetCommissioner().IsActive())
|
||||
{
|
||||
const uint8_t *cur = aTlvs;
|
||||
const uint8_t *end = aTlvs + aLength;
|
||||
bool hasSessionId = false;
|
||||
|
||||
while (cur < end)
|
||||
{
|
||||
const Tlv *data = reinterpret_cast<const Tlv *>(cur);
|
||||
|
||||
if (data->GetType() == Tlv::kCommissionerSessionId)
|
||||
{
|
||||
hasSessionId = true;
|
||||
break;
|
||||
}
|
||||
|
||||
cur += sizeof(Tlv) + data->GetLength();
|
||||
}
|
||||
|
||||
if (!hasSessionId)
|
||||
{
|
||||
CommissionerSessionIdTlv sessionId;
|
||||
sessionId.Init();
|
||||
sessionId.SetCommissionerSessionId(netif.GetCommissioner().GetSessionId());
|
||||
SuccessOrExit(error = message->Append(&sessionId, sizeof(sessionId)));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
|
||||
|
||||
if (aDataset.mComponents.mIsActiveTimestampPresent)
|
||||
{
|
||||
ActiveTimestampTlv timestamp;
|
||||
timestamp.Init();
|
||||
static_cast<Timestamp *>(×tamp)->SetSeconds(aDataset.mActiveTimestamp);
|
||||
static_cast<Timestamp *>(×tamp)->SetTicks(0);
|
||||
SuccessOrExit(error = message->Append(×tamp, sizeof(timestamp)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsPendingTimestampPresent)
|
||||
{
|
||||
PendingTimestampTlv timestamp;
|
||||
timestamp.Init();
|
||||
static_cast<Timestamp *>(×tamp)->SetSeconds(aDataset.mPendingTimestamp);
|
||||
static_cast<Timestamp *>(×tamp)->SetTicks(0);
|
||||
SuccessOrExit(error = message->Append(×tamp, sizeof(timestamp)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsMasterKeyPresent)
|
||||
{
|
||||
NetworkMasterKeyTlv masterkey;
|
||||
masterkey.Init();
|
||||
masterkey.SetNetworkMasterKey(aDataset.mMasterKey);
|
||||
SuccessOrExit(error = message->Append(&masterkey, sizeof(masterkey)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsNetworkNamePresent)
|
||||
{
|
||||
NetworkNameTlv networkname;
|
||||
networkname.Init();
|
||||
networkname.SetNetworkName(aDataset.mNetworkName.m8);
|
||||
SuccessOrExit(error = message->Append(&networkname, sizeof(Tlv) + networkname.GetLength()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsExtendedPanIdPresent)
|
||||
{
|
||||
ExtendedPanIdTlv extpanid;
|
||||
extpanid.Init();
|
||||
extpanid.SetExtendedPanId(aDataset.mExtendedPanId);
|
||||
SuccessOrExit(error = message->Append(&extpanid, sizeof(extpanid)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsMeshLocalPrefixPresent)
|
||||
{
|
||||
MeshLocalPrefixTlv localprefix;
|
||||
localprefix.Init();
|
||||
localprefix.SetMeshLocalPrefix(aDataset.mMeshLocalPrefix);
|
||||
SuccessOrExit(error = message->Append(&localprefix, sizeof(localprefix)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsDelayPresent)
|
||||
{
|
||||
DelayTimerTlv delaytimer;
|
||||
delaytimer.Init();
|
||||
delaytimer.SetDelayTimer(aDataset.mDelay);
|
||||
SuccessOrExit(error = message->Append(&delaytimer, sizeof(delaytimer)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsPanIdPresent)
|
||||
{
|
||||
PanIdTlv panid;
|
||||
panid.Init();
|
||||
panid.SetPanId(aDataset.mPanId);
|
||||
SuccessOrExit(error = message->Append(&panid, sizeof(panid)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsChannelPresent)
|
||||
{
|
||||
ChannelTlv channel;
|
||||
channel.Init();
|
||||
channel.SetChannelPage(OT_RADIO_CHANNEL_PAGE);
|
||||
channel.SetChannel(aDataset.mChannel);
|
||||
SuccessOrExit(error = message->Append(&channel, sizeof(channel)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsChannelMaskPage0Present)
|
||||
{
|
||||
ChannelMaskTlv channelMask;
|
||||
channelMask.Init();
|
||||
channelMask.SetChannelPage(OT_RADIO_CHANNEL_PAGE);
|
||||
channelMask.SetMask(aDataset.mChannelMaskPage0);
|
||||
SuccessOrExit(error = message->Append(&channelMask, sizeof(channelMask)));
|
||||
}
|
||||
|
||||
if (aLength > 0)
|
||||
{
|
||||
SuccessOrExit(error = message->Append(aTlvs, aLength));
|
||||
}
|
||||
|
||||
if (message->GetLength() == header.GetLength())
|
||||
{
|
||||
// no payload, remove coap payload marker
|
||||
message->SetLength(message->GetLength() - 1);
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(netif.GetMle().GetMeshLocal16());
|
||||
netif.GetMle().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = netif.GetCoap().SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset set request to leader");
|
||||
|
||||
exit:
|
||||
|
||||
if (error != OT_ERROR_NONE && message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetManager::SendGetRequest(const otOperationalDatasetComponents &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const
|
||||
{
|
||||
ThreadNetif & netif = GetNetif();
|
||||
otError error = OT_ERROR_NONE;
|
||||
Coap::Header header;
|
||||
Message * message;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Tlv tlv;
|
||||
uint8_t datasetTlvs[kMaxDatasetTlvs];
|
||||
uint8_t length;
|
||||
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(mUriGet);
|
||||
|
||||
length = 0;
|
||||
|
||||
if (aDatasetComponents.mIsActiveTimestampPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kActiveTimestamp;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPendingTimestampPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPendingTimestamp;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsMasterKeyPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kNetworkMasterKey;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsNetworkNamePresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kNetworkName;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsExtendedPanIdPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kExtendedPanId;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsMeshLocalPrefixPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kMeshLocalPrefix;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsDelayPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kDelayTimer;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPanIdPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPanId;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsChannelPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kChannel;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPSKcPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPSKc;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsSecurityPolicyPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kSecurityPolicy;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsChannelMaskPage0Present)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kChannelMask;
|
||||
}
|
||||
|
||||
if (aLength + length > 0)
|
||||
{
|
||||
header.SetPayloadMarker();
|
||||
}
|
||||
|
||||
VerifyOrExit((message = NewMeshCoPMessage(netif.GetCoap(), header)) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
if (aLength + length > 0)
|
||||
{
|
||||
tlv.SetType(Tlv::kGet);
|
||||
tlv.SetLength(aLength + length);
|
||||
SuccessOrExit(error = message->Append(&tlv, sizeof(tlv)));
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
SuccessOrExit(error = message->Append(datasetTlvs, length));
|
||||
}
|
||||
|
||||
if (aLength > 0)
|
||||
{
|
||||
SuccessOrExit(error = message->Append(aTlvTypes, aLength));
|
||||
}
|
||||
}
|
||||
|
||||
if (aAddress != NULL)
|
||||
{
|
||||
messageInfo.SetPeerAddr(*static_cast<const Ip6::Address *>(aAddress));
|
||||
}
|
||||
else
|
||||
{
|
||||
netif.GetMle().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(netif.GetMle().GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = netif.GetCoap().SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset get request");
|
||||
|
||||
exit:
|
||||
|
||||
if (error != OT_ERROR_NONE && message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
ActiveDataset::ActiveDataset(Instance &aInstance)
|
||||
: DatasetManager(aInstance,
|
||||
Tlv::kActiveTimestamp,
|
||||
@@ -393,6 +708,11 @@ void ActiveDataset::Set(const Dataset &aDataset)
|
||||
DatasetManager::Set(aDataset);
|
||||
}
|
||||
|
||||
otError ActiveDataset::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
return DatasetManager::Set(aDataset);
|
||||
}
|
||||
|
||||
otError ActiveDataset::Set(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -456,6 +776,17 @@ void PendingDataset::ClearNetwork(void)
|
||||
DatasetManager::Set(dataset);
|
||||
}
|
||||
|
||||
otError PendingDataset::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = DatasetManager::Set(aDataset));
|
||||
StartDelayTimer();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError PendingDataset::Set(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
@@ -80,15 +80,6 @@ public:
|
||||
*/
|
||||
int Compare(const Timestamp &aTimestamp) const;
|
||||
|
||||
/**
|
||||
* This method appends the MLE Dataset TLV but excluding MeshCoP Sub Timestamp TLV.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully append MLE Dataset TLV without MeshCoP Sub Timestamp TLV.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient available buffers to append the message with MLE Dataset TLV.
|
||||
*
|
||||
*/
|
||||
otError AppendMleDatasetTlv(Message &aMessage) const;
|
||||
|
||||
/**
|
||||
* This method retrieves the dataset from non-volatile memory.
|
||||
*
|
||||
@@ -128,6 +119,36 @@ public:
|
||||
*/
|
||||
void HandleDetach(void);
|
||||
|
||||
/**
|
||||
* This method sends a MGMT_SET request to the Leader.
|
||||
*
|
||||
* @param[in] aDataset The Operational Datset.
|
||||
* @param[in] aTlvs Any additional raw TLVs to include.
|
||||
* @param[in] aLength Number of bytes in @p aTlvs.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
otError SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength);
|
||||
|
||||
/**
|
||||
* This method sends a MGMT_GET request.
|
||||
*
|
||||
* @param[in] aDatasetComponents An Operational Dataset components structure specifying components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength Number of bytes in @p aTlvTypes.
|
||||
* @param[in] aAddress The IPv6 destination address for the MGMT_GET request.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
otError SendGetRequest(const otOperationalDatasetComponents &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
@@ -162,6 +183,14 @@ protected:
|
||||
*/
|
||||
otError Set(const Dataset &aDataset);
|
||||
|
||||
/**
|
||||
* This method sets the Operational Dataset in non-volatile memory.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
*
|
||||
*/
|
||||
otError Set(const otOperationalDataset &aDataset);
|
||||
|
||||
/**
|
||||
* This method sets the Operational Dataset for the partition.
|
||||
*
|
||||
@@ -214,6 +243,11 @@ private:
|
||||
uint8_t * aTlvs,
|
||||
uint8_t aLength) const;
|
||||
|
||||
enum
|
||||
{
|
||||
kMaxDatasetTlvs = 16, // Maximum number of TLVs in an `otOperationalDataset`.
|
||||
};
|
||||
|
||||
TimerMilli mTimer;
|
||||
|
||||
const char *mUriGet;
|
||||
@@ -222,44 +256,15 @@ private:
|
||||
#if OPENTHREAD_FTD
|
||||
public:
|
||||
/**
|
||||
* This method sends a MGMT_SET request to the Leader.
|
||||
* This method appends the MLE Dataset TLV but excluding MeshCoP Sub Timestamp TLV.
|
||||
*
|
||||
* @param[in] aDataset The Operational Datset.
|
||||
* @param[in] aTlvs Any additional raw TLVs to include.
|
||||
* @param[in] aLength Number of bytes in @p aTlvs.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
* @retval OT_ERROR_NONE Successfully append MLE Dataset TLV without MeshCoP Sub Timestamp TLV.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient available buffers to append the message with MLE Dataset TLV.
|
||||
*
|
||||
*/
|
||||
otError SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength);
|
||||
|
||||
/**
|
||||
* This method sends a MGMT_GET request.
|
||||
*
|
||||
* @param[in] aDatasetComponents An Operational Dataset components structure specifying components to request.
|
||||
* @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested.
|
||||
* @param[in] aLength Number of bytes in @p aTlvTypes.
|
||||
* @param[in] aAddress The IPv6 destination address for the MGMT_GET request.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
otError SendGetRequest(const otOperationalDatasetComponents &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const;
|
||||
otError AppendMleDatasetTlv(Message &aMessage) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This method sets the Operational Dataset in non-volatile memory.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
*
|
||||
*/
|
||||
otError Set(const otOperationalDataset &aDataset);
|
||||
|
||||
/**
|
||||
* This method handles the MGMT_SET request message.
|
||||
*
|
||||
@@ -274,11 +279,6 @@ protected:
|
||||
otError Set(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
kMaxDatasetTlvs = 16, // Maximum number of TLVs in an `otOperationalDataset`.
|
||||
};
|
||||
|
||||
void SendSetResponse(const Coap::Header & aRequestHeader,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
StateTlv::State aState);
|
||||
@@ -326,7 +326,6 @@ public:
|
||||
*/
|
||||
otError Set(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
/**
|
||||
* This method sets the Operational Dataset in non-volatile memory.
|
||||
*
|
||||
@@ -335,6 +334,8 @@ public:
|
||||
*/
|
||||
otError Set(const otOperationalDataset &aDataset);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
/**
|
||||
* This method starts the Leader functions for maintaining the Active Operational Dataset.
|
||||
*
|
||||
@@ -411,6 +412,16 @@ public:
|
||||
*/
|
||||
void ClearNetwork(void);
|
||||
|
||||
/**
|
||||
* This method sets the Operational Dataset in non-volatile memory.
|
||||
*
|
||||
* This method also starts the Delay Timer.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
*
|
||||
*/
|
||||
otError Set(const otOperationalDataset &aDataset);
|
||||
|
||||
/**
|
||||
* This method sets the Operational Dataset for the partition.
|
||||
*
|
||||
@@ -427,15 +438,6 @@ public:
|
||||
otError Set(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
/**
|
||||
* This method sets the Operational Dataset in non-volatile memory.
|
||||
*
|
||||
* This method also starts the Delay Timer.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
*
|
||||
*/
|
||||
otError Set(const otOperationalDataset &aDataset);
|
||||
|
||||
/**
|
||||
* This method starts the Leader functions for maintaining the Active Operational Dataset.
|
||||
|
||||
@@ -58,36 +58,13 @@
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
otError DatasetManager::Set(const otOperationalDataset &aDataset)
|
||||
otError DatasetManager::AppendMleDatasetTlv(Message &aMessage) const
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
otError error = OT_ERROR_NONE;
|
||||
Dataset dataset(mLocal.GetType());
|
||||
|
||||
SuccessOrExit(error = mLocal.Set(aDataset));
|
||||
mLocal.Get(dataset);
|
||||
|
||||
switch (netif.GetMle().GetRole())
|
||||
{
|
||||
case OT_DEVICE_ROLE_DISABLED:
|
||||
Restore();
|
||||
break;
|
||||
|
||||
case OT_DEVICE_ROLE_CHILD:
|
||||
case OT_DEVICE_ROLE_ROUTER:
|
||||
mTimer.Start(1000);
|
||||
break;
|
||||
|
||||
case OT_DEVICE_ROLE_LEADER:
|
||||
Restore();
|
||||
netif.GetNetworkDataLeader().IncrementVersion();
|
||||
netif.GetNetworkDataLeader().IncrementStableVersion();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return dataset.AppendMleDatasetTlv(aMessage);
|
||||
}
|
||||
|
||||
otError DatasetManager::Set(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
@@ -313,294 +290,6 @@ exit:
|
||||
return state == StateTlv::kAccept ? OT_ERROR_NONE : OT_ERROR_DROP;
|
||||
}
|
||||
|
||||
otError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength)
|
||||
{
|
||||
ThreadNetif & netif = GetNetif();
|
||||
otError error = OT_ERROR_NONE;
|
||||
Coap::Header header;
|
||||
Message * message;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(mUriSet);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
VerifyOrExit((message = NewMeshCoPMessage(netif.GetCoap(), header)) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
#if OPENTHREAD_ENABLE_COMMISSIONER
|
||||
|
||||
if (netif.GetCommissioner().IsActive())
|
||||
{
|
||||
const uint8_t *cur = aTlvs;
|
||||
const uint8_t *end = aTlvs + aLength;
|
||||
bool hasSessionId = false;
|
||||
|
||||
while (cur < end)
|
||||
{
|
||||
const Tlv *data = reinterpret_cast<const Tlv *>(cur);
|
||||
|
||||
if (data->GetType() == Tlv::kCommissionerSessionId)
|
||||
{
|
||||
hasSessionId = true;
|
||||
break;
|
||||
}
|
||||
|
||||
cur += sizeof(Tlv) + data->GetLength();
|
||||
}
|
||||
|
||||
if (!hasSessionId)
|
||||
{
|
||||
CommissionerSessionIdTlv sessionId;
|
||||
sessionId.Init();
|
||||
sessionId.SetCommissionerSessionId(netif.GetCommissioner().GetSessionId());
|
||||
SuccessOrExit(error = message->Append(&sessionId, sizeof(sessionId)));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_COMMISSIONER
|
||||
|
||||
if (aDataset.mComponents.mIsActiveTimestampPresent)
|
||||
{
|
||||
ActiveTimestampTlv timestamp;
|
||||
timestamp.Init();
|
||||
static_cast<Timestamp *>(×tamp)->SetSeconds(aDataset.mActiveTimestamp);
|
||||
static_cast<Timestamp *>(×tamp)->SetTicks(0);
|
||||
SuccessOrExit(error = message->Append(×tamp, sizeof(timestamp)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsPendingTimestampPresent)
|
||||
{
|
||||
PendingTimestampTlv timestamp;
|
||||
timestamp.Init();
|
||||
static_cast<Timestamp *>(×tamp)->SetSeconds(aDataset.mPendingTimestamp);
|
||||
static_cast<Timestamp *>(×tamp)->SetTicks(0);
|
||||
SuccessOrExit(error = message->Append(×tamp, sizeof(timestamp)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsMasterKeyPresent)
|
||||
{
|
||||
NetworkMasterKeyTlv masterkey;
|
||||
masterkey.Init();
|
||||
masterkey.SetNetworkMasterKey(aDataset.mMasterKey);
|
||||
SuccessOrExit(error = message->Append(&masterkey, sizeof(masterkey)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsNetworkNamePresent)
|
||||
{
|
||||
NetworkNameTlv networkname;
|
||||
networkname.Init();
|
||||
networkname.SetNetworkName(aDataset.mNetworkName.m8);
|
||||
SuccessOrExit(error = message->Append(&networkname, sizeof(Tlv) + networkname.GetLength()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsExtendedPanIdPresent)
|
||||
{
|
||||
ExtendedPanIdTlv extpanid;
|
||||
extpanid.Init();
|
||||
extpanid.SetExtendedPanId(aDataset.mExtendedPanId);
|
||||
SuccessOrExit(error = message->Append(&extpanid, sizeof(extpanid)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsMeshLocalPrefixPresent)
|
||||
{
|
||||
MeshLocalPrefixTlv localprefix;
|
||||
localprefix.Init();
|
||||
localprefix.SetMeshLocalPrefix(aDataset.mMeshLocalPrefix);
|
||||
SuccessOrExit(error = message->Append(&localprefix, sizeof(localprefix)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsDelayPresent)
|
||||
{
|
||||
DelayTimerTlv delaytimer;
|
||||
delaytimer.Init();
|
||||
delaytimer.SetDelayTimer(aDataset.mDelay);
|
||||
SuccessOrExit(error = message->Append(&delaytimer, sizeof(delaytimer)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsPanIdPresent)
|
||||
{
|
||||
PanIdTlv panid;
|
||||
panid.Init();
|
||||
panid.SetPanId(aDataset.mPanId);
|
||||
SuccessOrExit(error = message->Append(&panid, sizeof(panid)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsChannelPresent)
|
||||
{
|
||||
ChannelTlv channel;
|
||||
channel.Init();
|
||||
channel.SetChannelPage(OT_RADIO_CHANNEL_PAGE);
|
||||
channel.SetChannel(aDataset.mChannel);
|
||||
SuccessOrExit(error = message->Append(&channel, sizeof(channel)));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsChannelMaskPage0Present)
|
||||
{
|
||||
ChannelMaskTlv channelMask;
|
||||
channelMask.Init();
|
||||
channelMask.SetChannelPage(OT_RADIO_CHANNEL_PAGE);
|
||||
channelMask.SetMask(aDataset.mChannelMaskPage0);
|
||||
SuccessOrExit(error = message->Append(&channelMask, sizeof(channelMask)));
|
||||
}
|
||||
|
||||
if (aLength > 0)
|
||||
{
|
||||
SuccessOrExit(error = message->Append(aTlvs, aLength));
|
||||
}
|
||||
|
||||
if (message->GetLength() == header.GetLength())
|
||||
{
|
||||
// no payload, remove coap payload marker
|
||||
message->SetLength(message->GetLength() - 1);
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(netif.GetMle().GetMeshLocal16());
|
||||
netif.GetMle().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = netif.GetCoap().SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset set request to leader");
|
||||
|
||||
exit:
|
||||
|
||||
if (error != OT_ERROR_NONE && message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetManager::SendGetRequest(const otOperationalDatasetComponents &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const
|
||||
{
|
||||
ThreadNetif & netif = GetNetif();
|
||||
otError error = OT_ERROR_NONE;
|
||||
Coap::Header header;
|
||||
Message * message;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Tlv tlv;
|
||||
uint8_t datasetTlvs[kMaxDatasetTlvs];
|
||||
uint8_t length;
|
||||
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(mUriGet);
|
||||
|
||||
length = 0;
|
||||
|
||||
if (aDatasetComponents.mIsActiveTimestampPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kActiveTimestamp;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPendingTimestampPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPendingTimestamp;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsMasterKeyPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kNetworkMasterKey;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsNetworkNamePresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kNetworkName;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsExtendedPanIdPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kExtendedPanId;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsMeshLocalPrefixPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kMeshLocalPrefix;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsDelayPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kDelayTimer;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPanIdPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPanId;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsChannelPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kChannel;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPSKcPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPSKc;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsSecurityPolicyPresent)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kSecurityPolicy;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsChannelMaskPage0Present)
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kChannelMask;
|
||||
}
|
||||
|
||||
if (aLength + length > 0)
|
||||
{
|
||||
header.SetPayloadMarker();
|
||||
}
|
||||
|
||||
VerifyOrExit((message = NewMeshCoPMessage(netif.GetCoap(), header)) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
if (aLength + length > 0)
|
||||
{
|
||||
tlv.SetType(Tlv::kGet);
|
||||
tlv.SetLength(aLength + length);
|
||||
SuccessOrExit(error = message->Append(&tlv, sizeof(tlv)));
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
SuccessOrExit(error = message->Append(datasetTlvs, length));
|
||||
}
|
||||
|
||||
if (aLength > 0)
|
||||
{
|
||||
SuccessOrExit(error = message->Append(aTlvTypes, aLength));
|
||||
}
|
||||
}
|
||||
|
||||
if (aAddress != NULL)
|
||||
{
|
||||
messageInfo.SetPeerAddr(*static_cast<const Ip6::Address *>(aAddress));
|
||||
}
|
||||
else
|
||||
{
|
||||
netif.GetMle().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(netif.GetMle().GetMeshLocal16());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = netif.GetCoap().SendMessage(*message, messageInfo));
|
||||
|
||||
otLogInfoMeshCoP("sent dataset get request");
|
||||
|
||||
exit:
|
||||
|
||||
if (error != OT_ERROR_NONE && message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void DatasetManager::SendSetResponse(const Coap::Header & aRequestHeader,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
StateTlv::State aState)
|
||||
@@ -632,11 +321,6 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
otError ActiveDataset::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
return DatasetManager::Set(aDataset);
|
||||
}
|
||||
|
||||
otError ActiveDataset::GenerateLocal(void)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
@@ -780,17 +464,6 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
otError PendingDataset::Set(const otOperationalDataset &aDataset)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
SuccessOrExit(error = DatasetManager::Set(aDataset));
|
||||
StartDelayTimer();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void PendingDataset::StartLeader(void)
|
||||
{
|
||||
StartDelayTimer();
|
||||
|
||||
@@ -310,13 +310,14 @@ protected:
|
||||
|
||||
otError EncodeOperationalDataset(const otOperationalDataset &aDataset);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
otError EncodeChildInfo(const otChildInfo &aChildInfo);
|
||||
otError DecodeOperationalDataset(otOperationalDataset &aDataset,
|
||||
const uint8_t ** aTlvs = NULL,
|
||||
uint8_t * aTlvsLength = NULL,
|
||||
const otIp6Address ** aDestIpAddress = NULL,
|
||||
bool aAllowEmptyValues = false);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
otError EncodeChildInfo(const otChildInfo &aChildInfo);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_UDP_FORWARD
|
||||
|
||||
@@ -792,6 +792,26 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE>;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case SPINEL_PROP_THREAD_ACTIVE_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_ACTIVE_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_PENDING_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_PENDING_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_SET_ACTIVE_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_ACTIVE_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_GET_ACTIVE_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_ACTIVE_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET>;
|
||||
break;
|
||||
|
||||
#if OPENTHREAD_ENABLE_JAM_DETECTION
|
||||
case SPINEL_PROP_JAM_DETECT_ENABLE:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_JAM_DETECT_ENABLE>;
|
||||
@@ -865,24 +885,6 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_UDP_FORWARD_STREAM>;
|
||||
break;
|
||||
#endif
|
||||
case SPINEL_PROP_THREAD_ACTIVE_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_ACTIVE_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_PENDING_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_PENDING_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_SET_ACTIVE_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_ACTIVE_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_GET_ACTIVE_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_ACTIVE_DATASET>;
|
||||
break;
|
||||
case SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET>;
|
||||
break;
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
case SPINEL_PROP_CHILD_SUPERVISION_INTERVAL:
|
||||
handler = &NcpBase::HandlePropertySet<SPINEL_PROP_CHILD_SUPERVISION_INTERVAL>;
|
||||
|
||||
+1
-327
@@ -39,7 +39,7 @@
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
#include <openthread/child_supervision.h>
|
||||
#endif
|
||||
#include <openthread/dataset_ftd.h>
|
||||
#include <openthread/dataset.h>
|
||||
#include <openthread/diag.h>
|
||||
#include <openthread/icmp6.h>
|
||||
#include <openthread/ncp.h>
|
||||
@@ -853,332 +853,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
|
||||
const uint8_t ** aTlvs,
|
||||
uint8_t * aTlvsLength,
|
||||
const otIp6Address ** aDestIpAddress,
|
||||
bool aAllowEmptyValue)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
memset(&aDataset, 0, sizeof(otOperationalDataset));
|
||||
|
||||
if (aTlvs != NULL)
|
||||
{
|
||||
*aTlvs = NULL;
|
||||
}
|
||||
|
||||
if (aTlvsLength != NULL)
|
||||
{
|
||||
*aTlvsLength = 0;
|
||||
}
|
||||
|
||||
if (aDestIpAddress != NULL)
|
||||
{
|
||||
*aDestIpAddress = NULL;
|
||||
}
|
||||
|
||||
while (!mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
unsigned int propKey;
|
||||
|
||||
SuccessOrExit(error = mDecoder.OpenStruct());
|
||||
SuccessOrExit(error = mDecoder.ReadUintPacked(propKey));
|
||||
|
||||
switch (static_cast<spinel_prop_key_t>(propKey))
|
||||
{
|
||||
case SPINEL_PROP_DATASET_ACTIVE_TIMESTAMP:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint64(aDataset.mActiveTimestamp));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsActiveTimestampPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_PENDING_TIMESTAMP:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint64(aDataset.mPendingTimestamp));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsPendingTimestampPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_MASTER_KEY:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *key;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(key, len));
|
||||
VerifyOrExit(len == OT_MASTER_KEY_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mMasterKey.m8, key, len);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsMasterKeyPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_NETWORK_NAME:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const char *name;
|
||||
size_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUtf8(name));
|
||||
len = strlen(name);
|
||||
VerifyOrExit(len <= OT_NETWORK_NAME_MAX_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mNetworkName.m8, name, len + 1);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsNetworkNamePresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_XPANID:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *xpanid;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(xpanid, len));
|
||||
VerifyOrExit(len == OT_EXT_PAN_ID_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mExtendedPanId.m8, xpanid, len);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsExtendedPanIdPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_IPV6_ML_PREFIX:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const otIp6Address *addr;
|
||||
uint8_t prefixLen;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadIp6Address(addr));
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(prefixLen));
|
||||
VerifyOrExit(prefixLen == 64, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mMeshLocalPrefix.m8, addr, OT_MESH_LOCAL_PREFIX_SIZE);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsMeshLocalPrefixPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_DELAY_TIMER:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(aDataset.mDelay));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsDelayPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_MAC_15_4_PANID:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(aDataset.mPanId));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsPanIdPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_PHY_CHAN:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
uint8_t channel;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(channel));
|
||||
aDataset.mChannel = channel;
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsChannelPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_PSKC:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *psk;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(psk, len));
|
||||
VerifyOrExit(len == OT_PSKC_MAX_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mPSKc.m8, psk, OT_PSKC_MAX_SIZE);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsPSKcPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_SECURITY_POLICY:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(aDataset.mSecurityPolicy.mRotationTime));
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(aDataset.mSecurityPolicy.mFlags));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsSecurityPolicyPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_PHY_CHAN_SUPPORTED:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
uint8_t channel;
|
||||
|
||||
aDataset.mChannelMaskPage0 = 0;
|
||||
|
||||
while (!mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(channel));
|
||||
VerifyOrExit(channel <= 31, error = OT_ERROR_INVALID_ARGS);
|
||||
aDataset.mChannelMaskPage0 |= (1U << channel);
|
||||
}
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsChannelMaskPage0Present = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_RAW_TLVS:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *tlvs;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(tlvs, len));
|
||||
VerifyOrExit(len <= 255, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
if (aTlvs != NULL)
|
||||
{
|
||||
*aTlvs = tlvs;
|
||||
}
|
||||
|
||||
if (aTlvsLength != NULL)
|
||||
{
|
||||
*aTlvsLength = static_cast<uint8_t>(len);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_DEST_ADDRESS:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const otIp6Address *addr;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadIp6Address(addr));
|
||||
|
||||
if (aDestIpAddress != NULL)
|
||||
{
|
||||
*aDestIpAddress = addr;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SuccessOrExit(error = mDecoder.CloseStruct());
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_ACTIVE_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset));
|
||||
error = otDatasetSetActive(mInstance, &dataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_PENDING_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset));
|
||||
error = otDatasetSetPending(mInstance, &dataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_ACTIVE_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength));
|
||||
error = otDatasetSendMgmtActiveSet(mInstance, &dataset, extraTlvs, extraTlvsLength);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength));
|
||||
error = otDatasetSendMgmtPendingSet(mInstance, &dataset, extraTlvs, extraTlvsLength);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_ACTIVE_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
const otIp6Address * destIpAddress;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength, &destIpAddress, true));
|
||||
error = otDatasetSendMgmtActiveGet(mInstance, &dataset.mComponents, extraTlvs, extraTlvsLength, destIpAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
const otIp6Address * destIpAddress;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength, &destIpAddress, true));
|
||||
error = otDatasetSendMgmtPendingGet(mInstance, &dataset.mComponents, extraTlvs, extraTlvsLength, destIpAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_CHILD_SUPERVISION
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CHILD_SUPERVISION_INTERVAL>(void)
|
||||
|
||||
@@ -984,6 +984,331 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_PENDING_DATASE
|
||||
return EncodeOperationalDataset(dataset);
|
||||
}
|
||||
|
||||
otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
|
||||
const uint8_t ** aTlvs,
|
||||
uint8_t * aTlvsLength,
|
||||
const otIp6Address ** aDestIpAddress,
|
||||
bool aAllowEmptyValue)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
memset(&aDataset, 0, sizeof(otOperationalDataset));
|
||||
|
||||
if (aTlvs != NULL)
|
||||
{
|
||||
*aTlvs = NULL;
|
||||
}
|
||||
|
||||
if (aTlvsLength != NULL)
|
||||
{
|
||||
*aTlvsLength = 0;
|
||||
}
|
||||
|
||||
if (aDestIpAddress != NULL)
|
||||
{
|
||||
*aDestIpAddress = NULL;
|
||||
}
|
||||
|
||||
while (!mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
unsigned int propKey;
|
||||
|
||||
SuccessOrExit(error = mDecoder.OpenStruct());
|
||||
SuccessOrExit(error = mDecoder.ReadUintPacked(propKey));
|
||||
|
||||
switch (static_cast<spinel_prop_key_t>(propKey))
|
||||
{
|
||||
case SPINEL_PROP_DATASET_ACTIVE_TIMESTAMP:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint64(aDataset.mActiveTimestamp));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsActiveTimestampPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_PENDING_TIMESTAMP:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint64(aDataset.mPendingTimestamp));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsPendingTimestampPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_MASTER_KEY:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *key;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(key, len));
|
||||
VerifyOrExit(len == OT_MASTER_KEY_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mMasterKey.m8, key, len);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsMasterKeyPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_NETWORK_NAME:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const char *name;
|
||||
size_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUtf8(name));
|
||||
len = strlen(name);
|
||||
VerifyOrExit(len <= OT_NETWORK_NAME_MAX_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mNetworkName.m8, name, len + 1);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsNetworkNamePresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_XPANID:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *xpanid;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(xpanid, len));
|
||||
VerifyOrExit(len == OT_EXT_PAN_ID_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mExtendedPanId.m8, xpanid, len);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsExtendedPanIdPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_IPV6_ML_PREFIX:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const otIp6Address *addr;
|
||||
uint8_t prefixLen;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadIp6Address(addr));
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(prefixLen));
|
||||
VerifyOrExit(prefixLen == 64, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mMeshLocalPrefix.m8, addr, OT_MESH_LOCAL_PREFIX_SIZE);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsMeshLocalPrefixPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_DELAY_TIMER:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(aDataset.mDelay));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsDelayPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_MAC_15_4_PANID:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(aDataset.mPanId));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsPanIdPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_PHY_CHAN:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
uint8_t channel;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(channel));
|
||||
aDataset.mChannel = channel;
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsChannelPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NET_PSKC:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *psk;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(psk, len));
|
||||
VerifyOrExit(len == OT_PSKC_MAX_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
memcpy(aDataset.mPSKc.m8, psk, OT_PSKC_MAX_SIZE);
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsPSKcPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_SECURITY_POLICY:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint16(aDataset.mSecurityPolicy.mRotationTime));
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(aDataset.mSecurityPolicy.mFlags));
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsSecurityPolicyPresent = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_PHY_CHAN_SUPPORTED:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
uint8_t channel;
|
||||
|
||||
aDataset.mChannelMaskPage0 = 0;
|
||||
|
||||
while (!mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
SuccessOrExit(error = mDecoder.ReadUint8(channel));
|
||||
VerifyOrExit(channel <= 31, error = OT_ERROR_INVALID_ARGS);
|
||||
aDataset.mChannelMaskPage0 |= (1U << channel);
|
||||
}
|
||||
}
|
||||
|
||||
aDataset.mComponents.mIsChannelMaskPage0Present = true;
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_RAW_TLVS:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const uint8_t *tlvs;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(tlvs, len));
|
||||
VerifyOrExit(len <= 255, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
if (aTlvs != NULL)
|
||||
{
|
||||
*aTlvs = tlvs;
|
||||
}
|
||||
|
||||
if (aTlvsLength != NULL)
|
||||
{
|
||||
*aTlvsLength = static_cast<uint8_t>(len);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_DATASET_DEST_ADDRESS:
|
||||
|
||||
if (!aAllowEmptyValue || !mDecoder.IsAllReadInStruct())
|
||||
{
|
||||
const otIp6Address *addr;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadIp6Address(addr));
|
||||
|
||||
if (aDestIpAddress != NULL)
|
||||
{
|
||||
*aDestIpAddress = addr;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SuccessOrExit(error = mDecoder.CloseStruct());
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_ACTIVE_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset));
|
||||
error = otDatasetSetActive(mInstance, &dataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_PENDING_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset));
|
||||
error = otDatasetSetPending(mInstance, &dataset);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_ACTIVE_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength));
|
||||
error = otDatasetSendMgmtActiveSet(mInstance, &dataset, extraTlvs, extraTlvsLength);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength));
|
||||
error = otDatasetSendMgmtPendingSet(mInstance, &dataset, extraTlvs, extraTlvsLength);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_ACTIVE_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
const otIp6Address * destIpAddress;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength, &destIpAddress, true));
|
||||
error = otDatasetSendMgmtActiveGet(mInstance, &dataset.mComponents, extraTlvs, extraTlvsLength, destIpAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_GET_PENDING_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDataset dataset;
|
||||
const uint8_t * extraTlvs;
|
||||
uint8_t extraTlvsLength;
|
||||
const otIp6Address * destIpAddress;
|
||||
|
||||
SuccessOrExit(error = DecodeOperationalDataset(dataset, &extraTlvs, &extraTlvsLength, &destIpAddress, true));
|
||||
error = otDatasetSendMgmtPendingGet(mInstance, &dataset.mComponents, extraTlvs, extraTlvsLength, destIpAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
#if OPENTHREAD_ENABLE_JOINER
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_MESHCOP_JOINER_STATE>(void)
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ class OpenThread(IThci):
|
||||
|
||||
# Used for reference firmware version control for Test Harness.
|
||||
# This variable will be updated to match the OpenThread reference firmware officially released.
|
||||
firmwarePrefix = "OPENTHREAD/201806"
|
||||
firmwarePrefix = "OPENTHREAD/"
|
||||
|
||||
#def __init__(self, SerialPort=COMPortName, EUI=MAC_Address):
|
||||
def __init__(self, **kwargs):
|
||||
@@ -402,7 +402,6 @@ class OpenThread(IThci):
|
||||
self.addBlockedMAC(addr)
|
||||
|
||||
if self.__sendCommand('ifconfig up')[0] == 'Done':
|
||||
self.__setRouterSelectionJitter(1)
|
||||
if self.__sendCommand('thread start')[0] == 'Done':
|
||||
self.isPowerDown = False
|
||||
return True
|
||||
@@ -1008,12 +1007,14 @@ class OpenThread(IThci):
|
||||
if eRoleId == Thread_Device_Role.Leader:
|
||||
print 'join as leader'
|
||||
mode = 'rsdn'
|
||||
self.__setRouterSelectionJitter(1)
|
||||
if self.AutoDUTEnable is False:
|
||||
# set ROUTER_DOWNGRADE_THRESHOLD
|
||||
self.__setRouterDowngradeThreshold(33)
|
||||
elif eRoleId == Thread_Device_Role.Router:
|
||||
print 'join as router'
|
||||
mode = 'rsdn'
|
||||
self.__setRouterSelectionJitter(1)
|
||||
if self.AutoDUTEnable is False:
|
||||
# set ROUTER_DOWNGRADE_THRESHOLD
|
||||
self.__setRouterDowngradeThreshold(33)
|
||||
@@ -1027,6 +1028,7 @@ class OpenThread(IThci):
|
||||
elif eRoleId == Thread_Device_Role.REED:
|
||||
print 'join as REED'
|
||||
mode = 'rsdn'
|
||||
self.__setRouterSelectionJitter(1)
|
||||
# set ROUTER_UPGRADE_THRESHOLD
|
||||
self.__setRouterUpgradeThreshold(0)
|
||||
elif eRoleId == Thread_Device_Role.EndDevice_FED:
|
||||
@@ -2020,10 +2022,11 @@ class OpenThread(IThci):
|
||||
False: fail to set provisioning Url
|
||||
"""
|
||||
print '%s call setProvisioningUrl' % self.port
|
||||
cmd = 'commissioner provisioningurl %s' %(strURL)
|
||||
self.provisioningUrl = strURL
|
||||
print cmd
|
||||
return self.__sendCommand(cmd)[0] == "Done"
|
||||
if self.deviceRole == Thread_Device_Role.Commissioner:
|
||||
cmd = 'commissioner provisioningurl %s' %(strURL)
|
||||
return self.__sendCommand(cmd)[0] == "Done"
|
||||
return True
|
||||
|
||||
def allowCommission(self):
|
||||
"""start commissioner candidate petition process
|
||||
|
||||
@@ -500,7 +500,6 @@ class OpenThread_WpanCtl(IThci):
|
||||
nodeType = 'end'
|
||||
else:
|
||||
pass
|
||||
self.__setRouterSelectionJitter(1)
|
||||
if startType == 'form':
|
||||
startCmd = WPANCTL_CMD + '%s %s -c %s -T %s ' % (startType, self.networkName, str(self.channel), nodeType)
|
||||
else:
|
||||
@@ -1184,6 +1183,7 @@ class OpenThread_WpanCtl(IThci):
|
||||
print 'join as leader'
|
||||
#rsdn
|
||||
mode = 15
|
||||
self.__setRouterSelectionJitter(1)
|
||||
if self.AutoDUTEnable is False:
|
||||
# set ROUTER_DOWNGRADE_THRESHOLD
|
||||
self.__setRouterDowngradeThreshold(33)
|
||||
@@ -1191,6 +1191,7 @@ class OpenThread_WpanCtl(IThci):
|
||||
print 'join as router'
|
||||
#rsdn
|
||||
mode = 15
|
||||
self.__setRouterSelectionJitter(1)
|
||||
if self.AutoDUTEnable is False:
|
||||
# set ROUTER_DOWNGRADE_THRESHOLD
|
||||
self.__setRouterDowngradeThreshold(33)
|
||||
@@ -1207,6 +1208,7 @@ class OpenThread_WpanCtl(IThci):
|
||||
print 'join as REED'
|
||||
#rsdn
|
||||
mode = 15
|
||||
self.__setRouterSelectionJitter(1)
|
||||
# set ROUTER_UPGRADE_THRESHOLD
|
||||
self.__setRouterUpgradeThreshold(0)
|
||||
elif eRoleId == Thread_Device_Role.EndDevice_FED:
|
||||
|
||||
Reference in New Issue
Block a user