diff options
author | Thomas Graf <tgr@deb.localdomain> | 2008-01-30 12:14:58 (GMT) |
---|---|---|
committer | Thomas Graf <tgr@deb.localdomain> | 2008-01-30 12:14:58 (GMT) |
commit | 0fa6756cca2444ddf665cc140585822d6c04507a (patch) | |
tree | 0202e361d2feb81e5337fd4bb75e05abeacff803 | |
parent | 3607dbfa54e7ca775a89078f64bdcb150ea9306b (diff) | |
download | libnl-0fa6756cca2444ddf665cc140585822d6c04507a.zip libnl-0fa6756cca2444ddf665cc140585822d6c04507a.tar.gz libnl-0fa6756cca2444ddf665cc140585822d6c04507a.tar.bz2 |
Abstract address allocation based on netlink attribute
-rw-r--r-- | include/netlink/addr.h | 1 | ||||
-rw-r--r-- | lib/addr.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/netlink/addr.h b/include/netlink/addr.h index 25fce7e..8464a0c 100644 --- a/include/netlink/addr.h +++ b/include/netlink/addr.h @@ -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 *); @@ -203,6 +203,21 @@ struct nl_addr *nl_addr_build(int family, void *buf, size_t size) } /** + * 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. * @arg hint Address family hint or AF_UNSPEC. |