[IOT-986] Not send response to multicast message for resource not existing
authorHabib Virji <habib.virji@samsung.com>
Fri, 1 Jul 2016 14:09:57 +0000 (15:09 +0100)
committerZiran Sun <ziran.sun@samsung.com>
Tue, 5 Jul 2016 09:39:16 +0000 (09:39 +0000)
The resource not existing, it should not return any response for multicast packet.
There was no check for multicast request, this has been added and it does not send
any response.

Also add OC_MULTICAST type in octypes.h.
octypes.h transport flag should correspond to flags set in the CA layer. In the CA
layer (1 << 7), 7 bit is set for Multicast. In the RI layer, the type were differing,
hence was not possible to check if it is multicast packet. Please note the OC_RESERVED1
was not used anywhere and was wrong, it should match the transport flag of the CA layer.

BUG: http://jira.iotivity.org/browse/IOT-1126,
     http://jira.iotivity.org/browse/IOT-1107,
     http://jira.iotivity.org/browse/IOT-986

Change-Id: Ia8a7d1bdacf4e9a8a8d6cb21c49ad830cce7c3cc
Signed-off-by: Habib Virji <habib.virji@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9073
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Mushfiqul Islam <i.mushfiq@samsung.com>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
resource/csdk/stack/include/octypes.h
resource/csdk/stack/src/ocresource.c

index 7867d1d..9a32a43 100644 (file)
@@ -398,8 +398,8 @@ typedef enum
     /** IP & TCP adapter only.*/
     OC_IP_USE_V4       = (1 << 6),
 
-    /** internal use only.*/
-    OC_RESERVED1       = (1 << 7),   // internal use only
+    /** Multicast only.*/
+    OC_MULTICAST       = (1 << 7),
 
     /** Link-Local multicast is the default multicast scope for IPv6.
      *  These are placed here to correspond to the IPv6 multicast address bits.*/
index fc36619..cc25c77 100755 (executable)
@@ -705,8 +705,6 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
     }
 
     OCStackResult discoveryResult = OC_STACK_ERROR;
-
-    bool bMulticast    = false;     // Was the discovery request a multicast request?
     OCPayload* payload = NULL;
 
     OIC_LOG(INFO, TAG, "Entering HandleVirtualResource");
@@ -948,19 +946,19 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
         {
             SendNonPersistantDiscoveryResponse(request, resource, payload, OC_EH_OK);
         }
-        else if(bMulticast == false && (request->devAddr.adapter != OC_ADAPTER_RFCOMM_BTEDR) &&
-               (request->devAddr.adapter != OC_ADAPTER_GATT_BTLE))
+        else if(((request->devAddr.flags &  OC_MULTICAST) == false) &&
+            (request->devAddr.adapter != OC_ADAPTER_RFCOMM_BTEDR) &&
+            (request->devAddr.adapter != OC_ADAPTER_GATT_BTLE))
         {
-            OIC_LOG_V(ERROR, TAG, "Sending a (%d) error to (%d)  \
-                discovery request", discoveryResult, virtualUriInRequest);
+            OIC_LOG_V(ERROR, TAG, "Sending a (%d) error to (%d) discovery request",
+                discoveryResult, virtualUriInRequest);
             SendNonPersistantDiscoveryResponse(request, resource, NULL,
                 (discoveryResult == OC_STACK_NO_RESOURCE) ? OC_EH_RESOURCE_NOT_FOUND : OC_EH_ERROR);
         }
         else
         {
             // Ignoring the discovery request as per RFC 7252, Section #8.2
-            OIC_LOG(INFO, TAG, "Silently ignoring the request since device does not have \
-                any useful data to send");
+            OIC_LOG(INFO, TAG, "Silently ignoring the request since no useful data to send. ");
         }
     }