]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Android: Add DRIVER command support on hostapd and hostapd_cli
authorSunil Dutt <usdutt@codeaurora.org>
Thu, 18 Feb 2021 15:43:13 +0000 (07:43 -0800)
committerJouni Malinen <j@w1.fi>
Fri, 26 Feb 2021 18:22:41 +0000 (20:22 +0200)
Add DRIVER command support on hostapd and hostapd_cli on Android
similarly to the way this previously enabled in wpa_supplicant and
wpa_cli.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
hostapd/ctrl_iface.c
hostapd/hostapd_cli.c
src/ap/ap_drv_ops.h

index 3254557913d2b1b055adfe7540b1a3d33b9a50dc..05d6be6ffb0501e0ca6b70b70d53e0ba2dbbf432 100644 (file)
@@ -3364,6 +3364,23 @@ static int hostapd_ctrl_iface_get_capability(struct hostapd_data *hapd,
 }
 
 
+#ifdef ANDROID
+static int hostapd_ctrl_iface_driver_cmd(struct hostapd_data *hapd, char *cmd,
+                                        char *buf, size_t buflen)
+{
+       int ret;
+
+       ret = hostapd_drv_driver_cmd(hapd, cmd, buf, buflen);
+       if (ret == 0) {
+               ret = os_snprintf(buf, buflen, "%s\n", "OK");
+               if (os_snprintf_error(buflen, ret))
+                       ret = -1;
+       }
+       return ret;
+}
+#endif /* ANDROID */
+
+
 static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
                                              char *buf, char *reply,
                                              int reply_size,
@@ -3866,6 +3883,11 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
        } else if (os_strcmp(buf, "PTKSA_CACHE_LIST") == 0) {
                reply_len = ptksa_cache_list(hapd->ptksa, reply, reply_size);
 #endif /* CONFIG_PASN */
+#ifdef ANDROID
+       } else if (os_strncmp(buf, "DRIVER ", 7) == 0) {
+               reply_len = hostapd_ctrl_iface_driver_cmd(hapd, buf + 7, reply,
+                                                         reply_size);
+#endif /* ANDROID */
        } else {
                os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
                reply_len = 16;
index 249e46699273485c6186acbb36236fd52585d38b..eaa628ad0676cc0e8962df69242cdd98ede505f0 100644 (file)
@@ -1541,6 +1541,14 @@ static int hostapd_cli_cmd_reload_wpa_psk(struct wpa_ctrl *ctrl, int argc,
 }
 
 
+#ifdef ANDROID
+static int hostapd_cli_cmd_driver(struct wpa_ctrl *ctrl, int argc, char *argv[])
+{
+       return hostapd_cli_cmd(ctrl, "DRIVER", 1, argc, argv);
+}
+#endif /* ANDROID */
+
+
 struct hostapd_cli_cmd {
        const char *cmd;
        int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]);
@@ -1732,6 +1740,10 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
          "<addr> [req_mode=] <measurement request hexdump>  = send a Beacon report request to a station" },
        { "reload_wpa_psk", hostapd_cli_cmd_reload_wpa_psk, NULL,
          "= reload wpa_psk_file only" },
+#ifdef ANDROID
+       { "driver", hostapd_cli_cmd_driver, NULL,
+         "<driver sub command> [<hex formatted data>] = send driver command data" },
+#endif /* ANDROID */
        { NULL, NULL, NULL, NULL }
 };
 
index 582ab61d8dd52a4a8b47435747088e1a92bae197..a420701167710ed877e75c9fbf498d205ae4c65b 100644 (file)
@@ -393,4 +393,14 @@ hostapd_drv_set_band(struct hostapd_data *hapd, u32 band_mask)
        return hapd->driver->set_band(hapd->drv_priv, band_mask);
 }
 
+#ifdef ANDROID
+static inline int hostapd_drv_driver_cmd(struct hostapd_data *hapd,
+                                        char *cmd, char *buf, size_t buf_len)
+{
+       if (!hapd->driver->driver_cmd)
+               return -1;
+       return hapd->driver->driver_cmd(hapd->drv_priv, cmd, buf, buf_len);
+}
+#endif /* ANDROID */
+
 #endif /* AP_DRV_OPS */