当前位置: 首页>>代码示例>>C++>>正文


C++ CallbackInfo::dataRecordCallbackFunction方法代码示例

本文整理汇总了C++中CallbackInfo::dataRecordCallbackFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ CallbackInfo::dataRecordCallbackFunction方法的具体用法?C++ CallbackInfo::dataRecordCallbackFunction怎么用?C++ CallbackInfo::dataRecordCallbackFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CallbackInfo的用法示例。


在下文中一共展示了CallbackInfo::dataRecordCallbackFunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processDataSet

/**
 * Processes an IPFIX data set.
 * Called by processMessage
 */
static void processDataSet(IpfixReceiver* ipfixReceiver, SourceID sourceId, IpfixSetHeader* set) {
	BufferedTemplate* bt = getBufferedTemplate(ipfixReceiver->templateBuffer, sourceId, ntohs(set->id));

	if(bt == 0) {
                /* this error may come in rapid succession; I hope I don't regret it */
		msg(MSG_INFO, "Template %d unknown to collecting process", ntohs(set->id));
		return;
	}
	
	#ifdef SUPPORT_NETFLOWV9
	if ((bt->setID == IPFIX_SetId_Template) || (bt->setID == NetflowV9_SetId_Template)) {
	#else
	if (bt->setID == IPFIX_SetId_Template) {
	#endif

		TemplateInfo* ti = bt->templateInfo;

		uint16_t length = ntohs(set->length)-((byte*)(&set->data)-(byte*)set);

		byte* record = &set->data;
	
		if (bt->recordLength < 65535) {
			byte* recordX = record+length;

			if (record >= recordX - (bt->recordLength - 1)) {
				DPRINTF("Got a Data Set that contained not a single full record\n");
			}

			/* We stop processing when no full record is left */
			while (record < recordX - (bt->recordLength - 1)) {
				int n;		
				for (n = 0; n < ipfixReceiver->callbackCount; n++) {
					CallbackInfo* ci = &ipfixReceiver->callbackInfo[n];
					if (ci->dataRecordCallbackFunction) ci->dataRecordCallbackFunction(ci->handle, sourceId, ti, bt->recordLength, record);
					}
				record = record + bt->recordLength;
				}
			} else {
			byte* recordX = record+length;

			if (record >= recordX - 3) {
				DPRINTF("Got a Data Set that contained not a single full record");
			}

			/* We assume that all variable-length records are >= 4 byte, so we stop processing when only 3 bytes are left */
			while (record < recordX - 3) {
				int recordLength=0;
				int i;
				for (i = 0; i < ti->fieldCount; i++) {
					int fieldLength = 0;
					if (ti->fieldInfo[i].type.length < 65535) {
						fieldLength = ti->fieldInfo[i].type.length;
						} else {
						if (*(byte*)record < 255) {
							fieldLength = *(byte*)record;
							} else {
							fieldLength = *(uint16_t*)(record+1);
							}
						}
					ti->fieldInfo[i].type.length = fieldLength;
					ti->fieldInfo[i].offset = recordLength;
					recordLength += fieldLength;
					}
				int n;		
				for (n = 0; n < ipfixReceiver->callbackCount; n++) {
					CallbackInfo* ci = &ipfixReceiver->callbackInfo[n];
					if (ci->dataRecordCallbackFunction) ci->dataRecordCallbackFunction(ci->handle, sourceId, ti, recordLength, record);
					}
				record = record + recordLength;
				}
			}
		} else 
	if (bt->setID == IPFIX_SetId_OptionsTemplate) {
  	
		OptionsTemplateInfo* ti = bt->optionsTemplateInfo;

		uint16_t length = ntohs(set->length)-((byte*)(&set->data)-(byte*)set);
		byte* record = &set->data;
	
		if (bt->recordLength < 65535) {
			byte* recordX = record+length;
			while (record < recordX) {
				int n;		
				for (n = 0; n < ipfixReceiver->callbackCount; n++) {
					CallbackInfo* ci = &ipfixReceiver->callbackInfo[n];
					if (ci->optionsRecordCallbackFunction) ci->optionsRecordCallbackFunction(ci->handle, sourceId, ti, bt->recordLength, record);
					}
				record = record + bt->recordLength;
				}
			} else {
			byte* recordX = record+length;
			while (record < recordX) {
				int recordLength=0;
				int i;
				for (i = 0; i < ti->scopeCount; i++) {
					int fieldLength = 0;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:101,代码来源:rcvIpfix.c


注:本文中的CallbackInfo::dataRecordCallbackFunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。