libnl  1.1
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-2006 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_build(int, void *, size_t);
26 extern struct nl_addr * nl_addr_parse(const char *, int);
27 extern struct nl_addr * nl_addr_clone(struct nl_addr *);
28 
29 /* Destroyage */
30 extern void nl_addr_destroy(struct nl_addr *);
31 
32 /* Usage Management */
33 extern struct nl_addr * nl_addr_get(struct nl_addr *);
34 extern void nl_addr_put(struct nl_addr *);
35 extern int nl_addr_shared(struct nl_addr *);
36 
37 extern int nl_addr_cmp(struct nl_addr *, struct nl_addr *);
38 extern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
39 extern int nl_addr_iszero(struct nl_addr *);
40 extern int nl_addr_valid(char *, int);
41 extern int nl_addr_guess_family(struct nl_addr *);
42 extern int nl_addr_fill_sockaddr(struct nl_addr *,
43  struct sockaddr *, socklen_t *);
44 extern struct addrinfo *nl_addr_info(struct nl_addr *addr);
45 extern int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen);
46 
47 /* Access Functions */
48 extern void nl_addr_set_family(struct nl_addr *, int);
49 extern int nl_addr_get_family(struct nl_addr *);
50 extern int nl_addr_set_binary_addr(struct nl_addr *, void *,
51  size_t);
52 extern void * nl_addr_get_binary_addr(struct nl_addr *);
53 extern unsigned int nl_addr_get_len(struct nl_addr *);
54 extern void nl_addr_set_prefixlen(struct nl_addr *, int);
55 extern unsigned int nl_addr_get_prefixlen(struct nl_addr *);
56 
57 /* Address Family Translations */
58 extern char * nl_af2str(int, char *, size_t);
59 extern int nl_str2af(const char *);
60 
61 /* Translations to Strings */
62 extern char * nl_addr2str(struct nl_addr *, char *, size_t);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif