xref: /titanic_41/usr/src/cmd/ipf/lib/common/printhostmask.c (revision d6c23f6fbecbcca8ddd2b74c6e10f37095f9fd46)
17c478bd9Sstevel@tonic-gate /*
2*d6c23f6fSyx160601  * Copyright (C) 2000-2005 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: printhostmask.c,v 1.8 2002/04/11 15:01:19 darrenr Exp $
77663b816Sml37995  *
8*d6c23f6fSyx160601  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
97663b816Sml37995  * Use is subject to license terms.
107c478bd9Sstevel@tonic-gate  */
117c478bd9Sstevel@tonic-gate 
127663b816Sml37995 #pragma ident	"%Z%%M%	%I%	%E% SMI"
137663b816Sml37995 
147c478bd9Sstevel@tonic-gate #include "ipf.h"
157c478bd9Sstevel@tonic-gate 
167c478bd9Sstevel@tonic-gate 
printhostmask(v,addr,mask)177c478bd9Sstevel@tonic-gate void	printhostmask(v, addr, mask)
187c478bd9Sstevel@tonic-gate int	v;
197c478bd9Sstevel@tonic-gate u_32_t	*addr, *mask;
207c478bd9Sstevel@tonic-gate {
217c478bd9Sstevel@tonic-gate #ifdef  USE_INET6
227663b816Sml37995 	char ipbuf[INET6_ADDRSTRLEN];
237c478bd9Sstevel@tonic-gate #else
247c478bd9Sstevel@tonic-gate 	struct in_addr ipa;
257c478bd9Sstevel@tonic-gate #endif
267c478bd9Sstevel@tonic-gate 
27*d6c23f6fSyx160601 	if ((v == 4) && (!*addr) && (!*mask))
287c478bd9Sstevel@tonic-gate 		printf("any");
297c478bd9Sstevel@tonic-gate 	else {
307c478bd9Sstevel@tonic-gate #ifdef  USE_INET6
317c478bd9Sstevel@tonic-gate 		void *ptr = addr;
327c478bd9Sstevel@tonic-gate 		int af;
337c478bd9Sstevel@tonic-gate 
34*d6c23f6fSyx160601 		if (v == 4)
357c478bd9Sstevel@tonic-gate 			af = AF_INET;
36*d6c23f6fSyx160601 		else if (v == 6)
377c478bd9Sstevel@tonic-gate 			af = AF_INET6;
38*d6c23f6fSyx160601 		else
397c478bd9Sstevel@tonic-gate 			af = 0;
407c478bd9Sstevel@tonic-gate 		printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf)));
417c478bd9Sstevel@tonic-gate #else
427c478bd9Sstevel@tonic-gate 		ipa.s_addr = *addr;
437c478bd9Sstevel@tonic-gate 		printf("%s", inet_ntoa(ipa));
447c478bd9Sstevel@tonic-gate #endif
45*d6c23f6fSyx160601 		if (mask != NULL)
467663b816Sml37995 			printmask(v, mask);
477c478bd9Sstevel@tonic-gate 	}
487c478bd9Sstevel@tonic-gate }
49