]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - event.c
makefile: don't include .config
[thirdparty/iw.git] / event.c
diff --git a/event.c b/event.c
index 6f7027fc8372d9f62ec3c7ded4d7ac3da3ccd2f3..fbe3e0e36182db11aad9bca0cc66e928f8790ff5 100644 (file)
--- a/event.c
+++ b/event.c
@@ -110,7 +110,7 @@ static void parse_cqm_event(struct nlattr **attrs)
        struct nlattr *cqm[NL80211_ATTR_CQM_MAX + 1];
        struct nlattr *cqm_attr = attrs[NL80211_ATTR_CQM];
 
-       printf("connection quality monitor event: ");
+       printf("CQM event: ");
 
        if (!cqm_attr ||
            nla_parse_nested(cqm, NL80211_ATTR_CQM_MAX, cqm_attr, cqm_policy)) {
@@ -120,11 +120,27 @@ static void parse_cqm_event(struct nlattr **attrs)
 
        if (cqm[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT]) {
                enum nl80211_cqm_rssi_threshold_event rssi_event;
+               bool found_one = false;
+
                rssi_event = nla_get_u32(cqm[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT]);
-               if (rssi_event == NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH)
+
+               switch (rssi_event) {
+               case NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH:
                        printf("RSSI went above threshold\n");
-               else
+                       found_one = true;
+                       break;
+               case NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW:
                        printf("RSSI went below threshold\n");
+                       found_one = true;
+                       break;
+               case NL80211_CQM_RSSI_BEACON_LOSS_EVENT:
+                       printf("Beacon loss detected\n");
+                       found_one = true;
+                       break;
+               }
+
+               if (!found_one)
+                       printf("Unknown event type: %i\n", rssi_event);
        } else if (cqm[NL80211_ATTR_CQM_PKT_LOSS_EVENT] &&
                   attrs[NL80211_ATTR_MAC]) {
                uint32_t frames;
@@ -183,6 +199,67 @@ static void parse_mic_failure(struct nlattr **attrs)
        printf("\n");
 }
 
+static void parse_wowlan_wake_event(struct nlattr **attrs)
+{
+       struct nlattr *tb[NUM_NL80211_WOWLAN_TRIG];
+
+       printf("WoWLAN wakeup\n");
+       if (!attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) {
+               printf("\twakeup not due to WoWLAN\n");
+               return;
+       }
+
+       nla_parse(tb, MAX_NL80211_WOWLAN_TRIG,
+                 nla_data(attrs[NL80211_ATTR_WOWLAN_TRIGGERS]),
+                 nla_len(attrs[NL80211_ATTR_WOWLAN_TRIGGERS]), NULL);
+
+       if (tb[NL80211_WOWLAN_TRIG_DISCONNECT])
+               printf("\t* was disconnected\n");
+       if (tb[NL80211_WOWLAN_TRIG_MAGIC_PKT])
+               printf("\t* magic packet received\n");
+       if (tb[NL80211_WOWLAN_TRIG_PKT_PATTERN])
+               printf("\t* pattern index: %u\n",
+                      nla_get_u32(tb[NL80211_WOWLAN_TRIG_PKT_PATTERN]));
+       if (tb[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE])
+               printf("\t* GTK rekey failure\n");
+       if (tb[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST])
+               printf("\t* EAP identity request\n");
+       if (tb[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE])
+               printf("\t* 4-way handshake\n");
+       if (tb[NL80211_WOWLAN_TRIG_RFKILL_RELEASE])
+               printf("\t* RF-kill released\n");
+       if (tb[NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211]) {
+               uint8_t *d = nla_data(tb[NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211]);
+               int l = nla_len(tb[NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211]);
+               int i;
+               printf("\t* packet (might be truncated): ");
+               for (i = 0; i < l; i++) {
+                       if (i > 0)
+                               printf(":");
+                       printf("%.2x", d[i]);
+               }
+               printf("\n");
+       }
+       if (tb[NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023]) {
+               uint8_t *d = nla_data(tb[NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023]);
+               int l = nla_len(tb[NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023]);
+               int i;
+               printf("\t* packet (might be truncated): ");
+               for (i = 0; i < l; i++) {
+                       if (i > 0)
+                               printf(":");
+                       printf("%.2x", d[i]);
+               }
+               printf("\n");
+       }
+       if (tb[NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH])
+               printf("\t* TCP connection wakeup received\n");
+       if (tb[NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST])
+               printf("\t* TCP connection lost\n");
+       if (tb[NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS])
+               printf("\t* TCP connection ran out of tokens\n");
+}
+
 static int print_event(struct nl_msg *msg, void *arg)
 {
        struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
@@ -437,6 +514,9 @@ static int print_event(struct nl_msg *msg, void *arg)
        case NL80211_CMD_PMKSA_CANDIDATE:
                printf("PMKSA candidate found\n");
                break;
+       case NL80211_CMD_SET_WOWLAN:
+               parse_wowlan_wake_event(tb);
+               break;
        default:
                printf("unknown event %d\n", gnlh->cmd);
                break;