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: Stephen Hemminger <shemminger@vyatta.com>
10 * Fabio Checconi <fabio@gandalf.sssup.it>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 #include <arpa/inet.h>
22 static void explain(void)
24 fprintf(stderr
, "Usage: ... qfq\n");
27 static void explain1(const char *arg
)
29 fprintf(stderr
, "Illegal \"%s\"\n", arg
);
32 static void explain_class(void)
34 fprintf(stderr
, "Usage: ... qfq weight NUMBER maxpkt BYTES\n");
37 static int qfq_parse_opt(struct qdisc_util
*qu
, int argc
, char **argv
,
38 struct nlmsghdr
*n
, const char *dev
)
41 if (matches(*argv
, "help") != 0)
42 fprintf(stderr
, "What is \"%s\"?\n", *argv
);
50 static int qfq_parse_class_opt(struct qdisc_util
*qu
, int argc
, char **argv
,
51 struct nlmsghdr
*n
, const char *dev
)
57 addattr_l(n
, 4096, TCA_OPTIONS
, NULL
, 0);
60 if (matches(*argv
, "weight") == 0) {
62 if (get_u32(&tmp
, *argv
, 10)) {
63 explain1("weight"); return -1;
65 addattr32(n
, 4096, TCA_QFQ_WEIGHT
, tmp
);
66 } else if (matches(*argv
, "maxpkt") == 0) {
68 if (get_u32(&tmp
, *argv
, 10)) {
69 explain1("maxpkt"); return -1;
71 addattr32(n
, 4096, TCA_QFQ_LMAX
, tmp
);
72 } else if (strcmp(*argv
, "help") == 0) {
76 fprintf(stderr
, "What is \"%s\"?\n", *argv
);
83 tail
->rta_len
= (void *)NLMSG_TAIL(n
) - (void *)tail
;
88 static int qfq_print_opt(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*opt
)
90 struct rtattr
*tb
[TCA_QFQ_MAX
+ 1];
95 parse_rtattr_nested(tb
, TCA_QFQ_MAX
, opt
);
97 if (tb
[TCA_QFQ_WEIGHT
]) {
98 fprintf(f
, "weight %u ",
99 rta_getattr_u32(tb
[TCA_QFQ_WEIGHT
]));
102 if (tb
[TCA_QFQ_LMAX
]) {
103 fprintf(f
, "maxpkt %u ",
104 rta_getattr_u32(tb
[TCA_QFQ_LMAX
]));
110 struct qdisc_util qfq_qdisc_util
= {
112 .parse_qopt
= qfq_parse_opt
,
113 .print_qopt
= qfq_print_opt
,
114 .parse_copt
= qfq_parse_class_opt
,
115 .print_copt
= qfq_print_opt
,