[netfilter-cvslog] r3996 - trunk/libctnetlink
laforge at netfilter.org
laforge at netfilter.org
Fri Jun 24 18:28:49 CEST 2005
Author: laforge at netfilter.org
Date: 2005-06-24 18:28:49 +0200 (Fri, 24 Jun 2005)
New Revision: 3996
Modified:
trunk/libctnetlink/libctnetlink.c
trunk/libctnetlink/libctnetlink.h
Log:
add ctnl_new_expect() function
Modified: trunk/libctnetlink/libctnetlink.c
===================================================================
--- trunk/libctnetlink/libctnetlink.c 2005-06-24 16:28:24 UTC (rev 3995)
+++ trunk/libctnetlink/libctnetlink.c 2005-06-24 16:28:49 UTC (rev 3996)
@@ -26,7 +26,6 @@
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ip_conntrack.h>
#include <linux/netfilter_ipv4/ip_conntrack_tcp.h>
-#include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
#include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
#include <linux/netfilter_ipv4/ip_conntrack_netlink.h>
@@ -442,6 +441,70 @@
return nfnl_send(&cth->nfnlh, (struct nlmsghdr *)&buf);
}
+/**
+ * ctnl_new_expect - create a new expectation
+ *
+ * cth: libctnetlink handle
+ * t: tuple of to-be-created expectation
+ * mask: mask of to-be-created expectation
+ * master_tuple_orig: tuple of master original direction
+ * master_tuple_reply: tuple of master reply direction
+ * timeout: timeout of new expectation
+ */
+int ctnl_new_expect(struct ctnl_handle *cth,
+ struct ip_conntrack_tuple *t,
+ struct ip_conntrack_tuple *mask,
+ struct ip_conntrack_tuple *master_tuple_orig,
+ struct ip_conntrack_tuple *master_tuple_reply,
+ unsigned long timeout)
+{
+ struct {
+ struct nlmsghdr nlh;
+ struct nfgenmsg nfmsg;
+ } *req;
+
+ char buf[sizeof(*req) + NFA_LENGTH(sizeof(*t))
+ + NFA_LENGTH(sizeof(*mask))
+ + NFA_LENGTH(sizeof(*master_tuple_orig))
+ + NFA_LENGTH(sizeof(*master_tuple_reply))
+ + NFA_LENGTH(sizeof(unsigned long))];
+
+ memset(&buf, 0, sizeof(buf));
+
+ req = (void *) &buf;
+
+ nfnl_fill_hdr(&cth->nfnlh, (struct nlmsghdr *) &buf,
+ 0, AF_INET, IPCTNL_MSG_EXP_NEW,
+ NLM_F_REQUEST|NLM_F_CREATE|NLM_F_ACK);
+
+ if (nfnl_addattr_l(&req->nlh, sizeof(buf), CTA_EXP_TUPLE, t,
+ sizeof(*t)) < 0)
+ return -1;
+
+ if (nfnl_addattr_l(&req->nlh, sizeof(buf), CTA_EXP_MASK, mask,
+ sizeof(*mask)) < 0)
+ return -1;
+
+ if (nfnl_addattr_l(&req->nlh, sizeof(buf), CTA_ORIG, master_tuple_orig,
+ sizeof(*master_tuple_orig)) < 0)
+ return -1;
+
+ if (nfnl_addattr_l(&req->nlh, sizeof(buf), CTA_RPLY,
+ master_tuple_reply, sizeof(*master_tuple_reply)) < 0)
+ return -1;
+
+ if (nfnl_addattr_l(&req->nlh, sizeof(buf), CTA_EXP_TIMEOUT, &timeout,
+ sizeof(timeout)) < 0)
+ return -1;
+
+ if (nfnl_send(&cth->nfnlh, (struct nlmsghdr *)&buf) < 0 ) {
+ ctnl_error("error while nfnl_send\n");
+ return -1;
+ }
+
+ return nfnl_listen(&cth->nfnlh, &list_conntrack_handler, cth);
+}
+
#if 0
int ctnl_listen(struct ctnl_handle *cth,
int (*handler)(struct sockaddr_nl *, struct nlmsghdr *n, void *),
Modified: trunk/libctnetlink/libctnetlink.h
===================================================================
--- trunk/libctnetlink/libctnetlink.h 2005-06-24 16:28:24 UTC (rev 3995)
+++ trunk/libctnetlink/libctnetlink.h 2005-06-24 16:28:49 UTC (rev 3996)
@@ -48,6 +48,12 @@
extern int ctnl_list_expect(struct ctnl_handle *cth, int family);
extern int ctnl_del_expect(struct ctnl_handle *cth,
struct ip_conntrack_tuple *t);
+extern int ctnl_new_expect(struct ctnl_handle *cth,
+ struct ip_conntrack_tuple *t,
+ struct ip_conntrack_tuple *mask,
+ struct ip_conntrack_tuple *master_tuple_orig,
+ struct ip_conntrack_tuple *master_tuple_reply,
+ unsigned long timeout);
#if 0
extern int ctnl_listen(struct ctnl_handle *ctnl,
More information about the netfilter-cvslog
mailing list