mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-09 06:14:05 +01:00
monitor: Add option to not print rtnl output
This commit is contained in:
parent
c6fb438c73
commit
d6a9b0f85a
@ -49,6 +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;
|
||||||
|
|
||||||
#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) && \
|
||||||
@ -104,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);
|
nlmon = nlmon_open(ifname, id, writer_path, nortnl);
|
||||||
if (!nlmon)
|
if (!nlmon)
|
||||||
l_main_quit();
|
l_main_quit();
|
||||||
}
|
}
|
||||||
@ -681,6 +682,7 @@ static const struct option main_options[] = {
|
|||||||
{ "analyze", required_argument, NULL, 'a' },
|
{ "analyze", required_argument, NULL, 'a' },
|
||||||
{ "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' },
|
||||||
{ "version", no_argument, NULL, 'v' },
|
{ "version", no_argument, NULL, 'v' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ }
|
{ }
|
||||||
@ -700,7 +702,7 @@ int main(int argc, char *argv[])
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
opt = getopt_long(argc, argv, "r:w:a:F:i:vh",
|
opt = getopt_long(argc, argv, "r:w:a:F:i:nvh",
|
||||||
main_options, NULL);
|
main_options, NULL);
|
||||||
if (opt < 0)
|
if (opt < 0)
|
||||||
break;
|
break;
|
||||||
@ -738,6 +740,9 @@ int main(int argc, char *argv[])
|
|||||||
case 'i':
|
case 'i':
|
||||||
ifname = optarg;
|
ifname = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
nortnl = true;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
printf("%s\n", VERSION);
|
printf("%s\n", VERSION);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -93,6 +93,7 @@ struct nlmon {
|
|||||||
struct l_io *pae_io;
|
struct l_io *pae_io;
|
||||||
struct l_queue *req_list;
|
struct l_queue *req_list;
|
||||||
struct pcap *pcap;
|
struct pcap *pcap;
|
||||||
|
bool nortnl;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nlmon_req {
|
struct nlmon_req {
|
||||||
@ -4616,7 +4617,10 @@ static bool nlmon_receive(struct l_io *io, void *user_data)
|
|||||||
switch (proto_type) {
|
switch (proto_type) {
|
||||||
case NETLINK_ROUTE:
|
case NETLINK_ROUTE:
|
||||||
store_netlink(nlmon, tv, proto_type, nlmsg);
|
store_netlink(nlmon, tv, proto_type, nlmsg);
|
||||||
nlmon_print_rtnl(nlmon, tv, nlmsg, nlmsg->nlmsg_len);
|
|
||||||
|
if (!nlmon->nortnl)
|
||||||
|
nlmon_print_rtnl(nlmon, tv, nlmsg,
|
||||||
|
nlmsg->nlmsg_len);
|
||||||
break;
|
break;
|
||||||
case NETLINK_GENERIC:
|
case NETLINK_GENERIC:
|
||||||
nlmon_message(nlmon, tv, tp, nlmsg);
|
nlmon_message(nlmon, tv, tp, nlmsg);
|
||||||
@ -4920,7 +4924,8 @@ static struct l_io *open_pae(void)
|
|||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
struct nlmon *nlmon;
|
struct nlmon *nlmon;
|
||||||
struct l_io *io, *pae_io;
|
struct l_io *io, *pae_io;
|
||||||
@ -4953,6 +4958,7 @@ 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;
|
||||||
|
|
||||||
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,7 +25,8 @@
|
|||||||
|
|
||||||
struct nlmon;
|
struct nlmon;
|
||||||
|
|
||||||
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);
|
||||||
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