2 * src/genl-ctrl-list.c List Generic Netlink Families
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-2012 Thomas Graf <tgraf@suug.ch>
12 #include <netlink/cli/utils.h>
14 static struct nl_cache *alloc_genl_family_cache(struct nl_sock *sk)
16 return nl_cli_alloc_cache(sk, "generic netlink family",
17 genl_ctrl_alloc_cache);
20 static void print_usage(void)
23 "Usage: genl-ctrl-list [--details]\n"
26 " -d, --details Include detailed information in the list\n"
27 " -h, --help Show this help\n"
28 " -v, --version Show versioning information\n"
33 int main(int argc, char *argv[])
36 struct nl_cache *family_cache;
37 struct nl_dump_params params = {
38 .dp_type = NL_DUMP_LINE,
42 sock = nl_cli_alloc_socket();
43 nl_cli_connect(sock, NETLINK_GENERIC);
44 family_cache = alloc_genl_family_cache(sock);
48 static struct option long_opts[] = {
49 { "details", 0, 0, 'd' },
50 { "format", 1, 0, 'f' },
51 { "help", 0, 0, 'h' },
52 { "version", 0, 0, 'v' },
56 c = getopt_long(argc, argv, "df:hv", long_opts, &optidx);
61 case 'f': params.dp_type = nl_cli_parse_dumptype(optarg); break;
62 case 'd': params.dp_type = NL_DUMP_DETAILS; break;
63 case 'h': print_usage(); break;
64 case 'v': nl_cli_print_version(); break;
68 nl_cache_dump(family_cache, ¶ms);