Commit 91415dfd authored by Sachin Agrawal's avatar Sachin Agrawal

Add new resource property 'EXPLICIT_DISCOVERABLE'

Some resources (such as, SVR's) needs to be discovered only when
explicitly requested. This property allows the resource to be included
in discovery response only when explicitly requested via query filters.

Change-Id: I1adeffa0996ecf36ffdd9ebd3dbf9c32d9f3cc0d
Signed-off-by: default avatarSachin Agrawal <sachin.agrawal@intel.com>
Signed-off-by: default avatarSakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1680Reviewed-by: default avatarJoseph Morrow <joseph.l.morrow@intel.com>
Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1952
parent 46bf148c
......@@ -66,6 +66,7 @@ struct SPTargetDeviceInfo
OCDevAddr endpoint; /**< target address **/
OicSecPstat_t *pstat; /**< Pointer to target's pstat resource. **/
OicSecDoxm_t *doxm; /**< Pointer to target's doxm resource. **/
uint16_t securePort; /**< Secure port **/
SPTargetDeviceInfo_t *next; /**< Next pointer. **/
};
......
......@@ -386,7 +386,7 @@ OCStackResult CreateACLResource()
OIC_RSRC_ACL_URI,
ACLEntityHandler,
NULL,
OC_OBSERVABLE);
OC_OBSERVABLE | OC_SECURE | OC_EXPLICIT_DISCOVERABLE);
if (OC_STACK_OK != ret)
{
......
......@@ -580,7 +580,7 @@ OCStackResult CreateDoxmResource()
OIC_RSRC_DOXM_URI,
DoxmEntityHandler,
NULL,
OC_OBSERVABLE);
OC_OBSERVABLE | OC_SECURE | OC_EXPLICIT_DISCOVERABLE);
if (OC_STACK_OK != ret)
{
......
......@@ -333,6 +333,9 @@ typedef enum
* signifies that responses from this resource can expect delays in
* processing its requests from clients.
* ::OC_SECURE When this bit is set, the resource is a secure resource.
* ::OC_EXPLICIT_DISCOVERABLE When this bit is set, the resource is allowed to be discovered only
* if discovery request contains an explicit querystring.
* Ex: GET /oic/res?rt=oic.sec.acl
*/
typedef enum
{
......@@ -341,7 +344,8 @@ typedef enum
OC_OBSERVABLE = (1 << 1),
OC_ACTIVE = (1 << 2),
OC_SLOW = (1 << 3),
OC_SECURE = (1 << 4)
OC_SECURE = (1 << 4),
OC_EXPLICIT_DISCOVERABLE = (1 << 5)
} OCResourceProperty;
/**
......
......@@ -324,8 +324,6 @@ OCStackResult DetermineResourceHandling (const OCServerRequest *request,
OC_LOG_V(INFO, TAG, "DetermineResourceHandling for %s", request->resourceUrl);
const OCDevAddr *devAddr = &request->devAddr;
// Check if virtual resource
if (GetTypeOfVirtualURI(request->resourceUrl) != OC_UNKNOWN_URI)
{
......@@ -359,13 +357,6 @@ OCStackResult DetermineResourceHandling (const OCServerRequest *request,
return OC_STACK_NO_RESOURCE;
}
// secure resource will entertain only authorized requests
if ((resourcePtr->resourceProperties & OC_SECURE) && ((devAddr->flags & OC_FLAG_SECURE) == 0))
{
OC_LOG(ERROR, TAG, PCF("Un-authorized request. Ignoring"));
return OC_STACK_RESOURCE_ERROR;
}
if (IsCollectionResource (resourcePtr))
{
// Collection resource
......@@ -502,7 +493,21 @@ static bool includeThisResourceInResponse(OCResource *resource,
return false;
}
if ( !(resource->resourceProperties & OC_ACTIVE) ||
if ( resource->resourceProperties & OC_EXPLICIT_DISCOVERABLE)
{
/*
* At least one valid filter should be available to
* include the resource in discovery response
*/
if (!((interfaceFilter && *interfaceFilter ) ||
(resourceTypeFilter && *resourceTypeFilter)))
{
OC_LOG_V(INFO, TAG, PCF("%s no query string for EXPLICIT_DISCOVERABLE \
resource"), resource->uri);
return false;
}
}
else if ( !(resource->resourceProperties & OC_ACTIVE) ||
!(resource->resourceProperties & OC_DISCOVERABLE))
{
OC_LOG_V(INFO, TAG, PCF("%s not ACTIVE or DISCOVERABLE"), resource->uri);
......
......@@ -2627,7 +2627,8 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
// Make sure resourceProperties bitmask has allowed properties specified
if (resourceProperties
> (OC_ACTIVE | OC_DISCOVERABLE | OC_OBSERVABLE | OC_SLOW | OC_SECURE))
> (OC_ACTIVE | OC_DISCOVERABLE | OC_OBSERVABLE | OC_SLOW | OC_SECURE |
OC_EXPLICIT_DISCOVERABLE))
{
OC_LOG(ERROR, TAG, PCF("Invalid property"));
return OC_STACK_INVALID_PARAM;
......
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