1145519Sdarrenr/* $FreeBSD$ */ 2145510Sdarrenr 3145510Sdarrenr/* 4255332Scy * Copyright (C) 2012 by Darren Reed. 5145510Sdarrenr * 6145510Sdarrenr * See the IPFILTER.LICENCE file for details on licencing. 7145510Sdarrenr */ 8145510Sdarrenr 9145510Sdarrenr#include "ipf.h" 10145510Sdarrenr 11145510Sdarrenr 12255332Scyip_pool_t * 13255332Scyprintpool(pp, copyfunc, name, opts, fields) 14255332Scy ip_pool_t *pp; 15255332Scy copyfunc_t copyfunc; 16255332Scy char *name; 17255332Scy int opts; 18255332Scy wordtab_t *fields; 19145510Sdarrenr{ 20255332Scy ip_pool_node_t *ipnp, *ipnpn, ipn, **pnext; 21145510Sdarrenr ip_pool_t ipp; 22145510Sdarrenr 23145510Sdarrenr if ((*copyfunc)(pp, &ipp, sizeof(ipp))) 24145510Sdarrenr return NULL; 25145510Sdarrenr 26145510Sdarrenr if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN)) 27145510Sdarrenr return ipp.ipo_next; 28145510Sdarrenr 29170268Sdarrenr printpooldata(&ipp, opts); 30145510Sdarrenr 31170268Sdarrenr if ((ipp.ipo_flags & IPOOL_DELETE) != 0) 32170268Sdarrenr PRINTF("# "); 33170268Sdarrenr if ((opts & OPT_DEBUG) == 0) 34145510Sdarrenr PRINTF("\t{"); 35145510Sdarrenr 36145510Sdarrenr ipnpn = ipp.ipo_list; 37145510Sdarrenr ipp.ipo_list = NULL; 38255332Scy pnext = &ipp.ipo_list; 39145510Sdarrenr while (ipnpn != NULL) { 40145510Sdarrenr ipnp = (ip_pool_node_t *)malloc(sizeof(*ipnp)); 41145510Sdarrenr (*copyfunc)(ipnpn, ipnp, sizeof(ipn)); 42145510Sdarrenr ipnpn = ipnp->ipn_next; 43255332Scy *pnext = ipnp; 44255332Scy pnext = &ipnp->ipn_next; 45255332Scy ipnp->ipn_next = NULL; 46145510Sdarrenr } 47145510Sdarrenr 48145510Sdarrenr if (ipp.ipo_list == NULL) { 49145510Sdarrenr putchar(';'); 50145510Sdarrenr } else { 51255332Scy for (ipnp = ipp.ipo_list; ipnp != NULL; ipnp = ipnpn) { 52255332Scy ipnpn = printpoolnode(ipnp, opts, fields); 53255332Scy free(ipnp); 54145510Sdarrenr 55145510Sdarrenr if ((opts & OPT_DEBUG) == 0) { 56145510Sdarrenr putchar(';'); 57145510Sdarrenr } 58145510Sdarrenr } 59145510Sdarrenr } 60145510Sdarrenr 61145510Sdarrenr if ((opts & OPT_DEBUG) == 0) 62145510Sdarrenr PRINTF(" };\n"); 63145510Sdarrenr 64145510Sdarrenr return ipp.ipo_next; 65145510Sdarrenr} 66