Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+79 −78
Original line number Diff line number Diff line
@@ -740,8 +740,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
	pie = 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);
	if ((p != NULL) && (ielen > 0)) {
		if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) {
	if (p && ielen > 0) {
		if (p[1 + ielen] == 0x2D && p[2 + ielen] != 0x2D) {
			/* Invalid value 0x2D is detected in Extended Supported
			 * Rates (ESR) IE. Try to fix the IE length to avoid
			 * failed Beacon parsing.
@@ -750,7 +750,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
				  "Beacon of BSSID: %pM. Fix the length of "
				  "ESR IE to avoid failed Beacon parsing.\n",
				  mgmt->bssid);
			*(p + 1) = ielen - 1;
			p[1] = ielen - 1;
		}
	}

@@ -759,25 +759,30 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
		return _SUCCESS;
	}

	if (ether_addr_equal(mgmt->bssid,
			     get_my_bssid23a(&pmlmeinfo->network))){
	if (!ether_addr_equal(mgmt->bssid,
			      get_my_bssid23a(&pmlmeinfo->network)))
		goto out;

	if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
		/* we should update current network before auth,
		   or some IE is wrong */
		pbss = (struct wlan_bssid_ex *)
				kmalloc(sizeof(struct wlan_bssid_ex),
					GFP_ATOMIC);
			kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
		if (pbss) {
				if (collect_bss_info23a(padapter, precv_frame,
							pbss) == _SUCCESS) {
					update_network23a(&pmlmepriv->cur_network.network, pbss, padapter, true);
			if (collect_bss_info23a(padapter, precv_frame, pbss) ==
			    _SUCCESS) {
				update_network23a(
					&pmlmepriv->cur_network.network, pbss,
					padapter, true);
				rtw_get_bcn_info23a(&pmlmepriv->cur_network);
			}
			kfree(pbss);
		}

		/* 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_TSF23a(pmlmeext, pframe, pkt_len);
@@ -792,11 +797,9 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
	    (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
		psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
		if (psta) {
				ret = rtw_check_bcn_info23a(padapter, mgmt,
							    pkt_len);
			ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len);
			if (!ret) {
					DBG_8723A_LEVEL(_drv_always_,
							"ap has changed, "
				DBG_8723A_LEVEL(_drv_always_, "ap has changed, "
						"disconnect now\n");
				receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535);
				return _SUCCESS;
@@ -825,14 +828,13 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
			/* allocate a new CAM entry for IBSS station */
			cam_idx = allocate_fw_sta_entry23a(padapter);
			if (cam_idx == NUM_STA)
					goto _END_ONBEACON_;
				goto out;

			/* get supported rate */
				if (update_sta_support_rate23a(padapter, pie,
							       pie_len,
			if (update_sta_support_rate23a(padapter, pie, pie_len,
						       cam_idx) == _FAIL) {
				pmlmeinfo->FW_sta_info[cam_idx].status = 0;
					goto _END_ONBEACON_;
				goto out;
			}

			/* update TSF Value */
@@ -843,9 +845,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
						cam_idx);
		}
	}
	}

_END_ONBEACON_:
out:

	return _SUCCESS;
}