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
)
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];
93 parse_rtattr_nested(tb
, TCA_DRR_MAX
, opt
);
95 if (tb
[TCA_DRR_QUANTUM
])
96 fprintf(f
, "quantum %s ",
97 sprint_size(rta_getattr_u32(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
;
109 if (RTA_PAYLOAD(xstats
) < sizeof(*x
))
111 x
= RTA_DATA(xstats
);
113 fprintf(f
, " deficit %s ", sprint_size(x
->deficit
, b1
));
117 struct qdisc_util drr_qdisc_util
= {
119 .parse_qopt
= drr_parse_opt
,
120 .print_qopt
= drr_print_opt
,
121 .print_xstats
= drr_print_xstats
,
122 .parse_copt
= drr_parse_class_opt
,
123 .print_copt
= drr_print_opt
,