libnl
3.2.24-rc1
|
Abstract data type representing any kind of network address. More...
Creating Abstract Network Addresses | |
struct nl_addr * | nl_addr_alloc (size_t maxsize) |
Allocate empty abstract address. More... | |
struct nl_addr * | nl_addr_build (int family, void *buf, size_t size) |
Allocate abstract address based on a binary address. More... | |
struct nl_addr * | nl_addr_alloc_attr (struct nlattr *nla, int family) |
Allocate abstract address based on Netlink attribute. More... | |
int | nl_addr_parse (const char *addrstr, int hint, struct nl_addr **result) |
Allocate abstract address based on character string. More... | |
struct nl_addr * | nl_addr_clone (struct nl_addr *addr) |
Clone existing abstract address object. More... | |
Managing Usage References | |
struct nl_addr * | nl_addr_get (struct nl_addr *addr) |
Increase the reference counter of an abstract address. More... | |
void | nl_addr_put (struct nl_addr *addr) |
Decrease the reference counter of an abstract address. More... | |
int | nl_addr_shared (struct nl_addr *addr) |
Check whether an abstract address is shared. More... | |
Miscellaneous | |
int | nl_addr_cmp (struct nl_addr *a, struct nl_addr *b) |
Compare abstract addresses. More... | |
int | nl_addr_cmp_prefix (struct nl_addr *a, struct nl_addr *b) |
Compare the prefix of two abstract addresses. More... | |
int | nl_addr_iszero (struct nl_addr *addr) |
Returns true if the address consists of all zeros. More... | |
int | nl_addr_valid (char *addr, int family) |
Check if address string is parseable for a specific address family. More... | |
int | nl_addr_guess_family (struct nl_addr *addr) |
Guess address family of abstract address based on address size. More... | |
int | nl_addr_fill_sockaddr (struct nl_addr *addr, struct sockaddr *sa, socklen_t *salen) |
Fill out sockaddr structure with values from abstract address object. More... | |
Getting Information About Addresses | |
int | nl_addr_info (struct nl_addr *addr, struct addrinfo **result) |
Call getaddrinfo() for an abstract address object. More... | |
int | nl_addr_resolve (struct nl_addr *addr, char *host, size_t hostlen) |
Resolve abstract address object to a name using getnameinfo(). More... | |
Attributes | |
void | nl_addr_set_family (struct nl_addr *addr, int family) |
Set address family. More... | |
int | nl_addr_get_family (struct nl_addr *addr) |
Return address family. More... | |
int | nl_addr_set_binary_addr (struct nl_addr *addr, void *buf, size_t len) |
Set binary address of abstract address object. More... | |
void * | nl_addr_get_binary_addr (struct nl_addr *addr) |
Get binary address of abstract address object. More... | |
unsigned int | nl_addr_get_len (struct nl_addr *addr) |
Get length of binary address of abstract address object. More... | |
void | nl_addr_set_prefixlen (struct nl_addr *addr, int prefixlen) |
Set the prefix length of an abstract address. More... | |
unsigned int | nl_addr_get_prefixlen (struct nl_addr *addr) |
Return prefix length of abstract address object. More... | |
Translations to Strings | |
char * | nl_addr2str (struct nl_addr *addr, char *buf, size_t size) |
Convert abstract address object to character string. More... | |
Address Family Transformations | |
char * | nl_af2str (int family, char *buf, size_t size) |
int | nl_str2af (const char *name) |
Abstract data type representing any kind of network address.
Related sections in the development guide:
|
read |
Allocate empty abstract address.
maxsize | Upper limit of the binary address to be stored |
The new address object will be empty with a prefix length of 0 and will be capable of holding binary addresses up to the specified limit.
Definition at line 185 of file addr.c.
Referenced by nl_addr_build(), and nl_addr_parse().
|
read |
Allocate abstract address based on a binary address.
family | Address family |
buf | Binary address |
size | Length of binary address |
This function will allocate an abstract address capable of holding the binary address specified. The prefix length will be set to the full length of the binary address provided.
Definition at line 216 of file addr.c.
References nl_addr_alloc().
Referenced by nl_addr_alloc_attr(), nl_addr_clone(), rtnl_link_vxlan_get_group(), and rtnl_link_vxlan_get_local().
|
read |
Allocate abstract address based on Netlink attribute.
nla | Netlink attribute |
family | Address family. |
Allocates an abstract address based on the specified Netlink attribute by interpreting the payload of the Netlink attribute as the binary address.
This function is identical to:
Definition at line 255 of file addr.c.
References nl_addr_build(), nla_data(), and nla_len().
int nl_addr_parse | ( | const char * | addrstr, |
int | hint, | ||
struct nl_addr ** | result | ||
) |
Allocate abstract address based on character string.
addrstr | Address represented as character string. |
hint | Address family hint or AF_UNSPEC. |
result | Pointer to store resulting address. |
Regognizes the following address formats:
Special values:
The prefix length may be appened at the end prefixed with a slash, e.g. 10.0.0.0/8.
Definition at line 291 of file addr.c.
References nl_addr_alloc(), nl_addr_set_binary_addr(), nl_addr_set_family(), and nl_addr_set_prefixlen().
|
read |
Clone existing abstract address object.
addr | Abstract address object |
Allocates new abstract address representing an identical clone of an existing address.
Definition at line 471 of file addr.c.
References nl_addr_build().
|
read |
Increase the reference counter of an abstract address.
addr | Abstract address |
Increases the reference counter of the address and thus prevents the release of the memory resources until the reference is given back using the function nl_addr_put().
void nl_addr_put | ( | struct nl_addr * | addr | ) |
Decrease the reference counter of an abstract address.
addr | Abstract addr |
int nl_addr_shared | ( | struct nl_addr * | addr | ) |
int nl_addr_cmp | ( | struct nl_addr * | a, |
struct nl_addr * | b | ||
) |
Compare abstract addresses.
a | An abstract address |
b | Another abstract address |
Verifies whether the address family, address length, prefix length, and binary addresses of two abstract addresses matches.
Definition at line 563 of file addr.c.
Referenced by rtnl_addr_get(), and rtnl_neigh_get().
int nl_addr_cmp_prefix | ( | struct nl_addr * | a, |
struct nl_addr * | b | ||
) |
Compare the prefix of two abstract addresses.
a | An abstract address |
b | Another abstract address |
Verifies whether the address family and the binary address covered by the smaller prefix length of the two abstract addresses matches.
int nl_addr_iszero | ( | struct nl_addr * | addr | ) |
int nl_addr_valid | ( | char * | addr, |
int | family | ||
) |
int nl_addr_guess_family | ( | struct nl_addr * | addr | ) |
int nl_addr_fill_sockaddr | ( | struct nl_addr * | addr, |
struct sockaddr * | sa, | ||
socklen_t * | salen | ||
) |
Fill out sockaddr structure with values from abstract address object.
addr | Abstract address object. |
sa | Destination sockaddr structure buffer. |
salen | Length of sockaddr structure buffer. |
Fills out the specified sockaddr structure with the data found in the specified abstract address. The salen argument needs to be set to the size of sa but will be modified to the actual size used during before the function exits.
Definition at line 700 of file addr.c.
Referenced by nl_addr_resolve().
int nl_addr_info | ( | struct nl_addr * | addr, |
struct addrinfo ** | result | ||
) |
Call getaddrinfo() for an abstract address object.
addr | Abstract address object. |
result | Pointer to store resulting address list. |
Calls getaddrinfo() for the specified abstract address in AI_NUMERICHOST mode.
Definition at line 756 of file addr.c.
References nl_addr2str().
int nl_addr_resolve | ( | struct nl_addr * | addr, |
char * | host, | ||
size_t | hostlen | ||
) |
Resolve abstract address object to a name using getnameinfo().
addr | Abstract address object. |
host | Destination buffer for host name. |
hostlen | Length of destination buffer. |
Resolves the abstract address to a name and writes the looked up result into the host buffer. getnameinfo() is used to perform the lookup and is put into NI_NAMEREQD mode so the function will fail if the lookup couldn't be performed.
Definition at line 800 of file addr.c.
References nl_addr_fill_sockaddr().
void nl_addr_set_family | ( | struct nl_addr * | addr, |
int | family | ||
) |
Set address family.
addr | Abstract address object |
family | Address family |
Definition at line 832 of file addr.c.
Referenced by nl_addr_parse().
int nl_addr_get_family | ( | struct nl_addr * | addr | ) |
Return address family.
addr | Abstract address object |
AF_UNSPEC
Definition at line 845 of file addr.c.
Referenced by rtnl_link_vxlan_set_group(), and rtnl_link_vxlan_set_local().
int nl_addr_set_binary_addr | ( | struct nl_addr * | addr, |
void * | buf, | ||
size_t | len | ||
) |
Set binary address of abstract address object.
addr | Abstract address object. |
buf | Buffer containing binary address. |
len | Length of buffer containing binary address. |
Modifies the binary address portion of the abstract address. The abstract address must be capable of holding the required amount or this function will fail.
Definition at line 870 of file addr.c.
Referenced by nl_addr_parse().
void* nl_addr_get_binary_addr | ( | struct nl_addr * | addr | ) |
Get binary address of abstract address object.
addr | Abstract address object. |
Definition at line 893 of file addr.c.
Referenced by flnl_lookup_build_request(), nla_put_addr(), rtnl_link_vxlan_set_group(), and rtnl_link_vxlan_set_local().
unsigned int nl_addr_get_len | ( | struct nl_addr * | addr | ) |
Get length of binary address of abstract address object.
addr | Abstract address object. |
Definition at line 905 of file addr.c.
Referenced by nla_put_addr(), rtnl_link_vxlan_set_group(), and rtnl_link_vxlan_set_local().
void nl_addr_set_prefixlen | ( | struct nl_addr * | addr, |
int | prefixlen | ||
) |
Set the prefix length of an abstract address.
addr | Abstract address object |
prefixlen | New prefix length |
Definition at line 917 of file addr.c.
Referenced by nl_addr_parse(), and rtnl_addr_set_prefixlen().
unsigned int nl_addr_get_prefixlen | ( | struct nl_addr * | addr | ) |
Return prefix length of abstract address object.
addr | Abstract address object |
char* nl_addr2str | ( | struct nl_addr * | addr, |
char * | buf, | ||
size_t | size | ||
) |
Convert abstract address object to character string.
addr | Abstract address object. |
buf | Destination buffer. |
size | Size of destination buffer. |
Converts an abstract address to a character string and stores the result in the specified destination buffer.
Definition at line 951 of file addr.c.
Referenced by nl_addr_info().