{
case OCREP_PROP_INT:
dest->arr.iArray = (int64_t*)OICMalloc(dimTotal * sizeof(int64_t));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.iArray, "Failed allocating memory");
memcpy(dest->arr.iArray, source->arr.iArray, dimTotal * sizeof(int64_t));
break;
case OCREP_PROP_DOUBLE:
dest->arr.dArray = (double*)OICMalloc(dimTotal * sizeof(double));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.dArray, "Failed allocating memory");
memcpy(dest->arr.dArray, source->arr.dArray, dimTotal * sizeof(double));
break;
case OCREP_PROP_BOOL:
dest->arr.bArray = (bool*)OICMalloc(dimTotal * sizeof(bool));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.bArray, "Failed allocating memory");
memcpy(dest->arr.bArray, source->arr.bArray, dimTotal * sizeof(bool));
break;
case OCREP_PROP_STRING:
dest->arr.strArray = (char**)OICMalloc(dimTotal * sizeof(char*));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.strArray, "Failed allocating memory");
for(size_t i = 0; i < dimTotal; ++i)
{
dest->arr.strArray[i] = OICStrdup(source->arr.strArray[i]);
break;
case OCREP_PROP_OBJECT:
dest->arr.objArray = (OCRepPayload**)OICMalloc(dimTotal * sizeof(OCRepPayload*));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.objArray, "Failed allocating memory");
for(size_t i = 0; i < dimTotal; ++i)
{
dest->arr.objArray[i] = OCRepPayloadClone(source->arr.objArray[i]);
break;
case OCREP_PROP_ARRAY:
dest->arr.objArray = (OCRepPayload**)OICMalloc(dimTotal * sizeof(OCRepPayload*));
+ VERIFY_PARAM_NON_NULL(TAG, dest->arr.objArray, "Failed allocating memory");
for(size_t i = 0; i < dimTotal; ++i)
{
dest->arr.objArray[i] = OCRepPayloadClone(source->arr.objArray[i]);
OIC_LOG(ERROR, TAG, "CopyPropertyValueArray invalid type");
break;
}
+exit:
+ return;
}
static void OCCopyPropertyValue (OCRepPayloadValue *dest, OCRepPayloadValue *source)
return payload;
}
-//TODO : Remove this once all cbor changes land.
-OCSecurityPayload* OCSecurityPayloadCreate(const char* securityData)
-{
- OCSecurityPayload* payload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
-
- if (!payload)
- {
- return NULL;
- }
-
- payload->base.type = PAYLOAD_TYPE_SECURITY;
- payload->securityData = OICStrdup(securityData);
-
- return payload;
-}
-
-// TODO : To convert this to OCSecurityPayloadCreate once all cbor changes land.
-OCSecurityPayload* OCSecurityPayloadCBORCreate(const uint8_t* securityData, size_t size)
+OCSecurityPayload* OCSecurityPayloadCreate(const uint8_t* securityData, size_t size)
{
OCSecurityPayload* payload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
}
payload->base.type = PAYLOAD_TYPE_SECURITY;
- payload->securityData1 = (uint8_t *)OICCalloc(1, size);
- if (!payload->securityData1)
+ payload->securityData = (uint8_t *)OICCalloc(1, size);
+ if (!payload->securityData)
{
OICFree(payload);
return NULL;
}
- memcpy(payload->securityData1, (uint8_t *)securityData, size);
+ memcpy(payload->securityData, (uint8_t *)securityData, size);
payload->payloadSize = size;
return payload;
{
return;
}
- // Remove this once all cbor changes land.
+
OICFree(payload->securityData);
- // OICFree(payload->securityData1);
OICFree(payload);
}
return NULL;
}
-static OCResourcePayload* OCCopyResource(const OCResource* res, uint16_t port)
+static OCResourcePayload* OCCopyResource(const OCResource* res, uint16_t securePort,
+ uint16_t tcpPort)
{
OCResourcePayload* pl = (OCResourcePayload*)OICCalloc(1, sizeof(OCResourcePayload));
if (!pl)
pl->bitmap = res->resourceProperties & (OC_OBSERVABLE | OC_DISCOVERABLE);
pl->secure = (res->resourceProperties & OC_SECURE) != 0;
- pl->port = port;
-
+ pl->port = securePort;
+#ifdef TCP_ADAPTER
+ pl->tcpPort = tcpPort;
+#endif
return pl;
}
void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
- uint16_t port)
+ uint16_t securePort, uint16_t tcpPort)
{
- OCDiscoveryPayloadAddNewResource(payload, OCCopyResource(res, port));
+ OCDiscoveryPayloadAddNewResource(payload, OCCopyResource(res, securePort, tcpPort));
}
bool OCResourcePayloadAddStringLL(OCStringLL **stringLL, const char *value)
if (!*stringLL)
{
*stringLL = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
- VERIFY_PARAM_NON_NULL(TAG, dup, "Failed allocating memory");
+ VERIFY_PARAM_NON_NULL(TAG, *stringLL, "Failed allocating memory");
(*stringLL)->value = dup;
return true;
}
return;
}
OICFree(payload->sid);
+ OICFree(payload->baseURI);
+ OICFree(payload->uri);
+ OICFree(payload->type);
+ OICFree(payload->name);
+ OCFreeOCStringLL(payload->interface);
OCDiscoveryResourceDestroy(payload->resources);
OICFree(payload);
}
goto exit;
}
+ OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_DEFAULT);
+ OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_READ);
+
payload->types = CloneOCStringLL((OCStringLL *)types);
if (types && !payload->types)
{
OICFree(payload->specVersion);
OICFree(payload->dataModelVersion);
OCFreeOCStringLL(payload->types);
+ OCFreeOCStringLL(payload->interfaces);
OICFree(payload);
}
}
payload->base.type = PAYLOAD_TYPE_PLATFORM;
-
- payload->interfaces = (OCStringLL*)OICCalloc(1, sizeof(OCStringLL));
- if (!payload->interfaces)
- {
- return NULL;
- }
- payload->interfaces->value = OICStrdup(OC_RSRVD_INTERFACE_READ);
payload->rt = OICStrdup(OC_RSRVD_RESOURCE_TYPE_PLATFORM);
+
+ OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_DEFAULT);
+ OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_READ);
+
OCCopyPlatformInfo(platformInfo, payload);
return payload;