2 * Copyright (c) 2004,2005 Damien Miller <djm@mindrot.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 /* Address handling routines */
22 #include <sys/socket.h>
23 #include <netinet/in.h>
33 } xa
; /* 128-bit address */
34 u_int32_t scope_id
; /* iface scope id for v6 */
37 #define addr8 xa.addr8
38 #define addr16 xa.addr16
39 #define addr32 xa.addr32
42 int addr_sa_to_xaddr(struct sockaddr
*sa
, socklen_t slen
, struct xaddr
*xa
);
43 int addr_netmask(int af
, u_int l
, struct xaddr
*n
);
44 int addr_pton(const char *p
, struct xaddr
*n
);
45 int addr_pton_cidr(const char *p
, struct xaddr
*n
, u_int
*l
);
46 int addr_ntop(const struct xaddr
*n
, char *p
, size_t len
);
47 int addr_and(struct xaddr
*dst
, const struct xaddr
*a
, const struct xaddr
*b
);
48 int addr_cmp(const struct xaddr
*a
, const struct xaddr
*b
);
49 int addr_host_to_all1s(struct xaddr
*a
, u_int masklen
);
50 int addr_netmatch(const struct xaddr
*host
, const struct xaddr
*net
,
52 void addr_increment(struct xaddr
*a
);