本文整理汇总了C++中ccnxName_Release函数的典型用法代码示例。如果您正苦于以下问题:C++ ccnxName_Release函数的具体用法?C++ ccnxName_Release怎么用?C++ ccnxName_Release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ccnxName_Release函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Global, getMatchByName)
{
AthenaLRUContentStoreConfig config;
config.capacityInMB = 10;
AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config);
char *lci = "lci:/cakes/and/pies";
PARCClock *clock = parcClock_Wallclock();
CCNxName *truthName = ccnxName_CreateFromURI(lci);
CCNxContentObject *truthObject = ccnxContentObject_CreateWithDataPayload(truthName, NULL);
ccnxContentObject_SetExpiryTime(truthObject, parcClock_GetTime(clock) + 100);
ccnxName_Release(&truthName);
athenaContentStore_PutContentObject(store, truthObject);
CCNxName *testName = ccnxName_CreateFromURI(lci);
CCNxInterest *interest = ccnxInterest_CreateSimple(testName);
ccnxName_Release(&testName);
//athena_EncodeMessage(interest);
CCNxContentObject *testObject = athenaContentStore_GetMatch(store, interest);
ccnxInterest_Release(&interest);
// TODO: match on other than name!
assertTrue(ccnxContentObject_Equals(truthObject, testObject), "Expected to get the same ContentObject back");
assertTrue(truthObject == testObject, "Expected the same pointer back");
athenaContentStore_Release(&store);
ccnxContentObject_Release(&truthObject);
parcClock_Release(&clock);
}
开发者ID:kevnfx,项目名称:Athena,代码行数:34,代码来源:test_athena_ContentStore.c
示例2: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Global, ccnxContentObject_Equals)
{
CCNxName *nameA = ccnxName_CreateFromCString("lci:/foo/bar/A");
PARCBuffer *payloadA = parcBuffer_Allocate(100);
CCNxContentObject *objectA = ccnxContentObject_CreateWithDataPayload(nameA, payloadA);
ccnxContentObject_AssertValid(objectA);
assertTrue(ccnxContentObject_Equals(objectA, objectA), "Expected same instance to be equal");
CCNxContentObject *objectA2 = ccnxContentObject_CreateWithDataPayload(nameA, payloadA);
ccnxContentObject_AssertValid(objectA2);
assertTrue(ccnxContentObject_Equals(objectA, objectA2), "Expected ContentObject with same payload and name to be equal");
CCNxName *nameB = ccnxName_CreateFromCString("lci:/foo/bar/B");
CCNxContentObject *objectB = ccnxContentObject_CreateWithDataPayload(nameB, payloadA);
ccnxContentObject_AssertValid(objectB);
assertFalse(ccnxContentObject_Equals(objectA, objectB), "Expected ContentObject with same payload and different name");
ccnxName_Release(&nameA);
ccnxName_Release(&nameB);
parcBuffer_Release(&payloadA);
ccnxContentObject_Release(&objectA);
ccnxContentObject_Release(&objectA2);
ccnxContentObject_Release(&objectB);
}
开发者ID:GlennCScott,项目名称:Libccnx-common,代码行数:29,代码来源:test_ccnx_ContentObject.c
示例3: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Local, putWithExpiryTime)
{
AthenaLRUContentStore *impl = _createLRUContentStore();
CCNxName *name1 = ccnxName_CreateFromURI("lci:/first/entry");
CCNxContentObject *contentObject1 = ccnxContentObject_CreateWithDataPayload(name1, NULL);
CCNxName *name2 = ccnxName_CreateFromURI("lci:/second/entry");
CCNxContentObject *contentObject2 = ccnxContentObject_CreateWithDataPayload(name2, NULL);
CCNxName *name3 = ccnxName_CreateFromURI("lci:/third/entry");
CCNxContentObject *contentObject3 = ccnxContentObject_CreateWithDataPayload(name3, NULL);
uint64_t now = parcClock_GetTime(impl->wallClock);
ccnxContentObject_SetExpiryTime(contentObject1, now + 200); // Expires AFTER object 2
ccnxContentObject_SetExpiryTime(contentObject2, now + 100);
// contentObject3 has no expiry time, so it expires last.
_AthenaLRUContentStoreEntry *entry1 = _athenaLRUContentStoreEntry_Create(contentObject1);
_AthenaLRUContentStoreEntry *entry2 = _athenaLRUContentStoreEntry_Create(contentObject2);
_AthenaLRUContentStoreEntry *entry3 = _athenaLRUContentStoreEntry_Create(contentObject3);
bool status = _athenaLRUContentStore_PutContentObject(impl, contentObject1);
assertTrue(status, "Exepected to insert content");
status = _athenaLRUContentStore_PutContentObject(impl, contentObject2);
assertTrue(status, "Exepected to insert content");
_AthenaLRUContentStoreEntry *oldestEntry = _getEarliestExpiryTime(impl);
assertTrue(oldestEntry->contentObject == entry2->contentObject, "Expected entry 2 to be the earliest expiring entry");
status = _athenaLRUContentStore_PutContentObject(impl, contentObject3);
assertTrue(status, "Exepected to insert content");
// The entry with no expiration time should not affect list ordering.
oldestEntry = _getEarliestExpiryTime(impl);
assertTrue(oldestEntry->contentObject == entry2->contentObject, "Expected entry 2 to be the earliest expiring entry");
// Now remove the oldest one we added. The next oldest one should be contentObject1
_athenaLRUContentStore_RemoveMatch(impl, name2, NULL, NULL);
// The entry with no expiration time should not affect list ordering.
oldestEntry = _getEarliestExpiryTime(impl);
assertTrue(oldestEntry->contentObject == entry1->contentObject, "Expected entry 1 to be the earliest expiring entry");
_athenaLRUContentStoreEntry_Release(&entry1);
_athenaLRUContentStoreEntry_Release(&entry2);
_athenaLRUContentStoreEntry_Release(&entry3);
ccnxContentObject_Release(&contentObject1);
ccnxContentObject_Release(&contentObject2);
ccnxContentObject_Release(&contentObject3);
ccnxName_Release(&name1);
ccnxName_Release(&name2);
ccnxName_Release(&name3);
_athenaLRUContentStore_Release((AthenaContentStoreImplementation *) &impl);
}
开发者ID:chris-wood,项目名称:ghost,代码行数:60,代码来源:test_athena_LRUContentStore.c
示例4: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Global, ccnxInterest_Equals)
{
CCNxName *nameA = ccnxName_CreateFromURI("lci:/name");
PARCBuffer *keyA = parcBuffer_Allocate(8);
parcBuffer_PutUint64(keyA, 1234L);
CCNxInterest *interestA = ccnxInterest_Create(nameA,
1000, /* lifetime */
keyA, /* KeyId */
NULL /* ContentObjectHash */
);
CCNxName *nameB = ccnxName_CreateFromURI("lci:/name");
PARCBuffer *keyB = parcBuffer_Allocate(8);
parcBuffer_PutUint64(keyB, 1234L);
CCNxInterest *interestB = ccnxInterest_Create(nameB,
1000, /* lifetime */
keyB, /* KeyId */
NULL /* ContentObjectHash */
);
assertTrue(ccnxInterest_Equals(interestA, interestB), "Expected equivalent interests to be equal.");
ccnxName_Release(&nameA);
ccnxName_Release(&nameB);
parcBuffer_Release(&keyA);
parcBuffer_Release(&keyB);
ccnxInterest_Release(&interestA);
ccnxInterest_Release(&interestB);
}
开发者ID:mword,项目名称:Libccnx-common,代码行数:30,代码来源:test_ccnx_Interest.c
示例5: reader_writer
int
reader_writer(CCNxPortalFactory *factory, const char *uri)
{
CCNxPortal *portal = ccnxPortalFactory_GetInstance(factory, ccnxPortalTypeDatagram, ccnxPortalProtocol_TLV, &ccnxPortalAttributes_Blocking);
CCNxName *prefix = ccnxName_CreateFromURI(uri);
CCNxName *bye = ccnxName_CreateFromURI("lci:/Hello/Goodbye%21");
CCNxName *contentname = ccnxName_CreateFromURI("lci:/Hello/World");
if (ccnxPortal_Listen(portal, prefix, 365 * 86400, CCNxStackTimeout_Never)) {
CCNxMetaMessage *msg;
while ((msg = ccnxPortal_Receive(portal, CCNxStackTimeout_Never)) != NULL) {
if (ccnxMetaMessage_IsInterest(msg)) {
CCNxInterest *interest = ccnxMetaMessage_GetInterest(msg);
CCNxName *interestName = ccnxInterest_GetName(interest);
if (ccnxName_Equals(interestName, contentname)) {
const PARCKeyId *publisherKeyId = ccnxPortal_GetKeyId(portal);
char buffer[128];
time_t theTime = time(0);
sprintf(buffer, "Hello World. The time is %s", ctime(&theTime));
PARCBuffer *payload = parcBuffer_CreateFromArray(buffer, 128);
parcBuffer_Flip(payload);
PARCBuffer *b = parcBuffer_Acquire(payload);
CCNxContentObject *uob = ccnxContentObject_CreateWithDataPayload(contentname, b);
// missing NULL check, case 1024
CCNxMetaMessage *message = ccnxMetaMessage_CreateFromContentObject(uob);
if (ccnxPortal_Send(portal, message, CCNxTransportStackTimeCCNxStackTimeout_Neverout_Never) == false) {
fprintf(stderr, "ccnx_write failed\n");
}
// ccnxMessage_Release(message);
} else if (ccnxName_Equals(interestName, bye)) {
break;
}
} else {
ccnxMetaMessage_Display(msg, 0);
}
ccnxMetaMessage_Release(&msg);
}
}
ccnxName_Release(&prefix);
ccnxName_Release(&bye);
ccnxName_Release(&contentname);
ccnxPortal_Release(&portal);
return 0;
}
开发者ID:isolis,项目名称:Libccnx-portal,代码行数:58,代码来源:ccnx-portal-read.c
示例6: testValidationSetV1_KeyId_KeyLocator_KeyId_Key
void
testValidationSetV1_KeyId_KeyLocator_KeyId_Key(TestData *data,
bool (*set)(CCNxTlvDictionary *message, const PARCBuffer *keyid,
const CCNxKeyLocator *keyLocator),
bool (*test)(const CCNxTlvDictionary *message))
{
CCNxName *name = ccnxName_CreateFromURI("lci:/parc/validation/test");
CCNxTlvDictionary *packetV1 = ccnxContentObject_CreateWithImplAndPayload(&CCNxContentObjectFacadeV1_Implementation,
name,
CCNxPayloadType_DATA,
NULL);
bool success = set(packetV1, data->keyid, data->locatorByKey);
assertTrue(success, "Failed to set on V1");
bool testResult = test(packetV1);
assertTrue(testResult, "Test function failed on V1 packet");
PARCBuffer *testKeyId = ccnxValidationFacadeV1_GetKeyId(packetV1);
assertTrue(parcBuffer_Equals(testKeyId, data->keyid), "keyid not equal");
PARCBuffer *testKey = ccnxValidationFacadeV1_GetPublicKey(packetV1);
assertTrue(parcBuffer_Equals(testKey, data->key), "keys not equal");
ccnxName_Release(&name);
ccnxTlvDictionary_Release(&packetV1);
}
开发者ID:mword,项目名称:Libccnx-common,代码行数:26,代码来源:testrig_validation.c
示例7: _athenactl_Run
static int
_athenactl_Run(PARCIdentity *identity, int argc, char **argv)
{
if (argc < 1) {
printf("usage: spawn <port | link specification>\n");
return 1;
}
char *linkSpecification = argv[0];
char constructedLinkSpecification[MAXPATHLEN] = { 0 };
// Short-cut, user can specify just a port and we will construct a default tcp listener specification
if (atoi(argv[0]) != 0) {
sprintf(constructedLinkSpecification, "tcp://localhost:%d/listener", atoi(argv[0]));
linkSpecification = constructedLinkSpecification;
}
CCNxName *name = ccnxName_CreateFromURI(CCNxNameAthenaCommand_Run);
CCNxInterest *interest = ccnxInterest_CreateSimple(name);
ccnxName_Release(&name);
PARCBuffer *payload = parcBuffer_AllocateCString(linkSpecification);
ccnxInterest_SetPayload(interest, payload);
parcBuffer_Release(&payload);
const char *result = _athenactl_SendInterestControl(identity, interest);
if (result) {
printf("%s\n", result);
parcMemory_Deallocate(&result);
}
ccnxMetaMessage_Release(&interest);
return 0;
}
开发者ID:chris-wood,项目名称:ghost,代码行数:35,代码来源:athenactl.c
示例8: _athenactl_RemoveRoute
static int
_athenactl_RemoveRoute(PARCIdentity *identity, int argc, char **argv)
{
if (argc < 2) {
printf("usage: remove route <linkName> <prefix>\n");
return 1;
}
CCNxName *name = ccnxName_CreateFromURI(CCNxNameAthenaCommand_FIBRemoveRoute);
CCNxInterest *interest = ccnxInterest_CreateSimple(name);
ccnxName_Release(&name);
char *linkName = argv[0];
char *prefix = argv[1];
// passed in as <linkName> <prefix>, passed on as <prefix> <linkname>
char routeArguments[MAXPATHLEN];
sprintf(routeArguments, "%s %s", prefix, linkName);
PARCBuffer *payload = parcBuffer_AllocateCString(routeArguments);
ccnxInterest_SetPayload(interest, payload);
parcBuffer_Release(&payload);
const char *result = _athenactl_SendInterestControl(identity, interest);
if (result) {
printf("FIB: %s\n", result);
parcMemory_Deallocate(&result);
}
ccnxMetaMessage_Release(&interest);
return 0;
}
开发者ID:chris-wood,项目名称:ghost,代码行数:32,代码来源:athenactl.c
示例9: _athenactl_RemoveLink
static int
_athenactl_RemoveLink(PARCIdentity *identity, int argc, char **argv)
{
if (argc < 1) {
printf("usage: remove link <linkName>\n");
return 1;
}
CCNxName *name = ccnxName_CreateFromURI(CCNxNameAthenaCommand_LinkDisconnect);
CCNxInterest *interest = ccnxInterest_CreateSimple(name);
ccnxName_Release(&name);
PARCBuffer *payload = parcBuffer_AllocateCString(argv[0]);
ccnxInterest_SetPayload(interest, payload);
parcBuffer_Release(&payload);
const char *result = _athenactl_SendInterestControl(identity, interest);
if (result) {
printf("Link: %s\n", result);
parcMemory_Deallocate(&result);
}
ccnxMetaMessage_Release(&interest);
return 0;
}
开发者ID:chris-wood,项目名称:ghost,代码行数:26,代码来源:athenactl.c
示例10: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Global, ccnxKeyLocator_GetType)
{
// Try FromKey
char *hexString = "ABCDEF1234";
PARCBuffer *keyBuffer = parcBuffer_WrapCString(hexString);
PARCKeyId *keyId = parcKeyId_Create(keyBuffer);
PARCKey *key = parcKey_CreateFromDerEncodedPublicKey(keyId, PARCSigningAlgorithm_RSA, keyBuffer);
CCNxKeyLocator *keyLocator = ccnxKeyLocator_CreateFromKey(key);
parcKeyId_Release(&keyId);
parcBuffer_Release(&keyBuffer);
ccnxKeyLocator_AssertValid(keyLocator);
assertTrue(ccnxKeyLocator_GetType(keyLocator) == CCNxKeyLocatorType_Key, "Actual certificate type didn't match expected type");
ccnxKeyLocator_Release(&keyLocator);
parcKey_Release(&key);
// Try KeyName
CCNxName *keyURIName = ccnxName_CreateFromCString("lci://name/test");
CCNxLink *keyLink = ccnxLink_Create(keyURIName, NULL, NULL);
keyLocator = ccnxKeyLocator_CreateFromKeyLink(keyLink);
ccnxKeyLocator_AssertValid(keyLocator);
assertTrue(ccnxKeyLocator_GetType(keyLocator) == CCNxKeyLocatorType_Link, "Actual certificate type didn't match expected type");
assertFalse(ccnxKeyLocator_GetType(keyLocator) == CCNxKeyLocatorType_Key, "Actual certificate type didn't match expected type");
ccnxKeyLocator_Release(&keyLocator);
ccnxName_Release(&keyURIName);
ccnxLink_Release(&keyLink);
}
开发者ID:PARC,项目名称:Libccnx-common,代码行数:31,代码来源:test_ccnx_KeyLocator.c
示例11: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Global, ccnxTlvCodecName_Encode)
{
uint8_t truthBytes[] = { 0x10, 0x20, 0x00, 0x0E, 0x00, CCNxNameLabelType_NAME, 0x00, 0x0A, 'b', 'r', 'a', 'n', 'd', 'y', 'w', 'i', 'n', 'e' };
PARCBuffer *truth = parcBuffer_Wrap(truthBytes, sizeof(truthBytes), 0, sizeof(truthBytes));
CCNxCodecTlvEncoder *encoder = ccnxCodecTlvEncoder_Create();
ccnxCodecTlvEncoder_Initialize(encoder);
PARCBuffer *buffer = parcBuffer_WrapCString("brandywine");
CCNxNameSegment *segment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_NAME, buffer);
CCNxName *name = ccnxName_Append(ccnxName_Create(), segment);
ccnxNameSegment_Release(&segment);
parcBuffer_Release(&buffer);
ccnxCodecSchemaV1NameCodec_Encode(encoder, 0x1020, name);
ccnxCodecTlvEncoder_Finalize(encoder);
PARCBuffer *test = ccnxCodecTlvEncoder_CreateBuffer(encoder);
if (!parcBuffer_Equals(truth, test)) {
printf("Buffers do not match\n");
printf("Excpected:\n");
parcBuffer_Display(truth, 3);
printf("Got:\n");
parcBuffer_Display(test, 3);
assertTrue(parcBuffer_Equals(truth, test), "Buffers do not match");
}
ccnxName_Release(&name);
parcBuffer_Release(&test);
ccnxCodecTlvEncoder_Destroy(&encoder);
parcBuffer_Release(&truth);
}
开发者ID:PARC,项目名称:Libccnx-common,代码行数:34,代码来源:test_ccnxCodecSchemaV1_NameCodec.c
示例12: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Global, ccnxPortal_Send_ImmediateTimeout_WouldBlock)
{
TestData *data = longBowTestCase_GetClipBoardData(testCase);
CCNxPortal *portalOut = ccnxPortalFactory_CreatePortal(data->factory, TEST_STACK);
CCNxName *name = ccnxName_CreateFromCString("lci:/Hello/World");
CCNxInterest *interest = ccnxInterest_CreateSimple(name);
ccnxName_Release(&name);
CCNxMetaMessage *interestMessage = ccnxMetaMessage_CreateFromInterest(interest);
for (int count = 0; count < 10000; count++) {
if (ccnxPortal_Send(portalOut, interestMessage, CCNxStackTimeout_Immediate) == false) {
break;
}
count++;
}
assertFalse(ccnxPortal_Send(portalOut, interestMessage, CCNxStackTimeout_Immediate),
"Expected send to fail due to blocking");
ccnxMetaMessage_Release(&interestMessage);
ccnxInterest_Release(&interest);
ccnxPortal_Release(&portalOut);
}
开发者ID:PARC,项目名称:Libccnx-portal,代码行数:26,代码来源:test_ccnx_Portal.c
示例13: testValidationSetV1_KeyId_KeyLocator_KeyId_KeyName
void
testValidationSetV1_KeyId_KeyLocator_KeyId_KeyName(TestData *data,
bool (*set)(CCNxTlvDictionary *message, const PARCBuffer *keyid,
const CCNxKeyLocator *keyLocator),
bool (*test)(const CCNxTlvDictionary *message))
{
CCNxName *name = ccnxName_CreateFromURI("lci:/parc/validation/test");
CCNxTlvDictionary *packetV1 = ccnxContentObject_CreateWithImplAndPayload(&CCNxContentObjectFacadeV1_Implementation,
name,
CCNxPayloadType_DATA,
NULL);
bool success = set(packetV1, data->keyid, data->locatorByName);
assertTrue(success, "Failed to set on V1");
bool testResult = test(packetV1);
assertTrue(testResult, "Test function failed on V1 packet");
PARCBuffer *testKeyId = ccnxValidationFacadeV1_GetKeyId(packetV1);
assertTrue(parcBuffer_Equals(testKeyId, data->keyid), "keyid not equal");
// XXX: TODO: GetKeyName() returns a Link, so it should be GetLink().
// It also creates a new object (the CCNxLink), so... needs thinking about.
// See BugzId: 3322
CCNxLink *testLink = ccnxValidationFacadeV1_GetKeyName(packetV1);
assertTrue(ccnxName_Equals(ccnxLink_GetName(testLink), data->keyname), "Keynames not equal");
ccnxLink_Release(&testLink);
ccnxName_Release(&name);
ccnxTlvDictionary_Release(&packetV1);
}
开发者ID:mword,项目名称:Libccnx-common,代码行数:31,代码来源:testrig_validation.c
示例14: LONGBOW_TEST_CASE
LONGBOW_TEST_CASE(Global, athenaTransportLinkAdapter_ListLinks)
{
PARCURI *connectionURI;
const char *result;
AthenaTransportLinkAdapter *athenaTransportLinkAdapter = athenaTransportLinkAdapter_Create(_removeLink, NULL);
assertNotNull(athenaTransportLinkAdapter, "athenaTransportLinkAdapter_Create returned NULL");
_LoadModule(athenaTransportLinkAdapter, "TCP");
connectionURI = parcURI_Parse("tcp://127.0.0.1:50200/listener/name=TCPListener");
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
parcURI_Release(&connectionURI);
connectionURI = parcURI_Parse("tcp://127.0.0.1:50200/name=TCP_0");
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
parcURI_Release(&connectionURI);
CCNxName *name = ccnxName_CreateFromCString(CCNxNameAthenaCommand_LinkList);
CCNxInterest *ccnxMessage = ccnxInterest_CreateSimple(name);
ccnxName_Release(&name);
CCNxContentObject *contentObject = athenaTransportLinkAdapter_ProcessMessage(athenaTransportLinkAdapter, ccnxMessage);
assertNotNull(contentObject, "athenaTransportLinkAdapter_ProcessMessage failed");
ccnxInterest_Release(&ccnxMessage);
ccnxContentObject_Release(&contentObject);
int closeResult = athenaTransportLinkAdapter_CloseByName(athenaTransportLinkAdapter, "TCP_0");
assertTrue(closeResult == 0, "athenaTransportLinkAdapter_CloseByName failed (%s)", strerror(errno));
athenaTransportLinkAdapter_Destroy(&athenaTransportLinkAdapter);
}
开发者ID:PARC,项目名称:Athena,代码行数:33,代码来源:test_athena_TransportLinkAdapter.c
示例15: _executeUserCommand
/**
* Given a command (e.g "fetch") and an optional target name (e.g. "file.txt"), create an appropriate CCNxInterest
* and write it to the Portal.
*
* @param command The command to be handled.
* @param targetName The name of the target content, if any, that the command applies to.
*
* @return true If a CCNxInterest for the specified command and optional target was successfully issued and answered.
*/
static bool
_executeUserCommand(const char *command, const char *targetName)
{
bool result = false;
CCNxPortalFactory *factory = _setupConsumerPortalFactory();
CCNxPortal *portal = ccnxPortalFactory_CreatePortal(factory, ccnxPortalRTA_Chunked);
assertNotNull(portal, "Expected a non-null CCNxPortal pointer.");
// Given the user's command and optional target, create an Interest.
CCNxInterest *interest = _createInterest(command, targetName);
// Send the Interest through the Portal, and wait for a response.
CCNxMetaMessage *message = ccnxMetaMessage_CreateFromInterest(interest);
if (ccnxPortal_Send(portal, message, CCNxStackTimeout_Never)) {
CCNxName *domainPrefix = ccnxName_CreateFromURI(tutorialCommon_DomainPrefix); // e.g. 'lci:/ccnx/tutorial'
result = _receiveResponseToIssuedInterest(portal, domainPrefix);
ccnxName_Release(&domainPrefix);
}
ccnxMetaMessage_Release(&message);
ccnxInterest_Release(&interest);
ccnxPortal_Release(&portal);
ccnxPortalFactory_Release(&factory);
return result;
}
开发者ID:isolis,项目名称:ccnx-tutorial,代码行数:39,代码来源:tutorial_Client.c
示例16: _createInterest
/**
* Create and return a CCNxInterest whose Name contains our commend (e.g. "fetch" or "list"),
* and, optionally, the name of a target object (e.g. "file.txt"). The newly created CCNxInterest
* must eventually be released by calling ccnxInterest_Release().
*
* @param command The command to embed in the created CCNxInterest.
* @param targetName The name of the content, if any, that the command applies to.
*
* @return A newly created CCNxInterest for the specified command and targetName.
*/
static CCNxInterest *
_createInterest(const char *command, const char *targetName)
{
CCNxName *interestName = ccnxName_CreateFromURI(tutorialCommon_DomainPrefix); // Start with the prefix. We append to this.
// Create a NameSegment for our command, which we will append after the prefix we just created.
PARCBuffer *commandBuffer = parcBuffer_WrapCString((char *) command);
CCNxNameSegment *commandSegment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_NAME, commandBuffer);
parcBuffer_Release(&commandBuffer);
// Append the new command segment to the prefix
ccnxName_Append(interestName, commandSegment);
ccnxNameSegment_Release(&commandSegment);
// If we have a target, then create another NameSegment for it and append that.
if (targetName != NULL) {
// Create a NameSegment for our target object
PARCBuffer *targetBuf = parcBuffer_WrapCString((char *) targetName);
CCNxNameSegment *targetSegment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_NAME, targetBuf);
parcBuffer_Release(&targetBuf);
// Append it to the ccnxName.
ccnxName_Append(interestName, targetSegment);
ccnxNameSegment_Release(&targetSegment);
}
CCNxInterest *result = ccnxInterest_CreateSimple(interestName);
ccnxName_Release(&interestName);
return result;
}
开发者ID:isolis,项目名称:ccnx-tutorial,代码行数:42,代码来源:tutorial_Client.c
注:本文中的ccnxName_Release函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论