1 /* 2 * Copyright (C) 2002 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * Copyright 2007 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 18 void printhashdata(hp, opts) 19 iphtable_t *hp; 20 int opts; 21 { 22 23 if ((opts & OPT_DEBUG) == 0) { 24 if ((hp->iph_type & IPHASH_ANON) == IPHASH_ANON) 25 PRINTF("# 'anonymous' table\n"); 26 switch (hp->iph_type & ~IPHASH_ANON) 27 { 28 case IPHASH_LOOKUP : 29 PRINTF("table"); 30 break; 31 case IPHASH_GROUPMAP : 32 PRINTF("group-map"); 33 if (hp->iph_flags & FR_INQUE) 34 PRINTF(" in"); 35 else if (hp->iph_flags & FR_OUTQUE) 36 PRINTF(" out"); 37 else 38 PRINTF(" ???"); 39 break; 40 default : 41 PRINTF("%#x", hp->iph_type); 42 break; 43 } 44 PRINTF(" role = "); 45 } else { 46 PRINTF("Hash Table Number: %s", hp->iph_name); 47 if ((hp->iph_type & IPHASH_ANON) == IPHASH_ANON) 48 PRINTF("(anon)"); 49 putchar(' '); 50 PRINTF("Role: "); 51 } 52 53 switch (hp->iph_unit) 54 { 55 case IPL_LOGNAT : 56 PRINTF("nat"); 57 break; 58 case IPL_LOGIPF : 59 PRINTF("ipf"); 60 break; 61 case IPL_LOGAUTH : 62 PRINTF("auth"); 63 break; 64 case IPL_LOGCOUNT : 65 PRINTF("count"); 66 break; 67 default : 68 PRINTF("#%d", hp->iph_unit); 69 break; 70 } 71 72 if ((opts & OPT_DEBUG) == 0) { 73 if ((hp->iph_type & ~IPHASH_ANON) == IPHASH_LOOKUP) 74 PRINTF(" type = hash"); 75 PRINTF(" number = %s size = %lu", 76 hp->iph_name, (u_long)hp->iph_size); 77 if (hp->iph_seed != 0) 78 PRINTF(" seed = %lu", hp->iph_seed); 79 putchar('\n'); 80 } else { 81 PRINTF(" Type: "); 82 switch (hp->iph_type & ~IPHASH_ANON) 83 { 84 case IPHASH_LOOKUP : 85 PRINTF("lookup"); 86 break; 87 case IPHASH_GROUPMAP : 88 PRINTF("groupmap Group. %s", hp->iph_name); 89 break; 90 default : 91 break; 92 } 93 94 putchar('\n'); 95 PRINTF("\t\tSize: %lu\tSeed: %lu", 96 (u_long)hp->iph_size, hp->iph_seed); 97 PRINTF("\tRef. Count: %d\tMasks: %#x\n", hp->iph_ref, 98 hp->iph_masks[0]); 99 } 100 101 if ((opts & OPT_DEBUG) != 0) { 102 struct in_addr m; 103 int i; 104 105 for (i = 0; i < 32; i++) { 106 if ((1 << i) & hp->iph_masks[0]) { 107 ntomask(4, i, &m.s_addr); 108 PRINTF("\t\tMask: %s\n", inet_ntoa(m)); 109 } 110 } 111 } 112 } 113