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

Update IPFIXLIB to fix incorrect flowid and nano/millis logic, havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@76 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent e4d8b2f1
...@@ -674,10 +674,6 @@ void addPktToHash(np_ctxt_t *npctxt, ...@@ -674,10 +674,6 @@ void addPktToHash(np_ctxt_t *npctxt,
setPayload(npctxt, bkt, payload, payloadLen, 0); setPayload(npctxt, bkt, payload, payloadLen, 0);
bkt->src2dstTcpFlags |= flags; /* Do not move this line before updateTcpFlags(...) */ bkt->src2dstTcpFlags |= flags; /* Do not move this line before updateTcpFlags(...) */
if(bkt->dst2srcTcpFlagsFirst == (unsigned short)-1) {
// Only update for first packet.
bkt->dst2srcTcpFlagsFirst = flags;
}
updatePacketSizeStats(npctxt,bkt,len,0); updatePacketSizeStats(npctxt,bkt,len,0);
if(npctxt->bitrateCalcEnabled!=0) { if(npctxt->bitrateCalcEnabled!=0) {
...@@ -712,6 +708,10 @@ void addPktToHash(np_ctxt_t *npctxt, ...@@ -712,6 +708,10 @@ void addPktToHash(np_ctxt_t *npctxt,
setPayload(npctxt, bkt, payload, payloadLen, 1); setPayload(npctxt, bkt, payload, payloadLen, 1);
bkt->dst2srcTcpFlags |= flags; /* Do not move this line before updateTcpFlags(...) */ bkt->dst2srcTcpFlags |= flags; /* Do not move this line before updateTcpFlags(...) */
if(bkt->dst2srcTcpFlagsFirst == (unsigned short)-1) {
// Only update for first packet.
bkt->dst2srcTcpFlagsFirst = flags;
}
updatePacketSizeStats(npctxt,bkt,len,1); updatePacketSizeStats(npctxt,bkt,len,1);
if(npctxt->bitrateCalcEnabled!=0) { if(npctxt->bitrateCalcEnabled!=0) {
updateBitrateCalculation(npctxt,bkt,len, stamp,1,0); updateBitrateCalculation(npctxt,bkt,len, stamp,1,0);
...@@ -739,6 +739,11 @@ void addPktToHash(np_ctxt_t *npctxt, ...@@ -739,6 +739,11 @@ void addPktToHash(np_ctxt_t *npctxt,
bkt->dst2src_expval_pktlength_x2= bkt->dst2src_expval_pktlength_x2+ len*len; bkt->dst2src_expval_pktlength_x2= bkt->dst2src_expval_pktlength_x2+ len*len;
} }
if(bkt->dst2srcflowid==0) {
bkt->dst2srcflowid = npctxt->numObservedFlows;
npctxt->numObservedFlows = npctxt->numObservedFlows + 1;
}
} }
pthread_mutex_unlock(&hashMutex[mutexIdx]); pthread_mutex_unlock(&hashMutex[mutexIdx]);
...@@ -909,7 +914,8 @@ void addPktToHash(np_ctxt_t *npctxt, ...@@ -909,7 +914,8 @@ void addPktToHash(np_ctxt_t *npctxt,
/* Increase num of observed flows. We don't update the number of flows /* Increase num of observed flows. We don't update the number of flows
* when traffic is discovered in the other direction. */ * when traffic is discovered in the other direction. */
bkt->flowid = (uint32_t)npctxt->numObservedFlows; bkt->src2dstflowid = (uint32_t)npctxt->numObservedFlows;
bkt->dst2srcflowid = 0;
npctxt->numObservedFlows = npctxt->numObservedFlows + 1; npctxt->numObservedFlows = npctxt->numObservedFlows + 1;
/* Put the bucket on top of the list */ /* Put the bucket on top of the list */
......
...@@ -157,7 +157,8 @@ typedef struct hashBucket { ...@@ -157,7 +157,8 @@ typedef struct hashBucket {
u_int64_t optionsIPV4src2dst; u_int64_t optionsIPV4src2dst;
u_int64_t optionsIPV4dst2src; u_int64_t optionsIPV4dst2src;
u_int32_t flowid; // ID of flow locally unique to _exporter_. u_int32_t src2dstflowid; // ID of flow locally unique to _exporter_.
u_int32_t dst2srcflowid;
u_int8_t flowEndReason; u_int8_t flowEndReason;
......
...@@ -1247,7 +1247,8 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate, ...@@ -1247,7 +1247,8 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
copyInt32(0, outBuffer, outBufferBegin, outBufferMax); /* FIX */ copyInt32(0, outBuffer, outBufferBegin, outBufferMax); /* FIX */
break; break;
case 148: case 148:
copyInt32(theFlow->flowid, outBuffer, outBufferBegin, outBufferMax); copyInt32(direction==0?theFlow->src2dstflowid:theFlow->dst2srcflowid,
outBuffer, outBufferBegin, outBufferMax);
break; break;
case 150: // FLOW_START_SECONDS uint32 case 150: // FLOW_START_SECONDS uint32
...@@ -1274,28 +1275,28 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate, ...@@ -1274,28 +1275,28 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
{ {
u_int32_t usec = (direction == 1 ? (theFlow->firstSeenRcvd&0xFFFFFFFF) : (theFlow->firstSeenSent&0xFFFFFFFF))/TIME_US; u_int32_t usec = (direction == 1 ? (theFlow->firstSeenRcvd&0xFFFFFFFF) : (theFlow->firstSeenSent&0xFFFFFFFF))/TIME_US;
u_int32_t sec = (direction == 1 ? (theFlow->firstSeenRcvd>>32) : (theFlow->firstSeenSent>>32)); u_int32_t sec = (direction == 1 ? (theFlow->firstSeenRcvd>>32) : (theFlow->firstSeenSent>>32));
copyInt64((u_int64_t)usec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax); copyInt64((u_int64_t)usec + (u_int64_t)sec*1000000ull, outBuffer,outBufferBegin,outBufferMax);
} }
break; break;
case 155: // FLOW_END_MICROSECONDS uint64 case 155: // FLOW_END_MICROSECONDS uint64
{ {
u_int32_t usec = (direction == 1 ? (theFlow->lastSeenRcvd&0xFFFFFFFF) : (theFlow->lastSeenSent&0xFFFFFFFF))/TIME_US; u_int32_t usec = (direction == 1 ? (theFlow->lastSeenRcvd&0xFFFFFFFF) : (theFlow->lastSeenSent&0xFFFFFFFF))/TIME_US;
u_int32_t sec = (direction == 1 ? (theFlow->lastSeenRcvd>>32) : (theFlow->lastSeenSent>>32)); u_int32_t sec = (direction == 1 ? (theFlow->lastSeenRcvd>>32) : (theFlow->lastSeenSent>>32));
copyInt64((u_int64_t)usec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax); copyInt64((u_int64_t)usec + (u_int64_t)sec*1000000ull, outBuffer,outBufferBegin,outBufferMax);
} }
break; break;
case 156: // FLOW_START_NANOSECONDS uint64 case 156: // FLOW_START_NANOSECONDS uint64
{ {
u_int32_t nsec = (direction == 1 ? (theFlow->firstSeenRcvd&0xFFFFFFFF) : (theFlow->firstSeenSent&0xFFFFFFFF))/TIME_NS; u_int32_t nsec = (direction == 1 ? (theFlow->firstSeenRcvd&0xFFFFFFFF) : (theFlow->firstSeenSent&0xFFFFFFFF))/TIME_NS;
u_int32_t sec = (direction == 1 ? (theFlow->firstSeenRcvd>>32) : (theFlow->firstSeenSent>>32)); u_int32_t sec = (direction == 1 ? (theFlow->firstSeenRcvd>>32) : (theFlow->firstSeenSent>>32));
copyInt64((u_int64_t)nsec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax); copyInt64((u_int64_t)nsec + (u_int64_t)sec*1000000000ull, outBuffer,outBufferBegin,outBufferMax);
} }
break; break;
case 157: // FLOW_END_NANOSECONDS uint64 case 157: // FLOW_END_NANOSECONDS uint64
{ {
u_int32_t nsec = (direction == 1 ? (theFlow->lastSeenRcvd&0xFFFFFFFF) : (theFlow->lastSeenSent&0xFFFFFFFF))/TIME_NS; u_int32_t nsec = (direction == 1 ? (theFlow->lastSeenRcvd&0xFFFFFFFF) : (theFlow->lastSeenSent&0xFFFFFFFF))/TIME_NS;
u_int32_t sec = (direction == 1 ? (theFlow->lastSeenRcvd>>32) : (theFlow->lastSeenSent>>32)); u_int32_t sec = (direction == 1 ? (theFlow->lastSeenRcvd>>32) : (theFlow->lastSeenSent>>32));
copyInt64((u_int64_t)nsec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax); copyInt64((u_int64_t)nsec + (u_int64_t)sec*1000000000ull, outBuffer,outBufferBegin,outBufferMax);
} }
break; break;
case 160: case 160:
......
Supports Markdown
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