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

Update IPFIXLIB to potentially fix bandwidth calculation issues, and correct...

Update IPFIXLIB to potentially fix bandwidth calculation issues, and correct int64 network byte ordering, havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@51 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent dfa1bd04
......@@ -414,7 +414,7 @@ static void calculateBitrate(u_int divisor, u_int64_t stamp, u_int64_t *lastupda
// First: If advancing, then sum up and check for record first.
if(numSlotsAdvance > 0 || force) {
u_int32_t sum = 0, u_int32_t sum2 = 0;
u_int32_t sum = 0;
for(i=0; i<BITRATE_AVERAGER_SLOTS; i++) {
sum += averager[i];
......@@ -427,11 +427,13 @@ static void calculateBitrate(u_int divisor, u_int64_t stamp, u_int64_t *lastupda
}
// Retain 'sum', we need to know if its MAX_UINT32.
sum2 = sum*mult;
if(sum2 < *rate_best_min)
*rate_best_min = sum2;
if(sum!=MAX_UINT32 && sum2 > *rate_best_max)
*rate_best_max = sum2;
if(sum != MAX_UINT32) {
sum *= mult;
if(sum < *rate_best_min)
*rate_best_min = sum;
if(sum > *rate_best_max)
*rate_best_max = sum;
}
/* If 'force', then all we wanted was to update stats */
if(force)
......
......@@ -640,24 +640,14 @@ void nprintf(FILE *stream, char *fmt, HashBucket *theFlow, int direction) {
}
unsigned long long ntohll(unsigned long long n) {
#if __BYTE_ORDER == __BIG_ENDIAN
return n;
#else
return (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32);
#endif
}
/**
* This method does not really belong here, but where else to put
* it...
*/
unsigned long long htonll(unsigned long long n) {
#if __BYTE_ORDER == __BIG_ENDIAN
return n;
#else
return (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32);
#endif
return (((u_int64_t)(ntohl((u_int32_t)((n << 32) >> 32))) << 32) |
(u_int32_t)ntohl(((u_int32_t)(n >> 32))));
//return (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32);
}
/* ********* NetFlow v9/IPFIX ***************************** */
......
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