2 * src/nl-link-dump.c Dump link 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-link-dump <mode> [<filter>]\n"
18 " mode := { brief | detailed | stats | xml }\n"
19 " filter := [dev DEV] [mtu MTU] [txqlen TXQLEN] [weight WEIGHT] [link LINK]\n"
20 " [master MASTER] [qdisc QDISC] [addr ADDR] [broadcast BRD]\n"
21 " [{ up | down }] [{ arp | noarp }] [{ promisc | nopromisc }]\n"
22 " [{ dynamic | nodynamic }] [{ multicast | nomulticast }]\n"
23 " [{ trailers | notrailers }] [{ allmulticast | noallmulticast }]\n");
29 int main(int argc, char *argv[])
31 struct nl_handle *nlh;
32 struct nl_cache *link_cache;
33 struct rtnl_link *link;
34 struct nl_dump_params params = {
36 .dp_type = NL_DUMP_BRIEF
40 if (nltool_init(argc, argv) < 0)
43 if (argc < 2 || !strcmp(argv[1], "-h"))
46 nlh = nltool_alloc_handle();
50 link = rtnl_link_alloc();
54 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
57 link_cache = nltool_alloc_link_cache(nlh);
61 params.dp_type = nltool_parse_dumptype(argv[1]);
62 if (params.dp_type < 0)
65 get_filter(link, argc, argv, 2, link_cache);
66 nl_cache_dump_filter(link_cache, ¶ms, (struct nl_object *) link);
67 nl_cache_free(link_cache);
73 nl_handle_destroy(nlh);