/* * src/nl-neightbl-list.c Dump neighbour tables * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version 2.1 * of the License. * * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch> */ #include <netlink/cli/utils.h> #include <netlink/cli/link.h> static void print_usage(void) { printf( "Usage: nl-neightbl-list [OPTION]...\n" "\n" "Options\n" " -f, --format=TYPE Output format { brief | details | stats }\n" " -h, --help Show this help\n" " -v, --version Show versioning information\n" ); exit(0); } int main(int argc, char *argv[]) { struct nl_sock *sock; struct nl_cache *link_cache, *neightbl_cache; struct nl_dump_params params = { .dp_type = NL_DUMP_LINE, .dp_fd = stdout, }; sock = nl_cli_alloc_socket(); nl_cli_connect(sock, NETLINK_ROUTE); link_cache = nl_cli_link_alloc_cache(sock); neightbl_cache = nl_cli_alloc_cache(sock, "neighbour table", rtnl_neightbl_alloc_cache); for (;;) { int c, optidx = 0; static struct option long_opts[] = { { "format", 1, 0, 'f' }, { "help", 0, 0, 'h' }, { "version", 0, 0, 'v' }, { 0, 0, 0, 0 } }; c = getopt_long(argc, argv, "f:hv", long_opts, &optidx); if (c == -1) break; switch (c) { case 'f': params.dp_type = nl_cli_parse_dumptype(optarg); break; case 'h': print_usage(); break; case 'v': nl_cli_print_version(); break; } } nl_cache_dump(neightbl_cache, ¶ms); return 0; }