1 /*
2 * Copyright (C) 2012 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 */
6
7 #include "ipf.h"
8
9
10 ippool_dst_t *
printdstlist(ippool_dst_t * pp,copyfunc_t copyfunc,char * name,int opts,ipf_dstnode_t * nodes,wordtab_t * fields)11 printdstlist( ippool_dst_t *pp, copyfunc_t copyfunc, char *name, int opts,
12 ipf_dstnode_t *nodes, wordtab_t *fields)
13 {
14 ipf_dstnode_t *node;
15 ippool_dst_t dst;
16
17 if ((*copyfunc)(pp, &dst, sizeof(dst)))
18 return (NULL);
19
20 if ((name != NULL) && strncmp(name, dst.ipld_name, FR_GROUPLEN))
21 return (dst.ipld_next);
22
23 if (fields == NULL)
24 printdstlistdata(&dst, opts);
25
26 if ((dst.ipld_flags & IPDST_DELETE) != 0)
27 PRINTF("# ");
28 if ((opts & OPT_DEBUG) == 0)
29 PRINTF("\t{");
30
31 if (nodes == NULL) {
32 putchar(';');
33 } else {
34 for (node = nodes; node != NULL; ) {
35 ipf_dstnode_t *n;
36
37 n = calloc(1, node->ipfd_size);
38 if (n == NULL)
39 break;
40 if ((*copyfunc)(node, n, node->ipfd_size)) {
41 free(n);
42 return (NULL);
43 }
44
45 node = printdstlistnode(n, bcopywrap, opts, fields);
46
47 free(n);
48 }
49 }
50
51 if ((opts & OPT_DEBUG) == 0)
52 PRINTF(" };\n");
53
54 return (dst.ipld_next);
55 }
56