4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Patrick McHardy <kaber@trash.net>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
26 static void explain(void)
28 fprintf(stderr, "Usage: ... drr\n");
31 static void explain2(void)
33 fprintf(stderr, "Usage: ... drr quantum SIZE\n");
37 static int drr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
40 if (strcmp(*argv, "help") == 0) {
44 fprintf(stderr, "What is \"%s\"?\n", *argv);
52 static int drr_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
59 addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
62 if (strcmp(*argv, "quantum") == 0) {
64 if (get_size(&tmp, *argv)) {
65 fprintf(stderr, "Illegal \"quantum\"\n");
68 addattr_l(n, 1024, TCA_DRR_QUANTUM, &tmp, sizeof(tmp));
69 } else if (strcmp(*argv, "help") == 0) {
73 fprintf(stderr, "What is \"%s\"?\n", *argv);
80 tail->rta_len = (void *) NLMSG_TAIL(n) - (void *)tail;
84 static int drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
86 struct rtattr *tb[TCA_DRR_MAX + 1];
92 parse_rtattr_nested(tb, TCA_DRR_MAX, opt);
94 if (tb[TCA_DRR_QUANTUM])
95 fprintf(f, "quantum %s ",
96 sprint_size(*(__u32 *)RTA_DATA(tb[TCA_DRR_QUANTUM]), b1));
100 static int drr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
102 struct tc_drr_stats *x;
107 if (RTA_PAYLOAD(xstats) < sizeof(*x))
109 x = RTA_DATA(xstats);
111 fprintf(f, " deficit %s ", sprint_size(x->deficit, b1));
115 struct qdisc_util drr_qdisc_util = {
117 .parse_qopt = drr_parse_opt,
118 .print_qopt = drr_print_opt,
119 .print_xstats = drr_print_xstats,
120 .parse_copt = drr_parse_class_opt,
121 .print_copt = drr_print_opt,