6#include <netlink/cli/utils.h>
7#include <linux/pkt_sched.h>
9static void print_usage(
void)
12"Usage: nl-classid-lookup [OPTIONS]... NAME\n"
15" -h, --help Show this help text.\n"
16" -v, --version Show versioning information.\n"
17" -r, --reverse Do a reverse lookup, i.e. classid to name.\n"
18" --raw Print the raw classid, not pretty printed.\n"
21" $ nl-classid-lookup low_latency\n"
22" $ nl-classid-lookup -r 1:12\n"
28int main(
int argc,
char *argv[])
32 int err, reverse = 0, raw = 0;
39 static struct option long_opts[] = {
40 {
"help", 0, 0,
'h' },
41 {
"version", 0, 0,
'v' },
42 {
"reverse", 0, 0,
'r' },
43 {
"raw", 0, 0, ARG_RAW },
47 c = getopt_long(argc, argv,
"hvr", long_opts, &optidx);
52 case 'h': print_usage();
break;
53 case 'v': nl_cli_print_version();
break;
54 case 'r': reverse = 1;
break;
55 case ARG_RAW: raw = 1;
break;
62 name = argv[optind++];
71 name, nl_geterror(err));
77 printf(
"%#x\n", classid);
79 printf(
"%x:%x\n", TC_H_MAJ(classid) >> 16, TC_H_MIN(classid));
int rtnl_tc_str2handle(const char *str, uint32_t *res)
Convert a charactering strint to a traffic control handle.
char * rtnl_tc_handle2str(uint32_t handle, char *buf, size_t len)
Convert a traffic control handle to a character string (Reentrant).
void nl_cli_fatal(int err, const char *fmt,...)
Print error message and quit application.