From: Jan Engelhardt <jengelh@medozas.de>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 2/2] examples/genl: support dumping the genl families
Date: Sat, 8 Jan 2011 04:09:47 +0100 [thread overview]
Message-ID: <1294456188-4221-3-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1294456188-4221-1-git-send-email-jengelh@medozas.de>
The usage text already specified [family] as optional, now implement it :-)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
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) {
--
1.7.1
next prev parent reply other threads:[~2011-01-08 3:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-08 3:09 libmnl: genl patches Jan Engelhardt
2011-01-08 3:09 ` [PATCH 1/2] examples/genl: fix newline imbalance Jan Engelhardt
2011-01-08 3:09 ` Jan Engelhardt [this message]
2011-01-09 18:57 ` libmnl: genl patches Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1294456188-4221-3-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).