2 * src/nl-rule-dump.c Dump rule 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-rule-dump <mode> [<filter>]\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, *rule_cache;
26 struct rtnl_rule *rule;
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 nlh = nl_handle_alloc_nondefault(nltool_cbset);
43 rule = rtnl_rule_alloc();
47 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
50 link_cache = nltool_alloc_link_cache(nlh);
54 rule_cache = nltool_alloc_rule_cache(nlh);
56 goto errout_link_cache;
58 params.dp_type = nltool_parse_dumptype(argv[1]);
59 if (params.dp_type < 0)
60 goto errout_rule_cache;
62 //get_filter(route, argc, argv, 2, route_cache);
64 nl_cache_dump_filter(rule_cache, ¶ms, (struct nl_object *) rule);
69 nl_cache_free(rule_cache);
71 nl_cache_free(link_cache);
75 nl_object_put((struct nl_object *) rule);