1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <unistd.h>
28#include <fcntl.h>
29#include <sys/socket.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32#include <string.h>
33
34#include "utils.h"
35#include "tc_util.h"
36
37static void explain(void)
38{
39 fprintf(stderr, "Usage: ... multiq [help]\n");
40}
41
42static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
43 struct nlmsghdr *n, const char *dev)
44{
45 struct tc_multiq_qopt opt = {};
46
47 if (argc) {
48 if (strcmp(*argv, "help") == 0) {
49 explain();
50 return -1;
51 } else {
52 fprintf(stderr, "What is \"%s\"?\n", *argv);
53 explain();
54 return -1;
55 }
56 }
57
58 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
59 return 0;
60}
61
62static int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
63{
64 struct tc_multiq_qopt *qopt;
65
66 if (opt == NULL)
67 return 0;
68 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
69 return 0;
70
71 qopt = RTA_DATA(opt);
72
73 fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands);
74
75 return 0;
76}
77
78struct qdisc_util multiq_qdisc_util = {
79 .id = "multiq",
80 .parse_qopt = multiq_parse_opt,
81 .print_qopt = multiq_print_opt,
82};
83