1
2 /*
3 * Copyright (C) 2012 by Darren Reed.
4 *
5 * See the IPFILTER.LICENCE file for details on licencing.
6 */
7
8 #include "ipf.h"
9
10
11 ip_pool_node_t *
printpoolnode(ip_pool_node_t * np,int opts,wordtab_t * fields)12 printpoolnode(ip_pool_node_t *np, int opts, wordtab_t *fields)
13 {
14 int i;
15
16 if (fields != NULL) {
17 for (i = 0; fields[i].w_value != 0; i++) {
18 printpoolfield(np, IPLT_POOL, i);
19 if (fields[i + 1].w_value != 0)
20 printf("\t");
21 }
22 printf("\n");
23 } else if ((opts & OPT_DEBUG) == 0) {
24 putchar(' ');
25 if (np->ipn_info == 1)
26 PRINTF("! ");
27 printip(np->ipn_addr.adf_family,
28 (u_32_t *)&np->ipn_addr.adf_addr.in4);
29 printmask(np->ipn_addr.adf_family,
30 (u_32_t *)&np->ipn_mask.adf_addr);
31 } else {
32 #ifdef USE_INET6
33 if (np->ipn_addr.adf_family == AF_INET6) {
34 char buf[INET6_ADDRSTRLEN + 1];
35 const char *str;
36
37 buf[0] = '\0';
38 str = inet_ntop(AF_INET6, &np->ipn_addr.adf_addr.in6,
39 buf, sizeof(buf) - 1);
40 if (str == NULL)
41 str = "???";
42 PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
43 str);
44 } else if (np->ipn_addr.adf_family == AF_INET) {
45 #else
46 if (np->ipn_addr.adf_family == AF_INET) {
47 #endif
48 PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
49 inet_ntoa(np->ipn_addr.adf_addr.in4));
50 } else {
51 PRINTF("\tAddress: family: %d\n",
52 np->ipn_addr.adf_family);
53 }
54 printmask(np->ipn_addr.adf_family,
55 (u_32_t *)&np->ipn_mask.adf_addr);
56 #ifdef USE_QUAD_T
57 PRINTF("\n\t\tHits %"PRIu64"\tBytes %"PRIu64"\tName %s\tRef %d\n",
58 np->ipn_hits, np->ipn_bytes,
59 np->ipn_name, np->ipn_ref);
60 #else
61 PRINTF("\n\t\tHits %lu\tBytes %lu\tName %s\tRef %d\n",
62 np->ipn_hits, np->ipn_bytes,
63 np->ipn_name, np->ipn_ref);
64 #endif
65 }
66 return (np->ipn_next);
67 }
68