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

Update IPFIXLIB to correct corrupted IP addresses created when attempting to...

Update IPFIXLIB to correct corrupted IP addresses created when attempting to export ipv6 addresses as ipv4, and vice versa, havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@113 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent f5ea410c
......@@ -894,6 +894,21 @@ static void copyIpV6(struct in6_addr ipv6, char *outBuffer, int *outBufferBegin,
copyLen((char*)&ipv6, sizeof(ipv6), outBuffer, outBufferBegin, outBufferMax);
}
static void copyIpAddress(u_int8_t version, struct IpAddress &ipaddr, char *outBuffer, int *outBufferBegin, int *outBufferMax) {
if(ipaddr.ipVersion==version)
copyLen((char*)((version==6)?(&ipaddr.ipType.ipv6):(&ipaddr.ipType.ipv4)),
(version==6)?sizeof(ipaddr.ipType.ipv6):sizeof(ipaddr.ipType.ipv4),
outBuffer, outBufferBegin, outBufferMax);
else {
/* Write empty data for address */
if((*outBufferBegin)+strLen < (*outBufferMax)) {
memset(&outBuffer[(*outBufferBegin)], 0, strLen);
(*outBufferBegin) += strLen;
}
}
}
/* ****************************************************** */
static void
......@@ -1012,8 +1027,8 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
outBuffer, outBufferBegin, outBufferMax);
break;
case 8:
copyInt32(direction == 0 ? theFlow->src.ipType.ipv4 : theFlow->dst.ipType.ipv4,
outBuffer, outBufferBegin, outBufferMax);
copyIpAddress(4, direction == 0 ? theFlow->src : theFlow->dst,
outBuffer, outBufferBegin, outBufferMax);
break;
case 9: /* SRC_MASK */
/* FIXME: Not implemented */
......@@ -1027,8 +1042,8 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
outBuffer, outBufferBegin, outBufferMax);
break;
case 12:
copyInt32(direction == 1 ? theFlow->src.ipType.ipv4 : theFlow->dst.ipType.ipv4,
outBuffer, outBufferBegin, outBufferMax);
copyIpAddress(4, direction == 1 ? theFlow->src : theFlow->dst,
outBuffer, outBufferBegin, outBufferMax);
break;
case 13: /* DST_MASK */
/* FIXME: Not implemented */
......@@ -1112,12 +1127,12 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
copyInt16(direction==0?theFlow->src2dstMaxPktSize:theFlow->dst2srcMaxPktSize, outBuffer, outBufferBegin, outBufferMax);
break;
case 27:
copyIpV6(direction == 0 ? theFlow->src.ipType.ipv6 : theFlow->dst.ipType.ipv6,
outBuffer, outBufferBegin, outBufferMax);
copyIpAddress(6, direction == 0 ? theFlow->src : theFlow->dst,
outBuffer, outBufferBegin, outBufferMax);
break;
case 28:
copyIpV6(direction == 0 ? theFlow->dst.ipType.ipv6 : theFlow->src.ipType.ipv6,
outBuffer, outBufferBegin, outBufferMax);
copyIpAddress(6, direction == 0 ? theFlow->dst : theFlow->src,
outBuffer, outBufferBegin, outBufferMax);
break;
case 29:
case 30:
......
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