1 /* 2 * Copyright (C) 2002 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 */ 6 7 #include "ipf.h" 8 9 #define PRINTF (void)printf 10 #define FPRINTF (void)fprintf 11 12 ip_pool_t *printpool(pp, copyfunc, opts) 13 ip_pool_t *pp; 14 copyfunc_t copyfunc; 15 int opts; 16 { 17 ip_pool_node_t *ipnp, *ipnpn, ipn; 18 ip_pool_t ipp; 19 20 if ((*copyfunc)(pp, &ipp, sizeof(ipp))) 21 return NULL; 22 23 if ((opts & OPT_DEBUG) == 0) { 24 if ((ipp.ipo_flags & IPOOL_ANON) != 0) 25 PRINTF("# 'anonymous' tree %s\n", ipp.ipo_name); 26 PRINTF("table role = "); 27 } else { 28 PRINTF("Name: %s", ipp.ipo_name); 29 if ((ipp.ipo_flags & IPOOL_ANON) == IPOOL_ANON) 30 PRINTF("(anon)"); 31 putchar(' '); 32 PRINTF("Role: "); 33 } 34 35 switch (ipp.ipo_unit) 36 { 37 case IPL_LOGIPF : 38 printf("ipf"); 39 break; 40 case IPL_LOGNAT : 41 printf("nat"); 42 break; 43 case IPL_LOGSTATE : 44 printf("state"); 45 break; 46 case IPL_LOGAUTH : 47 printf("auth"); 48 break; 49 case IPL_LOGSYNC : 50 printf("sync"); 51 break; 52 case IPL_LOGSCAN : 53 printf("scan"); 54 break; 55 case IPL_LOGLOOKUP : 56 printf("lookup"); 57 break; 58 case IPL_LOGCOUNT : 59 printf("count"); 60 break; 61 default : 62 printf("unknown(%d)", ipp.ipo_unit); 63 } 64 65 if ((opts & OPT_DEBUG) == 0) { 66 PRINTF(" type = tree number = %s\n", ipp.ipo_name); 67 PRINTF("\t{"); 68 } else { 69 putchar(' '); 70 71 PRINTF("\tReferences: %d\tHits: %lu\n", ipp.ipo_ref, 72 ipp.ipo_hits); 73 PRINTF("\tNodes Starting at %p\n", ipp.ipo_list); 74 } 75 76 ipnpn = ipp.ipo_list; 77 ipp.ipo_list = NULL; 78 while (ipnpn != NULL) { 79 ipnp = (ip_pool_node_t *)malloc(sizeof(*ipnp)); 80 (*copyfunc)(ipnpn, ipnp, sizeof(ipn)); 81 ipnpn = ipnp->ipn_next; 82 ipnp->ipn_next = ipp.ipo_list; 83 ipp.ipo_list = ipnp; 84 } 85 86 for (ipnp = ipp.ipo_list; ipnp != NULL; ) { 87 ipnp = printpoolnode(ipnp, opts); 88 89 if ((opts & OPT_DEBUG) == 0) { 90 if (ipnp == NULL) 91 putchar(';'); 92 else 93 putchar(','); 94 } 95 } 96 97 if ((opts & OPT_DEBUG) == 0) 98 PRINTF(" };\n"); 99 100 return ipp.ipo_next; 101 } 102