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>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
25 static void explain(void)
27 fprintf(stderr, "Usage: ... drr\n");
30 static void explain2(void)
32 fprintf(stderr, "Usage: ... drr quantum SIZE\n");
36 static int drr_parse_opt(struct qdisc_util *qu, int argc, char **argv,
37 struct nlmsghdr *n, const char *dev)
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,
53 struct nlmsghdr *n, const char *dev)
58 tail = addattr_nest(n, 1024, TCA_OPTIONS);
61 if (strcmp(*argv, "quantum") == 0) {
63 if (get_size(&tmp, *argv)) {
64 fprintf(stderr, "Illegal \"quantum\"\n");
67 addattr_l(n, 1024, TCA_DRR_QUANTUM, &tmp, sizeof(tmp));
68 } else if (strcmp(*argv, "help") == 0) {
72 fprintf(stderr, "What is \"%s\"?\n", *argv);
79 addattr_nest_end(n, tail);
83 static int drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
85 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(rta_getattr_u32(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;
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,