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