[netfilter-cvslog] r4401 - in trunk/libnetfilter_conntrack: include/libnetfilter_conntrack src

pablo at netfilter.org pablo at netfilter.org
Sun Oct 30 16:32:28 CET 2005


Author: pablo at netfilter.org
Date: 2005-10-30 16:32:27 +0100 (Sun, 30 Oct 2005)
New Revision: 4401

Modified:
   trunk/libnetfilter_conntrack/include/libnetfilter_conntrack/libnetfilter_conntrack.h
   trunk/libnetfilter_conntrack/src/libnetfilter_conntrack.c
Log:
o Added the expectation printing API
o Bumped version to 0.2.2



Modified: trunk/libnetfilter_conntrack/include/libnetfilter_conntrack/libnetfilter_conntrack.h
===================================================================
--- trunk/libnetfilter_conntrack/include/libnetfilter_conntrack/libnetfilter_conntrack.h	2005-10-30 14:58:23 UTC (rev 4400)
+++ trunk/libnetfilter_conntrack/include/libnetfilter_conntrack/libnetfilter_conntrack.h	2005-10-30 15:32:27 UTC (rev 4401)
@@ -13,7 +13,7 @@
 #include <linux/netfilter/nfnetlink_conntrack.h> 
 #include <libnfnetlink/libnfnetlink.h>
 
-#define LIBNETFILTER_CONNTRACK_VERSION "0.2.1"
+#define LIBNETFILTER_CONNTRACK_VERSION "0.2.2"
 
 enum {
 	CONNTRACK = NFNL_SUBSYS_CTNETLINK,
@@ -269,8 +269,8 @@
 				  unsigned int flags);
 extern int nfct_sprintf_conntrack_id(char *buf, struct nfct_conntrack *ct,
 				     unsigned int flags);
-extern int nfct_sprintf_address(char *buf, struct nfct_conntrack *ct, int dir);
-extern int nfct_sprintf_proto(char *buf, struct nfct_conntrack *ct, int dir);
+extern int nfct_sprintf_address(char *buf, struct nfct_tuple *t);
+extern int nfct_sprintf_proto(char *buf, struct nfct_tuple *t);
 extern int nfct_sprintf_protoinfo(char *buf, struct nfct_conntrack *ct);
 extern int nfct_sprintf_timeout(char *buf, struct nfct_conntrack *ct);
 extern int nfct_sprintf_protocol(char *buf, struct nfct_conntrack *ct);
@@ -279,7 +279,7 @@
 extern int nfct_sprintf_counters(char *buf, struct nfct_conntrack *ct, int dir);
 extern int nfct_sprintf_mark(char *buf, struct nfct_conntrack *ct);
 extern int nfct_sprintf_use(char *buf, struct nfct_conntrack *ct);
-extern int nfct_sprintf_id(char *buf, struct nfct_conntrack *ct);
+extern int nfct_sprintf_id(char *buf, unsigned int id);
 
 /* 
  * Expectations
@@ -295,4 +295,10 @@
 extern int nfct_event_expectation(struct nfct_handle *cth);
 extern int nfct_flush_expectation_table(struct nfct_handle *cth);
 
+/*
+ * expectation printing functions
+ */
+extern int nfct_sprintf_expect(char *buf, struct nfct_expect *exp);
+extern int nfct_sprintf_expect_id(char *buf, struct nfct_expect *exp);
+
 #endif	/* _LIBNETFILTER_CONNTRACK_H_ */

Modified: trunk/libnetfilter_conntrack/src/libnetfilter_conntrack.c
===================================================================
--- trunk/libnetfilter_conntrack/src/libnetfilter_conntrack.c	2005-10-30 14:58:23 UTC (rev 4400)
+++ trunk/libnetfilter_conntrack/src/libnetfilter_conntrack.c	2005-10-30 15:32:27 UTC (rev 4401)
@@ -506,21 +506,21 @@
 	return size;
 }
 
-int nfct_sprintf_address(char *buf, struct nfct_conntrack *ct, int dir)
+int nfct_sprintf_address(char *buf, struct nfct_tuple *t)
 {
 	return (sprintf(buf, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ",
-			NIPQUAD(ct->tuple[dir].src.v4),
-			NIPQUAD(ct->tuple[dir].dst.v4)));
+			NIPQUAD(t->src.v4),
+			NIPQUAD(t->dst.v4)));
 }
 
-int nfct_sprintf_proto(char *buf, struct nfct_conntrack *ct, int dir)
+int nfct_sprintf_proto(char *buf, struct nfct_tuple *t)
 {
 	int size = 0;
 	struct nfct_proto *h = NULL;
 
-	h = findproto(proto2str[ct->tuple[NFCT_DIR_ORIGINAL].protonum]);
+	h = findproto(proto2str[t->protonum]);
 	if (h && h->print_proto)
-		size += h->print_proto(buf, &ct->tuple[dir]);
+		size += h->print_proto(buf, t);
 
 	return size;
 }
