8#include <linux/netlink.h>
10#include <netlink/cli/utils.h>
11#include <netlink/cli/nh.h>
12#include <netlink/route/nh.h>
14static void print_usage(
void)
16 printf(
"Usage: nl-nh-list [OPTIONS]... \n"
19 " --details Show detailed information of each link\n"
20 " -h, --help Show this help text.\n"
21 " -v, --version Show versioning information.\n"
23 " -n, --name=NAME Name of link\n"
24 " -i, --index Interface index (unique identifier)\n"
25 " --family=NAME Link address family\n");
29int main(
int argc,
char *argv[])
32 struct nl_cache *link_cache;
38 sock = nl_cli_alloc_socket();
39 nl_cli_connect(sock, NETLINK_ROUTE);
47 static struct option long_opts[] = { {
"details", 0, 0,
49 {
"help", 0, 0,
'h' },
50 {
"version", 0, 0,
'v' },
51 {
"name", 1, 0,
'n' },
54 c = getopt_long(argc, argv,
"hvn:i:", long_opts, &optidx);
66 nl_cli_print_version();
71 link_cache = nl_cli_nh_alloc_cache(sock);
void nl_cache_dump(struct nl_cache *cache, struct nl_dump_params *params)
Dump all elements of a cache.
@ NL_DUMP_LINE
Dump object briefly on one line.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
enum nl_dump_type dp_type
Specifies the type of dump that is requested.