Commit 3bdc51bd authored by Habib Virji's avatar Habib Virji Committed by Phil Coval

Fix query handling for /oic/res

There was a mix up when query was supplied, it was only working if the interfaceQuery passed too. With just rt supplied,
it was returning all the resource. This patch fixes up the issue.

Change-Id: I980f0dd73fafdadd3d1dabae5edf024ac256f95c
Signed-off-by: default avatarHabib Virji <>
Reviewed-on: default avatarMushfiqul Islam <>
Tested-by: default avatarjenkins-iotivity <>
Reviewed-by: default avatarPhil Coval <>
parent ad2bfa44
......@@ -796,7 +796,6 @@ static OCStackResult addDiscoveryBaselineCommonProperties(OCDiscoveryPayload *di
VERIFY_PARAM_NON_NULL(TAG, discPayload->uri, "Failed adding href to discovery payload.");
OCGetPropertyValue(PAYLOAD_TYPE_DEVICE, "deviceName", (void **)&discPayload->name);
VERIFY_PARAM_NON_NULL(TAG, discPayload->name, "Failed adding name to discovery payload.");
discPayload->type = (OCStringLL*)OICCalloc(1, sizeof(OCStringLL));
VERIFY_PARAM_NON_NULL(TAG, discPayload->type, "Failed adding rt to discovery payload.");
......@@ -855,7 +854,7 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
bool baselineQuery = false;
if (interfaceQuery && 0 != strcmp(interfaceQuery, OC_RSRVD_INTERFACE_LL))
if (interfaceQuery && 0 == strcmp(interfaceQuery, OC_RSRVD_INTERFACE_DEFAULT))
baselineQuery = true;
......@@ -883,12 +882,14 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
if (OC_STACK_NO_RESOURCE == discoveryResult)
if ((!baselineQuery && (resource->resourceProperties & prop)) ||
(baselineQuery && (includeThisResourceInResponse(resource, interfaceQuery,
// This case will handle when no resource type and it is oic.if.ll.
if (!resourceTypeQuery && !baselineQuery && (resource->resourceProperties & prop))
discoveryResult = BuildVirtualResourceResponse(resource, discPayload,
discoveryResult = BuildVirtualResourceResponse(resource, discPayload, &request->devAddr);
else if (includeThisResourceInResponse(resource, interfaceQuery, resourceTypeQuery))
discoveryResult = BuildVirtualResourceResponse(resource, discPayload, &request->devAddr);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment