Commit f85ac230 authored by Teo Dacquet's avatar Teo Dacquet Committed by Greg Kroah-Hartman

rtl8723bs: os_dep: ioctl_linux: fix several braces coding style issues.

Fix checkpatch issues:
ERROR: that open brace { should be on the previous line.
WARNING: braces {} are not necessary for single statement blocks.
Signed-off-by: default avatarTeo Dacquet <teo.dacquet@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 05031914
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <rtw_mp.h> #include <rtw_mp.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV+30)
#define SCAN_ITEM_SIZE 768 #define SCAN_ITEM_SIZE 768
#define MAX_CUSTOM_LEN 64 #define MAX_CUSTOM_LEN 64
...@@ -44,8 +44,7 @@ extern u8 key_2char2num(u8 hch, u8 lch); ...@@ -44,8 +44,7 @@ extern u8 key_2char2num(u8 hch, u8 lch);
static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000,
6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000};
static const char * const iw_operation_mode[] = static const char * const iw_operation_mode[] = {
{
"Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor" "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor"
}; };
...@@ -190,16 +189,12 @@ static char *translate_scan(struct adapter *padapter, ...@@ -190,16 +189,12 @@ static char *translate_scan(struct adapter *padapter,
start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid);
/* parsing HT_CAP_IE */ /* parsing HT_CAP_IE */
if (pnetwork->network.Reserved[0] == 2) /* Probe Request */ if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */
{
p = rtw_get_ie(&pnetwork->network.IEs[0], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength); p = rtw_get_ie(&pnetwork->network.IEs[0], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength);
} } else {
else
{
p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12);
} }
if (p && ht_ielen>0) if (p && ht_ielen>0) {
{
struct rtw_ieee80211_ht_cap *pht_capie; struct rtw_ieee80211_ht_cap *pht_capie;
ht_cap = true; ht_cap = true;
pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2);
...@@ -210,33 +205,25 @@ static char *translate_scan(struct adapter *padapter, ...@@ -210,33 +205,25 @@ static char *translate_scan(struct adapter *padapter,
/* Add the protocol name */ /* Add the protocol name */
iwe.cmd = SIOCGIWNAME; iwe.cmd = SIOCGIWNAME;
if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates)) == true) if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates)) == true) {
{
if (ht_cap == true) if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
else else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
} } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates)) == true) {
else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates)) == true)
{
if (ht_cap == true) if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
else else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg");
} } else {
else if (pnetwork->network.Configuration.DSConfig > 14) {
{
if (pnetwork->network.Configuration.DSConfig > 14)
{
if (vht_cap == true) if (vht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11AC"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11AC");
else if (ht_cap == true) else if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an");
else else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a");
} } else {
else
{
if (ht_cap == true) if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
else else
...@@ -247,12 +234,9 @@ static char *translate_scan(struct adapter *padapter, ...@@ -247,12 +234,9 @@ static char *translate_scan(struct adapter *padapter,
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
/* Add mode */ /* Add mode */
if (pnetwork->network.Reserved[0] == 2) /* Probe Request */ if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */
{
cap = 0; cap = 0;
} } else {
else
{
__le16 le_tmp; __le16 le_tmp;
iwe.cmd = SIOCGIWMODE; iwe.cmd = SIOCGIWMODE;
...@@ -295,8 +279,7 @@ static char *translate_scan(struct adapter *padapter, ...@@ -295,8 +279,7 @@ static char *translate_scan(struct adapter *padapter,
return start; return start;
p = custom; p = custom;
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
while (pnetwork->network.SupportedRates[i]!= 0) while (pnetwork->network.SupportedRates[i]!= 0) {
{
rate = pnetwork->network.SupportedRates[i]&0x7F; rate = pnetwork->network.SupportedRates[i]&0x7F;
if (rate > max_rate) if (rate > max_rate)
max_rate = rate; max_rate = rate;
...@@ -307,20 +290,12 @@ static char *translate_scan(struct adapter *padapter, ...@@ -307,20 +290,12 @@ static char *translate_scan(struct adapter *padapter,
if (vht_cap == true) { if (vht_cap == true) {
max_rate = vht_data_rate; max_rate = vht_data_rate;
} } else if (ht_cap == true) {
else if (ht_cap == true) if (mcs_rate&0x8000) { /* MCS15 */
{
if (mcs_rate&0x8000)/* MCS15 */
{
max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130);
} else if (mcs_rate&0x0080) { /* MCS7 */
}
else if (mcs_rate&0x0080)/* MCS7 */
{
max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65);
} } else { /* default MCS7 */
else/* default MCS7 */
{
/* DBG_871X("wx_get_scan, mcs_rate_bitmap = 0x%x\n", mcs_rate); */ /* DBG_871X("wx_get_scan, mcs_rate_bitmap = 0x%x\n", mcs_rate); */
max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65);
} }
...@@ -334,8 +309,7 @@ static char *translate_scan(struct adapter *padapter, ...@@ -334,8 +309,7 @@ static char *translate_scan(struct adapter *padapter,
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN);
/* parsing WPA/WPA2 IE */ /* parsing WPA/WPA2 IE */
if (pnetwork->network.Reserved[0] != 2) /* Probe Request */ if (pnetwork->network.Reserved[0] != 2) { /* Probe Request */
{
u8 *buf; u8 *buf;
u8 wpa_ie[255], rsn_ie[255]; u8 wpa_ie[255], rsn_ie[255];
u16 wpa_len = 0, rsn_len = 0; u16 wpa_len = 0, rsn_len = 0;
...@@ -351,15 +325,13 @@ static char *translate_scan(struct adapter *padapter, ...@@ -351,15 +325,13 @@ static char *translate_scan(struct adapter *padapter,
if (wpa_len > 0) { if (wpa_len > 0) {
p =buf; p =buf;
p += sprintf(p, "wpa_ie ="); p += sprintf(p, "wpa_ie =");
for (i = 0; i < wpa_len; i++) { for (i = 0; i < wpa_len; i++)
p += sprintf(p, "%02x", wpa_ie[i]); p += sprintf(p, "%02x", wpa_ie[i]);
}
if (wpa_len > 100) { if (wpa_len > 100) {
printk("-----------------Len %d----------------\n", wpa_len); printk("-----------------Len %d----------------\n", wpa_len);
for (i = 0; i < wpa_len; i++) { for (i = 0; i < wpa_len; i++)
printk("%02x ", wpa_ie[i]); printk("%02x ", wpa_ie[i]);
}
printk("\n"); printk("\n");
printk("-----------------Len %d----------------\n", wpa_len); printk("-----------------Len %d----------------\n", wpa_len);
} }
...@@ -401,21 +373,16 @@ static char *translate_scan(struct adapter *padapter, ...@@ -401,21 +373,16 @@ static char *translate_scan(struct adapter *padapter,
u8 *ie_ptr = pnetwork->network.IEs + ie_offset; u8 *ie_ptr = pnetwork->network.IEs + ie_offset;
total_ielen = pnetwork->network.IELength - ie_offset; total_ielen = pnetwork->network.IELength - ie_offset;
if (pnetwork->network.Reserved[0] == 2) /* Probe Request */ if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */
{
ie_ptr = pnetwork->network.IEs; ie_ptr = pnetwork->network.IEs;
total_ielen = pnetwork->network.IELength; total_ielen = pnetwork->network.IELength;
} } else { /* Beacon or Probe Respones */
else /* Beacon or Probe Respones */
{
ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_; ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_;
total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_; total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_;
} }
while (cnt < total_ielen) while (cnt < total_ielen) {
{ if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen>2)) {
if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen>2))
{
wpsie_ptr = &ie_ptr[cnt]; wpsie_ptr = &ie_ptr[cnt];
iwe.cmd =IWEVGENIE; iwe.cmd =IWEVGENIE;
iwe.u.data.length = (u16)wps_ielen; iwe.u.data.length = (u16)wps_ielen;
...@@ -507,38 +474,27 @@ static int wpa_set_auth_algs(struct net_device *dev, u32 value) ...@@ -507,38 +474,27 @@ static int wpa_set_auth_algs(struct net_device *dev, u32 value)
struct adapter *padapter = (struct adapter *) rtw_netdev_priv(dev); struct adapter *padapter = (struct adapter *) rtw_netdev_priv(dev);
int ret = 0; int ret = 0;
if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) {
{
DBG_871X("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n", value); DBG_871X("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n", value);
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch;
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto;
} } else if (value & AUTH_ALG_SHARED_KEY) {
else if (value & AUTH_ALG_SHARED_KEY)
{
DBG_871X("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n", value); DBG_871X("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n", value);
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared;
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared;
} } else if (value & AUTH_ALG_OPEN_SYSTEM) {
else if (value & AUTH_ALG_OPEN_SYSTEM)
{
DBG_871X("wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM\n"); DBG_871X("wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM\n");
/* padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; */ /* padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; */
if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) {
{
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
} }
} else if (value & AUTH_ALG_LEAP) {
}
else if (value & AUTH_ALG_LEAP)
{
DBG_871X("wpa_set_auth_algs, AUTH_ALG_LEAP\n"); DBG_871X("wpa_set_auth_algs, AUTH_ALG_LEAP\n");
} } else {
else
{
DBG_871X("wpa_set_auth_algs, error!\n"); DBG_871X("wpa_set_auth_algs, error!\n");
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -559,33 +515,27 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -559,33 +515,27 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
param->u.crypt.err = 0; param->u.crypt.err = 0;
param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
if (param_len < (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) if (param_len < (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) {
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
{
if (param->u.crypt.idx >= WEP_KEYS || if (param->u.crypt.idx >= WEP_KEYS ||
param->u.crypt.idx >= BIP_MAX_KEYID) { param->u.crypt.idx >= BIP_MAX_KEYID) {
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
} } else {
else
{
{ {
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
} }
if (strcmp(param->u.crypt.alg, "WEP") == 0) if (strcmp(param->u.crypt.alg, "WEP") == 0) {
{
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n")); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n"));
DBG_871X("wpa_set_encryption, crypt.alg = WEP\n"); DBG_871X("wpa_set_encryption, crypt.alg = WEP\n");
...@@ -604,8 +554,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -604,8 +554,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx)); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx));
if (wep_key_len > 0) if (wep_key_len > 0) {
{
wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_key_len = wep_key_len <= 5 ? 5 : 13;
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len); pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len);
...@@ -619,13 +568,11 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -619,13 +568,11 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
pwep->KeyLength = wep_key_len; pwep->KeyLength = wep_key_len;
pwep->Length = wep_total_len; pwep->Length = wep_total_len;
if (wep_key_len == 13) if (wep_key_len == 13) {
{
padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_;
padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_;
} }
} } else {
else {
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
...@@ -635,17 +582,12 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -635,17 +582,12 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
if (param->u.crypt.set_tx) if (param->u.crypt.set_tx) {
{
DBG_871X("wep, set_tx = 1\n"); DBG_871X("wep, set_tx = 1\n");
if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL)
{
ret = -EOPNOTSUPP ; ret = -EOPNOTSUPP ;
} } else {
}
else
{
DBG_871X("wep, set_tx = 0\n"); DBG_871X("wep, set_tx = 0\n");
/* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */
...@@ -664,35 +606,28 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -664,35 +606,28 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
goto exit; goto exit;
} }
if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) /* 802_1x */ if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802_1x */
{
struct sta_info * psta,*pbcmc_sta; struct sta_info * psta,*pbcmc_sta;
struct sta_priv * pstapriv = &padapter->stapriv; struct sta_priv * pstapriv = &padapter->stapriv;
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE) == true) /* sta mode */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE) == true) { /* sta mode */
{
psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
if (psta == NULL) { if (psta == NULL) {
/* DEBUG_ERR(("Set wpa_set_encryption: Obtain Sta_info fail\n")); */ /* DEBUG_ERR(("Set wpa_set_encryption: Obtain Sta_info fail\n")); */
} } else {
else
{
/* Jeff: don't disable ieee8021x_blocked while clearing key */ /* Jeff: don't disable ieee8021x_blocked while clearing key */
if (strcmp(param->u.crypt.alg, "none") != 0) if (strcmp(param->u.crypt.alg, "none") != 0)
psta->ieee8021x_blocked = false; psta->ieee8021x_blocked = false;
if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)|| if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)||
(padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) {
{
psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
} }
if (param->u.crypt.set_tx == 1)/* pairwise key */ if (param->u.crypt.set_tx == 1) { /* pairwise key */
{
memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
if (strcmp(param->u.crypt.alg, "TKIP") == 0)/* set mic key */ if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */
{
/* DEBUG_ERR(("\nset key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len)); */ /* DEBUG_ERR(("\nset key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len)); */
memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8);
memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8);
...@@ -705,15 +640,11 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -705,15 +640,11 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
DBG_871X(" ~~~~set sta key:unicastkey\n"); DBG_871X(" ~~~~set sta key:unicastkey\n");
rtw_setstakey_cmd(padapter, psta, true, true); rtw_setstakey_cmd(padapter, psta, true, true);
} } else { /* group key */
else/* group key */ if (strcmp(param->u.crypt.alg, "TKIP") == 0 || strcmp(param->u.crypt.alg, "CCMP") == 0) {
{
if (strcmp(param->u.crypt.alg, "TKIP") == 0 || strcmp(param->u.crypt.alg, "CCMP") == 0)
{
memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
/* only TKIP group key need to install this */ /* only TKIP group key need to install this */
if (param->u.crypt.key_len > 16) if (param->u.crypt.key_len > 16) {
{
memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[16]), 8); memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[16]), 8);
memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[24]), 8); memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[24]), 8);
} }
...@@ -724,9 +655,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -724,9 +655,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx;
rtw_set_key(padapter,&padapter->securitypriv, param->u.crypt.idx, 1, true); rtw_set_key(padapter,&padapter->securitypriv, param->u.crypt.idx, 1, true);
} } else if (strcmp(param->u.crypt.alg, "BIP") == 0) {
else if (strcmp(param->u.crypt.alg, "BIP") == 0)
{
/* printk("BIP key_len =%d , index =%d @@@@@@@@@@@@@@@@@@\n", param->u.crypt.key_len, param->u.crypt.idx); */ /* printk("BIP key_len =%d , index =%d @@@@@@@@@@@@@@@@@@\n", param->u.crypt.key_len, param->u.crypt.idx); */
/* save the IGTK key, length 16 bytes */ /* save the IGTK key, length 16 bytes */
memcpy(padapter->securitypriv.dot11wBIPKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(padapter->securitypriv.dot11wBIPKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
...@@ -742,25 +671,20 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -742,25 +671,20 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
} }
pbcmc_sta =rtw_get_bcmc_stainfo(padapter); pbcmc_sta =rtw_get_bcmc_stainfo(padapter);
if (pbcmc_sta == NULL) if (pbcmc_sta == NULL) {
{
/* DEBUG_ERR(("Set OID_802_11_ADD_KEY: bcmc stainfo is null\n")); */ /* DEBUG_ERR(("Set OID_802_11_ADD_KEY: bcmc stainfo is null\n")); */
} } else {
else
{
/* Jeff: don't disable ieee8021x_blocked while clearing key */ /* Jeff: don't disable ieee8021x_blocked while clearing key */
if (strcmp(param->u.crypt.alg, "none") != 0) if (strcmp(param->u.crypt.alg, "none") != 0)
pbcmc_sta->ieee8021x_blocked = false; pbcmc_sta->ieee8021x_blocked = false;
if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)|| if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)||
(padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) {
{
pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
} }
} }
} } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) /* adhoc mode */ /* adhoc mode */
{
} }
} }
...@@ -785,8 +709,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie ...@@ -785,8 +709,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
return -EINVAL; return -EINVAL;
} }
if (ielen) if (ielen) {
{
buf = rtw_zmalloc(ielen); buf = rtw_zmalloc(ielen);
if (buf == NULL) { if (buf == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -810,31 +733,24 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie ...@@ -810,31 +733,24 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
goto exit; goto exit;
} }
if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
{
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
padapter->securitypriv.ndisauthtype =Ndis802_11AuthModeWPAPSK; padapter->securitypriv.ndisauthtype =Ndis802_11AuthModeWPAPSK;
memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen);
} }
if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) {
{
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
padapter->securitypriv.ndisauthtype =Ndis802_11AuthModeWPA2PSK; padapter->securitypriv.ndisauthtype =Ndis802_11AuthModeWPA2PSK;
memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen);
} }
if (group_cipher == 0) if (group_cipher == 0)
{
group_cipher = WPA_CIPHER_NONE; group_cipher = WPA_CIPHER_NONE;
}
if (pairwise_cipher == 0) if (pairwise_cipher == 0)
{
pairwise_cipher = WPA_CIPHER_NONE; pairwise_cipher = WPA_CIPHER_NONE;
}
switch (group_cipher) switch (group_cipher) {
{
case WPA_CIPHER_NONE: case WPA_CIPHER_NONE:
padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
padapter->securitypriv.ndisencryptstatus =Ndis802_11EncryptionDisabled; padapter->securitypriv.ndisencryptstatus =Ndis802_11EncryptionDisabled;
...@@ -857,8 +773,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie ...@@ -857,8 +773,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
break; break;
} }
switch (pairwise_cipher) switch (pairwise_cipher) {
{
case WPA_CIPHER_NONE: case WPA_CIPHER_NONE:
padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
padapter->securitypriv.ndisencryptstatus =Ndis802_11EncryptionDisabled; padapter->securitypriv.ndisencryptstatus =Ndis802_11EncryptionDisabled;
...@@ -886,12 +801,10 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie ...@@ -886,12 +801,10 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
u16 cnt = 0; u16 cnt = 0;
u8 eid, wps_oui[4]={0x0, 0x50, 0xf2, 0x04}; u8 eid, wps_oui[4]={0x0, 0x50, 0xf2, 0x04};
while (cnt < ielen) while (cnt < ielen) {
{
eid = buf[cnt]; eid = buf[cnt];
if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) {
{
DBG_871X("SET WPS_IE\n"); DBG_871X("SET WPS_IE\n");
padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < MAX_WPS_IE_LEN) ? (buf[cnt+1]+2):MAX_WPS_IE_LEN; padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < MAX_WPS_IE_LEN) ? (buf[cnt+1]+2):MAX_WPS_IE_LEN;
...@@ -947,48 +860,36 @@ static int rtw_wx_get_name(struct net_device *dev, ...@@ -947,48 +860,36 @@ static int rtw_wx_get_name(struct net_device *dev,
/* parsing HT_CAP_IE */ /* parsing HT_CAP_IE */
p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12);
if (p && ht_ielen>0) if (p && ht_ielen>0)
{
ht_cap = true; ht_cap = true;
}
prates = &pcur_bss->SupportedRates; prates = &pcur_bss->SupportedRates;
if (rtw_is_cckratesonly_included((u8 *)prates) == true) if (rtw_is_cckratesonly_included((u8 *)prates) == true) {
{
if (ht_cap == true) if (ht_cap == true)
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn");
else else
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b");
} } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) {
else if ((rtw_is_cckrates_included((u8 *)prates)) == true)
{
if (ht_cap == true) if (ht_cap == true)
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn");
else else
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg");
} } else {
else if (pcur_bss->Configuration.DSConfig > 14) {
{
if (pcur_bss->Configuration.DSConfig > 14)
{
if (vht_cap == true) if (vht_cap == true)
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11AC"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11AC");
else if (ht_cap == true) else if (ht_cap == true)
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an");
else else
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a");
} } else {
else
{
if (ht_cap == true) if (ht_cap == true)
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn");
else else
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g");
} }
} }
} } else {
else
{
/* prates = &padapter->registrypriv.dev_network.SupportedRates; */ /* prates = &padapter->registrypriv.dev_network.SupportedRates; */
/* snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); */ /* snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); */
snprintf(wrqu->name, IFNAMSIZ, "unassociated"); snprintf(wrqu->name, IFNAMSIZ, "unassociated");
...@@ -1013,15 +914,13 @@ static int rtw_wx_get_freq(struct net_device *dev, ...@@ -1013,15 +914,13 @@ static int rtw_wx_get_freq(struct net_device *dev,
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
{
/* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */ /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */
wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000; wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000;
wrqu->freq.e = 1; wrqu->freq.e = 1;
wrqu->freq.i = pcur_bss->Configuration.DSConfig; wrqu->freq.i = pcur_bss->Configuration.DSConfig;
} } else {
else {
wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000;
wrqu->freq.e = 1; wrqu->freq.e = 1;
wrqu->freq.i = padapter->mlmeextpriv.cur_channel; wrqu->freq.i = padapter->mlmeextpriv.cur_channel;
...@@ -1047,8 +946,7 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, ...@@ -1047,8 +946,7 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
goto exit; goto exit;
} }
switch (wrqu->mode) switch (wrqu->mode) {
{
case IW_MODE_AUTO: case IW_MODE_AUTO:
networkType = Ndis802_11AutoUnknown; networkType = Ndis802_11AutoUnknown;
DBG_871X("set_mode = IW_MODE_AUTO\n"); DBG_871X("set_mode = IW_MODE_AUTO\n");
...@@ -1105,22 +1003,14 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, ...@@ -1105,22 +1003,14 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n"));
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
{
wrqu->mode = IW_MODE_INFRA; wrqu->mode = IW_MODE_INFRA;
} } else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true))
{
wrqu->mode = IW_MODE_ADHOC; wrqu->mode = IW_MODE_ADHOC;
} } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
{
wrqu->mode = IW_MODE_MASTER; wrqu->mode = IW_MODE_MASTER;
} } else {
else
{
wrqu->mode = IW_MODE_AUTO; wrqu->mode = IW_MODE_AUTO;
} }
return 0; return 0;
...@@ -1147,25 +1037,19 @@ static int rtw_wx_set_pmkid(struct net_device *dev, ...@@ -1147,25 +1037,19 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
*/ */
memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN);
if (pPMK->cmd == IW_PMKSA_ADD) if (pPMK->cmd == IW_PMKSA_ADD) {
{
DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n"); DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n");
if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN)) if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN))
{
return(intReturn); return(intReturn);
}
else else
{
intReturn = true; intReturn = true;
}
blInserted = false; blInserted = false;
/* overwrite PMKID */ /* overwrite PMKID */
for (j = 0 ; j<NUM_PMKID_CACHE; j++) for (j = 0 ; j<NUM_PMKID_CACHE; j++) {
{ if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) /* BSSID is matched, the same AP => rewrite with new PMKID. */
{ /* BSSID is matched, the same AP => rewrite with new PMKID. */
DBG_871X("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); DBG_871X("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n");
memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN);
...@@ -1176,8 +1060,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev, ...@@ -1176,8 +1060,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
} }
} }
if (!blInserted) if (!blInserted) {
{
/* Find a new entry */ /* Find a new entry */
DBG_871X("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n", DBG_871X("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n",
psecuritypriv->PMKIDIndex); psecuritypriv->PMKIDIndex);
...@@ -1188,27 +1071,20 @@ static int rtw_wx_set_pmkid(struct net_device *dev, ...@@ -1188,27 +1071,20 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
psecuritypriv->PMKIDList[ psecuritypriv->PMKIDIndex ].bUsed = true; psecuritypriv->PMKIDList[ psecuritypriv->PMKIDIndex ].bUsed = true;
psecuritypriv->PMKIDIndex++ ; psecuritypriv->PMKIDIndex++ ;
if (psecuritypriv->PMKIDIndex == 16) if (psecuritypriv->PMKIDIndex == 16)
{
psecuritypriv->PMKIDIndex = 0; psecuritypriv->PMKIDIndex = 0;
}
} }
} } else if (pPMK->cmd == IW_PMKSA_REMOVE) {
else if (pPMK->cmd == IW_PMKSA_REMOVE)
{
DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n");
intReturn = true; intReturn = true;
for (j = 0 ; j<NUM_PMKID_CACHE; j++) for (j = 0 ; j<NUM_PMKID_CACHE; j++) {
{ if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */
{ /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */
memset(psecuritypriv->PMKIDList[ j ].Bssid, 0x00, ETH_ALEN); memset(psecuritypriv->PMKIDList[ j ].Bssid, 0x00, ETH_ALEN);
psecuritypriv->PMKIDList[ j ].bUsed = false; psecuritypriv->PMKIDList[ j ].bUsed = false;
break; break;
} }
} }
} } else if (pPMK->cmd == IW_PMKSA_FLUSH) {
else if (pPMK->cmd == IW_PMKSA_FLUSH)
{
DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n");
memset(&psecuritypriv->PMKIDList[ 0 ], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE); memset(&psecuritypriv->PMKIDList[ 0 ], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
psecuritypriv->PMKIDIndex = 0; psecuritypriv->PMKIDIndex = 0;
...@@ -1273,9 +1149,8 @@ static int rtw_wx_get_range(struct net_device *dev, ...@@ -1273,9 +1149,8 @@ static int rtw_wx_get_range(struct net_device *dev,
range->num_bitrates = RATE_COUNT; range->num_bitrates = RATE_COUNT;
for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++)
range->bitrate[i] = rtw_rates[i]; range->bitrate[i] = rtw_rates[i];
}
range->min_frag = MIN_FRAG_THRESHOLD; range->min_frag = MIN_FRAG_THRESHOLD;
range->max_frag = MAX_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD;
...@@ -1288,8 +1163,7 @@ static int rtw_wx_get_range(struct net_device *dev, ...@@ -1288,8 +1163,7 @@ static int rtw_wx_get_range(struct net_device *dev,
for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) { for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) {
/* Include only legal frequencies for some countries */ /* Include only legal frequencies for some countries */
if (pmlmeext->channel_set[i].ChannelNum != 0) if (pmlmeext->channel_set[i].ChannelNum != 0) {
{
range->freq[val].i = pmlmeext->channel_set[i].ChannelNum; range->freq[val].i = pmlmeext->channel_set[i].ChannelNum;
range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000; range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000;
range->freq[val].e = 1; range->freq[val].e = 1;
...@@ -1349,8 +1223,7 @@ static int rtw_wx_set_wap(struct net_device *dev, ...@@ -1349,8 +1223,7 @@ static int rtw_wx_set_wap(struct net_device *dev,
enum NDIS_802_11_AUTHENTICATION_MODE authmode; enum NDIS_802_11_AUTHENTICATION_MODE authmode;
rtw_ps_deny(padapter, PS_DENY_JOIN); rtw_ps_deny(padapter, PS_DENY_JOIN);
if (_FAIL == rtw_pwr_wakeup(padapter)) if (_FAIL == rtw_pwr_wakeup(padapter)) {
{
ret = -1; ret = -1;
goto exit; goto exit;
} }
...@@ -1383,15 +1256,12 @@ static int rtw_wx_set_wap(struct net_device *dev, ...@@ -1383,15 +1256,12 @@ static int rtw_wx_set_wap(struct net_device *dev,
src_bssid = temp->sa_data; src_bssid = temp->sa_data;
if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) {
{ if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) {
if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode))
{
ret = -1; ret = -1;
spin_unlock_bh(&queue->lock); spin_unlock_bh(&queue->lock);
goto exit; goto exit;
} }
break; break;
} }
...@@ -1429,13 +1299,9 @@ static int rtw_wx_get_wap(struct net_device *dev, ...@@ -1429,13 +1299,9 @@ static int rtw_wx_get_wap(struct net_device *dev,
if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) ||
((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) ||
((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) {
{
memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
} } else {
else
{
memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
} }
...@@ -1461,8 +1327,7 @@ static int rtw_wx_set_mlme(struct net_device *dev, ...@@ -1461,8 +1327,7 @@ static int rtw_wx_set_mlme(struct net_device *dev,
DBG_871X("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason); DBG_871X("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason);
switch (mlme->cmd) switch (mlme->cmd) {
{
case IW_MLME_DEAUTH: case IW_MLME_DEAUTH:
if (!rtw_set_802_11_disassociate(padapter)) if (!rtw_set_802_11_disassociate(padapter))
ret = -1; ret = -1;
...@@ -1493,8 +1358,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, ...@@ -1493,8 +1358,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
#endif #endif
rtw_ps_deny(padapter, PS_DENY_SCAN); rtw_ps_deny(padapter, PS_DENY_SCAN);
if (_FAIL == rtw_pwr_wakeup(padapter)) if (_FAIL == rtw_pwr_wakeup(padapter)) {
{
ret = -1; ret = -1;
goto exit; goto exit;
} }
...@@ -1518,26 +1382,22 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, ...@@ -1518,26 +1382,22 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
/* When Busy Traffic, driver do not site survey. So driver return success. */ /* When Busy Traffic, driver do not site survey. So driver return success. */
/* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */ /* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */
/* modify by thomas 2011-02-22. */ /* modify by thomas 2011-02-22. */
if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) {
{
indicate_wx_scan_complete_event(padapter); indicate_wx_scan_complete_event(padapter);
goto exit; goto exit;
} }
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) {
{
indicate_wx_scan_complete_event(padapter); indicate_wx_scan_complete_event(padapter);
goto exit; goto exit;
} }
memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT);
if (wrqu->data.length == sizeof(struct iw_scan_req)) if (wrqu->data.length == sizeof(struct iw_scan_req)) {
{
struct iw_scan_req *req = (struct iw_scan_req *)extra; struct iw_scan_req *req = (struct iw_scan_req *)extra;
if (wrqu->data.flags & IW_SCAN_THIS_ESSID) if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
{
int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE);
memcpy(ssid[0].Ssid, req->essid, len); memcpy(ssid[0].Ssid, req->essid, len);
...@@ -1551,17 +1411,12 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, ...@@ -1551,17 +1411,12 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
spin_unlock_bh(&pmlmepriv->lock); spin_unlock_bh(&pmlmepriv->lock);
} } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) {
else if (req->scan_type == IW_SCAN_TYPE_PASSIVE)
{
DBG_871X("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n"); DBG_871X("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n");
} }
} } else if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE
else if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) {
&& !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)
)
{
int len = wrqu->data.length -WEXT_CSCAN_HEADER_SIZE; int len = wrqu->data.length -WEXT_CSCAN_HEADER_SIZE;
char *pos = extra+WEXT_CSCAN_HEADER_SIZE; char *pos = extra+WEXT_CSCAN_HEADER_SIZE;
char section; char section;
...@@ -1626,9 +1481,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, ...@@ -1626,9 +1481,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
/* jeff: it has still some scan paramater to parse, we only do this now... */ /* jeff: it has still some scan paramater to parse, we only do this now... */
_status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT); _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT);
} else } else {
{
_status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0);
} }
...@@ -1666,8 +1519,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, ...@@ -1666,8 +1519,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
DBG_871X("DBG_IOCTL %s:%d\n", __func__, __LINE__); DBG_871X("DBG_IOCTL %s:%d\n", __func__, __LINE__);
#endif #endif
if (adapter_to_pwrctl(padapter)->brfoffbyhw && padapter->bDriverStopped) if (adapter_to_pwrctl(padapter)->brfoffbyhw && padapter->bDriverStopped) {
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
...@@ -1682,8 +1534,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, ...@@ -1682,8 +1534,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
phead = get_list_head(queue); phead = get_list_head(queue);
plist = get_next(phead); plist = get_next(phead);
while (1) while (1) {
{
if (phead == plist) if (phead == plist)
break; break;
...@@ -1697,9 +1548,8 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, ...@@ -1697,9 +1548,8 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
/* report network only if the current channel set contains the channel to which this network belongs */ /* report network only if the current channel set contains the channel to which this network belongs */
if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0 if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0
&& rtw_mlme_band_check(padapter, pnetwork->network.Configuration.DSConfig) == true && rtw_mlme_band_check(padapter, pnetwork->network.Configuration.DSConfig) == true
&& true == rtw_validate_ssid(&(pnetwork->network.Ssid)) && true == rtw_validate_ssid(&(pnetwork->network.Ssid))) {
)
{
ev =translate_scan(padapter, a, pnetwork, ev, stop); ev =translate_scan(padapter, a, pnetwork, ev, stop);
} }
...@@ -1750,8 +1600,7 @@ static int rtw_wx_set_essid(struct net_device *dev, ...@@ -1750,8 +1600,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv)));
rtw_ps_deny(padapter, PS_DENY_JOIN); rtw_ps_deny(padapter, PS_DENY_JOIN);
if (_FAIL == rtw_pwr_wakeup(padapter)) if (_FAIL == rtw_pwr_wakeup(padapter)) {
{
ret = -1; ret = -1;
goto exit; goto exit;
} }
...@@ -1773,8 +1622,7 @@ static int rtw_wx_set_essid(struct net_device *dev, ...@@ -1773,8 +1622,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
authmode = padapter->securitypriv.ndisauthtype; authmode = padapter->securitypriv.ndisauthtype;
DBG_871X("=>%s\n", __func__); DBG_871X("=>%s\n", __func__);
if (wrqu->essid.flags && wrqu->essid.length) if (wrqu->essid.flags && wrqu->essid.length) {
{
len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE;
if (wrqu->essid.length != 33) if (wrqu->essid.length != 33)
...@@ -1791,8 +1639,7 @@ static int rtw_wx_set_essid(struct net_device *dev, ...@@ -1791,8 +1639,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
pmlmepriv->pscanned = get_next(phead); pmlmepriv->pscanned = get_next(phead);
while (1) { while (1) {
if (phead == pmlmepriv->pscanned) if (phead == pmlmepriv->pscanned) {
{
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_, RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_,
("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n")); ("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n"));
...@@ -1810,19 +1657,16 @@ static int rtw_wx_set_essid(struct net_device *dev, ...@@ -1810,19 +1657,16 @@ static int rtw_wx_set_essid(struct net_device *dev,
pnetwork->network.Ssid.Ssid)); pnetwork->network.Ssid.Ssid));
if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) &&
(pnetwork->network.Ssid.SsidLength ==ndis_ssid.SsidLength)) (pnetwork->network.Ssid.SsidLength ==ndis_ssid.SsidLength)) {
{
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
("rtw_wx_set_essid: find match, set infra mode\n")); ("rtw_wx_set_essid: find match, set infra mode\n"));
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) {
{
if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
continue; continue;
} }
if (rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode) == false) if (rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode) == false) {
{
ret = -1; ret = -1;
spin_unlock_bh(&queue->lock); spin_unlock_bh(&queue->lock);
goto exit; goto exit;
...@@ -1867,8 +1711,7 @@ static int rtw_wx_get_essid(struct net_device *dev, ...@@ -1867,8 +1711,7 @@ static int rtw_wx_get_essid(struct net_device *dev,
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n"));
if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
{
len = pcur_bss->Ssid.SsidLength; len = pcur_bss->Ssid.SsidLength;
wrqu->essid.length = len; wrqu->essid.length = len;
...@@ -1876,9 +1719,7 @@ static int rtw_wx_get_essid(struct net_device *dev, ...@@ -1876,9 +1719,7 @@ static int rtw_wx_get_essid(struct net_device *dev,
memcpy(extra, pcur_bss->Ssid.Ssid, len); memcpy(extra, pcur_bss->Ssid.Ssid, len);
wrqu->essid.flags = 1; wrqu->essid.flags = 1;
} } else {
else
{
ret = -1; ret = -1;
goto exit; goto exit;
} }
...@@ -1952,15 +1793,12 @@ static int rtw_wx_set_rate(struct net_device *dev, ...@@ -1952,15 +1793,12 @@ static int rtw_wx_set_rate(struct net_device *dev,
set_rate: set_rate:
for (i = 0; i<NumRates; i++) for (i = 0; i<NumRates; i++) {
{ if (ratevalue ==mpdatarate[i]) {
if (ratevalue ==mpdatarate[i])
{
datarates[i] = mpdatarate[i]; datarates[i] = mpdatarate[i];
if (fixed == 0) if (fixed == 0)
break; break;
} } else {
else {
datarates[i] = 0xff; datarates[i] = 0xff;
} }
...@@ -2097,8 +1935,7 @@ static int rtw_wx_set_enc(struct net_device *dev, ...@@ -2097,8 +1935,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
key = erq->flags & IW_ENCODE_INDEX; key = erq->flags & IW_ENCODE_INDEX;
if (erq->flags & IW_ENCODE_DISABLED) if (erq->flags & IW_ENCODE_DISABLED) {
{
DBG_871X("EncryptionDisabled\n"); DBG_871X("EncryptionDisabled\n");
padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
...@@ -2115,17 +1952,14 @@ static int rtw_wx_set_enc(struct net_device *dev, ...@@ -2115,17 +1952,14 @@ static int rtw_wx_set_enc(struct net_device *dev,
return -EINVAL; return -EINVAL;
key--; key--;
keyindex_provided = 1; keyindex_provided = 1;
} } else {
else
{
keyindex_provided = 0; keyindex_provided = 0;
key = padapter->securitypriv.dot11PrivacyKeyIndex; key = padapter->securitypriv.dot11PrivacyKeyIndex;
DBG_871X("rtw_wx_set_enc, key =%d\n", key); DBG_871X("rtw_wx_set_enc, key =%d\n", key);
} }
/* set authentication mode */ /* set authentication mode */
if (erq->flags & IW_ENCODE_OPEN) if (erq->flags & IW_ENCODE_OPEN) {
{
DBG_871X("rtw_wx_set_enc():IW_ENCODE_OPEN\n"); DBG_871X("rtw_wx_set_enc():IW_ENCODE_OPEN\n");
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
...@@ -2135,9 +1969,7 @@ static int rtw_wx_set_enc(struct net_device *dev, ...@@ -2135,9 +1969,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
authmode = Ndis802_11AuthModeOpen; authmode = Ndis802_11AuthModeOpen;
padapter->securitypriv.ndisauthtype =authmode; padapter->securitypriv.ndisauthtype =authmode;
} } else if (erq->flags & IW_ENCODE_RESTRICTED) {
else if (erq->flags & IW_ENCODE_RESTRICTED)
{
DBG_871X("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n"); DBG_871X("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n");
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
...@@ -2147,9 +1979,7 @@ static int rtw_wx_set_enc(struct net_device *dev, ...@@ -2147,9 +1979,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_;
authmode = Ndis802_11AuthModeShared; authmode = Ndis802_11AuthModeShared;
padapter->securitypriv.ndisauthtype =authmode; padapter->securitypriv.ndisauthtype =authmode;
} } else {
else
{
DBG_871X("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags); DBG_871X("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags);
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
...@@ -2161,24 +1991,19 @@ static int rtw_wx_set_enc(struct net_device *dev, ...@@ -2161,24 +1991,19 @@ static int rtw_wx_set_enc(struct net_device *dev,
} }
wep.KeyIndex = key; wep.KeyIndex = key;
if (erq->length > 0) if (erq->length > 0) {
{
wep.KeyLength = erq->length <= 5 ? 5 : 13; wep.KeyLength = erq->length <= 5 ? 5 : 13;
wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
} } else {
else
{
wep.KeyLength = 0 ; wep.KeyLength = 0 ;
if (keyindex_provided == 1)/* set key_id only, no given KeyMaterial(erq->length == 0). */ if (keyindex_provided == 1) { /* set key_id only, no given KeyMaterial(erq->length == 0). */
{
padapter->securitypriv.dot11PrivacyKeyIndex = key; padapter->securitypriv.dot11PrivacyKeyIndex = key;
DBG_871X("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]); DBG_871X("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]);
switch (padapter->securitypriv.dot11DefKeylen[key]) switch (padapter->securitypriv.dot11DefKeylen[key]) {
{
case 5: case 5:
padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_;
break; break;
...@@ -2219,14 +2044,12 @@ static int rtw_wx_get_enc(struct net_device *dev, ...@@ -2219,14 +2044,12 @@ static int rtw_wx_get_enc(struct net_device *dev,
struct iw_point *erq = &(wrqu->encoding); struct iw_point *erq = &(wrqu->encoding);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
if (check_fwstate(pmlmepriv, _FW_LINKED) != true) if (check_fwstate(pmlmepriv, _FW_LINKED) != true) {
{ if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != true) {
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != true) erq->length = 0;
{ erq->flags |= IW_ENCODE_DISABLED;
erq->length = 0; return 0;
erq->flags |= IW_ENCODE_DISABLED; }
return 0;
}
} }
...@@ -2236,8 +2059,7 @@ static int rtw_wx_get_enc(struct net_device *dev, ...@@ -2236,8 +2059,7 @@ static int rtw_wx_get_enc(struct net_device *dev,
if (key > WEP_KEYS) if (key > WEP_KEYS)
return -EINVAL; return -EINVAL;
key--; key--;
} else } else {
{
key = padapter->securitypriv.dot11PrivacyKeyIndex; key = padapter->securitypriv.dot11PrivacyKeyIndex;
} }
...@@ -2248,8 +2070,7 @@ static int rtw_wx_get_enc(struct net_device *dev, ...@@ -2248,8 +2070,7 @@ static int rtw_wx_get_enc(struct net_device *dev,
/* erq->flags |= IW_ENCODE_OPEN; */ /* erq->flags |= IW_ENCODE_OPEN; */
/* */ /* */
switch (padapter->securitypriv.ndisencryptstatus) switch (padapter->securitypriv.ndisencryptstatus) {
{
case Ndis802_11EncryptionNotSupported: case Ndis802_11EncryptionNotSupported:
case Ndis802_11EncryptionDisabled: case Ndis802_11EncryptionDisabled:
erq->length = 0; erq->length = 0;
...@@ -2258,23 +2079,16 @@ static int rtw_wx_get_enc(struct net_device *dev, ...@@ -2258,23 +2079,16 @@ static int rtw_wx_get_enc(struct net_device *dev,
case Ndis802_11Encryption1Enabled: case Ndis802_11Encryption1Enabled:
erq->length = padapter->securitypriv.dot11DefKeylen[key]; erq->length = padapter->securitypriv.dot11DefKeylen[key];
if (erq->length) if (erq->length) {
{
memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]); memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]);
erq->flags |= IW_ENCODE_ENABLED; erq->flags |= IW_ENCODE_ENABLED;
if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen)
{
erq->flags |= IW_ENCODE_OPEN; erq->flags |= IW_ENCODE_OPEN;
}
else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared) else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared)
{ erq->flags |= IW_ENCODE_RESTRICTED;
erq->flags |= IW_ENCODE_RESTRICTED; } else {
}
}
else
{
erq->length = 0; erq->length = 0;
erq->flags |= IW_ENCODE_DISABLED; erq->flags |= IW_ENCODE_DISABLED;
} }
...@@ -2343,14 +2157,13 @@ static int rtw_wx_set_auth(struct net_device *dev, ...@@ -2343,14 +2157,13 @@ static int rtw_wx_set_auth(struct net_device *dev,
case IW_AUTH_TKIP_COUNTERMEASURES: case IW_AUTH_TKIP_COUNTERMEASURES:
{ {
if (param->value) if (param->value) {
{ /* wpa_supplicant is enabling the tkip countermeasure. */ /* wpa_supplicant is enabling the tkip countermeasure. */
padapter->securitypriv.btkip_countermeasure = true; padapter->securitypriv.btkip_countermeasure = true;
} } else {
else /* wpa_supplicant is disabling the tkip countermeasure. */
{ /* wpa_supplicant is disabling the tkip countermeasure. */ padapter->securitypriv.btkip_countermeasure = false;
padapter->securitypriv.btkip_countermeasure = false; }
}
break; break;
} }
case IW_AUTH_DROP_UNENCRYPTED: case IW_AUTH_DROP_UNENCRYPTED:
...@@ -2367,8 +2180,7 @@ static int rtw_wx_set_auth(struct net_device *dev, ...@@ -2367,8 +2180,7 @@ static int rtw_wx_set_auth(struct net_device *dev,
* be set. * be set.
*/ */
if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) {
{
break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */ break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */
/* then it needn't reset it; */ /* then it needn't reset it; */
} }
...@@ -2462,37 +2274,29 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, ...@@ -2462,37 +2274,29 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
{
param->u.crypt.set_tx = 1; param->u.crypt.set_tx = 1;
}
/* cliW: WEP does not have group key /* cliW: WEP does not have group key
* just not checking GROUP key setting * just not checking GROUP key setting
*/ */
if ((pext->alg != IW_ENCODE_ALG_WEP) && if ((pext->alg != IW_ENCODE_ALG_WEP) &&
((pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ((pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
|| (pext->ext_flags & IW_ENCODE_ALG_AES_CMAC) || (pext->ext_flags & IW_ENCODE_ALG_AES_CMAC))) {
))
{
param->u.crypt.set_tx = 0; param->u.crypt.set_tx = 0;
} }
param->u.crypt.idx = (pencoding->flags&0x00FF) -1 ; param->u.crypt.idx = (pencoding->flags&0x00FF) -1 ;
if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
{
memcpy(param->u.crypt.seq, pext->rx_seq, 8); memcpy(param->u.crypt.seq, pext->rx_seq, 8);
}
if (pext->key_len) if (pext->key_len) {
{
param->u.crypt.key_len = pext->key_len; param->u.crypt.key_len = pext->key_len;
/* memcpy(param + 1, pext + 1, pext->key_len); */ /* memcpy(param + 1, pext + 1, pext->key_len); */
memcpy(param->u.crypt.key, pext + 1, pext->key_len); memcpy(param->u.crypt.key, pext + 1, pext->key_len);
} }
if (pencoding->flags & IW_ENCODE_DISABLED) if (pencoding->flags & IW_ENCODE_DISABLED) {
{
/* todo: remove key */ /* todo: remove key */
/* remove = 1; */ /* remove = 1; */
} }
...@@ -2514,8 +2318,7 @@ static int rtw_wx_get_nick(struct net_device *dev, ...@@ -2514,8 +2318,7 @@ static int rtw_wx_get_nick(struct net_device *dev,
/* struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); */ /* struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); */
/* struct security_priv *psecuritypriv = &padapter->securitypriv; */ /* struct security_priv *psecuritypriv = &padapter->securitypriv; */
if (extra) if (extra) {
{
wrqu->data.length = 14; wrqu->data.length = 14;
wrqu->data.flags = 1; wrqu->data.flags = 1;
memcpy(extra, "<WIFI@REALTEK>", 14); memcpy(extra, "<WIFI@REALTEK>", 14);
...@@ -2683,9 +2486,9 @@ static int rtw_wx_set_channel_plan(struct net_device *dev, ...@@ -2683,9 +2486,9 @@ static int rtw_wx_set_channel_plan(struct net_device *dev,
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
u8 channel_plan_req = (u8) (*((int *)wrqu)); u8 channel_plan_req = (u8) (*((int *)wrqu));
if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1, 1)) { if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1, 1))
DBG_871X("%s set channel_plan = 0x%02X\n", __func__, channel_plan_req); DBG_871X("%s set channel_plan = 0x%02X\n", __func__, channel_plan_req);
} else else
return -EPERM; return -EPERM;
return 0; return 0;
...@@ -2751,14 +2554,12 @@ static int rtw_get_ap_info(struct net_device *dev, ...@@ -2751,14 +2554,12 @@ static int rtw_get_ap_info(struct net_device *dev,
DBG_871X("+rtw_get_aplist_info\n"); DBG_871X("+rtw_get_aplist_info\n");
if ((padapter->bDriverStopped) || (pdata == NULL)) if ((padapter->bDriverStopped) || (pdata == NULL)) {
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING))) == true) while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING))) == true) {
{
msleep(30); msleep(30);
cnt++; cnt++;
if (cnt > 100) if (cnt > 100)
...@@ -2768,16 +2569,12 @@ static int rtw_get_ap_info(struct net_device *dev, ...@@ -2768,16 +2569,12 @@ static int rtw_get_ap_info(struct net_device *dev,
/* pdata->length = 0;? */ /* pdata->length = 0;? */
pdata->flags = 0; pdata->flags = 0;
if (pdata->length>=32) if (pdata->length>=32) {
{ if (copy_from_user(data, pdata->pointer, 32)) {
if (copy_from_user(data, pdata->pointer, 32))
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
} } else {
else
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
...@@ -2787,8 +2584,7 @@ static int rtw_get_ap_info(struct net_device *dev, ...@@ -2787,8 +2584,7 @@ static int rtw_get_ap_info(struct net_device *dev,
phead = get_list_head(queue); phead = get_list_head(queue);
plist = get_next(phead); plist = get_next(phead);
while (1) while (1) {
{
if (phead == plist) if (phead == plist)
break; break;
...@@ -2796,32 +2592,27 @@ static int rtw_get_ap_info(struct net_device *dev, ...@@ -2796,32 +2592,27 @@ static int rtw_get_ap_info(struct net_device *dev,
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
/* if (hwaddr_aton_i(pdata->pointer, bssid)) */ /* if (hwaddr_aton_i(pdata->pointer, bssid)) */
if (hwaddr_aton_i(data, bssid)) if (hwaddr_aton_i(data, bssid)) {
{
DBG_871X("Invalid BSSID '%s'.\n", (u8 *)data); DBG_871X("Invalid BSSID '%s'.\n", (u8 *)data);
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
return -EINVAL; return -EINVAL;
} }
if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN))/* BSSID match, then check if supporting wpa/wpa2 */ if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { /* BSSID match, then check if supporting wpa/wpa2 */
{
DBG_871X("BSSID:" MAC_FMT "\n", MAC_ARG(bssid)); DBG_871X("BSSID:" MAC_FMT "\n", MAC_ARG(bssid));
pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen>0)) if (pbuf && (wpa_ielen>0)) {
{
pdata->flags = 1; pdata->flags = 1;
break; break;
} }
pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen>0)) if (pbuf && (wpa_ielen>0)) {
{
pdata->flags = 2; pdata->flags = 2;
break; break;
} }
} }
plist = get_next(plist); plist = get_next(plist);
...@@ -2830,10 +2621,8 @@ static int rtw_get_ap_info(struct net_device *dev, ...@@ -2830,10 +2621,8 @@ static int rtw_get_ap_info(struct net_device *dev,
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
if (pdata->length>=34) if (pdata->length>=34) {
{ if (copy_to_user((u8 __force __user *)pdata->pointer+32, (u8 *)&pdata->flags, 1)) {
if (copy_to_user((u8 __force __user *)pdata->pointer+32, (u8 *)&pdata->flags, 1))
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
...@@ -2855,8 +2644,7 @@ static int rtw_set_pid(struct net_device *dev, ...@@ -2855,8 +2644,7 @@ static int rtw_set_pid(struct net_device *dev,
int *pdata = (int *)wrqu; int *pdata = (int *)wrqu;
int selector; int selector;
if ((padapter->bDriverStopped) || (pdata == NULL)) if ((padapter->bDriverStopped) || (pdata == NULL)) {
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
...@@ -2886,17 +2674,14 @@ static int rtw_wps_start(struct net_device *dev, ...@@ -2886,17 +2674,14 @@ static int rtw_wps_start(struct net_device *dev,
u32 u32wps_start = 0; u32 u32wps_start = 0;
unsigned int uintRet = 0; unsigned int uintRet = 0;
if ((true == padapter->bDriverStopped) ||(true ==padapter->bSurpriseRemoved) || (NULL == pdata)) if ((true == padapter->bDriverStopped) ||(true ==padapter->bSurpriseRemoved) || (NULL == pdata)) {
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
uintRet = copy_from_user((void*) &u32wps_start, pdata->pointer, 4); uintRet = copy_from_user((void*) &u32wps_start, pdata->pointer, 4);
if (u32wps_start == 0) if (u32wps_start == 0)
{
u32wps_start = *extra; u32wps_start = *extra;
}
DBG_871X("[%s] wps_start = %d\n", __func__, u32wps_start); DBG_871X("[%s] wps_start = %d\n", __func__, u32wps_start);
...@@ -2964,18 +2749,15 @@ static int rtw_rereg_nd_name(struct net_device *dev, ...@@ -2964,18 +2749,15 @@ static int rtw_rereg_nd_name(struct net_device *dev,
if (wrqu->data.length > IFNAMSIZ) if (wrqu->data.length > IFNAMSIZ)
return -EFAULT; return -EFAULT;
if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) { if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ))
return -EFAULT; return -EFAULT;
}
if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) { if (0 == strcmp(rereg_priv->old_ifname, new_ifname))
return ret; return ret;
}
DBG_871X("%s new_ifname:%s\n", __func__, new_ifname); DBG_871X("%s new_ifname:%s\n", __func__, new_ifname);
if (0 != (ret = rtw_change_ifname(padapter, new_ifname))) { if (0 != (ret = rtw_change_ifname(padapter, new_ifname)))
goto exit; goto exit;
}
strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ);
rereg_priv->old_ifname[IFNAMSIZ-1] = 0; rereg_priv->old_ifname[IFNAMSIZ-1] = 0;
...@@ -3021,11 +2803,9 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3021,11 +2803,9 @@ static int rtw_dbg_port(struct net_device *dev,
extra_arg = *(pdata+1); extra_arg = *(pdata+1);
switch (major_cmd) switch (major_cmd) {
{
case 0x70:/* read_reg */ case 0x70:/* read_reg */
switch (minor_cmd) switch (minor_cmd) {
{
case 1: case 1:
DBG_871X("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); DBG_871X("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg));
break; break;
...@@ -3038,8 +2818,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3038,8 +2818,7 @@ static int rtw_dbg_port(struct net_device *dev,
} }
break; break;
case 0x71:/* write_reg */ case 0x71:/* write_reg */
switch (minor_cmd) switch (minor_cmd) {
{
case 1: case 1:
rtw_write8(padapter, arg, extra_arg); rtw_write8(padapter, arg, extra_arg);
DBG_871X("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); DBG_871X("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg));
...@@ -3070,8 +2849,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3070,8 +2849,7 @@ static int rtw_dbg_port(struct net_device *dev,
break; break;
case 0x76: case 0x76:
switch (minor_cmd) switch (minor_cmd) {
{
case 0x00: /* normal mode, */ case 0x00: /* normal mode, */
padapter->recvpriv.is_signal_dbg = 0; padapter->recvpriv.is_signal_dbg = 0;
break; break;
...@@ -3108,8 +2886,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3108,8 +2886,7 @@ static int rtw_dbg_port(struct net_device *dev,
, WLAN_REASON_EXPIRATION_CHK); , WLAN_REASON_EXPIRATION_CHK);
break; break;
case 0x7F: case 0x7F:
switch (minor_cmd) switch (minor_cmd) {
{
case 0x0: case 0x0:
DBG_871X("fwstate = 0x%x\n", get_fwstate(pmlmepriv)); DBG_871X("fwstate = 0x%x\n", get_fwstate(pmlmepriv));
break; break;
...@@ -3137,8 +2914,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3137,8 +2914,7 @@ static int rtw_dbg_port(struct net_device *dev,
break; break;
case 0x05: case 0x05:
psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
if (psta) if (psta) {
{
int i; int i;
struct recv_reorder_ctrl *preorder_ctrl; struct recv_reorder_ctrl *preorder_ctrl;
...@@ -3152,18 +2928,13 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3152,18 +2928,13 @@ static int rtw_dbg_port(struct net_device *dev,
DBG_871X("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); DBG_871X("ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
DBG_871X("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); DBG_871X("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
for (i = 0;i<16;i++) for (i = 0;i<16;i++) {
{
preorder_ctrl = &psta->recvreorder_ctrl[i]; preorder_ctrl = &psta->recvreorder_ctrl[i];
if (preorder_ctrl->enable) if (preorder_ctrl->enable)
{
DBG_871X("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq); DBG_871X("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq);
}
} }
} } else {
else
{
DBG_871X("can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress)); DBG_871X("can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress));
} }
break; break;
...@@ -3196,19 +2967,16 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3196,19 +2967,16 @@ static int rtw_dbg_port(struct net_device *dev,
spin_lock_bh(&pstapriv->sta_hash_lock); spin_lock_bh(&pstapriv->sta_hash_lock);
for (i = 0; i< NUM_STA; i++) for (i = 0; i< NUM_STA; i++) {
{
phead = &(pstapriv->sta_hash[i]); phead = &(pstapriv->sta_hash[i]);
plist = get_next(phead); plist = get_next(phead);
while (phead != plist) while (phead != plist) {
{
psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
plist = get_next(plist); plist = get_next(plist);
if (extra_arg == psta->aid) if (extra_arg == psta->aid) {
{
DBG_871X("sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr)); DBG_871X("sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr));
DBG_871X("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); DBG_871X("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self);
DBG_871X("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); DBG_871X("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
...@@ -3226,17 +2994,12 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3226,17 +2994,12 @@ static int rtw_dbg_port(struct net_device *dev,
for (j = 0;j<16;j++) for (j = 0;j<16;j++) {
{
preorder_ctrl = &psta->recvreorder_ctrl[j]; preorder_ctrl = &psta->recvreorder_ctrl[j];
if (preorder_ctrl->enable) if (preorder_ctrl->enable)
{
DBG_871X("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq); DBG_871X("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq);
}
} }
} }
} }
} }
...@@ -3255,8 +3018,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3255,8 +3018,7 @@ static int rtw_dbg_port(struct net_device *dev,
if (arg == 0) { if (arg == 0) {
DBG_871X("disable driver ctrl vcs\n"); DBG_871X("disable driver ctrl vcs\n");
padapter->driver_vcs_en = 0; padapter->driver_vcs_en = 0;
} } else if (arg == 1) {
else if (arg == 1) {
DBG_871X("enable driver ctrl vcs = %d\n", extra_arg); DBG_871X("enable driver ctrl vcs = %d\n", extra_arg);
padapter->driver_vcs_en = 1; padapter->driver_vcs_en = 1;
...@@ -3272,8 +3034,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3272,8 +3034,7 @@ static int rtw_dbg_port(struct net_device *dev,
DBG_871X("dump rx packet (%d)\n", extra_arg); DBG_871X("dump rx packet (%d)\n", extra_arg);
/* pHalData->bDumpRxPkt =extra_arg; */ /* pHalData->bDumpRxPkt =extra_arg; */
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg));
} } else if (arg == 1) {
else if (arg == 1) {
DBG_871X("dump tx packet (%d)\n", extra_arg); DBG_871X("dump tx packet (%d)\n", extra_arg);
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg));
} }
...@@ -3284,8 +3045,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3284,8 +3045,7 @@ static int rtw_dbg_port(struct net_device *dev,
if (arg == 0) { if (arg == 0) {
DBG_871X("disable driver ctrl rx_ampdu_factor\n"); DBG_871X("disable driver ctrl rx_ampdu_factor\n");
padapter->driver_rx_ampdu_factor = 0xFF; padapter->driver_rx_ampdu_factor = 0xFF;
} } else if (arg == 1) {
else if (arg == 1) {
DBG_871X("enable driver ctrl rx_ampdu_factor = %d\n", extra_arg); DBG_871X("enable driver ctrl rx_ampdu_factor = %d\n", extra_arg);
...@@ -3310,12 +3070,10 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3310,12 +3070,10 @@ static int rtw_dbg_port(struct net_device *dev,
struct registry_priv *pregpriv = &padapter->registrypriv; struct registry_priv *pregpriv = &padapter->registrypriv;
/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */
/* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
if (pregpriv && (extra_arg == 0 || extra_arg == 1|| extra_arg == 2 || extra_arg == 3)) if (pregpriv && (extra_arg == 0 || extra_arg == 1|| extra_arg == 2 || extra_arg == 3)) {
{
pregpriv->rx_stbc = extra_arg; pregpriv->rx_stbc = extra_arg;
DBG_871X("set rx_stbc =%d\n", pregpriv->rx_stbc); DBG_871X("set rx_stbc =%d\n", pregpriv->rx_stbc);
} } else
else
DBG_871X("get rx_stbc =%d\n", pregpriv->rx_stbc); DBG_871X("get rx_stbc =%d\n", pregpriv->rx_stbc);
} }
...@@ -3324,12 +3082,10 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3324,12 +3082,10 @@ static int rtw_dbg_port(struct net_device *dev,
{ {
struct registry_priv *pregpriv = &padapter->registrypriv; struct registry_priv *pregpriv = &padapter->registrypriv;
/* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */
if (pregpriv && extra_arg < 3) if (pregpriv && extra_arg < 3) {
{
pregpriv->ampdu_enable = extra_arg; pregpriv->ampdu_enable = extra_arg;
DBG_871X("set ampdu_enable =%d\n", pregpriv->ampdu_enable); DBG_871X("set ampdu_enable =%d\n", pregpriv->ampdu_enable);
} } else
else
DBG_871X("get ampdu_enable =%d\n", pregpriv->ampdu_enable); DBG_871X("get ampdu_enable =%d\n", pregpriv->ampdu_enable);
} }
...@@ -3343,8 +3099,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3343,8 +3099,7 @@ static int rtw_dbg_port(struct net_device *dev,
{ {
if (arg == 0xff) { if (arg == 0xff) {
rtw_odm_dbg_comp_msg(RTW_DBGDUMP, padapter); rtw_odm_dbg_comp_msg(RTW_DBGDUMP, padapter);
} } else {
else {
u64 dbg_comp = (u64)extra_arg; u64 dbg_comp = (u64)extra_arg;
rtw_odm_dbg_comp_set(padapter, dbg_comp); rtw_odm_dbg_comp_set(padapter, dbg_comp);
} }
...@@ -3375,8 +3130,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3375,8 +3130,7 @@ static int rtw_dbg_port(struct net_device *dev,
if (arg == 0) { if (arg == 0) {
DBG_871X("driver disable LDPC\n"); DBG_871X("driver disable LDPC\n");
pregistrypriv->ldpc_cap = 0x00; pregistrypriv->ldpc_cap = 0x00;
} } else if (arg == 1) {
else if (arg == 1) {
DBG_871X("driver set LDPC cap = 0x%x\n", extra_arg); DBG_871X("driver set LDPC cap = 0x%x\n", extra_arg);
pregistrypriv->ldpc_cap = (u8)(extra_arg&0x33); pregistrypriv->ldpc_cap = (u8)(extra_arg&0x33);
} }
...@@ -3391,8 +3145,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3391,8 +3145,7 @@ static int rtw_dbg_port(struct net_device *dev,
if (arg == 0) { if (arg == 0) {
DBG_871X("driver disable STBC\n"); DBG_871X("driver disable STBC\n");
pregistrypriv->stbc_cap = 0x00; pregistrypriv->stbc_cap = 0x00;
} } else if (arg == 1) {
else if (arg == 1) {
DBG_871X("driver set STBC cap = 0x%x\n", extra_arg); DBG_871X("driver set STBC cap = 0x%x\n", extra_arg);
pregistrypriv->stbc_cap = (u8)(extra_arg&0x33); pregistrypriv->stbc_cap = (u8)(extra_arg&0x33);
} }
...@@ -3406,8 +3159,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3406,8 +3159,7 @@ static int rtw_dbg_port(struct net_device *dev,
DBG_871X("disable driver ctrl max_rx_rate, reset to default_rate_set\n"); DBG_871X("disable driver ctrl max_rx_rate, reset to default_rate_set\n");
init_mlme_default_rate_set(padapter); init_mlme_default_rate_set(padapter);
pregistrypriv->ht_enable = (u8)rtw_ht_enable; pregistrypriv->ht_enable = (u8)rtw_ht_enable;
} } else if (arg == 1) {
else if (arg == 1) {
int i; int i;
u8 max_rx_rate; u8 max_rx_rate;
...@@ -3416,18 +3168,15 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3416,18 +3168,15 @@ static int rtw_dbg_port(struct net_device *dev,
max_rx_rate = (u8)extra_arg; max_rx_rate = (u8)extra_arg;
if (max_rx_rate < 0xc) /* max_rx_rate < MSC0 -> B or G -> disable HT */ if (max_rx_rate < 0xc) { /* max_rx_rate < MSC0 -> B or G -> disable HT */
{
pregistrypriv->ht_enable = 0; pregistrypriv->ht_enable = 0;
for (i = 0; i<NumRates; i++) for (i = 0; i<NumRates; i++) {
{
if (pmlmeext->datarate[i] > max_rx_rate) if (pmlmeext->datarate[i] > max_rx_rate)
pmlmeext->datarate[i] = 0xff; pmlmeext->datarate[i] = 0xff;
} }
} }
else if (max_rx_rate < 0x1c) /* mcs0~mcs15 */ else if (max_rx_rate < 0x1c) { /* mcs0~mcs15 */
{
u32 mcs_bitmap = 0x0; u32 mcs_bitmap = 0x0;
for (i = 0; i<((max_rx_rate+1)-0xc); i++) for (i = 0; i<((max_rx_rate+1)-0xc); i++)
...@@ -3443,8 +3192,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3443,8 +3192,7 @@ static int rtw_dbg_port(struct net_device *dev,
if (arg == 0) { if (arg == 0) {
DBG_871X("disable driver ctrl ampdu density\n"); DBG_871X("disable driver ctrl ampdu density\n");
padapter->driver_ampdu_spacing = 0xFF; padapter->driver_ampdu_spacing = 0xFF;
} } else if (arg == 1) {
else if (arg == 1) {
DBG_871X("enable driver ctrl ampdu density = %d\n", extra_arg); DBG_871X("enable driver ctrl ampdu density = %d\n", extra_arg);
...@@ -3531,15 +3279,12 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3531,15 +3279,12 @@ static int rtw_dbg_port(struct net_device *dev,
break; break;
case 0xdd:/* registers dump , 0 for mac reg, 1 for bb reg, 2 for rf reg */ case 0xdd:/* registers dump , 0 for mac reg, 1 for bb reg, 2 for rf reg */
{ {
if (extra_arg == 0) { if (extra_arg == 0)
mac_reg_dump(RTW_DBGDUMP, padapter); mac_reg_dump(RTW_DBGDUMP, padapter);
} else if (extra_arg == 1)
else if (extra_arg == 1) {
bb_reg_dump(RTW_DBGDUMP, padapter); bb_reg_dump(RTW_DBGDUMP, padapter);
} else if (extra_arg ==2)
else if (extra_arg ==2) {
rf_reg_dump(RTW_DBGDUMP, padapter); rf_reg_dump(RTW_DBGDUMP, padapter);
}
} }
break; break;
...@@ -3557,8 +3302,7 @@ static int rtw_dbg_port(struct net_device *dev, ...@@ -3557,8 +3302,7 @@ static int rtw_dbg_port(struct net_device *dev,
DBG_871X("extra_arg = 4 - disable BT coexistence - BIT(3)\n"); DBG_871X("extra_arg = 4 - disable BT coexistence - BIT(3)\n");
DBG_871X("extra_arg = 5 - disable antenna diversity - BIT(4)\n"); DBG_871X("extra_arg = 5 - disable antenna diversity - BIT(4)\n");
DBG_871X("extra_arg = 6 - enable all dynamic func\n"); DBG_871X("extra_arg = 6 - enable all dynamic func\n");
} } else {
else {
/*extra_arg = 0 - disable all dynamic func /*extra_arg = 0 - disable all dynamic func
extra_arg = 1 - disable DIG extra_arg = 1 - disable DIG
extra_arg = 2 - disable tx power tracking extra_arg = 2 - disable tx power tracking
...@@ -3634,8 +3378,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value) ...@@ -3634,8 +3378,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
/* ret = ieee80211_wpa_enable(ieee, value); */ /* ret = ieee80211_wpa_enable(ieee, value); */
switch ((value)&0xff) switch ((value)&0xff) {
{
case 1 : /* WPA */ case 1 : /* WPA */
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled;
...@@ -3721,8 +3464,7 @@ static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) ...@@ -3721,8 +3464,7 @@ static int wpa_mlme(struct net_device *dev, u32 command, u32 reason)
int ret = 0; int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
switch (command) switch (command) {
{
case IEEE_MLME_STA_DEAUTH: case IEEE_MLME_STA_DEAUTH:
if (!rtw_set_802_11_disassociate(padapter)) if (!rtw_set_802_11_disassociate(padapter))
...@@ -3759,14 +3501,12 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) ...@@ -3759,14 +3501,12 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
} }
param = (struct ieee_param *)rtw_malloc(p->length); param = (struct ieee_param *)rtw_malloc(p->length);
if (param == NULL) if (param == NULL) {
{
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
if (copy_from_user(param, p->pointer, p->length)) if (copy_from_user(param, p->pointer, p->length)) {
{
kfree(param); kfree(param);
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
...@@ -3829,35 +3569,28 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3829,35 +3569,28 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
/* sizeof(struct ieee_param) = 64 bytes; */ /* sizeof(struct ieee_param) = 64 bytes; */
/* if (param_len != (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) */ /* if (param_len != (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) */
if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) {
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
{ if (param->u.crypt.idx >= WEP_KEYS) {
if (param->u.crypt.idx >= WEP_KEYS)
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
} } else {
else
{
psta = rtw_get_stainfo(pstapriv, param->sta_addr); psta = rtw_get_stainfo(pstapriv, param->sta_addr);
if (!psta) if (!psta) {
{
/* ret = -EINVAL; */ /* ret = -EINVAL; */
DBG_871X("rtw_set_encryption(), sta has already been removed or never been added\n"); DBG_871X("rtw_set_encryption(), sta has already been removed or never been added\n");
goto exit; goto exit;
} }
} }
if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) {
{
/* todo:clear default encryption keys */ /* todo:clear default encryption keys */
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
...@@ -3871,8 +3604,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3871,8 +3604,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
} }
if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) {
{
DBG_871X("r871x_set_encryption, crypt.alg = WEP\n"); DBG_871X("r871x_set_encryption, crypt.alg = WEP\n");
wep_key_idx = param->u.crypt.idx; wep_key_idx = param->u.crypt.idx;
...@@ -3880,15 +3612,13 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3880,15 +3612,13 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
DBG_871X("r871x_set_encryption, wep_key_idx =%d, len =%d\n", wep_key_idx, wep_key_len); DBG_871X("r871x_set_encryption, wep_key_idx =%d, len =%d\n", wep_key_idx, wep_key_len);
if ((wep_key_idx >= WEP_KEYS) || (wep_key_len<= 0)) if ((wep_key_idx >= WEP_KEYS) || (wep_key_len<= 0)) {
{
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
if (wep_key_len > 0) if (wep_key_len > 0) {
{
wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_key_len = wep_key_len <= 5 ? 5 : 13;
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
pwep =(struct ndis_802_11_wep *)rtw_malloc(wep_total_len); pwep =(struct ndis_802_11_wep *)rtw_malloc(wep_total_len);
...@@ -3908,8 +3638,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3908,8 +3638,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
if (param->u.crypt.set_tx) if (param->u.crypt.set_tx) {
{
DBG_871X("wep, set_tx = 1\n"); DBG_871X("wep, set_tx = 1\n");
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Auto;
...@@ -3917,8 +3646,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3917,8 +3646,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
psecuritypriv->dot118021XGrpPrivacy = _WEP40_; psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
if (pwep->KeyLength == 13) if (pwep->KeyLength == 13) {
{
psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
psecuritypriv->dot118021XGrpPrivacy = _WEP104_; psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
} }
...@@ -3931,9 +3659,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3931,9 +3659,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psecuritypriv->dot11DefKeylen[wep_key_idx]=pwep->KeyLength; psecuritypriv->dot11DefKeylen[wep_key_idx]=pwep->KeyLength;
rtw_ap_set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx, 1); rtw_ap_set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx, 1);
} } else {
else
{
DBG_871X("wep, set_tx = 0\n"); DBG_871X("wep, set_tx = 0\n");
/* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */
...@@ -3951,25 +3677,18 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3951,25 +3677,18 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
} }
if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) /* group key */ if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */
{ if (param->u.crypt.set_tx == 1) {
if (param->u.crypt.set_tx == 1) if (strcmp(param->u.crypt.alg, "WEP") == 0) {
{
if (strcmp(param->u.crypt.alg, "WEP") == 0)
{
DBG_871X("%s, set group_key, WEP\n", __func__); DBG_871X("%s, set group_key, WEP\n", __func__);
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
psecuritypriv->dot118021XGrpPrivacy = _WEP40_; psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
if (param->u.crypt.key_len == 13) if (param->u.crypt.key_len == 13)
{
psecuritypriv->dot118021XGrpPrivacy = _WEP104_; psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
}
} } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
{
DBG_871X("%s, set group_key, TKIP\n", __func__); DBG_871X("%s, set group_key, TKIP\n", __func__);
psecuritypriv->dot118021XGrpPrivacy = _TKIP_; psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
...@@ -3984,16 +3703,13 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -3984,16 +3703,13 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psecuritypriv->busetkipkey = true; psecuritypriv->busetkipkey = true;
} }
else if (strcmp(param->u.crypt.alg, "CCMP") == 0) else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
{
DBG_871X("%s, set group_key, CCMP\n", __func__); DBG_871X("%s, set group_key, CCMP\n", __func__);
psecuritypriv->dot118021XGrpPrivacy = _AES_; psecuritypriv->dot118021XGrpPrivacy = _AES_;
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
} } else {
else
{
DBG_871X("%s, set group_key, none\n", __func__); DBG_871X("%s, set group_key, none\n", __func__);
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
...@@ -4008,38 +3724,28 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -4008,38 +3724,28 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx);
pbcmc_sta =rtw_get_bcmc_stainfo(padapter); pbcmc_sta =rtw_get_bcmc_stainfo(padapter);
if (pbcmc_sta) if (pbcmc_sta) {
{
pbcmc_sta->ieee8021x_blocked = false; pbcmc_sta->ieee8021x_blocked = false;
pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */
} }
} }
goto exit; goto exit;
} }
if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) /* psk/802_1x */ if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /* psk/802_1x */
{ if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) if (param->u.crypt.set_tx == 1) {
{
if (param->u.crypt.set_tx == 1)
{
memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
if (strcmp(param->u.crypt.alg, "WEP") == 0) if (strcmp(param->u.crypt.alg, "WEP") == 0) {
{
DBG_871X("%s, set pairwise key, WEP\n", __func__); DBG_871X("%s, set pairwise key, WEP\n", __func__);
psta->dot118021XPrivacy = _WEP40_; psta->dot118021XPrivacy = _WEP40_;
if (param->u.crypt.key_len == 13) if (param->u.crypt.key_len == 13)
{
psta->dot118021XPrivacy = _WEP104_; psta->dot118021XPrivacy = _WEP104_;
} } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
}
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
{
DBG_871X("%s, set pairwise key, TKIP\n", __func__); DBG_871X("%s, set pairwise key, TKIP\n", __func__);
psta->dot118021XPrivacy = _TKIP_; psta->dot118021XPrivacy = _TKIP_;
...@@ -4051,16 +3757,12 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -4051,16 +3757,12 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psecuritypriv->busetkipkey = true; psecuritypriv->busetkipkey = true;
} } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
{
DBG_871X("%s, set pairwise key, CCMP\n", __func__); DBG_871X("%s, set pairwise key, CCMP\n", __func__);
psta->dot118021XPrivacy = _AES_; psta->dot118021XPrivacy = _AES_;
} } else {
else
{
DBG_871X("%s, set pairwise key, none\n", __func__); DBG_871X("%s, set pairwise key, none\n", __func__);
psta->dot118021XPrivacy = _NO_PRIVACY_; psta->dot118021XPrivacy = _NO_PRIVACY_;
...@@ -4070,21 +3772,14 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -4070,21 +3772,14 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psta->ieee8021x_blocked = false; psta->ieee8021x_blocked = false;
} } else { /* group key??? */
else/* group key??? */ if (strcmp(param->u.crypt.alg, "WEP") == 0) {
{
if (strcmp(param->u.crypt.alg, "WEP") == 0)
{
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
psecuritypriv->dot118021XGrpPrivacy = _WEP40_; psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
if (param->u.crypt.key_len == 13) if (param->u.crypt.key_len == 13)
{
psecuritypriv->dot118021XGrpPrivacy = _WEP104_; psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
} } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
}
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
{
psecuritypriv->dot118021XGrpPrivacy = _TKIP_; psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
...@@ -4096,15 +3791,11 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -4096,15 +3791,11 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psecuritypriv->busetkipkey = true; psecuritypriv->busetkipkey = true;
} } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
{
psecuritypriv->dot118021XGrpPrivacy = _AES_; psecuritypriv->dot118021XGrpPrivacy = _AES_;
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
} } else {
else
{
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
} }
...@@ -4117,16 +3808,12 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, ...@@ -4117,16 +3808,12 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx);
pbcmc_sta =rtw_get_bcmc_stainfo(padapter); pbcmc_sta =rtw_get_bcmc_stainfo(padapter);
if (pbcmc_sta) if (pbcmc_sta) {
{
pbcmc_sta->ieee8021x_blocked = false; pbcmc_sta->ieee8021x_blocked = false;
pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */
} }
} }
} }
} }
exit: exit:
...@@ -4196,14 +3883,11 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) ...@@ -4196,14 +3883,11 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
DBG_871X("rtw_add_sta(aid =%d) =" MAC_FMT "\n", param->u.add_sta.aid, MAC_ARG(param->sta_addr)); DBG_871X("rtw_add_sta(aid =%d) =" MAC_FMT "\n", param->u.add_sta.aid, MAC_ARG(param->sta_addr));
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
{
return -EINVAL; return -EINVAL;
}
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
{
return -EINVAL; return -EINVAL;
} }
...@@ -4221,8 +3905,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) ...@@ -4221,8 +3905,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
*/ */
/* psta = rtw_alloc_stainfo(pstapriv, param->sta_addr); */ /* psta = rtw_alloc_stainfo(pstapriv, param->sta_addr); */
psta = rtw_get_stainfo(pstapriv, param->sta_addr); psta = rtw_get_stainfo(pstapriv, param->sta_addr);
if (psta) if (psta) {
{
int flags = param->u.add_sta.flags; int flags = param->u.add_sta.flags;
/* DBG_871X("rtw_add_sta(), init sta's variables, psta =%p\n", psta); */ /* DBG_871X("rtw_add_sta(), init sta's variables, psta =%p\n", psta); */
...@@ -4242,14 +3925,11 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) ...@@ -4242,14 +3925,11 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
psta->qos_option = 0; psta->qos_option = 0;
/* chec 802.11n ht cap. */ /* chec 802.11n ht cap. */
if (WLAN_STA_HT&flags) if (WLAN_STA_HT&flags) {
{
psta->htpriv.ht_option = true; psta->htpriv.ht_option = true;
psta->qos_option = 1; psta->qos_option = 1;
memcpy((void*)&psta->htpriv.ht_cap, (void*)&param->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); memcpy((void*)&psta->htpriv.ht_cap, (void*)&param->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap));
} } else {
else
{
psta->htpriv.ht_option = false; psta->htpriv.ht_option = false;
} }
...@@ -4259,9 +3939,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) ...@@ -4259,9 +3939,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
update_sta_info_apmode(padapter, psta); update_sta_info_apmode(padapter, psta);
} } else {
else
{
ret = -ENOMEM; ret = -ENOMEM;
} }
...@@ -4280,27 +3958,22 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) ...@@ -4280,27 +3958,22 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
DBG_871X("rtw_del_sta =" MAC_FMT "\n", MAC_ARG(param->sta_addr)); DBG_871X("rtw_del_sta =" MAC_FMT "\n", MAC_ARG(param->sta_addr));
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
{
return -EINVAL; return -EINVAL;
}
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
{
return -EINVAL; return -EINVAL;
} }
psta = rtw_get_stainfo(pstapriv, param->sta_addr); psta = rtw_get_stainfo(pstapriv, param->sta_addr);
if (psta) if (psta) {
{
u8 updated =false; u8 updated =false;
/* DBG_871X("free psta =%p, aid =%d\n", psta, psta->aid); */ /* DBG_871X("free psta =%p, aid =%d\n", psta, psta->aid); */
spin_lock_bh(&pstapriv->asoc_list_lock); spin_lock_bh(&pstapriv->asoc_list_lock);
if (list_empty(&psta->asoc_list) ==false) if (list_empty(&psta->asoc_list) ==false) {
{
list_del_init(&psta->asoc_list); list_del_init(&psta->asoc_list);
pstapriv->asoc_list_cnt--; pstapriv->asoc_list_cnt--;
updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING);
...@@ -4312,9 +3985,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) ...@@ -4312,9 +3985,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
psta = NULL; psta = NULL;
} } else {
else
{
DBG_871X("rtw_del_sta(), sta has already been removed or never been added\n"); DBG_871X("rtw_del_sta(), sta has already been removed or never been added\n");
/* ret = -1; */ /* ret = -1; */
...@@ -4338,20 +4009,16 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par ...@@ -4338,20 +4009,16 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par
DBG_871X("rtw_ioctl_get_sta_info, sta_addr: " MAC_FMT "\n", MAC_ARG(param_ex->sta_addr)); DBG_871X("rtw_ioctl_get_sta_info, sta_addr: " MAC_FMT "\n", MAC_ARG(param_ex->sta_addr));
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
{
return -EINVAL; return -EINVAL;
}
if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff && if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff &&
param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff && param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff &&
param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) {
{
return -EINVAL; return -EINVAL;
} }
psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr);
if (psta) if (psta) {
{
psta_data->aid = (u16)psta->aid; psta_data->aid = (u16)psta->aid;
psta_data->capability = psta->capability; psta_data->capability = psta->capability;
psta_data->flags = psta->flags; psta_data->flags = psta->flags;
...@@ -4384,9 +4051,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par ...@@ -4384,9 +4051,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par
psta_data->tx_drops = psta->sta_stats.tx_drops; psta_data->tx_drops = psta->sta_stats.tx_drops;
} } else {
else
{
ret = -1; ret = -1;
} }
...@@ -4405,22 +4070,17 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) ...@@ -4405,22 +4070,17 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
DBG_871X("rtw_get_sta_wpaie, sta_addr: " MAC_FMT "\n", MAC_ARG(param->sta_addr)); DBG_871X("rtw_get_sta_wpaie, sta_addr: " MAC_FMT "\n", MAC_ARG(param->sta_addr));
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
{
return -EINVAL; return -EINVAL;
}
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
{
return -EINVAL; return -EINVAL;
} }
psta = rtw_get_stainfo(pstapriv, param->sta_addr); psta = rtw_get_stainfo(pstapriv, param->sta_addr);
if (psta) if (psta) {
{ if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) {
if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC))
{
int wpa_ie_len; int wpa_ie_len;
int copy_len; int copy_len;
...@@ -4431,15 +4091,11 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) ...@@ -4431,15 +4091,11 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
param->u.wpa_ie.len = copy_len; param->u.wpa_ie.len = copy_len;
memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len); memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len);
} } else {
else
{
/* ret = -1; */ /* ret = -1; */
DBG_871X("sta's wpa_ie is NONE\n"); DBG_871X("sta's wpa_ie is NONE\n");
} }
} } else {
else
{
ret = -1; ret = -1;
} }
...@@ -4464,14 +4120,12 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, ...@@ -4464,14 +4120,12 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
ie_len = len-12-2;/* 12 = param header, 2:no packed */ ie_len = len-12-2;/* 12 = param header, 2:no packed */
if (pmlmepriv->wps_beacon_ie) if (pmlmepriv->wps_beacon_ie) {
{
kfree(pmlmepriv->wps_beacon_ie); kfree(pmlmepriv->wps_beacon_ie);
pmlmepriv->wps_beacon_ie = NULL; pmlmepriv->wps_beacon_ie = NULL;
} }
if (ie_len>0) if (ie_len>0) {
{
pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len);
pmlmepriv->wps_beacon_ie_len = ie_len; pmlmepriv->wps_beacon_ie_len = ie_len;
if (pmlmepriv->wps_beacon_ie == NULL) { if (pmlmepriv->wps_beacon_ie == NULL) {
...@@ -4484,7 +4138,6 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, ...@@ -4484,7 +4138,6 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true);
pmlmeext->bstart_bss = true; pmlmeext->bstart_bss = true;
} }
...@@ -4507,14 +4160,12 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par ...@@ -4507,14 +4160,12 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par
ie_len = len-12-2;/* 12 = param header, 2:no packed */ ie_len = len-12-2;/* 12 = param header, 2:no packed */
if (pmlmepriv->wps_probe_resp_ie) if (pmlmepriv->wps_probe_resp_ie) {
{
kfree(pmlmepriv->wps_probe_resp_ie); kfree(pmlmepriv->wps_probe_resp_ie);
pmlmepriv->wps_probe_resp_ie = NULL; pmlmepriv->wps_probe_resp_ie = NULL;
} }
if (ie_len>0) if (ie_len>0) {
{
pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len);
pmlmepriv->wps_probe_resp_ie_len = ie_len; pmlmepriv->wps_probe_resp_ie_len = ie_len;
if (pmlmepriv->wps_probe_resp_ie == NULL) { if (pmlmepriv->wps_probe_resp_ie == NULL) {
...@@ -4544,14 +4195,12 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par ...@@ -4544,14 +4195,12 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par
ie_len = len-12-2;/* 12 = param header, 2:no packed */ ie_len = len-12-2;/* 12 = param header, 2:no packed */
if (pmlmepriv->wps_assoc_resp_ie) if (pmlmepriv->wps_assoc_resp_ie) {
{
kfree(pmlmepriv->wps_assoc_resp_ie); kfree(pmlmepriv->wps_assoc_resp_ie);
pmlmepriv->wps_assoc_resp_ie = NULL; pmlmepriv->wps_assoc_resp_ie = NULL;
} }
if (ie_len>0) if (ie_len>0) {
{
pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len);
pmlmepriv->wps_assoc_resp_ie_len = ie_len; pmlmepriv->wps_assoc_resp_ie_len = ie_len;
if (pmlmepriv->wps_assoc_resp_ie == NULL) { if (pmlmepriv->wps_assoc_resp_ie == NULL) {
...@@ -4632,8 +4281,7 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p ...@@ -4632,8 +4281,7 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
{
return -EINVAL; return -EINVAL;
} }
...@@ -4654,8 +4302,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para ...@@ -4654,8 +4302,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
{
return -EINVAL; return -EINVAL;
} }
...@@ -4705,14 +4352,12 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) ...@@ -4705,14 +4352,12 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
} }
param = (struct ieee_param *)rtw_malloc(p->length); param = (struct ieee_param *)rtw_malloc(p->length);
if (param == NULL) if (param == NULL) {
{
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
if (copy_from_user(param, p->pointer, p->length)) if (copy_from_user(param, p->pointer, p->length)) {
{
kfree(param); kfree(param);
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
...@@ -4720,8 +4365,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) ...@@ -4720,8 +4365,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
/* DBG_871X("%s, cmd =%d\n", __func__, param->cmd); */ /* DBG_871X("%s, cmd =%d\n", __func__, param->cmd); */
switch (param->cmd) switch (param->cmd) {
{
case RTL871X_HOSTAPD_FLUSH: case RTL871X_HOSTAPD_FLUSH:
ret = rtw_hostapd_sta_flush(dev); ret = rtw_hostapd_sta_flush(dev);
...@@ -4861,8 +4505,7 @@ static int rtw_wx_set_priv(struct net_device *dev, ...@@ -4861,8 +4505,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
/* dev->name, ext)); */ /* dev->name, ext)); */
#ifdef DEBUG_RTW_WX_SET_PRIV #ifdef DEBUG_RTW_WX_SET_PRIV
if (!(ext_dbg = vmalloc(len))) if (!(ext_dbg = vmalloc(len))) {
{
vfree(ext, len); vfree(ext, len);
return -ENOMEM; return -ENOMEM;
} }
...@@ -4871,8 +4514,7 @@ static int rtw_wx_set_priv(struct net_device *dev, ...@@ -4871,8 +4514,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
#endif #endif
/* added for wps2.0 @20110524 */ /* added for wps2.0 @20110524 */
if (dwrq->flags == 0x8766 && len > 8) if (dwrq->flags == 0x8766 && len > 8) {
{
u32 cp_sz; u32 cp_sz;
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
u8 *probereq_wpsie = ext; u8 *probereq_wpsie = ext;
...@@ -4880,12 +4522,10 @@ static int rtw_wx_set_priv(struct net_device *dev, ...@@ -4880,12 +4522,10 @@ static int rtw_wx_set_priv(struct net_device *dev,
u8 wps_oui[4]={0x0, 0x50, 0xf2, 0x04}; u8 wps_oui[4]={0x0, 0x50, 0xf2, 0x04};
if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) &&
(!memcmp(&probereq_wpsie[2], wps_oui, 4))) (!memcmp(&probereq_wpsie[2], wps_oui, 4))) {
{
cp_sz = probereq_wpsie_len>MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN:probereq_wpsie_len; cp_sz = probereq_wpsie_len>MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN:probereq_wpsie_len;
if (pmlmepriv->wps_probe_req_ie) if (pmlmepriv->wps_probe_req_ie) {
{
pmlmepriv->wps_probe_req_ie_len = 0; pmlmepriv->wps_probe_req_ie_len = 0;
kfree(pmlmepriv->wps_probe_req_ie); kfree(pmlmepriv->wps_probe_req_ie);
pmlmepriv->wps_probe_req_ie = NULL; pmlmepriv->wps_probe_req_ie = NULL;
...@@ -4909,8 +4549,7 @@ static int rtw_wx_set_priv(struct net_device *dev, ...@@ -4909,8 +4549,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
} }
if (len >= WEXT_CSCAN_HEADER_SIZE if (len >= WEXT_CSCAN_HEADER_SIZE
&& !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE) && !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) {
) {
ret = rtw_wx_set_scan(dev, info, awrq, ext); ret = rtw_wx_set_scan(dev, info, awrq, ext);
goto FREE_EXT; goto FREE_EXT;
} }
...@@ -4939,17 +4578,13 @@ static int rtw_pm_set(struct net_device *dev, ...@@ -4939,17 +4578,13 @@ static int rtw_pm_set(struct net_device *dev,
DBG_871X("[%s] extra = %s\n", __func__, extra); DBG_871X("[%s] extra = %s\n", __func__, extra);
if (!memcmp(extra, "lps =", 4)) if (!memcmp(extra, "lps =", 4)) {
{
sscanf(extra+4, "%u", &mode); sscanf(extra+4, "%u", &mode);
ret = rtw_pm_set_lps(padapter, mode); ret = rtw_pm_set_lps(padapter, mode);
} } else if (!memcmp(extra, "ips =", 4)) {
else if (!memcmp(extra, "ips =", 4))
{
sscanf(extra+4, "%u", &mode); sscanf(extra+4, "%u", &mode);
ret = rtw_pm_set_ips(padapter, mode); ret = rtw_pm_set_ips(padapter, mode);
} } else {
else {
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -5015,8 +4650,7 @@ static int rtw_widi_set_probe_request(struct net_device *dev, ...@@ -5015,8 +4650,7 @@ static int rtw_widi_set_probe_request(struct net_device *dev,
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
pbuf = rtw_malloc(sizeof(l2_msg_t)); pbuf = rtw_malloc(sizeof(l2_msg_t));
if (pbuf) if (pbuf) {
{
if (copy_from_user(pbuf, wrqu->data.pointer, wrqu->data.length)) if (copy_from_user(pbuf, wrqu->data.pointer, wrqu->data.length))
ret = -EFAULT; ret = -EFAULT;
/* memcpy(pbuf, wrqu->data.pointer, wrqu->data.length); */ /* memcpy(pbuf, wrqu->data.pointer, wrqu->data.length); */
...@@ -5067,17 +4701,12 @@ static int rtw_test( ...@@ -5067,17 +4701,12 @@ static int rtw_test(
} }
if (strcmp(pch, "bton") == 0) if (strcmp(pch, "bton") == 0)
{
rtw_btcoex_SetManualControl(padapter, false); rtw_btcoex_SetManualControl(padapter, false);
}
if (strcmp(pch, "btoff") == 0) if (strcmp(pch, "btoff") == 0)
{
rtw_btcoex_SetManualControl(padapter, true); rtw_btcoex_SetManualControl(padapter, true);
}
if (strcmp(pch, "h2c") == 0) if (strcmp(pch, "h2c") == 0) {
{
u8 param[8]; u8 param[8];
u8 count = 0; u8 count = 0;
u32 tmp; u32 tmp;
...@@ -5104,9 +4733,8 @@ static int rtw_test( ...@@ -5104,9 +4733,8 @@ static int rtw_test(
ret = rtw_hal_fill_h2c_cmd(padapter, param[0], count-1, &param[1]); ret = rtw_hal_fill_h2c_cmd(padapter, param[0], count-1, &param[1]);
pos = sprintf(extra, "H2C ID = 0x%02x content =", param[0]); pos = sprintf(extra, "H2C ID = 0x%02x content =", param[0]);
for (i = 1; i<count; i++) { for (i = 1; i<count; i++)
pos += sprintf(extra+pos, "%02x,", param[i]); pos += sprintf(extra+pos, "%02x,", param[i]);
}
extra[pos] = 0; extra[pos] = 0;
pos--; pos--;
pos += sprintf(extra+pos, " %s", ret == _FAIL?"FAIL":"OK"); pos += sprintf(extra+pos, " %s", ret == _FAIL?"FAIL":"OK");
...@@ -5118,8 +4746,7 @@ static int rtw_test( ...@@ -5118,8 +4746,7 @@ static int rtw_test(
return 0; return 0;
} }
static iw_handler rtw_handlers[] = static iw_handler rtw_handlers[] = {
{
NULL, /* SIOCSIWCOMMIT */ NULL, /* SIOCSIWCOMMIT */
rtw_wx_get_name, /* SIOCGIWNAME */ rtw_wx_get_name, /* SIOCGIWNAME */
dummy, /* SIOCSIWNWID */ dummy, /* SIOCSIWNWID */
...@@ -5293,8 +4920,7 @@ static const struct iw_priv_args rtw_private_args[] = { ...@@ -5293,8 +4920,7 @@ static const struct iw_priv_args rtw_private_args[] = {
#endif #endif
}; };
static iw_handler rtw_private_handler[] = static iw_handler rtw_private_handler[] = {
{
rtw_wx_write32, /* 0x00 */ rtw_wx_write32, /* 0x00 */
rtw_wx_read32, /* 0x01 */ rtw_wx_read32, /* 0x01 */
rtw_drvext_hdl, /* 0x02 */ rtw_drvext_hdl, /* 0x02 */
...@@ -5350,14 +4976,12 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) ...@@ -5350,14 +4976,12 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
int tmp_qual = 0; int tmp_qual = 0;
int tmp_noise = 0; int tmp_noise = 0;
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) != true) if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) != true) {
{
piwstats->qual.qual = 0; piwstats->qual.qual = 0;
piwstats->qual.level = 0; piwstats->qual.level = 0;
piwstats->qual.noise = 0; piwstats->qual.noise = 0;
/* DBG_871X("No link level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); */ /* DBG_871X("No link level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); */
} } else {
else {
#ifdef CONFIG_SIGNAL_DISPLAY_DBM #ifdef CONFIG_SIGNAL_DISPLAY_DBM
tmp_level = translate_percentage_to_dbm(padapter->recvpriv.signal_strength); tmp_level = translate_percentage_to_dbm(padapter->recvpriv.signal_strength);
#else #else
...@@ -5409,8 +5033,7 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) ...@@ -5409,8 +5033,7 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
return &padapter->iwstats; return &padapter->iwstats;
} }
struct iw_handler_def rtw_handlers_def = struct iw_handler_def rtw_handlers_def = {
{
.standard = rtw_handlers, .standard = rtw_handlers,
.num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler),
#if defined(CONFIG_WEXT_PRIV) #if defined(CONFIG_WEXT_PRIV)
...@@ -5523,8 +5146,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5523,8 +5146,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
} }
/* Watch out for sub-ioctls ! */ /* Watch out for sub-ioctls ! */
if (priv_args[k].cmd < SIOCDEVPRIVATE) if (priv_args[k].cmd < SIOCDEVPRIVATE) {
{
int j = -1; int j = -1;
/* Find the matching *real* ioctl */ /* Find the matching *real* ioctl */
...@@ -5554,12 +5176,10 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5554,12 +5176,10 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
/* If we have to set some data */ /* If we have to set some data */
if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) &&
(priv_args[k].set_args & IW_PRIV_SIZE_MASK)) (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) {
{
u8 *str; u8 *str;
switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) {
{
case IW_PRIV_TYPE_BYTE: case IW_PRIV_TYPE_BYTE:
/* Fetch args */ /* Fetch args */
count = 0; count = 0;
...@@ -5597,8 +5217,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5597,8 +5217,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
break; break;
case IW_PRIV_TYPE_CHAR: case IW_PRIV_TYPE_CHAR:
if (len > 0) if (len > 0) {
{
/* Size of the string to fetch */ /* Size of the string to fetch */
wdata.data.length = len; wdata.data.length = len;
if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK))
...@@ -5606,9 +5225,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5606,9 +5225,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
/* Fetch string */ /* Fetch string */
memcpy(buffer, ptr, wdata.data.length); memcpy(buffer, ptr, wdata.data.length);
} } else {
else
{
wdata.data.length = 1; wdata.data.length = 1;
buffer[0] = '\0'; buffer[0] = '\0';
} }
...@@ -5622,41 +5239,32 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5622,41 +5239,32 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
} }
if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) &&
(wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) {
{
DBG_8192C("%s: The command %s needs exactly %d argument(s)...\n", DBG_8192C("%s: The command %s needs exactly %d argument(s)...\n",
__func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK);
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} }
} /* if args to set */ } else { /* if args to set */
else
{
wdata.data.length = 0L; wdata.data.length = 0L;
} }
/* Those two tests are important. They define how the driver /* Those two tests are important. They define how the driver
* will have to handle the data */ * will have to handle the data */
if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) &&
((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) {
{
/* First case : all SET args fit within wrq */ /* First case : all SET args fit within wrq */
if (offset) if (offset)
wdata.mode = subcmd; wdata.mode = subcmd;
memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset);
} } else {
else
{
if ((priv_args[k].set_args == 0) && if ((priv_args[k].set_args == 0) &&
(priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) &&
(get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) {
{
/* Second case : no SET args, GET args fit within wrq */ /* Second case : no SET args, GET args fit within wrq */
if (offset) if (offset)
wdata.mode = subcmd; wdata.mode = subcmd;
} } else {
else
{
/* Third case : args won't fit in wrq, or variable number of args */ /* Third case : args won't fit in wrq, or variable number of args */
if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) {
err = -EFAULT; err = -EFAULT;
...@@ -5670,8 +5278,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5670,8 +5278,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
input = NULL; input = NULL;
extra_size = 0; extra_size = 0;
if (IW_IS_SET(priv_args[k].cmd)) if (IW_IS_SET(priv_args[k].cmd)) {
{
/* Size of set arguments */ /* Size of set arguments */
extra_size = get_priv_size(priv_args[k].set_args); extra_size = get_priv_size(priv_args[k].set_args);
...@@ -5701,8 +5308,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5701,8 +5308,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
/* If we have to get some data */ /* If we have to get some data */
if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) &&
(priv_args[k].get_args & IW_PRIV_SIZE_MASK)) (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) {
{
int j; int j;
int n = 0; /* number of args */ int n = 0; /* number of args */
u8 str[20] = {0}; u8 str[20] = {0};
...@@ -5720,12 +5326,10 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5720,12 +5326,10 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
goto exit; goto exit;
} }
switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) {
{
case IW_PRIV_TYPE_BYTE: case IW_PRIV_TYPE_BYTE:
/* Display args */ /* Display args */
for (j = 0; j < n; j++) for (j = 0; j < n; j++) {
{
sprintf(str, "%d ", extra[j]); sprintf(str, "%d ", extra[j]);
len = strlen(str); len = strlen(str);
output_len = strlen(output); output_len = strlen(output);
...@@ -5739,8 +5343,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5739,8 +5343,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
case IW_PRIV_TYPE_INT: case IW_PRIV_TYPE_INT:
/* Display args */ /* Display args */
for (j = 0; j < n; j++) for (j = 0; j < n; j++) {
{
sprintf(str, "%d ", ((__s32*)extra)[j]); sprintf(str, "%d ", ((__s32*)extra)[j]);
len = strlen(str); len = strlen(str);
output_len = strlen(output); output_len = strlen(output);
...@@ -5769,9 +5372,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ ...@@ -5769,9 +5372,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
err = -EFAULT; err = -EFAULT;
goto exit; goto exit;
} }
} /* if args to set */ } else { /* if args to set */
else
{
wrq_data->data.length = 0; wrq_data->data.length = 0;
} }
...@@ -5788,8 +5389,7 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -5788,8 +5389,7 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
struct iwreq *wrq = (struct iwreq *)rq; struct iwreq *wrq = (struct iwreq *)rq;
int ret = 0; int ret = 0;
switch (cmd) switch (cmd) {
{
case RTL_IOCTL_WPA_SUPPLICANT: case RTL_IOCTL_WPA_SUPPLICANT:
ret = wpa_supplicant_ioctl(dev, &wrq->u.data); ret = wpa_supplicant_ioctl(dev, &wrq->u.data);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment