[CONPRO-1583]Enable Duplicate Ipv4/Ipv6 packets through build flag. 27/236727/1
authorSudipto <sudipto.bal@samsung.com>
Fri, 19 Jun 2020 16:58:06 +0000 (22:28 +0530)
committerSudipto <sudipto.bal@samsung.com>
Fri, 19 Jun 2020 16:58:14 +0000 (22:28 +0530)
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/697
(cherry-picked from 5f16b1a9e8aa57e535d3bdf7a7e318a8c3b557ff)

Change-Id: I9188df1161d97302a837af2aeec76d0ee0a72592
Signed-off-by: Kush <kush.agrawal@samsung.com>
Signed-off-by: Sudipto <sudipto.bal@samsung.com>
build_common/SConscript
resource/csdk/connectivity/src/camessagehandler.c

index 6dc7f19..ed663ef 100755 (executable)
@@ -140,6 +140,7 @@ help_vars.Add(EnumVariable('PLATFORM_TLS', 'Use platform tls instead of local mb
 help_vars.Add(EnumVariable('OIC_SUPPORT_TIZEN_TRACE', 'Tizen Trace(T-trace) api availability', 'False', allowed_values=('True', 'False')))
 help_vars.Add(BoolVariable('WITH_PROCESS_EVENT','Build including process event logics in ocstack', 'False'))
 help_vars.Add(BoolVariable('DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY', 'Disable auto-discovery of NSProvider over TCP for TCP connected events', False))
+help_vars.Add(BoolVariable('ENABLE_DUP','Enable duplicate IPv4/IPv6 packets', 'False'))
 AddOption('--prefix',
                   dest='prefix',
                   type='string',
@@ -385,6 +386,9 @@ if env.get('WITH_PROCESS_EVENT'):
 if env.get('DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY'):
        env.AppendUnique(CPPDEFINES = ['DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY'])
 
+if env.get('ENABLE_DUP'):
+        env.AppendUnique(CPPDEFINES = ['ENABLE_DUP'])
+
 libs = []
 if env.get('SECURED') == '1':
     defines.append('-D__WITH_DTLS__=1')
index da4320d..ab515be 100644 (file)
@@ -768,7 +768,16 @@ static bool CADropSecondMessage(CAHistory_t *history, const CAEndpoint_t *ep, ui
     {
         CAHistoryItem_t *item = &(history->items[i]);
         if (id == item->messageId && tokenLength == item->tokenLength
-            && memcmp(item->token, token, tokenLength) == 0)
+#ifndef ENABLE_DUP
+            && ep->ifindex == item->ifindex && memcmp(item->token, token, tokenLength) == 0)
+        {
+             OIC_LOG_V(INFO, TAG, "IPv%c duplicate message ignored",
+                          familyFlags & CA_IPV6 ? '6' : '4');
+             ret = true;
+             break;
+        }
+#else
+        && memcmp(item->token, token, tokenLength) == 0)
         {
             if ((familyFlags ^ item->flags) == CA_IPFAMILY_MASK)
             {
@@ -777,11 +786,15 @@ static bool CADropSecondMessage(CAHistory_t *history, const CAEndpoint_t *ep, ui
                 ret = true;
                 break;
             }
-        }
+       }
+#endif
     }
 
     history->items[history->nextIndex].flags = familyFlags;
     history->items[history->nextIndex].messageId = id;
+#ifndef ENABLE_DUP
+    history->items[history->nextIndex].ifindex = ep->ifindex;
+#endif
     if (token && tokenLength)
     {
         memcpy(history->items[history->nextIndex].token, token, tokenLength);