1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3 * Copyright (c) 2013 Cong Wang <[email protected]>
4 */
5
6 #include "nl-default.h"
7
8 #include <netlink/cli/utils.h>
9 #include <netlink/cli/tc.h>
10
print_usage(void)11 static void print_usage(void)
12 {
13 printf(
14 "Usage: nl-qdisc-add [...] ingress\n"
15 "\n"
16 "OPTIONS\n"
17 " --help Show this help text.\n"
18 "\n"
19 "EXAMPLE"
20 " # Attach ingress to eth1\n"
21 " nl-qdisc-add --dev=eth1 --parent=root ingress\n");
22 }
23
ingress_parse_argv(struct rtnl_tc * tc,int argc,char ** argv)24 static void ingress_parse_argv(struct rtnl_tc *tc, int argc, char **argv)
25 {
26 for (;;) {
27 int c, optidx = 0;
28 static struct option long_opts[] = {
29 { "help", 0, 0, 'h' },
30 { 0, 0, 0, 0 }
31 };
32
33 c = getopt_long(argc, argv, "h", long_opts, &optidx);
34 if (c == -1)
35 break;
36
37 switch (c) {
38 case 'h':
39 print_usage();
40 return;
41 }
42 }
43 }
44
45 static struct nl_cli_tc_module ingress_module =
46 {
47 .tm_name = "ingress",
48 .tm_type = RTNL_TC_TYPE_QDISC,
49 .tm_parse_argv = ingress_parse_argv,
50 };
51
ingress_init(void)52 static void _nl_init ingress_init(void)
53 {
54 nl_cli_tc_register(&ingress_module);
55 }
56
ingress_exit(void)57 static void _nl_exit ingress_exit(void)
58 {
59 nl_cli_tc_unregister(&ingress_module);
60 }
61