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.
5*637Sml37995  *
6*637Sml37995  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
7*637Sml37995  * Use is subject to license terms.
80Sstevel@tonic-gate  */
90Sstevel@tonic-gate 
10*637Sml37995 #pragma ident	"%Z%%M%	%I%	%E% SMI"
11*637Sml37995 
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 
170Sstevel@tonic-gate ip_pool_t *printpool(pp, copyfunc, opts)
180Sstevel@tonic-gate ip_pool_t *pp;
190Sstevel@tonic-gate copyfunc_t copyfunc;
200Sstevel@tonic-gate int opts;
210Sstevel@tonic-gate {
22*637Sml37995 	ip_pool_node_t *ipnp, *ipnpn;
230Sstevel@tonic-gate 	ip_pool_t ipp;
240Sstevel@tonic-gate 
250Sstevel@tonic-gate 	if ((*copyfunc)(pp, &ipp, sizeof(ipp)))
260Sstevel@tonic-gate 		return NULL;
270Sstevel@tonic-gate 
280Sstevel@tonic-gate 	if ((opts & OPT_DEBUG) == 0) {
290Sstevel@tonic-gate 		if ((ipp.ipo_flags & IPOOL_ANON) != 0)
300Sstevel@tonic-gate 			PRINTF("# 'anonymous' tree %s\n", ipp.ipo_name);
310Sstevel@tonic-gate 		PRINTF("table role = ");
320Sstevel@tonic-gate 	} else {
330Sstevel@tonic-gate 		PRINTF("Name: %s", ipp.ipo_name);
340Sstevel@tonic-gate 		if ((ipp.ipo_flags & IPOOL_ANON) == IPOOL_ANON)
350Sstevel@tonic-gate 			PRINTF("(anon)");
360Sstevel@tonic-gate 		putchar(' ');
370Sstevel@tonic-gate 		PRINTF("Role: ");
380Sstevel@tonic-gate 	}
390Sstevel@tonic-gate 
400Sstevel@tonic-gate 	switch (ipp.ipo_unit)
410Sstevel@tonic-gate 	{
420Sstevel@tonic-gate 	case IPL_LOGIPF :
430Sstevel@tonic-gate 		printf("ipf");
440Sstevel@tonic-gate 		break;
450Sstevel@tonic-gate 	case IPL_LOGNAT :
460Sstevel@tonic-gate 		printf("nat");
470Sstevel@tonic-gate 		break;
480Sstevel@tonic-gate 	case IPL_LOGSTATE :
490Sstevel@tonic-gate 		printf("state");
500Sstevel@tonic-gate 		break;
510Sstevel@tonic-gate 	case IPL_LOGAUTH :
520Sstevel@tonic-gate 		printf("auth");
530Sstevel@tonic-gate 		break;
540Sstevel@tonic-gate 	case IPL_LOGSYNC :
550Sstevel@tonic-gate 		printf("sync");
560Sstevel@tonic-gate 		break;
570Sstevel@tonic-gate 	case IPL_LOGSCAN :
580Sstevel@tonic-gate 		printf("scan");
590Sstevel@tonic-gate 		break;
600Sstevel@tonic-gate 	case IPL_LOGLOOKUP :
610Sstevel@tonic-gate 		printf("lookup");
620Sstevel@tonic-gate 		break;
630Sstevel@tonic-gate 	case IPL_LOGCOUNT :
640Sstevel@tonic-gate 		printf("count");
650Sstevel@tonic-gate 		break;
660Sstevel@tonic-gate 	default :
670Sstevel@tonic-gate 		printf("unknown(%d)", ipp.ipo_unit);
680Sstevel@tonic-gate 	}
690Sstevel@tonic-gate 
700Sstevel@tonic-gate 	if ((opts & OPT_DEBUG) == 0) {
710Sstevel@tonic-gate 		PRINTF(" type = tree number = %s\n", ipp.ipo_name);
720Sstevel@tonic-gate 		PRINTF("\t{");
730Sstevel@tonic-gate 	} else {
740Sstevel@tonic-gate 		putchar(' ');
750Sstevel@tonic-gate 
760Sstevel@tonic-gate 		PRINTF("\tReferences: %d\tHits: %lu\n", ipp.ipo_ref,
770Sstevel@tonic-gate 			ipp.ipo_hits);
780Sstevel@tonic-gate 		PRINTF("\tNodes Starting at %p\n", ipp.ipo_list);
790Sstevel@tonic-gate 	}
800Sstevel@tonic-gate 
810Sstevel@tonic-gate 	ipnpn = ipp.ipo_list;
820Sstevel@tonic-gate 	ipp.ipo_list = NULL;
830Sstevel@tonic-gate 	while (ipnpn != NULL) {
840Sstevel@tonic-gate 		ipnp = (ip_pool_node_t *)malloc(sizeof(*ipnp));
85*637Sml37995 		(*copyfunc)(ipnpn, ipnp, sizeof(*ipnp));
860Sstevel@tonic-gate 		ipnpn = ipnp->ipn_next;
870Sstevel@tonic-gate 		ipnp->ipn_next = ipp.ipo_list;
880Sstevel@tonic-gate 		ipp.ipo_list = ipnp;
890Sstevel@tonic-gate 	}
900Sstevel@tonic-gate 
910Sstevel@tonic-gate 	for (ipnp = ipp.ipo_list; ipnp != NULL; ) {
920Sstevel@tonic-gate 		ipnp = printpoolnode(ipnp, opts);
930Sstevel@tonic-gate 
94*637Sml37995 		if ((opts & OPT_DEBUG) == 0)
95*637Sml37995 			putchar(';');
960Sstevel@tonic-gate 	}
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 	if ((opts & OPT_DEBUG) == 0)
990Sstevel@tonic-gate 		PRINTF(" };\n");
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate 	return ipp.ipo_next;
1020Sstevel@tonic-gate }
103