xref: /titanic_44/usr/src/cmd/ipf/lib/common/printhostmask.c (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
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 
9 #include "ipf.h"
10 
11 
12 void	printhostmask(v, addr, mask)
13 int	v;
14 u_32_t	*addr, *mask;
15 {
16 #ifdef  USE_INET6
17 	char ipbuf[64];
18 #else
19 	struct in_addr ipa;
20 #endif
21 
22 	if (!*addr && !*mask)
23 		printf("any");
24 	else {
25 #ifdef  USE_INET6
26 		void *ptr = addr;
27 		int af;
28 
29 		if (v == 4) {
30 			ptr = addr;
31 			af = AF_INET;
32 		} else if (v == 6) {
33 			ptr = addr;
34 			af = AF_INET6;
35 		} else
36 			af = 0;
37 		printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf)));
38 #else
39 		ipa.s_addr = *addr;
40 		printf("%s", inet_ntoa(ipa));
41 #endif
42 		printmask(mask);
43 	}
44 }
45