Fixed policy response in /oic/res discovery
authorJongmin Choi <jminl.choi@samsung.com>
Tue, 28 Jun 2016 08:02:20 +0000 (17:02 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 29 Jun 2016 05:39:01 +0000 (05:39 +0000)
Added "sec": false to response in case of unsecure resource
Removed "port" information in case of unsecure resource

This patch is based on the Core Spec CR on resource policy.
If "sec" is false, it may or may not be included in /oic/res discovery response.
If "sec" is false, "port" shall be omitted in the response.
This patch should be used together with
Disable OC_SECURE flag in case of SECURED=0 build patch
(https://gerrit.iotivity.org/gerrit/#/c/8875/)

Change-Id: I8e0f3b39896c8856ab659f966e1227196e0f2153
Signed-off-by: Jongmin Choi <jminl.choi@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8987
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/stack/src/ocpayloadconvert.c

index 5ee09cc..29a6691 100644 (file)
@@ -334,15 +334,14 @@ static int64_t OCConvertDiscoveryPayload(OCDiscoveryPayload *payload, uint8_t *o
             err |= cbor_encode_uint(&policyMap, resource->bitmap);
             VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding bitmap value to policy map");
 
-            if (resource->secure)
-            {
-                err |= cbor_encode_text_string(&policyMap, OC_RSRVD_SECURE,
-                        sizeof(OC_RSRVD_SECURE) - 1);
-                VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding secure tag to policy map");
-                err |= cbor_encode_boolean(&policyMap, OC_RESOURCE_SECURE);
-                VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding secure value to policy map");
-            }
-            if ((resource->secure && resource->port != 0) || payload->baseURI)
+            // Secure
+            err |= cbor_encode_text_string(&policyMap, OC_RSRVD_SECURE,
+                    sizeof(OC_RSRVD_SECURE) - 1);
+            VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding secure tag to policy map");
+            err |= cbor_encode_boolean(&policyMap, resource->secure);
+            VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding secure value to policy map");
+
+            if (resource->secure || payload->baseURI)
             {
                 err |= cbor_encode_text_string(&policyMap, OC_RSRVD_HOSTING_PORT,
                         sizeof(OC_RSRVD_HOSTING_PORT) - 1);