Abstract address allocation based on netlink attribute

This commit is contained in:
Thomas Graf 2008-01-30 13:14:58 +01:00
parent 3607dbfa54
commit 0fa6756cca
2 changed files with 16 additions and 0 deletions

View 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 *);

View 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.