Merge branch 'master' into notification-service
[platform/upstream/iotivity.git] / resource / csdk / stack / src / ocpayloadparse.c
old mode 100644 (file)
new mode 100755 (executable)
index 4763299..bd37367
@@ -340,6 +340,16 @@ static OCStackResult OCParseDiscoveryPayload(OCPayload **outPayload, CborValue *
                 VERIFY_CBOR_SUCCESS(TAG, err, "to find port value");
             }
 
+#ifdef TCP_ADAPTER
+            // TCP Port
+            err = cbor_value_map_find_value(&policyMap, OC_RSRVD_TCP_PORT, &curVal);
+            if (cbor_value_is_valid(&curVal))
+            {
+                err = cbor_value_get_int(&curVal, (int *)&resource->tcpPort);
+                VERIFY_CBOR_SUCCESS(TAG, err, "to find tcp port value");
+            }
+#endif
+
             err = cbor_value_advance(&resourceMap);
             VERIFY_CBOR_SUCCESS(TAG, err, "to advance resource map");
 
@@ -356,6 +366,8 @@ static OCStackResult OCParseDiscoveryPayload(OCPayload **outPayload, CborValue *
     }
 
     *outPayload = (OCPayload *)out;
+    OIC_LOG_PAYLOAD(DEBUG, *outPayload);
+
     return OC_STACK_OK;
 
 exit:
@@ -385,6 +397,7 @@ static OCStackResult OCParseDevicePayload(OCPayload **outPayload, CborValue *roo
         // Resource Type
         err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &curVal);
         VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
+
         if (cbor_value_is_valid(&curVal))
         {
             err =  OCParseStringLL(rootValue, OC_RSRVD_RESOURCE_TYPE, &out->types);
@@ -456,7 +469,7 @@ static OCStackResult OCParsePlatformPayload(OCPayload **outPayload, CborValue *r
     OCStackResult ret = OC_STACK_INVALID_PARAM;
     CborError err = CborNoError;
     OCPlatformInfo info = {0};
-    char* rt = NULL;
+    OCStringLL* rt = NULL;
     OCStringLL* interfaces = NULL;
     OCPlatformPayload* out = NULL;
 
@@ -560,15 +573,17 @@ static OCStackResult OCParsePlatformPayload(OCPayload **outPayload, CborValue *r
         // Resource type
         err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &repVal);
         VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
+
         if(cbor_value_is_valid(&repVal))
         {
-            err = cbor_value_dup_text_string(&repVal, &rt, &len, NULL);
+            err = OCParseStringLL(rootValue, OC_RSRVD_RESOURCE_TYPE, &rt);
             VERIFY_CBOR_SUCCESS(TAG, err, "Failed to find resource type in the platform payload");
         }
 
         // Interface Types
         err = cbor_value_map_find_value(rootValue, OC_RSRVD_INTERFACE, &repVal);
         VERIFY_CBOR_SUCCESS(TAG, err, "to find interface tag");
+
         if(cbor_value_is_valid(&repVal))
         {
             err =  OCParseStringLL(rootValue, OC_RSRVD_INTERFACE, &interfaces);
@@ -841,8 +856,10 @@ exit:
 static CborError OCParseArray(OCRepPayload *out, const char *name, CborValue *container)
 {
     void *arr = NULL;
-    OCRepPayloadPropType type;
-    size_t dimensions[MAX_REP_ARRAY_DEPTH];
+
+    OCRepPayloadPropType type = OCREP_PROP_NULL;
+    size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
+
     size_t dimTotal = 0;
     size_t allocSize = 0;
     bool res = true;