]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AOSP: driver_cmd
authorJouni Malinen <j@w1.fi>
Fri, 1 Nov 2013 09:30:24 +0000 (11:30 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 1 Nov 2013 14:34:56 +0000 (16:34 +0200)
src/drivers/driver.h
src/drivers/driver_nl80211.c
wpa_supplicant/ctrl_iface.c
wpa_supplicant/driver_i.h
wpa_supplicant/wpa_cli.c

index 97bd9c6716d4b65ac4bde4820afc54d41306817c..b8c98290d8a5c5f61a8862e60058fcc207854f58 100644 (file)
@@ -2591,7 +2591,18 @@ struct wpa_driver_ops {
         * DEPRECATED - use set_ap() instead
         */
        int (*set_authmode)(void *priv, int authmode);
-
+#ifdef ANDROID
+       /**
+        * driver_cmd - execute driver-specific command
+        * @priv: private driver interface data
+        * @cmd: command to execute
+        * @buf: return buffer
+        * @buf_len: buffer length
+        *
+        * Returns: 0 on success, -1 on failure
+        */
+        int (*driver_cmd)(void *priv, char *cmd, char *buf, size_t buf_len);
+#endif
        /**
         * set_rekey_info - Set rekey information
         * @priv: Private driver interface data
index 6792e04d8f0db42904b57dd1bfa064238923da92..567b3aab47ed5f91afd83d1d60f3b9dc62104bd4 100644 (file)
@@ -343,6 +343,10 @@ static inline int have_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx)
        return 0;
 }
 #endif /* HOSTAPD */
+#ifdef ANDROID
+extern int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf,
+                                        size_t buf_len);
+#endif
 
 static int wpa_driver_nl80211_set_freq(struct i802_bss *bss,
                                       struct hostapd_freq_params *freq);
@@ -10777,4 +10781,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        .update_ft_ies = wpa_driver_nl80211_update_ft_ies,
        .get_mac_addr = wpa_driver_nl80211_get_macaddr,
        .get_survey = wpa_driver_nl80211_get_survey,
+#ifdef ANDROID
+       .driver_cmd = wpa_driver_nl80211_driver_cmd,
+#endif
 };
index 3ac4c8745d5692d5582f89489c2ec526e8147ee6..57364f47486b1383c9d2526929c95df7c7de0b25 100644 (file)
@@ -5124,6 +5124,20 @@ static int wpa_supplicant_pktcnt_poll(struct wpa_supplicant *wpa_s, char *buf,
 }
 
 
+#ifdef ANDROID
+static int wpa_supplicant_driver_cmd(struct wpa_supplicant *wpa_s, char *cmd,
+                                    char *buf, size_t buflen)
+{
+       int ret;
+
+       ret = wpa_drv_driver_cmd(wpa_s, cmd, buf, buflen);
+       if (ret == 0)
+               ret = sprintf(buf, "%s\n", "OK");
+       return ret;
+}
+#endif
+
+
 static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
 {
        wpa_dbg(wpa_s, MSG_DEBUG, "Flush all wpa_supplicant state");
@@ -5696,6 +5710,11 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                if (wpa_supplicant_ctrl_iface_autoscan(wpa_s, buf + 9))
                        reply_len = -1;
 #endif /* CONFIG_AUTOSCAN */
+#ifdef ANDROID
+       } else if (os_strncmp(buf, "DRIVER ", 7) == 0) {
+               reply_len = wpa_supplicant_driver_cmd(wpa_s, buf + 7, reply,
+                                                     reply_size);
+#endif
        } else if (os_strcmp(buf, "REAUTHENTICATE") == 0) {
                pmksa_cache_clear_current(wpa_s->wpa);
                eapol_sm_request_reauth(wpa_s->eapol);
index ad33d3c82c7c351dbb4bab49bf6cfb75c9a80bc9..5e7dbf73ae018b6a3e3e22cafaec0f8ff70edb3f 100644 (file)
@@ -665,6 +665,16 @@ static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
        return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
 }
 
+#ifdef ANDROID
+static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
+                                    char *cmd, char *buf, size_t buf_len)
+{
+       if (!wpa_s->driver->driver_cmd)
+               return -1;
+       return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
+}
+#endif
+
 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
                                          const u8 *kek, const u8 *kck,
                                          const u8 *replay_ctr)
index 65ca9a34b6257a37f9a199a336501f30e57e337f..a379d6504e426bbc8c9cb25ec59805f5e46d9009 100644 (file)
@@ -2369,6 +2369,28 @@ static int wpa_cli_cmd_raw(struct wpa_ctrl *ctrl, int argc, char *argv[])
 }
 
 
+#ifdef ANDROID
+static int wpa_cli_cmd_driver(struct wpa_ctrl *ctrl, int argc, char *argv[])
+{
+       char cmd[256];
+       int i;
+       int len;
+
+       if (argc < 1) {
+               printf("Invalid DRIVER command: needs one argument (cmd)\n");
+               return -1;
+       }
+
+       len = os_snprintf(cmd, sizeof(cmd), "DRIVER %s", argv[0]);
+       for (i=1; i < argc; i++)
+               len += os_snprintf(cmd + len, sizeof(cmd) - len, " %s", argv[i]);
+       cmd[sizeof(cmd) - 1] = '\0';
+       printf("%s: %s\n", __func__, cmd);
+       return wpa_ctrl_command(ctrl, cmd);
+}
+#endif
+
+
 static int wpa_cli_cmd_flush(struct wpa_ctrl *ctrl, int argc, char *argv[])
 {
        return wpa_ctrl_command(ctrl, "FLUSH");
@@ -2830,6 +2852,11 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
          "<params..> = Sent unprocessed command" },
        { "flush", wpa_cli_cmd_flush, NULL, cli_cmd_flag_none,
          "= flush wpa_supplicant state" },
+#ifdef ANDROID
+       { "driver", wpa_cli_cmd_driver, NULL,
+         cli_cmd_flag_none,
+         "<command> = driver private commands" },
+#endif
        { NULL, NULL, NULL, cli_cmd_flag_none, NULL }
 };