12 #include <netlink/cli/utils.h>
13 #include <netlink/cli/tc.h>
14 #include <netlink/cli/class.h>
15 #include <netlink/cli/link.h>
17 static struct nl_sock *sock;
23 static void print_usage(
void)
26 "Usage: nl-class-list [OPTION]...\n"
29 " --details Show details\n"
30 " --stats Show statistics\n"
31 " -h, --help Show this help\n"
32 " -v, --version Show versioning information\n"
34 " -d, --dev=DEV Device the class is attached to. (default: all)\n"
35 " -p, --parent=ID Identifier of parent class.\n"
36 " -i, --id=ID Identifier.\n"
37 " -k, --kind=NAME Kind of class (e.g. pfifo_fast)\n"
40 " # Display statistics of all classes on eth0\n"
41 " $ nl-class-list --stats --dev=eth0\n"
47 static void __dump_class(
int ifindex,
struct rtnl_class *filter)
49 struct nl_cache *cache;
51 cache = nl_cli_class_alloc_cache(sock, ifindex);
55 static void dump_class(
struct nl_object *obj,
void *arg)
57 struct rtnl_link *link = nl_object_priv(obj);
62 int main(
int argc,
char *argv[])
64 struct rtnl_class *
class;
66 struct nl_cache *link_cache;
69 sock = nl_cli_alloc_socket();
70 nl_cli_connect(sock, NETLINK_ROUTE);
71 link_cache = nl_cli_link_alloc_cache(sock);
72 class = nl_cli_class_alloc();
73 tc = (
struct rtnl_tc *)
class;
75 params.
dp_fd = stdout;
83 static struct option long_opts[] = {
84 {
"details", 0, 0, ARG_DETAILS },
85 {
"stats", 0, 0, ARG_STATS },
86 {
"help", 0, 0,
'h' },
87 {
"version", 0, 0,
'v' },
89 {
"parent", 1, 0,
'p' },
91 {
"kind", 1, 0,
'k' },
95 c = getopt_long(argc, argv,
"hvd:p:i:k:", long_opts, &optidx);
102 case 'h': print_usage();
break;
103 case 'v': nl_cli_print_version();
break;
104 case 'd': nl_cli_tc_parse_dev(tc, link_cache, optarg);
break;
105 case 'p': nl_cli_tc_parse_parent(tc, optarg);
break;
106 case 'i': nl_cli_tc_parse_handle(tc, optarg, 0);
break;
107 case 'k': nl_cli_tc_parse_kind(tc, optarg);
break;
112 __dump_class(ifindex,
class);