addr.h

00001 /*
00002  * netlink/addr.h               Abstract Address
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #ifndef NETLINK_ADDR_H_
00013 #define NETLINK_ADDR_H_
00014 
00015 #include <netlink/netlink.h>
00016 
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 struct nl_addr;
00022 
00023 /* Creation */
00024 extern struct nl_addr * nl_addr_alloc(size_t);
00025 extern struct nl_addr * nl_addr_alloc_attr(struct nlattr *, int);
00026 extern struct nl_addr * nl_addr_build(int, void *, size_t);
00027 extern int              nl_addr_parse(const char *, int, struct nl_addr **);
00028 extern struct nl_addr * nl_addr_clone(struct nl_addr *);
00029 
00030 /* Usage Management */
00031 extern struct nl_addr * nl_addr_get(struct nl_addr *);
00032 extern void             nl_addr_put(struct nl_addr *);
00033 extern int              nl_addr_shared(struct nl_addr *);
00034 
00035 extern int              nl_addr_cmp(struct nl_addr *, struct nl_addr *);
00036 extern int              nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
00037 extern int              nl_addr_iszero(struct nl_addr *);
00038 extern int              nl_addr_valid(char *, int);
00039 extern int              nl_addr_guess_family(struct nl_addr *);
00040 extern int              nl_addr_fill_sockaddr(struct nl_addr *,
00041                                               struct sockaddr *, socklen_t *);
00042 extern int              nl_addr_info(struct nl_addr *, struct addrinfo **);
00043 extern int              nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen);
00044 
00045 /* Access Functions */
00046 extern void             nl_addr_set_family(struct nl_addr *, int);
00047 extern int              nl_addr_get_family(struct nl_addr *);
00048 extern int              nl_addr_set_binary_addr(struct nl_addr *, void *,
00049                                                 size_t);
00050 extern void *           nl_addr_get_binary_addr(struct nl_addr *);
00051 extern unsigned int     nl_addr_get_len(struct nl_addr *);
00052 extern void             nl_addr_set_prefixlen(struct nl_addr *, int);
00053 extern unsigned int     nl_addr_get_prefixlen(struct nl_addr *);
00054 
00055 /* Address Family Translations */
00056 extern char *           nl_af2str(int, char *, size_t);
00057 extern int              nl_str2af(const char *);
00058 
00059 /* Translations to Strings */
00060 extern char *           nl_addr2str(struct nl_addr *, char *, size_t);
00061 
00062 #ifdef __cplusplus
00063 }
00064 #endif
00065 
00066 #endif