libnl  3.2.24-rc1
ingress.c
1 
2 /*
3  * src/lib/ingress.c ingress module for CLI lib
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation version 2.1
8  * of the License.
9  *
10  * Copyright (c) 2013 Cong Wang <xiyou.wangcong@gmail.com>
11  */
12 
13 #include <netlink/cli/utils.h>
14 #include <netlink/cli/tc.h>
15 
16 static void print_usage(void)
17 {
18  printf(
19 "Usage: nl-qdisc-add [...] ingress\n"
20 "\n"
21 "OPTIONS\n"
22 " --help Show this help text.\n"
23 "\n"
24 "EXAMPLE"
25 " # Attach ingress to eth1\n"
26 " nl-qdisc-add --dev=eth1 --parent=root ingress\n");
27 }
28 
29 static void ingress_parse_argv(struct rtnl_tc *tc, int argc, char **argv)
30 {
31  for (;;) {
32  int c, optidx = 0;
33  static struct option long_opts[] = {
34  { "help", 0, 0, 'h' },
35  { 0, 0, 0, 0 }
36  };
37 
38  c = getopt_long(argc, argv, "h", long_opts, &optidx);
39  if (c == -1)
40  break;
41 
42  switch (c) {
43  case 'h':
44  print_usage();
45  return;
46  }
47  }
48 }
49 
50 static struct nl_cli_tc_module ingress_module =
51 {
52  .tm_name = "ingress",
53  .tm_type = RTNL_TC_TYPE_QDISC,
54  .tm_parse_argv = ingress_parse_argv,
55 };
56 
57 static void __init ingress_init(void)
58 {
59  nl_cli_tc_register(&ingress_module);
60 }
61 
62 static void __exit ingress_exit(void)
63 {
64  nl_cli_tc_unregister(&ingress_module);
65 }