2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
10 #pragma ident "%Z%%M% %I% %E% SMI"
14 #define PRINTF (void)printf
15 #define FPRINTF (void)fprintf
18 iphtable_t
*printhash(hp
, copyfunc
, name
, opts
)
24 iphtent_t
*ipep
, **table
;
29 if ((*copyfunc
)((char *)hp
, (char *)&iph
, sizeof(iph
)))
32 if ((name
!= NULL
) && strncmp(name
, iph
.iph_name
, FR_GROUPLEN
))
35 if ((opts
& OPT_DEBUG
) == 0) {
36 if ((iph
.iph_type
& IPHASH_ANON
) == IPHASH_ANON
)
37 PRINTF("# 'anonymous' table\n");
38 switch (iph
.iph_type
& ~IPHASH_ANON
)
43 case IPHASH_GROUPMAP
:
45 if (iph
.iph_flags
& FR_INQUE
)
47 else if (iph
.iph_flags
& FR_OUTQUE
)
53 PRINTF("%#x", iph
.iph_type
);
58 PRINTF("Hash Table Number: %s", iph
.iph_name
);
59 if ((iph
.iph_type
& IPHASH_ANON
) == IPHASH_ANON
)
80 PRINTF("#%d", iph
.iph_unit
);
84 if ((opts
& OPT_DEBUG
) == 0) {
85 if ((iph
.iph_type
& ~IPHASH_ANON
) == IPHASH_LOOKUP
)
86 PRINTF(" type = hash");
87 PRINTF(" number = %s size = %lu",
88 iph
.iph_name
, (u_long
)iph
.iph_size
);
89 if (iph
.iph_seed
!= 0)
90 PRINTF(" seed = %lu", iph
.iph_seed
);
94 switch (iph
.iph_type
& ~IPHASH_ANON
)
99 case IPHASH_GROUPMAP
:
100 PRINTF("groupmap Group. %s", iph
.iph_name
);
107 PRINTF("\t\tSize: %lu\tSeed: %lu",
108 (u_long
)iph
.iph_size
, iph
.iph_seed
);
109 PRINTF("\tRef. Count: %d\tMasks: %#x\n", iph
.iph_ref
,
113 if ((opts
& OPT_DEBUG
) != 0) {
116 for (i
= 0; i
< 32; i
++) {
117 if ((1 << i
) & iph
.iph_masks
[3]) {
118 ntomask(4, i
, &m
.s_addr
);
119 PRINTF("\t\tMask: %s\n", inet_ntoa(m
));
124 if ((opts
& OPT_DEBUG
) == 0)
127 sz
= iph
.iph_size
* sizeof(*table
);
129 if ((*copyfunc
)((char *)iph
.iph_table
, (char *)table
, sz
))
132 for (i
= 0, printed
= 0; i
< iph
.iph_size
; i
++) {
133 for (ipep
= table
[i
]; ipep
!= NULL
; ) {
134 ipep
= printhashnode(&iph
, ipep
, copyfunc
, opts
);
143 if ((opts
& OPT_DEBUG
) == 0)