xref: /titanic_51/usr/src/cmd/ipf/lib/common/printpoolnode.c (revision dc5a8425272d2602e4c21b95b9eeac2b897f45a1)
1 /*
2  * Copyright (C) 2002 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
7  * Use is subject to license terms.
8  */
9 
10 #pragma ident	"%Z%%M%	%I%	%E% SMI"
11 
12 #include "ipf.h"
13 
14 #define	PRINTF	(void)printf
15 #define	FPRINTF	(void)fprintf
16 
17 ip_pool_node_t *printpoolnode(np, opts)
18 ip_pool_node_t *np;
19 int opts;
20 {
21 	if ((opts & OPT_DEBUG) == 0) {
22 		putchar(' ');
23 		if (np->ipn_info == 1)
24 			PRINTF("! ");
25 
26 #ifdef USE_INET6
27 		if (np->ipn_addr.adf_family == AF_INET6)
28                         printhostmask(6, (u_32_t *)&np->ipn_addr.adf_addr.in6,
29                                          (u_32_t *)&np->ipn_mask.adf_addr);
30 		else
31 #endif
32 		{
33 			printip((u_32_t *)&np->ipn_addr.adf_addr.in4);
34 			printmask(4, (u_32_t *)&np->ipn_mask.adf_addr);
35 		}
36 	} else {
37 #ifdef USE_INET6
38 		char addinfo[INET6_ADDRSTRLEN + 1];
39 #endif
40 		PRINTF("\t\t");
41 		if (np->ipn_info == 1)
42 			PRINTF("! ");
43 
44 #ifdef USE_INET6
45 		PRINTF("%s", inet_ntop(np->ipn_addr.adf_family,
46 				       (void *)&np->ipn_addr.adf_addr.in4,
47 				       addinfo, INET6_ADDRSTRLEN));
48 #else
49 		PRINTF("%s", inet_ntoa(np->ipn_addr.adf_addr.in4));
50 #endif
51 #ifdef USE_INET6
52 		if (np->ipn_addr.adf_family == AF_INET6)
53 			printmask(6, (u_32_t *)&np->ipn_mask.adf_addr);
54 		else
55 #endif
56 			printmask(4, (u_32_t *)&np->ipn_mask.adf_addr);
57 
58 		PRINTF("\n\t\tHits %lu\tName %s\n",
59 			np->ipn_hits, np->ipn_name);
60 	}
61 	return np->ipn_next;
62 }
63