6 #include <netlink/cli/utils.h>
7 #include <netlink/cli/tc.h>
8 #include <netlink/cli/cls.h>
9 #include <netlink/route/cls/basic.h>
11 static void print_usage(
void)
14 "Usage: nl-cls-add [...] basic [OPTIONS]...\n"
17 " -h, --help Show this help text.\n"
18 " -t, --target=ID Target class to send matching packets to\n"
19 " -e, --ematch=EXPR Ematch expression\n"
22 " # Create a \"catch-all\" classifier, attached to \"q_root\", classyfing\n"
23 " # all not yet classified packets to class \"c_default\"\n"
24 " nl-cls-add --dev=eth0 --parent=q_root basic --target=c_default\n");
27 static void parse_argv(
struct rtnl_tc *tc,
int argc,
char **argv)
29 struct rtnl_cls *cls = (
struct rtnl_cls *) tc;
30 struct rtnl_ematch_tree *tree;
40 static struct option long_opts[] = {
41 {
"help", 0, 0,
'h' },
42 {
"target", 1, 0,
't' },
43 {
"ematch", 1, 0,
'e' },
47 c = getopt_long(argc, argv,
"ht:e:", long_opts, &optidx);
59 optarg, nl_geterror(err));
61 rtnl_basic_set_target(cls, target);
65 tree = nl_cli_cls_parse_ematch(cls, optarg);
66 rtnl_basic_set_ematch(cls, tree);
75 .tm_type = RTNL_TC_TYPE_CLS,
76 .tm_parse_argv = parse_argv,
79 static void __init basic_init(
void)
81 nl_cli_tc_register(&basic_module);
84 static void __exit basic_exit(
void)
86 nl_cli_tc_unregister(&basic_module);
int rtnl_tc_str2handle(const char *str, uint32_t *res)
Convert a charactering strint to a traffic control handle.
void nl_cli_fatal(int err, const char *fmt,...)
Print error message and quit application.