Commit 9af36808 authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: rtl8723au: OnBeacon23a() tidy up code

Clean up the excessive if() levels at the end, and use struct
ieee80211_mgmt to calculate pointers passed on to check_assoc_AP23a()
Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9aac910a
...@@ -740,8 +740,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) ...@@ -740,8 +740,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
pie = mgmt->u.beacon.variable; pie = mgmt->u.beacon.variable;
pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable); pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable);
p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len); p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len);
if ((p != NULL) && (ielen > 0)) { if (p && ielen > 0) {
if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { if (p[1 + ielen] == 0x2D && p[2 + ielen] != 0x2D) {
/* Invalid value 0x2D is detected in Extended Supported /* Invalid value 0x2D is detected in Extended Supported
* Rates (ESR) IE. Try to fix the IE length to avoid * Rates (ESR) IE. Try to fix the IE length to avoid
* failed Beacon parsing. * failed Beacon parsing.
...@@ -750,7 +750,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) ...@@ -750,7 +750,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
"Beacon of BSSID: %pM. Fix the length of " "Beacon of BSSID: %pM. Fix the length of "
"ESR IE to avoid failed Beacon parsing.\n", "ESR IE to avoid failed Beacon parsing.\n",
mgmt->bssid); mgmt->bssid);
*(p + 1) = ielen - 1; p[1] = ielen - 1;
} }
} }
...@@ -759,93 +759,94 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) ...@@ -759,93 +759,94 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
return _SUCCESS; return _SUCCESS;
} }
if (ether_addr_equal(mgmt->bssid, if (!ether_addr_equal(mgmt->bssid,
get_my_bssid23a(&pmlmeinfo->network))){ get_my_bssid23a(&pmlmeinfo->network)))
if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { goto out;
/* we should update current network before auth,
or some IE is wrong */ if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
pbss = (struct wlan_bssid_ex *) /* we should update current network before auth,
kmalloc(sizeof(struct wlan_bssid_ex), or some IE is wrong */
GFP_ATOMIC); pbss = (struct wlan_bssid_ex *)
if (pbss) { kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
if (collect_bss_info23a(padapter, precv_frame, if (pbss) {
pbss) == _SUCCESS) { if (collect_bss_info23a(padapter, precv_frame, pbss) ==
update_network23a(&pmlmepriv->cur_network.network, pbss, padapter, true); _SUCCESS) {
rtw_get_bcn_info23a(&pmlmepriv->cur_network); update_network23a(
} &pmlmepriv->cur_network.network, pbss,
kfree(pbss); padapter, true);
rtw_get_bcn_info23a(&pmlmepriv->cur_network);
} }
kfree(pbss);
}
/* check the vendor of the assoc AP */ /* check the vendor of the assoc AP */
pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), pkt_len-sizeof(struct ieee80211_hdr_3addr)); pmlmeinfo->assoc_AP_vendor =
check_assoc_AP23a((u8 *)&mgmt->u.beacon, pkt_len -
offsetof(struct ieee80211_mgmt, u));
/* update TSF Value */ /* update TSF Value */
update_TSF23a(pmlmeext, pframe, pkt_len); update_TSF23a(pmlmeext, pframe, pkt_len);
/* start auth */ /* start auth */
start_clnt_auth23a(padapter); start_clnt_auth23a(padapter);
return _SUCCESS; return _SUCCESS;
} }
if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) &&
(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
if (psta) { if (psta) {
ret = rtw_check_bcn_info23a(padapter, mgmt, ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len);
pkt_len); if (!ret) {
if (!ret) { DBG_8723A_LEVEL(_drv_always_, "ap has changed, "
DBG_8723A_LEVEL(_drv_always_, "disconnect now\n");
"ap has changed, " receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535);
"disconnect now\n"); return _SUCCESS;
receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535); }
return _SUCCESS; /* update WMM, ERP in the beacon */
} /* todo: the timer is used instead of
/* update WMM, ERP in the beacon */ the number of the beacon received */
/* todo: the timer is used instead of if ((sta_rx_pkts(psta) & 0xf) == 0) {
the number of the beacon received */ /* DBG_8723A("update_bcn_info\n"); */
if ((sta_rx_pkts(psta) & 0xf) == 0) { update_beacon23a_info(padapter, pframe,
/* DBG_8723A("update_bcn_info\n"); */ pkt_len, psta);
update_beacon23a_info(padapter, pframe, }
pkt_len, psta); }
} } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
if (psta) {
/* update WMM, ERP in the beacon */
/* todo: the timer is used instead of the
number of the beacon received */
if ((sta_rx_pkts(psta) & 0xf) == 0) {
/* DBG_8723A("update_bcn_info\n"); */
update_beacon23a_info(padapter, pframe,
pkt_len, psta);
}
} else {
/* allocate a new CAM entry for IBSS station */
cam_idx = allocate_fw_sta_entry23a(padapter);
if (cam_idx == NUM_STA)
goto out;
/* get supported rate */
if (update_sta_support_rate23a(padapter, pie, pie_len,
cam_idx) == _FAIL) {
pmlmeinfo->FW_sta_info[cam_idx].status = 0;
goto out;
} }
} else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
if (psta) {
/* update WMM, ERP in the beacon */
/* todo: the timer is used instead of the
number of the beacon received */
if ((sta_rx_pkts(psta) & 0xf) == 0) {
/* DBG_8723A("update_bcn_info\n"); */
update_beacon23a_info(padapter, pframe,
pkt_len, psta);
}
} else {
/* allocate a new CAM entry for IBSS station */
cam_idx = allocate_fw_sta_entry23a(padapter);
if (cam_idx == NUM_STA)
goto _END_ONBEACON_;
/* get supported rate */
if (update_sta_support_rate23a(padapter, pie,
pie_len,
cam_idx) == _FAIL) {
pmlmeinfo->FW_sta_info[cam_idx].status = 0;
goto _END_ONBEACON_;
}
/* update TSF Value */ /* update TSF Value */
update_TSF23a(pmlmeext, pframe, pkt_len); update_TSF23a(pmlmeext, pframe, pkt_len);
/* report sta add event */ /* report sta add event */
report_add_sta_event23a(padapter, mgmt->sa, report_add_sta_event23a(padapter, mgmt->sa,
cam_idx); cam_idx);
}
} }
} }
_END_ONBEACON_: out:
return _SUCCESS; return _SUCCESS;
} }
......
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