Skip to content

Commit

Permalink
nl80211_driver: add private commands to use dropbcast
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Luciano Coelho authored and Eyal Shapira committed Feb 26, 2012
1 parent aaea6d9 commit 9d4ebfb
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/drivers/driver_nl80211.c
Expand Up @@ -7409,6 +7409,62 @@ static int nl80211_set_wowlan_triggers(struct i802_bss *bss, int enable)
return ret;
}

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 < 0) {
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)
Expand Down Expand Up @@ -7595,6 +7651,24 @@ static int nl80211_priv_driver_cmd( void *priv, char *cmd, char *buf, size_t buf
return nl80211_set_wowlan_triggers(bss, 1);
} 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 {
wpa_printf(MSG_ERROR, "Unsupported command: %s", cmd);
ret = -1;
Expand Down

0 comments on commit 9d4ebfb

Please sign in to comment.