xref: /freebsd/sbin/ipf/libipf/printhostmask.c (revision 963f5dc7a30624e95d72fb7f87b8892651164e46)
1 /*	$FreeBSD$	*/
2 
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * $Id$
9  */
10 
11 #include "ipf.h"
12 
13 
14 void
15 printhostmask(family, addr, mask)
16 	int	family;
17 	u_32_t	*addr, *mask;
18 {
19 #ifdef  USE_INET6
20 	char ipbuf[64];
21 #else
22 	struct in_addr ipa;
23 #endif
24 
25 	if ((family == -1) || ((!addr || !*addr) && (!mask || !*mask)))
26 		PRINTF("any");
27 	else {
28 #ifdef  USE_INET6
29 		void *ptr = addr;
30 
31 		PRINTF("%s", inet_ntop(family, ptr, ipbuf, sizeof(ipbuf)));
32 #else
33 		ipa.s_addr = *addr;
34 		PRINTF("%s", inet_ntoa(ipa));
35 #endif
36 		if (mask != NULL)
37 			printmask(family, mask);
38 	}
39 }
40