From d6a9b0f85a505bc31856c3de66349720389c5072 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 13 Jul 2016 10:14:28 -0500 Subject: [PATCH] monitor: Add option to not print rtnl output --- monitor/main.c | 9 +++++++-- monitor/nlmon.c | 10 ++++++++-- monitor/nlmon.h | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/monitor/main.c b/monitor/main.c index ec9b664d..7db34d9a 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -49,6 +49,7 @@ static struct nlmon *nlmon = NULL; static const char *writer_path = NULL; static struct l_timeout *timeout = NULL; +static bool nortnl; #define NLA_OK(nla,len) ((len) >= (int) sizeof(struct nlattr) && \ (nla)->nla_len >= sizeof(struct nlattr) && \ @@ -104,7 +105,7 @@ static void genl_parse(uint16_t type, const void *data, uint32_t len, return; if (!strcmp(name, NL80211_GENL_NAME)) { - nlmon = nlmon_open(ifname, id, writer_path); + nlmon = nlmon_open(ifname, id, writer_path, nortnl); if (!nlmon) l_main_quit(); } @@ -681,6 +682,7 @@ static const struct option main_options[] = { { "analyze", required_argument, NULL, 'a' }, { "nl80211", required_argument, NULL, 'F' }, { "interface", required_argument, NULL, 'i' }, + { "nortnl", no_argument, NULL, 'n' }, { "version", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { } @@ -700,7 +702,7 @@ int main(int argc, char *argv[]) for (;;) { int opt; - opt = getopt_long(argc, argv, "r:w:a:F:i:vh", + opt = getopt_long(argc, argv, "r:w:a:F:i:nvh", main_options, NULL); if (opt < 0) break; @@ -738,6 +740,9 @@ int main(int argc, char *argv[]) case 'i': ifname = optarg; break; + case 'n': + nortnl = true; + break; case 'v': printf("%s\n", VERSION); return EXIT_SUCCESS; diff --git a/monitor/nlmon.c b/monitor/nlmon.c index 58387603..7fcb9522 100644 --- a/monitor/nlmon.c +++ b/monitor/nlmon.c @@ -93,6 +93,7 @@ struct nlmon { struct l_io *pae_io; struct l_queue *req_list; struct pcap *pcap; + bool nortnl; }; struct nlmon_req { @@ -4616,7 +4617,10 @@ static bool nlmon_receive(struct l_io *io, void *user_data) switch (proto_type) { case NETLINK_ROUTE: store_netlink(nlmon, tv, proto_type, nlmsg); - nlmon_print_rtnl(nlmon, tv, nlmsg, nlmsg->nlmsg_len); + + if (!nlmon->nortnl) + nlmon_print_rtnl(nlmon, tv, nlmsg, + nlmsg->nlmsg_len); break; case NETLINK_GENERIC: nlmon_message(nlmon, tv, tp, nlmsg); @@ -4920,7 +4924,8 @@ static struct l_io *open_pae(void) return io; } -struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname) +struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname, + bool nortnl) { struct nlmon *nlmon; struct l_io *io, *pae_io; @@ -4953,6 +4958,7 @@ struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname) nlmon->pae_io = pae_io; nlmon->req_list = l_queue_new(); nlmon->pcap = pcap; + nlmon->nortnl = nortnl; l_io_set_read_handler(nlmon->io, nlmon_receive, nlmon, NULL); l_io_set_read_handler(nlmon->pae_io, pae_receive, nlmon, NULL); diff --git a/monitor/nlmon.h b/monitor/nlmon.h index 1eef4b7c..d833e07d 100644 --- a/monitor/nlmon.h +++ b/monitor/nlmon.h @@ -25,7 +25,8 @@ struct nlmon; -struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname); +struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname, + bool nortnl); void nlmon_close(struct nlmon *nlmon); struct nlmon *nlmon_create(uint16_t id);