Skip to contentSkip to conversation

add nflog_snprintf_xml() to output a log in XML format

PATCH In review Pablo Neira Ayuso 2 participants 5 messages May 26, 2010 – May 27, 2010 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 add nflog_snprintf_xml() to output a log in XML format

This patch adds a new function to output the packet in XML format.

---
 include/libnetfilter_log/libnetfilter_log.h |   12 +++
 src/libnetfilter_log.c                      |  113 +++++++++++++++++++++++++++
 2 files changed, 125 insertions(+), 0 deletions(-)
include/libnetfilter_log/libnetfilter_log.h +12 -0
index aa0da72..365b19d 100644
@@ -67,4 +67,16 @@ extern int nflog_get_gid(struct nflog_data *nfad, u_int32_t *gid);
 extern int nflog_get_seq(struct nflog_data *nfad, u_int32_t *seq);
 extern int nflog_get_seq_global(struct nflog_data *nfad, u_int32_t *seq);
 
+enum {
+        NFLOG_XML_PREFIX	= (1 << 0),
+        NFLOG_XML_HW		= (1 << 1),
+        NFLOG_XML_MARK		= (1 << 2),
+        NFLOG_XML_DEV		= (1 << 3),
+        NFLOG_XML_PHYSDEV	= (1 << 4),
+        NFLOG_XML_PAYLOAD	= (1 << 5),
+        NFLOG_XML_ALL		= ~0U,
+};
+
+extern int nflog_snprintf_xml(char *buf, int len, struct nflog_data *tb, int flags);
+
 #endif	/* __LIBNETFILTER_LOG_H */
src/libnetfilter_log.c +113 -0

116 lines not on this page · raw message

author maintainer
#1 lore raw
Quoted 1 line · Pablo Neira Ayuso

This patch adds a new function to output the packet in XML format.

I'm going to extend these to add NFLOG_XML_TIME. This patch will be used by ulogd2's XML output plugin. Consider these patches preliminary work-in-progress.

#2 lore raw
In reply to Pablo Neira Ayuso
Quoted 1 line · Pablo Neira Ayuso

This patch adds a new function to output the packet in XML format.

One thing always wondered me.. why is is that logging and queuing are separate? They seem to be both using netlink to transfer a packet in its entirety to userspace.

author maintainer
#3 lore raw
Quoted 7 lines · Jan Engelhardt
Quoted 1 line · Pablo Neira Ayuso

This patch adds a new function to output the packet in XML format.

One thing always wondered me.. why is is that logging and queuing are separate? They seem to be both using netlink to transfer a packet in its entirety to userspace.

Nowadays, the logging infrastructure can be simplified if we use netlink multicast instead. At the time the logging infrastructure was done, netlink only supported 32 multicast groups. Thus, it was not possible to implement it upon multicast.

They indeed look quite similar with the minor difference that logging has no verdicts and it contains the string prefix in the messages.

Probably Patrick can provide more reasons.

author maintainer
#4 lore raw

New version including NFLOG_XML_TIME.

add nflog_snprintf_xml() to output a log in XML format

This patch adds a new function to output the packet in XML format.

---
 include/libnetfilter_log/libnetfilter_log.h |   13 ++
 src/libnetfilter_log.c                      |  155 +++++++++++++++++++++++++++
 2 files changed, 168 insertions(+), 0 deletions(-)
include/libnetfilter_log/libnetfilter_log.h +13 -0
index aa0da72..6b0d3b0 100644
@@ -67,4 +67,17 @@ extern int nflog_get_gid(struct nflog_data *nfad, u_int32_t *gid);
 extern int nflog_get_seq(struct nflog_data *nfad, u_int32_t *seq);
 extern int nflog_get_seq_global(struct nflog_data *nfad, u_int32_t *seq);
 
+enum {
+	NFLOG_XML_PREFIX	= (1 << 0),
+	NFLOG_XML_HW		= (1 << 1),
+	NFLOG_XML_MARK		= (1 << 2),
+	NFLOG_XML_DEV		= (1 << 3),
+	NFLOG_XML_PHYSDEV	= (1 << 4),
+	NFLOG_XML_PAYLOAD	= (1 << 5),
+	NFLOG_XML_TIME		= (1 << 6),
+	NFLOG_XML_ALL		= ~0U,
+};
+
+extern int nflog_snprintf_xml(char *buf, size_t len, struct nflog_data *tb, int flags);
+
 #endif	/* __LIBNETFILTER_LOG_H */
src/libnetfilter_log.c +155 -0

158 lines not on this page · raw message