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>
15 #include <sys/socket.h>
16 #include <netinet/in.h>
17 #include <arpa/inet.h>
23 static void explain(void)
25 fprintf(stderr, "Usage: ... qfq\n");
28 static void explain1(const char *arg)
30 fprintf(stderr, "Illegal \"%s\"\n", arg);
33 static void explain_class(void)
35 fprintf(stderr, "Usage: ... qfq weight NUMBER maxpkt BYTES\n");
38 static int qfq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
42 if (matches(*argv, "help") == 0) {
46 fprintf(stderr, "What is \"%s\"?\n", *argv);
56 static int qfq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
63 addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
66 if (matches(*argv, "weight") == 0) {
68 if (get_u32(&tmp, *argv, 10)) {
69 explain1("weight"); return -1;
71 addattr32(n, 4096, TCA_QFQ_WEIGHT, tmp);
72 } else if (matches(*argv, "maxpkt") == 0) {
74 if (get_u32(&tmp, *argv, 10)) {
75 explain1("maxpkt"); return -1;
77 addattr32(n, 4096, TCA_QFQ_LMAX, tmp);
78 } else if (strcmp(*argv, "help") == 0) {
82 fprintf(stderr, "What is \"%s\"?\n", *argv);
89 tail->rta_len = (void *)NLMSG_TAIL(n) - (void *)tail;
94 static int qfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
96 struct rtattr *tb[TCA_QFQ_MAX + 1];
101 parse_rtattr_nested(tb, TCA_QFQ_MAX, opt);
103 if (tb[TCA_QFQ_WEIGHT]) {
104 fprintf(f, "weight %u ",
105 rta_getattr_u32(tb[TCA_QFQ_WEIGHT]));
108 if (tb[TCA_QFQ_LMAX]) {
109 fprintf(f, "maxpkt %u ",
110 rta_getattr_u32(tb[TCA_QFQ_LMAX]));
116 struct qdisc_util qfq_qdisc_util = {
118 .parse_qopt = qfq_parse_opt,
119 .print_qopt = qfq_print_opt,
120 .parse_copt = qfq_parse_class_opt,
121 .print_copt = qfq_print_opt,