From: Thomas Graf Date: Wed, 30 Jan 2008 12:14:38 +0000 (+0100) Subject: Abstract data allocation based on netlink attribute X-Git-Tag: libnl2_0~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3607dbfa54e7ca775a89078f64bdcb150ea9306b;p=thirdparty%2Flibnl.git Abstract data allocation based on netlink attribute --- diff --git a/include/netlink/data.h b/include/netlink/data.h index bb28d13..a518a24 100644 --- a/include/netlink/data.h +++ b/include/netlink/data.h @@ -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 *); diff --git a/lib/data.c b/lib/data.c index 9399389..7b81ceb 100644 --- a/lib/data.c +++ b/lib/data.c @@ -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