summaryrefslogtreecommitdiff
path: root/lib/cli/qdisc/ingress.c
blob: 9c09c4f010648efd6731f72d53d3ea3f6007a105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* SPDX-License-Identifier: LGPL-2.1-only */
/*
 * Copyright (c) 2013 Cong Wang <xiyou.wangcong@gmail.com>
 */

#include "nl-default.h"

#include <netlink/cli/utils.h>
#include <netlink/cli/tc.h>

static void print_usage(void)
{
	printf(
"Usage: nl-qdisc-add [...] ingress\n"
"\n"
"OPTIONS\n"
"     --help                Show this help text.\n"
"\n"
"EXAMPLE"
"    # Attach ingress to eth1\n"
"    nl-qdisc-add --dev=eth1 --parent=root ingress\n");
}

static void ingress_parse_argv(struct rtnl_tc *tc, int argc, char **argv)
{
	for (;;) {
		int c, optidx = 0;
		static struct option long_opts[] = {
			{ "help", 0, 0, 'h' },
			{ 0, 0, 0, 0 }
		};

		c = getopt_long(argc, argv, "h", long_opts, &optidx);
		if (c == -1)
			break;

		switch (c) {
		case 'h':
			print_usage();
			return;
		}
	}
}

static struct nl_cli_tc_module ingress_module =
{
	.tm_name		= "ingress",
	.tm_type		= RTNL_TC_TYPE_QDISC,
	.tm_parse_argv		= ingress_parse_argv,
};

static void _nl_init ingress_init(void)
{
	nl_cli_tc_register(&ingress_module);
}

static void _nl_exit ingress_exit(void)
{
	nl_cli_tc_unregister(&ingress_module);
}