]> git.proxmox.com Git - mirror_iproute2.git/blame - tc/q_fifo.c
rtnl_wilddump_request: fix alignment issue for embedded platforms
[mirror_iproute2.git] / tc / q_fifo.c
CommitLineData
aba5acdf
SH
1/*
2 * q_fifo.c FIFO.
3 *
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.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 */
12
13#include <stdio.h>
14#include <stdlib.h>
15#include <unistd.h>
16#include <syslog.h>
17#include <fcntl.h>
18#include <sys/socket.h>
19#include <netinet/in.h>
20#include <arpa/inet.h>
21#include <string.h>
22
23#include "utils.h"
24#include "tc_util.h"
25
26static void explain(void)
27{
f703129d 28 fprintf(stderr, "Usage: ... <[p|b]fifo | pfifo_head_drop> [ limit NUMBER ]\n");
aba5acdf
SH
29}
30
aba5acdf
SH
31static int fifo_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
32{
33 int ok=0;
34 struct tc_fifo_qopt opt;
35 memset(&opt, 0, sizeof(opt));
36
37 while (argc > 0) {
38 if (strcmp(*argv, "limit") == 0) {
39 NEXT_ARG();
40 if (get_size(&opt.limit, *argv)) {
41 fprintf(stderr, "Illegal \"limit\"\n");
42 return -1;
43 }
44 ok++;
45 } else if (strcmp(*argv, "help") == 0) {
46 explain();
47 return -1;
48 } else {
49 fprintf(stderr, "What is \"%s\"?\n", *argv);
50 explain();
51 return -1;
52 }
53 argc--; argv++;
54 }
55
56 if (ok)
57 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
58 return 0;
59}
60
61static int fifo_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
62{
63 struct tc_fifo_qopt *qopt;
64
65 if (opt == NULL)
66 return 0;
67
68 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
69 return -1;
70 qopt = RTA_DATA(opt);
71 if (strcmp(qu->id, "bfifo") == 0) {
72 SPRINT_BUF(b1);
73 fprintf(f, "limit %s", sprint_size(qopt->limit, b1));
74 } else
75 fprintf(f, "limit %up", qopt->limit);
76 return 0;
77}
78
aba5acdf 79
95812b56 80struct qdisc_util bfifo_qdisc_util = {
f2f99e2e
SH
81 .id = "bfifo",
82 .parse_qopt = fifo_parse_opt,
83 .print_qopt = fifo_print_opt,
aba5acdf
SH
84};
85
95812b56 86struct qdisc_util pfifo_qdisc_util = {
f2f99e2e
SH
87 .id = "pfifo",
88 .parse_qopt = fifo_parse_opt,
89 .print_qopt = fifo_print_opt,
aba5acdf 90};
78d55b6e 91
f703129d
HPP
92struct qdisc_util pfifo_head_drop_qdisc_util = {
93 .id = "pfifo_head_drop",
94 .parse_qopt = fifo_parse_opt,
95 .print_qopt = fifo_print_opt,
96};
97
78d55b6e 98extern int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
95812b56 99struct qdisc_util pfifo_fast_qdisc_util = {
f2f99e2e
SH
100 .id = "pfifo_fast",
101 .print_qopt = prio_print_opt,
78d55b6e 102};