aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wu <flamingice@sourmilk.net>2008-01-31 13:48:23 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:37:02 -0500
commit8cc9a73914b07b5908d8a59320f4557fc9639f2e (patch)
tree34ad48b7fa4078c04bd83a45e7cef75b0f49176a
parent66f7ac50ed7cc5c19a62bc97e8f6e7891004a03a (diff)
mac80211: Use monitor configuration flags
Take advantage of the monitor configuration flags now provided by cfg80211. Signed-off-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/mac80211/cfg.c15
-rw-r--r--net/mac80211/ieee80211.c56
-rw-r--r--net/mac80211/ieee80211_i.h3
-rw-r--r--net/mac80211/ieee80211_iface.c2
4 files changed, 60 insertions, 16 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 706418d477c2..a083cc78855e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -38,6 +38,9 @@ static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
38{ 38{
39 struct ieee80211_local *local = wiphy_priv(wiphy); 39 struct ieee80211_local *local = wiphy_priv(wiphy);
40 enum ieee80211_if_types itype; 40 enum ieee80211_if_types itype;
41 struct net_device *dev;
42 struct ieee80211_sub_if_data *sdata;
43 int err;
41 44
42 if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) 45 if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
43 return -ENODEV; 46 return -ENODEV;
@@ -46,7 +49,13 @@ static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
46 if (itype == IEEE80211_IF_TYPE_INVALID) 49 if (itype == IEEE80211_IF_TYPE_INVALID)
47 return -EINVAL; 50 return -EINVAL;
48 51
49 return ieee80211_if_add(local->mdev, name, NULL, itype); 52 err = ieee80211_if_add(local->mdev, name, &dev, itype);
53 if (err || itype != IEEE80211_IF_TYPE_MNTR || !flags)
54 return err;
55
56 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
57 sdata->u.mntr_flags = *flags;
58 return 0;
50} 59}
51 60
52static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) 61static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
@@ -99,6 +108,10 @@ static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,
99 ieee80211_if_reinit(dev); 108 ieee80211_if_reinit(dev);
100 ieee80211_if_set_type(dev, itype); 109 ieee80211_if_set_type(dev, itype);
101 110
111 if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || !flags)
112 return 0;
113
114 sdata->u.mntr_flags = *flags;
102 return 0; 115 return 0;
103} 116}
104 117
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
index cb09931af86a..83694fb49734 100644
--- a/net/mac80211/ieee80211.c
+++ b/net/mac80211/ieee80211.c
@@ -67,9 +67,19 @@ static void ieee80211_configure_filter(struct ieee80211_local *local)
67 new_flags |= FIF_ALLMULTI; 67 new_flags |= FIF_ALLMULTI;
68 68
69 if (local->monitors) 69 if (local->monitors)
70 new_flags |= FIF_CONTROL | 70 new_flags |= FIF_BCN_PRBRESP_PROMISC;
71 FIF_OTHER_BSS | 71
72 FIF_BCN_PRBRESP_PROMISC; 72 if (local->fif_fcsfail)
73 new_flags |= FIF_FCSFAIL;
74
75 if (local->fif_plcpfail)
76 new_flags |= FIF_PLCPFAIL;
77
78 if (local->fif_control)
79 new_flags |= FIF_CONTROL;
80
81 if (local->fif_other_bss)
82 new_flags |= FIF_OTHER_BSS;
73 83
74 changed_flags = local->filter_flags ^ new_flags; 84 changed_flags = local->filter_flags ^ new_flags;
75 85
@@ -231,13 +241,21 @@ static int ieee80211_open(struct net_device *dev)
231 case IEEE80211_IF_TYPE_MNTR: 241 case IEEE80211_IF_TYPE_MNTR:
232 /* must be before the call to ieee80211_configure_filter */ 242 /* must be before the call to ieee80211_configure_filter */
233 local->monitors++; 243 local->monitors++;
234 if (local->monitors == 1) { 244 if (local->monitors == 1)
235 netif_tx_lock_bh(local->mdev);
236 ieee80211_configure_filter(local);
237 netif_tx_unlock_bh(local->mdev);
238
239 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; 245 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
240 } 246
247 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
248 local->fif_fcsfail++;
249 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
250 local->fif_plcpfail++;
251 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
252 local->fif_control++;
253 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
254 local->fif_other_bss++;
255
256 netif_tx_lock_bh(local->mdev);
257 ieee80211_configure_filter(local);
258 netif_tx_unlock_bh(local->mdev);
241 break; 259 break;
242 case IEEE80211_IF_TYPE_STA: 260 case IEEE80211_IF_TYPE_STA:
243 case IEEE80211_IF_TYPE_IBSS: 261 case IEEE80211_IF_TYPE_IBSS:
@@ -353,13 +371,21 @@ static int ieee80211_stop(struct net_device *dev)
353 break; 371 break;
354 case IEEE80211_IF_TYPE_MNTR: 372 case IEEE80211_IF_TYPE_MNTR:
355 local->monitors--; 373 local->monitors--;
356 if (local->monitors == 0) { 374 if (local->monitors == 0)
357 netif_tx_lock_bh(local->mdev);
358 ieee80211_configure_filter(local);
359 netif_tx_unlock_bh(local->mdev);
360
361 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; 375 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
362 } 376
377 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
378 local->fif_fcsfail--;
379 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
380 local->fif_plcpfail--;
381 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
382 local->fif_control--;
383 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
384 local->fif_other_bss--;
385
386 netif_tx_lock_bh(local->mdev);
387 ieee80211_configure_filter(local);
388 netif_tx_unlock_bh(local->mdev);
363 break; 389 break;
364 case IEEE80211_IF_TYPE_STA: 390 case IEEE80211_IF_TYPE_STA:
365 case IEEE80211_IF_TYPE_IBSS: 391 case IEEE80211_IF_TYPE_IBSS:
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 31fc64c5652c..21d54b27ccc1 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -345,6 +345,7 @@ struct ieee80211_sub_if_data {
345 struct ieee80211_if_wds wds; 345 struct ieee80211_if_wds wds;
346 struct ieee80211_if_vlan vlan; 346 struct ieee80211_if_vlan vlan;
347 struct ieee80211_if_sta sta; 347 struct ieee80211_if_sta sta;
348 u32 mntr_flags;
348 } u; 349 } u;
349 int channel_use; 350 int channel_use;
350 int channel_use_raw; 351 int channel_use_raw;
@@ -425,6 +426,8 @@ struct ieee80211_local {
425 struct net_device *mdev; /* wmaster# - "master" 802.11 device */ 426 struct net_device *mdev; /* wmaster# - "master" 802.11 device */
426 int open_count; 427 int open_count;
427 int monitors; 428 int monitors;
429 /* number of interfaces with corresponding FIF_ flags */
430 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
428 unsigned int filter_flags; /* FIF_* */ 431 unsigned int filter_flags; /* FIF_* */
429 struct iw_statistics wstats; 432 struct iw_statistics wstats;
430 u8 wstats_flags; 433 u8 wstats_flags;
diff --git a/net/mac80211/ieee80211_iface.c b/net/mac80211/ieee80211_iface.c
index 27cee580f9f1..f66f1ddc3fda 100644
--- a/net/mac80211/ieee80211_iface.c
+++ b/net/mac80211/ieee80211_iface.c
@@ -160,6 +160,8 @@ void ieee80211_if_set_type(struct net_device *dev, int type)
160 case IEEE80211_IF_TYPE_MNTR: 160 case IEEE80211_IF_TYPE_MNTR:
161 dev->type = ARPHRD_IEEE80211_RADIOTAP; 161 dev->type = ARPHRD_IEEE80211_RADIOTAP;
162 dev->hard_start_xmit = ieee80211_monitor_start_xmit; 162 dev->hard_start_xmit = ieee80211_monitor_start_xmit;
163 sdata->u.mntr_flags = MONITOR_FLAG_CONTROL |
164 MONITOR_FLAG_OTHER_BSS;
163 break; 165 break;
164 default: 166 default:
165 printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x", 167 printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x",