Change SECURITY payload in correct format.
authorHabib Virji <habib.virji@samsung.com>
Thu, 10 Dec 2015 14:09:45 +0000 (14:09 +0000)
committerJon A. Cruz <jonc@osg.samsung.com>
Thu, 10 Dec 2015 21:28:08 +0000 (21:28 +0000)
Updated code to correct format:
[ { rep: security payload } ]

to

{security payload}

Change-Id: I8ab414d762b34c75ccff6ac7698d564462636829
Signed-off-by: Habib Virji <habib.virji@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4499
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/stack/src/ocpayloadconvert.c
resource/csdk/stack/src/ocpayloadparse.c

index 861f70a..e5ae680 100644 (file)
@@ -185,22 +185,17 @@ static int64_t OCConvertSecurityPayload(OCSecurityPayload* payload, uint8_t* out
 
     cbor_encoder_init(&encoder, outPayload, *size, 0);
 
-    CborEncoder rootArray;
-    err = err | cbor_encoder_create_array(&encoder, &rootArray, 1);
     CborEncoder map;
 
-    err = err | cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
+    err = err | cbor_encoder_create_map(&encoder, &map, CborIndefiniteLength);
 
     if(payload->securityData)
     {
-        err = err | AddTextStringToMap(&map, OC_RSRVD_REPRESENTATION,
-                sizeof(OC_RSRVD_REPRESENTATION) - 1,
-                payload->securityData);
+        err = err | cbor_encode_text_string(&map, payload->securityData,
+                                            strlen(payload->securityData));
     }
 
-    err = err | cbor_encoder_close_container(&rootArray, &map);
-
-    err = err | cbor_encoder_close_container(&encoder, &rootArray);
+    err = err | cbor_encoder_close_container(&encoder, &map);
     return checkError(err, &encoder, outPayload, size);
 }
 
index 05023ae..14fb921 100644 (file)
@@ -112,19 +112,13 @@ static OCStackResult OCParseSecurityPayload(OCPayload** outPayload, CborValue* r
 
     bool err = false;
     char * securityData = NULL;
-    CborValue arrayVal;
-    err = err || cbor_value_enter_container(rootValue, &arrayVal);
+    CborValue map;
+    err = err || cbor_value_enter_container(rootValue, &map);
 
-    if(cbor_value_is_map(&arrayVal))
+    if(cbor_value_is_map(&map))
     {
-        CborValue curVal;
-        err = err || cbor_value_map_find_value(&arrayVal, OC_RSRVD_REPRESENTATION, &curVal);
-
-        if(cbor_value_is_valid(&curVal))
-        {
-            size_t len;
-            err = err || cbor_value_dup_text_string(&curVal, &securityData, &len, NULL);
-        }
+        size_t len;
+        err = err || cbor_value_dup_text_string(&map, &securityData, &len, NULL);
     }
     else
     {
@@ -132,8 +126,7 @@ static OCStackResult OCParseSecurityPayload(OCPayload** outPayload, CborValue* r
         return OC_STACK_MALFORMED_RESPONSE;
     }
 
-    err = err || cbor_value_advance(&arrayVal);
-    err = err || cbor_value_leave_container(rootValue, &arrayVal);
+    err = err || cbor_value_leave_container(rootValue, &map);
 
     if(err)
     {