6#include <netlink/cli/utils.h>
8#include <linux/genetlink.h>
10static struct nl_cache *alloc_genl_family_cache(
struct nl_sock *sk)
12 return nl_cli_alloc_cache(sk,
"generic netlink family",
16static void print_usage(
void)
19 "Usage: genl-ctrl-list [--details]\n"
22 " -d, --details Include detailed information in the list\n"
23 " -h, --help Show this help\n"
24 " -v, --version Show versioning information\n"
29int main(
int argc,
char *argv[])
32 struct nl_cache *family_cache;
38 sock = nl_cli_alloc_socket();
39 nl_cli_connect(sock, NETLINK_GENERIC);
40 family_cache = alloc_genl_family_cache(sock);
44 static struct option long_opts[] = {
45 {
"details", 0, 0,
'd' },
46 {
"format", 1, 0,
'f' },
47 {
"help", 0, 0,
'h' },
48 {
"version", 0, 0,
'v' },
52 c = getopt_long(argc, argv,
"df:hv", long_opts, &optidx);
57 case 'f': params.
dp_type = nl_cli_parse_dumptype(optarg);
break;
59 case 'h': print_usage();
break;
60 case 'v': nl_cli_print_version();
break;
void nl_cache_dump(struct nl_cache *cache, struct nl_dump_params *params)
Dump all elements of a cache.
int genl_ctrl_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
Allocate a new controller 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.