xref: /freebsd/sbin/ipf/libipf/printmask.c (revision 3e8eb5c7f4909209c042403ddee340b2ee7003a5)
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 printmask(int family, u_32_t *mask)
16 {
17 	struct in_addr ipa;
18 	int ones;
19 
20 	if (family == AF_INET6) {
21 		PRINTF("/%d", count6bits(mask));
22 	} else if ((ones = count4bits(*mask)) == -1) {
23 		ipa.s_addr = *mask;
24 		PRINTF("/%s", inet_ntoa(ipa));
25 	} else {
26 		PRINTF("/%d", ones);
27 	}
28 }
29