2 * src/nl-neightbl-list.c Dump neighbour tables
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-2009 Thomas Graf <tgraf@suug.ch>
12 #include <netlink/cli/utils.h>
13 #include <netlink/cli/link.h>
15 static void print_usage(void)
18 "Usage: nl-neightbl-list [OPTION]...\n"
21 " -f, --format=TYPE Output format { brief | details | stats }\n"
22 " -h, --help Show this help\n"
23 " -v, --version Show versioning information\n"
28 int main(int argc, char *argv[])
31 struct nl_cache *link_cache, *neightbl_cache;
32 struct nl_dump_params params = {
33 .dp_type = NL_DUMP_LINE,
37 sock = nl_cli_alloc_socket();
38 nl_cli_connect(sock, NETLINK_ROUTE);
39 link_cache = nl_cli_link_alloc_cache(sock);
40 neightbl_cache = nl_cli_alloc_cache(sock, "neighbour table",
41 rtnl_neightbl_alloc_cache);
45 static struct option long_opts[] = {
46 { "format", 1, 0, 'f' },
47 { "help", 0, 0, 'h' },
48 { "version", 0, 0, 'v' },
52 c = getopt_long(argc, argv, "f:hv", long_opts, &optidx);
57 case 'f': params.dp_type = nl_cli_parse_dumptype(optarg); break;
58 case 'h': print_usage(); break;
59 case 'v': nl_cli_print_version(); break;
63 nl_cache_dump(neightbl_cache, ¶ms);