From: Jouni Malinen Date: Fri, 1 Nov 2013 09:30:24 +0000 (+0200) Subject: AOSP: driver_cmd X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e5c6ad06730e8a7b0894064ae5b316140c8d0fe;p=thirdparty%2Fhostap.git AOSP: driver_cmd --- diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 97bd9c671..b8c98290d 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -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 diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 6792e04d8..567b3aab4 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -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 }; diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 3ac4c8745..57364f474 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -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); diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h index ad33d3c82..5e7dbf73a 100644 --- a/wpa_supplicant/driver_i.h +++ b/wpa_supplicant/driver_i.h @@ -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) diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 65ca9a34b..a379d6504 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -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[] = { " = 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, + " = driver private commands" }, +#endif { NULL, NULL, NULL, cli_cmd_flag_none, NULL } };