Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / printhashdata.c
blob89f1947b6cd55b5d85f7fbfb90b95b121b8dd42c
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2002 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
7 */
9 #include "ipf.h"
11 #define PRINTF (void)printf
12 #define FPRINTF (void)fprintf
15 void printhashdata(hp, opts)
16 iphtable_t *hp;
17 int opts;
20 if ((opts & OPT_DEBUG) == 0) {
21 if ((hp->iph_type & IPHASH_ANON) == IPHASH_ANON)
22 PRINTF("# 'anonymous' table\n");
23 if ((hp->iph_flags & IPHASH_DELETE) == IPHASH_DELETE)
24 PRINTF("# ");
25 switch (hp->iph_type & ~IPHASH_ANON)
27 case IPHASH_LOOKUP :
28 PRINTF("table");
29 break;
30 case IPHASH_GROUPMAP :
31 PRINTF("group-map");
32 if (hp->iph_flags & FR_INQUE)
33 PRINTF(" in");
34 else if (hp->iph_flags & FR_OUTQUE)
35 PRINTF(" out");
36 else
37 PRINTF(" ???");
38 break;
39 default :
40 PRINTF("%#x", hp->iph_type);
41 break;
43 PRINTF(" role = ");
44 } else {
45 PRINTF("Hash Table %s: %s",
46 isdigit(*hp->iph_name) ? "Number" : "Name",
47 hp->iph_name);
48 if ((hp->iph_type & IPHASH_ANON) == IPHASH_ANON)
49 PRINTF("(anon)");
50 putchar(' ');
51 PRINTF("Role: ");
54 switch (hp->iph_unit)
56 case IPL_LOGNAT :
57 PRINTF("nat");
58 break;
59 case IPL_LOGIPF :
60 PRINTF("ipf");
61 break;
62 case IPL_LOGAUTH :
63 PRINTF("auth");
64 break;
65 case IPL_LOGCOUNT :
66 PRINTF("count");
67 break;
68 default :
69 PRINTF("#%d", hp->iph_unit);
70 break;
73 if ((opts & OPT_DEBUG) == 0) {
74 if ((hp->iph_type & ~IPHASH_ANON) == IPHASH_LOOKUP)
75 PRINTF(" type = hash");
76 PRINTF(" %s = %s size = %lu",
77 isdigit(*hp->iph_name) ? "number" : "name",
78 hp->iph_name, (u_long)hp->iph_size);
79 if (hp->iph_seed != 0)
80 PRINTF(" seed = %lu", hp->iph_seed);
81 putchar('\n');
82 } else {
83 PRINTF(" Type: ");
84 switch (hp->iph_type & ~IPHASH_ANON)
86 case IPHASH_LOOKUP :
87 PRINTF("lookup");
88 break;
89 case IPHASH_GROUPMAP :
90 PRINTF("groupmap Group. %s", hp->iph_name);
91 break;
92 default :
93 break;
96 putchar('\n');
97 PRINTF("\t\tSize: %lu\tSeed: %lu",
98 (u_long)hp->iph_size, hp->iph_seed);
99 PRINTF("\tRef. Count: %d\tMasks: %#x\n", hp->iph_ref,
100 hp->iph_masks);
103 if ((opts & OPT_DEBUG) != 0) {
104 struct in_addr m;
105 int i;
107 for (i = 0; i < 32; i++) {
108 if ((1 << i) & hp->iph_masks) {
109 ntomask(4, i, &m.s_addr);
110 PRINTF("\t\tMask: %s\n", inet_ntoa(m));