iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 2/3] monitor: allow parsing pcaps without -F option
Date: Wed, 26 Oct 2022 13:45:58 -0700	[thread overview]
Message-ID: <20221026204559.502432-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20221026204559.502432-1-prestwoj@gmail.com>

The -F option is undocumented but allows you to pass a nl80211
family ID so iwmon doesn't ignore messages which don't match the
systems nl80211 family ID (i.e. pcaps from other systems).

This is somewhat of a pain to use since its unclear what the other
system's family ID actually is until you run it though something
like wireshark. Instead iwmon can ignore the family ID when in
read mode which makes reading other systems pcap files automatic.
---
 monitor/main.c  | 1 +
 monitor/nlmon.c | 4 +++-
 monitor/nlmon.h | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/monitor/main.c b/monitor/main.c
index 50b3fd27..0cbab179 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -710,6 +710,7 @@ int main(int argc, char *argv[])
 		switch (opt) {
 		case 'r':
 			reader_path = optarg;
+			config.read_only = true;
 			break;
 		case 'w':
 			writer_path = optarg;
diff --git a/monitor/nlmon.c b/monitor/nlmon.c
index b58bef05..d786cc33 100644
--- a/monitor/nlmon.c
+++ b/monitor/nlmon.c
@@ -104,6 +104,7 @@ struct nlmon {
 	bool nowiphy;
 	bool noscan;
 	bool noies;
+	bool read;
 };
 
 struct nlmon_req {
@@ -7202,7 +7203,7 @@ static void nlmon_message(struct nlmon *nlmon, const struct timeval *tv,
 		return;
 	}
 
-	if (nlmsg->nlmsg_type != nlmon->id) {
+	if (!nlmon->read && nlmsg->nlmsg_type != nlmon->id) {
 		if (nlmsg->nlmsg_type == GENL_ID_CTRL)
 			store_message(nlmon, tv, nlmsg);
 		return;
@@ -7265,6 +7266,7 @@ struct nlmon *nlmon_create(uint16_t id, const struct nlmon_config *config)
 	nlmon->nowiphy = config->nowiphy;
 	nlmon->noscan = config->noscan;
 	nlmon->noies = config->noies;
+	nlmon->read = config->read_only;
 
 	return nlmon;
 }
diff --git a/monitor/nlmon.h b/monitor/nlmon.h
index d1092c11..96958c25 100644
--- a/monitor/nlmon.h
+++ b/monitor/nlmon.h
@@ -30,6 +30,7 @@ struct nlmon_config {
 	bool nowiphy;
 	bool noscan;
 	bool noies;
+	bool read_only;
 };
 
 struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname,
-- 
2.34.3


  reply	other threads:[~2022-10-26 20:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 20:45 [PATCH v2 1/3] monitor: pass config to nlmon_create James Prestwood
2022-10-26 20:45 ` James Prestwood [this message]
2022-10-26 20:45 ` [PATCH v2 3/3] monitor: remove -F option James Prestwood
2022-10-26 21:49 ` [PATCH v2 1/3] monitor: pass config to nlmon_create Denis Kenzior

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=20221026204559.502432-2-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /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).