CCNxControl * cpi_CreateResponse(CCNxControl *request, PARCJSON *operation) { PARCJSON *requestJson = ccnxControl_GetJson(request); // use the same key as the request uint64_t seqnum = controlPlaneInterface_GetSequenceNumber(requestJson); PARCJSONValue *value = parcJSON_GetValueByName(requestJson, cpiRequest); assertNotNull(value, "Could not get request or response"); assertTrue(parcJSONValue_IsJSON(value), "cpiRequest should be a JSON object"); PARCJSON *operationJson = parcJSONValue_GetJSON(value); PARCJSONPair *pair = parcJSON_GetPairByIndex(operationJson, 1); const PARCBuffer *opKeyBuf = parcJSONPair_GetName(pair); const char *opKey = parcBuffer_ToString(opKeyBuf); PARCJSON *response = parcJSON_Create(); parcJSON_AddInteger(response, cpiSeqnum, (int) seqnum); parcJSON_AddObject(response, opKey, operation); parcMemory_Deallocate(&opKey); PARCJSON *responseJson = parcJSON_Create(); parcJSON_AddObject(responseJson, cpiResponse, response); parcJSON_Release(&response); CCNxControl *result = ccnxControl_CreateCPIRequest(responseJson); parcJSON_Release(&responseJson); return result; }
PARCJSON * ccnxManifestHashGroup_ToJson(const CCNxManifestHashGroup *group) { PARCJSON *root = parcJSON_Create(); PARCJSONArray *ptrList = parcJSONArray_Create(); for (size_t i = 0; i < parcLinkedList_Size(group->pointers); i++) { CCNxManifestHashGroupPointer *ptr = (CCNxManifestHashGroupPointer *) parcLinkedList_GetAtIndex(group->pointers, i); PARCJSON *ptrJson = parcJSON_Create(); // Type. parcJSON_AddInteger(ptrJson, "type", ccnxManifestHashGroupPointer_GetType(ptr)); // Digest. char *digestString = parcBuffer_ToHexString(ptr->digest); parcJSON_AddString(ptrJson, "digest", digestString); parcMemory_Deallocate(&digestString); // Add the tuple to the list. PARCJSONValue *val = parcJSONValue_CreateFromJSON(ptrJson); parcJSONArray_AddValue(ptrList, val); // Cleanup parcJSONValue_Release(&val); parcJSON_Release(&ptrJson); } root = parcJSON_AddArray(root, "HashGroup", ptrList); parcJSONArray_Release(&ptrList); if (group->overallDataDigest != NULL) { char *digestString = parcBuffer_ToHexString(group->overallDataDigest); root = parcJSON_AddString(root, "overallDataDigest", digestString); parcMemory_Deallocate((void **) &digestString); } if (group->locator != NULL) { char *locatorString = ccnxName_ToString(group->locator); root = parcJSON_AddString(root, "locator", locatorString); parcMemory_Deallocate((void **) &locatorString); } if (group->entrySize > 0) { root = parcJSON_AddInteger(root, "entrySize", group->entrySize); } if (group->dataSize > 0) { root = parcJSON_AddInteger(root, "dataSize", group->dataSize); } if (group->blockSize > 0) { root = parcJSON_AddInteger(root, "blockSize", group->blockSize); } if (group->treeHeight > 0) { root = parcJSON_AddInteger(root, "treeHeight", group->treeHeight); } return root; }
/** * Given the inner operation member, wrap it in a Request with a sequence number * * Example: * @code * <#example#> * @endcode */ PARCJSON * cpi_CreateRequest(const char *key, PARCJSON *operation) { PARCJSON *result = parcJSON_Create(); PARCJSON *request = parcJSON_Create(); uint64_t seqnum = cpi_GetNextSequenceNumber(); parcJSON_AddInteger(request, cpiSeqnum, (int) seqnum); parcJSON_AddObject(request, key, operation); parcJSON_AddObject(result, cpiRequest, request); parcJSON_Release(&request); return result; }
PARCJSON * ccnxManifest_ToJSON(const CCNxManifest *manifest) { PARCJSON *root = parcJSON_Create(); char *nameString = ccnxName_ToString(ccnxManifest_GetName(manifest)); parcJSON_AddString(root, "locator", nameString); parcMemory_Deallocate(&nameString); PARCJSONArray *array = parcJSONArray_Create(); for (size_t i = 0; i < ccnxManifest_GetNumberOfHashGroups(manifest); i++) { CCNxManifestHashGroup *group = ccnxManifest_GetHashGroupByIndex(manifest, i); PARCJSON *groupJson = ccnxManifestHashGroup_ToJson(group); PARCJSONValue *jsonValue = parcJSONValue_CreateFromJSON(groupJson); parcJSONArray_AddValue(array, jsonValue); parcJSONValue_Release(&jsonValue); parcJSON_Release(&groupJson); ccnxManifestHashGroup_Release(&group); } parcJSON_AddArray(root, "HashGroups", array); parcJSONArray_Release(&array); return root; }
PARCJSON * parcBasicStats_ToJSON(const PARCBasicStats *stats) { PARCJSON *result = parcJSON_Create(); if (result != NULL) { PARCJSONPair *pair = parcJSONPair_CreateFromDouble("maximum", stats->maximum); parcJSON_AddPair(result, pair); parcJSONPair_Release(&pair); pair = parcJSONPair_CreateFromDouble("minimum", stats->minimum); parcJSON_AddPair(result, pair); parcJSONPair_Release(&pair); pair = parcJSONPair_CreateFromDouble("mean", stats->mean); parcJSON_AddPair(result, pair); parcJSONPair_Release(&pair); pair = parcJSONPair_CreateFromDouble("variance", stats->variance); parcJSON_AddPair(result, pair); parcJSONPair_Release(&pair); pair = parcJSONPair_CreateFromInteger("count", stats->count); parcJSON_AddPair(result, pair); parcJSONPair_Release(&pair); } return result; }
PARCJSON * parcHashMap_ToJSON(const PARCHashMap *hashMap) { parcHashMap_OptionalAssertValid(hashMap); PARCJSON *result = parcJSON_Create(); PARCIterator *iterator = parcHashMap_CreateKeyIterator((PARCHashMap *) hashMap); while (parcIterator_HasNext(iterator)) { PARCObject *keyObject = parcIterator_Next(iterator); const PARCObject *valueObject = parcHashMap_Get(hashMap, keyObject); char *key = parcObject_ToString(keyObject); PARCJSON *value = parcObject_ToJSON(valueObject); parcJSON_AddObject(result, key, value); parcMemory_Deallocate(&key); parcJSON_Release(&value); } parcIterator_Release(&iterator); return result; }
LONGBOW_TEST_CASE(JSON, parcJSON_CreateRelease) { PARCJSON *json = parcJSON_Create(); parcJSON_Release(&json); assertNull(json, "Expected the NULL pointer side-effect of Release."); }
PARCJSONValue * parcJSONValue_ObjectParser(PARCJSONParser *parser) { PARCJSONValue *result = NULL; // absorb the (required) '{' character. if (parcJSONParser_NextChar(parser) == '{') { PARCJSON *json = parcJSON_Create(); while (parcJSONParser_Remaining(parser)) { char c = parcJSONParser_PeekNextChar(parser); if (c == '}') { // Absorb the '}' and terminate. parcJSONParser_NextChar(parser); result = parcJSONValue_CreateFromJSON(json); break; } else if (c == ',') { // absorb the ',' character and continue parcJSONParser_NextChar(parser); } else if (c == '"') { PARCJSONPair *pair = parcJSONPair_Parser(parser); if (pair == NULL) { break; } parcJSON_AddPair(json, pair); parcJSONPair_Release(&pair); } else { break; } } parcJSON_Release(&json); } return result; }
PARCJSON * parcSortedList_ToJSON(const PARCSortedList *instance) { PARCJSON *result = parcJSON_Create(); return result; }
LONGBOW_TEST_CASE(JSON, parcJSON_AddValue) { PARCJSON *json = parcJSON_Create(); char *expectedName = "value"; PARCJSONValue *value = parcJSONValue_CreateFromCString("Some Pig"); parcJSON_AddValue(json, expectedName, value); const PARCJSONPair *pair = parcJSON_GetPairByName(json, expectedName); PARCBuffer *actualName = parcJSONPair_GetName(pair); PARCJSONValue *actualValue = parcJSONPair_GetValue(pair); assertTrue(strcmp(expectedName, parcBuffer_Overlay(actualName, 0)) == 0, "Expected name %s, actual %s", expectedName, (char *) parcBuffer_ToString(actualName)); assertTrue(parcJSONValue_IsString(actualValue), "Expect value to be type PARCJSONArray"); assertTrue(parcBuffer_Equals(parcJSONValue_GetString(actualValue), parcJSONValue_GetString(value)), "Expected %s actual %s", parcJSONValue_ToString(value), parcJSONValue_ToString(actualValue)); parcJSONValue_Release(&value); parcJSON_Release(&json); }
PARCJSON * cpi_CreatePauseInputRequest(void) { PARCJSON *operation = parcJSON_Create(); PARCJSON *result = cpi_CreateRequest(cpiPause, operation); parcJSON_Release(&operation); return result; }
PARCJSON * metisConfiguration_GetVersion(MetisConfiguration *config) { PARCJSON *fwd = parcJSON_Create(); parcJSON_AddString(fwd, "NAME", metisAbout_Name()); parcJSON_AddString(fwd, "COPYRIGHT", metisAbout_MiniNotice()); parcJSON_AddString(fwd, "VERSION", metisAbout_Version()); return fwd; }
PARCJSON * cpi_CreateFlushRequest(void) { PARCJSON *operation = parcJSON_Create(); PARCJSON *result = cpi_CreateRequest(cpiFlush, operation); parcJSON_Release(&operation); return result; }
PARCJSON * parcScheduledTask_ToJSON(const PARCScheduledTask *instance) { PARCJSON *result = parcJSON_Create(); if (result != NULL) { } return result; }
PARCJSON * parcStopwatch_ToJSON(const PARCStopwatch *instance) { PARCJSON *result = parcJSON_Create(); if (result != NULL) { PARCJSON *start = parcJSON_Create(); parcJSON_AddInteger(start, "seconds", instance->start.tv_sec); parcJSON_AddInteger(start, "microseconds", instance->start.tv_usec); PARCJSON *stop = parcJSON_Create(); parcJSON_AddInteger(stop, "seconds", instance->stop.tv_sec); parcJSON_AddInteger(stop, "microseconds", instance->stop.tv_usec); parcJSON_AddObject(result, "start", start); parcJSON_AddObject(result, "stop", stop); parcJSON_Release(&start); parcJSON_Release(&stop); } return result; }
PARCJSONValue * parcJSONValue_CreateFromTimespec(const struct timespec *timespec) { PARCJSON *jsonTimespec = parcJSON_Create(); parcJSON_AddInteger(jsonTimespec, "seconds", timespec->tv_sec); parcJSON_AddInteger(jsonTimespec, "nanos", timespec->tv_nsec); PARCJSONValue *result = _createValue(PARCJSONValueType_JSON); if (result != NULL) { result->value.object = jsonTimespec; } return result; }
PARCJSONValue * parcJSONValue_CreateFromTimeval(const struct timeval *timeval) { PARCJSON *jsonTimeval = parcJSON_Create(); parcJSON_AddInteger(jsonTimeval, "seconds", timeval->tv_sec); parcJSON_AddInteger(jsonTimeval, "micros", timeval->tv_usec); PARCJSONValue *result = _createValue(PARCJSONValueType_JSON); if (result != NULL) { result->value.object = jsonTimeval; } return result; }
CCNxControl *ccnxControlFacade_CreateNotification(PARCJSON *payload) { assertNotNull(payload, "Parameter ccnx_json must be non-null"); CCNxTlvDictionary *dictionary = ccnxCodecSchemaV1TlvDictionary_CreateControl(); // Create a new JSON object that indicates that this is a notification. Wrap it around // the supplied JSON object. PARCJSON *notificationWrapper = parcJSON_Create(); parcJSON_AddBoolean(notificationWrapper, _NotificationIndicator, true); parcJSON_AddObject(notificationWrapper, _NotificationPayload, payload); ccnxTlvDictionary_PutJson(dictionary, CCNxCodecSchemaV1TlvDictionary_MessageFastArray_PAYLOAD, notificationWrapper); parcJSON_Release(¬ificationWrapper); return dictionary; }
PARCJSON * ccnxPortalAnchor_ToJSON(const CCNxPortalAnchor *anchor) { ccnxPortalAnchor_OptionalAssertValid(anchor); PARCJSON *result = parcJSON_Create(); if (result != NULL) { char *prefix = ccnxName_ToString(anchor->prefix); parcJSON_AddString(result, "namePrefix", prefix); parcJSON_AddInteger(result, "expireTime", (int64_t) anchor->expireTime); parcMemory_Deallocate(&prefix); } return result; }
/** * Create a PARCBuffer payload containing a JSON string with information about this ContentStore's * size. */ static PARCBuffer * _createStatSizeResponsePayload(const AthenaLRUContentStore *impl, const CCNxName *name, uint64_t chunkNumber) { PARCJSON *json = parcJSON_Create(); parcJSON_AddString(json, "moduleName", AthenaContentStore_LRUImplementation.description); parcJSON_AddInteger(json, "time", parcClock_GetTime(impl->wallClock)); parcJSON_AddInteger(json, "numEntries", impl->numEntries); parcJSON_AddInteger(json, "sizeInBytes", impl->currentSizeInBytes); char *jsonString = parcJSON_ToString(json); parcJSON_Release(&json); PARCBuffer *result = parcBuffer_CreateFromArray(jsonString, strlen(jsonString)); parcMemory_Deallocate(&jsonString); return parcBuffer_Flip(result); }
CCNxConnectionConfig * publicKeySignerPkcs12Store_ConnectionConfig(CCNxConnectionConfig *connConfig, const char *filename, const char *password) { assertNotNull(connConfig, "Parameter connConfig must be non-null"); assertNotNull(filename, "Parameter filename must be non-null"); assertNotNull(password, "Parameter password must be non-null"); PARCJSONValue *signerNameJson = parcJSONValue_CreateFromCString((char *) publicKeySignerPkcs12Store_GetName()); ccnxConnectionConfig_Add(connConfig, param_SIGNER, signerNameJson); parcJSONValue_Release(&signerNameJson); PARCJSON *keystoreJson = parcJSON_Create(); parcJSON_AddString(keystoreJson, param_KEYSTORE_NAME, filename); parcJSON_AddString(keystoreJson, param_KEYSTORE_PASSWD, password); PARCJSONValue *value = parcJSONValue_CreateFromJSON(keystoreJson); parcJSON_Release(&keystoreJson); CCNxConnectionConfig *result = ccnxConnectionConfig_Add(connConfig, publicKeySignerPkcs12Store_GetName(), value); parcJSONValue_Release(&value); return result; }
static CCNxMetaMessage * _create_stats_response(Athena *athena, CCNxName *ccnxName) { PARCJSON *json = parcJSON_Create(); struct timeval tv; gettimeofday(&tv, NULL); uint64_t nowInMillis = (tv.tv_sec * 1000) + (tv.tv_usec / 1000); parcJSON_AddString(json, "moduleName", athenaAbout_Name()); parcJSON_AddInteger(json, "time", nowInMillis); parcJSON_AddInteger(json, "numProcessedInterests", athena->stats.numProcessedInterests); parcJSON_AddInteger(json, "numProcessedContentObjects", athena->stats.numProcessedContentObjects); parcJSON_AddInteger(json, "numProcessedControlMessages", athena->stats.numProcessedControlMessages); parcJSON_AddInteger(json, "numProcessedInterestReturns", athena->stats.numProcessedInterestReturns); char *jsonString = parcJSON_ToString(json); parcJSON_Release(&json); PARCBuffer *payload = parcBuffer_CreateFromArray(jsonString, strlen(jsonString)); parcMemory_Deallocate(&jsonString); CCNxContentObject *contentObject = ccnxContentObject_CreateWithNameAndPayload(ccnxName, parcBuffer_Flip(payload)); ccnxContentObject_SetExpiryTime(contentObject, nowInMillis + 100); // this response is good for 100 millis CCNxMetaMessage *result = ccnxMetaMessage_CreateFromContentObject(contentObject); ccnxContentObject_Release(&contentObject); parcBuffer_Release(&payload); return result; }
LONGBOW_TEST_CASE(JSON, parcJSON_AddBoolean) { PARCJSON *json = parcJSON_Create(); char *expectedName = "boolean"; bool expectedValue = true; parcJSON_AddBoolean(json, expectedName, expectedValue); const PARCJSONPair *pair = parcJSON_GetPairByName(json, expectedName); PARCBuffer *actualName = parcJSONPair_GetName(pair); PARCJSONValue *actualValue = parcJSONPair_GetValue(pair); assertTrue(strcmp(expectedName, parcBuffer_Overlay(actualName, 0)) == 0, "Expected name %s, actual %s", expectedName, (char *) parcBuffer_ToString(actualName)); assertTrue(expectedValue == parcJSONValue_GetBoolean(actualValue), "Expected %d actual %d", expectedValue, parcJSONValue_GetBoolean(actualValue)); parcJSON_Release(&json); }
LONGBOW_TEST_CASE(JSON, parcJSON_AddInteger) { PARCJSON *json = parcJSON_Create(); char *expectedName = "integer"; uint64_t expectedValue = 12345; parcJSON_AddInteger(json, expectedName, expectedValue); const PARCJSONPair *pair = parcJSON_GetPairByName(json, expectedName); PARCBuffer *actualName = parcJSONPair_GetName(pair); PARCJSONValue *actualValue = parcJSONPair_GetValue(pair); assertTrue(strcmp(expectedName, parcBuffer_Overlay(actualName, 0)) == 0, "Expected name %s, actual %s", expectedName, (char *) parcBuffer_ToString(actualName)); assertTrue(expectedValue == parcJSONValue_GetInteger(actualValue), "Expected %" PRIi64 "d actual %" PRIi64 "d", expectedValue, parcJSONValue_GetInteger(actualValue)); parcJSON_Release(&json); }
LONGBOW_TEST_CASE(JSON, parcJSON_AddObject) { PARCJSON *json = parcJSON_Create(); PARCJSON *expectedValue = parcJSON_ParseString("{ \"string\" : \"xyzzy\" }"); parcJSON_AddObject(json, "object", expectedValue); char *expectedName = "object"; const PARCJSONPair *pair = parcJSON_GetPairByName(json, expectedName); PARCBuffer *actualName = parcJSONPair_GetName(pair); PARCJSONValue *actualValue = parcJSONPair_GetValue(pair); assertTrue(strcmp(expectedName, parcBuffer_Overlay(actualName, 0)) == 0, "Expected name %s, actual %s", expectedName, (char *) parcBuffer_ToString(actualName)); assertTrue(parcJSON_Equals(expectedValue, parcJSONValue_GetJSON(actualValue)), "Expected value did not match the actual value."); parcJSON_Release(&expectedValue); parcJSON_Release(&json); }
PARCJSON * cpiConnectionList_ToJson(const CPIConnectionList *list) { assertNotNull(list, "Parameter must be non-null"); PARCJSONArray *inner_json = parcJSONArray_Create(); size_t length = parcArrayList_Size(list->listOfConnections); for (size_t i = 0; i < length; i++) { CPIConnection *tunnel = (CPIConnection *) parcArrayList_Get(list->listOfConnections, i); PARCJSON *json = cpiConnection_ToJson(tunnel); PARCJSONValue *value = parcJSONValue_CreateFromJSON(json); parcJSON_Release(&json); parcJSONArray_AddValue(inner_json, value); parcJSONValue_Release(&value); } PARCJSON *outter_json = parcJSON_Create(); parcJSON_AddArray(outter_json, cpi_ConnectionList, inner_json); parcJSONArray_Release(&inner_json); return outter_json; }
PARCJSON * cpiInterfaceSet_ToJson(CPIInterfaceSet *set) { assertNotNull(set, "Parameter must be non-null"); PARCJSONArray *interfaceList = parcJSONArray_Create(); size_t length = parcArrayList_Size(set->listOfInterfaces); for (size_t i = 0; i < length; i++) { CPIInterface *iface = (CPIInterface *) parcArrayList_Get(set->listOfInterfaces, i); PARCJSON *json = cpiInterface_ToJson(iface); PARCJSONValue *value = parcJSONValue_CreateFromJSON(json); parcJSON_Release(&json); parcJSONArray_AddValue(interfaceList, value); parcJSONValue_Release(&value); } PARCJSON *result = parcJSON_Create(); parcJSON_AddArray(result, cpi_InterfaceList, interfaceList); parcJSONArray_Release(&interfaceList); return result; }
LONGBOW_TEST_CASE(JSON, parcJSON_AddString) { PARCJSON *json = parcJSON_Create(); char *expectedName = "string"; char *expectedValue = "value"; parcJSON_AddString(json, expectedName, expectedValue); const PARCJSONPair *pair = parcJSON_GetPairByName(json, "string"); PARCBuffer *actualName = parcJSONPair_GetName(pair); PARCJSONValue *actualValue = parcJSONPair_GetValue(pair); assertTrue(strcmp(expectedName, parcBuffer_Overlay(actualName, 0)) == 0, "Expected name %s, actual %s", expectedName, parcBuffer_ToString(actualName)); assertTrue(strcmp(expectedValue, parcBuffer_Overlay(parcJSONValue_GetString(actualValue), 0)) == 0, "Expected value %s, actual %s", expectedValue, parcJSONValue_ToString(actualValue)); parcJSON_Release(&json); }
LONGBOW_TEST_CASE(JSON, parcJSON_Add) { PARCJSON *json = parcJSON_Create(); { PARCBuffer *string = parcBuffer_WrapCString("string"); PARCJSONValue *stringValue = parcJSONValue_CreateFromString(string); PARCBuffer *stringName = parcBuffer_WrapCString("string"); PARCJSONPair *pair = parcJSONPair_Create(stringName, stringValue); parcJSON_AddPair(json, pair); parcJSONPair_Release(&pair); parcBuffer_Release(&stringName); parcJSONValue_Release(&stringValue); parcBuffer_Release(&string); } { PARCBuffer *name = parcBuffer_WrapCString("null"); PARCJSONValue *value = parcJSONValue_CreateFromNULL(); PARCJSONPair *pair = parcJSONPair_Create(name, value); parcJSON_AddPair(json, pair); parcJSONPair_Release(&pair); parcBuffer_Release(&name); parcJSONValue_Release(&value); } { PARCBuffer *name = parcBuffer_WrapCString("true"); PARCJSONValue *value = parcJSONValue_CreateFromBoolean(true); PARCJSONPair *pair = parcJSONPair_Create(name, value); parcJSON_AddPair(json, pair); parcJSONPair_Release(&pair); parcBuffer_Release(&name); parcJSONValue_Release(&value); } { PARCBuffer *name = parcBuffer_WrapCString("false"); PARCJSONValue *value = parcJSONValue_CreateFromBoolean(false); PARCJSONPair *pair = parcJSONPair_Create(name, value); parcJSON_AddPair(json, pair); parcJSONPair_Release(&pair); parcBuffer_Release(&name); parcJSONValue_Release(&value); } { PARCBuffer *name = parcBuffer_WrapCString("integer"); PARCJSONValue *value = parcJSONValue_CreateFromInteger(31415); PARCJSONPair *pair = parcJSONPair_Create(name, value); parcJSON_AddPair(json, pair); parcJSONPair_Release(&pair); parcBuffer_Release(&name); parcJSONValue_Release(&value); } { PARCBuffer *name = parcBuffer_WrapCString("float"); PARCJSONValue *value = parcJSONValue_CreateFromFloat(3.1415); PARCJSONPair *pair = parcJSONPair_Create(name, value); parcJSON_AddPair(json, pair); parcJSONPair_Release(&pair); parcBuffer_Release(&name); parcJSONValue_Release(&value); } parcJSON_Release(&json); }
static CCNxMetaMessage * _create_FIBList_response(Athena *athena, CCNxName *ccnxName, PARCList *fibEntryList) { PARCJSON *jsonPayload = parcJSON_Create(); PARCJSONArray *jsonEntryList = parcJSONArray_Create(); parcJSON_AddArray(jsonPayload, JSON_KEY_RESULT, jsonEntryList); for (size_t i = 0; i < parcList_Size(fibEntryList); ++i) { AthenaFIBListEntry *entry = parcList_GetAtIndex(fibEntryList, i); if (entry != NULL) { CCNxName *prefixName = athenaFIBListEntry_GetName(entry); if (prefixName) { char *prefix = ccnxName_ToString(prefixName); int linkId = athenaFIBListEntry_GetLinkId(entry); const char *linkName = athenaTransportLinkAdapter_LinkIdToName(athena->athenaTransportLinkAdapter, linkId); parcLog_Debug(athena->log, " Route: %s->%s", prefix, linkName); PARCJSON *jsonItem = parcJSON_Create(); parcJSON_AddString(jsonItem, JSON_KEY_NAME, prefix); parcJSON_AddString(jsonItem, JSON_KEY_LINK, linkName); PARCJSONValue *jsonItemValue = parcJSONValue_CreateFromJSON(jsonItem); parcJSON_Release(&jsonItem); parcJSONArray_AddValue(jsonEntryList, jsonItemValue); parcJSONValue_Release(&jsonItemValue); parcMemory_Deallocate(&prefix); } else { int linkId = athenaFIBListEntry_GetLinkId(entry); const char *linkName = athenaTransportLinkAdapter_LinkIdToName(athena->athenaTransportLinkAdapter, linkId); parcLog_Debug(athena->log, " Route: <empty>->%s", linkName); PARCJSON *jsonItem = parcJSON_Create(); parcJSON_AddString(jsonItem, JSON_KEY_NAME, ""); parcJSON_AddString(jsonItem, JSON_KEY_LINK, linkName); PARCJSONValue *jsonItemValue = parcJSONValue_CreateFromJSON(jsonItem); parcJSON_Release(&jsonItem); parcJSONArray_AddValue(jsonEntryList, jsonItemValue); parcJSONValue_Release(&jsonItemValue); } } } char *jsonString = parcJSON_ToString(jsonPayload); parcJSONArray_Release(&jsonEntryList); parcJSON_Release(&jsonPayload); PARCBuffer *payload = parcBuffer_CreateFromArray(jsonString, strlen(jsonString)); CCNxContentObject *contentObject = ccnxContentObject_CreateWithNameAndPayload(ccnxName, parcBuffer_Flip(payload)); struct timeval tv; gettimeofday(&tv, NULL); uint64_t nowInMillis = (tv.tv_sec * 1000) + (tv.tv_usec / 1000); ccnxContentObject_SetExpiryTime(contentObject, nowInMillis + 100); // this response is good for 100 millis CCNxMetaMessage *result = ccnxMetaMessage_CreateFromContentObject(contentObject); ccnxContentObject_Release(&contentObject); parcBuffer_Release(&payload); parcMemory_Deallocate(&jsonString); athena_EncodeMessage(result); return result; }