/**
 * Prints a DataRecord
 * @param sourceID SourceID of the exporting process
 * @param dataTemplateInfo Pointer to a structure defining the DataTemplate used
 * @param length Length of the data block supplied
 * @param data Pointer to a data block containing all variable fields
 */
void IpfixPrinter::onDataRecord(IpfixDataRecord* record)
{
	int i;
	/* we need a FieldInfo for printIPv4 */
	IpfixRecord::FieldInfo::Type tmpInfo = {0, 4, false, 0}; // length=4 for IPv4 address
	boost::shared_ptr<IpfixRecord::DataTemplateInfo> dataTemplateInfo;

	switch (outputType) {
		case LINE:
			printf("ERROR: one line record not implemented for IpfixDataRecords\n");
			//printOneLineRecord(record);
			break;

		case TREE:
			dataTemplateInfo = record->templateInfo;
			printf("\n-+--- DataRecord (Template id=%u from ", dataTemplateInfo->templateId);
			if(record->sourceID->exporterAddress.len == 4)
				printIPv4(tmpInfo, &record->sourceID->exporterAddress.ip[0]);
			else
				printf("non-IPv4 address");
			printf(":%d (", record->sourceID->exporterPort);
			tmpInfo.length = 1; // length=1 for protocol identifier
			printProtocol(tmpInfo, &record->sourceID->protocol);
			printf(") )\n");

			printf(" `- fixed data\n");
			for (i = 0; i < dataTemplateInfo->dataCount; i++) {
				printf(" '   `- ");
				printFieldData(dataTemplateInfo->dataInfo[i].type,
						(dataTemplateInfo->data + dataTemplateInfo->dataInfo[i].offset));
				printf("\n");
			}
			printf(" `- variable data\n");
			for (i = 0; i < dataTemplateInfo->fieldCount; i++) {
				printf(" '   `- ");
				printFieldData(dataTemplateInfo->fieldInfo[i].type,
						(record->data + dataTemplateInfo->fieldInfo[i].offset));
				printf("\n");
			}
			printf(" `---\n\n");
			break;

		case TABLE:
			printTableRecord(record);
			break;

		case NONE:
			break;
	}

	record->removeReference();
}
Beispiel #2
0
/**
 * Prints a DataRecord
 * @param sourceID SourceID of the exporting process
 * @param dataTemplateInfo Pointer to a structure defining the DataTemplate used
 * @param length Length of the data block supplied
 * @param data Pointer to a data block containing all variable fields
 */
void IpfixPrinter::onDataRecord(IpfixDataRecord* record)
{
	switch (outputType) {
		case LINE:
			printOneLineRecord(record);
			break;
		case TREE:
			printTreeRecord(record);
			break;

		case TABLE:
			printTableRecord(record);
			break;
		case NONE:
			break;
	}

	record->removeReference();
}