summaryrefslogtreecommitdiffstats
path: root/libnfnetlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnfnetlink.c')
-rw-r--r--libnfnetlink.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libnfnetlink.c b/libnfnetlink.c
index f0997fd..80cb0c4 100644
--- a/libnfnetlink.c
+++ b/libnfnetlink.c
@@ -186,6 +186,25 @@ void nfnl_fill_hdr(struct nfnl_handle *nfnlh,
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
*