From: Denis Vlasenko <vda@ilport.com.ua>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
jbenc@suse.cz, softmac-dev@sipsolutions.net,
bcm43xx-dev@lists.berlios.de
Subject: [PATCH] ieee80211_rx_any: filter out packets, call ieee80211_rx or ieee80211_rx_mgt
Date: Sun, 22 Jan 2006 14:04:52 +0200 [thread overview]
Message-ID: <200601221404.52757.vda@ilport.com.ua> (raw)
In-Reply-To: <20060118200616.GC6583@tuxdriver.com>
[-- Attachment #1: Type: text/plain, Size: 323 bytes --]
bcm43xx_rx() contains code to filter out packets from
foreign BSSes and decide whether to call ieee80211_rx
or ieee80211_rx_mgt. This is not bcm specific.
Patch adapts that code and adds it to 80211
as ieee80211_rx_any() function.
Diffed against wireless-2.6.git
Signed-off-by: Denis Vlasenko <vda@ilport.com.ua>
--
vda
[-- Attachment #2: rx.patch --]
[-- Type: text/x-diff, Size: 2456 bytes --]
diff -urp softmac-snapshot/net/ieee80211/ieee80211_rx.c softmac-snapshot.1/net/ieee80211/ieee80211_rx.c
--- softmac-snapshot/net/ieee80211/ieee80211_rx.c Wed Jan 18 07:27:03 2006
+++ softmac-snapshot.1/net/ieee80211/ieee80211_rx.c Sun Jan 22 14:01:43 2006
@@ -758,6 +758,80 @@ int ieee80211_rx(struct ieee80211_device
/* Returning 0 indicates to caller that we have not handled the SKB--
* so it is still allocated and can be used again by underlying
* hardware as a DMA target */
+ return 0;
+}
+
+/* Kernel doesn't have it, why? */
+static inline int is_mcast_or_bcast_ether_addr(const u8 *addr)
+{
+ return (0x01 & addr[0]);
+}
+
+/* Filter out unrelated packets, call ieee80211_rx[_mgt] */
+int ieee80211_rx_any(struct ieee80211_device *ieee,
+ struct sk_buff *skb, struct ieee80211_rx_stats *stats)
+{
+ struct ieee80211_hdr_4addr *hdr;
+ int is_packet_for_us;
+ u16 fc;
+
+ if (ieee->iw_mode == IW_MODE_MONITOR)
+ return ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL;
+
+ hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ fc = le16_to_cpu(hdr->frame_ctl);
+
+ switch (fc & IEEE80211_FCTL_FTYPE) {
+ case IEEE80211_FTYPE_MGMT:
+ ieee80211_rx_mgt(ieee, hdr, stats);
+ return 0;
+ case IEEE80211_FTYPE_DATA:
+ break;
+ case IEEE80211_FTYPE_CTL:
+ return 0;
+ default:
+ return -EINVAL;
+ }
+
+ is_packet_for_us = 0;
+ switch (ieee->iw_mode) {
+ case IW_MODE_ADHOC:
+ /* promisc: get all */
+ if (ieee->dev->flags & IFF_PROMISC)
+ is_packet_for_us = 1;
+ /* our BSS */
+ else if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0) {
+ /* to us */
+ if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
+ is_packet_for_us = 1;
+ /* mcast */
+ else if (is_mcast_or_bcast_ether_addr(hdr->addr1))
+ is_packet_for_us = 1;
+ }
+ break;
+ case IW_MODE_INFRA:
+ /* promisc: get all */
+ if (ieee->dev->flags & IFF_PROMISC)
+ is_packet_for_us = 1;
+ /* our BSS (== from our AP) */
+ else if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0) {
+ /* to us */
+ if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
+ is_packet_for_us = 1;
+ /* mcast */
+ else if (is_mcast_or_bcast_ether_addr(hdr->addr1))
+ /* not our own packet bcasted from AP */
+ if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN))
+ is_packet_for_us = 1;
+ }
+ break;
+ default:
+ /* ? */
+ break;
+ }
+
+ if (is_packet_for_us)
+ return (ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL);
return 0;
}
next prev parent reply other threads:[~2006-01-22 12:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-18 20:06 wireless: the contenders John W. Linville
2006-01-18 20:19 ` [Bcm43xx-dev] " Michael Buesch
2006-01-18 20:25 ` John W. Linville
2006-01-18 20:36 ` Jeff Garzik
2006-01-18 20:48 ` John W. Linville
2006-01-18 20:52 ` Jeff Garzik
2006-01-19 0:19 ` [Bcm43xx-dev] " Johannes Berg
2006-01-19 15:27 ` John W. Linville
2006-01-22 11:57 ` [PATCH] trivial fix Denis Vlasenko
2006-01-22 11:59 ` [PATCH] ieee80211_rx_any: filter out packets, call ieee80211_rx or ieee80211_rx_mgt Denis Vlasenko
[not found] ` <200601221408.45486.vda@ilport.com.ua>
2006-01-22 12:25 ` [Bcm43xx-dev] " Michael Buesch
2006-01-22 12:04 ` Denis Vlasenko [this message]
2006-01-22 13:32 ` Patrick McHardy
2006-01-23 14:32 ` [softmac-dev] " Johannes Berg
2006-01-23 19:00 ` Stefan Rompf
2006-01-24 8:06 ` [Bcm43xx-dev] " Denis Vlasenko
2006-01-25 15:44 ` Stuffed Crust
2006-01-26 10:25 ` Denis Vlasenko
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=200601221404.52757.vda@ilport.com.ua \
--to=vda@ilport.com.ua \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=jbenc@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=softmac-dev@sipsolutions.net \
/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;
as well as URLs for NNTP newsgroup(s).