]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/lib/printhashnode.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / lib / printhashnode.c
1 /*      $FreeBSD$       */
2
3 /*
4  * Copyright (C) 2002-2005 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  */
8
9 #include "ipf.h"
10
11 #define PRINTF  (void)printf
12 #define FPRINTF (void)fprintf
13
14 iphtent_t *printhashnode(iph, ipep, copyfunc, opts)
15 iphtable_t *iph;
16 iphtent_t *ipep;
17 copyfunc_t copyfunc;
18 int opts;
19 {
20         iphtent_t ipe;
21
22         if ((*copyfunc)(ipep, &ipe, sizeof(ipe)))
23                 return NULL;
24
25         ipe.ipe_addr.in4_addr = htonl(ipe.ipe_addr.in4_addr);
26         ipe.ipe_mask.in4_addr = htonl(ipe.ipe_mask.in4_addr);
27
28         if ((opts & OPT_DEBUG) != 0) {
29                 PRINTF("\tAddress: %s",
30                         inet_ntoa(ipe.ipe_addr.in4));
31                 printmask((u_32_t *)&ipe.ipe_mask.in4_addr);
32                 PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
33                         ipe.ipe_group);
34         } else {
35                 putchar(' ');
36                 printip((u_32_t *)&ipe.ipe_addr.in4_addr);
37                 printmask((u_32_t *)&ipe.ipe_mask.in4_addr);
38                 if (ipe.ipe_value != 0) {
39                         switch (iph->iph_type & ~IPHASH_ANON)
40                         {
41                         case IPHASH_GROUPMAP :
42                                 if (strncmp(ipe.ipe_group, iph->iph_name,
43                                             FR_GROUPLEN))
44                                         PRINTF(", group = %s", ipe.ipe_group);
45                                 break;
46                         }
47                 }
48                 putchar(';');
49         }
50
51         ipep = ipe.ipe_next;
52         return ipep;
53 }