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)
56 tail = addattr_nest(n, 4096, TCA_OPTIONS);
59 if (matches(*argv, "weight") == 0) {
61 if (get_u32(&tmp, *argv, 10)) {
62 explain1("weight"); return -1;
64 addattr32(n, 4096, TCA_QFQ_WEIGHT, tmp);
65 } else if (matches(*argv, "maxpkt") == 0) {
67 if (get_u32(&tmp, *argv, 10)) {
68 explain1("maxpkt"); return -1;
70 addattr32(n, 4096, TCA_QFQ_LMAX, tmp);
71 } else if (strcmp(*argv, "help") == 0) {
75 fprintf(stderr, "What is \"%s\"?\n", *argv);
82 addattr_nest_end(n, tail);
87 static int qfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
89 struct rtattr *tb[TCA_QFQ_MAX + 1];
94 parse_rtattr_nested(tb, TCA_QFQ_MAX, opt);
96 if (tb[TCA_QFQ_WEIGHT]) {
97 fprintf(f, "weight %u ",
98 rta_getattr_u32(tb[TCA_QFQ_WEIGHT]));
101 if (tb[TCA_QFQ_LMAX]) {
102 fprintf(f, "maxpkt %u ",
103 rta_getattr_u32(tb[TCA_QFQ_LMAX]));
109 struct qdisc_util qfq_qdisc_util = {
111 .parse_qopt = qfq_parse_opt,
112 .print_qopt = qfq_print_opt,
113 .parse_copt = qfq_parse_class_opt,
114 .print_copt = qfq_print_opt,