17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed. 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 57663b816Sml37995 * 6*ab25eeb5Syz155240 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 77663b816Sml37995 * Use is subject to license terms. 87c478bd9Sstevel@tonic-gate */ 97c478bd9Sstevel@tonic-gate 107663b816Sml37995 #pragma ident "%Z%%M% %I% %E% SMI" 117663b816Sml37995 127c478bd9Sstevel@tonic-gate #include "ipf.h" 137c478bd9Sstevel@tonic-gate 147c478bd9Sstevel@tonic-gate #define PRINTF (void)printf 157c478bd9Sstevel@tonic-gate #define FPRINTF (void)fprintf 167c478bd9Sstevel@tonic-gate 17*ab25eeb5Syz155240 ip_pool_t *printpool(pp, copyfunc, name, opts) 187c478bd9Sstevel@tonic-gate ip_pool_t *pp; 197c478bd9Sstevel@tonic-gate copyfunc_t copyfunc; 20*ab25eeb5Syz155240 char *name; 217c478bd9Sstevel@tonic-gate int opts; 227c478bd9Sstevel@tonic-gate { 23*ab25eeb5Syz155240 ip_pool_node_t *ipnp, *ipnpn, ipn; 247c478bd9Sstevel@tonic-gate ip_pool_t ipp; 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate if ((*copyfunc)(pp, &ipp, sizeof(ipp))) 277c478bd9Sstevel@tonic-gate return NULL; 287c478bd9Sstevel@tonic-gate 29*ab25eeb5Syz155240 if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN)) 30*ab25eeb5Syz155240 return ipp.ipo_next; 31*ab25eeb5Syz155240 327c478bd9Sstevel@tonic-gate if ((opts & OPT_DEBUG) == 0) { 337c478bd9Sstevel@tonic-gate if ((ipp.ipo_flags & IPOOL_ANON) != 0) 347c478bd9Sstevel@tonic-gate PRINTF("# 'anonymous' tree %s\n", ipp.ipo_name); 357c478bd9Sstevel@tonic-gate PRINTF("table role = "); 367c478bd9Sstevel@tonic-gate } else { 377c478bd9Sstevel@tonic-gate PRINTF("Name: %s", ipp.ipo_name); 387c478bd9Sstevel@tonic-gate if ((ipp.ipo_flags & IPOOL_ANON) == IPOOL_ANON) 397c478bd9Sstevel@tonic-gate PRINTF("(anon)"); 407c478bd9Sstevel@tonic-gate putchar(' '); 417c478bd9Sstevel@tonic-gate PRINTF("Role: "); 427c478bd9Sstevel@tonic-gate } 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate switch (ipp.ipo_unit) 457c478bd9Sstevel@tonic-gate { 467c478bd9Sstevel@tonic-gate case IPL_LOGIPF : 477c478bd9Sstevel@tonic-gate printf("ipf"); 487c478bd9Sstevel@tonic-gate break; 497c478bd9Sstevel@tonic-gate case IPL_LOGNAT : 507c478bd9Sstevel@tonic-gate printf("nat"); 517c478bd9Sstevel@tonic-gate break; 527c478bd9Sstevel@tonic-gate case IPL_LOGSTATE : 537c478bd9Sstevel@tonic-gate printf("state"); 547c478bd9Sstevel@tonic-gate break; 557c478bd9Sstevel@tonic-gate case IPL_LOGAUTH : 567c478bd9Sstevel@tonic-gate printf("auth"); 577c478bd9Sstevel@tonic-gate break; 587c478bd9Sstevel@tonic-gate case IPL_LOGSYNC : 597c478bd9Sstevel@tonic-gate printf("sync"); 607c478bd9Sstevel@tonic-gate break; 617c478bd9Sstevel@tonic-gate case IPL_LOGSCAN : 627c478bd9Sstevel@tonic-gate printf("scan"); 637c478bd9Sstevel@tonic-gate break; 647c478bd9Sstevel@tonic-gate case IPL_LOGLOOKUP : 657c478bd9Sstevel@tonic-gate printf("lookup"); 667c478bd9Sstevel@tonic-gate break; 677c478bd9Sstevel@tonic-gate case IPL_LOGCOUNT : 687c478bd9Sstevel@tonic-gate printf("count"); 697c478bd9Sstevel@tonic-gate break; 707c478bd9Sstevel@tonic-gate default : 717c478bd9Sstevel@tonic-gate printf("unknown(%d)", ipp.ipo_unit); 727c478bd9Sstevel@tonic-gate } 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate if ((opts & OPT_DEBUG) == 0) { 757c478bd9Sstevel@tonic-gate PRINTF(" type = tree number = %s\n", ipp.ipo_name); 767c478bd9Sstevel@tonic-gate PRINTF("\t{"); 777c478bd9Sstevel@tonic-gate } else { 787c478bd9Sstevel@tonic-gate putchar(' '); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate PRINTF("\tReferences: %d\tHits: %lu\n", ipp.ipo_ref, 817c478bd9Sstevel@tonic-gate ipp.ipo_hits); 827c478bd9Sstevel@tonic-gate PRINTF("\tNodes Starting at %p\n", ipp.ipo_list); 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate ipnpn = ipp.ipo_list; 867c478bd9Sstevel@tonic-gate ipp.ipo_list = NULL; 877c478bd9Sstevel@tonic-gate while (ipnpn != NULL) { 887c478bd9Sstevel@tonic-gate ipnp = (ip_pool_node_t *)malloc(sizeof(*ipnp)); 89*ab25eeb5Syz155240 (*copyfunc)(ipnpn, ipnp, sizeof(ipn)); 907c478bd9Sstevel@tonic-gate ipnpn = ipnp->ipn_next; 917c478bd9Sstevel@tonic-gate ipnp->ipn_next = ipp.ipo_list; 927c478bd9Sstevel@tonic-gate ipp.ipo_list = ipnp; 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate 95*ab25eeb5Syz155240 if (ipp.ipo_list == NULL) { 96*ab25eeb5Syz155240 putchar(';'); 97*ab25eeb5Syz155240 } else { 987c478bd9Sstevel@tonic-gate for (ipnp = ipp.ipo_list; ipnp != NULL; ) { 997c478bd9Sstevel@tonic-gate ipnp = printpoolnode(ipnp, opts); 1007c478bd9Sstevel@tonic-gate 101*ab25eeb5Syz155240 if ((opts & OPT_DEBUG) == 0) { 1027c478bd9Sstevel@tonic-gate putchar(';'); 1037c478bd9Sstevel@tonic-gate } 104*ab25eeb5Syz155240 } 105*ab25eeb5Syz155240 } 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate if ((opts & OPT_DEBUG) == 0) 1087c478bd9Sstevel@tonic-gate PRINTF(" };\n"); 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate return ipp.ipo_next; 1117c478bd9Sstevel@tonic-gate } 112