@@ -542,9 +542,9 @@
 	return (sprintf(buf, "use=%u ", ct->use));
 }
 
-int nfct_sprintf_id(char *buf, struct nfct_conntrack *ct)
+int nfct_sprintf_id(char *buf, unsigned int id)
 {
-	return (sprintf(buf, "id=%u ", ct->id));
+	return (sprintf(buf, "id=%u ", id));
 }
 
 int nfct_sprintf_conntrack(char *buf, struct nfct_conntrack *ct, 
@@ -560,8 +560,8 @@
         if (flags & NFCT_PROTOINFO)
 		size += nfct_sprintf_protoinfo(buf+size, ct);
 
-	size += nfct_sprintf_address(buf+size, ct, NFCT_DIR_ORIGINAL);
-	size += nfct_sprintf_proto(buf+size, ct, NFCT_DIR_ORIGINAL);
+	size += nfct_sprintf_address(buf+size, &ct->tuple[NFCT_DIR_ORIGINAL]);
+	size += nfct_sprintf_proto(buf+size, &ct->tuple[NFCT_DIR_ORIGINAL]);
 
 	if (flags & NFCT_COUNTERS_ORIG)
 		size += nfct_sprintf_counters(buf+size, ct, NFCT_DIR_ORIGINAL);
@@ -569,8 +569,8 @@
 	if (flags & NFCT_STATUS)
 		size += nfct_sprintf_status_seen_reply(buf+size, ct);
 
-	size += nfct_sprintf_address(buf+size, ct, NFCT_DIR_REPLY);
-	size += nfct_sprintf_proto(buf+size, ct, NFCT_DIR_REPLY);
+	size += nfct_sprintf_address(buf+size, &ct->tuple[NFCT_DIR_REPLY]);
+	size += nfct_sprintf_proto(buf+size, &ct->tuple[NFCT_DIR_REPLY]);
 
 	if (flags & NFCT_COUNTERS_RPLY)
 		size += nfct_sprintf_counters(buf+size, ct, NFCT_DIR_REPLY);
@@ -594,7 +594,7 @@
 	
 	size = nfct_sprintf_conntrack(buf, ct, flags);
 	if (flags & NFCT_ID)
-		size += nfct_sprintf_id(buf+size, ct);
+		size += nfct_sprintf_id(buf+size, ct->id);
 
 	return size;
 }
@@ -623,24 +623,52 @@
 	return 0;
 }
 
+int nfct_sprintf_expect_proto(char *buf, struct nfct_expect *exp)
+{
+	 return(sprintf(buf, "%ld proto=%d ", exp->timeout, 
+					      exp->tuple.protonum));
+}
+
+int nfct_sprintf_expect(char *buf, struct nfct_expect *exp)
+{
+	int size = 0;
+	
+	size = nfct_sprintf_expect_proto(buf, exp);
+	size += nfct_sprintf_address(buf+size, &exp->tuple);
+	size += nfct_sprintf_proto(buf+size, &exp->tuple);
+
+	return size;
+}
+
+int nfct_sprintf_expect_id(char *buf, struct nfct_expect *exp)
+{
+	int size = 0;
+
+	size = nfct_sprintf_expect(buf, exp);
+	size += nfct_sprintf_id(buf+size, exp->id);
+
+	return size;
+}
+
 int nfct_default_expect_display(void *arg, unsigned int flags, int type)
 {
-	struct nfct_expect *exp = arg;
 	char buf[256];
 	int size = 0;
-        struct nfct_proto *h = NULL;
 
-	size += sprintf(buf, "%ld proto=%d ", exp->timeout, exp->tuple.protonum);
-	size += sprintf(buf+size, "src=%u.%u.%u.%u dst=%u.%u.%u.%u ",
-					NIPQUAD(exp->tuple.src.v4),
-					NIPQUAD(exp->tuple.dst.v4));
+	size = nfct_sprintf_expect(buf, arg);
+	sprintf(buf+size, "\n");
+	fprintf(stdout, buf);
 
-	h = findproto(proto2str[exp->tuple.protonum]);
-	if (h && h->print_proto)
-		size += h->print_proto(buf+size, &exp->tuple);
-	
-	size += sprintf(buf+size, "id=%u ", exp->id);
-	size += sprintf(buf+size, "\n");
+	return 0;
+}
+
+int nfct_default_expect_display_id(void *arg, unsigned int flags, int type)
+{
+	char buf[256];
+	int size = 0;
+
+	size = nfct_sprintf_expect_id(buf, arg);
+	sprintf(buf+size, "\n");
 	fprintf(stdout, buf);
 
 	return 0;




More information about the netfilter-cvslog mailing list