From d386e3797794d970b5e96c25fc00780c80b2a6fe Mon Sep 17 00:00:00 2001 From: Kush Date: Wed, 4 Mar 2020 21:02:39 +0530 Subject: [PATCH] [CONPRO-1568] Ignoring duplicate IPv6/Ipv4 messages Issue : There can be duplicate messages coming from multiple ipv6 (or v4) addresses in the system. The presence of ipv6 link-local for instance could cause duplicate messages to appear. Solution : Remove check based on IPv4/Ipv6 https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/668 (cherry-picked from 7d5e906bedb032f88f2dd2fca97f70a631c1346e) Change-Id: I7fd73ad9401a30192141a048db9d88cd7bfea3b6 Signed-off-by: Kush Signed-off-by: DoHyun Pyun --- resource/csdk/connectivity/api/cacommon.h | 1 + resource/csdk/connectivity/src/camessagehandler.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) mode change 100755 => 100644 resource/csdk/connectivity/api/cacommon.h diff --git a/resource/csdk/connectivity/api/cacommon.h b/resource/csdk/connectivity/api/cacommon.h old mode 100755 new mode 100644 index d1e53f7..f236968 --- a/resource/csdk/connectivity/api/cacommon.h +++ b/resource/csdk/connectivity/api/cacommon.h @@ -547,6 +547,7 @@ typedef struct uint16_t messageId; char token[CA_MAX_TOKEN_LEN]; uint8_t tokenLength; + uint32_t ifindex; } CAHistoryItem_t; typedef struct diff --git a/resource/csdk/connectivity/src/camessagehandler.c b/resource/csdk/connectivity/src/camessagehandler.c index da4320d..5a92d15 100644 --- a/resource/csdk/connectivity/src/camessagehandler.c +++ b/resource/csdk/connectivity/src/camessagehandler.c @@ -768,20 +768,18 @@ 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) + && ep->ifindex == item->ifindex && memcmp(item->token, token, tokenLength) == 0) { - if ((familyFlags ^ item->flags) == CA_IPFAMILY_MASK) - { - OIC_LOG_V(INFO, TAG, "IPv%c duplicate message ignored", - familyFlags & CA_IPV6 ? '6' : '4'); - ret = true; - break; - } + OIC_LOG_V(INFO, TAG, "IPv%c duplicate message ignored", + familyFlags & CA_IPV6 ? '6' : '4'); + ret = true; + break; } } history->items[history->nextIndex].flags = familyFlags; history->items[history->nextIndex].messageId = id; + history->items[history->nextIndex].ifindex = ep->ifindex; if (token && tokenLength) { memcpy(history->items[history->nextIndex].token, token, tokenLength); -- 2.7.4