From: Habib Virji Date: Fri, 1 Jul 2016 14:09:57 +0000 (+0100) Subject: [IOT-986] Not send response to multicast message for resource not existing X-Git-Tag: 1.2.0+RC1~251 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9633b594ac497f854341c4964858f0f628f7c8b5;p=platform%2Fupstream%2Fiotivity.git [IOT-986] Not send response to multicast message for resource not existing 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/9073 Tested-by: jenkins-iotivity Reviewed-by: Mushfiqul Islam Reviewed-by: Ziran Sun --- diff --git a/resource/csdk/stack/include/octypes.h b/resource/csdk/stack/include/octypes.h index 7867d1d..9a32a43 100644 --- a/resource/csdk/stack/include/octypes.h +++ b/resource/csdk/stack/include/octypes.h @@ -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.*/ diff --git a/resource/csdk/stack/src/ocresource.c b/resource/csdk/stack/src/ocresource.c index fc36619..cc25c77 100755 --- a/resource/csdk/stack/src/ocresource.c +++ b/resource/csdk/stack/src/ocresource.c @@ -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. "); } }