summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2010-11-22 21:51:48 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2010-11-22 21:51:48 +0100
commitbbe1f68ded15a3579d26d8c3f23e9c3941296193 (patch)
tree411e86b58fbbb08290e6aaa30ffc4b137080352d
parentff4bacb058e3e084a1bf717bf5c5034e14f4ebea (diff)
downloadlibmnl-bbe1f68ded15a3579d26d8c3f23e9c3941296193.tar.gz
libmnl-bbe1f68ded15a3579d26d8c3f23e9c3941296193.zip
attr: add mnl_attr_nest_cancel()
This patch adds mnl_attr_nest_cancel() that allows to cancel the current nest that we are building. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/libmnl/libmnl.h1
-rw-r--r--src/attr.c13
-rw-r--r--src/libmnl.map1
3 files changed, 15 insertions, 0 deletions
diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index 0b581d4..dc4d3dd 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -96,6 +96,7 @@ extern void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *d
/* TLV attribute nesting */
extern struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type);
extern void mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start);
+extern void mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start);
/* TLV validation */
extern int mnl_attr_type_valid(const struct nlattr *attr, uint16_t maxtype);
diff --git a/src/attr.c b/src/attr.c
index 7357f43..16f390a 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -504,5 +504,18 @@ mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start)
}
/**
+ * mnl_attr_nest_cancel - cancel an attribute nest
+ * \param nlh pointer to the netlink message
+ * \param start pointer to the attribute nest returned by mnl_attr_nest_start()
+ *
+ * This function updates the attribute header that identifies the nest.
+ */
+EXPORT_SYMBOL void
+mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start)
+{
+ nlh->nlmsg_len -= mnl_nlmsg_get_payload_tail(nlh) - (void *)start;
+}
+
+/**
* @}
*/
diff --git a/src/libmnl.map b/src/libmnl.map
index efa2da1..4bbd06e 100644
--- a/src/libmnl.map
+++ b/src/libmnl.map
@@ -11,6 +11,7 @@ global:
mnl_attr_get_u8;
mnl_attr_nest_end;
mnl_attr_nest_start;
+ mnl_attr_nest_cancel;
mnl_attr_next;
mnl_attr_ok;
mnl_attr_parse;