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