int 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); if ((nodes = pfctl_update_qstats(dev, &root)) < 0) return (-1); 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) == -1) return (-1); 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); }
int 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 ((nodes = pfctl_update_qstats(dev, &root)) < 0) return (-1); if (nodes == 0) printf("No queue in use\n"); 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 && nodes > 0) { printf("\n"); fflush(stdout); sleep(STAT_INTERVAL); if ((nodes = pfctl_update_qstats(dev, &root)) == -1) return (-1); for (node = root; node != NULL; node = node->next) { if (iface != NULL && strcmp(node->altq.ifname, iface)) continue; #ifdef __FreeBSD__ if (node->altq.local_flags & PFALTQ_FLAG_IF_REMOVED) continue; #endif pfctl_print_altq_node(dev, node, 0, opts); } } pfctl_free_altq_node(root); return (0); }