4 * Copyright (C) 2012 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
12 #include <sys/ioctl.h>
14 #include "netinet/ip_lookup.h"
15 #include "netinet/ip_pool.h"
19 load_pool(plp, iocfunc)
27 if (pool_open() == -1)
30 op.iplo_unit = plp->ipo_unit;
31 op.iplo_type = IPLT_POOL;
33 strncpy(op.iplo_name, plp->ipo_name, sizeof(op.iplo_name));
34 op.iplo_size = sizeof(pool);
35 op.iplo_struct = &pool;
36 bzero((char *)&pool, sizeof(pool));
37 pool.ipo_unit = plp->ipo_unit;
38 strncpy(pool.ipo_name, plp->ipo_name, sizeof(pool.ipo_name));
39 if (plp->ipo_name[0] == '\0')
40 op.iplo_arg |= IPOOL_ANON;
42 if ((opts & OPT_REMOVE) == 0) {
43 if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op)) {
44 if ((opts & OPT_DONOTHING) == 0) {
45 return ipf_perror_fd(pool_fd(), iocfunc,
51 if (op.iplo_arg & IPOOL_ANON)
52 strncpy(pool.ipo_name, op.iplo_name, sizeof(pool.ipo_name));
54 if ((opts & OPT_VERBOSE) != 0) {
55 pool.ipo_list = plp->ipo_list;
56 (void) printpool(&pool, bcopywrap, pool.ipo_name, opts, NULL);
60 for (a = plp->ipo_list; a != NULL; a = a->ipn_next)
61 load_poolnode(plp->ipo_unit, pool.ipo_name,
64 if ((opts & OPT_REMOVE) != 0) {
65 if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
66 if ((opts & OPT_DONOTHING) == 0) {
67 return ipf_perror_fd(pool_fd(), iocfunc,
68 "delete lookup table");