[netfilter-cvslog] r4144 - trunk/libnfnetlink

laforge at netfilter.org laforge at netfilter.org
Fri Jul 22 01:37:58 CEST 2005


Author: laforge at netfilter.org
Date: 2005-07-22 01:37:52 +0200 (Fri, 22 Jul 2005)
New Revision: 4144

Modified:
   trunk/libnfnetlink/libnfnetlink.c
   trunk/libnfnetlink/libnfnetlink.h
Log:
- add support for nfnetlink version field
- add res_id parameter to nfnl_fill_hdr()
- add nested attribute macros


Modified: trunk/libnfnetlink/libnfnetlink.c
===================================================================
--- trunk/libnfnetlink/libnfnetlink.c	2005-07-21 02:00:51 UTC (rev 4143)
+++ trunk/libnfnetlink/libnfnetlink.c	2005-07-21 23:37:52 UTC (rev 4144)
@@ -1,7 +1,7 @@
 /* libnfnetlink.c: generic library for communication with netfilter
  *
  * (C) 2001 by Jay Schulist <jschlst at samba.org>
- * (C) 2002 by Harald Welte <laforge at gnumonks.org>
+ * (C) 2002-2005 by Harald Welte <laforge at gnumonks.org>
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com)
  *
@@ -63,7 +63,8 @@
 int nfnl_open(struct nfnl_handle *nfnlh, u_int8_t subsys_id,
 	      u_int32_t subscriptions)
 {
-	int err, addr_len;
+	int err;
+	unsigned int addr_len;
 	
 	memset(nfnlh, 0, sizeof(*nfnlh));
 	nfnlh->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER);
@@ -137,6 +138,7 @@
  * nlh: netlink header to be filled in
  * len: length of _payload_ bytes (not including nfgenmsg)
  * family: AF_INET / ...
+ * res_id: resource id
  * msg_type: nfnetlink message type (without subsystem)
  * msg_flags: netlink message flags
  *
@@ -145,8 +147,9 @@
  *
  */
 void nfnl_fill_hdr(struct nfnl_handle *nfnlh,
-		    struct nlmsghdr *nlh, int len, 
+		    struct nlmsghdr *nlh, unsigned int len, 
 		    u_int8_t family,
+		    u_int16_t res_id,
 		    u_int16_t msg_type,
 		    u_int16_t msg_flags)
 {
@@ -160,7 +163,8 @@
 	nlh->nlmsg_seq = ++nfnlh->seq;
 
 	nfg->nfgen_family = family;
-
+	nfg->version = NFNETLINK_V0;
+	nfg->res_id = htons(res_id);
 }
 
 /**

Modified: trunk/libnfnetlink/libnfnetlink.h
===================================================================
--- trunk/libnfnetlink/libnfnetlink.h	2005-07-21 02:00:51 UTC (rev 4143)
+++ trunk/libnfnetlink/libnfnetlink.h	2005-07-21 23:37:52 UTC (rev 4144)
@@ -30,8 +30,9 @@
 extern int nfnl_send(struct nfnl_handle *, struct nlmsghdr *);
 
 
-extern void nfnl_fill_hdr(struct nfnl_handle *, struct nlmsghdr *, int,
-                          u_int8_t, u_int16_t, u_int16_t);
+extern void nfnl_fill_hdr(struct nfnl_handle *, struct nlmsghdr *,
+			  unsigned int, u_int8_t, u_int16_t, u_int16_t,
+			  u_int16_t);
 
 extern int nfnl_listen(struct nfnl_handle *,
                       int (*)(struct sockaddr_nl *, struct nlmsghdr *, void *),
@@ -48,6 +49,8 @@
 extern int nfnl_nfa_addattr_l(struct nfattr *, int, int, void *, int);
 extern int nfnl_nfa_addattr32(struct nfattr *, int, int, u_int32_t);
 extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int);
+#define nfnl_parse_nested(tb, max, nfa) \
+	nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa)))
 #define nfnl_nest(nlh, bufsize, type) 				\
 ({	struct nfattr *__start = NLMSG_TAIL(nlh);		\
 	nfnl_addattr_l(nlh, bufsize, type, NULL, 0); 		\




More information about the netfilter-cvslog mailing list