X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=event.c;h=100f644d00d1a0ba41a30ea0c6376139ebf4a640;hb=HEAD;hp=61395f8f0e070150a0f87a9740431d02890d38a5;hpb=cd64525e2d3674da64d7ce554f8047950764dff1;p=thirdparty%2Fiw.git diff --git a/event.c b/event.c index 61395f8..dec50f0 100644 --- a/event.c +++ b/event.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "iw.h" static int no_seq_check(struct nl_msg *msg, void *arg) @@ -294,6 +295,8 @@ static void parse_wowlan_wake_event(struct nlattr **attrs) printf("\t* TCP connection lost\n"); if (tb[NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS]) printf("\t* TCP connection ran out of tokens\n"); + if (tb[NL80211_WOWLAN_TRIG_UNPROTECTED_DEAUTH_DISASSOC]) + printf("\t* unprotected deauth/disassoc\n"); } extern struct vendor_event *__start_vendor_event[]; @@ -892,6 +895,21 @@ static void parse_ch_switch_notify(struct nlattr **attrs, int command) printf("\n"); } +static void parse_assoc_comeback(struct nlattr **attrs, int command) +{ + __u32 timeout = 0; + char macbuf[6 * 3] = ""; + + if (attrs[NL80211_ATTR_MAC]) + mac_addr_n2a(macbuf, nla_data(attrs[NL80211_ATTR_MAC])); + + if (attrs[NL80211_ATTR_TIMEOUT]) + timeout = nla_get_u32(attrs[NL80211_ATTR_TIMEOUT]); + + printf("assoc comeback bssid %s timeout %d\n", + macbuf, timeout); +} + static int print_event(struct nl_msg *msg, void *arg) { struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); @@ -905,12 +923,13 @@ static int print_event(struct nl_msg *msg, void *arg) int rem_nst; __u16 status; - if (args->time || args->reltime) { + if (args->time || args->reltime || args->ctime) { unsigned long long usecs, previous; previous = 1000000ULL * args->ts.tv_sec + args->ts.tv_usec; gettimeofday(&args->ts, NULL); usecs = 1000000ULL * args->ts.tv_sec + args->ts.tv_usec; + if (args->reltime) { if (!args->have_ts) { usecs = 0; @@ -918,7 +937,17 @@ static int print_event(struct nl_msg *msg, void *arg) } else usecs -= previous; } - printf("%llu.%06llu: ", usecs/1000000, usecs % 1000000); + + if (args->ctime) { + struct tm *tm = localtime(&args->ts.tv_sec); + char buf[255]; + + memset(buf, 0, 255); + strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm); + printf("[%s.%06lu]: ", buf, (unsigned long )args->ts.tv_usec); + } else { + printf("%llu.%06llu: ", usecs/1000000, usecs % 1000000); + } } nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), @@ -1221,6 +1250,12 @@ static int print_event(struct nl_msg *msg, void *arg) case NL80211_RADAR_NOP_FINISHED: printf("%d MHz: NOP finished\n", freq); break; + case NL80211_RADAR_PRE_CAC_EXPIRED: + printf("%d MHz: PRE-CAC expired\n", freq); + break; + case NL80211_RADAR_CAC_STARTED: + printf("%d MHz: CAC started\n", freq); + break; default: printf("%d MHz: unknown radar event\n", freq); } @@ -1259,6 +1294,9 @@ static int print_event(struct nl_msg *msg, void *arg) case NL80211_CMD_CH_SWITCH_NOTIFY: parse_ch_switch_notify(tb, gnlh->cmd); break; + case NL80211_CMD_ASSOC_COMEBACK: /* 147 */ + parse_assoc_comeback(tb, gnlh->cmd); + break; default: printf("unknown event %d (%s)\n", gnlh->cmd, command_name(gnlh->cmd)); @@ -1407,6 +1445,7 @@ static int print_events(struct nl80211_state *state, enum id_input id) { struct print_event_args args; + int num_time_formats = 0; int ret; memset(&args, 0, sizeof(args)); @@ -1417,17 +1456,22 @@ static int print_events(struct nl80211_state *state, while (argc > 0) { if (strcmp(argv[0], "-f") == 0) args.frame = true; - else if (strcmp(argv[0], "-t") == 0) + else if (strcmp(argv[0], "-t") == 0) { + num_time_formats++; args.time = true; - else if (strcmp(argv[0], "-r") == 0) + } else if (strcmp(argv[0], "-T") == 0) { + num_time_formats++; + args.ctime = true; + } else if (strcmp(argv[0], "-r") == 0) { + num_time_formats++; args.reltime = true; - else + } else return 1; argc--; argv++; } - if (args.time && args.reltime) + if (num_time_formats > 1) return 1; if (argc) @@ -1439,8 +1483,9 @@ static int print_events(struct nl80211_state *state, return __do_listen_events(state, 0, NULL, 0, NULL, &args); } -TOPLEVEL(event, "[-t|-r] [-f]", 0, 0, CIB_NONE, print_events, +TOPLEVEL(event, "[-t|-T|-r] [-f]", 0, 0, CIB_NONE, print_events, "Monitor events from the kernel.\n" "-t - print timestamp\n" + "-T - print absolute, human-readable timestamp\n" "-r - print relative timestamp\n" "-f - print full frame for auth/assoc etc.");