[netfilter-cvslog] r4157 - trunk/libnfnetlink
laforge at netfilter.org
laforge at netfilter.org
Wed Jul 27 21:21:55 CEST 2005
Author: laforge at netfilter.org
Date: 2005-07-27 21:21:54 +0200 (Wed, 27 Jul 2005)
New Revision: 4157
Modified:
trunk/libnfnetlink/libnfnetlink.c
trunk/libnfnetlink/libnfnetlink.h
Log:
add nfnl_parse_hdr() function
Modified: trunk/libnfnetlink/libnfnetlink.c
===================================================================
--- trunk/libnfnetlink/libnfnetlink.c 2005-07-26 22:20:00 UTC (rev 4156)
+++ trunk/libnfnetlink/libnfnetlink.c 2005-07-27 19:21:54 UTC (rev 4157)
@@ -186,6 +186,25 @@
nfg->res_id = htons(res_id);
}
+struct nfattr *
+nfnl_parse_hdr(struct nfnl_handle *nfnlh, const struct nlmsghdr *nlh,
+ struct nfgenmsg **genmsg)
+{
+ if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(struct nfgenmsg)))
+ return NULL;
+
+ if (nlh->nlmsg_len == NLMSG_LENGTH(sizeof(struct nfgenmsg))) {
+ if (genmsg)
+ *genmsg = (struct nfgenmsg *)((void *)nlh+sizeof(nlh));
+ return NULL;
+ }
+
+ if (genmsg)
+ *genmsg = (struct nfgenmsg *)((void *)nlh + sizeof(nlh));
+
+ return ((void *)nlh + NLMSG_LENGTH(sizeof(struct nfgenmsg)));
+}
+
/**
* nfnl_listen: listen for one or more netlink messages
*
Modified: trunk/libnfnetlink/libnfnetlink.h
===================================================================
--- trunk/libnfnetlink/libnfnetlink.h 2005-07-26 22:20:00 UTC (rev 4156)
+++ trunk/libnfnetlink/libnfnetlink.h 2005-07-27 19:21:54 UTC (rev 4157)
@@ -38,6 +38,10 @@
unsigned int, u_int8_t, u_int16_t, u_int16_t,
u_int16_t);
+extern struct nfattr *nfnl_parse_hdr(struct nfnl_handle *nfnlh,
+ const struct nlmsghdr *nlh,
+ struct nfgenmsg **genmsg);
+
extern int nfnl_listen(struct nfnl_handle *,
int (*)(struct sockaddr_nl *, struct nlmsghdr *, void *),
void *);
More information about the netfilter-cvslog
mailing list