xref: /onnv-gate/usr/src/cmd/ipf/lib/common/printmask.c (revision 637:3bfca5eeee8e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
50Sstevel@tonic-gate  *
60Sstevel@tonic-gate  * $Id: printmask.c,v 1.5 2002/06/15 04:48:33 darrenr Exp $
7*637Sml37995  *
8*637Sml37995  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
9*637Sml37995  * Use is subject to license terms.
100Sstevel@tonic-gate  */
110Sstevel@tonic-gate 
12*637Sml37995 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13*637Sml37995 
140Sstevel@tonic-gate #include "ipf.h"
150Sstevel@tonic-gate 
160Sstevel@tonic-gate 
printmask(v,mask)17*637Sml37995 void	printmask(v, mask)
18*637Sml37995 int v;
190Sstevel@tonic-gate u_32_t	*mask;
200Sstevel@tonic-gate {
210Sstevel@tonic-gate 	struct in_addr ipa;
220Sstevel@tonic-gate 	int ones;
230Sstevel@tonic-gate 
240Sstevel@tonic-gate #ifdef  USE_INET6
25*637Sml37995 	if (v == 6)
260Sstevel@tonic-gate 		printf("/%d", count6bits(mask));
270Sstevel@tonic-gate 	else
280Sstevel@tonic-gate #endif
290Sstevel@tonic-gate 	if ((ones = count4bits(*mask)) == -1) {
300Sstevel@tonic-gate 		ipa.s_addr = *mask;
310Sstevel@tonic-gate 		printf("/%s", inet_ntoa(ipa));
320Sstevel@tonic-gate 	} else
330Sstevel@tonic-gate 		printf("/%d", ones);
340Sstevel@tonic-gate }
35