]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Add a driver ops function to check WoWLAN status
authorMatteo Croce <matteo.croce@canonical.com>
Thu, 14 Jun 2018 09:00:42 +0000 (11:00 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 30 Dec 2019 16:46:29 +0000 (18:46 +0200)
Add function that returns whether WoWLAN has been enabled for the device
or not.

Signed-off-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
src/drivers/driver.h
src/drivers/driver_nl80211.c

index f0e2a6f26e2abd6b8edbaea3423b66e9d09b8e04..ce64f341c6fdb862a1e48125f386dddabd34c0bd 100644 (file)
@@ -3512,6 +3512,12 @@ struct wpa_driver_ops {
        int (*br_set_net_param)(void *priv, enum drv_br_net_param param,
                                unsigned int val);
 
+       /**
+        * get_wowlan - Get wake-on-wireless status
+        * @priv: Private driver interface data
+        */
+       int (*get_wowlan)(void *priv);
+
        /**
         * set_wowlan - Set wake-on-wireless triggers
         * @priv: Private driver interface data
index b7efb6a3b864d51a3cb2ba8c9e8e8cb952bcec1d..9b3f6047108e4cdaee8a2cf18db79dbbf5723487 100644 (file)
@@ -9398,6 +9398,46 @@ static int nl80211_set_qos_map(void *priv, const u8 *qos_map_set,
 }
 
 
+static int get_wowlan_handler(struct nl_msg *msg, void *arg)
+{
+       struct nlattr *tb[NL80211_ATTR_MAX + 1];
+       struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+       int *wowlan_enabled = arg;
+
+       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+                 genlmsg_attrlen(gnlh, 0), NULL);
+
+       *wowlan_enabled = !!tb[NL80211_ATTR_WOWLAN_TRIGGERS];
+
+       return NL_SKIP;
+}
+
+
+static int nl80211_get_wowlan(void *priv)
+{
+       struct i802_bss *bss = priv;
+       struct wpa_driver_nl80211_data *drv = bss->drv;
+       struct nl_msg *msg;
+       int wowlan_enabled;
+       int ret;
+
+       wpa_printf(MSG_DEBUG, "nl80211: Getting wowlan status");
+
+       msg = nl80211_drv_msg(drv, 0, NL80211_CMD_GET_WOWLAN);
+
+       ret = send_and_recv_msgs(drv, msg, get_wowlan_handler, &wowlan_enabled);
+       if (ret) {
+               wpa_printf(MSG_DEBUG, "nl80211: Getting wowlan status failed");
+               return 0;
+       }
+
+       wpa_printf(MSG_DEBUG, "nl80211: wowlan is %s",
+                  wowlan_enabled ? "enabled" : "disabled");
+
+       return wowlan_enabled;
+}
+
+
 static int nl80211_set_wowlan(void *priv,
                              const struct wowlan_triggers *triggers)
 {
@@ -11269,6 +11309,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
 #endif /* ANDROID */
        .vendor_cmd = nl80211_vendor_cmd,
        .set_qos_map = nl80211_set_qos_map,
+       .get_wowlan = nl80211_get_wowlan,
        .set_wowlan = nl80211_set_wowlan,
        .set_mac_addr = nl80211_set_mac_addr,
 #ifdef CONFIG_MESH