17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed. 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 57663b816Sml37995 * 6*de22af4eSJohn Ojemann * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 77c478bd9Sstevel@tonic-gate */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate #include "ipf.h" 107c478bd9Sstevel@tonic-gate 117c478bd9Sstevel@tonic-gate #define PRINTF (void)printf 127c478bd9Sstevel@tonic-gate #define FPRINTF (void)fprintf 137c478bd9Sstevel@tonic-gate 147c478bd9Sstevel@tonic-gate iphtent_t *printhashnode(iph, ipep, copyfunc, opts) 157c478bd9Sstevel@tonic-gate iphtable_t *iph; 167c478bd9Sstevel@tonic-gate iphtent_t *ipep; 177c478bd9Sstevel@tonic-gate copyfunc_t copyfunc; 187c478bd9Sstevel@tonic-gate int opts; 197c478bd9Sstevel@tonic-gate { 207c478bd9Sstevel@tonic-gate iphtent_t ipe; 217c478bd9Sstevel@tonic-gate 227c478bd9Sstevel@tonic-gate if ((*copyfunc)(ipep, &ipe, sizeof(ipe))) 237c478bd9Sstevel@tonic-gate return NULL; 247c478bd9Sstevel@tonic-gate 257663b816Sml37995 if (ipe.ipe_family == AF_INET) { 267c478bd9Sstevel@tonic-gate ipe.ipe_addr.in4_addr = htonl(ipe.ipe_addr.in4_addr); 277c478bd9Sstevel@tonic-gate ipe.ipe_mask.in4_addr = htonl(ipe.ipe_mask.in4_addr); 287663b816Sml37995 } 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate if ((opts & OPT_DEBUG) != 0) { 317663b816Sml37995 #ifdef USE_INET6 327663b816Sml37995 char addinfo[INET6_ADDRSTRLEN]; 337663b816Sml37995 PRINTF("\tAddress: %s", 347663b816Sml37995 inet_ntop(ipe.ipe_family, (void *)&ipe.ipe_addr.in4, 357663b816Sml37995 addinfo, sizeof(addinfo))); 367663b816Sml37995 #else 377c478bd9Sstevel@tonic-gate PRINTF("\tAddress: %s", 387c478bd9Sstevel@tonic-gate inet_ntoa(ipe.ipe_addr.in4)); 397663b816Sml37995 #endif 407663b816Sml37995 #ifdef USE_INET6 417663b816Sml37995 if (ipe.ipe_family == AF_INET6) 427663b816Sml37995 printmask(6, (u_32_t *)&ipe.ipe_mask.in6); 437663b816Sml37995 else 447663b816Sml37995 #endif 457663b816Sml37995 printmask(4, (u_32_t *)&ipe.ipe_mask.in4_addr); 467663b816Sml37995 47*de22af4eSJohn Ojemann #ifdef USE_QUAD_T 48*de22af4eSJohn Ojemann PRINTF("\tHits %qu\tBytes %qu", ipe.ipe_hits, ipe.ipe_bytes); 49*de22af4eSJohn Ojemann #else 50*de22af4eSJohn Ojemann PRINTF("\tHits %lu\tBytes %lu", ipe.ipe_hits, ipe.ipe_bytes); 51*de22af4eSJohn Ojemann #endif 52ab25eeb5Syz155240 PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref, 53ab25eeb5Syz155240 ipe.ipe_group); 547c478bd9Sstevel@tonic-gate } else { 557c478bd9Sstevel@tonic-gate putchar(' '); 567663b816Sml37995 #ifdef USE_INET6 577663b816Sml37995 if (ipe.ipe_family == AF_INET6) 587663b816Sml37995 printhostmask(6, (u_32_t *)&ipe.ipe_addr.in6, 597663b816Sml37995 (u_32_t *)&ipe.ipe_mask.in6); 607663b816Sml37995 else 617663b816Sml37995 #endif 627663b816Sml37995 { 637c478bd9Sstevel@tonic-gate printip((u_32_t *)&ipe.ipe_addr.in4_addr); 647663b816Sml37995 printmask(4, (u_32_t *)&ipe.ipe_mask.in4_addr); 657663b816Sml37995 } 667c478bd9Sstevel@tonic-gate if (ipe.ipe_value != 0) { 677c478bd9Sstevel@tonic-gate switch (iph->iph_type & ~IPHASH_ANON) 687c478bd9Sstevel@tonic-gate { 697c478bd9Sstevel@tonic-gate case IPHASH_GROUPMAP : 70ab25eeb5Syz155240 if (strncmp(ipe.ipe_group, iph->iph_name, 71ab25eeb5Syz155240 FR_GROUPLEN)) 727c478bd9Sstevel@tonic-gate PRINTF(", group = %s", ipe.ipe_group); 737c478bd9Sstevel@tonic-gate break; 747c478bd9Sstevel@tonic-gate } 757c478bd9Sstevel@tonic-gate } 767c478bd9Sstevel@tonic-gate putchar(';'); 777c478bd9Sstevel@tonic-gate } 787c478bd9Sstevel@tonic-gate ipep = ipe.ipe_next; 797c478bd9Sstevel@tonic-gate return ipep; 807c478bd9Sstevel@tonic-gate } 81