[IOT-1226] Updating code for reset case without client knowledge
authorsaurabh.s9 <saurabh.s9@samsung.com>
Thu, 25 Aug 2016 12:20:51 +0000 (17:50 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Tue, 30 Aug 2016 07:55:32 +0000 (07:55 +0000)
Change-Id: I24af255c499dd6502d5a4186c4bad7a2ede7225a
Signed-off-by: saurabh.s9 <saurabh.s9@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10919
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Heewon Park <h_w.park@samsung.com>
Reviewed-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/src/ocprovisioningmanager.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 277e7f1..fdf9010
@@ -933,6 +933,36 @@ OCStackResult OCGetDevInfoFromNetwork(unsigned short waittime,
         return res;
     }
 
+    // Code to compare devices in unowned list and deviceid from DB
+    // (In case of hard reset of the device)
+    OCProvisionDev_t* pUnownedList = unownedDevice;
+    while (pUnownedList && uuidList)
+    {
+        OCUuidList_t *tmp1 = NULL,*tmp2=NULL;
+        LL_FOREACH_SAFE(uuidList, tmp1, tmp2)
+        {
+            if(0 == memcmp(tmp1->dev.id, pUnownedList->doxm->deviceID.id,
+                            sizeof(pUnownedList->doxm->deviceID.id)))
+            {
+                OIC_LOG_V(INFO, TAG, "OCGetDevInfoFromNetwork : \
+                            Removing device id = %s in PDM and dat.", pUnownedList->doxm->deviceID.id);
+                if (OC_STACK_OK != PDMDeleteDevice(&pUnownedList->doxm->deviceID))
+                {
+                    OIC_LOG(ERROR, TAG, "OCGetDevInfoFromNetwork : \
+                            Failed to remove device in PDM.");
+                }
+                //remove the cred entry from dat file
+                if (OC_STACK_OK != RemoveDeviceInfoFromLocal(pUnownedList))
+                {
+                    OIC_LOG(ERROR, TAG, "OCGetDevInfoFromNetwork : \
+                            Failed to remove cred entry device in dat file.");
+                }
+                LL_DELETE(uuidList, tmp1);
+                OICFree(tmp1);
+            }
+        }
+        pUnownedList = pUnownedList->next;
+    }
     // Code to compare devices in owned list and deviceid from DB.
     OCProvisionDev_t* pCurDev = ownedDevice;
     size_t deleteCnt = 0;