Commit a12960f9 authored by Martin Kaiser's avatar Martin Kaiser Committed by Greg Kroah-Hartman

staging: r8188eu: restructure mlme subfunction handling

Move some code around in rtw_mlme_ext.c to make it simpler.

mlme_sta_tbl is used only by mgt_dispatcher. Move the table inside the
function. Move mgt_dispatcher behind the handler functions. We can then
make the handler functions static.
Signed-off-by: default avatarMartin Kaiser <martin@kaiser.cx>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Link: https://lore.kernel.org/r/20221024081417.66441-2-martin@kaiser.cxSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4a1fc310
......@@ -12,24 +12,6 @@
#include "../include/rtl8188e_xmit.h"
#include "../include/rtl8188e_dm.h"
/* response function for each management frame subtype, do not reorder */
static mlme_handler mlme_sta_tbl[] = {
OnAssocReq,
OnAssocRsp,
OnAssocReq,
OnAssocRsp,
OnProbeReq,
OnProbeRsp,
NULL,
NULL,
OnBeacon,
NULL,
OnDisassoc,
OnAuthClient,
OnDeAuth,
OnAction,
};
static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
/**************************************************
......@@ -393,47 +375,6 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
}
}
void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
{
int index;
mlme_handler fct;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
if (!ieee80211_is_mgmt(hdr->frame_control))
return;
/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
!is_broadcast_ether_addr(hdr->addr1))
return;
index = (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
if (index >= ARRAY_SIZE(mlme_sta_tbl))
return;
fct = mlme_sta_tbl[index];
if (psta) {
if (ieee80211_has_retry(hdr->frame_control)) {
if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
/* drop the duplicate management frame */
return;
}
psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
}
if (ieee80211_is_auth(hdr->frame_control)) {
if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
fct = OnAuth;
else
fct = OnAuthClient;
}
if (fct)
fct(padapter, precv_frame);
}
static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da)
{
bool response = true;
......@@ -4008,6 +3949,63 @@ struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv)
return pmgntframe;
}
void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
{
mlme_handler mlme_sta_tbl[] = {
OnAssocReq,
OnAssocRsp,
OnAssocReq,
OnAssocRsp,
OnProbeReq,
OnProbeRsp,
NULL,
NULL,
OnBeacon,
NULL,
OnDisassoc,
OnAuthClient,
OnDeAuth,
OnAction,
};
int index;
mlme_handler fct;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
if (!ieee80211_is_mgmt(hdr->frame_control))
return;
/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
!is_broadcast_ether_addr(hdr->addr1))
return;
index = (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
if (index >= ARRAY_SIZE(mlme_sta_tbl))
return;
fct = mlme_sta_tbl[index];
if (psta) {
if (ieee80211_has_retry(hdr->frame_control)) {
if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
/* drop the duplicate management frame */
return;
}
psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
}
if (ieee80211_is_auth(hdr->frame_control)) {
if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
fct = OnAuth;
else
fct = OnAuthClient;
}
if (fct)
fct(padapter, precv_frame);
}
/****************************************************************************
Following are some TX functions for WiFi MLME
......
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