12 #include <netlink/cli/utils.h> 14 #include <linux/genetlink.h> 16 static struct nl_cache *alloc_genl_family_cache(
struct nl_sock *sk)
18 return nl_cli_alloc_cache(sk,
"generic netlink family",
22 static void print_usage(
void)
25 "Usage: genl-ctrl-list [--details]\n" 28 " -d, --details Include detailed information in the list\n" 29 " -h, --help Show this help\n" 30 " -v, --version Show versioning information\n" 35 int main(
int argc,
char *argv[])
38 struct nl_cache *family_cache;
44 sock = nl_cli_alloc_socket();
45 nl_cli_connect(sock, NETLINK_GENERIC);
46 family_cache = alloc_genl_family_cache(sock);
50 static struct option long_opts[] = {
51 {
"details", 0, 0,
'd' },
52 {
"format", 1, 0,
'f' },
53 {
"help", 0, 0,
'h' },
54 {
"version", 0, 0,
'v' },
58 c = getopt_long(argc, argv,
"df:hv", long_opts, &optidx);
63 case 'f': params.
dp_type = nl_cli_parse_dumptype(optarg);
break;
65 case 'h': print_usage();
break;
66 case 'v': nl_cli_print_version();
break;
Dump object briefly on one line.
enum nl_dump_type dp_type
Specifies the type of dump that is requested.
int genl_ctrl_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
Allocate a new controller cache.
Dump all attributes but no statistics.
void nl_cache_dump(struct nl_cache *cache, struct nl_dump_params *params)
Dump all elements of a cache.