libnl  3.6.0
pfifo.c
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch>
4  */
5 
6 #include <netlink/cli/utils.h>
7 #include <netlink/cli/tc.h>
8 #include <netlink/route/qdisc/fifo.h>
9 
10 static void print_usage(void)
11 {
12  printf(
13 "Usage: nl-qdisc-add [...] pfifo [OPTIONS]...\n"
14 "\n"
15 "OPTIONS\n"
16 " --help Show this help text.\n"
17 " --limit=LIMIT Maximum queue length in number of packets.\n"
18 "\n"
19 "EXAMPLE"
20 " # Attach pfifo with a 32 packet limit to eth1\n"
21 " nl-qdisc-add --dev=eth1 --parent=root pfifo --limit=32\n");
22 }
23 
24 static void pfifo_parse_argv(struct rtnl_tc *tc, int argc, char **argv)
25 {
26  struct rtnl_qdisc *qdisc = (struct rtnl_qdisc *) tc;
27 
28  for (;;) {
29  int c, optidx = 0;
30  enum {
31  ARG_LIMIT = 257,
32  };
33  static struct option long_opts[] = {
34  { "help", 0, 0, 'h' },
35  { "limit", 1, 0, ARG_LIMIT },
36  { 0, 0, 0, 0 }
37  };
38 
39  c = getopt_long(argc, argv, "h", long_opts, &optidx);
40  if (c == -1)
41  break;
42 
43  switch (c) {
44  case 'h':
45  print_usage();
46  return;
47 
48  case ARG_LIMIT:
50  break;
51  }
52  }
53 }
54 
55 static struct nl_cli_tc_module pfifo_module =
56 {
57  .tm_name = "pfifo",
58  .tm_type = RTNL_TC_TYPE_QDISC,
59  .tm_parse_argv = pfifo_parse_argv,
60 };
61 
62 static void __init pfifo_init(void)
63 {
64  nl_cli_tc_register(&pfifo_module);
65 }
66 
67 static void __exit pfifo_exit(void)
68 {
69  nl_cli_tc_unregister(&pfifo_module);
70 }
uint32_t nl_cli_parse_u32(const char *arg)
Parse a text based 32 bit unsigned integer argument.
Definition: utils.c:36
int rtnl_qdisc_fifo_set_limit(struct rtnl_qdisc *qdisc, int limit)
Set limit of FIFO qdisc.
Definition: fifo.c:100