summaryrefslogtreecommitdiffstats
path: root/contrib/pf/pfctl/pfctl_qstats.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pf/pfctl/pfctl_qstats.c')
-rw-r--r--contrib/pf/pfctl/pfctl_qstats.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/contrib/pf/pfctl/pfctl_qstats.c b/contrib/pf/pfctl/pfctl_qstats.c
index 0e8b61f..a46603c 100644
--- a/contrib/pf/pfctl/pfctl_qstats.c
+++ b/contrib/pf/pfctl/pfctl_qstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_qstats.c,v 1.24 2003/07/31 09:46:08 kjc Exp $ */
+/* $OpenBSD: pfctl_qstats.c,v 1.29 2004/03/15 15:25:44 dhartmei Exp $ */
/*
* Copyright (c) Henning Brauer <henning@openbsd.org>
@@ -84,28 +84,40 @@ void pfctl_print_altq_nodestat(int,
void update_avg(struct pf_altq_node *);
int
-pfctl_show_altq(int dev, int opts, int verbose2)
+pfctl_show_altq(int dev, const char *iface, int opts, int verbose2)
{
struct pf_altq_node *root = NULL, *node;
+ int nodes, dotitle = (opts & PF_OPT_SHOWALL);
#ifdef __FreeBSD__
if (!altqsupport)
return (-1);
#endif
- if (pfctl_update_qstats(dev, &root))
+
+ if ((nodes = pfctl_update_qstats(dev, &root)) < 0)
return (-1);
- for (node = root; node != NULL; node = node->next)
+ for (node = root; node != NULL; node = node->next) {
+ if (iface != NULL && strcmp(node->altq.ifname, iface))
+ continue;
+ if (dotitle) {
+ pfctl_print_title("ALTQ:");
+ dotitle = 0;
+ }
pfctl_print_altq_node(dev, node, 0, opts);
+ }
while (verbose2) {
printf("\n");
fflush(stdout);
sleep(STAT_INTERVAL);
- if (pfctl_update_qstats(dev, &root))
+ if (pfctl_update_qstats(dev, &root) == -1)
return (-1);
- for (node = root; node != NULL; node = node->next)
+ for (node = root; node != NULL; node = node->next) {
+ if (iface != NULL && strcmp(node->altq.ifname, iface))
+ continue;
pfctl_print_altq_node(dev, node, 0, opts);
+ }
}
pfctl_free_altq_node(root);
return (0);
@@ -162,7 +174,7 @@ pfctl_update_qstats(int dev, struct pf_altq_node **root)
}
}
}
- return (0);
+ return (mnr);
}
void
@@ -252,12 +264,13 @@ pfctl_print_altq_node(int dev, const struct pf_altq_node *node, unsigned level,
pfctl_print_altq_nodestat(dev, node);
if (opts & PF_OPT_DEBUG)
- printf(" [ qid=%u ifname=%s ifbandwidth=%s ]\n", node->altq.qid,
- node->altq.ifname, rate2str((double)(node->altq.ifbandwidth)));
+ printf(" [ qid=%u ifname=%s ifbandwidth=%s ]\n",
+ node->altq.qid, node->altq.ifname,
+ rate2str((double)(node->altq.ifbandwidth)));
for (child = node->children; child != NULL;
child = child->next)
- pfctl_print_altq_node(dev, child, level+1, opts);
+ pfctl_print_altq_node(dev, child, level + 1, opts);
}
void
OpenPOWER on IntegriCloud