LONGBOW_TEST_CASE(Dictionary, component_Codec_Tlv_Upcall_Read_Control) { TestData *data = longBowTestCase_GetClipBoardData(testCase); PARCBuffer *wireFormat = parcBuffer_Wrap(v1_cpi_add_route_crc32c, sizeof(v1_cpi_add_route_crc32c), 0, sizeof(v1_cpi_add_route_crc32c)); CCNxTlvDictionary *dictionary = ccnxWireFormatMessage_FromControlPacketType(CCNxTlvDictionary_SchemaVersion_V1, wireFormat); parcBuffer_Release(&wireFormat); // We have not set the message type or schema TransportMessage *tm = transportMessage_CreateFromDictionary(dictionary); transportMessage_SetInfo(tm, data->mock->connection, NULL); ccnxTlvDictionary_Release(&dictionary); // ------ // Now do the actual test of sending the transport message up the stack TransportMessage *test_tm = sendUp(data, tm); // It should now be parsed into an control message CCNxTlvDictionary *testdict = transportMessage_GetDictionary(test_tm); assertNotNull(testdict, "Failed to get dictionary from the transport message"); assertTrue(ccnxTlvDictionary_IsControl(testdict), "Dictionary says it is not a Control"); assertTrue(ccnxTlvDictionary_GetSchemaVersion(testdict) == CCNxTlvDictionary_SchemaVersion_V1, "Wrong schema, got %d expected %d", ccnxTlvDictionary_GetSchemaVersion(testdict), CCNxTlvDictionary_SchemaVersion_V1); transportMessage_Destroy(&tm); }
void ccnxControlFacade_AssertValid(const CCNxTlvDictionary *controlDictionary) { assertNotNull(controlDictionary, "Parameter must be a non-null CCNxControlFacade pointer"); assertTrue(ccnxTlvDictionary_IsValueJson(controlDictionary, CCNxCodecSchemaV1TlvDictionary_MessageFastArray_PAYLOAD), "Does not have JSON payload"); assertTrue(ccnxTlvDictionary_IsControl(controlDictionary), "Does not have type set"); }
LONGBOW_TEST_CASE(Global, ccnxWireFormatMessage_FromControlPacketType) { PARCBuffer *buffer = parcBuffer_Allocate(10); CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromControlPacketType(CCNxTlvDictionary_SchemaVersion_V1, buffer); assertTrue(ccnxTlvDictionary_IsControl((CCNxTlvDictionary *) message), "Wrong message type"); ccnxWireFormatMessage_Release(&message); parcBuffer_Release(&buffer); }
bool ccnxControlFacade_IsCPI(const CCNxTlvDictionary *controlDictionary) { bool result = false; ccnxControlFacade_AssertValid(controlDictionary); result = ccnxTlvDictionary_IsControl(controlDictionary); PARCJSON *controlJSON = ccnxTlvDictionary_GetJson(controlDictionary, CCNxCodecSchemaV1TlvDictionary_MessageFastArray_PAYLOAD); if (controlJSON != NULL) { if (parcJSON_GetValueByName(controlJSON, _NotificationIndicator) != NULL) { // this is a notification result = false; } } return result; }