From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 1/3] monitor: pass config to nlmon_create
Date: Wed, 26 Oct 2022 13:45:57 -0700 [thread overview]
Message-ID: <20221026204559.502432-1-prestwoj@gmail.com> (raw)
Expand nlmon_create to be useful for both pcaps and monitoring. Doing
this also lets iwmon filter pcaps based on --no-ies,rtnl,scan etc
flags since they are part of the config.
---
monitor/main.c | 8 +++++---
monitor/nlmon.c | 15 +++++++--------
monitor/nlmon.h | 2 +-
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/monitor/main.c b/monitor/main.c
index f0b16bbf..50b3fd27 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -569,7 +569,8 @@ done:
return exit_status;
}
-static int process_pcap(struct pcap *pcap, uint16_t id)
+static int process_pcap(struct pcap *pcap, uint16_t id,
+ const struct nlmon_config *config)
{
struct nlmon *nlmon = NULL;
struct timeval tv;
@@ -586,7 +587,7 @@ static int process_pcap(struct pcap *pcap, uint16_t id)
return EXIT_FAILURE;
}
- nlmon = nlmon_create(id);
+ nlmon = nlmon_create(id, config);
while (pcap_read(pcap, &tv, buf, snaplen, &len, &real_len)) {
uint16_t arphrd_type;
@@ -797,7 +798,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "Invalid packet format\n");
exit_status = EXIT_FAILURE;
} else
- exit_status = process_pcap(pcap, nl80211_family);
+ exit_status = process_pcap(pcap, nl80211_family,
+ &config);
pcap_close(pcap);
diff --git a/monitor/nlmon.c b/monitor/nlmon.c
index 69e86ce3..b58bef05 100644
--- a/monitor/nlmon.c
+++ b/monitor/nlmon.c
@@ -7253,7 +7253,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, const struct nlmon_config *config)
{
struct nlmon *nlmon;
@@ -7261,6 +7261,10 @@ struct nlmon *nlmon_create(uint16_t id)
nlmon->id = id;
nlmon->req_list = l_queue_new();
+ nlmon->nortnl = config->nortnl;
+ nlmon->nowiphy = config->nowiphy;
+ nlmon->noscan = config->noscan;
+ nlmon->noies = config->noies;
return nlmon;
}
@@ -8449,17 +8453,12 @@ struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname,
} else
pcap = NULL;
- nlmon = l_new(struct nlmon, 1);
- nlmon->id = id;
+ nlmon = nlmon_create(id, config);
+
nlmon->io = io;
nlmon->pae_io = pae_io;
- nlmon->req_list = l_queue_new();
nlmon->pcap = pcap;
- nlmon->nortnl = config->nortnl;
- nlmon->nowiphy = config->nowiphy;
- nlmon->noscan = config->noscan;
- nlmon->noies = config->noies;
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 ab038fdf..d1092c11 100644
--- a/monitor/nlmon.h
+++ b/monitor/nlmon.h
@@ -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, const struct nlmon_config *config);
void nlmon_destroy(struct nlmon *nlmon);
void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv,
const void *data, uint32_t size);
--
2.34.3
next 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 James Prestwood [this message]
2022-10-26 20:45 ` [PATCH v2 2/3] monitor: allow parsing pcaps without -F option James Prestwood
2022-10-26 20:45 ` [PATCH v2 3/3] monitor: remove " 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-1-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).