From dee64b10be2b0c9345e8974df26a39d6d5904e75 Mon Sep 17 00:00:00 2001 From: Oleksii Beketov Date: Thu, 4 Apr 2019 14:42:59 +0300 Subject: [PATCH] Default OTM select CB Default OTM select callback introduced https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/469 (cherry picked from 051a32dd63c54a309ff698d9143e9cb8a9733a3c Change-Id: I5f437da5c654d763c7c467e7ce11a39efbc67e19 Signed-off-by: Oleksii Beketov Signed-off-by: DoHyun Pyun --- .../provisioning/src/ownershiptransfermanager.c | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c index a483e7a..781567b 100644 --- a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c +++ b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c @@ -104,7 +104,8 @@ static uint8_t g_OxmAllowStatus[OXM_IDX_COUNT] = {ALLOWED_OXM, ALLOWED_OXM, ALLO NOT_ALLOWED_OXM}; #endif -static OTMSelectMethodCallback g_selectOTMCB = NULL; +static OicSecOxm_t selectOTMcb_default(const OicSecOxm_t* otmList, const uint32_t len); +static OTMSelectMethodCallback g_selectOTMCB = selectOTMcb_default; OCStackResult OTMSetOTCallback(OicSecOxm_t oxm, OTMCallbackData_t* callbacks) { @@ -224,6 +225,29 @@ static OxmAllowTableIdx_t GetOxmAllowTableIdx(OicSecOxm_t oxm) } } +OicSecOxm_t selectOTMcb_default(const OicSecOxm_t* otmList, const uint32_t len) +{ + OIC_LOG(INFO, TAG, "IN selectOTMcb_default"); + OicSecOxm_t ret = -1; + VERIFY_NON_NULL(TAG, otmList, ERROR); + VERIFY_SUCCESS(TAG, (len > 0), ERROR); + + ret = otmList[len-1]; + + for (size_t i = 0; i < len; i++) + { + if (OIC_RANDOM_DEVICE_PIN == otmList[i]) + { + ret = OIC_RANDOM_DEVICE_PIN; + break; + } + } + +exit: + OIC_LOG(INFO, TAG, "OUT selectOTMcb_default"); + return ret; +} + /** * Function to select appropriate provisioning method. * -- 2.7.4