]> granicus.if.org Git - libnl/commitdiff
Abstract data allocation based on netlink attribute
authorThomas Graf <tgr@deb.localdomain>
Wed, 30 Jan 2008 12:14:38 +0000 (13:14 +0100)
committerThomas Graf <tgr@deb.localdomain>
Wed, 30 Jan 2008 12:14:38 +0000 (13:14 +0100)
include/netlink/data.h
lib/data.c

index bb28d13741fb8a5c2d2e5162e43a6ca8ef4ab139..a518a24ce8a9d6b7eae2ecf1f3b87165c14f3abd 100644 (file)
@@ -22,6 +22,7 @@ struct nl_data;
 
 /* General */
 extern struct nl_data *        nl_data_alloc(void *, size_t);
+extern struct nl_data * nl_data_alloc_from_attr(struct nlattr *);
 extern struct nl_data *        nl_data_clone(struct nl_data *);
 extern int             nl_data_append(struct nl_data *, void *, size_t);
 extern void            nl_data_free(struct nl_data *);
index 93993894c05eaab5e97a30018d0a7deed9b30ffc..7b81ceb15d00f57afbd7f7587de63c7c62112f5c 100644 (file)
@@ -60,6 +60,21 @@ errout:
        return NULL;
 }
 
+/**
+ * Allocate abstract data object based on netlink attribute.
+ * @arg nla            Netlink attribute of unspecific type.
+ *
+ * Allocates a new abstract data and copies the payload of the
+ * attribute to the abstract data object.
+ * 
+ * @see nla_data_alloc
+ * @return Newly allocated data handle or NULL
+ */
+struct nl_data *nl_data_alloc_from_attr(struct nlattr *nla)
+{
+       return nl_data_alloc(nla_data(nla), nla_len(nla));
+}
+
 /**
  * Clone an abstract data object.
  * @arg src            Abstract data object