]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ipfilter/lib/printpoolnode.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ipfilter / lib / printpoolnode.c
1 /*      $FreeBSD$       */
2
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  */
8
9 #include "ipf.h"
10
11
12 ip_pool_node_t *
13 printpoolnode(np, opts, fields)
14         ip_pool_node_t *np;
15         int opts;
16         wordtab_t *fields;
17 {
18         int i;
19
20         if (fields != NULL) {
21                 for (i = 0; fields[i].w_value != 0; i++) {
22                         printpoolfield(np, IPLT_POOL, i);
23                         if (fields[i + 1].w_value != 0)
24                                 printf("\t");
25                 }
26                 printf("\n");
27         } else if ((opts & OPT_DEBUG) == 0) {
28                 putchar(' ');
29                 if (np->ipn_info == 1)
30                         PRINTF("! ");
31                 printip(np->ipn_addr.adf_family,
32                         (u_32_t *)&np->ipn_addr.adf_addr.in4);
33                 printmask(np->ipn_addr.adf_family,
34                           (u_32_t *)&np->ipn_mask.adf_addr);
35         } else {
36                 PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
37                         inet_ntoa(np->ipn_addr.adf_addr.in4));
38                 printmask(np->ipn_addr.adf_family,
39                           (u_32_t *)&np->ipn_mask.adf_addr);
40 #ifdef USE_QUAD_T
41                 PRINTF("\n\t\tHits %"PRIu64"\tBytes %"PRIu64"\tName %s\tRef %d\n",
42                         np->ipn_hits, np->ipn_bytes,
43                         np->ipn_name, np->ipn_ref);
44 #else
45                 PRINTF("\n\t\tHits %lu\tBytes %lu\tName %s\tRef %d\n",
46                         np->ipn_hits, np->ipn_bytes,
47                         np->ipn_name, np->ipn_ref);
48 #endif
49         }
50         return np->ipn_next;
51 }