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(dst, iocfunc, nodes)
26 if (dst->ipld_name[0] == '\0')
29 if (pool_open() == -1)
32 op.iplo_unit = dst->ipld_unit;
33 op.iplo_type = IPLT_DSTLIST;
35 strncpy(op.iplo_name, dst->ipld_name, sizeof(op.iplo_name));
36 op.iplo_size = sizeof(dest);
37 op.iplo_struct = &dest;
38 bzero((char *)&dest, sizeof(dest));
39 dest.ipld_unit = dst->ipld_unit;
40 dest.ipld_policy = dst->ipld_policy;
41 dest.ipld_flags = dst->ipld_flags;
42 strncpy(dest.ipld_name, dst->ipld_name, sizeof(dest.ipld_name));
44 if ((opts & OPT_REMOVE) == 0) {
45 if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
46 if ((opts & OPT_DONOTHING) == 0) {
47 return ipf_perror_fd(pool_fd(), iocfunc,
48 "add destination list table");
52 if ((opts & OPT_VERBOSE) != 0) {
53 dest.ipld_dests = dst->ipld_dests;
54 printdstlist(&dest, bcopywrap, dest.ipld_name, opts, nodes, NULL);
55 dest.ipld_dests = NULL;
58 for (a = nodes; a != NULL; a = a->ipfd_next)
59 load_dstlistnode(dst->ipld_unit, dest.ipld_name, a, iocfunc);
61 if ((opts & OPT_REMOVE) != 0) {
62 if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
63 if ((opts & OPT_DONOTHING) == 0) {
64 return ipf_perror_fd(pool_fd(), iocfunc,
65 "delete destination list table");