2 * src/nl-neigh-dump.c Dump neighbour 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-neigh-dump <mode> [<filter>]\n"
18 " mode := { brief | detailed | stats | xml }\n"
19 " filter := [dev DEV] [dst ADDR] [lladdr ADDR]\n");
25 int main(int argc, char *argv[])
27 struct nl_handle *nlh;
28 struct nl_cache *link_cache, *neigh_cache;
29 struct rtnl_neigh *neigh;
30 struct nl_dump_params params = {
32 .dp_type = NL_DUMP_BRIEF
36 if (nltool_init(argc, argv) < 0)
39 if (argc < 2 || !strcmp(argv[1], "-h"))
42 nlh = nltool_alloc_handle();
46 neigh = rtnl_neigh_alloc();
50 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
53 link_cache = nltool_alloc_link_cache(nlh);
57 neigh_cache = nltool_alloc_neigh_cache(nlh);
59 goto errout_link_cache;
61 params.dp_type = nltool_parse_dumptype(argv[1]);
62 if (params.dp_type < 0)
63 goto errout_neigh_cache;
65 get_filter(neigh, argc, argv, 2, neigh_cache);
67 nl_cache_dump_filter(neigh_cache, ¶ms, (struct nl_object *) neigh);
72 nl_cache_free(neigh_cache);
74 nl_cache_free(link_cache);
78 rtnl_neigh_put(neigh);
80 nl_handle_destroy(nlh);