1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
5*0Sstevel@tonic-gate  *
6*0Sstevel@tonic-gate  * $Id: printhostmask.c,v 1.8 2002/04/11 15:01:19 darrenr Exp $
7*0Sstevel@tonic-gate  */
8*0Sstevel@tonic-gate 
9*0Sstevel@tonic-gate #include "ipf.h"
10*0Sstevel@tonic-gate 
11*0Sstevel@tonic-gate 
12*0Sstevel@tonic-gate void	printhostmask(v, addr, mask)
13*0Sstevel@tonic-gate int	v;
14*0Sstevel@tonic-gate u_32_t	*addr, *mask;
15*0Sstevel@tonic-gate {
16*0Sstevel@tonic-gate #ifdef  USE_INET6
17*0Sstevel@tonic-gate 	char ipbuf[64];
18*0Sstevel@tonic-gate #else
19*0Sstevel@tonic-gate 	struct in_addr ipa;
20*0Sstevel@tonic-gate #endif
21*0Sstevel@tonic-gate 
22*0Sstevel@tonic-gate 	if (!*addr && !*mask)
23*0Sstevel@tonic-gate 		printf("any");
24*0Sstevel@tonic-gate 	else {
25*0Sstevel@tonic-gate #ifdef  USE_INET6
26*0Sstevel@tonic-gate 		void *ptr = addr;
27*0Sstevel@tonic-gate 		int af;
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate 		if (v == 4) {
30*0Sstevel@tonic-gate 			ptr = addr;
31*0Sstevel@tonic-gate 			af = AF_INET;
32*0Sstevel@tonic-gate 		} else if (v == 6) {
33*0Sstevel@tonic-gate 			ptr = addr;
34*0Sstevel@tonic-gate 			af = AF_INET6;
35*0Sstevel@tonic-gate 		} else
36*0Sstevel@tonic-gate 			af = 0;
37*0Sstevel@tonic-gate 		printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf)));
38*0Sstevel@tonic-gate #else
39*0Sstevel@tonic-gate 		ipa.s_addr = *addr;
40*0Sstevel@tonic-gate 		printf("%s", inet_ntoa(ipa));
41*0Sstevel@tonic-gate #endif
42*0Sstevel@tonic-gate 		printmask(mask);
43*0Sstevel@tonic-gate 	}
44*0Sstevel@tonic-gate }
45