mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-23 20:54:14 +01:00
monitor: added scan/wiphy flags
Specifying --noscan will filter out any scan related packets Specifying --nowiphy will filter out any "new wiphy" packets
This commit is contained in:
parent
2608dcae6f
commit
5c5bfbb423
@ -49,7 +49,7 @@
|
|||||||
static struct nlmon *nlmon = NULL;
|
static struct nlmon *nlmon = NULL;
|
||||||
static const char *writer_path = NULL;
|
static const char *writer_path = NULL;
|
||||||
static struct l_timeout *timeout = NULL;
|
static struct l_timeout *timeout = NULL;
|
||||||
static bool nortnl;
|
static struct nlmon_config config;
|
||||||
|
|
||||||
#define NLA_OK(nla,len) ((len) >= (int) sizeof(struct nlattr) && \
|
#define NLA_OK(nla,len) ((len) >= (int) sizeof(struct nlattr) && \
|
||||||
(nla)->nla_len >= sizeof(struct nlattr) && \
|
(nla)->nla_len >= sizeof(struct nlattr) && \
|
||||||
@ -105,7 +105,7 @@ static void genl_parse(uint16_t type, const void *data, uint32_t len,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!strcmp(name, NL80211_GENL_NAME)) {
|
if (!strcmp(name, NL80211_GENL_NAME)) {
|
||||||
nlmon = nlmon_open(ifname, id, writer_path, nortnl);
|
nlmon = nlmon_open(ifname, id, writer_path, &config);
|
||||||
if (!nlmon)
|
if (!nlmon)
|
||||||
l_main_quit();
|
l_main_quit();
|
||||||
}
|
}
|
||||||
@ -674,6 +674,8 @@ static void usage(void)
|
|||||||
"\t-a, --analyze <file> Analyze netlink PCAP trace file\n"
|
"\t-a, --analyze <file> Analyze netlink PCAP trace file\n"
|
||||||
"\t-i, --interface <dev> Use specified netlink monitor\n"
|
"\t-i, --interface <dev> Use specified netlink monitor\n"
|
||||||
"\t-n, --nortnl Don't show RTNL output\n"
|
"\t-n, --nortnl Don't show RTNL output\n"
|
||||||
|
"\t-y, --nowiphy Don't show 'New Wiphy' output\n"
|
||||||
|
"\t-s, --noscan Don't show scan result output\n"
|
||||||
"\t-h, --help Show help options\n");
|
"\t-h, --help Show help options\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,6 +686,8 @@ static const struct option main_options[] = {
|
|||||||
{ "nl80211", required_argument, NULL, 'F' },
|
{ "nl80211", required_argument, NULL, 'F' },
|
||||||
{ "interface", required_argument, NULL, 'i' },
|
{ "interface", required_argument, NULL, 'i' },
|
||||||
{ "nortnl", no_argument, NULL, 'n' },
|
{ "nortnl", no_argument, NULL, 'n' },
|
||||||
|
{ "nowiphy", no_argument, NULL, 'y' },
|
||||||
|
{ "noscan", no_argument, NULL, 's' },
|
||||||
{ "version", no_argument, NULL, 'v' },
|
{ "version", no_argument, NULL, 'v' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ }
|
{ }
|
||||||
@ -703,7 +707,7 @@ int main(int argc, char *argv[])
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
opt = getopt_long(argc, argv, "r:w:a:F:i:nvh",
|
opt = getopt_long(argc, argv, "r:w:a:F:i:nvhys",
|
||||||
main_options, NULL);
|
main_options, NULL);
|
||||||
if (opt < 0)
|
if (opt < 0)
|
||||||
break;
|
break;
|
||||||
@ -742,7 +746,13 @@ int main(int argc, char *argv[])
|
|||||||
ifname = optarg;
|
ifname = optarg;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
nortnl = true;
|
config.nortnl = true;
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
config.nowiphy = true;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
config.noscan = true;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
printf("%s\n", VERSION);
|
printf("%s\n", VERSION);
|
||||||
|
@ -94,6 +94,8 @@ struct nlmon {
|
|||||||
struct l_queue *req_list;
|
struct l_queue *req_list;
|
||||||
struct pcap *pcap;
|
struct pcap *pcap;
|
||||||
bool nortnl;
|
bool nortnl;
|
||||||
|
bool nowiphy;
|
||||||
|
bool noscan;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nlmon_req {
|
struct nlmon_req {
|
||||||
@ -3945,7 +3947,8 @@ static void netlink_str(char *str, size_t size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_message(const struct timeval *tv, enum msg_type type,
|
static void print_message(struct nlmon *nlmon, const struct timeval *tv,
|
||||||
|
enum msg_type type,
|
||||||
uint16_t flags, int status,
|
uint16_t flags, int status,
|
||||||
uint8_t cmd, uint8_t version,
|
uint8_t cmd, uint8_t version,
|
||||||
const void *data, uint32_t len)
|
const void *data, uint32_t len)
|
||||||
@ -3957,6 +3960,13 @@ static void print_message(const struct timeval *tv, enum msg_type type,
|
|||||||
bool out = false;
|
bool out = false;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (nlmon->nowiphy && (cmd == NL80211_CMD_NEW_WIPHY))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (nlmon->noscan && ((cmd == NL80211_CMD_NEW_SCAN_RESULTS) ||
|
||||||
|
(cmd == NL80211_CMD_TRIGGER_SCAN)))
|
||||||
|
return;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MSG_REQUEST:
|
case MSG_REQUEST:
|
||||||
label = "Request";
|
label = "Request";
|
||||||
@ -4099,7 +4109,7 @@ static void nlmon_message(struct nlmon *nlmon, const struct timeval *tv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
store_message(nlmon, tv, nlmsg);
|
store_message(nlmon, tv, nlmsg);
|
||||||
print_message(tv, type, nlmsg->nlmsg_flags, status,
|
print_message(nlmon, tv, type, nlmsg->nlmsg_flags, status,
|
||||||
req->cmd, req->version,
|
req->cmd, req->version,
|
||||||
NULL, sizeof(status));
|
NULL, sizeof(status));
|
||||||
nlmon_req_free(req);
|
nlmon_req_free(req);
|
||||||
@ -4128,7 +4138,7 @@ static void nlmon_message(struct nlmon *nlmon, const struct timeval *tv,
|
|||||||
l_queue_push_tail(nlmon->req_list, req);
|
l_queue_push_tail(nlmon->req_list, req);
|
||||||
|
|
||||||
store_message(nlmon, tv, nlmsg);
|
store_message(nlmon, tv, nlmsg);
|
||||||
print_message(tv, MSG_REQUEST, flags, 0,
|
print_message(nlmon, tv, MSG_REQUEST, flags, 0,
|
||||||
req->cmd, req->version,
|
req->cmd, req->version,
|
||||||
NLMSG_DATA(nlmsg) + GENL_HDRLEN,
|
NLMSG_DATA(nlmsg) + GENL_HDRLEN,
|
||||||
NLMSG_PAYLOAD(nlmsg, GENL_HDRLEN));
|
NLMSG_PAYLOAD(nlmsg, GENL_HDRLEN));
|
||||||
@ -4151,7 +4161,7 @@ static void nlmon_message(struct nlmon *nlmon, const struct timeval *tv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
store_message(nlmon, tv, nlmsg);
|
store_message(nlmon, tv, nlmsg);
|
||||||
print_message(tv, type, nlmsg->nlmsg_flags, 0,
|
print_message(nlmon, tv, type, nlmsg->nlmsg_flags, 0,
|
||||||
genlmsg->cmd, genlmsg->version,
|
genlmsg->cmd, genlmsg->version,
|
||||||
NLMSG_DATA(nlmsg) + GENL_HDRLEN,
|
NLMSG_DATA(nlmsg) + GENL_HDRLEN,
|
||||||
NLMSG_PAYLOAD(nlmsg, GENL_HDRLEN));
|
NLMSG_PAYLOAD(nlmsg, GENL_HDRLEN));
|
||||||
@ -5288,7 +5298,7 @@ static struct l_io *open_pae(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
const struct nlmon_config *config)
|
||||||
{
|
{
|
||||||
struct nlmon *nlmon;
|
struct nlmon *nlmon;
|
||||||
struct l_io *io, *pae_io;
|
struct l_io *io, *pae_io;
|
||||||
@ -5321,7 +5331,9 @@ struct nlmon *nlmon_open(const char *ifname, uint16_t id, const char *pathname,
|
|||||||
nlmon->pae_io = pae_io;
|
nlmon->pae_io = pae_io;
|
||||||
nlmon->req_list = l_queue_new();
|
nlmon->req_list = l_queue_new();
|
||||||
nlmon->pcap = pcap;
|
nlmon->pcap = pcap;
|
||||||
nlmon->nortnl = nortnl;
|
nlmon->nortnl = config->nortnl;
|
||||||
|
nlmon->nowiphy = config->nowiphy;
|
||||||
|
nlmon->noscan = config->noscan;
|
||||||
|
|
||||||
l_io_set_read_handler(nlmon->io, nlmon_receive, nlmon, NULL);
|
l_io_set_read_handler(nlmon->io, nlmon_receive, nlmon, NULL);
|
||||||
l_io_set_read_handler(nlmon->pae_io, pae_receive, nlmon, NULL);
|
l_io_set_read_handler(nlmon->pae_io, pae_receive, nlmon, NULL);
|
||||||
|
@ -25,8 +25,14 @@
|
|||||||
|
|
||||||
struct nlmon;
|
struct nlmon;
|
||||||
|
|
||||||
|
struct nlmon_config {
|
||||||
|
bool nortnl;
|
||||||
|
bool nowiphy;
|
||||||
|
bool noscan;
|
||||||
|
};
|
||||||
|
|
||||||
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);
|
const struct nlmon_config *config);
|
||||||
void nlmon_close(struct nlmon *nlmon);
|
void nlmon_close(struct nlmon *nlmon);
|
||||||
|
|
||||||
struct nlmon *nlmon_create(uint16_t id);
|
struct nlmon *nlmon_create(uint16_t id);
|
||||||
|
Loading…
Reference in New Issue
Block a user