xref: /titanic_50/usr/src/cmd/ipf/lib/common/printmask.c (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * Copyright (C) 1993-2001 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: printmask.c,v 1.5 2002/06/15 04:48:33 darrenr Exp $
7  *
8  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
9  * Use is subject to license terms.
10  */
11 
12 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13 
14 #include "ipf.h"
15 
16 
17 void	printmask(v, mask)
18 int v;
19 u_32_t	*mask;
20 {
21 	struct in_addr ipa;
22 	int ones;
23 
24 #ifdef  USE_INET6
25 	if (v == 6)
26 		printf("/%d", count6bits(mask));
27 	else
28 #endif
29 	if ((ones = count4bits(*mask)) == -1) {
30 		ipa.s_addr = *mask;
31 		printf("/%s", inet_ntoa(ipa));
32 	} else
33 		printf("/%d", ones);
34 }
35