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 nlattr; 22 23 struct nl_addr; 24 25 /* Creation */ 26 extern struct nl_addr * nl_addr_alloc(size_t); 27 extern struct nl_addr * nl_addr_alloc_attr(const struct nlattr *, int); 28 extern struct nl_addr * nl_addr_build(int, const void *, size_t); 29 extern int nl_addr_parse(const char *, int, struct nl_addr **); 30 extern struct nl_addr * nl_addr_clone(const 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(const struct nl_addr *); 36 37 extern int nl_addr_cmp(const struct nl_addr *, 38 const struct nl_addr *); 39 extern int nl_addr_cmp_prefix(const struct nl_addr *, 40 const struct nl_addr *); 41 extern int nl_addr_iszero(const struct nl_addr *); 42 extern int nl_addr_valid(const char *, int); 43 extern int nl_addr_guess_family(const struct nl_addr *); 44 extern int nl_addr_fill_sockaddr(const struct nl_addr *, 45 struct sockaddr *, socklen_t *); 46 extern int nl_addr_info(const struct nl_addr *, 47 struct addrinfo **); 48 extern int nl_addr_resolve(const struct nl_addr *, char *, size_t); 49 50 /* Access Functions */ 51 extern void nl_addr_set_family(struct nl_addr *, int); 52 extern int nl_addr_get_family(const struct nl_addr *); 53 extern int nl_addr_set_binary_addr(struct nl_addr *, const void *, 54 size_t); 55 extern void * nl_addr_get_binary_addr(const struct nl_addr *); 56 extern unsigned int nl_addr_get_len(const struct nl_addr *); 57 extern void nl_addr_set_prefixlen(struct nl_addr *, int); 58 extern unsigned int nl_addr_get_prefixlen(const struct nl_addr *); 59 60 /* Address Family Translations */ 61 extern char * nl_af2str(int, char *, size_t); 62 extern int nl_str2af(const char *); 63 64 /* Translations to Strings */ 65 extern char * nl_addr2str(const struct nl_addr *, char *, size_t); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif 72