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