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");
36 #define usage() return(-1)
38 static int drr_parse_opt(struct qdisc_util
*qu
, int argc
, char **argv
, struct nlmsghdr
*n
)
41 if (strcmp(*argv
, "help") == 0) {
45 fprintf(stderr
, "What is \"%s\"?\n", *argv
);
54 static int drr_parse_class_opt(struct qdisc_util
*qu
, int argc
, char **argv
,
61 addattr_l(n
, 1024, TCA_OPTIONS
, NULL
, 0);
64 if (strcmp(*argv
, "quantum") == 0) {
66 if (get_size(&tmp
, *argv
)) {
67 fprintf(stderr
, "Illegal \"quantum\"\n");
70 addattr_l(n
, 1024, TCA_DRR_QUANTUM
, &tmp
, sizeof(tmp
));
71 } else if (strcmp(*argv
, "help") == 0) {
75 fprintf(stderr
, "What is \"%s\"?\n", *argv
);
82 tail
->rta_len
= (void *) NLMSG_TAIL(n
) - (void *)tail
;
86 static int drr_print_opt(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*opt
)
88 struct rtattr
*tb
[TCA_DRR_MAX
+ 1];
94 parse_rtattr_nested(tb
, TCA_DRR_MAX
, opt
);
96 if (tb
[TCA_DRR_QUANTUM
])
97 fprintf(f
, "quantum %s ",
98 sprint_size(*(__u32
*)RTA_DATA(tb
[TCA_DRR_QUANTUM
]), b1
));
102 static int drr_print_xstats(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*xstats
)
104 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
,