From: Rishik Yechuri <epicrishik@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Rishik Yechuri <rishik.yechuri.code@gmail.com>
Subject: [PATCH 01/10] staging: rtl8723bs: use struct ieee80211_hdr for header addresses
Date: Tue, 13 Oct 2026 15:15:29 -0500 [thread overview]
Message-ID: <20261013201538.43156-2-rishik.yechuri.code@gmail.com> (raw)
In-Reply-To: <20261013201538.43156-1-rishik.yechuri.code@gmail.com>
The driver defines GetAddr1Ptr() through GetAddr4Ptr() in wifi.h to
obtain pointers to the address fields of an IEEE 802.11 header by
adding hardcoded byte offsets to the frame buffer. This duplicates
struct ieee80211_hdr from <linux/ieee80211.h>, which describes the
same layout and is used throughout the wireless subsystem.
Replace each use of these macros with the corresponding addr1..addr4
member of struct ieee80211_hdr, and remove the macro definitions.
Several functions in rtw_mlme_ext.c already access the header through
struct ieee80211_hdr. This makes the remaining call sites consistent
with them.
Include <linux/ieee80211.h> directly in wifi.h, since the inline helpers
there now depend on struct ieee80211_hdr.
This is the first step towards replacing the driver's private 802.11
header macros with the generic helpers provided by the kernel.
No functional change intended.
Signed-off-by: Rishik Yechuri <rishik.yechuri.code@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 87 +++++++++++--------
drivers/staging/rtl8723bs/core/rtw_recv.c | 46 +++++-----
.../staging/rtl8723bs/core/rtw_wlan_util.c | 2 +-
drivers/staging/rtl8723bs/include/wifi.h | 43 +++++----
.../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 +-
5 files changed, 100 insertions(+), 81 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 511eccf5b..1349bd423 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -415,11 +415,12 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, union recv_frame *precv_frame)
{
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
if (ptable->func) {
/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
- if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
- !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
+ if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
+ !is_broadcast_ether_addr(hdr->addr1))
return;
ptable->func(padapter, precv_frame);
@@ -432,14 +433,15 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
struct mlme_handler *ptable;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
u8 *pframe = precv_frame->u.hdr.rx_data;
- struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe));
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
+ struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
if (GetFrameType(pframe) != WIFI_MGT_TYPE)
return;
/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
- if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
- !is_broadcast_ether_addr(GetAddr1Ptr(pframe))) {
+ if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
+ !is_broadcast_ether_addr(hdr->addr1)) {
return;
}
@@ -554,6 +556,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
uint len = precv_frame->u.hdr.len;
struct wlan_bssid_ex *pbss;
int ret = _SUCCESS;
@@ -574,7 +577,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
return _SUCCESS;
}
- if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) {
+ if (!memcmp(hdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) {
if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
/* we should update current network before auth, or some IE is wrong */
pbss = kmalloc_obj(*pbss, GFP_ATOMIC);
@@ -610,7 +613,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) &&
(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ psta = rtw_get_stainfo(pstapriv, hdr->addr2);
if (psta) {
ret = rtw_check_bcn_info(padapter, pframe, len);
if (!ret) {
@@ -628,7 +631,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
adaptive_early_32k(pmlmeext, pframe, len);
}
} else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ psta = rtw_get_stainfo(pstapriv, hdr->addr2);
if (psta) {
/* update WMM, ERP in the beacon */
/* todo: the timer is used instead of the number of the beacon received */
@@ -650,7 +653,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
update_TSF(pmlmeext, pframe, len);
/* report sta add event */
- report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx);
+ report_add_sta_event(padapter, hdr->addr2, cam_idx);
}
}
}
@@ -673,6 +676,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
uint len = precv_frame->u.hdr.len;
u8 offset = 0;
@@ -682,7 +686,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
if (len < WLAN_HDR_A3_LEN)
return _FAIL;
- sa = GetAddr2Ptr(pframe);
+ sa = hdr->addr2;
auth_mode = psecuritypriv->dot11_auth_algrthm;
@@ -930,6 +934,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
struct wlan_bssid_ex *cur = &(pmlmeinfo->network);
struct sta_priv *pstapriv = &padapter->stapriv;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
uint pkt_len = precv_frame->u.hdr.len;
if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
@@ -944,7 +949,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
if (pkt_len < sizeof(struct ieee80211_hdr_3addr) + ie_offset)
return _FAIL;
- pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ pstat = rtw_get_stainfo(pstapriv, hdr->addr2);
if (!pstat) {
status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA;
goto asoc_class2_error;
@@ -1302,7 +1307,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
asoc_class2_error:
- issue_deauth(padapter, GetAddr2Ptr(pframe), status);
+ issue_deauth(padapter, hdr->addr2, status);
return _FAIL;
@@ -1418,10 +1423,11 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
int ignore_received_deauth = 0;
/* check A3 */
- if (memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
+ if (memcmp(hdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
return _SUCCESS;
reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN));
@@ -1432,9 +1438,9 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
netdev_dbg(padapter->pnetdev,
"ap recv deauth reason code(%d) sta:%pM\n", reason,
- GetAddr2Ptr(pframe));
+ hdr->addr2);
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ psta = rtw_get_stainfo(pstapriv, hdr->addr2);
if (psta) {
u8 updated = false;
@@ -1470,11 +1476,11 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
netdev_dbg(padapter->pnetdev,
"sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
- reason, GetAddr3Ptr(pframe),
+ reason, hdr->addr3,
ignore_received_deauth);
if (ignore_received_deauth == 0)
- receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
+ receive_disconnect(padapter, hdr->addr3, reason);
pmlmepriv->link_detect_info.busy_traffic = false;
return _SUCCESS;
@@ -1487,9 +1493,10 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
/* check A3 */
- if (memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
+ if (memcmp(hdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))
return _SUCCESS;
reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN));
@@ -1500,9 +1507,9 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
netdev_dbg(padapter->pnetdev,
"ap recv disassoc reason code(%d) sta:%pM\n",
- reason, GetAddr2Ptr(pframe));
+ reason, hdr->addr2);
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ psta = rtw_get_stainfo(pstapriv, hdr->addr2);
if (psta) {
u8 updated = false;
@@ -1521,9 +1528,9 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
}
netdev_dbg(padapter->pnetdev,
"sta recv disassoc reason code(%d) sta:%pM\n",
- reason, GetAddr3Ptr(pframe));
+ reason, hdr->addr3);
- receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
+ receive_disconnect(padapter, hdr->addr3, reason);
pmlmepriv->link_detect_info.busy_traffic = false;
return _SUCCESS;
@@ -1539,11 +1546,12 @@ unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_fr
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
u8 *frame_body = (u8 *)(pframe + sizeof(struct ieee80211_hdr_3addr));
u8 category;
u8 action;
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ psta = rtw_get_stainfo(pstapriv, hdr->addr2);
if (!psta)
goto exit;
@@ -1579,17 +1587,18 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
struct sta_priv *pstapriv = &padapter->stapriv;
/* check RA matches or not */
- if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */
+ if (memcmp(myid(&(padapter->eeprompriv)), hdr->addr1, ETH_ALEN))/* for if1, sta/ap mode */
return _SUCCESS;
if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
return _SUCCESS;
- addr = GetAddr2Ptr(pframe);
+ addr = hdr->addr2;
psta = rtw_get_stainfo(pstapriv, addr);
if (!psta)
@@ -1742,11 +1751,12 @@ unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_
{
unsigned int ret = _FAIL;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
u8 category, action;
/* check RA matches or not */
- if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))
+ if (memcmp(myid(&(padapter->eeprompriv)), hdr->addr1, ETH_ALEN))
goto exit;
category = frame_body[0];
@@ -1770,11 +1780,12 @@ unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_
unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame)
{
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
u8 category, action;
/* check RA matches or not */
- if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))
+ if (memcmp(myid(&(padapter->eeprompriv)), hdr->addr1, ETH_ALEN))
goto exit;
category = frame_body[0];
@@ -1797,13 +1808,14 @@ unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame
unsigned int OnAction_sa_query(struct adapter *padapter, union recv_frame *precv_frame)
{
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
unsigned short tid;
switch (pframe[WLAN_HDR_A3_LEN + 1]) {
case 0: /* SA Query req */
memcpy(&tid, &pframe[WLAN_HDR_A3_LEN + 2], sizeof(unsigned short));
- issue_action_SA_Query(padapter, GetAddr2Ptr(pframe), 1, tid);
+ issue_action_SA_Query(padapter, hdr->addr2, 1, tid);
break;
case 1: /* SA Query rsp */
@@ -1924,13 +1936,13 @@ void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattri
void update_mgntframe_attrib_addr(struct adapter *padapter, struct xmit_frame *pmgntframe)
{
- u8 *pframe;
+ struct ieee80211_hdr *hdr;
struct pkt_attrib *pattrib = &pmgntframe->attrib;
- pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
+ hdr = (struct ieee80211_hdr *)(pmgntframe->buf_addr + TXDESC_OFFSET);
- memcpy(pattrib->ra, GetAddr1Ptr(pframe), ETH_ALEN);
- memcpy(pattrib->ta, GetAddr2Ptr(pframe), ETH_ALEN);
+ memcpy(pattrib->ra, hdr->addr1, ETH_ALEN);
+ memcpy(pattrib->ta, hdr->addr2, ETH_ALEN);
}
void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe)
@@ -2609,9 +2621,9 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i
fctrl = &(pwlanhdr->frame_control);
*(fctrl) = 0;
- memcpy(GetAddr1Ptr(pwlanhdr), pstat->hwaddr, ETH_ALEN);
- memcpy(GetAddr2Ptr(pwlanhdr), myid(&(padapter->eeprompriv)), ETH_ALEN);
- memcpy(GetAddr3Ptr(pwlanhdr), get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
+ memcpy(pwlanhdr->addr1, pstat->hwaddr, ETH_ALEN);
+ memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN);
+ memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq);
pmlmeext->mgnt_seq++;
@@ -3744,6 +3756,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str
u8 *p;
u16 val16, subtype;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
u32 packet_len = precv_frame->u.hdr.len;
u8 ie_offset;
struct registry_priv *pregistrypriv = &padapter->registrypriv;
@@ -3854,10 +3867,10 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str
if (val16 & BIT(0)) {
bssid->infrastructure_mode = NL80211_IFTYPE_STATION;
- memcpy(bssid->mac_address, GetAddr2Ptr(pframe), ETH_ALEN);
+ memcpy(bssid->mac_address, hdr->addr2, ETH_ALEN);
} else {
bssid->infrastructure_mode = NL80211_IFTYPE_ADHOC;
- memcpy(bssid->mac_address, GetAddr3Ptr(pframe), ETH_ALEN);
+ memcpy(bssid->mac_address, hdr->addr3, ETH_ALEN);
}
if (val16 & BIT(4))
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 381b3e29a..8f3c0552e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -673,6 +673,7 @@ static signed int sta2sta_data_frame(struct adapter *adapter, union recv_frame *
struct sta_info **psta)
{
u8 *ptr = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr;
signed int ret = _SUCCESS;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct sta_priv *pstapriv = &adapter->stapriv;
@@ -730,9 +731,9 @@ static signed int sta2sta_data_frame(struct adapter *adapter, union recv_frame *
}
} else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
- memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
- memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
- memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->dst, hdr->addr1, ETH_ALEN);
+ memcpy(pattrib->src, hdr->addr2, ETH_ALEN);
+ memcpy(pattrib->bssid, hdr->addr3, ETH_ALEN);
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
@@ -759,6 +760,7 @@ static signed int ap2sta_data_frame(struct adapter *adapter, union recv_frame *p
struct sta_info **psta)
{
u8 *ptr = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
signed int ret = _SUCCESS;
struct sta_priv *pstapriv = &adapter->stapriv;
@@ -812,9 +814,9 @@ static signed int ap2sta_data_frame(struct adapter *adapter, union recv_frame *p
} else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) &&
check_fwstate(pmlmepriv, _FW_LINKED)) {
- memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
- memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
- memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->dst, hdr->addr1, ETH_ALEN);
+ memcpy(pattrib->src, hdr->addr2, ETH_ALEN);
+ memcpy(pattrib->bssid, hdr->addr3, ETH_ALEN);
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
@@ -909,16 +911,17 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct sta_priv *pstapriv = &padapter->stapriv;
u8 *pframe = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
struct sta_info *psta = NULL;
if (GetFrameType(pframe) != WIFI_CTRL_TYPE)
return _FAIL;
/* receive the frames that ra(a1) is my address */
- if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN))
+ if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN))
return _FAIL;
- psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
+ psta = rtw_get_stainfo(pstapriv, hdr->addr2);
if (!psta)
return _FAIL;
@@ -1193,14 +1196,17 @@ static union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union re
static signed int validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame)
{
+ struct ieee80211_hdr *hdr;
struct sta_info *psta;
precv_frame = recvframe_chk_defrag(padapter, precv_frame);
if (!precv_frame)
return _SUCCESS;
+ hdr = (struct ieee80211_hdr *)precv_frame->u.hdr.rx_data;
+
/* for rx pkt statistics */
- psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->u.hdr.rx_data));
+ psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
if (!psta)
goto exit;
@@ -1214,12 +1220,10 @@ static signed int validate_recv_mgnt_frame(struct adapter *padapter, union recv_
psta->sta_stats.rx_probereq_pkts++;
break;
case WIFI_PROBERSP:
- if (!memcmp(padapter->eeprompriv.mac_addr,
- GetAddr1Ptr(precv_frame->u.hdr.rx_data),
- ETH_ALEN))
+ if (!memcmp(padapter->eeprompriv.mac_addr, hdr->addr1, ETH_ALEN))
psta->sta_stats.rx_probersp_pkts++;
- else if (is_broadcast_ether_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) ||
- is_multicast_ether_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)))
+ else if (is_broadcast_ether_addr(hdr->addr1) ||
+ is_multicast_ether_addr(hdr->addr1))
psta->sta_stats.rx_probersp_bm_pkts++;
else
psta->sta_stats.rx_probersp_uo_pkts++;
@@ -1239,6 +1243,7 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_f
u8 *psa, *pda, *pbssid;
struct sta_info *psta = NULL;
u8 *ptr = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct security_priv *psecuritypriv = &adapter->securitypriv;
signed int ret = _SUCCESS;
@@ -1278,8 +1283,8 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_f
break;
case 3:
- memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN);
- memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->ra, hdr->addr1, ETH_ALEN);
+ memcpy(pattrib->ta, hdr->addr2, ETH_ALEN);
ret = _FAIL;
break;
@@ -1344,6 +1349,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
u8 *ptr = precv_frame->u.hdr.rx_data;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)ptr;
u8 subtype;
subtype = GetFrameSubType(ptr); /* bit(7)~bit(2) */
@@ -1352,7 +1358,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED) &&
adapter->securitypriv.binstallBIPkey) {
/* unicast management frame decrypt */
- if (pattrib->privacy && !(is_multicast_ether_addr(GetAddr1Ptr(ptr))) &&
+ if (pattrib->privacy && !(is_multicast_ether_addr(hdr->addr1)) &&
(subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC || subtype == WIFI_ACTION)) {
u8 *mgmt_DATA;
u32 data_len = 0;
@@ -1362,8 +1368,8 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr);
/* set iv and icv length */
SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt);
- memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN);
- memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->ra, hdr->addr1, ETH_ALEN);
+ memcpy(pattrib->ta, hdr->addr2, ETH_ALEN);
/* actual management data frame body */
data_len = pattrib->pkt_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
mgmt_DATA = kzalloc(data_len, GFP_ATOMIC);
@@ -1381,7 +1387,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
/* remove the iv and icv length */
pattrib->pkt_len = pattrib->pkt_len - pattrib->iv_len - pattrib->icv_len;
kfree(mgmt_DATA);
- } else if (is_multicast_ether_addr(GetAddr1Ptr(ptr)) &&
+ } else if (is_multicast_ether_addr(hdr->addr1) &&
(subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC)) {
signed int BIP_ret = _SUCCESS;
/* verify BIP MME IE of broadcast/multicast de-auth/disassoc packet */
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 9feab9ab7..72607588d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1082,7 +1082,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0;
unsigned char *pbuf;
u32 wpa_ielen = 0;
- u8 *pbssid = GetAddr3Ptr(pframe);
+ u8 *pbssid = ((struct ieee80211_hdr *)pframe)->addr3;
struct HT_info_element *pht_info = NULL;
struct ieee80211_ht_cap *pht_cap = NULL;
u32 bcn_channel;
diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h
index 93cb83488..6c877c7ca 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -7,6 +7,8 @@
#ifndef _WIFI_H_
#define _WIFI_H_
+#include <linux/ieee80211.h>
+
#define WLAN_HDR_A3_LEN 24
#define WLAN_HDR_A3_QOS_LEN 26
@@ -180,47 +182,42 @@ enum {
#define GetAid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff)
-#define GetAddr1Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 4))
-
-#define GetAddr2Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 10))
-
-#define GetAddr3Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 16))
-
-#define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24))
-
static inline unsigned char *rtl8723bs_get_ra(unsigned char *pframe)
{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
unsigned char *ra;
- ra = GetAddr1Ptr(pframe);
+ ra = hdr->addr1;
return ra;
}
static inline unsigned char *get_ta(unsigned char *pframe)
{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
unsigned char *ta;
- ta = GetAddr2Ptr(pframe);
+ ta = hdr->addr2;
return ta;
}
static inline unsigned char *get_da(unsigned char *pframe)
{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
unsigned char *da;
unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
switch (to_fr_ds) {
case 0x00: /* ToDs = 0, FromDs = 0 */
- da = GetAddr1Ptr(pframe);
+ da = hdr->addr1;
break;
case 0x01: /* ToDs = 0, FromDs = 1 */
- da = GetAddr1Ptr(pframe);
+ da = hdr->addr1;
break;
case 0x02: /* ToDs = 1, FromDs = 0 */
- da = GetAddr3Ptr(pframe);
+ da = hdr->addr3;
break;
default: /* ToDs = 1, FromDs = 1 */
- da = GetAddr3Ptr(pframe);
+ da = hdr->addr3;
break;
}
@@ -229,21 +226,22 @@ static inline unsigned char *get_da(unsigned char *pframe)
static inline unsigned char *get_sa(unsigned char *pframe)
{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
unsigned char *sa;
unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
switch (to_fr_ds) {
case 0x00: /* ToDs = 0, FromDs = 0 */
- sa = GetAddr2Ptr(pframe);
+ sa = hdr->addr2;
break;
case 0x01: /* ToDs = 0, FromDs = 1 */
- sa = GetAddr3Ptr(pframe);
+ sa = hdr->addr3;
break;
case 0x02: /* ToDs = 1, FromDs = 0 */
- sa = GetAddr2Ptr(pframe);
+ sa = hdr->addr2;
break;
default: /* ToDs = 1, FromDs = 1 */
- sa = GetAddr4Ptr(pframe);
+ sa = hdr->addr4;
break;
}
@@ -252,21 +250,22 @@ static inline unsigned char *get_sa(unsigned char *pframe)
static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe;
unsigned char *sa = NULL;
unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
switch (to_fr_ds) {
case 0x00: /* ToDs = 0, FromDs = 0 */
- sa = GetAddr3Ptr(pframe);
+ sa = hdr->addr3;
break;
case 0x01: /* ToDs = 0, FromDs = 1 */
- sa = GetAddr2Ptr(pframe);
+ sa = hdr->addr2;
break;
case 0x02: /* ToDs = 1, FromDs = 0 */
- sa = GetAddr1Ptr(pframe);
+ sa = hdr->addr1;
break;
case 0x03: /* ToDs = 1, FromDs = 1 */
- sa = GetAddr1Ptr(pframe);
+ sa = hdr->addr1;
break;
}
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 91d98418c..9d203810e 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1908,7 +1908,8 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame,
sinfo.filled = 0;
sinfo.assoc_req_ies = pmgmt_frame + WLAN_HDR_A3_LEN + ie_offset;
sinfo.assoc_req_ies_len = frame_len - WLAN_HDR_A3_LEN - ie_offset;
- cfg80211_new_sta(wdev, GetAddr2Ptr(pmgmt_frame), &sinfo, GFP_ATOMIC);
+ cfg80211_new_sta(wdev, ((struct ieee80211_hdr *)pmgmt_frame)->addr2,
+ &sinfo, GFP_ATOMIC);
}
}
--
2.43.0
next prev parent reply other threads:[~2026-10-13 20:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 20:15 [PATCH 00/10] staging: rtl8723bs: replace private 802.11 header macros with generic helpers Rishik Yechuri
2026-10-13 20:15 ` Rishik Yechuri [this message]
2026-10-13 20:15 ` [PATCH 02/10] staging: rtl8723bs: use ieee80211_has_*() to test frame control flags Rishik Yechuri
2026-10-13 20:15 ` [PATCH 03/10] staging: rtl8723bs: set frame control flags with IEEE80211_FCTL_* masks Rishik Yechuri
2026-10-13 20:15 ` [PATCH 04/10] staging: rtl8723bs: use ieee80211_is_*() for frame type tests Rishik Yechuri
2026-10-13 20:15 ` [PATCH 05/10] staging: rtl8723bs: use IEEE80211_FCTL_* masks for frame type dispatch Rishik Yechuri
2026-10-13 20:15 ` [PATCH 06/10] staging: rtl8723bs: remove unused num member from struct mlme_handler Rishik Yechuri
2026-10-13 20:15 ` [PATCH 07/10] staging: rtl8723bs: use IEEE80211_FTYPE_* and IEEE80211_STYPE_* values Rishik Yechuri
2026-10-13 20:15 ` [PATCH 08/10] staging: rtl8723bs: use struct ieee80211_hdr for seq_ctrl and duration_id Rishik Yechuri
2026-10-13 20:15 ` [PATCH 09/10] staging: rtl8723bs: use IEEE80211_QOS_CTL_* masks for QoS control Rishik Yechuri
2026-10-13 20:15 ` [PATCH 10/10] staging: rtl8723bs: use ieee80211_get_DA() and ieee80211_get_SA() Rishik Yechuri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261013201538.43156-2-rishik.yechuri.code@gmail.com \
--to=epicrishik@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=rishik.yechuri.code@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox