Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / cmd / ipf / lib / common / printhashdata.c
blobcef1afb35c0c80162e1d69a0275885d2ef49ed17
1 /*
2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
8 */
10 #pragma ident "%Z%%M% %I% %E% SMI"
12 #include "ipf.h"
14 #define PRINTF (void)printf
15 #define FPRINTF (void)fprintf
18 void printhashdata(hp, opts)
19 iphtable_t *hp;
20 int opts;
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)
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;
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: ");
53 switch (hp->iph_unit)
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;
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)
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;
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]);
101 if ((opts & OPT_DEBUG) != 0) {
102 struct in_addr m;
103 int i;
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));