blob: cc3d201f97814c4e4beb76fbad1db69d24f4666a [file] [log] [blame]
Frank Makered6b39c2011-05-23 21:14:58 -07001/*
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-2008 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
18extern "C" {
19#endif
20
21struct nl_addr;
22
23/* Creation */
24extern struct nl_addr * nl_addr_alloc(size_t);
25extern struct nl_addr * nl_addr_alloc_attr(struct nlattr *, int);
26extern struct nl_addr * nl_addr_build(int, void *, size_t);
27extern int nl_addr_parse(const char *, int, struct nl_addr **);
28extern struct nl_addr * nl_addr_clone(struct nl_addr *);
29
30/* Destroyage */
31extern void nl_addr_destroy(struct nl_addr *);
32
33/* Usage Management */
34extern struct nl_addr * nl_addr_get(struct nl_addr *);
35extern void nl_addr_put(struct nl_addr *);
36extern int nl_addr_shared(struct nl_addr *);
37
38extern int nl_addr_cmp(struct nl_addr *, struct nl_addr *);
39extern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
40extern int nl_addr_iszero(struct nl_addr *);
41extern int nl_addr_valid(char *, int);
42extern int nl_addr_guess_family(struct nl_addr *);
43extern int nl_addr_fill_sockaddr(struct nl_addr *,
44 struct sockaddr *, socklen_t *);
45extern int nl_addr_info(struct nl_addr *, struct addrinfo **);
46extern int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen);
47
48/* Access Functions */
49extern void nl_addr_set_family(struct nl_addr *, int);
50extern int nl_addr_get_family(struct nl_addr *);
51extern int nl_addr_set_binary_addr(struct nl_addr *, void *,
52 size_t);
53extern void * nl_addr_get_binary_addr(struct nl_addr *);
54extern unsigned int nl_addr_get_len(struct nl_addr *);
55extern void nl_addr_set_prefixlen(struct nl_addr *, int);
56extern unsigned int nl_addr_get_prefixlen(struct nl_addr *);
57
58/* Address Family Translations */
59extern char * nl_af2str(int, char *, size_t);
60extern int nl_str2af(const char *);
61
62/* Translations to Strings */
63extern char * nl_addr2str(struct nl_addr *, char *, size_t);
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif