[IOT-2762] CreateEndpoint err in secured mode 19/24219/2
authoruzchoi <uzchoi@samsung.com>
Mon, 5 Feb 2018 08:31:58 +0000 (17:31 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 26 Feb 2018 07:17:35 +0000 (07:17 +0000)
In case of server process and client process exist in a same machine,
ifindex of CAEndpoint_t is different from the ifindex of Request DevAddr
because the ifindex of request DevAddr indicate local loopback in
secured mode while CAEndpoint_t shows physical interface.
This error can be fixed by checking whether the sender is from loopback.
However, some machine shows wrong print in if_indextoname() such as
eth0 instead of lo.
For this reason, I removed the comparison of ifindex. For more exact
check, we can put IP address is from my machine but looks inefficient.

Change-Id: Ic67fd2b4609df5779cb2775f632dca79b2bc7232
Signed-off-by: uzchoi <uzchoi@samsung.com>
resource/csdk/stack/src/ocpayload.c

index dda821e..87cc7df 100644 (file)
@@ -1825,10 +1825,11 @@ OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource, const O
         for (size_t i = 0; i < infoSize; i++)
         {
             CAEndpoint_t *info = networkInfo + i;
+            OIC_LOG_V(DEBUG, TAG, "CATransportAdapter_t value = %d", info->adapter);
+            OIC_LOG_V(DEBUG, TAG, "info[%d], info->ifindex = %d, devAddr->ifindex = %d"
+                                  , (int)i, info->ifindex, devAddr->ifindex);
 
-            if (((CA_ADAPTER_IP | CA_ADAPTER_TCP) & info->adapter &&
-                 info->ifindex == devAddr->ifindex) ||
-                info->adapter == CA_ADAPTER_RFCOMM_BTEDR)
+            if ((CA_ADAPTER_IP | CA_ADAPTER_TCP) & info->adapter)
             {
                 OCTpsSchemeFlags matchedTps = OC_NO_TPS;
                 if (OC_STACK_OK != OCGetMatchedTpsFlags(info->adapter,
@@ -1855,7 +1856,7 @@ OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource, const O
                     OCStackResult ret = OCConvertTpsToString(matchedTps, &(tmpNode->tps));
                     if (ret != OC_STACK_OK)
                     {
-                        OIC_LOG_V(DEBUG, TAG, "OCConvertTpsToString(%s) is false", tmpNode->tps);
+                        OIC_LOG_V(ERROR, TAG, "OCConvertTpsToString(%s) is false", tmpNode->tps);
                         OCDiscoveryEndpointDestroy(tmpNode);
                         goto exit;
                     }
@@ -1900,10 +1901,6 @@ OCEndpointPayload* CreateEndpointPayloadList(const OCResource *resource, const O
                     }
                 }
             }
-            else
-            {
-                OIC_LOG_V(DEBUG, TAG, "CATransportAdapter_t value = %d", info->adapter);
-            }
         }
     }