LONGBOW_TEST_CASE(Global, ccnxInterest_GetKeyIdRestriction) { CCNxName *name = ccnxName_CreateFromURI("lci:/name"); PARCBuffer *key = parcBuffer_Allocate(8); parcBuffer_PutUint64(key, 1234L); CCNxInterest *interest = ccnxInterest_Create(name, 3000, key, NULL); PARCBuffer *actual = ccnxInterest_GetKeyIdRestriction(interest); actual = ccnxInterest_GetKeyIdRestriction(interest); assertTrue(actual == key, "Expected retrieved key to be the same as assigned"); ccnxName_Release(&name); ccnxInterest_Release(&interest); parcBuffer_Release(&key); }
static CCNxContentObject * //_athenaLRUContentStore_GetMatch(AthenaContentStoreImplementation *store, const CCNxName *name, const PARCBuffer *keyIdRestriction, // const PARCBuffer *contentObjectHash) _athenaLRUContentStore_GetMatch(AthenaContentStoreImplementation *store, const CCNxInterest *interest) { CCNxContentObject *result = NULL; AthenaLRUContentStore *impl = (AthenaLRUContentStore *) store; _AthenaLRUContentStoreEntry *entry = NULL; CCNxName *name = ccnxInterest_GetName(interest); PARCBuffer *contentObjectHashRestriction = ccnxInterest_GetContentObjectHashRestriction(interest); PARCBuffer *keyIdRestriction = ccnxInterest_GetKeyIdRestriction(interest); if (contentObjectHashRestriction != NULL) { PARCObject *nameAndHashKey = _createHashableKey(name, NULL, contentObjectHashRestriction); entry = (_AthenaLRUContentStoreEntry *) parcHashMap_Get(impl->tableByNameAndObjectHash, nameAndHashKey); parcObject_Release((PARCObject **) &nameAndHashKey); } if ((entry == NULL) && (keyIdRestriction != NULL)) { PARCObject *nameAndKeyIdKey = _createHashableKey(name, keyIdRestriction, NULL); entry = (_AthenaLRUContentStoreEntry *) parcHashMap_Get(impl->tableByNameAndKeyId, nameAndKeyIdKey); parcObject_Release((PARCObject **) &nameAndKeyIdKey); } if (entry == NULL) { PARCObject *nameKey = _createHashableKey(name, NULL, NULL); entry = (_AthenaLRUContentStoreEntry *) parcHashMap_Get(impl->tableByName, nameKey); parcObject_Release((PARCObject **) &nameKey); } // Matching is done. Now check for validity, if necessary. if (entry != NULL) { // We found matching content. Now make sure it's not expired before returning it. If it is expired, // remove it from the store and don't return anything. if (entry->hasExpiryTime && (entry->expiryTime < parcClock_GetTime(impl->wallClock))) { _athenaLRUContentStore_PurgeContentStoreEntry(impl, entry); entry = NULL; } // XXX: TODO: Check that the KeyId, if any, was verified. } // At this point, the cached content is considered valid for responding with. Return it. if (entry != NULL) { result = entry->contentObject; // Update LRU so that the matched entry is at the top of the list. _moveContentStoreEntryToLRUHead(impl, entry); impl->stats.numMatchHits++; } else { impl->stats.numMatchMisses++; } return result; }