libnl 3.7.0
|
Abstract data type representing any kind of network address. More...
Address Family Transformations | |
char * | nl_af2str (int family, char *buf, size_t size) |
int | nl_str2af (const char *name) |
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, const void *buf, size_t size) |
Allocate abstract address based on a binary address. More... | |
struct nl_addr * | nl_addr_alloc_attr (const 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 (const 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 (const struct nl_addr *addr) |
Check whether an abstract address is shared. More... | |
Miscellaneous | |
int | nl_addr_cmp (const struct nl_addr *a, const struct nl_addr *b) |
Compare abstract addresses. More... | |
int | nl_addr_cmp_prefix (const struct nl_addr *a, const struct nl_addr *b) |
Compare the prefix of two abstract addresses. More... | |
int | nl_addr_iszero (const struct nl_addr *addr) |
Returns true if the address consists of all zeros. More... | |
int | nl_addr_valid (const char *addr, int family) |
Check if address string is parseable for a specific address family. More... | |
int | nl_addr_guess_family (const struct nl_addr *addr) |
Guess address family of abstract address based on address size. More... | |
int | nl_addr_fill_sockaddr (const 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 (const struct nl_addr *addr, struct addrinfo **result) |
Call getaddrinfo() for an abstract address object. More... | |
int | nl_addr_resolve (const 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 (const struct nl_addr *addr) |
Return address family. More... | |
int | nl_addr_set_binary_addr (struct nl_addr *addr, const void *buf, size_t len) |
Set binary address of abstract address object. More... | |
void * | nl_addr_get_binary_addr (const struct nl_addr *addr) |
Get binary address of abstract address object. More... | |
unsigned int | nl_addr_get_len (const 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 (const struct nl_addr *addr) |
Return prefix length of abstract address object. More... | |
Translations to Strings | |
char * | nl_addr2str (const struct nl_addr *addr, char *buf, size_t size) |
Convert abstract address object to character string. More... | |
Abstract data type representing any kind of network address.
Related sections in the development guide:
struct nl_addr * nl_addr_alloc | ( | size_t | maxsize | ) |
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 180 of file addr.c.
Referenced by nl_addr_build(), and nl_addr_parse().
struct nl_addr * nl_addr_build | ( | int | family, |
const void * | buf, | ||
size_t | size | ||
) |
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 211 of file addr.c.
References nl_addr_alloc().
Referenced by nl_addr_alloc_attr(), nl_addr_clone(), rtnl_link_geneve_get_remote(), rtnl_link_vxlan_get_group(), and rtnl_link_vxlan_get_local().
struct nl_addr * nl_addr_alloc_attr | ( | const struct nlattr * | nla, |
int | family | ||
) |
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 256 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 292 of file addr.c.
References nl_addr_alloc(), nl_addr_set_binary_addr(), nl_addr_set_family(), and nl_addr_set_prefixlen().
struct nl_addr * nl_addr_clone | ( | const struct nl_addr * | addr | ) |
Clone existing abstract address object.
addr | Abstract address object |
Allocates new abstract address representing an identical clone of an existing address.
Definition at line 492 of file addr.c.
References nl_addr_build().
Referenced by rtnl_link_macvlan_add_macaddr(), xfrmnl_sel_clone(), and xfrmnl_user_tmpl_clone().
struct nl_addr * nl_addr_get | ( | struct nl_addr * | addr | ) |
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().
Definition at line 522 of file addr.c.
Referenced by rtnl_link_macvlan_del_macaddr(), and rtnl_link_vf_set_addr().
void nl_addr_put | ( | struct nl_addr * | addr | ) |
Decrease the reference counter of an abstract address.
addr | Abstract addr |
Definition at line 538 of file addr.c.
Referenced by rtnl_link_macvlan_del_macaddr(), rtnl_link_macvlan_set_mode(), rtnl_link_vf_free(), and rtnl_link_vf_set_addr().
int nl_addr_shared | ( | const struct nl_addr * | addr | ) |
int nl_addr_cmp | ( | const struct nl_addr * | a, |
const 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 584 of file addr.c.
Referenced by rtnl_addr_get(), rtnl_link_macvlan_del_macaddr(), rtnl_neigh_get(), and rtnl_neigh_get_by_vlan().
int nl_addr_cmp_prefix | ( | const struct nl_addr * | a, |
const 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.
Definition at line 623 of file addr.c.
Referenced by xfrmnl_sel_cmp(), and xfrmnl_user_tmpl_cmp().
int nl_addr_iszero | ( | const struct nl_addr * | addr | ) |
int nl_addr_valid | ( | const char * | addr, |
int | family | ||
) |
int nl_addr_guess_family | ( | const struct nl_addr * | addr | ) |
int nl_addr_fill_sockaddr | ( | const 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 735 of file addr.c.
Referenced by nl_addr_resolve().
int nl_addr_info | ( | const 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 803 of file addr.c.
References nl_addr2str().
int nl_addr_resolve | ( | const 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 847 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 879 of file addr.c.
Referenced by nl_addr_parse().
int nl_addr_get_family | ( | const struct nl_addr * | addr | ) |
Return address family.
addr | Abstract address object |
AF_UNSPEC
Definition at line 892 of file addr.c.
Referenced by rtnl_link_geneve_set_remote(), rtnl_link_macvlan_add_macaddr(), rtnl_link_macvlan_del_macaddr(), rtnl_link_vxlan_set_group(), and rtnl_link_vxlan_set_local().
int nl_addr_set_binary_addr | ( | struct nl_addr * | addr, |
const 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 917 of file addr.c.
Referenced by nl_addr_parse().
void * nl_addr_get_binary_addr | ( | const struct nl_addr * | addr | ) |
Get binary address of abstract address object.
addr | Abstract address object. |
Definition at line 940 of file addr.c.
Referenced by flnl_lookup_build_request(), nla_put_addr(), rtnl_link_geneve_set_remote(), rtnl_link_vxlan_set_group(), and rtnl_link_vxlan_set_local().
unsigned int nl_addr_get_len | ( | const struct nl_addr * | addr | ) |
Get length of binary address of abstract address object.
addr | Abstract address object. |
Definition at line 952 of file addr.c.
Referenced by nla_put_addr(), rtnl_link_geneve_set_remote(), 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 964 of file addr.c.
Referenced by nl_addr_parse(), and rtnl_addr_set_prefixlen().
unsigned int nl_addr_get_prefixlen | ( | const struct nl_addr * | addr | ) |
Return prefix length of abstract address object.
addr | Abstract address object |
char * nl_addr2str | ( | const 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 998 of file addr.c.
Referenced by nl_addr_info().