Default OTM select CB 33/204733/1
authorOleksii Beketov <ol.beketov@samsung.com>
Thu, 4 Apr 2019 11:42:59 +0000 (14:42 +0300)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 26 Apr 2019 04:17:52 +0000 (13:17 +0900)
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 <ol.beketov@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
resource/csdk/security/provisioning/src/ownershiptransfermanager.c

index a483e7a..781567b 100644 (file)
@@ -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.
  *