libnl
3.2.3
|
Creating Abstract Addresses | |
struct nl_addr * | nl_addr_alloc (size_t maxsize) |
Allocate new abstract address object. | |
struct nl_addr * | nl_addr_build (int family, void *buf, size_t size) |
Allocate new abstract address object based on a binary address. | |
struct nl_addr * | nl_addr_alloc_attr (struct nlattr *nla, int family) |
Allocate abstract address based on netlink attribute. | |
int | nl_addr_parse (const char *addrstr, int hint, struct nl_addr **result) |
Allocate abstract address object based on a character string. | |
struct nl_addr * | nl_addr_clone (struct nl_addr *addr) |
Clone existing abstract address object. | |
Managing Usage References | |
struct nl_addr * | nl_addr_get (struct nl_addr *addr) |
void | nl_addr_put (struct nl_addr *addr) |
int | nl_addr_shared (struct nl_addr *addr) |
Check whether an abstract address object is shared. | |
Miscellaneous | |
int | nl_addr_cmp (struct nl_addr *a, struct nl_addr *b) |
Compares two abstract address objects. | |
int | nl_addr_cmp_prefix (struct nl_addr *a, struct nl_addr *b) |
Compares the prefix of two abstract address objects. | |
int | nl_addr_iszero (struct nl_addr *addr) |
Returns true if the address consists of all zeros. | |
int | nl_addr_valid (char *addr, int family) |
Check if an address matches a certain family. | |
int | nl_addr_guess_family (struct nl_addr *addr) |
Guess address family of an abstract address object based on address size. | |
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. | |
Getting Information About Addresses | |
int | nl_addr_info (struct nl_addr *addr, struct addrinfo **result) |
Call getaddrinfo() for an abstract address object. | |
int | nl_addr_resolve (struct nl_addr *addr, char *host, size_t hostlen) |
Resolve abstract address object to a name using getnameinfo(). | |
Attributes | |
void | nl_addr_set_family (struct nl_addr *addr, int family) |
int | nl_addr_get_family (struct nl_addr *addr) |
int | nl_addr_set_binary_addr (struct nl_addr *addr, void *buf, size_t len) |
Set binary address of abstract address object. | |
void * | nl_addr_get_binary_addr (struct nl_addr *addr) |
Get binary address of abstract address object. | |
unsigned int | nl_addr_get_len (struct nl_addr *addr) |
Get length of binary address of abstract address object. | |
void | nl_addr_set_prefixlen (struct nl_addr *addr, int prefixlen) |
unsigned int | nl_addr_get_prefixlen (struct nl_addr *addr) |
Get prefix length of abstract address object. | |
Translations to Strings | |
char * | nl_addr2str (struct nl_addr *addr, char *buf, size_t size) |
Convert abstract address object to character string. | |
Address Family Transformations | |
char * | nl_af2str (int family, char *buf, size_t size) |
int | nl_str2af (const char *name) |
struct nl_addr *a = nl_addr_parse("::1", AF_UNSPEC); printf("Address family: %s\n", nl_af2str(nl_addr_get_family(a))); nl_addr_put(a); a = nl_addr_parse("11:22:33:44:55:66", AF_UNSPEC); printf("Address family: %s\n", nl_af2str(nl_addr_get_family(a))); nl_addr_put(a);
struct nl_addr* nl_addr_alloc | ( | size_t | maxsize | ) | [read] |
Allocate new abstract address object.
maxsize | Maximum size of the binary address. |
Definition at line 175 of file addr.c.
Referenced by nl_addr_build(), and nl_addr_parse().
struct nl_addr* nl_addr_build | ( | int | family, |
void * | buf, | ||
size_t | size | ||
) | [read] |
Allocate new abstract address object based on a binary address.
family | Address family. |
buf | Buffer containing the binary address. |
size | Length of binary address buffer. |
Definition at line 196 of file addr.c.
References nl_addr_alloc().
Referenced by nl_addr_alloc_attr(), and nl_addr_clone().
struct nl_addr* nl_addr_alloc_attr | ( | struct nlattr * | nla, |
int | family | ||
) | [read] |
Allocate abstract address based on netlink attribute.
nla | Netlink attribute of unspecific type. |
family | Address family. |
Considers the netlink attribute payload a address of the specified family and allocates a new abstract address based on it.
Definition at line 224 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 object based on a 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:
Format Len Family ---------------------------------------------------------------- IPv6 address format 16 AF_INET6 ddd.ddd.ddd.ddd 4 AF_INET HH:HH:HH:HH:HH:HH 6 AF_LLC AA{.|,}NNNN 2 AF_DECnet HH:HH:HH:... variable AF_UNSPEC
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 256 of file addr.c.
References nl_addr_alloc(), and nl_addr_set_binary_addr().
struct nl_addr* nl_addr_clone | ( | struct nl_addr * | addr | ) | [read] |
Clone existing abstract address object.
addr | Abstract address object. |
Definition at line 431 of file addr.c.
References nl_addr_build().
int nl_addr_shared | ( | struct nl_addr * | addr | ) |
int nl_addr_cmp | ( | struct nl_addr * | a, |
struct nl_addr * | b | ||
) |
Compares two abstract address objects.
a | A abstract address object. |
b | Another abstract address object. |
is
found, respectively to be less than, to, or be greater than b
. Definition at line 492 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 | ||
) |
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 617 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 673 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 717 of file addr.c.
References nl_addr_fill_sockaddr().
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. |
Definition at line 758 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 773 of file addr.c.
Referenced by flnl_lookup_build_request(), and nla_put_addr().
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 782 of file addr.c.
Referenced by nla_put_addr().
unsigned int nl_addr_get_prefixlen | ( | struct nl_addr * | addr | ) |
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 819 of file addr.c.
Referenced by nl_addr_info().