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

index 25fce7e25b5eaa630997498e50332b1768e7f1d1..8464a0cdc13c269eac3c4c2468cd7a0762350657 100644 (file)
@@ -22,6 +22,7 @@ struct nl_addr;
 
 /* Creation */
 extern struct nl_addr *        nl_addr_alloc(size_t);
+extern struct nl_addr *        nl_addr_alloc_from_attr(struct nlattr *, int);
 extern struct nl_addr *        nl_addr_build(int, void *, size_t);
 extern struct nl_addr *        nl_addr_parse(const char *, int);
 extern struct nl_addr *        nl_addr_clone(struct nl_addr *);
index 68f77410d65fba76d20eed4a40df75b9f14e9847..70e4b1d2ffda7b3ae97a9c6622cdbfb8a96ad58c 100644 (file)
@@ -202,6 +202,21 @@ struct nl_addr *nl_addr_build(int family, void *buf, size_t size)
        return addr;
 }
 
+/**
+ * Allocate abstract address based on netlink attribute.
+ * @arg nla            Netlink attribute of unspecific type.
+ * @arg family         Address family.
+ *
+ * Considers the netlink attribute payload a address of the specified
+ * family and allocates a new abstract address based on it.
+ *
+ * @return Newly allocated address handle or NULL.
+ */
+struct nl_addr *nl_addr_alloc_from_attr(struct nlattr *nla, int family)
+{
+       return nl_addr_build(family, nla_data(nla), nla_len(nla));
+}
+
 /**
  * Allocate abstract address object based on a character string
  * @arg addrstr                Address represented as character string.