10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed. 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 5637Sml37995 * 6*2393Syz155240 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 7637Sml37995 * Use is subject to license terms. 80Sstevel@tonic-gate */ 90Sstevel@tonic-gate 10637Sml37995 #pragma ident "%Z%%M% %I% %E% SMI" 11637Sml37995 120Sstevel@tonic-gate #include "ipf.h" 130Sstevel@tonic-gate 140Sstevel@tonic-gate #define PRINTF (void)printf 150Sstevel@tonic-gate #define FPRINTF (void)fprintf 160Sstevel@tonic-gate 17*2393Syz155240 ip_pool_t *printpool(pp, copyfunc, name, opts) 180Sstevel@tonic-gate ip_pool_t *pp; 190Sstevel@tonic-gate copyfunc_t copyfunc; 20*2393Syz155240 char *name; 210Sstevel@tonic-gate int opts; 220Sstevel@tonic-gate { 23*2393Syz155240 ip_pool_node_t *ipnp, *ipnpn, ipn; 240Sstevel@tonic-gate ip_pool_t ipp; 250Sstevel@tonic-gate 260Sstevel@tonic-gate if ((*copyfunc)(pp, &ipp, sizeof(ipp))) 270Sstevel@tonic-gate return NULL; 280Sstevel@tonic-gate 29*2393Syz155240 if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN)) 30*2393Syz155240 return ipp.ipo_next; 31*2393Syz155240 320Sstevel@tonic-gate if ((opts & OPT_DEBUG) == 0) { 330Sstevel@tonic-gate if ((ipp.ipo_flags & IPOOL_ANON) != 0) 340Sstevel@tonic-gate PRINTF("# 'anonymous' tree %s\n", ipp.ipo_name); 350Sstevel@tonic-gate PRINTF("table role = "); 360Sstevel@tonic-gate } else { 370Sstevel@tonic-gate PRINTF("Name: %s", ipp.ipo_name); 380Sstevel@tonic-gate if ((ipp.ipo_flags & IPOOL_ANON) == IPOOL_ANON) 390Sstevel@tonic-gate PRINTF("(anon)"); 400Sstevel@tonic-gate putchar(' '); 410Sstevel@tonic-gate PRINTF("Role: "); 420Sstevel@tonic-gate } 430Sstevel@tonic-gate 440Sstevel@tonic-gate switch (ipp.ipo_unit) 450Sstevel@tonic-gate { 460Sstevel@tonic-gate case IPL_LOGIPF : 470Sstevel@tonic-gate printf("ipf"); 480Sstevel@tonic-gate break; 490Sstevel@tonic-gate case IPL_LOGNAT : 500Sstevel@tonic-gate printf("nat"); 510Sstevel@tonic-gate break; 520Sstevel@tonic-gate case IPL_LOGSTATE : 530Sstevel@tonic-gate printf("state"); 540Sstevel@tonic-gate break; 550Sstevel@tonic-gate case IPL_LOGAUTH : 560Sstevel@tonic-gate printf("auth"); 570Sstevel@tonic-gate break; 580Sstevel@tonic-gate case IPL_LOGSYNC : 590Sstevel@tonic-gate printf("sync"); 600Sstevel@tonic-gate break; 610Sstevel@tonic-gate case IPL_LOGSCAN : 620Sstevel@tonic-gate printf("scan"); 630Sstevel@tonic-gate break; 640Sstevel@tonic-gate case IPL_LOGLOOKUP : 650Sstevel@tonic-gate printf("lookup"); 660Sstevel@tonic-gate break; 670Sstevel@tonic-gate case IPL_LOGCOUNT : 680Sstevel@tonic-gate printf("count"); 690Sstevel@tonic-gate break; 700Sstevel@tonic-gate default : 710Sstevel@tonic-gate printf("unknown(%d)", ipp.ipo_unit); 720Sstevel@tonic-gate } 730Sstevel@tonic-gate 740Sstevel@tonic-gate if ((opts & OPT_DEBUG) == 0) { 750Sstevel@tonic-gate PRINTF(" type = tree number = %s\n", ipp.ipo_name); 760Sstevel@tonic-gate PRINTF("\t{"); 770Sstevel@tonic-gate } else { 780Sstevel@tonic-gate putchar(' '); 790Sstevel@tonic-gate 800Sstevel@tonic-gate PRINTF("\tReferences: %d\tHits: %lu\n", ipp.ipo_ref, 810Sstevel@tonic-gate ipp.ipo_hits); 820Sstevel@tonic-gate PRINTF("\tNodes Starting at %p\n", ipp.ipo_list); 830Sstevel@tonic-gate } 840Sstevel@tonic-gate 850Sstevel@tonic-gate ipnpn = ipp.ipo_list; 860Sstevel@tonic-gate ipp.ipo_list = NULL; 870Sstevel@tonic-gate while (ipnpn != NULL) { 880Sstevel@tonic-gate ipnp = (ip_pool_node_t *)malloc(sizeof(*ipnp)); 89*2393Syz155240 (*copyfunc)(ipnpn, ipnp, sizeof(ipn)); 900Sstevel@tonic-gate ipnpn = ipnp->ipn_next; 910Sstevel@tonic-gate ipnp->ipn_next = ipp.ipo_list; 920Sstevel@tonic-gate ipp.ipo_list = ipnp; 930Sstevel@tonic-gate } 940Sstevel@tonic-gate 95*2393Syz155240 if (ipp.ipo_list == NULL) { 96*2393Syz155240 putchar(';'); 97*2393Syz155240 } else { 98*2393Syz155240 for (ipnp = ipp.ipo_list; ipnp != NULL; ) { 99*2393Syz155240 ipnp = printpoolnode(ipnp, opts); 1000Sstevel@tonic-gate 101*2393Syz155240 if ((opts & OPT_DEBUG) == 0) { 102*2393Syz155240 putchar(';'); 103*2393Syz155240 } 104*2393Syz155240 } 1050Sstevel@tonic-gate } 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate if ((opts & OPT_DEBUG) == 0) 1080Sstevel@tonic-gate PRINTF(" };\n"); 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate return ipp.ipo_next; 1110Sstevel@tonic-gate } 112