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

Update IPFIXLIB to add support to other data types, like 64-bits octet count,...

Update IPFIXLIB to add support to other data types, like 64-bits octet count, etc., havard.mork@gmail.com


git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@43 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 8d1d0c84
......@@ -604,6 +604,7 @@ void addPktToHash(np_ctxt_t *npctxt,
updateBitrateCalculation(npctxt,bkt,len, stamp,0);
}
bkt->src2dstOctetDeltaCount = bkt->src2dstOctetDeltaCount + len;
if(src.ipVersion == 4 && proto == IPPROTO_TCP)
bkt->optionsIPV4src2dst |= v4_options;
......@@ -628,6 +629,8 @@ void addPktToHash(np_ctxt_t *npctxt,
updateBitrateCalculation(npctxt,bkt,len, stamp,1);
}
bkt->dst2srcOctetDeltaCount = bkt->dst2srcOctetDeltaCount + len;
if(src.ipVersion == 4 && proto == IPPROTO_TCP)
bkt->optionsIPV4dst2src |= v4_options;
else
......@@ -736,6 +739,11 @@ void addPktToHash(np_ctxt_t *npctxt,
bkt->optionsIPV4dst2src = 0;
bkt->optionsIPV6dst2src = 0;
bkt->src2dstOctetDeltaCount = len;
bkt->dst2srcOctetDeltaCount = 0;
//src2dstOctetTotalCount = len;
//dst2srcOctetTotalCount = 0;
/* Calculate src2dst payload length (payload length for ipv6). Only first packet. */
bkt->src2dstPktlenIpv4 = 0;
......
......@@ -1141,7 +1141,6 @@ npInitContext(void)
struct hostent *phe = gethostbyname(ac);
if (phe != NULL) {
for (i = 0; phe->h_addr_list[i] != 0; ++i) {
struct in_addr addr;
if(phe->h_addrtype==AF_INET)
memcpy(&npctxt->exporterIpv4Address, phe->h_addr_list[i], sizeof(struct in_addr));
else if(phe->h_addrtype==AF_INET6)
......
......@@ -144,6 +144,11 @@ typedef struct hashBucket {
u_int64_t optionsIPV4dst2src;
u_int32_t flowid; // ID of flow locally unique to _exporter_.
u_int64_t src2dstOctetDeltaCount;
u_int64_t dst2srcOctetDeltaCount;
//u_int64_t src2dstOctetTotalCount;
//u_int64_t dst2srcOctetTotalCount;
} HashBucket;
......@@ -757,9 +757,9 @@ static V9TemplateId ver9_templates[] = {
{190, 2, "PKTLEN_IPV4"},
{191, 4, "PKTLEN_IPV6"},
// *
//{204, 1 - octetDeltaCount - int
//{205, 1 - postOctetDeltaCount - int
//{206, 1 - octetTotalCount - int
{204, 8, "OCTETS_64"},
//{205, 1 - postOctetDeltaCount - int
{206, 8, "OCTETS_TOT_64"},
{207, 1, "HDRLEN_IPV4"},
{208, 8, "IPV4_OPT"},
{209, 8, "TCP_OPT"},
......@@ -931,6 +931,7 @@ exportPayload(np_ctxt_t *npctxt, HashBucket *myBucket, int direction,
#define TIME_S 4294967296ULL
#define TIME_MS 4294967
#define TIME_US 4294
#define TIME_NS 4
/* ******************************************** */
......@@ -1231,38 +1232,53 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
break;
case 152: // FLOW_START_MILLISECONDS uint64
{
u_int32_t msec = (direction == 1 ? (theFlow->firstSeenRcvd&0xFFFFFFFF) : (theFlow->firstSeenSent&0xFFFFFFFF));
copyInt32(direction == 1 ? (theFlow->firstSeenRcvd>>32) : (theFlow->firstSeenSent>>32), outBuffer,outBufferBegin,outBufferMax);
copyInt32(msec, outBuffer,outBufferBegin,outBufferMax);
u_int32_t msec = (direction == 1 ? (theFlow->firstSeenRcvd&0xFFFFFFFF) : (theFlow->firstSeenSent&0xFFFFFFFF))/TIME_MS;
u_int32_t sec = (direction == 1 ? (theFlow->firstSeenRcvd>>32) : (theFlow->firstSeenSent>>32));
copyInt64((u_int64_t)msec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax);
}
break;
case 153: // FLOW_END_MILLISECONDS uint64
{
u_int32_t msec = (direction == 1 ? (theFlow->lastSeenRcvd&0xFFFFFFFF) : (theFlow->lastSeenSent&0xFFFFFFFF));
msec /= TIME_MS;
copyInt32(direction == 1 ? (theFlow->lastSeenRcvd>>32) : (theFlow->lastSeenSent>>32), outBuffer,outBufferBegin,outBufferMax);
copyInt32(msec, outBuffer,outBufferBegin,outBufferMax);
u_int32_t msec = (direction == 1 ? (theFlow->lastSeenRcvd&0xFFFFFFFF) : (theFlow->lastSeenSent&0xFFFFFFFF))/TIME_MS;
u_int32_t sec = (direction == 1 ? (theFlow->lastSeenRcvd>>32) : (theFlow->lastSeenSent>>32));
copyInt64((u_int64_t)msec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax);
}
break;
case 154: // FLOW_START_MICROSECONDS uint64
{
u_int32_t usec = (direction == 1 ? (theFlow->firstSeenRcvd&0xFFFFFFFF) : (theFlow->firstSeenSent&0xFFFFFFFF));
usec /= TIME_US;
copyInt32(direction == 1 ? (theFlow->firstSeenRcvd>>32) : (theFlow->firstSeenSent>>32), outBuffer,outBufferBegin,outBufferMax);
copyInt32(usec, outBuffer,outBufferBegin,outBufferMax);
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));
copyInt64((u_int64_t)usec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax);
}
break;
case 155: // FLOW_END_MICROSECONDS uint64
{
u_int32_t usec = (direction == 1 ? (theFlow->lastSeenRcvd&0xFFFFFFFF) : (theFlow->lastSeenSent&0xFFFFFFFF));
usec /= TIME_US;
copyInt32(direction == 1 ? (theFlow->lastSeenRcvd>>32) : (theFlow->lastSeenSent>>32), outBuffer,outBufferBegin,outBufferMax);
copyInt32(usec, outBuffer,outBufferBegin,outBufferMax);
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));
copyInt64((u_int64_t)usec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax);
}
break;
case 156: // FLOW_START_NANOSECONDS uint64
{
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));
copyInt64((u_int64_t)nsec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax);
}
break;
case 157: // FLOW_END_NANOSECONDS uint64
{
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));
copyInt64((u_int64_t)nsec + (u_int64_t)sec*1000ull, outBuffer,outBufferBegin,outBufferMax);
}
break;
case 160:
//FIXME int64
copyInt64(0,outBuffer, outBufferBegin, outBufferMax);
{
u_int32_t ssec = npctxt->initialSniffTime>>32;
u_int32_t stick= npctxt->initialSniffTime&0xFFFFFFFFull;
u_int64_t initSniffTime = ((u_int64_t)ssec)*1000ull + stick/TIME_MS;
copyInt64(initSniffTime,outBuffer, outBufferBegin, outBufferMax);
}
break;
case 161: // FLOW_DURATION_MILLISECONDS
if(direction==0)
......@@ -1302,6 +1318,17 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
copyInt32(direction==0?theFlow->src2dstPktlenIpv6:theFlow->dst2srcPktlenIpv6,
outBuffer, outBufferBegin, outBufferMax);
break;
case 204:
copyInt64(direction==0?theFlow->src2dstOctetDeltaCount:theFlow->dst2srcOctetDeltaCount,
outBuffer, outBufferBegin, outBufferMax);
break;
case 206:
//copyInt64(direction==0?theFlow->src2dstOctetTotalCount:theFlow->dst2srcOctetTotalCount,
// outBuffer, outBufferBegin, outBufferMax);
/* For now, then number of octets are only the deltas -- we don't keep exported flows */
copyInt64(direction==0?theFlow->src2dstOctetDeltaCount:theFlow->dst2srcOctetDeltaCount,
outBuffer, outBufferBegin, outBufferMax);
break;
case 207:
copyInt8(theFlow->headerlengthIPv4,outBuffer, outBufferBegin, outBufferMax);
break;
......
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