2 * Copyright (C) 2012 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: load_dstlist.c,v 1.1.2.5 2012/07/22 08:04:24 darren_r Exp $
10 #include <sys/ioctl.h>
12 #include "netinet/ip_lookup.h"
13 #include "netinet/ip_dstlist.h"
17 load_dstlist(ippool_dst_t *dst, ioctlfunc_t iocfunc, ipf_dstnode_t *nodes)
23 if (dst->ipld_name[0] == '\0')
26 if (pool_open() == -1)
29 op.iplo_unit = dst->ipld_unit;
30 op.iplo_type = IPLT_DSTLIST;
32 strncpy(op.iplo_name, dst->ipld_name, sizeof(op.iplo_name));
33 op.iplo_size = sizeof(dest);
34 op.iplo_struct = &dest;
35 bzero((char *)&dest, sizeof(dest));
36 dest.ipld_unit = dst->ipld_unit;
37 dest.ipld_policy = dst->ipld_policy;
38 dest.ipld_flags = dst->ipld_flags;
39 strncpy(dest.ipld_name, dst->ipld_name, sizeof(dest.ipld_name));
41 if ((opts & OPT_REMOVE) == 0) {
42 if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
43 if ((opts & OPT_DONOTHING) == 0) {
44 return (ipf_perror_fd(pool_fd(), iocfunc,
45 "add destination list table"));
49 if ((opts & OPT_VERBOSE) != 0) {
50 dest.ipld_dests = dst->ipld_dests;
51 printdstlist(&dest, bcopywrap, dest.ipld_name, opts, nodes, NULL);
52 dest.ipld_dests = NULL;
55 for (a = nodes; a != NULL; a = a->ipfd_next)
56 load_dstlistnode(dst->ipld_unit, dest.ipld_name, a, iocfunc);
58 if ((opts & OPT_REMOVE) != 0) {
59 if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
60 if ((opts & OPT_DONOTHING) == 0) {
61 return (ipf_perror_fd(pool_fd(), iocfunc,
62 "delete destination list table"));