diff --git a/include/openthread/thread.h b/include/openthread/thread.h index 151cfda4b..b6c752246 100644 --- a/include/openthread/thread.h +++ b/include/openthread/thread.h @@ -239,34 +239,6 @@ OTAPI const otMasterKey *OTCALL otThreadGetMasterKey(otInstance *aInstance); */ OTAPI ThreadError OTCALL otThreadSetMasterKey(otInstance *aInstance, const otMasterKey *aKey); -/** - * Get the thrPSKc. - * - * @param[in] aInstance A pointer to an OpenThread instance. - * - * @returns A pointer to a buffer containing the thrPSKc. - * - * @sa otThreadSetPSKc - */ -OTAPI const uint8_t *OTCALL otThreadGetPSKc(otInstance *aInstance); - -/** - * Set the thrPSKc. - * - * This function will only succeed when Thread protocols are disabled. A successful - * call to this function will also invalidate the Active and Pending Operational Datasets in - * non-volatile memory. - * - * @param[in] aInstance A pointer to an OpenThread instance. - * @param[in] aPSKc A pointer to a buffer containing the thrPSKc. - * - * @retval kThreadError_None Successfully set the thrPSKc. - * @retval kThreadError_InvalidState Thread protocols are enabled. - * - * @sa otThreadGetPSKc - */ -OTAPI ThreadError OTCALL otThreadSetPSKc(otInstance *aInstance, const uint8_t *aPSKc); - /** * This function returns a pointer to the Mesh Local EID. * diff --git a/include/openthread/thread_ftd.h b/include/openthread/thread_ftd.h index 636fb5bcd..acf429c58 100644 --- a/include/openthread/thread_ftd.h +++ b/include/openthread/thread_ftd.h @@ -396,6 +396,34 @@ OTAPI ThreadError OTCALL otThreadGetRouterInfo(otInstance *aInstance, uint16_t a */ OTAPI ThreadError OTCALL otThreadGetEidCacheEntry(otInstance *aInstance, uint8_t aIndex, otEidCacheEntry *aEntry); +/** + * Get the thrPSKc. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns A pointer to a buffer containing the thrPSKc. + * + * @sa otThreadSetPSKc + */ +OTAPI const uint8_t *OTCALL otThreadGetPSKc(otInstance *aInstance); + +/** + * Set the thrPSKc. + * + * This function will only succeed when Thread protocols are disabled. A successful + * call to this function will also invalidate the Active and Pending Operational Datasets in + * non-volatile memory. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aPSKc A pointer to a buffer containing the thrPSKc. + * + * @retval kThreadError_None Successfully set the thrPSKc. + * @retval kThreadError_InvalidState Thread protocols are enabled. + * + * @sa otThreadGetPSKc + */ +OTAPI ThreadError OTCALL otThreadSetPSKc(otInstance *aInstance, const uint8_t *aPSKc); + /** * @} * diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index a176438eb..41459269a 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -149,27 +149,6 @@ ThreadError otThreadSetLinkMode(otInstance *aInstance, otLinkModeConfig aConfig) return aInstance->mThreadNetif.GetMle().SetDeviceMode(mode); } -#if OPENTHREAD_FTD -const uint8_t *otThreadGetPSKc(otInstance *aInstance) -{ - return aInstance->mThreadNetif.GetKeyManager().GetPSKc(); -} - -ThreadError otThreadSetPSKc(otInstance *aInstance, const uint8_t *aPSKc) -{ - ThreadError error = kThreadError_None; - VerifyOrExit(aInstance->mThreadNetif.GetMle().GetDeviceState() == Mle::kDeviceStateDisabled, - error = kThreadError_InvalidState); - - aInstance->mThreadNetif.GetKeyManager().SetPSKc(aPSKc); - aInstance->mThreadNetif.GetActiveDataset().Clear(false); - aInstance->mThreadNetif.GetPendingDataset().Clear(false); - -exit: - return error; -} -#endif - const otMasterKey *otThreadGetMasterKey(otInstance *aInstance) { return &aInstance->mThreadNetif.GetKeyManager().GetMasterKey(); diff --git a/src/core/api/thread_ftd_api.cpp b/src/core/api/thread_ftd_api.cpp index f17f90976..cf87cbd8f 100644 --- a/src/core/api/thread_ftd_api.cpp +++ b/src/core/api/thread_ftd_api.cpp @@ -77,7 +77,6 @@ ThreadError otThreadSetPreferredRouterId(otInstance *aInstance, uint8_t aRouterI return aInstance->mThreadNetif.GetMle().SetPreferredRouterId(aRouterId); } - uint8_t otThreadGetLocalLeaderWeight(otInstance *aInstance) { return aInstance->mThreadNetif.GetMle().GetLeaderWeight(); @@ -232,7 +231,6 @@ exit: return error; } - ThreadError otThreadGetEidCacheEntry(otInstance *aInstance, uint8_t aIndex, otEidCacheEntry *aEntry) { ThreadError error; @@ -244,7 +242,6 @@ exit: return error; } - ThreadError otThreadSetSteeringData(otInstance *aInstance, otExtAddress *aExtAddress) { ThreadError error; @@ -261,4 +258,23 @@ ThreadError otThreadSetSteeringData(otInstance *aInstance, otExtAddress *aExtAdd return error; } +const uint8_t *otThreadGetPSKc(otInstance *aInstance) +{ + return aInstance->mThreadNetif.GetKeyManager().GetPSKc(); +} + +ThreadError otThreadSetPSKc(otInstance *aInstance, const uint8_t *aPSKc) +{ + ThreadError error = kThreadError_None; + VerifyOrExit(aInstance->mThreadNetif.GetMle().GetDeviceState() == Mle::kDeviceStateDisabled, + error = kThreadError_InvalidState); + + aInstance->mThreadNetif.GetKeyManager().SetPSKc(aPSKc); + aInstance->mThreadNetif.GetActiveDataset().Clear(false); + aInstance->mThreadNetif.GetPendingDataset().Clear(false); + +exit: + return error; +} + #endif // OPENTHREAD_FTD