]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ipfilter/lib/printpoolnode.c
Add libbearssl
[FreeBSD/FreeBSD.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 #ifdef USE_INET6
37                 if (np->ipn_addr.adf_family == AF_INET6) {
38                         char buf[INET6_ADDRSTRLEN + 1];
39                         const char *str;
40                         
41                         buf[0] = '\0';
42                         str = inet_ntop(AF_INET6, &np->ipn_addr.adf_addr.in6,
43                                 buf, sizeof(buf) - 1);
44                         if (str == NULL)
45                                 str = "???";
46                         PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
47                                 str);
48                 } else if (np->ipn_addr.adf_family == AF_INET) {
49 #else
50                 if (np->ipn_addr.adf_family == AF_INET) {
51 #endif
52                         PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
53                                 inet_ntoa(np->ipn_addr.adf_addr.in4));
54                 } else {
55                         PRINTF("\tAddress: family: %d\n",
56                                 np->ipn_addr.adf_family);
57                 }
58                 printmask(np->ipn_addr.adf_family,
59                           (u_32_t *)&np->ipn_mask.adf_addr);
60 #ifdef USE_QUAD_T
61                 PRINTF("\n\t\tHits %"PRIu64"\tBytes %"PRIu64"\tName %s\tRef %d\n",
62                         np->ipn_hits, np->ipn_bytes,
63                         np->ipn_name, np->ipn_ref);
64 #else
65                 PRINTF("\n\t\tHits %lu\tBytes %lu\tName %s\tRef %d\n",
66                         np->ipn_hits, np->ipn_bytes,
67                         np->ipn_name, np->ipn_ref);
68 #endif
69         }
70         return np->ipn_next;
71 }