]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/blob - tc/q_multiq.c
v3.3.0
[lisovros/iproute2_canprio.git] / tc / q_multiq.c
1 /*
2  * q_multiq.c           Multiqueue aware qdisc
3  *
4  * Copyright (c) 2008, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place - Suite 330, Boston, MA 02111-1307 USA.
18  *
19  * Author: Alexander Duyck <alexander.h.duyck@intel.com>
20  *
21  * Original Authors:    PJ Waskiewicz, <peter.p.waskiewicz.jr@intel.com> (RR)
22  *                      Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> (from PRIO)
23  *
24  */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <syslog.h>
30 #include <fcntl.h>
31 #include <sys/socket.h>
32 #include <netinet/in.h>
33 #include <arpa/inet.h>
34 #include <string.h>
35
36 #include "utils.h"
37 #include "tc_util.h"
38
39 static void explain(void)
40 {
41         fprintf(stderr, "Usage: ... multiq [help]\n");
42 }
43
44 static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
45                             struct nlmsghdr *n)
46 {
47         struct tc_multiq_qopt opt;
48
49         if (argc) {
50                 if (strcmp(*argv, "help") == 0) {
51                         explain();
52                         return -1;
53                 } else {
54                         fprintf(stderr, "What is \"%s\"?\n", *argv);
55                         explain();
56                         return -1;
57                 }
58         }
59
60         addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
61         return 0;
62 }
63
64 int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
65 {
66         struct tc_multiq_qopt *qopt;
67
68         if (opt == NULL)
69                 return 0;
70         if (RTA_PAYLOAD(opt) < sizeof(*qopt))
71                 return 0;
72
73         qopt = RTA_DATA(opt);
74
75         fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands);
76
77         return 0;
78 }
79
80 struct qdisc_util multiq_qdisc_util = {
81         .id             = "multiq",
82         .parse_qopt     = multiq_parse_opt,
83         .print_qopt     = multiq_print_opt,
84 };