Move /var/svc/log to /var/log/svc
[unleashed/lotheac.git] / usr / src / cmd / ipf / lib / common / printpool.c
blob842086274ba8ff92cb4dc9a5dde2458803a220a7
1 /*
2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
8 */
10 #pragma ident "%Z%%M% %I% %E% SMI"
12 #include "ipf.h"
14 #define PRINTF (void)printf
15 #define FPRINTF (void)fprintf
17 ip_pool_t *printpool(pp, copyfunc, name, opts)
18 ip_pool_t *pp;
19 copyfunc_t copyfunc;
20 char *name;
21 int opts;
23 ip_pool_node_t *ipnp, *ipnpn, ipn;
24 ip_pool_t ipp;
26 if ((*copyfunc)(pp, &ipp, sizeof(ipp)))
27 return NULL;
29 if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN))
30 return ipp.ipo_next;
32 if ((opts & OPT_DEBUG) == 0) {
33 if ((ipp.ipo_flags & IPOOL_ANON) != 0)
34 PRINTF("# 'anonymous' tree %s\n", ipp.ipo_name);
35 PRINTF("table role = ");
36 } else {
37 PRINTF("Name: %s", ipp.ipo_name);
38 if ((ipp.ipo_flags & IPOOL_ANON) == IPOOL_ANON)
39 PRINTF("(anon)");
40 putchar(' ');
41 PRINTF("Role: ");
44 switch (ipp.ipo_unit)
46 case IPL_LOGIPF :
47 printf("ipf");
48 break;
49 case IPL_LOGNAT :
50 printf("nat");
51 break;
52 case IPL_LOGSTATE :
53 printf("state");
54 break;
55 case IPL_LOGAUTH :
56 printf("auth");
57 break;
58 case IPL_LOGSYNC :
59 printf("sync");
60 break;
61 case IPL_LOGSCAN :
62 printf("scan");
63 break;
64 case IPL_LOGLOOKUP :
65 printf("lookup");
66 break;
67 case IPL_LOGCOUNT :
68 printf("count");
69 break;
70 default :
71 printf("unknown(%d)", ipp.ipo_unit);
74 if ((opts & OPT_DEBUG) == 0) {
75 PRINTF(" type = tree number = %s\n", ipp.ipo_name);
76 PRINTF("\t{");
77 } else {
78 putchar(' ');
80 PRINTF("\tReferences: %d\tHits: %lu\n", ipp.ipo_ref,
81 ipp.ipo_hits);
82 PRINTF("\tNodes Starting at %p\n", ipp.ipo_list);
85 ipnpn = ipp.ipo_list;
86 ipp.ipo_list = NULL;
87 while (ipnpn != NULL) {
88 ipnp = (ip_pool_node_t *)malloc(sizeof(*ipnp));
89 (*copyfunc)(ipnpn, ipnp, sizeof(ipn));
90 ipnpn = ipnp->ipn_next;
91 ipnp->ipn_next = ipp.ipo_list;
92 ipp.ipo_list = ipnp;
95 if (ipp.ipo_list == NULL) {
96 putchar(';');
97 } else {
98 for (ipnp = ipp.ipo_list; ipnp != NULL; ) {
99 ipnp = printpoolnode(ipnp, opts);
101 if ((opts & OPT_DEBUG) == 0) {
102 putchar(';');
107 if ((opts & OPT_DEBUG) == 0)
108 PRINTF(" };\n");
110 return ipp.ipo_next;