From ad51250835d7c4962d5953cb898ee97cb5cf9037 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 26 Oct 2022 13:45:58 -0700 Subject: [PATCH] monitor: allow parsing pcaps without -F option 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,