Commit a4d7b9eb authored by Ricardo Martínez's avatar Ricardo Martínez
Browse files

Extending the name lengths of deviceIds and linkIds forming the context

Adding friendly traces for debugging purposes in the process of parsing the context JSON
parent 8c493794
Loading
Loading
Loading
Loading
+23 −17
Original line number Diff line number Diff line
@@ -908,7 +908,8 @@ void parse_json_device_endpoints_array(cJSON* endPointsArray, struct device_t* d
 */
 /////////////////////////////////////////////////////////////////////////////////////////
void parsing_json_deviceList_array(cJSON* deviceArray) {

	DEBUG_PC("");
	DEBUG_PC("========= PARSING DEVICE LIST ============");
	for (gint i = 0; i < cJSON_GetArraySize(deviceArray); i++) {
		deviceList->numDevices++;
		struct device_t* d = &(deviceList->devices[i]);
@@ -918,7 +919,7 @@ void parsing_json_deviceList_array(cJSON* deviceArray) {
		cJSON* deviceUuidObj = cJSON_GetObjectItem(item, "device_Id");
		if (cJSON_IsString(deviceUuidObj)) {
			duplicate_string(d->deviceId, deviceUuidObj->valuestring);
			//DEBUG_PC("Device (%d) -- Id: %s (uuid string format)", i + 1, d->deviceId);
			DEBUG_PC("Device (%d) -- Id: %s (uuid string format)", i + 1, d->deviceId);
		}

		// Get the device Type
@@ -927,12 +928,11 @@ void parsing_json_deviceList_array(cJSON* deviceArray) {
			duplicate_string(d->deviceType, deviceTypeObj->valuestring);
			//DEBUG_PC("  Device Type: %s ---", d->deviceType);
		}
		//DEBUG_PC("DeviceId: %s, Device Type: %s", d->deviceId, d->deviceType);
		DEBUG_PC("DeviceId: %s, Device Type: %s", d->deviceId, d->deviceType);

		// get the device endPoints
		cJSON* deviceEndpointsArray = cJSON_GetObjectItem(item, "device_endpoints");
		if (cJSON_IsArray(deviceEndpointsArray))
		{
		if (cJSON_IsArray(deviceEndpointsArray)) {
			parse_json_device_endpoints_array(deviceEndpointsArray, d);
		}
	}
@@ -954,6 +954,7 @@ void parsing_json_deviceList_array(cJSON* deviceArray) {
void parse_json_link_endpoints_array(cJSON *endPointsLinkObj, struct link_t* l) {

	for (gint i = 0; i < cJSON_GetArraySize(endPointsLinkObj); i++) {
		//DEBUG_PC("link: %s has %d endPointIds", l->linkId, l->numLinkEndPointIds);
		l->numLinkEndPointIds++;
		struct link_endpointId_t* endPointLink = &(l->linkEndPointId[i]);

@@ -982,7 +983,7 @@ void parse_json_link_endpoints_array(cJSON *endPointsLinkObj, struct link_t* l)
			cJSON* deviceIdObj = cJSON_GetObjectItem(endPointIdObj, "device_id");
			if (cJSON_IsString(deviceIdObj)) {
				duplicate_string(endPointLink->deviceId, deviceIdObj->valuestring);
				//DEBUG_PC("Link Endpoint (%d) -- Device Id: %s (uuid)", i + 1, endPointLink->deviceId);
				DEBUG_PC("   Link Endpoint[%d] -- DeviceId: %s", i + 1, endPointLink->deviceId);
			}
			// Get the endpoint_uuid
			cJSON* endPointUuidObj = cJSON_GetObjectItem(endPointIdObj, "endpoint_uuid");
@@ -992,6 +993,7 @@ void parse_json_link_endpoints_array(cJSON *endPointsLinkObj, struct link_t* l)
			}
		}
	}
	//DEBUG_PC("link id: %s has %d endpoints", l->linkId, l->numLinkEndPointIds);
	return;
}

@@ -1008,21 +1010,24 @@ void parse_json_link_endpoints_array(cJSON *endPointsLinkObj, struct link_t* l)
 /////////////////////////////////////////////////////////////////////////////////////////
void parsing_json_linkList_array(cJSON* linkListArray) {

	DEBUG_PC("");
	DEBUG_PC("======= PARSING OF THE LINK LIST ARRAY ==========");
	for (gint i = 0; i < cJSON_GetArraySize(linkListArray); i++) {
		linkList->numLinks++;
		struct link_t* l = &(linkList->links[i]);
		//l->numLinkEndPointIds = 0;

		cJSON* item = cJSON_GetArrayItem(linkListArray, i);

		// Get the link Id (uuid)
		cJSON* linkIdObj = cJSON_GetObjectItem(item, "link_Id");
		if (cJSON_IsString(linkIdObj)) {
			duplicate_string(l->linkId, linkIdObj->valuestring);
			//DEBUG_PC("Link (%d) -- Id: %s (uuid)", i + 1, l->linkId);
			DEBUG_PC(" * Link (%d) -- Id: %s (uuid)", i + 1, l->linkId);
		}
		// Get the link endpoints (assumed to be p2p)
		cJSON* endPointsLinkObj = cJSON_GetObjectItem(item, "link_endpoint_ids");
		if (cJSON_IsArray(endPointsLinkObj)) {
			//DEBUG_PC("number linkEndPointIds: %d", l->numLinkEndPointIds);
			parse_json_link_endpoints_array(endPointsLinkObj, l);
		}
		// get the fowarding direction
@@ -1096,8 +1101,8 @@ void parsing_json_linkList_array(cJSON* linkListArray) {
 */
 ////////////////////////////////////////////////////////////////////////////////////////
void generate_reverse_linkList() {

	DEBUG_PC("Starting the Creation of the Reverse Links [current: %d]", linkList->numLinks);
	DEBUG_PC("");
	DEBUG_PC("CREATION OF REVERSE LINKS");
	gint numLinks = linkList->numLinks;
	
	for (gint i = 0; i < numLinks; i++) {
@@ -1112,16 +1117,17 @@ void generate_reverse_linkList() {

		// Assumption: p2p links. The newLink endpoints are the reversed ones form the reference Link (refLink)
		// i.e., refLink A->B, then newLink B->A
#if 0
		//DEBUG_PC("ref: %s has %d endpoints", refLink->linkId, refLink->numLinkEndPointIds);
#if 1
		if (refLink->numLinkEndPointIds != 2) {
			DEBUG_PC("To construct the new Link from ref, 2 EndPoints are a MUST");
			DEBUG_PC("To construct the new Link from ref: %s, 2 EndPoints are a MUST", refLink->linkId);
			exit(-1);
		}
#endif
		DEBUG_PC(" * Link[%d] -- Id: %s", numLinks + i, newLink->linkId);

		//DEBUG_PC("Number of Endpoints in Link: %d", refLink->numLinkEndPointIds);
		for (gint j = refLink->numLinkEndPointIds - 1, m = 0; j >= 0; j--, m++) {			
			
			
			struct link_endpointId_t* refEndPId = &(refLink->linkEndPointId[j]);
			struct link_endpointId_t* newEndPId = &(newLink->linkEndPointId[m]);
			// Duplicate the topologyId information, i.e., contextId and topology_uuid
@@ -1130,7 +1136,7 @@ void generate_reverse_linkList() {
			//duplicate the deviceId and endPoint_uuid
			duplicate_string(newEndPId->deviceId, refEndPId->deviceId);
			duplicate_string(newEndPId->endPointId, refEndPId->endPointId);
			//DEBUG_PC("refLink Endpoint[%d]: %s(%s)", j, refEndPId->deviceId, refEndPId->endPointId);
			DEBUG_PC("refLink Endpoint[%d]: %s(%s)", j, refEndPId->deviceId, refEndPId->endPointId);
			//DEBUG_PC("newLink Endpoint[%d]: %s(%s)", m, newEndPId->deviceId, newEndPId->endPointId);
			newLink->numLinkEndPointIds++;
		}
+2 −1
Original line number Diff line number Diff line
@@ -1704,6 +1704,7 @@ struct linkList_t* create_link_list() {
		DEBUG_PC("Memory Allocation Failure");
		exit(-1);
	}
	lList->numLinks = 0;
	return lList;
}

@@ -1916,7 +1917,7 @@ void print_link_forwarding_direction(guint linkFwDir) {
			DEBUG_PC("BIDIRECTIONAL LINK FORWARDING DIRECTION");
			break;
		case LINK_FORWARDING_DIRECTION_UNIDIRECTIONAL:
			//DEBUG_PC("UNIDIRECTIONAL LINK FORWARDING DIRECTION");
			DEBUG_PC("UNIDIRECTIONAL LINK FORWARDING DIRECTION");
			break;
		case  LINK_FORWARDING_DIRECTION_UNKNOWN:
			DEBUG_PC("UNKNOWN LINK FORWARDING DIRECTION");
+3 −2
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ extern struct serviceList_t* serviceList;

#define MAX_NODE_ID_SIZE				37 // UUID 128 Bits - In hexadecimal requires 36 char
#define MAX_CONTEXT_ID					37
#define UUID_CHAR_LENGTH				37
//#define UUID_CHAR_LENGTH				37
#define UUID_CHAR_LENGTH				100
struct nodes_t {
	gchar nodeId[UUID_CHAR_LENGTH];
};
@@ -308,7 +309,7 @@ struct latency_characteristics_t {
struct link_t {
	gchar linkId[UUID_CHAR_LENGTH]; // link Id using UUID (128 bits)

	guint numLinkEndPointIds;
	gint numLinkEndPointIds;
	struct link_endpointId_t linkEndPointId[MAX_NUM_LINK_ENDPOINT_IDS];

	guint forwarding_direction;