Search Linux Wireless

[PATCH] zd1211rw-mac80211: function which checks for monitor mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ulrich Kunitz <kune@xxxxxxxxxxxxxx>

This patch introduces the function has_monitor_interfaces. The
function checks whether monitor interfaces have been enabled. It
will allow us to change the interface management data in the
zd_mac structure.

Signed-off-by: Ulrich Kunitz <kune@xxxxxxxxxxxxxx>
Signed-off-by: Daniel Drake <dsd@xxxxxxxxxx>
---
 drivers/net/wireless/zd1211rw-mac80211/zd_mac.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/zd1211rw-mac80211/zd_mac.c b/drivers/net/wireless/zd1211rw-mac80211/zd_mac.c
index 1693532..257d033 100644
--- a/drivers/net/wireless/zd1211rw-mac80211/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw-mac80211/zd_mac.c
@@ -170,9 +170,20 @@ void zd_mac_clear(struct zd_mac *mac)
 	ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
 }
 
+/**
+ * has_monitor_interfaces - have monitor interfaces been enabled?
+ * @mac: the struct zd_mac pointer
+ *
+ * The function returns, whether the device has monitor interfaces attached.
+ */
+static int has_monitor_interfaces(struct zd_mac *mac)
+{
+	return mac->type == IEEE80211_IF_TYPE_MNTR;
+}
+
 static int set_rx_filter(struct zd_mac *mac)
 {
-	u32 filter = mac->type == IEEE80211_IF_TYPE_MNTR ? ~0 : STA_RX_FILTER;
+	u32 filter = has_monitor_interfaces(mac) ? ~0 : STA_RX_FILTER;
 
 	return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter);
 }
@@ -180,7 +191,7 @@ static int set_rx_filter(struct zd_mac *mac)
 static int set_sniffer(struct zd_mac *mac)
 {
 	return zd_iowrite32(&mac->chip, CR_SNIFFER_ON,
-		mac->type == IEEE80211_IF_TYPE_MNTR ? 1 : 0);
+		has_monitor_interfaces(mac) ? 1 : 0);
 	return 0;
 }
 
@@ -189,7 +200,7 @@ static int set_mc_hash(struct zd_mac *mac)
 	struct zd_mc_hash hash;
 
 	zd_mc_clear(&hash);
-	if (mac->type == IEEE80211_IF_TYPE_MNTR)
+	if (has_monitor_interfaces(mac))
 		zd_mc_add_all(&hash);
 
 	return zd_chip_set_multicast_hash(&mac->chip, &hash);
@@ -685,7 +696,7 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
 	buffer += ZD_PLCP_HEADER_SIZE;
 
 	if (filter_ack(hw, (struct ieee80211_hdr *)buffer, &stats) &&
-	    mac->type != IEEE80211_IF_TYPE_MNTR)
+	    !has_monitor_interfaces(mac))
 		return 0;
 
 	skb = dev_alloc_skb(length);
@@ -765,7 +776,7 @@ static void zd_op_set_multicast_list(struct ieee80211_hw *hw,
 	unsigned long flags;
 
 	if ((dev_flags & (IFF_PROMISC|IFF_ALLMULTI)) ||
-            mac->type == IEEE80211_IF_TYPE_MNTR)
+	     has_monitor_interfaces(mac))
 	{
 		zd_mc_add_all(&hash);
 	} else {
-- 
1.5.2.4

-
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux