1/* 2 * Copyright (C) 2002 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 */ 6 7#include <sys/ioctl.h> 8#include "ipf.h" 9#include "netinet/ipl.h" 10 11#define PRINTF (void)printf 12#define FPRINTF (void)fprintf 13 14 15ip_pool_t *printpool_live(pool, fd, name, opts) 16ip_pool_t *pool; 17int fd; 18char *name; 19int opts; 20{ 21 ip_pool_node_t entry, *top, *node; 22 ipflookupiter_t iter; 23 int printed, last; 24 ipfobj_t obj; 25 26 if ((name != NULL) && strncmp(name, pool->ipo_name, FR_GROUPLEN)) 27 return pool->ipo_next; 28 29 printpooldata(pool, opts); 30 31 if ((pool->ipo_flags & IPOOL_DELETE) != 0) 32 PRINTF("# "); 33 if ((opts & OPT_DEBUG) == 0) 34 PRINTF("\t{"); 35 36 obj.ipfo_rev = IPFILTER_VERSION; 37 obj.ipfo_type = IPFOBJ_LOOKUPITER; 38 obj.ipfo_ptr = &iter; 39 obj.ipfo_size = sizeof(iter); 40 41 iter.ili_data = &entry; 42 iter.ili_type = IPLT_POOL; 43 iter.ili_otype = IPFLOOKUPITER_NODE; 44 iter.ili_ival = IPFGENITER_LOOKUP; 45 iter.ili_unit = pool->ipo_unit; 46 strncpy(iter.ili_name, pool->ipo_name, FR_GROUPLEN); 47 48 last = 0; 49 top = NULL; 50 printed = 0; 51 52 while (!last && (ioctl(fd, SIOCLOOKUPITER, &obj) == 0)) { 53 if (entry.ipn_next == NULL) 54 last = 1;
| 1/* 2 * Copyright (C) 2002 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 */ 6 7#include <sys/ioctl.h> 8#include "ipf.h" 9#include "netinet/ipl.h" 10 11#define PRINTF (void)printf 12#define FPRINTF (void)fprintf 13 14 15ip_pool_t *printpool_live(pool, fd, name, opts) 16ip_pool_t *pool; 17int fd; 18char *name; 19int opts; 20{ 21 ip_pool_node_t entry, *top, *node; 22 ipflookupiter_t iter; 23 int printed, last; 24 ipfobj_t obj; 25 26 if ((name != NULL) && strncmp(name, pool->ipo_name, FR_GROUPLEN)) 27 return pool->ipo_next; 28 29 printpooldata(pool, opts); 30 31 if ((pool->ipo_flags & IPOOL_DELETE) != 0) 32 PRINTF("# "); 33 if ((opts & OPT_DEBUG) == 0) 34 PRINTF("\t{"); 35 36 obj.ipfo_rev = IPFILTER_VERSION; 37 obj.ipfo_type = IPFOBJ_LOOKUPITER; 38 obj.ipfo_ptr = &iter; 39 obj.ipfo_size = sizeof(iter); 40 41 iter.ili_data = &entry; 42 iter.ili_type = IPLT_POOL; 43 iter.ili_otype = IPFLOOKUPITER_NODE; 44 iter.ili_ival = IPFGENITER_LOOKUP; 45 iter.ili_unit = pool->ipo_unit; 46 strncpy(iter.ili_name, pool->ipo_name, FR_GROUPLEN); 47 48 last = 0; 49 top = NULL; 50 printed = 0; 51 52 while (!last && (ioctl(fd, SIOCLOOKUPITER, &obj) == 0)) { 53 if (entry.ipn_next == NULL) 54 last = 1;
|
60 } 61 62 while (top != NULL) { 63 node = top; 64 (void) printpoolnode(node, opts); 65 if ((opts & OPT_DEBUG) == 0) 66 putchar(';'); 67 top = node->ipn_next; 68 free(node); 69 printed++; 70 } 71 72 if (printed == 0) 73 putchar(';'); 74 75 if ((opts & OPT_DEBUG) == 0) 76 PRINTF(" };\n");
| 61 } 62 63 while (top != NULL) { 64 node = top; 65 (void) printpoolnode(node, opts); 66 if ((opts & OPT_DEBUG) == 0) 67 putchar(';'); 68 top = node->ipn_next; 69 free(node); 70 printed++; 71 } 72 73 if (printed == 0) 74 putchar(';'); 75 76 if ((opts & OPT_DEBUG) == 0) 77 PRINTF(" };\n");
|