libnl  3.2.28
addr.h
1 /*
2  * netlink/addr.h Abstract Address
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation version 2.1
7  * of the License.
8  *
9  * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
10  */
11 
12 #ifndef NETLINK_ADDR_H_
13 #define NETLINK_ADDR_H_
14 
15 #include <netlink/netlink.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 struct nl_addr;
22 
23 /* Creation */
24 extern struct nl_addr * nl_addr_alloc(size_t);
25 extern struct nl_addr * nl_addr_alloc_attr(const struct nlattr *, int);
26 extern struct nl_addr * nl_addr_build(int, const void *, size_t);
27 extern int nl_addr_parse(const char *, int, struct nl_addr **);
28 extern struct nl_addr * nl_addr_clone(const struct nl_addr *);
29 
30 /* Usage Management */
31 extern struct nl_addr * nl_addr_get(struct nl_addr *);
32 extern void nl_addr_put(struct nl_addr *);
33 extern int nl_addr_shared(const struct nl_addr *);
34 
35 extern int nl_addr_cmp(const struct nl_addr *,
36  const struct nl_addr *);
37 extern int nl_addr_cmp_prefix(const struct nl_addr *,
38  const struct nl_addr *);
39 extern int nl_addr_iszero(const struct nl_addr *);
40 extern int nl_addr_valid(const char *, int);
41 extern int nl_addr_guess_family(const struct nl_addr *);
42 extern int nl_addr_fill_sockaddr(const struct nl_addr *,
43  struct sockaddr *, socklen_t *);
44 extern int nl_addr_info(const struct nl_addr *,
45  struct addrinfo **);
46 extern int nl_addr_resolve(const struct nl_addr *, char *, size_t);
47 
48 /* Access Functions */
49 extern void nl_addr_set_family(struct nl_addr *, int);
50 extern int nl_addr_get_family(const struct nl_addr *);
51 extern int nl_addr_set_binary_addr(struct nl_addr *, const void *,
52  size_t);
53 extern void * nl_addr_get_binary_addr(const struct nl_addr *);
54 extern unsigned int nl_addr_get_len(const struct nl_addr *);
55 extern void nl_addr_set_prefixlen(struct nl_addr *, int);
56 extern unsigned int nl_addr_get_prefixlen(const struct nl_addr *);
57 
58 /* Address Family Translations */
59 extern char * nl_af2str(int, char *, size_t);
60 extern int nl_str2af(const char *);
61 
62 /* Translations to Strings */
63 extern char * nl_addr2str(const struct nl_addr *, char *, size_t);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif
struct nl_addr * nl_addr_clone(const struct nl_addr *)
Clone existing abstract address object.
Definition: addr.c:471
struct nl_addr * nl_addr_alloc(size_t)
Allocate empty abstract address.
Definition: addr.c:185
int nl_addr_resolve(const struct nl_addr *, char *, size_t)
Resolve abstract address object to a name using getnameinfo().
Definition: addr.c:800
void nl_addr_set_prefixlen(struct nl_addr *, int)
Set the prefix length of an abstract address.
Definition: addr.c:917
int nl_addr_cmp(const struct nl_addr *, const struct nl_addr *)
Compare abstract addresses.
Definition: addr.c:563
int nl_addr_guess_family(const struct nl_addr *)
Guess address family of abstract address based on address size.
Definition: addr.c:673
unsigned int nl_addr_get_prefixlen(const struct nl_addr *)
Return prefix length of abstract address object.
Definition: addr.c:928
struct nl_addr * nl_addr_build(int, const void *, size_t)
Allocate abstract address based on a binary address.
Definition: addr.c:216
int nl_addr_parse(const char *, int, struct nl_addr **)
Allocate abstract address based on character string.
Definition: addr.c:291
struct nl_addr * nl_addr_get(struct nl_addr *)
Increase the reference counter of an abstract address.
Definition: addr.c:501
void nl_addr_set_family(struct nl_addr *, int)
Set address family.
Definition: addr.c:832
struct nl_addr * nl_addr_alloc_attr(const struct nlattr *, int)
Allocate abstract address based on Netlink attribute.
Definition: addr.c:255
int nl_addr_iszero(const struct nl_addr *)
Returns true if the address consists of all zeros.
Definition: addr.c:620
int nl_addr_set_binary_addr(struct nl_addr *, const void *, size_t)
Set binary address of abstract address object.
Definition: addr.c:870
int nl_addr_info(const struct nl_addr *, struct addrinfo **)
Call getaddrinfo() for an abstract address object.
Definition: addr.c:756
void nl_addr_put(struct nl_addr *)
Decrease the reference counter of an abstract address.
Definition: addr.c:517
int nl_addr_valid(const char *, int)
Check if address string is parseable for a specific address family.
Definition: addr.c:639
int nl_addr_fill_sockaddr(const struct nl_addr *, struct sockaddr *, socklen_t *)
Fill out sockaddr structure with values from abstract address object.
Definition: addr.c:700
int nl_addr_cmp_prefix(const struct nl_addr *, const struct nl_addr *)
Compare the prefix of two abstract addresses.
Definition: addr.c:594
unsigned int nl_addr_get_len(const struct nl_addr *)
Get length of binary address of abstract address object.
Definition: addr.c:905
void * nl_addr_get_binary_addr(const struct nl_addr *)
Get binary address of abstract address object.
Definition: addr.c:893
int nl_addr_shared(const struct nl_addr *)
Check whether an abstract address is shared.
Definition: addr.c:534
char * nl_addr2str(const struct nl_addr *, char *, size_t)
Convert abstract address object to character string.
Definition: addr.c:951
int nl_addr_get_family(const struct nl_addr *)
Return address family.
Definition: addr.c:845