8#include <netlink/cli/utils.h>
9#include <netlink/cli/tc.h>
10#include <netlink/cli/cls.h>
11#include <netlink/route/cls/basic.h>
13#include "base/nl-base-utils.h"
15static void print_usage(
void)
18"Usage: nl-cls-add [...] basic [OPTIONS]...\n"
21" -h, --help Show this help text.\n"
22" -t, --target=ID Target class to send matching packets to\n"
23" -e, --ematch=EXPR Ematch expression\n"
26" # Create a \"catch-all\" classifier, attached to \"q_root\", classyfing\n"
27" # all not yet classified packets to class \"c_default\"\n"
28" nl-cls-add --dev=eth0 --parent=q_root basic --target=c_default\n");
31static void parse_argv(
struct rtnl_tc *tc,
int argc,
char **argv)
33 struct rtnl_cls *cls = (
struct rtnl_cls *) tc;
34 struct rtnl_ematch_tree *tree;
44 static struct option long_opts[] = {
45 {
"help", 0, 0,
'h' },
46 {
"target", 1, 0,
't' },
47 {
"ematch", 1, 0,
'e' },
51 c = getopt_long(argc, argv,
"ht:e:", long_opts, &optidx);
63 optarg, nl_geterror(err));
65 rtnl_basic_set_target(cls, target);
69 tree = nl_cli_cls_parse_ematch(cls, optarg);
70 rtnl_basic_set_ematch(cls, tree);
79 .tm_type = RTNL_TC_TYPE_CLS,
80 .tm_parse_argv = parse_argv,
83static void _nl_init basic_init(
void)
85 nl_cli_tc_register(&basic_module);
88static void _nl_exit basic_exit(
void)
90 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.