xref: /titanic_52/usr/src/cmd/ipf/lib/common/printmask.c (revision 7663b81667fda05833f609eceac713f0a83c2347)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  * $Id: printmask.c,v 1.5 2002/06/15 04:48:33 darrenr Exp $
7*7663b816Sml37995  *
8*7663b816Sml37995  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
9*7663b816Sml37995  * Use is subject to license terms.
107c478bd9Sstevel@tonic-gate  */
117c478bd9Sstevel@tonic-gate 
12*7663b816Sml37995 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13*7663b816Sml37995 
147c478bd9Sstevel@tonic-gate #include "ipf.h"
157c478bd9Sstevel@tonic-gate 
167c478bd9Sstevel@tonic-gate 
17*7663b816Sml37995 void	printmask(v, mask)
18*7663b816Sml37995 int v;
197c478bd9Sstevel@tonic-gate u_32_t	*mask;
207c478bd9Sstevel@tonic-gate {
217c478bd9Sstevel@tonic-gate 	struct in_addr ipa;
227c478bd9Sstevel@tonic-gate 	int ones;
237c478bd9Sstevel@tonic-gate 
247c478bd9Sstevel@tonic-gate #ifdef  USE_INET6
25*7663b816Sml37995 	if (v == 6)
267c478bd9Sstevel@tonic-gate 		printf("/%d", count6bits(mask));
277c478bd9Sstevel@tonic-gate 	else
287c478bd9Sstevel@tonic-gate #endif
297c478bd9Sstevel@tonic-gate 	if ((ones = count4bits(*mask)) == -1) {
307c478bd9Sstevel@tonic-gate 		ipa.s_addr = *mask;
317c478bd9Sstevel@tonic-gate 		printf("/%s", inet_ntoa(ipa));
327c478bd9Sstevel@tonic-gate 	} else
337c478bd9Sstevel@tonic-gate 		printf("/%d", ones);
347c478bd9Sstevel@tonic-gate }
35