4 * Copyright (C) 2002 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
11 #define PRINTF (void)printf
12 #define FPRINTF (void)fprintf
15 iphtable_t *printhash(hp, copyfunc, name, opts)
21 iphtent_t *ipep, **table;
26 if ((*copyfunc)((char *)hp, (char *)&iph, sizeof(iph)))
29 if ((name != NULL) && strncmp(name, iph.iph_name, FR_GROUPLEN))
32 if ((opts & OPT_DEBUG) == 0) {
33 if ((iph.iph_type & IPHASH_ANON) == IPHASH_ANON)
34 PRINTF("# 'anonymous' table\n");
35 switch (iph.iph_type & ~IPHASH_ANON)
40 case IPHASH_GROUPMAP :
42 if (iph.iph_flags & FR_INQUE)
44 else if (iph.iph_flags & FR_OUTQUE)
50 PRINTF("%#x", iph.iph_type);
55 PRINTF("Hash Table Number: %s", iph.iph_name);
56 if ((iph.iph_type & IPHASH_ANON) == IPHASH_ANON)
77 PRINTF("#%d", iph.iph_unit);
81 if ((opts & OPT_DEBUG) == 0) {
82 if ((iph.iph_type & ~IPHASH_ANON) == IPHASH_LOOKUP)
83 PRINTF(" type = hash");
84 PRINTF(" number = %s size = %lu",
85 iph.iph_name, (u_long)iph.iph_size);
86 if (iph.iph_seed != 0)
87 PRINTF(" seed = %lu", iph.iph_seed);
91 switch (iph.iph_type & ~IPHASH_ANON)
96 case IPHASH_GROUPMAP :
97 PRINTF("groupmap Group. %s", iph.iph_name);
104 PRINTF("\t\tSize: %lu\tSeed: %lu",
105 (u_long)iph.iph_size, iph.iph_seed);
106 PRINTF("\tRef. Count: %d\tMasks: %#x\n", iph.iph_ref,
110 if ((opts & OPT_DEBUG) != 0) {
113 for (i = 0; i < 32; i++) {
114 if ((1 << i) & iph.iph_masks) {
115 ntomask(4, i, &m.s_addr);
116 PRINTF("\t\tMask: %s\n", inet_ntoa(m));
121 if ((opts & OPT_DEBUG) == 0)
124 sz = iph.iph_size * sizeof(*table);
126 if ((*copyfunc)((char *)iph.iph_table, (char *)table, sz))
129 for (i = 0, printed = 0; i < iph.iph_size; i++) {
130 for (ipep = table[i]; ipep != NULL; ) {
131 ipep = printhashnode(&iph, ipep, copyfunc, opts);
140 if ((opts & OPT_DEBUG) == 0)