monitor: allow parsing pcaps without -F option
PATCH 1/1 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 | 2 +- monitor/nlmon.c | 6 ++++-- monitor/nlmon.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)
monitor/main.c +1 -1
@@ -586,7 +586,7 @@ static int process_pcap(struct pcap *pcap, uint16_t id)return EXIT_FAILURE ; } - nlmon =nlmon_create (id); + nlmon =nlmon_create (id, true);while (pcap_read (pcap, &tv, buf, snaplen, &len, &real_len)) {uint16_t arphrd_type;
monitor/nlmon.c +4 -2
@@ -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 ;
@@ -7253,7 +7254,7 @@ static void nlmon_message(struct nlmon *nlmon, const struct timeval *tv, } } -struct nlmon *nlmon_create (uint16_t id) +struct nlmon *nlmon_create (uint16_t id,bool read_only) {struct nlmon *nlmon;
@@ -7261,6 +7262,7 @@ struct nlmon *nlmon_create(uint16_t id) nlmon->id = id; nlmon->req_list =l_queue_new (); + nlmon->read = true;return nlmon; }
monitor/nlmon.h +1 -1
@@ -36,7 +36,7 @@ struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname, const struct nlmon_config *config);void nlmon_close (struct nlmon *nlmon); -struct nlmon *nlmon_create (uint16_t id); +struct nlmon *nlmon_create (uint16_t id,bool read_only);void nlmon_destroy (struct nlmon *nlmon);void nlmon_print_rtnl (struct nlmon *nlmon,const struct timeval *tv,const void *data,uint32_t size);
Signature · 1 line
2.34.3
Hi James,
Quoted 3 lines · James Prestwood
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).
So should we remove -F option then as well?
Quoted 15 lines
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 | 2 +- monitor/nlmon.c | 6 ++++-- monitor/nlmon.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)monitor/main.c +0
-0
<snip>
monitor/main.c struct nlmon *nlmon_create(uint16_t id) · line 7265
Quoted 5 lines
monitor/main.c +1
-0@@ -7261,6 +7262,7 @@ struct nlmon *nlmon_create(uint16_t id) nlmon->id = id; nlmon->req_list =l_queue_new (); + nlmon->read = true;
did you intend read = read_only; here?
monitor/main.c struct nlmon *nlmon_create(uint16_t id) · line 7267
Quoted 3 lines
monitor/main.c +0
-0return nlmon; }
Regards,
-Denis