int marlin_priv_cmd(struct net_device *ndev, struct ifreq *ifr) { struct wlan_vif_t *vif; struct android_wifi_priv_cmd priv_cmd; char *command = NULL; u8 addr[ETH_ALEN] = {0}; int bytes_written = 0; int ret = 0; vif = ndev_to_vif(ndev); if (!ifr->ifr_data) return -EINVAL; if (copy_from_user(&priv_cmd, ifr->ifr_data, sizeof(struct android_wifi_priv_cmd))) return -EFAULT; command = kmalloc(priv_cmd.total_len, GFP_KERNEL); if (!command) { printke("%s: Failed to allocate command!\n", __func__); return -ENOMEM; } if (copy_from_user(command, priv_cmd.buf, priv_cmd.total_len)) { ret = -EFAULT; goto exit; } if (strnicmp(command, CMD_BLACKLIST_ENABLE, strlen(CMD_BLACKLIST_ENABLE)) == 0) { int skip = strlen(CMD_BLACKLIST_ENABLE) + 1; printke("%s, Received regular blacklist enable command\n", __func__); sscanf(command + skip, "" MACSTR "", STR2MAC(addr)); bytes_written = wlan_cmd_add_blacklist(vif, addr); } else if (strnicmp(command, CMD_BLACKLIST_DISABLE, strlen(CMD_BLACKLIST_DISABLE)) == 0) { int skip = strlen(CMD_BLACKLIST_DISABLE) + 1; printke("%s, Received regular blacklist disable command\n", __func__); sscanf(command + skip, "" MACSTR "", STR2MAC(addr)); bytes_written = wlan_cmd_del_blacklist(vif, addr); } if (bytes_written < 0) ret = bytes_written; exit: kfree(command); return ret; }
int sprdwl_priv_cmd(struct net_device *dev, struct ifreq *ifr) { struct sprdwl_priv *priv = netdev_priv(dev); int ret = 0; char *command = NULL; int bytes_written = 0; struct android_wifi_priv_cmd priv_cmd; u8 addr[6] = {0}; if (!ifr->ifr_data) { ret = -EINVAL; goto exit; } if (copy_from_user(&priv_cmd, ifr->ifr_data, sizeof(struct android_wifi_priv_cmd))) { ret = -EFAULT; goto exit; } command = kmalloc(priv_cmd.total_len, GFP_KERNEL); if (!command) { dev_err(&priv->wdev->netdev->dev, "%s: Failed to allocate command!\n", __func__); ret = -ENOMEM; goto exit; } if (copy_from_user(command, priv_cmd.buf, priv_cmd.total_len)) { ret = -EFAULT; goto exit; } if (strnicmp(command, CMD_BLACKLIST_ENABLE, strlen(CMD_BLACKLIST_ENABLE)) == 0) { int skip = strlen(CMD_BLACKLIST_ENABLE) + 1; dev_err(&priv->wdev->netdev->dev, "%s, Received regular blacklist enable command\n", __func__); sscanf(command + skip, "" MACSTR "", STR2MAC(addr)); bytes_written = sprdwl_set_blacklist_cmd(priv->wlan_sipc, addr, 1); } else if (strnicmp(command, CMD_BLACKLIST_DISABLE, strlen(CMD_BLACKLIST_DISABLE)) == 0) { int skip = strlen(CMD_BLACKLIST_DISABLE) + 1; dev_err(&priv->wdev->netdev->dev, "%s, Received regular blacklist disable command\n", __func__); sscanf(command + skip, "" MACSTR "", STR2MAC(addr)); bytes_written = sprdwl_set_blacklist_cmd(priv->wlan_sipc, addr, 0); } if (bytes_written < 0) ret = bytes_written; exit: kfree(command); return ret; }