CCNxInterestReturnInterface * ccnxInterestReturnInterface_GetInterface(const CCNxTlvDictionary *dictionary) { assertTrue(ccnxTlvDictionary_IsInterestReturn(dictionary), "Expected an InterestReturn"); CCNxInterestReturnInterface *impl = ccnxTlvDictionary_GetMessageInterface(dictionary); if (!impl) { // If we're here, we need to update the interface pointer. Break the const. // We're not changing data values, just initializing the Interface pointer. // Figure out what the typeInterface should be, based on the attributes we know. int schemaVersion = ccnxTlvDictionary_GetSchemaVersion(dictionary); switch (schemaVersion) { case CCNxTlvDictionary_SchemaVersion_V0: trapUnexpectedState("ccnxInterestReturnInterface_GetInterface() not implemented for V0"); case CCNxTlvDictionary_SchemaVersion_V1: impl = &CCNxInterestReturnFacadeV1_Implementation; break; default: trapUnexpectedState("Unknown SchemaVersion encountered in ccnxInterestReturnInterface_GetInterface()"); break; } if (impl) { ccnxTlvDictionary_SetMessageInterface((CCNxTlvDictionary *) dictionary, impl); // break the const. } } return impl; }
static void _assertInvariants(const CCNxTlvDictionary *interestDictionary) { assertNotNull(interestDictionary, "Dictionary is null"); assertTrue((ccnxTlvDictionary_IsInterest(interestDictionary) || ccnxTlvDictionary_IsInterestReturn(interestDictionary)), "Dictionary is not an interest"); assertTrue(ccnxTlvDictionary_GetSchemaVersion(interestDictionary) == CCNxTlvDictionary_SchemaVersion_V1, "Dictionary is wrong schema Interest, got %d expected %d", ccnxTlvDictionary_GetSchemaVersion(interestDictionary), CCNxTlvDictionary_SchemaVersion_V1); }