xref: /onnv-gate/usr/src/cmd/ipf/lib/common/printhostmask.c (revision 7176:101cc5da1498)
10Sstevel@tonic-gate /*
2*7176Syx160601  * Copyright (C) 2000-2005 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: printhostmask.c,v 1.8 2002/04/11 15:01:19 darrenr Exp $
7637Sml37995  *
8*7176Syx160601  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
9637Sml37995  * Use is subject to license terms.
100Sstevel@tonic-gate  */
110Sstevel@tonic-gate 
12637Sml37995 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13637Sml37995 
140Sstevel@tonic-gate #include "ipf.h"
150Sstevel@tonic-gate 
160Sstevel@tonic-gate 
printhostmask(v,addr,mask)170Sstevel@tonic-gate void	printhostmask(v, addr, mask)
180Sstevel@tonic-gate int	v;
190Sstevel@tonic-gate u_32_t	*addr, *mask;
200Sstevel@tonic-gate {
210Sstevel@tonic-gate #ifdef  USE_INET6
22637Sml37995 	char ipbuf[INET6_ADDRSTRLEN];
230Sstevel@tonic-gate #else
240Sstevel@tonic-gate 	struct in_addr ipa;
250Sstevel@tonic-gate #endif
260Sstevel@tonic-gate 
27*7176Syx160601 	if ((v == 4) && (!*addr) && (!*mask))
280Sstevel@tonic-gate 		printf("any");
290Sstevel@tonic-gate 	else {
300Sstevel@tonic-gate #ifdef  USE_INET6
310Sstevel@tonic-gate 		void *ptr = addr;
320Sstevel@tonic-gate 		int af;
330Sstevel@tonic-gate 
34*7176Syx160601 		if (v == 4)
350Sstevel@tonic-gate 			af = AF_INET;
36*7176Syx160601 		else if (v == 6)
370Sstevel@tonic-gate 			af = AF_INET6;
38*7176Syx160601 		else
390Sstevel@tonic-gate 			af = 0;
400Sstevel@tonic-gate 		printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf)));
410Sstevel@tonic-gate #else
420Sstevel@tonic-gate 		ipa.s_addr = *addr;
430Sstevel@tonic-gate 		printf("%s", inet_ntoa(ipa));
440Sstevel@tonic-gate #endif
45*7176Syx160601 		if (mask != NULL)
46*7176Syx160601 			printmask(v, mask);
470Sstevel@tonic-gate 	}
480Sstevel@tonic-gate }
49