2 * src/nl-route-dump.c Dump route 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-route-dump <mode> [<filter>]\n"
18 " mode := { brief | detailed | stats | xml }\n");
24 int main(int argc, char *argv[])
26 struct nl_handle *nlh;
27 struct nl_cache *link_cache, *route_cache;
28 struct rtnl_route *route;
29 struct nl_dump_params params = {
31 .dp_type = NL_DUMP_BRIEF
35 if (nltool_init(argc, argv) < 0)
38 if (argc < 2 || !strcmp(argv[1], "-h"))
41 nlh = nltool_alloc_handle();
45 route = rtnl_route_alloc();
49 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
52 link_cache = nltool_alloc_link_cache(nlh);
56 route_cache = nltool_alloc_route_cache(nlh);
58 goto errout_link_cache;
60 params.dp_type = nltool_parse_dumptype(argv[1]);
61 if (params.dp_type < 0)
62 goto errout_route_cache;
64 get_filter(route, argc, argv, 2, route_cache, link_cache);
66 nl_cache_dump_filter(route_cache, ¶ms, (struct nl_object *) route);
71 nl_cache_free(route_cache);
73 nl_cache_free(link_cache);
77 rtnl_route_put(route);
79 nl_handle_destroy(nlh);