12 #include <netlink/cli/utils.h>
13 #include <netlink/cli/tc.h>
14 #include <netlink/cli/cls.h>
15 #include <netlink/route/cls/basic.h>
17 static void print_usage(
void)
20 "Usage: nl-cls-add [...] basic [OPTIONS]...\n"
23 " -h, --help Show this help text.\n"
24 " -t, --target=ID Target class to send matching packets to\n"
25 " -e, --ematch=EXPR Ematch expression\n"
28 " # Create a \"catch-all\" classifier, attached to \"q_root\", classyfing\n"
29 " # all not yet classified packets to class \"c_default\"\n"
30 " nl-cls-add --dev=eth0 --parent=q_root basic --target=c_default\n");
33 static void parse_argv(
struct rtnl_tc *tc,
int argc,
char **argv)
35 struct rtnl_cls *cls = (
struct rtnl_cls *) tc;
36 struct rtnl_ematch_tree *tree;
46 static struct option long_opts[] = {
47 {
"help", 0, 0,
'h' },
48 {
"target", 1, 0,
't' },
49 {
"ematch", 1, 0,
'e' },
53 c = getopt_long(argc, argv,
"ht:e:", long_opts, &optidx);
65 optarg, nl_geterror(err));
67 rtnl_basic_set_target(cls, target);
71 tree = nl_cli_cls_parse_ematch(cls, optarg);
72 rtnl_basic_set_ematch(cls, tree);
81 .tm_type = RTNL_TC_TYPE_CLS,
82 .tm_parse_argv = parse_argv,
85 static void __init basic_init(
void)
87 nl_cli_tc_register(&basic_module);
90 static void __exit basic_exit(
void)
92 nl_cli_tc_unregister(&basic_module);