summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-11-13 10:01:05 +0100
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:40 +0200
commit2c82a9de62637cca89adc82fbd78b41e65b35115 (patch)
treeadd45ec3390b51070ab9489eea6e2afe9ef8c3e2
parentf0718ef8e12cb0ebd43b67a73d6ed3869a2ab803 (diff)
IPFIX: misc fixes
o include the size of the Set header length in the Set length. o send IPv4 addresses as a 32bit value. Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
-rw-r--r--output/ipfix/ipfix.c19
-rw-r--r--output/ipfix/ipfix.h5
-rw-r--r--output/ipfix/ulogd_output_IPFIX.c7
3 files changed, 24 insertions, 7 deletions
diff --git a/output/ipfix/ipfix.c b/output/ipfix/ipfix.c
index 1164fb9..c9d8e4f 100644
--- a/output/ipfix/ipfix.c
+++ b/output/ipfix/ipfix.c
@@ -75,7 +75,7 @@ ipfix_msg_add_set(struct ipfix_msg *msg, uint16_t sid)
shdr = (struct ipfix_set_hdr *)msg->tail;
shdr->id = sid; /* leave host byte-order */
- shdr->len = 0;
+ shdr->len = IPFIX_SET_HDRLEN;
msg->tail += IPFIX_SET_HDRLEN;
msg->last_set = shdr;
return shdr;
@@ -109,6 +109,23 @@ ipfix_msg_add_data(struct ipfix_msg *msg, size_t len)
return data;
}
+/* check and dump message */
+int
+ipfix_dump_msg(const struct ipfix_msg *msg)
+{
+ const struct ipfix_hdr *hdr = ipfix_msg_hdr(msg);
+ const struct ipfix_set_hdr *shdr = (struct ipfix_set_hdr *)hdr->data;
+
+ BUG_ON(ntohs(hdr->len) < IPFIX_HDRLEN);
+ BUG_ON(ipfix_msg_len(msg) != IPFIX_HDRLEN + ntohs(shdr->len));
+
+ ulogd_log(ULOGD_DEBUG, "msg: ver=%#x len=%#x t=%#x seq=%#x oid=%d\n",
+ ntohs(hdr->version), ntohs(hdr->len), htonl(hdr->time),
+ ntohl(hdr->seqno), ntohl(hdr->oid));
+
+ return 0;
+}
+
/* template management */
size_t
ipfix_rec_len(uint16_t sid)
diff --git a/output/ipfix/ipfix.h b/output/ipfix/ipfix.h
index 38b174d..b72a3ca 100644
--- a/output/ipfix/ipfix.h
+++ b/output/ipfix/ipfix.h
@@ -50,8 +50,8 @@ struct ipfix_msg {
};
struct vy_ipfix_data {
- struct sockaddr_in saddr;
- struct sockaddr_in daddr;
+ struct in_addr saddr;
+ struct in_addr daddr;
uint16_t ifi_in;
uint16_t ifi_out;
uint32_t packets;
@@ -83,5 +83,6 @@ size_t ipfix_msg_len(const struct ipfix_msg *);
void *ipfix_msg_data(struct ipfix_msg *);
struct ipfix_set_hdr *ipfix_msg_add_set(struct ipfix_msg *, uint16_t);
void *ipfix_msg_add_data(struct ipfix_msg *, size_t);
+int ipfix_dump_msg(const struct ipfix_msg *);
#endif /* IPFIX_H */
diff --git a/output/ipfix/ulogd_output_IPFIX.c b/output/ipfix/ulogd_output_IPFIX.c
index 1495a03..25ee27b 100644
--- a/output/ipfix/ulogd_output_IPFIX.c
+++ b/output/ipfix/ulogd_output_IPFIX.c
@@ -233,7 +233,6 @@ static int
ipfix_start(struct ulogd_pluginstance *pi)
{
struct ipfix_priv *priv = upi_priv(pi);
- struct ipfix_set_hdr *shdr;
char addr[16];
int ret;
@@ -359,12 +358,12 @@ again:
return ULOGD_IRET_OK;
}
ipfix_msg_add_set(priv->msg, VY_IPFIX_SID);
- /* can't loop because we know the next will succeed */
+ /* can't loop because the next will definitely succeed */
goto again;
}
- key_src_in(&in[InIpSaddr], &data->saddr.sin_addr);
- key_src_in(&in[InIpDaddr], &data->daddr.sin_addr);
+ key_src_in(&in[InIpSaddr], &data->saddr);
+ key_src_in(&in[InIpDaddr], &data->daddr);
data->ifi_in = data->ifi_out = 0;
data->packets = htonl((uint32_t)(key_src_u64(&in[InRawInPktCount])