diff options
author | Luciano Coelho <coelho@ti.com> | 2012-02-25 00:35:28 +0200 |
---|---|---|
committer | Arik Nemtsov <arik@wizery.com> | 2012-08-02 13:04:00 +0300 |
commit | 3aa26e2f047e4bbbd669d4550d50f2ece76b65b1 (patch) | |
tree | e48076ab77a61d60a0f55bfe08fe32c6f4e54c29 | |
parent | ec19d050266d8aba9c19ea09dd9661b2d7de2bd0 (diff) | |
download | external_wpa_supplicant_8_ti-3aa26e2f047e4bbbd669d4550d50f2ece76b65b1.zip external_wpa_supplicant_8_ti-3aa26e2f047e4bbbd669d4550d50f2ece76b65b1.tar.gz external_wpa_supplicant_8_ti-3aa26e2f047e4bbbd669d4550d50f2ece76b65b1.tar.bz2 |
nl80211_driver: add private commands to use dropbcast
Add DRIVER DROPBCAST {GET,ENABLE,DISABLE} commands to show the current
setting, enable and disable the feature of dropping all broadcast
packets while in suspend mode.
Signed-off-by: Luciano Coelho <coelho@ti.com>
-rw-r--r-- | src/drivers/driver_nl80211.c | 78 |
1 files changed, 76 insertions, 2 deletions
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 5c197f5..a36abfe 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -9181,6 +9181,62 @@ static int nl80211_parse_wowlan_trigger_nr(char *s) return i; } +static int nl80211_toggle_dropbcast(int enable) +{ + char filename[90]; + int rv; + FILE *f; + + snprintf(filename, sizeof(filename) - 1, + "/sys/bus/platform/devices/wl12xx/drop_bcast"); + f = fopen(filename, "w"); + if (!f) { + wpa_printf(MSG_DEBUG, "Could not open file %s: %s", + filename, strerror(errno)); + return -1; + } + + rv = fprintf(f, "%d", enable); + fclose(f); + if (rv < 1) { + wpa_printf(MSG_DEBUG, "Could not write to file %s: %s", + filename, strerror(errno)); + return -1; + } + + return 0; +} + +static int nl80211_dropbcast_get(char *buf, size_t buf_len) +{ + char filename[90], value[10], *pos; + int f, rv; + + snprintf(filename, sizeof(filename) - 1, + "/sys/bus/platform/devices/wl12xx/drop_bcast"); + f = open(filename, O_RDONLY); + if (f < 0) { + wpa_printf(MSG_DEBUG, "Could not open file %s: %s", + filename, strerror(errno)); + return -1; + } + + rv = read(f, value, sizeof(value) - 1); + close(f); + if (rv < 0) { + wpa_printf(MSG_DEBUG, "Could not read file %s: %s", + filename, strerror(errno)); + return -1; + } + + value[rv] = '\0'; + pos = os_strchr(value, '\n'); + if (pos) + *pos = '\0'; + + return snprintf(buf, buf_len, "Drop bcast = %s\n", value); +} + #endif /* ANDROID */ static int nl80211_add_pmkid(void *priv, const u8 *bssid, const u8 *pmkid) @@ -9683,10 +9739,28 @@ static int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf, if(i < 0) return i; return nl80211_toggle_wowlan_trigger(bss, i, 0); - } else if( os_strcasecmp(cmd, "RXFILTER-START") == 0 ) { + } else if (os_strcasecmp(cmd, "RXFILTER-START") == 0) { return nl80211_set_wowlan_triggers(bss, 1); - } else if( os_strcasecmp(cmd, "RXFILTER-STOP") == 0 ) { + } else if (os_strcasecmp(cmd, "RXFILTER-STOP") == 0) { return nl80211_set_wowlan_triggers(bss, 0); + } else if (os_strncasecmp(cmd, "DROPBCAST", 9) == 0) { + char *value = cmd + 10; + + if (!os_strcasecmp(value, "ENABLE") || + !os_strcasecmp(value, "1")) { + ret = nl80211_toggle_dropbcast(1); + } else if (!os_strcasecmp(value, "DISABLE") || + !os_strcasecmp(value, "0")) { + ret = nl80211_toggle_dropbcast(0); + } else if (!os_strcasecmp(value, "GET") || + !os_strlen(value)) { + ret = nl80211_dropbcast_get(buf, buf_len); + } else { + wpa_printf(MSG_ERROR, + "Invalid parameter for DROPBCAST: %s", + value); + ret = -1; + } } else if( os_strcasecmp(cmd, "LINKSPEED") == 0 ) { struct wpa_signal_info sig; int linkspeed; |