Commit 3c34fc27 authored by Steven Saunders's avatar Steven Saunders Committed by Nathan Heldt-Sheller

Rename macro VERIFY_CBOR_SUCCESS

to VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY

Change-Id: I5ee8795a21d8d84708737f83957fe260cf1234d2
Signed-off-by: default avatarSteven Saunders <s.saunders-contractor@cablelabs.com>
parent faaf7fc4
......@@ -44,7 +44,7 @@
#define PLUGINSPECIFICDETAILS "PluginSpecificDetails"
#define RESOURCES "RESOURCES"
#define VERIFY_CBOR_SUCCESS(log_tag, err, log_message) \
#define VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(log_tag, err, log_message) \
if ((CborNoError != (err)) && (CborErrorOutOfMemory != (err))) \
{ \
if ((log_tag) && (log_message)) \
......@@ -134,38 +134,38 @@ int64_t MPMFormMetaData(MPMResourceList *list, MPMDeviceSpecificData *deviceDeta
cbor_encoder_init(&encoder, buff, size, 0);
err = cbor_encoder_create_array(&encoder, &rootArray, 1);
VERIFY_CBOR_SUCCESS(TAG, err, " Creating Root Array");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Creating Root Array");
err = cbor_encoder_create_map(&rootArray, &rootMap, CborIndefiniteLength);
VERIFY_CBOR_SUCCESS(TAG, err, "Creating Root MAP");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Creating Root MAP");
if (deviceDetails)
{
err = AddTextStringToMap(&rootMap, NAME, sizeof(NAME) - 1,
deviceDetails->devName);
VERIFY_CBOR_SUCCESS(TAG, err, "Adding device name");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Adding device name");
err = AddTextStringToMap(&rootMap, MANUFACTURER, sizeof(MANUFACTURER) - 1,
deviceDetails->manufacturerName);
VERIFY_CBOR_SUCCESS(TAG, err, "Adding Manufacture name");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Adding Manufacture name");
err = AddTextStringToMap(&rootMap, DEVICETYPE, sizeof(DEVICETYPE) - 1,
deviceDetails->devType);
VERIFY_CBOR_SUCCESS(TAG, err, "Adding Device Type");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Adding Device Type");
}
if (details)
{
err = AddstructureToMap(&rootMap, PLUGINSPECIFICDETAILS, sizeof(PLUGINSPECIFICDETAILS) - 1,
(const char *)details, payloadSize);
VERIFY_CBOR_SUCCESS(TAG, err, "Adding Plugin specific Details");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Adding Plugin specific Details");
}
err = cbor_encode_text_string(&rootMap, RESOURCES, sizeof(RESOURCES) - 1);
VERIFY_CBOR_SUCCESS(TAG, err, "Encoding Resources string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Encoding Resources string");
err = cbor_encoder_create_array(&rootMap, &linkArray, CborIndefiniteLength);
VERIFY_CBOR_SUCCESS(TAG, err, "Creating Link Array");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Creating Link Array");
for ( ; list ; )
{
......@@ -174,30 +174,30 @@ int64_t MPMFormMetaData(MPMResourceList *list, MPMDeviceSpecificData *deviceDeta
list->interfaces, list->bitmap);
// resource map inside the links array.
err = cbor_encoder_create_map(&linkArray, &linkMap, 4);
VERIFY_CBOR_SUCCESS(TAG, err, "Creating Link Map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Creating Link Map");
err = AddTextStringToMap(&linkMap, OC::Key::RESOURCETYPESKEY.c_str(),
OC::Key::RESOURCETYPESKEY.size(),
list->rt);
VERIFY_CBOR_SUCCESS(TAG, err, "Adding Resource type");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Adding Resource type");
err = AddTextStringToMap(&linkMap, OC::Key::URIKEY.c_str(), OC::Key::URIKEY.size(),
list->href);
VERIFY_CBOR_SUCCESS(TAG, err, "Adding OC::Key::URIKEY");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Adding OC::Key::URIKEY");
err = AddTextStringToMap(&linkMap, OC::Key::INTERFACESKEY.c_str(),
OC::Key::INTERFACESKEY.size(), list->interfaces);
VERIFY_CBOR_SUCCESS(TAG, err, "Adding Resource Interface");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Adding Resource Interface");
err = cbor_encode_text_string(&linkMap, OC::Key::BMKEY.c_str(), OC::Key::BMKEY.size());
VERIFY_CBOR_SUCCESS(TAG, err, "Encoding Bitmap string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Encoding Bitmap string");
err = cbor_encode_int(&linkMap, list->bitmap);
VERIFY_CBOR_SUCCESS(TAG, err, "encoding bit map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "encoding bit map");
// close link map inside link array
err = cbor_encoder_close_container(&linkArray, &linkMap);
VERIFY_CBOR_SUCCESS(TAG, err, "Closing link map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Closing link map");
list = list -> next;
OICFree(temp);
......@@ -205,15 +205,15 @@ int64_t MPMFormMetaData(MPMResourceList *list, MPMDeviceSpecificData *deviceDeta
// Close links array inside the root map.
err = cbor_encoder_close_container(&rootMap, &linkArray);
VERIFY_CBOR_SUCCESS(TAG, err, "Closing link array");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Closing link array");
// close root map inside the root array.
err = cbor_encoder_close_container(&rootArray, &rootMap);
VERIFY_CBOR_SUCCESS(TAG, err, "Closing Root Map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Closing Root Map");
// Close the final root array.
err = cbor_encoder_close_container(&encoder, &rootArray);
VERIFY_CBOR_SUCCESS(TAG, err, "Closing root Array");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Closing root Array");
return err;
}
......@@ -229,13 +229,13 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
int bitmap;
err = cbor_parser_init(buff, size, 0, &parser, &rootValue);
VERIFY_CBOR_SUCCESS(TAG, err, "Parser cbor init");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Parser cbor init");
if (cbor_value_is_array(&rootValue))
{
OIC_LOG_V(DEBUG, TAG, "ENCODED DATA - %s ", (char *)buff);
err = cbor_value_enter_container(&rootValue, &rootMapValue);
VERIFY_CBOR_SUCCESS(TAG, err, "Entering root array");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Entering root array");
if (!cbor_value_is_map(&rootMapValue))
{
OIC_LOG(ERROR, TAG, "ERROR, Malformed packet");
......@@ -246,7 +246,7 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
{
// Parsing device details
err = cbor_value_map_find_value(&rootMapValue, NAME, &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, "finding Name in map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "finding Name in map");
if (cbor_value_is_valid(&curVal))
{
if (cbor_value_is_text_string(&curVal))
......@@ -254,7 +254,7 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
size_t len = 0;
char *input = NULL;
err = cbor_value_dup_text_string(&curVal, &input, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, err, "Duplicating name string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Duplicating name string");
OIC_LOG_V(DEBUG, TAG, "\"NAME\":%s\n", input);
free(input);
}
......@@ -262,7 +262,7 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
}
err = cbor_value_map_find_value(&rootMapValue, MANUFACTURER, &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, "Finding Manufacturer details in map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "Finding Manufacturer details in map");
if (cbor_value_is_valid(&curVal))
{
if (cbor_value_is_text_string(&curVal))
......@@ -270,14 +270,14 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
size_t len = 0;
char *input = NULL;
err = cbor_value_dup_text_string(&curVal, &input, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, err, " Copying Text string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Copying Text string");
OIC_LOG_V(DEBUG, TAG, "\"MF\":%s\n", input);
free(input);
}
}
err = cbor_value_map_find_value(&rootMapValue, PLUGINSPECIFICDETAILS, &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, " Finding PLUGINSPECIFICDETAILS in map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Finding PLUGINSPECIFICDETAILS in map ");
if (cbor_value_is_valid(&curVal))
{
if (cbor_value_is_text_string(&curVal))
......@@ -285,20 +285,20 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
size_t len = 0;
char *input = NULL;
err = cbor_value_dup_text_string(&curVal, &input, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, err, " Copying Text string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Copying Text string");
*details = (void *)input;
}
}
err = cbor_value_map_find_value(&rootMapValue, RESOURCES, &linkMapValue);
VERIFY_CBOR_SUCCESS(TAG, err, " Finding RESOURCES in map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Finding RESOURCES in map ");
// Enter the links array and start iterating through the array processing
// each resource which shows up as a map.
if (cbor_value_is_valid(&linkMapValue))
{
err = cbor_value_enter_container(&linkMapValue, &resourceMapValue);
VERIFY_CBOR_SUCCESS(TAG, err, " Entering Link map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Entering Link map ");
while (cbor_value_is_map(&resourceMapValue))
{
MPMResourceList *tempPtr;
......@@ -311,39 +311,39 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
size_t len = 0;
char *input = NULL;
err = cbor_value_map_find_value(&resourceMapValue, OC::Key::URIKEY.c_str(), &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, " Finding Uri in map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Finding Uri in map ");
err = cbor_value_dup_text_string(&curVal, &input, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, err, " Copying Text string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Copying Text string");
strncpy(tempPtr->href, input, MPM_MAX_LENGTH_64);
OIC_LOG_V(DEBUG, TAG, "\"ref\":%s\n", input);
free(input);
input = NULL;
err = cbor_value_map_find_value(&resourceMapValue, OC::Key::RESOURCETYPESKEY.c_str(), &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, " Finding Rt in link map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Finding Rt in link map ");
err = cbor_value_dup_text_string(&curVal, &input, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, err, " Copying Text string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Copying Text string");
strncpy(tempPtr->rt, input, MPM_MAX_LENGTH_64);
OIC_LOG_V(DEBUG, TAG, "\"rt\":%s\n", input);
free(input);
input = NULL;
err = cbor_value_map_find_value(&resourceMapValue, OC::Key::INTERFACESKEY.c_str(), &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, " Finding If's in link map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Finding If's in link map ");
err = cbor_value_dup_text_string(&curVal, &input, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, err, " Copying Text string");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Copying Text string");
strncpy(tempPtr->interfaces, input, MPM_MAX_LENGTH_64);
OIC_LOG_V(DEBUG, TAG, "\"if\":%s\n", input);
free(input);
input = NULL;
err = cbor_value_map_find_value(&resourceMapValue, OC::Key::BMKEY.c_str(), &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, " Finding Bms in link map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Finding Bms in link map ");
if (cbor_value_is_integer(&curVal))
{
err = cbor_value_get_int(&curVal, &bitmap);
VERIFY_CBOR_SUCCESS(TAG, err, " Getting bit map value fromx link map ");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, " Getting bit map value fromx link map ");
tempPtr->bitmap = bitmap;
OIC_LOG_V(DEBUG, TAG, "\"bm\":%d\n", bitmap);
}
......@@ -351,7 +351,7 @@ void MPMParseMetaData(const uint8_t *buff, size_t size, MPMResourceList **list,
tempPtr->next = *list;
*list = tempPtr;
err = cbor_value_advance(&resourceMapValue);
VERIFY_CBOR_SUCCESS(TAG, err, "in resource map value advance");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "in resource map value advance");
}
}
}
......
This diff is collapsed.
......@@ -102,24 +102,24 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
// Create AMACL Map
cborEncoderResult = cbor_encoder_create_map(&encoder, &amaclMap, AMACL_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding AMACL Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding AMACL Map.");
// resources -- Mandatory
cborEncoderResult = cbor_encode_text_string(&amaclMap, OIC_JSON_RESOURCES_NAME,
strlen(OIC_JSON_RESOURCES_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding Resource Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding Resource Name Tag.");
cborEncoderResult = cbor_encoder_create_map(&amaclMap, &rsrcMap, AMACL_RSRC_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding Resource Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding Resource Map.");
cborEncoderResult = cbor_encode_text_string(&rsrcMap, OIC_JSON_RLIST_NAME,
strlen(OIC_JSON_RLIST_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RLIST Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding RLIST Name Tag.");
// TODO : Need to input array length by OicSecAmacl_t->resources->rlistLen based on spec.
cborEncoderResult = cbor_encoder_create_array(&rsrcMap, &rlistArray, amacl->resourcesLen);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RLIST Array.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding RLIST Array.");
// TODO : Need to add OicSecAmacl_t->rlist as array rMap based on RAML spec.
for (size_t i = 0; i < amacl->resourcesLen; i++)
......@@ -127,46 +127,46 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
// TODO : Need to create rMap structure based on RAML spec.
CborEncoder rMap;
cborEncoderResult = cbor_encoder_create_map(&rlistArray, &rMap, AMACL_RLIST_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RLIST Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding RLIST Map.");
cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_HREF_NAME,
strlen(OIC_JSON_HREF_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding HREF Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding HREF Name Tag.");
cborEncoderResult = cbor_encode_text_string(&rMap, amacl->resources[i],
strlen(amacl->resources[i]));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding HREF Value in Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding HREF Value in Map.");
cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_RT_NAME,
strlen(OIC_JSON_RT_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RT Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding RT Name Tag.");
// TODO : Need to assign real value of RT
cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_EMPTY_STRING,
strlen(OIC_JSON_EMPTY_STRING));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RT Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding RT Value.");
cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_IF_NAME,
strlen(OIC_JSON_IF_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding IF Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding IF Name Tag.");
// TODO : Need to assign real value of IF
cborEncoderResult = cbor_encode_text_string(&rMap, OIC_JSON_EMPTY_STRING,
strlen(OIC_JSON_EMPTY_STRING));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding IF Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding IF Value.");
cborEncoderResult = cbor_encoder_close_container(&rlistArray, &rMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing RLIST Array.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Closing RLIST Array.");
}
cborEncoderResult = cbor_encoder_close_container(&rsrcMap, &rlistArray);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing RLIST Array.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Closing RLIST Array.");
cborEncoderResult = cbor_encoder_close_container(&amaclMap, &rsrcMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Resource Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Closing Resource Map.");
cborEncoderResult = cbor_encoder_close_container(&encoder, &amaclMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Amacl Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Closing Amacl Map.");
if (CborNoError == cborEncoderResult)
{
......@@ -226,16 +226,16 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
CborValue amaclMap = { .parser = NULL };
cborFindResult = cbor_value_enter_container(&amaclCbor, &amaclMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering Amacl Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Entering Amacl Map.");
while(cbor_value_is_valid(&amaclMap) && cbor_value_is_text_string(&amaclMap))
{
char *name = NULL;
size_t len = 0;
cborFindResult = cbor_value_dup_text_string(&amaclMap, &name, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Amacl Data Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding Amacl Data Name Tag.");
cborFindResult = cbor_value_advance(&amaclMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Amacl Data Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding Amacl Data Value.");
//CborType type = cbor_value_get_type(&amaclMap);
......@@ -245,7 +245,7 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
// resource map
CborValue rsrcMap = { .parser = NULL };
cborFindResult = cbor_value_enter_container(&amaclMap, &rsrcMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering Resource Map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Entering Resource Map");
while(cbor_value_is_valid(&rsrcMap) && cbor_value_is_text_string(&rsrcMap))
{
......@@ -253,9 +253,9 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
char *rsrcName = NULL;
size_t rsrcNameLen = 0;
cborFindResult = cbor_value_dup_text_string(&rsrcMap, &rsrcName, &rsrcNameLen, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Resource Data Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding Resource Data Name Tag.");
cborFindResult = cbor_value_advance(&rsrcMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Resource Data Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding Resource Data Value.");
// rlist
if (0 == strcmp(OIC_JSON_RLIST_NAME, rsrcName))
......@@ -263,13 +263,13 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
int i = 0;
// TODO : Need to assign array length to OicSecAmacl_t->resources->rlistLen based of RAML spec.
cborFindResult = cbor_value_get_array_length(&rsrcMap, &headAmacl->resourcesLen);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Rlist Array Len.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding Rlist Array Len.");
CborValue rsrcArray = { .parser = NULL };
// rlist array
cborFindResult = cbor_value_enter_container(&rsrcMap, &rsrcArray);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering Rlist Array");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Entering Rlist Array");
// TODO : Need to check data structure of OicSecAmacl_t based on RAML spec.
headAmacl->resources = (char **) OICCalloc(headAmacl->resourcesLen, sizeof(*headAmacl->resources));
......@@ -280,23 +280,23 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
// rMap
CborValue rMap = { .parser = NULL };
cborFindResult = cbor_value_enter_container(&rsrcArray, &rMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Entering Rlist Map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Entering Rlist Map");
while(cbor_value_is_valid(&rMap) && cbor_value_is_text_string(&rMap))
{
char *rMapName = NULL;
size_t rMapNameLen = 0;
cborFindResult = cbor_value_dup_text_string(&rMap, &rMapName, &rMapNameLen, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RMap Data Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding RMap Data Name Tag.");
cborFindResult = cbor_value_advance(&rMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RMap Data Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding RMap Data Value.");
// "href"
if (0 == strcmp(OIC_JSON_HREF_NAME, rMapName))
{
// TODO : Need to check data structure of OicSecAmacl_t based on RAML spec.
cborFindResult = cbor_value_dup_text_string(&rMap, &headAmacl->resources[i++], &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Href Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding Href Value.");
}
// "rt"
......@@ -305,7 +305,7 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
// TODO : Need to check data structure of OicSecAmacl_t and assign based on RAML spec.
char *rtData = NULL;
cborFindResult = cbor_value_dup_text_string(&rMap, &rtData, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RT Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding RT Value.");
OICFree(rtData);
}
......@@ -315,14 +315,14 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
// TODO : Need to check data structure of OicSecAmacl_t and assign based on RAML spec.
char *ifData = NULL;
cborFindResult = cbor_value_dup_text_string(&rMap, &ifData, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding IF Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding IF Value.");
OICFree(ifData);
}
if (cbor_value_is_valid(&rMap))
{
cborFindResult = cbor_value_advance(&rMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Rlist Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Advancing Rlist Map.");
}
OICFree(rMapName);
}
......@@ -330,7 +330,7 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
if (cbor_value_is_valid(&rsrcArray))
{
cborFindResult = cbor_value_advance(&rsrcArray);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Resource Array.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Advancing Resource Array.");
}
}
}
......@@ -338,7 +338,7 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
if (cbor_value_is_valid(&rsrcMap))
{
cborFindResult = cbor_value_advance(&rsrcMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Resource Map.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Advancing Resource Map.");
}
OICFree(rsrcName);
}
......
This diff is collapsed.
......@@ -138,10 +138,10 @@ static CborError setCrlData(CborEncoder *out, const char *name, const OicSecKey_
VERIFY_SUCCESS(TAG, (B64_OK == b64result), ERROR);
result = cbor_encode_text_string(out, name, strlen(name));
VERIFY_CBOR_SUCCESS(TAG, result, "Failed Adding name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, result, "Failed Adding name Tag.");
result = cbor_encode_text_string(out, (const char *)encodeBuffer, len);
VERIFY_CBOR_SUCCESS(TAG, result, "Failed Adding data Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, result, "Failed Adding data Tag.");
exit:
OICFree(encodeBuffer);
......@@ -167,7 +167,7 @@ static CborError getCrlData(CborValue *in, const char *name, OicSecKey_t *value)
{
result = cbor_value_dup_text_string(&crlNode,
(char **)&decodeBuffer, &decodeBufferSize, NULL);
VERIFY_CBOR_SUCCESS(TAG, result, "Failed Advancing Byte Array.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, result, "Failed Advancing Byte Array.");
value->len = B64DECODE_OUT_SAFESIZE(decodeBufferSize + 1);
value->data = OICCalloc(1, value->len);
......@@ -224,65 +224,65 @@ OCStackResult CrlToCBORPayload(const OicSecCrl_t *crl, uint8_t **payload, size_t
cbor_encoder_init(&encoder, outPayload, cborLen, 0);
cborEncoderResult = cbor_encoder_create_map(&encoder, &crlMap, mapSize);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to create CRL Map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to create CRL Map");
//CRLId -- Mandatory
cborEncoderResult = cbor_encode_text_string(&crlMap, OC_RSRVD_CRL_ID,
strlen(OC_RSRVD_CRL_ID));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add CRL ID");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add CRL ID");
cborEncoderResult = cbor_encode_int(&crlMap, crl->CrlId);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add CRL Id value");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add CRL Id value");
//ThisUpdate -- Mandatory
cborEncoderResult = cbor_encode_text_string(&crlMap, OC_RSRVD_THIS_UPDATE,
strlen(OC_RSRVD_THIS_UPDATE));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add Crl update");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add Crl update");
cborEncoderResult = cbor_encode_text_string(&crlMap, (const char *)crl->ThisUpdate.data,
crl->ThisUpdate.len);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add Crl Update value");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add Crl Update value");
//CRLData -- Mandatory
cborEncoderResult = setCrlData(&crlMap, OC_RSRVD_CRL, &crl->CrlData);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add CRLData object");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add CRLData object");
//lastUpdate - internal field
if (lastUpdate)
{
cborEncoderResult = cbor_encode_text_string(&crlMap, OC_RSRVD_LAST_UPDATE,
strlen(OC_RSRVD_LAST_UPDATE));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add last Update tag");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add last Update tag");
cborEncoderResult = cbor_encode_text_string(&crlMap, lastUpdate, strlen(lastUpdate));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add last Update value");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add last Update value");
}
//RT -- Mandatory
CborEncoder rtArray;
cborEncoderResult = cbor_encode_text_string(&crlMap, OIC_JSON_RT_NAME,
strlen(OIC_JSON_RT_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RT Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding RT Name Tag.");
cborEncoderResult = cbor_encoder_create_array(&crlMap, &rtArray, 1);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding RT Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding RT Value.");
cborEncoderResult = cbor_encode_text_string(&rtArray, OIC_RSRC_TYPE_SEC_CRL,
strlen(OIC_RSRC_TYPE_SEC_CRL));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding RT Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding RT Value.");
cborEncoderResult = cbor_encoder_close_container(&crlMap, &rtArray);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing RT.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Closing RT.");
//IF-- Mandatory
CborEncoder ifArray;
cborEncoderResult = cbor_encode_text_string(&crlMap, OIC_JSON_IF_NAME,
strlen(OIC_JSON_IF_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding IF Name Tag.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding IF Name Tag.");
cborEncoderResult = cbor_encoder_create_array(&crlMap, &ifArray, 1);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding IF Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Addding IF Value.");
cborEncoderResult = cbor_encode_text_string(&ifArray, OC_RSRVD_INTERFACE_DEFAULT,
strlen(OC_RSRVD_INTERFACE_DEFAULT));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding IF Value.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding IF Value.");
cborEncoderResult = cbor_encoder_close_container(&crlMap, &ifArray);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing IF.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Closing IF.");
cborEncoderResult = cbor_encoder_close_container(&encoder, &crlMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to add close Crl map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed to add close Crl map");
*size = cbor_encoder_get_buffer_size(&encoder, outPayload);
*payload = outPayload;
......@@ -336,7 +336,7 @@ OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
cbor_parser_init(cborPayload, size, 0, &parser, &crlCbor);
CborValue crlMap = { .parser = NULL};
cborFindResult = cbor_value_enter_container(&crlCbor, &crlMap);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to enter Crl map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed to enter Crl map");
crl = (OicSecCrl_t *)OICCalloc(1, sizeof(OicSecCrl_t));
VERIFY_NOT_NULL(TAG, crl, ERROR);
......@@ -347,7 +347,7 @@ OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
int CrlId;
cborFindResult = cbor_value_get_int(&crlMap, &CrlId);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CrlId.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Finding CrlId.");
crl->CrlId = (uint16_t)CrlId;
}
......@@ -356,11 +356,11 @@ OCStackResult CBORPayloadToCrl(const uint8_t *cborPayload, const size_t size,
{
cborFindResult = cbor_value_dup_text_string(&crlMap,
(char **)&crl->ThisUpdate.data, &crl->ThisUpdate.len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Byte Array.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed Advancing Byte Array.");
}
cborFindResult = getCrlData(&crlCbor, OC_RSRVD_CRL, &crl->CrlData);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to read CRL.");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborFindResult, "Failed to read CRL.");
OIC_LOG_CRL(INFO, crl);
......
......@@ -150,57 +150,57 @@ static OCStackResult CSRToCBORPayload(const uint8_t *csr, size_t csrLen, OicEnco
// Create CSR Root Map (csr)
cborEncoderResult = cbor_encoder_create_map(&encoder, &csrRootMap, CSR_MAP_SIZE);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding CSR Root Map");
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding CSR Root Map");
// Create CSR string entry
cborEncoderResult = cbor_encode_text_string(&csrRootMap, OIC_JSON_CSR_NAME, strlen(OIC_JSON_CSR_NAME));
VERIFY_CBOR_SUCCESS(<