Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / iproute2 / tc / q_fifo.c
blob9f3b3eb2cd7cd96b8076529ce21d618d20b7d6e8
1 /*
2 * q_fifo.c FIFO.
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: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
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>
23 #include "utils.h"
24 #include "tc_util.h"
26 static void explain(void)
28 fprintf(stderr, "Usage: ... [p|b]fifo [ limit NUMBER ]\n");
31 #define usage() return(-1)
33 static int fifo_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
35 int ok=0;
36 struct tc_fifo_qopt opt;
37 memset(&opt, 0, sizeof(opt));
39 while (argc > 0) {
40 if (strcmp(*argv, "limit") == 0) {
41 NEXT_ARG();
42 if (get_size(&opt.limit, *argv)) {
43 fprintf(stderr, "Illegal \"limit\"\n");
44 return -1;
46 ok++;
47 } else if (strcmp(*argv, "help") == 0) {
48 explain();
49 return -1;
50 } else {
51 fprintf(stderr, "What is \"%s\"?\n", *argv);
52 explain();
53 return -1;
55 argc--; argv++;
58 if (ok)
59 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
60 return 0;
63 static int fifo_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
65 struct tc_fifo_qopt *qopt;
67 if (opt == NULL)
68 return 0;
70 if (RTA_PAYLOAD(opt) < sizeof(*qopt))
71 return -1;
72 qopt = RTA_DATA(opt);
73 if (strcmp(qu->id, "bfifo") == 0) {
74 SPRINT_BUF(b1);
75 fprintf(f, "limit %s", sprint_size(qopt->limit, b1));
76 } else
77 fprintf(f, "limit %up", qopt->limit);
78 return 0;
82 struct qdisc_util bfifo_qdisc_util = {
83 .id = "bfifo",
84 .parse_qopt = fifo_parse_opt,
85 .print_qopt = fifo_print_opt,
88 struct qdisc_util pfifo_qdisc_util = {
89 .id = "pfifo",
90 .parse_qopt = fifo_parse_opt,
91 .print_qopt = fifo_print_opt,
94 extern int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
95 struct qdisc_util pfifo_fast_qdisc_util = {
96 .id = "pfifo_fast",
97 .print_qopt = prio_print_opt,