xref: /titanic_44/usr/src/cmd/ipf/lib/common/printhostmask.c (revision 3db86aab554edbb4244c8d1a1c90f152eee768af)
1 /*
2  * Copyright (C) 1993-2001 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: printhostmask.c,v 1.8 2002/04/11 15:01:19 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	printhostmask(v, addr, mask)
18 int	v;
19 u_32_t	*addr, *mask;
20 {
21 #ifdef  USE_INET6
22 	char ipbuf[INET6_ADDRSTRLEN];
23 #else
24 	struct in_addr ipa;
25 #endif
26 
27 	if (!*addr && !*mask)
28 		printf("any");
29 	else {
30 #ifdef  USE_INET6
31 		void *ptr = addr;
32 		int af;
33 
34 		if (v == 4) {
35 			ptr = addr;
36 			af = AF_INET;
37 		} else if (v == 6) {
38 			ptr = addr;
39 			af = AF_INET6;
40 		} else
41 			af = 0;
42 		printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf)));
43 #else
44 		ipa.s_addr = *addr;
45 		printf("%s", inet_ntoa(ipa));
46 #endif
47 		printmask(v, mask);
48 	}
49 }
50