xref: /freebsd-src/sbin/ipf/libipf/printpooldata.c (revision 7531c434a593b2f369d69c85551e7ad1ebb7499a)
141edb306SCy Schubert /*
241edb306SCy Schubert  * Copyright (C) 2012 by Darren Reed.
341edb306SCy Schubert  *
441edb306SCy Schubert  * See the IPFILTER.LICENCE file for details on licencing.
541edb306SCy Schubert  */
641edb306SCy Schubert 
741edb306SCy Schubert #include "ipf.h"
841edb306SCy Schubert #include <ctype.h>
941edb306SCy Schubert 
1041edb306SCy Schubert 
1141edb306SCy Schubert void
printpooldata(ip_pool_t * pool,int opts)12efeb8bffSCy Schubert printpooldata(ip_pool_t *pool, int opts)
1341edb306SCy Schubert {
1441edb306SCy Schubert 
15*7531c434SCy Schubert 	if (opts & OPT_SAVEOUT) {
16*7531c434SCy Schubert 		PRINTF("pool ");
17*7531c434SCy Schubert 	} else if ((opts & OPT_DEBUG) == 0) {
1841edb306SCy Schubert 		if ((pool->ipo_flags & IPOOL_ANON) != 0)
1941edb306SCy Schubert 			PRINTF("# 'anonymous' tree %s\n", pool->ipo_name);
2041edb306SCy Schubert 		if ((pool->ipo_flags & IPOOL_DELETE) != 0)
2141edb306SCy Schubert 			PRINTF("# ");
2241edb306SCy Schubert 		PRINTF("table role=");
2341edb306SCy Schubert 	} else {
2441edb306SCy Schubert 		if ((pool->ipo_flags & IPOOL_DELETE) != 0)
2541edb306SCy Schubert 			PRINTF("# ");
2641edb306SCy Schubert 		PRINTF("%s: %s",
2741edb306SCy Schubert 			ISDIGIT(*pool->ipo_name) ? "Number" : "Name",
2841edb306SCy Schubert 			pool->ipo_name);
2941edb306SCy Schubert 		if ((pool->ipo_flags & IPOOL_ANON) == IPOOL_ANON)
3041edb306SCy Schubert 			PRINTF("(anon)");
3141edb306SCy Schubert 		putchar(' ');
3241edb306SCy Schubert 		PRINTF("Role: ");
3341edb306SCy Schubert 	}
3441edb306SCy Schubert 
3541edb306SCy Schubert 	printunit(pool->ipo_unit);
3641edb306SCy Schubert 
37*7531c434SCy Schubert 	if ((opts & OPT_SAVEOUT)) {
38*7531c434SCy Schubert 		PRINTF("/tree (%s \"\%s\";)\n",
39*7531c434SCy Schubert 			(!*pool->ipo_name || ISDIGIT(*pool->ipo_name)) ? \
40*7531c434SCy Schubert 			"number" : "name", pool->ipo_name);
41*7531c434SCy Schubert 	} else if ((opts & OPT_DEBUG) == 0) {
4241edb306SCy Schubert 		PRINTF(" type=tree %s=%s\n",
4341edb306SCy Schubert 			(!*pool->ipo_name || ISDIGIT(*pool->ipo_name)) ? \
4441edb306SCy Schubert 			"number" : "name", pool->ipo_name);
4541edb306SCy Schubert 	} else {
4641edb306SCy Schubert 		putchar(' ');
4741edb306SCy Schubert 
4841edb306SCy Schubert 		PRINTF("\tReferences: %d\tHits: %lu\n", pool->ipo_ref,
4941edb306SCy Schubert 			pool->ipo_hits);
5041edb306SCy Schubert 		if ((pool->ipo_flags & IPOOL_DELETE) != 0)
5141edb306SCy Schubert 			PRINTF("# ");
5241edb306SCy Schubert 		PRINTF("\tNodes Starting at %p\n", pool->ipo_list);
5341edb306SCy Schubert 	}
5441edb306SCy Schubert }
55