Use the host compiler for build tool c-ify.
[darkstat-debian] / addr.h
1 /* darkstat 3
2 * copyright (c) 2011 Emil Mikulic.
3 *
4 * addr.h: compound IPv4/IPv6 address
5 * (because struct sockaddr_storage stores too much)
6 *
7 * You may use, modify and redistribute this file under the terms of the
8 * GNU General Public License version 2. (see COPYING.GPL)
9 */
10 #ifndef __DARKSTAT_ADDR_H
11 #define __DARKSTAT_ADDR_H
12
13 #include <sys/types.h> /* for in_addr_t, at least on OpenBSD */
14 #include <sys/socket.h> /* for AF_INET6 */
15 #include <netinet/in.h> /* for in6_addr */
16
17 struct addr {
18 union {
19 in_addr_t v4;
20 struct in6_addr v6;
21 } ip;
22 enum { IPv4 = 4, IPv6 = 6 } family;
23 };
24
25 int addr_equal(const struct addr * const a, const struct addr * const b);
26 const char *addr_to_str(const struct addr * const a);
27 void addr_mask(struct addr *a, const struct addr * const mask);
28 int addr_inside(const struct addr * const a,
29 const struct addr * const net, const struct addr * const mask);
30
31 /* Returns 0 on success, gai_strerror() code otherwise. */
32 int str_to_addr(const char *s, struct addr *a);
33
34 #endif
35 /* vim:set ts=3 sw=3 tw=78 et: */