2 * src/nl-qdisc-list.c List Qdiscs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch>
12 #include <netlink/cli/utils.h>
13 #include <netlink/cli/qdisc.h>
14 #include <netlink/cli/link.h>
18 static void print_usage(void)
21 "Usage: nl-qdisc-list [OPTION]... [QDISC]\n"
24 " -f, --format=TYPE Output format { brief | details | stats }\n"
25 " -h, --help Show this help\n"
26 " -v, --version Show versioning information\n"
29 " -d, --dev=DEV Device the qdisc is attached to\n"
30 " -p, --parent=HANDLE Identifier of parent qdisc\n"
31 " -H, --handle=HANDLE Identifier\n"
32 " -k, --kind=NAME Kind of qdisc (e.g. pfifo_fast)\n"
37 int main(int argc, char *argv[])
40 struct rtnl_qdisc *qdisc;
41 struct nl_cache *link_cache, *qdisc_cache;
42 struct nl_dump_params params = {
43 .dp_type = NL_DUMP_LINE,
47 sock = nl_cli_alloc_socket();
48 nl_cli_connect(sock, NETLINK_ROUTE);
49 link_cache = nl_cli_link_alloc_cache(sock);
50 qdisc_cache = nl_cli_qdisc_alloc_cache(sock);
51 qdisc = nl_cli_qdisc_alloc();
58 static struct option long_opts[] = {
59 { "format", 1, 0, 'f' },
60 { "quiet", 0, 0, 'q' },
61 { "help", 0, 0, 'h' },
62 { "version", 0, 0, 'v' },
64 { "parent", 1, 0, 'p' },
65 { "handle", 1, 0, 'H' },
66 { "kind", 1, 0, 'k' },
70 c = getopt_long(argc, argv, "f:qhvd:p:H:k:",
76 case 'f': params.dp_type = nl_cli_parse_dumptype(optarg); break;
77 case 'q': quiet = 1; break;
78 case 'h': print_usage(); break;
79 case 'v': nl_cli_print_version(); break;
80 case 'd': nl_cli_qdisc_parse_dev(qdisc, link_cache, optarg); break;
81 case 'p': nl_cli_qdisc_parse_parent(qdisc, optarg); break;
82 case 'H': nl_cli_qdisc_parse_handle(qdisc, optarg); break;
83 case 'k': nl_cli_qdisc_parse_kind(qdisc, optarg); break;
87 nl_cache_dump_filter(qdisc_cache, ¶ms, OBJ_CAST(qdisc));