[MAC80211]: split up __ieee80211_rx

The really indented part that does the huge switch on the interface
type is a nuisance. Put it into an own function 'prepare_for_handlers'.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Johannes Berg 2007-07-27 15:43:22 +02:00 committed by David S. Miller
parent 570bd537a9
commit 23a24defa0

View File

@ -1240,6 +1240,73 @@ ieee80211_rx_handler ieee80211_rx_handlers[] =
/* main receive path */ /* main receive path */
static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
u8 *bssid, struct ieee80211_txrx_data *rx,
struct ieee80211_hdr *hdr)
{
int multicast = is_multicast_ether_addr(hdr->addr1);
switch (sdata->type) {
case IEEE80211_IF_TYPE_STA:
if (!bssid)
return 0;
if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
if (!rx->u.rx.in_scan)
return 0;
rx->u.rx.ra_match = 0;
} else if (!multicast &&
compare_ether_addr(sdata->dev->dev_addr,
hdr->addr1) != 0) {
if (!sdata->promisc)
return 0;
rx->u.rx.ra_match = 0;
}
break;
case IEEE80211_IF_TYPE_IBSS:
if (!bssid)
return 0;
if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
if (!rx->u.rx.in_scan)
return 0;
rx->u.rx.ra_match = 0;
} else if (!multicast &&
compare_ether_addr(sdata->dev->dev_addr,
hdr->addr1) != 0) {
if (!sdata->promisc)
return 0;
rx->u.rx.ra_match = 0;
} else if (!rx->sta)
rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb,
bssid, hdr->addr2);
break;
case IEEE80211_IF_TYPE_AP:
if (!bssid) {
if (compare_ether_addr(sdata->dev->dev_addr,
hdr->addr1))
return 0;
} else if (!ieee80211_bssid_match(bssid,
sdata->dev->dev_addr)) {
if (!rx->u.rx.in_scan)
return 0;
rx->u.rx.ra_match = 0;
}
if (sdata->dev == sdata->local->mdev && !rx->u.rx.in_scan)
/* do not receive anything via
* master device when not scanning */
return 0;
break;
case IEEE80211_IF_TYPE_WDS:
if (bssid ||
(rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
return 0;
if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
return 0;
break;
}
return 1;
}
/* /*
* This is the receive path handler. It is called by a low level driver when an * This is the receive path handler. It is called by a low level driver when an
* 802.11 MPDU is received from the hardware. * 802.11 MPDU is received from the hardware.
@ -1253,8 +1320,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr;
struct ieee80211_txrx_data rx; struct ieee80211_txrx_data rx;
u16 type; u16 type;
int multicast; int radiotap_len = 0, prepres;
int radiotap_len = 0;
struct ieee80211_sub_if_data *prev = NULL; struct ieee80211_sub_if_data *prev = NULL;
struct sk_buff *skb_new; struct sk_buff *skb_new;
u8 *bssid; u8 *bssid;
@ -1274,18 +1340,16 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
type = rx.fc & IEEE80211_FCTL_FTYPE; type = rx.fc & IEEE80211_FCTL_FTYPE;
if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT) if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT)
local->dot11ReceivedFragmentCount++; local->dot11ReceivedFragmentCount++;
multicast = is_multicast_ether_addr(hdr->addr1);
if (skb->len >= 16) if (skb->len >= 16) {
sta = rx.sta = sta_info_get(local, hdr->addr2); sta = rx.sta = sta_info_get(local, hdr->addr2);
else if (sta) {
rx.dev = rx.sta->dev;
rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
}
} else
sta = rx.sta = NULL; sta = rx.sta = NULL;
if (sta) {
rx.dev = sta->dev;
rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
}
if ((status->flag & RX_FLAG_MMIC_ERROR)) { if ((status->flag & RX_FLAG_MMIC_ERROR)) {
ieee80211_rx_michael_mic_report(local->mdev, hdr, sta, &rx); ieee80211_rx_michael_mic_report(local->mdev, hdr, sta, &rx);
goto end; goto end;
@ -1301,10 +1365,10 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
skb_push(skb, radiotap_len); skb_push(skb, radiotap_len);
if (sta && !sta->assoc_ap && !(sta->flags & WLAN_STA_WDS) && if (sta && !sta->assoc_ap && !(sta->flags & WLAN_STA_WDS) &&
!local->iff_promiscs && !multicast) { !local->iff_promiscs && !is_multicast_ether_addr(hdr->addr1)) {
rx.u.rx.ra_match = 1; rx.u.rx.ra_match = 1;
ieee80211_invoke_rx_handlers(local, local->rx_handlers, &rx, ieee80211_invoke_rx_handlers(local, local->rx_handlers, &rx,
sta); rx.sta);
sta_info_put(sta); sta_info_put(sta);
return; return;
} }
@ -1314,68 +1378,13 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
read_lock(&local->sub_if_lock); read_lock(&local->sub_if_lock);
list_for_each_entry(sdata, &local->sub_if_list, list) { list_for_each_entry(sdata, &local->sub_if_list, list) {
rx.u.rx.ra_match = 1; rx.u.rx.ra_match = 1;
switch (sdata->type) {
case IEEE80211_IF_TYPE_STA: prepres = prepare_for_handlers(sdata, bssid, &rx, hdr);
if (!bssid) /* prepare_for_handlers can change sta */
continue; sta = rx.sta;
if (!ieee80211_bssid_match(bssid,
sdata->u.sta.bssid)) { if (!prepres)
if (!rx.u.rx.in_scan) continue;
continue;
rx.u.rx.ra_match = 0;
} else if (!multicast &&
compare_ether_addr(sdata->dev->dev_addr,
hdr->addr1) != 0) {
if (!sdata->promisc)
continue;
rx.u.rx.ra_match = 0;
}
break;
case IEEE80211_IF_TYPE_IBSS:
if (!bssid)
continue;
if (!ieee80211_bssid_match(bssid,
sdata->u.sta.bssid)) {
if (!rx.u.rx.in_scan)
continue;
rx.u.rx.ra_match = 0;
} else if (!multicast &&
compare_ether_addr(sdata->dev->dev_addr,
hdr->addr1) != 0) {
if (!sdata->promisc)
continue;
rx.u.rx.ra_match = 0;
} else if (!sta)
sta = rx.sta =
ieee80211_ibss_add_sta(sdata->dev,
skb, bssid,
hdr->addr2);
break;
case IEEE80211_IF_TYPE_AP:
if (!bssid) {
if (compare_ether_addr(sdata->dev->dev_addr,
hdr->addr1))
continue;
} else if (!ieee80211_bssid_match(bssid,
sdata->dev->dev_addr)) {
if (!rx.u.rx.in_scan)
continue;
rx.u.rx.ra_match = 0;
}
if (sdata->dev == local->mdev && !rx.u.rx.in_scan)
/* do not receive anything via
* master device when not scanning */
continue;
break;
case IEEE80211_IF_TYPE_WDS:
if (bssid ||
(rx.fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
continue;
if (compare_ether_addr(sdata->u.wds.remote_addr,
hdr->addr2))
continue;
break;
}
if (prev) { if (prev) {
skb_new = skb_copy(skb, GFP_ATOMIC); skb_new = skb_copy(skb, GFP_ATOMIC);