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);
53 static int drr_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
60 addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
63 if (strcmp(*argv, "quantum") == 0) {
65 if (get_size(&tmp, *argv)) {
66 fprintf(stderr, "Illegal \"quantum\"\n");
69 addattr_l(n, 1024, TCA_DRR_QUANTUM, &tmp, sizeof(tmp));
70 } else if (strcmp(*argv, "help") == 0) {
74 fprintf(stderr, "What is \"%s\"?\n", *argv);
81 tail->rta_len = (void *) NLMSG_TAIL(n) - (void *)tail;
85 static int drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
87 struct rtattr *tb[TCA_DRR_MAX + 1];
93 parse_rtattr_nested(tb, TCA_DRR_MAX, opt);
95 if (tb[TCA_DRR_QUANTUM])
96 fprintf(f, "quantum %s ",
97 sprint_size(*(__u32 *)RTA_DATA(tb[TCA_DRR_QUANTUM]), b1));
101 static int drr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
103 struct tc_drr_stats *x;
108 if (RTA_PAYLOAD(xstats) < sizeof(*x))
110 x = RTA_DATA(xstats);
112 fprintf(f, " deficit %s ", sprint_size(x->deficit, b1));
116 struct qdisc_util drr_qdisc_util = {
118 .parse_qopt = drr_parse_opt,
119 .print_qopt = drr_print_opt,
120 .print_xstats = drr_print_xstats,
121 .parse_copt = drr_parse_class_opt,
122 .print_copt = drr_print_opt,