Fix ip_tunnel_parm. This is used to communicate with kernel
[iproute2.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 #define usage() return(-1)
45
46 static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
47                             struct nlmsghdr *n)
48 {
49         struct tc_multiq_qopt opt;
50
51         if (argc > 0) {
52                 if (strcmp(*argv, "help") == 0) {
53                         explain();
54                         return -1;
55                 } else {
56                         fprintf(stderr, "What is \"%s\"?\n", *argv);
57                         explain();
58                         return -1;
59                 }
60                 argc--; argv++;
61         }
62
63         addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
64         return 0;
65 }
66
67 int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
68 {
69         struct tc_multiq_qopt *qopt;
70
71         if (opt == NULL)
72                 return 0;
73         if (RTA_PAYLOAD(opt) < sizeof(*qopt))
74                 return 0;
75
76         qopt = RTA_DATA(opt);
77
78         fprintf(f, "bands %u/%u ", qopt->bands, qopt->max_bands);
79
80         return 0;
81 }
82
83 struct qdisc_util multiq_qdisc_util = {
84         .id             = "multiq",
85         .parse_qopt     = multiq_parse_opt,
86         .print_qopt     = multiq_print_opt,
87 };