From 07a3a6fe92c98e251a464a5744421ce211030003 Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Wed, 16 Apr 2008 15:37:39 +0000 Subject: add more verbose error notification when the injection of a conntrack fails --- src/log.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/log.c') diff --git a/src/log.c b/src/log.c index 51e757f..d97a69f 100644 --- a/src/log.c +++ b/src/log.c @@ -104,18 +104,30 @@ void dlog(int priority, const char *format, ...) } } -void dlog_ct(struct nf_conntrack *ct) +void dlog_ct(FILE *fd, struct nf_conntrack *ct, unsigned int type) { - FILE *fd = STATE(stats_log); time_t t; char buf[1024]; char *tmp; - - t = time(NULL); - ctime_r(&t, buf); - tmp = buf + strlen(buf); - buf[strlen(buf)-1]='\t'; - nfct_snprintf(buf+strlen(buf), 1024-strlen(buf), ct, 0, 0, 0); + unsigned int flags = 0; + + buf[0]='\0'; + + switch(type) { + case NFCT_O_PLAIN: + t = time(NULL); + ctime_r(&t, buf); + tmp = buf + strlen(buf); + buf[strlen(buf)-1]='\t'; + break; + case NFCT_O_XML: + tmp = buf; + flags |= NFCT_OF_TIME; + break; + default: + return; + } + nfct_snprintf(buf+strlen(buf), 1024-strlen(buf), ct, 0, type, flags); if (fd) { snprintf(buf+strlen(buf), 1024-strlen(buf), "\n"); -- cgit v1.2.3