Discard provisioning tool reply for owned device discovery
authorSandeep Sharma <sandeep.s9@samsung.com>
Fri, 27 May 2016 11:30:40 +0000 (17:00 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Tue, 21 Jun 2016 04:43:28 +0000 (04:43 +0000)
[Patch #1] fix C provisioning client as now PT's reply won't come
           for owned device discovery.

Change-Id: Ica5a66166c589282e99a3fd6c60bfd68b79013f6
Signed-off-by: Sandeep Sharma <sandeep.s9@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8367
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashwini Kumar <k.ashwini@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/pmutility.c

index ccfec69..eb20586 100644 (file)
@@ -1286,7 +1286,7 @@ static int waitCallbackRet(void)
 
 static int selectTwoDiffNum(int* a, int* b, const int max, const char* str)
 {
-    if(!a || !b || 2>=max || !str)
+    if(!a || !b || 2>max || !str)
     {
         return -1;
     }
index e36c166..f9d3ec6 100644 (file)
@@ -710,6 +710,22 @@ static OCStackApplicationResult DeviceDiscoveryHandler(void *ctx, OCDoHandle UNU
                     return OC_STACK_KEEP_TRANSACTION;
                 }
 
+                res = GetDoxmDeviceID(&myId);
+                if(OC_STACK_OK != res)
+                {
+                    OIC_LOG(ERROR, TAG, "Error while getting my UUID.");
+                    DeleteDoxmBinData(ptrDoxm);
+                    return OC_STACK_KEEP_TRANSACTION;
+                }
+                //if this is owned discovery and this is PT's reply, discard it
+                if((pDInfo->isOwnedDiscovery) &&
+                        (0 == memcmp(&ptrDoxm->deviceID.id, &myId.id, sizeof(myId.id))) )
+                {
+                    OIC_LOG(DEBUG, TAG, "discarding provision tool's reply");
+                    DeleteDoxmBinData(ptrDoxm);
+                    return OC_STACK_KEEP_TRANSACTION;
+                }
+
                 res = AddDevice(ppDevicesList, clientResponse->devAddr.addr,
                         clientResponse->devAddr.port,
                         clientResponse->devAddr.adapter,