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*2393Syz155240 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 7637Sml37995 * Use is subject to license terms. 80Sstevel@tonic-gate */ 90Sstevel@tonic-gate 10637Sml37995 #pragma ident "%Z%%M% %I% %E% SMI" 11637Sml37995 120Sstevel@tonic-gate #include "ipf.h" 130Sstevel@tonic-gate 140Sstevel@tonic-gate #define PRINTF (void)printf 150Sstevel@tonic-gate #define FPRINTF (void)fprintf 160Sstevel@tonic-gate 170Sstevel@tonic-gate iphtent_t *printhashnode(iph, ipep, copyfunc, opts) 180Sstevel@tonic-gate iphtable_t *iph; 190Sstevel@tonic-gate iphtent_t *ipep; 200Sstevel@tonic-gate copyfunc_t copyfunc; 210Sstevel@tonic-gate int opts; 220Sstevel@tonic-gate { 230Sstevel@tonic-gate iphtent_t ipe; 240Sstevel@tonic-gate 250Sstevel@tonic-gate if ((*copyfunc)(ipep, &ipe, sizeof(ipe))) 260Sstevel@tonic-gate return NULL; 270Sstevel@tonic-gate 28637Sml37995 if (ipe.ipe_family == AF_INET) { 29637Sml37995 ipe.ipe_addr.in4_addr = htonl(ipe.ipe_addr.in4_addr); 30637Sml37995 ipe.ipe_mask.in4_addr = htonl(ipe.ipe_mask.in4_addr); 31637Sml37995 } 320Sstevel@tonic-gate 330Sstevel@tonic-gate if ((opts & OPT_DEBUG) != 0) { 34637Sml37995 #ifdef USE_INET6 35637Sml37995 char addinfo[INET6_ADDRSTRLEN]; 36637Sml37995 PRINTF("\tAddress: %s", 37637Sml37995 inet_ntop(ipe.ipe_family, (void *)&ipe.ipe_addr.in4, 38637Sml37995 addinfo, sizeof(addinfo))); 39637Sml37995 #else 400Sstevel@tonic-gate PRINTF("\tAddress: %s", 410Sstevel@tonic-gate inet_ntoa(ipe.ipe_addr.in4)); 42637Sml37995 #endif 43637Sml37995 #ifdef USE_INET6 44637Sml37995 if (ipe.ipe_family == AF_INET6) 45637Sml37995 printmask(6, (u_32_t *)&ipe.ipe_mask.in6); 46637Sml37995 else 47637Sml37995 #endif 48637Sml37995 printmask(4, (u_32_t *)&ipe.ipe_mask.in4_addr); 49637Sml37995 50*2393Syz155240 PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref, 51*2393Syz155240 ipe.ipe_group); 520Sstevel@tonic-gate } else { 530Sstevel@tonic-gate putchar(' '); 54637Sml37995 #ifdef USE_INET6 55637Sml37995 if (ipe.ipe_family == AF_INET6) 56637Sml37995 printhostmask(6, (u_32_t *)&ipe.ipe_addr.in6, 57637Sml37995 (u_32_t *)&ipe.ipe_mask.in6); 58637Sml37995 else 59637Sml37995 #endif 60637Sml37995 { 61637Sml37995 printip((u_32_t *)&ipe.ipe_addr.in4_addr); 62637Sml37995 printmask(4, (u_32_t *)&ipe.ipe_mask.in4_addr); 63637Sml37995 } 640Sstevel@tonic-gate if (ipe.ipe_value != 0) { 650Sstevel@tonic-gate switch (iph->iph_type & ~IPHASH_ANON) 660Sstevel@tonic-gate { 670Sstevel@tonic-gate case IPHASH_GROUPMAP : 68*2393Syz155240 if (strncmp(ipe.ipe_group, iph->iph_name, 69*2393Syz155240 FR_GROUPLEN)) 70*2393Syz155240 PRINTF(", group = %s", ipe.ipe_group); 71*2393Syz155240 break; 720Sstevel@tonic-gate } 730Sstevel@tonic-gate } 740Sstevel@tonic-gate putchar(';'); 750Sstevel@tonic-gate } 760Sstevel@tonic-gate ipep = ipe.ipe_next; 770Sstevel@tonic-gate return ipep; 780Sstevel@tonic-gate } 79