summaryrefslogtreecommitdiffstats
path: root/include/debug.h
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2007-07-09 19:11:53 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2007-07-09 19:11:53 +0000
commit96084e1a1f2e0a49c961bbddb9fffd2e03bfae3f (patch)
treec078d88b157faa7c5ce76bc4591205756f09742b /include/debug.h
parent4df0be6fbf6a47905e0edf11c13b49ea0eacee5b (diff)
- conntrack-tools requires libnetfilter_conntrack >= 0.0.81
- add len field to nethdr - implement buffered send/recv to batch messages - stop using netlink format for network messages: use similar TLV-based format - reduce synchronization messages size up to 60% - introduce periodic alive messages for sync-nack protocol - timeslice alarm implementation: remove alarm pthread, remove locking - simplify debugging functions: use nfct_snprintf instead - remove major use of libnfnetlink functions: use libnetfilter_conntrack API - deprecate conntrackd -F, use conntrack -F instead - major rework of the network infrastructure: much simple, less messy
Diffstat (limited to 'include/debug.h')
-rw-r--r--include/debug.h56
1 files changed, 10 insertions, 46 deletions
diff --git a/include/debug.h b/include/debug.h
index 4d1f44f..1ffd9ac 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -1,57 +1,21 @@
#ifndef _DEBUG_H
#define _DEBUG_H
-#if 0
-#define debug printf
-#else
-#define debug
-#endif
-
-#include <string.h>
-#include <netinet/in.h>
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
#undef DEBUG_CT
-static inline void debug_ct(struct nf_conntrack *ct, char *msg)
-{
#ifdef DEBUG_CT
- struct in_addr addr, addr2, addr3, addr4;
-
- debug("----%s (%p) ----\n", msg, ct);
- memcpy(&addr,
- nfct_get_attr(ct, ATTR_ORIG_IPV4_SRC),
- sizeof(u_int32_t));
- memcpy(&addr2,
- nfct_get_attr(ct, ATTR_ORIG_IPV4_DST),
- sizeof(u_int32_t));
- memcpy(&addr3,
- nfct_get_attr(ct, ATTR_REPL_IPV4_SRC),
- sizeof(u_int32_t));
- memcpy(&addr4,
- nfct_get_attr(ct, ATTR_REPL_IPV4_DST),
- sizeof(u_int32_t));
-
- debug("status: %x\n", nfct_get_attr_u32(ct, ATTR_STATUS));
- debug("l3:%d l4:%d ",
- nfct_get_attr_u8(ct, ATTR_ORIG_L3PROTO),
- nfct_get_attr_u8(ct, ATTR_ORIG_L4PROTO));
- debug("%s:%hu ->", inet_ntoa(addr),
- ntohs(nfct_get_attr_u16(ct, ATTR_ORIG_PORT_SRC)));
- debug("%s:%hu\n",
- inet_ntoa(addr2),
- ntohs(nfct_get_attr_u16(ct, ATTR_ORIG_PORT_DST)));
- debug("l3:%d l4:%d ",
- nfct_get_attr_u8(ct, ATTR_REPL_L3PROTO),
- nfct_get_attr_u8(ct, ATTR_REPL_L4PROTO));
- debug("%s:%hu ->",
- inet_ntoa(addr3),
- ntohs(nfct_get_attr_u16(ct, ATTR_REPL_PORT_SRC)));
- debug("%s:%hu\n",
- inet_ntoa(addr4),
- ntohs(nfct_get_attr_u16(ct, ATTR_REPL_PORT_DST)));
- debug("-------------------------\n");
+#define debug_ct(ct, msg) \
+({ \
+ char buf[1024]; \
+ nfct_snprintf(buf, 1024, ct, NFCT_T_ALL, 0, 0); \
+ printf("[%s]: %s\n", msg, buf); \
+})
+#define debug printf
+#else
+#define debug_ct(ct, msg)
+#define debug
#endif
-}
#endif