xref: /freebsd/sbin/ipf/libipf/printhostmask.c (revision 1323ec57)
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( int family, u_32_t *addr, u_32_t *mask)
16 {
17 #ifdef  USE_INET6
18 	char ipbuf[64];
19 #else
20 	struct in_addr ipa;
21 #endif
22 
23 	if ((family == -1) || ((!addr || !*addr) && (!mask || !*mask)))
24 		PRINTF("any");
25 	else {
26 #ifdef  USE_INET6
27 		void *ptr = addr;
28 
29 		PRINTF("%s", inet_ntop(family, ptr, ipbuf, sizeof(ipbuf)));
30 #else
31 		ipa.s_addr = *addr;
32 		PRINTF("%s", inet_ntoa(ipa));
33 #endif
34 		if (mask != NULL)
35 			printmask(family, mask);
36 	}
37 }
38