diff options
author | Dmitry Shmidt <dimitrysh@google.com> | 2011-03-21 16:10:39 -0700 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2011-03-22 09:55:48 -0700 |
commit | eee21e1de8514a43f3e9089c136e7e27cc27a9fc (patch) | |
tree | 35401a963243c7341772cadd268e7eb69b1791c5 | |
parent | f257b4b4ffab5e52d7e3612c02f5c70d7eeaafc0 (diff) | |
download | wpa_supplicant_6-eee21e1de8514a43f3e9089c136e7e27cc27a9fc.tar.gz |
Add SCAN_INTERVAL command and remove system property access
Change-Id: Ia6fcdc44cf65b861d978f851bbe79b09b015d3c2
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r-- | wpa_supplicant/ctrl_iface.c | 14 | ||||
-rw-r--r-- | wpa_supplicant/wpa_cli.c | 23 | ||||
-rw-r--r-- | wpa_supplicant/wpa_supplicant.c | 17 |
3 files changed, 40 insertions, 14 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 687c13d..47c1f95 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -424,6 +424,17 @@ static int wpa_supplicant_ctrl_iface_bssid(struct wpa_supplicant *wpa_s, } #ifdef ANDROID +static int wpa_supplicant_ctrl_iface_scan_interval( + struct wpa_supplicant *wpa_s, char *cmd) +{ + int scan_int = atoi(cmd); + if (scan_int < 0) + return -1; + wpa_s->scan_interval = scan_int; + return 0; +} + + static int wpa_supplicant_ctrl_iface_blacklist( struct wpa_supplicant *wpa_s, char *cmd, char *buf, size_t buflen) { @@ -1737,6 +1748,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, if (wpa_supplicant_ctrl_iface_bssid(wpa_s, buf + 6)) reply_len = -1; #ifdef ANDROID + } else if (os_strncmp(buf, "SCAN_INTERVAL ", 14) == 0) { + reply_len = wpa_supplicant_ctrl_iface_scan_interval( + wpa_s, buf + 14); } else if (os_strncmp(buf, "BLACKLIST", 9) == 0) { reply_len = wpa_supplicant_ctrl_iface_blacklist( wpa_s, buf + 9, reply, reply_size); diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 9748ef4..9d8d8b2 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -748,6 +748,26 @@ static int wpa_cli_cmd_bssid(struct wpa_ctrl *ctrl, int argc, char *argv[]) #ifdef ANDROID +static int wpa_cli_cmd_scan_interval(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + char cmd[256]; + int res; + + if (argc != 1) { + printf("Invalid SCAN_INTERVAL command: needs one argument " + "scan_interval value)\n"); + return -1; + } + res = os_snprintf(cmd, sizeof(cmd), "SCAN_INTERVAL %s", argv[0]); + if (res < 0 || (size_t) res >= sizeof(cmd) - 1) { + printf("Too long SCAN_INTERVAL command.\n"); + return -1; + } + return wpa_ctrl_command(ctrl, cmd); +} + + static int wpa_cli_cmd_blacklist(struct wpa_ctrl *ctrl, int argc, char *argv[]) { char cmd[256], *pos, *end; @@ -1262,6 +1282,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { cli_cmd_flag_none, "<network id> <BSSID> = set preferred BSSID for an SSID" }, #ifdef ANDROID + { "scan_interval", wpa_cli_cmd_scan_interval, + cli_cmd_flag_none, + "<value> = set scan_interval parameter" }, { "blacklist", wpa_cli_cmd_blacklist, cli_cmd_flag_none, "<BSSID> = add a BSSID to the blacklist\n" diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index c90cf41..3a2388a 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -39,9 +39,6 @@ #include "blacklist.h" #include "wpas_glue.h" #include "wps_supplicant.h" -#ifdef ANDROID -#include <cutils/properties.h> -#endif const char *wpa_supplicant_version = "wpa_supplicant v" VERSION_STR "\n" @@ -1733,7 +1730,9 @@ static struct wpa_supplicant * wpa_supplicant_alloc(void) if (wpa_s == NULL) return NULL; wpa_s->scan_req = 1; - +#ifdef ANDROID + wpa_s->scan_interval = 5; +#endif return wpa_s; } @@ -2005,16 +2004,6 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, return NULL; } -#ifdef ANDROID - char scan_prop[PROPERTY_VALUE_MAX]; - char *endp; - if (property_get("wifi.supplicant_scan_interval", scan_prop, "6") != 0) { - wpa_s->scan_interval = (int)strtol(scan_prop, &endp, 0); - if (endp == scan_prop) { - wpa_s->scan_interval = 6; - } - } -#endif wpa_s->next = global->ifaces; global->ifaces = wpa_s; |