aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-08-09 19:22:47 (GMT)
committerJouni Malinen <j@w1.fi>2012-08-09 20:18:32 (GMT)
commite303d7191b0d0ea05b5ea21e6fb4304fc840d348 (patch)
tree5af14b0fcb029a3d6c87e582dfdf8a1483a7422b
parentda08a8eb9ad3899eedad7abc4724d660f1a85b54 (diff)
downloadhostap-e303d7191b0d0ea05b5ea21e6fb4304fc840d348.zip
hostap-e303d7191b0d0ea05b5ea21e6fb4304fc840d348.tar.gz
hostap-e303d7191b0d0ea05b5ea21e6fb4304fc840d348.tar.bz2
AOSP: wpa_cli
-rw-r--r--wpa_supplicant/wpa_cli.c67
1 files changed, 64 insertions, 3 deletions
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 4cd289b..4685970 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -80,6 +80,9 @@ static const char *pid_file = NULL;
static const char *action_file = NULL;
static int ping_interval = 5;
static int interactive = 0;
+#if defined(CONFIG_P2P) && defined(ANDROID_P2P)
+static char* redirect_interface = NULL;
+#endif
struct cli_txt_entry {
struct dl_list list;
@@ -395,7 +398,14 @@ static void wpa_cli_msg_cb(char *msg, size_t len)
static int _wpa_ctrl_command(struct wpa_ctrl *ctrl, char *cmd, int print)
{
+#ifdef ANDROID
+ char buf[4096];
+#else
char buf[2048];
+#endif
+#if defined(CONFIG_P2P) && defined(ANDROID_P2P)
+ char _cmd[256];
+#endif
size_t len;
int ret;
@@ -403,6 +413,22 @@ static int _wpa_ctrl_command(struct wpa_ctrl *ctrl, char *cmd, int print)
printf("Not connected to wpa_supplicant - command dropped.\n");
return -1;
}
+#if defined(CONFIG_P2P) && defined(ANDROID_P2P)
+ if (redirect_interface) {
+ char *arg;
+ arg = os_strchr(cmd, ' ');
+ if (arg) {
+ *arg++ = '\0';
+ ret = os_snprintf(_cmd, sizeof(_cmd), "%s %s %s", cmd, redirect_interface, arg);
+ }
+ else {
+ ret = os_snprintf(_cmd, sizeof(_cmd), "%s %s", cmd, redirect_interface);
+ }
+ cmd = _cmd;
+ os_free(redirect_interface);
+ redirect_interface = NULL;
+ }
+#endif
len = sizeof(buf) - 1;
ret = wpa_ctrl_request(ctrl, cmd, os_strlen(cmd), buf, &len,
wpa_cli_msg_cb);
@@ -1642,9 +1668,8 @@ static int wpa_cli_cmd_bss(struct wpa_ctrl *ctrl, int argc, char *argv[])
return -1;
}
- res = os_snprintf(cmd, sizeof(cmd), "BSS %s%s%s%s%s", argv[0],
- argc > 1 ? " " : "", argc > 1 ? argv[1] : "",
- argc > 2 ? " " : "", argc > 2 ? argv[2] : "");
+ res = os_snprintf(cmd, sizeof(cmd), "BSS %s\t%s\t%s", argv[0],
+ argc > 1 ? argv[1] : "", argc > 2 ? argv[2] : "");
if (res < 0 || (size_t) res >= sizeof(cmd))
return -1;
@@ -2659,6 +2684,26 @@ static int wpa_cli_cmd_reauthenticate(struct wpa_ctrl *ctrl, int argc,
return wpa_ctrl_command(ctrl, "REAUTHENTICATE");
}
+#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
enum wpa_cli_cmd_flags {
cli_cmd_flag_none = 0x00,
@@ -3004,6 +3049,11 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
"= get signal parameters" },
{ "reauthenticate", wpa_cli_cmd_reauthenticate, cli_cmd_flag_none,
"= trigger IEEE 802.1X/EAPOL reauthentication" },
+#ifdef ANDROID
+ { "driver", wpa_cli_cmd_driver,
+ cli_cmd_flag_none,
+ "<command> = driver private commands" },
+#endif
{ NULL, NULL, cli_cmd_flag_none, NULL }
};
@@ -3164,6 +3214,13 @@ static int wpa_request(struct wpa_ctrl *ctrl, int argc, char *argv[])
printf("Unknown command '%s'\n", argv[0]);
ret = 1;
} else {
+#if defined(CONFIG_P2P) && defined(ANDROID_P2P)
+ if ( (argc >= 2) && (os_strncmp(argv[1], "interface=", 10) == 0)) {
+ redirect_interface = os_strdup(argv[1]);
+ ret = match->handler(ctrl, argc - 2, &argv[2]);
+ }
+ else
+#endif
ret = match->handler(ctrl, argc - 1, &argv[1]);
}
@@ -3606,7 +3663,11 @@ static char * wpa_cli_get_default_ifname(void)
#endif /* CONFIG_CTRL_IFACE_UNIX */
#ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
+#ifdef ANDROID
+ char buf[4096], *pos;
+#else
char buf[2048], *pos;
+#endif
size_t len;
struct wpa_ctrl *ctrl;
int ret;