]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WNM: Add ctrl_iface command for sending WNM-Sleep Mode Request
authorJouni Malinen <jouni@qca.qualcomm.com>
Sun, 16 Dec 2012 10:29:10 +0000 (12:29 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 16 Dec 2012 10:29:10 +0000 (12:29 +0200)
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/ctrl_iface.c
wpa_supplicant/wnm_sta.c
wpa_supplicant/wnm_sta.h
wpa_supplicant/wpa_cli.c

index 5bfa890d575d9ac70b0667862eb72cee59782375..b12d349098f1c7d01c35ef0376f43d9c9c8fb157 100644 (file)
@@ -38,6 +38,7 @@
 #include "interworking.h"
 #include "blacklist.h"
 #include "autoscan.h"
+#include "wnm_sta.h"
 
 extern struct wpa_driver_ops *wpa_drivers[];
 
@@ -4671,6 +4672,31 @@ static int wpa_supplicant_ctrl_iface_autoscan(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_AUTOSCAN */
 
 
+#ifdef CONFIG_WNM
+
+static int wpas_ctrl_iface_wnm_sleep(struct wpa_supplicant *wpa_s, char *cmd)
+{
+       int enter;
+       int intval = 0;
+       char *pos;
+
+       if (os_strncmp(cmd, "enter", 5) == 0)
+               enter = 1;
+       else if (os_strncmp(cmd, "exit", 4) == 0)
+               enter = 0;
+       else
+               return -1;
+
+       pos = os_strstr(cmd, " interval=");
+       if (pos)
+               intval = atoi(pos + 10);
+
+       return ieee802_11_send_wnmsleep_req(wpa_s, enter ? 0 : 1, intval);
+}
+
+#endif /* CONFIG_WNM */
+
+
 static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf,
                                      size_t buflen)
 {
@@ -5221,6 +5247,11 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
        } else if (os_strcmp(buf, "REAUTHENTICATE") == 0) {
                pmksa_cache_clear_current(wpa_s->wpa);
                eapol_sm_request_reauth(wpa_s->eapol);
+#ifdef CONFIG_WNM
+       } else if (os_strncmp(buf, "WNM_SLEEP ", 10) == 0) {
+               if (wpas_ctrl_iface_wnm_sleep(wpa_s, buf + 10))
+                       reply_len = -1;
+#endif /* CONFIG_WNM */
        } else {
                os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
                reply_len = 16;
index aefe375c21901c27dcfdcbcd8090447a483f5b58..870c536ce37e347264a5fd391d47565f8e0a8012 100644 (file)
@@ -41,7 +41,7 @@ static int ieee80211_11_set_tfs_ie(struct wpa_supplicant *wpa_s,
 
 /* MLME-SLEEPMODE.request */
 int ieee802_11_send_wnmsleep_req(struct wpa_supplicant *wpa_s,
-                                u8 action, u8 intval)
+                                u8 action, u16 intval)
 {
        struct ieee80211_mgmt *mgmt;
        int res;
@@ -62,7 +62,7 @@ int ieee802_11_send_wnmsleep_req(struct wpa_supplicant *wpa_s,
        wnmsleep_ie->len = wnmsleep_ie_len - 2;
        wnmsleep_ie->action_type = action;
        wnmsleep_ie->status = WNM_STATUS_SLEEP_ACCEPT;
-       wnmsleep_ie->intval = intval;
+       wnmsleep_ie->intval = host_to_le16(intval);
 
        /* TFS IE(s) */
        wnmtfs_ie = os_zalloc(MAX_TFS_IE_LEN);
index ba2535b041b7ab305dc85136f7db5f3987a88aff..96fe0d9c663ab928b1e47bce865eb9f914cebf8c 100644 (file)
@@ -13,7 +13,7 @@ struct rx_action;
 struct wpa_supplicant;
 
 int ieee802_11_send_wnmsleep_req(struct wpa_supplicant *wpa_s,
-                                u8 action, u8 intval);
+                                u8 action, u16 intval);
 
 void ieee802_11_rx_wnm_action(struct wpa_supplicant *wpa_s,
                              struct rx_action *action);
index 61bb7fd7ec4996a54bf801caf15c66d41e823a74..0c6ef5e8ad1250f12f9f2735abfd2bc8bba90843 100644 (file)
@@ -2247,6 +2247,16 @@ static int wpa_cli_cmd_autoscan(struct wpa_ctrl *ctrl, int argc, char *argv[])
 #endif /* CONFIG_AUTOSCAN */
 
 
+#ifdef CONFIG_WNM
+
+static int wpa_cli_cmd_wnm_sleep(struct wpa_ctrl *ctrl, int argc, char *argv[])
+{
+       return wpa_cli_cmd(ctrl, "WNM_SLEEP", 0, argc, argv);
+}
+
+#endif /* CONFIG_WNM */
+
+
 static int wpa_cli_cmd_raw(struct wpa_ctrl *ctrl, int argc, char *argv[])
 {
        if (argc == 0)
@@ -2689,6 +2699,10 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
        { "autoscan", wpa_cli_cmd_autoscan, NULL, cli_cmd_flag_none,
          "[params] = Set or unset (if none) autoscan parameters" },
 #endif /* CONFIG_AUTOSCAN */
+#ifdef CONFIG_WNM
+       { "wnm_sleep", wpa_cli_cmd_wnm_sleep, NULL, cli_cmd_flag_none,
+         "<enter/exit> [interval=#] = enter/exit WNM-Sleep mode" },
+#endif /* CONFIG_WNM */
        { "raw", wpa_cli_cmd_raw, NULL, cli_cmd_flag_sensitive,
          "<params..> = Sent unprocessed command" },
        { NULL, NULL, NULL, cli_cmd_flag_none, NULL }