本文整理汇总了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;
//.........这里部分代码省略.........