diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2011-01-04 01:34:32 +0100 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2011-01-08 04:08:57 +0100 |
commit | d337d00183c27619f1eb4a84b06476658a4b7355 (patch) | |
tree | ad2591c30e26e17fb1f8f89f1644a311a146e2e4 | |
parent | 618b266ef65c18ee2c54f66e22a3a05b294ce5e0 (diff) | |
download | libmnl-d337d00183c27619f1eb4a84b06476658a4b7355.tar.gz libmnl-d337d00183c27619f1eb4a84b06476658a4b7355.zip |
examples/genl: support dumping the genl families
The usage text already specified [family] as optional, now implement it :-)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
-rw-r--r-- | examples/genl/genl-family-get.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/genl/genl-family-get.c b/examples/genl/genl-family-get.c index 1ad1a04..b16f7b6 100644 --- a/examples/genl/genl-family-get.c +++ b/examples/genl/genl-family-get.c @@ -178,6 +178,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) printf("grps:\n"); parse_genl_mc_grps(tb[CTRL_ATTR_MCAST_GROUPS]); } + printf("\n"); return MNL_CB_OK; } @@ -190,7 +191,7 @@ int main(int argc, char *argv[]) int ret; unsigned int seq, portid; - if (argc != 2) { + if (argc > 2) { printf("%s [family name]\n", argv[0]); exit(EXIT_FAILURE); } @@ -205,7 +206,10 @@ int main(int argc, char *argv[]) genl->version = 1; mnl_attr_put_u32(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL); - mnl_attr_put_strz(nlh, CTRL_ATTR_FAMILY_NAME, argv[1]); + if (argc >= 2) + mnl_attr_put_strz(nlh, CTRL_ATTR_FAMILY_NAME, argv[1]); + else + nlh->nlmsg_flags |= NLM_F_DUMP; nl = mnl_socket_open(NETLINK_GENERIC); if (nl == NULL) { |