1 /* $NetBSD: printpoolnode.c,v 1.1.1.1 2012/03/23 21:20:10 christos Exp $ */ 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 if (np->ipn_addr.adf_family == AF_INET) { 32 printip(np->ipn_addr.adf_family, 33 (u_32_t *)&np->ipn_addr.adf_addr.in4); 34 } else { 35 #ifdef USE_INET6 36 char buf[INET6_ADDRSTRLEN+1]; 37 const char *str; 38 39 str = inet_ntop(AF_INET6, &np->ipn_addr.adf_addr, 40 buf, sizeof(buf) - 1); 41 if (str != NULL) 42 PRINTF("%s", str); 43 #endif 44 } 45 printmask(np->ipn_addr.adf_family, 46 (u_32_t *)&np->ipn_mask.adf_addr); 47 } else { 48 PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "", 49 inet_ntoa(np->ipn_addr.adf_addr.in4)); 50 printmask(np->ipn_addr.adf_family, 51 (u_32_t *)&np->ipn_mask.adf_addr); 52 #ifdef USE_QUAD_T 53 PRINTF("\n\t\tHits %"PRIu64"\tBytes %"PRIu64"\tName %s\tRef %d\n", 54 np->ipn_hits, np->ipn_bytes, 55 np->ipn_name, np->ipn_ref); 56 #else 57 PRINTF("\n\t\tHits %lu\tBytes %lu\tName %s\tRef %d\n", 58 np->ipn_hits, np->ipn_bytes, 59 np->ipn_name, np->ipn_ref); 60 #endif 61 } 62 return np->ipn_next; 63 } 64