Commit dca8d2e6 authored by Håvard Moås's avatar Håvard Moås
Browse files

Update IPFIXLIB to add support for flowEndReason IPFIX data element, havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@44 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 7226bc59
......@@ -760,6 +760,7 @@ void addPktToHash(np_ctxt_t *npctxt,
else
bkt->headerlengthIPv4 = 0;
bkt->flowEndReason = FLOW_END_IDLE;
bkt->proto = proto;
bkt->sport = sport, bkt->dport = dport;
......@@ -883,17 +884,31 @@ printFlow(np_ctxt_t *npctxt, HashBucket *theFlow, int direction)
/* ****************************************************** */
int isFlowExpired(np_ctxt_t *npctxt, HashBucket *myBucket, time_t theTime) {
if((theTime - (myBucket->lastSeenSent >> 32) >= npctxt->idleTimeout) /* flow expired: data not sent for a while */
|| (theTime - (myBucket->firstSeenSent >> 32) >= npctxt->lifetimeTimeout) /* flow expired: flow active but too old */
|| ((myBucket->pktRcvd > 0)
&& ((theTime - (myBucket->lastSeenRcvd >> 32) >= npctxt->idleTimeout) /* flow expired: data not sent for a while */
|| (theTime - (myBucket->firstSeenRcvd >> 32) >= npctxt->lifetimeTimeout))) /* flow expired: flow active but too old */
) {
return(1);
} else {
/* if(hashDebug) printBucket(myBucket); */
return(0);
if((theTime - (myBucket->lastSeenSent >> 32) >= npctxt->idleTimeout)) {
/* flow expired: data not sent for a while */
myBucket->flowEndReason = FLOW_END_IDLE;
return 1;
}
if(theTime - (myBucket->firstSeenSent >> 32) >= npctxt->lifetimeTimeout) {
/* flow expired: flow active but too old */
myBucket->flowEndReason = FLOW_END_ACTIVE;
return 1;
}
if(myBucket->pktRcvd > 0) {
if((theTime - (myBucket->lastSeenRcvd >> 32) >= npctxt->idleTimeout)) {
/* flow expired: data not sent for a while */
myBucket->flowEndReason = FLOW_END_IDLE;
return 1;
}
if((theTime - (myBucket->firstSeenRcvd >> 32) >= npctxt->lifetimeTimeout)) {
/* flow expired: flow active but too old */
myBucket->flowEndReason = FLOW_END_ACTIVE;
return 1;
}
}
return(0);
}
/* ****************************************************** */
......@@ -940,6 +955,9 @@ void walkHash(np_ctxt_t *npctxt, int flushHash) {
#endif
if(flushHash || isFlowExpired(npctxt, myBucket, now)) {
if(flushHash)
myBucket->flowEndReason = FLOW_END_FORCED;
#ifdef DEBUG_EXPORT_2
printf("Found flow to emit (expired)(idx=%d)\n",npctxt->walkIndex);
#endif
......
......@@ -55,6 +55,13 @@
// When changing this, also consider engine.c:updateBitrateCalculation.
#define BITRATE_AVERAGER_SLOTS 10
#define FLOW_END_IDLE 0x01 /* Flow exported due to idle */
#define FLOW_END_ACTIVE 0x02 /* Flow exported due to lifetime max */
#define FLOW_END_EOF 0x03 /* End of flow detected (FIN, ...) */
#define FLOW_END_FORCED 0x04 /* Forced end of flow */
#define FLOW_END_CACHEFULL 0x05 /* Cache was full */
#define nwLatencyComputed(a) (NPROBE_FD_ISSET(FLAG_NW_LATENCY_COMPUTED, &(a->flags)))
#define applLatencyComputed(a) (NPROBE_FD_ISSET(FLAG_APPL_LATENCY_COMPUTED, &(a->flags)))
#define fragmentedPacketSrc2Dst(a) (NPROBE_FD_ISSET(FLAG_FRAGMENTED_PACKET_SRC2DST, &(a->flags)))
......@@ -145,6 +152,8 @@ typedef struct hashBucket {
u_int32_t flowid; // ID of flow locally unique to _exporter_.
u_int8_t flowEndReason;
u_int64_t src2dstOctetDeltaCount;
u_int64_t dst2srcOctetDeltaCount;
//u_int64_t src2dstOctetTotalCount;
......
......@@ -743,6 +743,8 @@ static V9TemplateId ver9_templates[] = {
{153, 8, "FLOW_END_MILLISECONDS" },
{154, 8, "FLOW_START_MICROSECONDS" },
{155, 8, "FLOW_END_MICROSECONDS" },
{156, 8, "FLOW_START_NANOSECONDS" },
{157, 8, "FLOW_END_NANOSECONDS" },
// *
{160, 8, "SYSINIT_MILLIS"},
{161, 8, "FLOW_DUR_MILLIS"},
......@@ -1215,7 +1217,7 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
copyIpV6(npctxt->exporterIpv6Address, outBuffer, outBufferBegin, outBufferMax);
break;
case 136:
copyInt8(0, outBuffer, outBufferBegin, outBufferMax); /* FIX */
copyInt8(theFlow->flowEndReason, outBuffer, outBufferBegin, outBufferMax);
break;
case 145:
copyInt32(0, outBuffer, outBufferBegin, outBufferMax); /* FIX */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment