10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed.
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing.
5637Sml37995 *
6*12255SJohn.Ojemann@Oracle.COM * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
70Sstevel@tonic-gate */
80Sstevel@tonic-gate
90Sstevel@tonic-gate #include "ipf.h"
100Sstevel@tonic-gate
110Sstevel@tonic-gate #define PRINTF (void)printf
120Sstevel@tonic-gate #define FPRINTF (void)fprintf
130Sstevel@tonic-gate
printhashnode(iph,ipep,copyfunc,opts)140Sstevel@tonic-gate iphtent_t *printhashnode(iph, ipep, copyfunc, opts)
150Sstevel@tonic-gate iphtable_t *iph;
160Sstevel@tonic-gate iphtent_t *ipep;
170Sstevel@tonic-gate copyfunc_t copyfunc;
180Sstevel@tonic-gate int opts;
190Sstevel@tonic-gate {
200Sstevel@tonic-gate iphtent_t ipe;
210Sstevel@tonic-gate
220Sstevel@tonic-gate if ((*copyfunc)(ipep, &ipe, sizeof(ipe)))
230Sstevel@tonic-gate return NULL;
240Sstevel@tonic-gate
25637Sml37995 if (ipe.ipe_family == AF_INET) {
26637Sml37995 ipe.ipe_addr.in4_addr = htonl(ipe.ipe_addr.in4_addr);
27637Sml37995 ipe.ipe_mask.in4_addr = htonl(ipe.ipe_mask.in4_addr);
28637Sml37995 }
290Sstevel@tonic-gate
300Sstevel@tonic-gate if ((opts & OPT_DEBUG) != 0) {
31637Sml37995 #ifdef USE_INET6
32637Sml37995 char addinfo[INET6_ADDRSTRLEN];
33637Sml37995 PRINTF("\tAddress: %s",
34637Sml37995 inet_ntop(ipe.ipe_family, (void *)&ipe.ipe_addr.in4,
35637Sml37995 addinfo, sizeof(addinfo)));
36637Sml37995 #else
370Sstevel@tonic-gate PRINTF("\tAddress: %s",
380Sstevel@tonic-gate inet_ntoa(ipe.ipe_addr.in4));
39637Sml37995 #endif
40637Sml37995 #ifdef USE_INET6
41637Sml37995 if (ipe.ipe_family == AF_INET6)
42637Sml37995 printmask(6, (u_32_t *)&ipe.ipe_mask.in6);
43637Sml37995 else
44637Sml37995 #endif
45637Sml37995 printmask(4, (u_32_t *)&ipe.ipe_mask.in4_addr);
46637Sml37995
47*12255SJohn.Ojemann@Oracle.COM #ifdef USE_QUAD_T
48*12255SJohn.Ojemann@Oracle.COM PRINTF("\tHits %qu\tBytes %qu", ipe.ipe_hits, ipe.ipe_bytes);
49*12255SJohn.Ojemann@Oracle.COM #else
50*12255SJohn.Ojemann@Oracle.COM PRINTF("\tHits %lu\tBytes %lu", ipe.ipe_hits, ipe.ipe_bytes);
51*12255SJohn.Ojemann@Oracle.COM #endif
522393Syz155240 PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
532393Syz155240 ipe.ipe_group);
540Sstevel@tonic-gate } else {
550Sstevel@tonic-gate putchar(' ');
56637Sml37995 #ifdef USE_INET6
57637Sml37995 if (ipe.ipe_family == AF_INET6)
58637Sml37995 printhostmask(6, (u_32_t *)&ipe.ipe_addr.in6,
59637Sml37995 (u_32_t *)&ipe.ipe_mask.in6);
60637Sml37995 else
61637Sml37995 #endif
62637Sml37995 {
63637Sml37995 printip((u_32_t *)&ipe.ipe_addr.in4_addr);
64637Sml37995 printmask(4, (u_32_t *)&ipe.ipe_mask.in4_addr);
65637Sml37995 }
660Sstevel@tonic-gate if (ipe.ipe_value != 0) {
670Sstevel@tonic-gate switch (iph->iph_type & ~IPHASH_ANON)
680Sstevel@tonic-gate {
690Sstevel@tonic-gate case IPHASH_GROUPMAP :
702393Syz155240 if (strncmp(ipe.ipe_group, iph->iph_name,
712393Syz155240 FR_GROUPLEN))
722393Syz155240 PRINTF(", group = %s", ipe.ipe_group);
732393Syz155240 break;
740Sstevel@tonic-gate }
750Sstevel@tonic-gate }
760Sstevel@tonic-gate putchar(';');
770Sstevel@tonic-gate }
780Sstevel@tonic-gate ipep = ipe.ipe_next;
790Sstevel@tonic-gate return ipep;
800Sstevel@tonic-gate }
81