2 * src/nl-qdisc-dump.c Dump qdisc attributes
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-2006 Thomas Graf <tgraf@suug.ch>
14 static void print_usage(void)
17 "Usage: nl-qdisc-dump <mode>\n"
18 " mode := { brief | detailed | stats | xml }\n");
22 int main(int argc, char *argv[])
24 struct nl_handle *nlh;
25 struct nl_cache *link_cache, *qdisc_cache;
26 struct rtnl_qdisc *qdisc;
27 struct nl_dump_params params = {
29 .dp_type = NL_DUMP_BRIEF
33 if (nltool_init(argc, argv) < 0)
36 if (argc < 2 || !strcmp(argv[1], "-h"))
39 params.dp_type = nltool_parse_dumptype(argv[1]);
40 if (params.dp_type < 0)
43 nlh = nltool_alloc_handle();
47 qdisc = rtnl_qdisc_alloc();
51 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
54 link_cache = nltool_alloc_link_cache(nlh);
58 qdisc_cache = nltool_alloc_qdisc_cache(nlh);
60 goto errout_link_cache;
62 nl_cache_dump_filter(qdisc_cache, ¶ms, (struct nl_object *) qdisc);
63 nl_cache_free(qdisc_cache);
67 nl_cache_free(link_cache);
69 rtnl_qdisc_put(qdisc);
72 nl_handle_destroy(nlh);