rtl8188eu: Dix checkpatch errors in core/rtw_ieee80211.c

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
Larry Finger 2013-07-28 18:59:03 -05:00
parent 7e4cdda1c0
commit a96e65934d

View file

@ -51,26 +51,30 @@ u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 };
/* for adhoc-master to generate ie and provide supported-rate to fw */
/* */
static u8 WIFI_CCKRATES[] =
{(IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK),
static u8 WIFI_CCKRATES[] = {
(IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK),
(IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK),
(IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK),
(IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)};
(IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)
};
static u8 WIFI_OFDMRATES[] =
{(IEEE80211_OFDM_RATE_6MB),
static u8 WIFI_OFDMRATES[] = {
(IEEE80211_OFDM_RATE_6MB),
(IEEE80211_OFDM_RATE_9MB),
(IEEE80211_OFDM_RATE_12MB),
(IEEE80211_OFDM_RATE_18MB),
(IEEE80211_OFDM_RATE_24MB),
IEEE80211_OFDM_RATE_36MB,
IEEE80211_OFDM_RATE_48MB,
IEEE80211_OFDM_RATE_54MB};
IEEE80211_OFDM_RATE_54MB
};
int rtw_get_bit_value_from_ieee_value(u8 val)
{
unsigned char dot11_rate_table[]={2,4,11,22,12,18,24,36,48,72,96,108,0}; /* last element must be zero!! */
unsigned char dot11_rate_table[] = {
2, 4, 11, 22, 12, 18, 24, 36, 48,
72, 96, 108, 0}; /* last element must be zero!! */
int i = 0;
while (dot11_rate_table[i] != 0) {
@ -85,14 +89,12 @@ uint rtw_is_cckrates_included(u8 *rate)
{
u32 i = 0;
while (rate[i]!=0)
{
while (rate[i] != 0) {
if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
(((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
return true;
i++;
}
return false;
}
@ -100,32 +102,24 @@ uint rtw_is_cckratesonly_included(u8 *rate)
{
u32 i = 0;
while (rate[i]!=0)
{
while (rate[i] != 0) {
if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
(((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
return false;
i++;
}
return true;
}
int rtw_check_network_type(unsigned char *rate, int ratelen, int channel)
{
if (channel > 14)
{
if (channel > 14) {
if ((rtw_is_cckrates_included(rate)) == true)
return WIRELESS_INVALID;
else
return WIRELESS_11A;
}
else /* could be pure B, pure G, or B/G */
{
} else { /* could be pure B, pure G, or B/G */
if ((rtw_is_cckratesonly_included(rate)) == true)
return WIRELESS_11B;
else if ((rtw_is_cckrates_included(rate)) == true)
@ -133,7 +127,6 @@ int rtw_check_network_type(unsigned char *rate, int ratelen, int channel)
else
return WIRELESS_11G;
}
}
u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source,
@ -141,7 +134,7 @@ u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *sourc
{
_rtw_memcpy((void *)pbuf, (void *)source, len);
*frlen = *frlen + len;
return (pbuf + len);
return pbuf + len;
}
/* rtw_set_ie will update frame length */
@ -164,7 +157,7 @@ _func_enter_;
*frlen = *frlen + (len + 2);
return (pbuf + len + 2);
return pbuf + len + 2;
_func_exit_;
}
@ -237,15 +230,11 @@ _func_enter_;
p = pbuf;
i = 0;
*len = 0;
while (1)
{
if (*p == index)
{
while (1) {
if (*p == index) {
*len = *(p + 1);
return (p);
}
else
{
return p;
} else {
tmp = *(p + 1);
p += (tmp + 2);
i += (tmp + 2);
@ -283,11 +272,8 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u
cnt = 0;
while (cnt<in_len)
{
if (eid == in_ie[cnt]
&& ( !oui || _rtw_memcmp(&in_ie[cnt+2], oui, oui_len) == true))
{
while (cnt < in_len) {
if (eid == in_ie[cnt] && (!oui || _rtw_memcmp(&in_ie[cnt+2], oui, oui_len))) {
target_ie = &in_ie[cnt];
if (ie)
@ -297,14 +283,10 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u
*ielen = in_ie[cnt+1]+2;
break;
}
else
{
} else {
cnt += in_ie[cnt+1]+2; /* goto next */
}
}
return target_ie;
}
@ -361,19 +343,16 @@ _func_enter_;
_rtw_memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
switch (mode)
{
switch (mode) {
case WIRELESS_11B:
_rtw_memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
break;
case WIRELESS_11G:
case WIRELESS_11A:
case WIRELESS_11_5N:
case WIRELESS_11A_5N:/* Todo: no basic rate for ofdm ? */
_rtw_memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
break;
case WIRELESS_11BG:
case WIRELESS_11G_24N:
case WIRELESS_11_24N:
@ -381,7 +360,6 @@ _func_enter_;
_rtw_memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
_rtw_memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
break;
}
_func_exit_;
}
@ -390,14 +368,11 @@ uint rtw_get_rateset_len(u8 *rateset)
{
uint i = 0;
_func_enter_;
while (1)
{
while (1) {
if ((rateset[i]) == 0)
break;
if (i > 12)
break;
i++;
}
_func_exit_;
@ -440,15 +415,12 @@ _func_enter_;
ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz);
/* supported rates */
if (pregistrypriv->wireless_mode == WIRELESS_11ABGN)
{
if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) {
if (pdev_network->Configuration.DSConfig > 14)
wireless_mode = WIRELESS_11A_5N;
else
wireless_mode = WIRELESS_11BG_24N;
}
else
{
} else {
wireless_mode = pregistrypriv->wireless_mode;
}
@ -456,40 +428,24 @@ _func_enter_;
rateLen = rtw_get_rateset_len(pdev_network->SupportedRates);
if (rateLen > 8)
{
if (rateLen > 8) {
ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz);
/* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */
}
else
{
} else {
ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz);
}
/* DS parameter set */
ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz);
/* IBSS Parameter Set */
ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz);
if (rateLen > 8)
{
ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz);
}
/* HT Cap. */
if (((pregistrypriv->wireless_mode&WIRELESS_11_5N)||(pregistrypriv->wireless_mode&WIRELESS_11_24N))
&& (pregistrypriv->ht_enable==true))
{
/* todo: */
}
_func_exit_;
/* return _SUCCESS; */
return sz;
}
@ -502,17 +458,13 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
u8 *pbuf = pie;
int limit_new = limit;
while (1)
{
while (1) {
pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new);
if (pbuf) {
/* check if oui matches... */
if (_rtw_memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type)) == false) {
if (_rtw_memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type)) == false)
goto check_next_ie;
}
/* check version... */
_rtw_memcpy((u8 *)&le_tmp, (pbuf + 6), sizeof(val16));
@ -520,40 +472,27 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
val16 = le16_to_cpu(le_tmp);
if (val16 != 0x0001)
goto check_next_ie;
*wpa_ie_len = *(pbuf + 1);
return pbuf;
}
else {
} else {
*wpa_ie_len = 0;
return NULL;
}
check_next_ie:
limit_new = limit - (pbuf - pie) - 2 - len;
if (limit_new <= 0)
break;
pbuf += (2 + len);
}
*wpa_ie_len = 0;
return NULL;
}
unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit)
{
return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
}
int rtw_get_wpa_cipher_suite(u8 *s)
@ -604,9 +543,7 @@ int rtw_parse_wpa_ie(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) ||
(_rtw_memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != true))
{
return _FAIL;
}
pos = wpa_ie;
@ -616,25 +553,16 @@ int rtw_parse_wpa_ie(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
/* group_cipher */
if (left >= WPA_SELECTOR_LEN) {
*group_cipher = rtw_get_wpa_cipher_suite(pos);
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
}
else if (left > 0)
{
} else if (left > 0) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left));
return _FAIL;
}
/* pairwise_cipher */
if (left >= 2)
{
/* count = le16_to_cpu(*(u16*)pos); */
if (left >= 2) {
count = RTW_GET_LE16(pos);
pos += 2;
left -= 2;
@ -645,17 +573,13 @@ int rtw_parse_wpa_ie(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
return _FAIL;
}
for (i = 0; i < count; i++)
{
for (i = 0; i < count; i++) {
*pairwise_cipher |= rtw_get_wpa_cipher_suite(pos);
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
}
}
else if (left == 1)
{
} else if (left == 1) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__));
return _FAIL;
}
@ -671,7 +595,6 @@ int rtw_parse_wpa_ie(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
}
return ret;
}
int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
@ -688,9 +611,7 @@ int rtw_parse_wpa2_ie(u8* rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2)))
{
return _FAIL;
}
pos = rsn_ie;
pos += 4;
@ -698,7 +619,6 @@ int rtw_parse_wpa2_ie(u8* rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
/* group_cipher */
if (left >= RSN_SELECTOR_LEN) {
*group_cipher = rtw_get_wpa2_cipher_suite(pos);
pos += RSN_SELECTOR_LEN;
@ -710,9 +630,7 @@ int rtw_parse_wpa2_ie(u8* rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
}
/* pairwise_cipher */
if (left >= 2)
{
/* count = le16_to_cpu(*(u16*)pos); */
if (left >= 2) {
count = RTW_GET_LE16(pos);
pos += 2;
left -= 2;
@ -723,17 +641,14 @@ int rtw_parse_wpa2_ie(u8* rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
return _FAIL;
}
for (i = 0; i < count; i++)
{
for (i = 0; i < count; i++) {
*pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos);
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
}
}
else if (left == 1)
{
} else if (left == 1) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__));
return _FAIL;
@ -748,9 +663,7 @@ int rtw_parse_wpa2_ie(u8* rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
}
}
}
return ret;
}
int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len)
@ -767,19 +680,20 @@ _func_enter_;
sec_idx = 0;
while (cnt<in_len)
{
while (cnt < in_len) {
authmode = in_ie[cnt];
if ((authmode==_WPA_IE_ID_)&&(_rtw_memcmp(&in_ie[cnt+2], &wpa_oui[0],4)==true))
{
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n rtw_get_wpa_ie: sec_idx=%d in_ie[cnt+1]+2=%d\n",sec_idx,in_ie[cnt+1]+2));
if ((authmode == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n",
sec_idx, in_ie[cnt+1]+2));
if (wpa_ie) {
_rtw_memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt+1]+2);
for (i=0;i<(in_ie[cnt+1]+2);i=i+8){
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",
for (i = 0; i < (in_ie[cnt+1]+2); i += 8) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",
wpa_ie[i], wpa_ie[i+1], wpa_ie[i+2], wpa_ie[i+3], wpa_ie[i+4],
wpa_ie[i+5], wpa_ie[i+6], wpa_ie[i+7]));
}
@ -787,18 +701,18 @@ _func_enter_;
*wpa_len = in_ie[cnt+1]+2;
cnt += in_ie[cnt+1]+2; /* get next */
}
else
{
if (authmode==_WPA2_IE_ID_)
{
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n get_rsn_ie: sec_idx=%d in_ie[cnt+1]+2=%d\n",sec_idx,in_ie[cnt+1]+2));
} else {
if (authmode == _WPA2_IE_ID_) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n",
sec_idx, in_ie[cnt+1]+2));
if (rsn_ie) {
_rtw_memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt+1]+2);
for (i=0;i<(in_ie[cnt+1]+2);i=i+8){
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",
for (i = 0; i < (in_ie[cnt+1]+2); i += 8) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",
rsn_ie[i], rsn_ie[i+1], rsn_ie[i+2], rsn_ie[i+3], rsn_ie[i+4],
rsn_ie[i+5], rsn_ie[i+6], rsn_ie[i+7]));
}
@ -806,19 +720,15 @@ _func_enter_;
*rsn_len = in_ie[cnt+1]+2;
cnt += in_ie[cnt+1]+2; /* get next */
}
else
{
} else {
cnt += in_ie[cnt+1]+2; /* get next */
}
}
}
_func_exit_;
return (*rsn_len+*wpa_len);
return *rsn_len + *wpa_len;
}
u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen)
@ -826,13 +736,12 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen)
u8 match = false;
u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
if (ie_ptr == NULL) return match;
if (ie_ptr == NULL)
return match;
eid = ie_ptr[0];
if ((eid==_WPA_IE_ID_)&&(_rtw_memcmp(&ie_ptr[2], wps_oui, 4)==true))
{
/* DBG_88E("==> found WPS_IE.....\n"); */
if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&ie_ptr[2], wps_oui, 4))) {
*wps_ielen = ie_ptr[1]+2;
match = true;
}
@ -862,12 +771,10 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
cnt = 0;
while (cnt<in_len)
{
while (cnt < in_len) {
eid = in_ie[cnt];
if ((eid==_WPA_IE_ID_)&&(_rtw_memcmp(&in_ie[cnt+2], wps_oui, 4)==true))
{
if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], wps_oui, 4))) {
wpsie_ptr = &in_ie[cnt];
if (wps_ie)
@ -879,14 +786,10 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
cnt += in_ie[cnt+1]+2;
break;
}
else
{
} else {
cnt += in_ie[cnt+1]+2; /* goto next */
}
}
return wpsie_ptr;
}
@ -911,40 +814,28 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_att
if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) ||
(_rtw_memcmp(wps_ie + 2, wps_oui , 4) != true))
{
return attr_ptr;
}
/* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */
attr_ptr = wps_ie + 6; /* goto first attr */
while (attr_ptr - wps_ie < wps_ielen)
{
while (attr_ptr - wps_ie < wps_ielen) {
/* 4 = 2(Attribute ID) + 2(Length) */
u16 attr_id = RTW_GET_BE16(attr_ptr);
u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2);
u16 attr_len = attr_data_len + 4;
/* DBG_88E("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
if ( attr_id == target_attr_id )
{
if (attr_id == target_attr_id) {
target_attr_ptr = attr_ptr;
if (buf_attr)
_rtw_memcpy(buf_attr, attr_ptr, attr_len);
if (len_attr)
*len_attr = attr_len;
break;
}
else
{
} else {
attr_ptr += attr_len; /* goto next */
}
}
return target_attr_ptr;
}
@ -968,8 +859,7 @@ u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8
attr_ptr = rtw_get_wps_attr(wps_ie, wps_ielen, target_attr_id, NULL, &attr_len);
if (attr_ptr && attr_len)
{
if (attr_ptr && attr_len) {
if (buf_content)
_rtw_memcpy(buf_content, attr_ptr+4, attr_len-4);
@ -993,8 +883,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
* sub-type. */
if (elen < 4) {
if (show_errors) {
DBG_88E("short vendor specific "
"information element ignored (len=%lu)\n",
DBG_88E("short vendor specific information element ignored (len=%lu)\n",
(unsigned long) elen);
}
return -1;
@ -1014,9 +903,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
break;
case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */
if (elen < 5) {
DBG_88E("short WME "
"information element ignored "
"(len=%lu)\n",
DBG_88E("short WME information element ignored (len=%lu)\n",
(unsigned long) elen);
return -1;
}
@ -1031,9 +918,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
elems->wme_tspec_len = elen;
break;
default:
DBG_88E("unknown WME "
"information element ignored "
"(subtype=%d len=%lu)\n",
DBG_88E("unknown WME information element ignored (subtype=%d len=%lu)\n",
pos[4], (unsigned long) elen);
return -1;
}
@ -1044,9 +929,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
elems->wps_ie_len = elen;
break;
default:
DBG_88E("Unknown Microsoft "
"information element ignored "
"(type=%d len=%lu)\n",
DBG_88E("Unknown Microsoft information element ignored (type=%d len=%lu)\n",
pos[3], (unsigned long) elen);
return -1;
}
@ -1059,24 +942,17 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
elems->vendor_ht_cap_len = elen;
break;
default:
DBG_88E("Unknown Broadcom "
"information element ignored "
"(type=%d len=%lu)\n",
DBG_88E("Unknown Broadcom information element ignored (type=%d len=%lu)\n",
pos[3], (unsigned long) elen);
return -1;
}
break;
default:
DBG_88E("unknown vendor specific information "
"element ignored (vendor OUI %02x:%02x:%02x "
"len=%lu)\n",
DBG_88E("unknown vendor specific information element ignored (vendor OUI %02x:%02x:%02x len=%lu)\n",
pos[0], pos[1], pos[2], (unsigned long) elen);
return -1;
}
return 0;
}
/**
@ -1106,9 +982,7 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
if (elen > left) {
if (show_errors) {
DBG_88E("IEEE 802.11 element "
"parse failed (id=%d elen=%d "
"left=%lu)\n",
DBG_88E("IEEE 802.11 element parse failed (id=%d elen=%d left=%lu)\n",
id, elen, (unsigned long) left);
}
return ParseFailed;
@ -1156,9 +1030,7 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
elems->ext_supp_rates_len = elen;
break;
case WLAN_EID_VENDOR_SPECIFIC:
if (rtw_ieee802_11_parse_vendor_specific(pos, elen,
elems,
show_errors))
if (rtw_ieee802_11_parse_vendor_specific(pos, elen, elems, show_errors))
unknown++;
break;
case WLAN_EID_RSN:
@ -1197,21 +1069,16 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
unknown++;
if (!show_errors)
break;
DBG_88E("IEEE 802.11 element parse "
"ignored unknown element (id=%d elen=%d)\n",
DBG_88E("IEEE 802.11 element parse ignored unknown element (id=%d elen=%d)\n",
id, elen);
break;
}
left -= elen;
pos += elen;
}
if (left)
return ParseFailed;
return unknown ? ParseUnknown : ParseOK;
}
u8 key_char2num(u8 ch)
@ -1228,39 +1095,34 @@ u8 key_char2num(u8 ch)
u8 str_2char2num(u8 hch, u8 lch)
{
return ((key_char2num(hch) * 10 ) + key_char2num(lch));
return (key_char2num(hch) * 10) + key_char2num(lch);
}
u8 key_2char2num(u8 hch, u8 lch)
{
return ((key_char2num(hch) << 4) | key_char2num(lch));
return (key_char2num(hch) << 4) | key_char2num(lch);
}
void rtw_macaddr_cfg(u8 *mac_addr)
{
u8 mac[ETH_ALEN];
if (mac_addr == NULL) return;
if (mac_addr == NULL)
return;
if ( rtw_initmac )
{ /* Users specify the mac address */
if (rtw_initmac) { /* Users specify the mac address */
int jj, kk;
for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
{
mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]);
}
_rtw_memcpy(mac_addr, mac, ETH_ALEN);
}
else
{ /* Use the mac address stored in the Efuse */
} else { /* Use the mac address stored in the Efuse */
_rtw_memcpy(mac, mac_addr, ETH_ALEN);
}
if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) &&
(mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
((mac[0] == 0x0) && (mac[1] == 0x0) && (mac[2] == 0x0) &&
(mac[3]==0x0) && (mac[4]==0x0) &&(mac[5]==0x0)))
{
(mac[3] == 0x0) && (mac[4] == 0x0) && (mac[5] == 0x0))) {
mac[0] = 0x00;
mac[1] = 0xe0;
mac[2] = 0x4c;
@ -1275,7 +1137,8 @@ void rtw_macaddr_cfg(u8 *mac_addr)
DBG_88E("rtw_macaddr_cfg MAC Address = %pM\n", (mac_addr));
}
void dump_ies(u8 *buf, u32 buf_len) {
void dump_ies(u8 *buf, u32 buf_len)
{
u8 *pos = (u8 *)buf;
u8 id, len;
@ -1293,11 +1156,11 @@ void dump_ies(u8 *buf, u32 buf_len) {
}
}
void dump_wps_ie(u8 *ie, u32 ie_len) {
void dump_wps_ie(u8 *ie, u32 ie_len)
{
u8 *pos = (u8 *)ie;
u16 id;
u16 len;
u8 *wps_ie;
uint wps_ielen;
@ -1309,19 +1172,17 @@ void dump_wps_ie(u8 *ie, u32 ie_len) {
while (pos-ie < ie_len) {
id = RTW_GET_BE16(pos);
len = RTW_GET_BE16(pos + 2);
DBG_88E("%s ID:0x%04x, LEN:%u\n", __func__, id, len);
pos += (4+len);
}
}
#ifdef CONFIG_P2P
void dump_p2p_ie(u8 *ie, u32 ie_len) {
void dump_p2p_ie(u8 *ie, u32 ie_len)
{
u8 *pos = (u8 *)ie;
u8 id;
u16 len;
u8 *p2p_ie;
uint p2p_ielen;
@ -1333,9 +1194,7 @@ void dump_p2p_ie(u8 *ie, u32 ie_len) {
while (pos-ie < ie_len) {
id = *pos;
len = RTW_GET_LE16(pos+1);
DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len);
pos += (3+len);
}
}
@ -1358,40 +1217,25 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen)
if (p2p_ielen != NULL)
*p2p_ielen = 0;
while (cnt<in_len)
{
while (cnt < in_len) {
eid = in_ie[cnt];
if ((in_len < 0) || (cnt > MAX_IE_SZ)) {
dump_stack();
return NULL;
}
if ( ( eid == _VENDOR_SPECIFIC_IE_ ) && ( _rtw_memcmp( &in_ie[cnt+2], p2p_oui, 4) == true ) )
{
if ((eid == _VENDOR_SPECIFIC_IE_) && (_rtw_memcmp(&in_ie[cnt+2], p2p_oui, 4) == true)) {
p2p_ie_ptr = in_ie + cnt;
if (p2p_ie != NULL)
{
_rtw_memcpy(p2p_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
}
if (p2p_ielen != NULL)
{
*p2p_ielen = in_ie[cnt + 1] + 2;
}
return p2p_ie_ptr;
break;
}
else
{
} else {
cnt += in_ie[cnt + 1] + 2; /* goto next */
}
}
return NULL;
}
/**
@ -1415,40 +1259,29 @@ u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_attr
if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) ||
(_rtw_memcmp(p2p_ie + 2, p2p_oui , 4) != true))
{
return attr_ptr;
}
/* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */
attr_ptr = p2p_ie + 6; /* goto first attr */
while (attr_ptr - p2p_ie < p2p_ielen)
{
while (attr_ptr - p2p_ie < p2p_ielen) {
/* 3 = 1(Attribute ID) + 2(Length) */
u8 attr_id = *attr_ptr;
u16 attr_data_len = RTW_GET_LE16(attr_ptr + 1);
u16 attr_len = attr_data_len + 3;
/* DBG_88E("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
if ( attr_id == target_attr_id )
{
if (attr_id == target_attr_id) {
target_attr_ptr = attr_ptr;
if (buf_attr)
_rtw_memcpy(buf_attr, attr_ptr, attr_len);
if (len_attr)
*len_attr = attr_len;
break;
}
else
{
} else {
attr_ptr += attr_len; /* goto next */
}
}
return target_attr_ptr;
}
@ -1472,8 +1305,7 @@ u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *
attr_ptr = rtw_get_p2p_attr(p2p_ie, p2p_ielen, target_attr_id, NULL, &attr_len);
if (attr_ptr && attr_len)
{
if (attr_ptr && attr_len) {
if (buf_content)
_rtw_memcpy(buf_content, attr_ptr+3, attr_len-3);
@ -1512,8 +1344,7 @@ static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id)
while (1) {
target_attr = rtw_get_p2p_attr(ie, ielen, attr_id, NULL, &target_attr_len);
if (target_attr && target_attr_len)
{
if (target_attr && target_attr_len) {
u8 *next_attr = target_attr+target_attr_len;
uint remain_len = ielen-(next_attr-ie);
@ -1522,13 +1353,10 @@ static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id)
_rtw_memset(target_attr+remain_len, 0, target_attr_len);
*(ie+1) -= target_attr_len;
ielen -= target_attr_len;
}
else
{
} else {
break;
}
}
return ielen;
}
@ -1538,11 +1366,10 @@ void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, u8 attr_id)
uint p2p_ielen, p2p_ielen_ori;
int cnt;
if ( (p2p_ie=rtw_get_p2p_ie(bss_ex->IEs+_FIXED_IE_LENGTH_, bss_ex->IELength-_FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori)) )
{
p2p_ie = rtw_get_p2p_ie(bss_ex->IEs+_FIXED_IE_LENGTH_, bss_ex->IELength-_FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori);
if (p2p_ie) {
p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id);
if (p2p_ielen != p2p_ielen_ori) {
u8 *next_ie_ori = p2p_ie+p2p_ielen_ori;
u8 *next_ie = p2p_ie+p2p_ielen;
uint remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs);
@ -1611,7 +1438,6 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
if (pbuf && (wpa_ielen > 0)) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen));
if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) {
pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher;
pnetwork->BcnInfo.group_cipher = group_cipher;
pnetwork->BcnInfo.is_8021x = is8021x;
@ -1620,7 +1446,6 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
ret = _SUCCESS;
}
} else {
pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen > 0)) {
@ -1704,8 +1529,7 @@ u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsign
{
u16 max_rate = 0;
if (rf_type == RF_1T1R)
{
if (rf_type == RF_1T1R) {
if (MCS_rate[0] & BIT(7))
max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650);
else if (MCS_rate[0] & BIT(6))
@ -1722,11 +1546,8 @@ u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsign
max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130);
else if (MCS_rate[0] & BIT(0))
max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65);
}
else
{
if (MCS_rate[1])
{
} else {
if (MCS_rate[1]) {
if (MCS_rate[1] & BIT(7))
max_rate = (bw_40MHz) ? ((short_GI_40) ? 3000 : 2700) : ((short_GI_20) ? 1444 : 1300);
else if (MCS_rate[1] & BIT(6))
@ -1743,9 +1564,7 @@ u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsign
max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260);
else if (MCS_rate[1] & BIT(0))
max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130);
}
else
{
} else {
if (MCS_rate[0] & BIT(7))
max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650);
else if (MCS_rate[0] & BIT(6))