summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2005-07-21 23:37:52 +0000
committer/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2005-07-21 23:37:52 +0000
commitf69063298af00767f999bde50f394dfa6e1d76bc (patch)
tree962639dfc7a76f0a9cc8a0751a05682d6f21679f
parenta0ca0df7c2acb455ca57be4c13704593b422dfd8 (diff)
- add support for nfnetlink version field
- add res_id parameter to nfnl_fill_hdr() - add nested attribute macros
-rw-r--r--libnfnetlink.c12
-rw-r--r--libnfnetlink.h7
2 files changed, 13 insertions, 6 deletions
diff --git a/libnfnetlink.c b/libnfnetlink.c
index cff2fcf..debc8fe 100644
--- a/libnfnetlink.c
+++ b/libnfnetlink.c
@@ -1,7 +1,7 @@
/* libnfnetlink.c: generic library for communication with netfilter
*
* (C) 2001 by Jay Schulist <jschlst@samba.org>
- * (C) 2002 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2002-2005 by Harald Welte <laforge@gnumonks.org>
*
* Development of this code funded by Astaro AG (http://www.astaro.com)
*
@@ -63,7 +63,8 @@ void nfnl_dump_packet(struct nlmsghdr *nlh, int received_len, char *desc)
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 @@ int nfnl_send(struct nfnl_handle *nfnlh, struct nlmsghdr *n)
* 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 @@ int nfnl_send(struct nfnl_handle *nfnlh, struct nlmsghdr *n)
*
*/
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 @@ void nfnl_fill_hdr(struct nfnl_handle *nfnlh,
nlh->nlmsg_seq = ++nfnlh->seq;
nfg->nfgen_family = family;
-
+ nfg->version = NFNETLINK_V0;
+ nfg->res_id = htons(res_id);
}
/**
diff --git a/libnfnetlink.h b/libnfnetlink.h
index 9761eed..ebf61f2 100644
--- a/libnfnetlink.h
+++ b/libnfnetlink.h
@@ -30,8 +30,9 @@ extern int nfnl_close(struct nfnl_handle *);
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_addattr32(struct nlmsghdr *, int, int, u_int32_t);
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); \