diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-12-23 07:15:44 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-12-28 16:55:06 -0500 |
commit | 98b6218388e345064c3f2d3c161383a18274c638 (patch) | |
tree | 3df881c8e15947aeefe31da7fa83980a1530aed3 | |
parent | e4da8c37af626001ff704fb29ea14eb58f5f7208 (diff) |
mac80211/cfg80211: add station events
When, for instance, a new IBSS peer is found, userspace
wants to be notified. Add events for all new stations
that mac80211 learns about.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | include/net/cfg80211.h | 12 | ||||
-rw-r--r-- | net/mac80211/sta_info.c | 5 | ||||
-rw-r--r-- | net/wireless/mlme.c | 10 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 21 | ||||
-rw-r--r-- | net/wireless/nl80211.h | 4 |
5 files changed, 51 insertions, 1 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index b66beb052054..add79930f47d 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -2195,4 +2195,16 @@ void cfg80211_remain_on_channel_expired(struct net_device *dev, | |||
2195 | enum nl80211_channel_type channel_type, | 2195 | enum nl80211_channel_type channel_type, |
2196 | gfp_t gfp); | 2196 | gfp_t gfp); |
2197 | 2197 | ||
2198 | |||
2199 | /** | ||
2200 | * cfg80211_new_sta - notify userspace about station | ||
2201 | * | ||
2202 | * @dev: the netdev | ||
2203 | * @mac_addr: the station's address | ||
2204 | * @sinfo: the station information | ||
2205 | * @gfp: allocation flags | ||
2206 | */ | ||
2207 | void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, | ||
2208 | struct station_info *sinfo, gfp_t gfp); | ||
2209 | |||
2198 | #endif /* __NET_CFG80211_H */ | 2210 | #endif /* __NET_CFG80211_H */ |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index f039e761aec1..47da552ce8a6 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -359,6 +359,7 @@ int sta_info_insert(struct sta_info *sta) | |||
359 | { | 359 | { |
360 | struct ieee80211_local *local = sta->local; | 360 | struct ieee80211_local *local = sta->local; |
361 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 361 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
362 | struct station_info sinfo; | ||
362 | unsigned long flags; | 363 | unsigned long flags; |
363 | int err = 0; | 364 | int err = 0; |
364 | 365 | ||
@@ -408,6 +409,10 @@ int sta_info_insert(struct sta_info *sta) | |||
408 | 409 | ||
409 | spin_unlock_irqrestore(&local->sta_lock, flags); | 410 | spin_unlock_irqrestore(&local->sta_lock, flags); |
410 | 411 | ||
412 | sinfo.filled = 0; | ||
413 | sinfo.generation = local->sta_generation; | ||
414 | cfg80211_new_sta(sdata->dev, sta->sta.addr, &sinfo, GFP_ATOMIC); | ||
415 | |||
411 | #ifdef CONFIG_MAC80211_DEBUGFS | 416 | #ifdef CONFIG_MAC80211_DEBUGFS |
412 | /* | 417 | /* |
413 | * Debugfs entry adding might sleep, so schedule process | 418 | * Debugfs entry adding might sleep, so schedule process |
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 11f6469b3f98..3dba19e17271 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c | |||
@@ -707,3 +707,13 @@ void cfg80211_remain_on_channel_expired(struct net_device *dev, | |||
707 | channel_type, gfp); | 707 | channel_type, gfp); |
708 | } | 708 | } |
709 | EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); | 709 | EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); |
710 | |||
711 | void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, | ||
712 | struct station_info *sinfo, gfp_t gfp) | ||
713 | { | ||
714 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | ||
715 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
716 | |||
717 | nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); | ||
718 | } | ||
719 | EXPORT_SYMBOL(cfg80211_new_sta); | ||
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index ff857f10cb85..e3bee3cecdfa 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -1642,7 +1642,7 @@ static int parse_station_flags(struct genl_info *info, | |||
1642 | 1642 | ||
1643 | static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, | 1643 | static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, |
1644 | int flags, struct net_device *dev, | 1644 | int flags, struct net_device *dev, |
1645 | u8 *mac_addr, struct station_info *sinfo) | 1645 | const u8 *mac_addr, struct station_info *sinfo) |
1646 | { | 1646 | { |
1647 | void *hdr; | 1647 | void *hdr; |
1648 | struct nlattr *sinfoattr, *txrate; | 1648 | struct nlattr *sinfoattr, *txrate; |
@@ -5350,6 +5350,25 @@ void nl80211_send_remain_on_channel_cancel( | |||
5350 | channel_type, 0, gfp); | 5350 | channel_type, 0, gfp); |
5351 | } | 5351 | } |
5352 | 5352 | ||
5353 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, | ||
5354 | struct net_device *dev, const u8 *mac_addr, | ||
5355 | struct station_info *sinfo, gfp_t gfp) | ||
5356 | { | ||
5357 | struct sk_buff *msg; | ||
5358 | |||
5359 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); | ||
5360 | if (!msg) | ||
5361 | return; | ||
5362 | |||
5363 | if (nl80211_send_station(msg, 0, 0, 0, dev, mac_addr, sinfo) < 0) { | ||
5364 | nlmsg_free(msg); | ||
5365 | return; | ||
5366 | } | ||
5367 | |||
5368 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
5369 | nl80211_mlme_mcgrp.id, gfp); | ||
5370 | } | ||
5371 | |||
5353 | /* initialisation/exit functions */ | 5372 | /* initialisation/exit functions */ |
5354 | 5373 | ||
5355 | int nl80211_init(void) | 5374 | int nl80211_init(void) |
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index a5e2de419b7a..14855b8fb430 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h | |||
@@ -70,4 +70,8 @@ void nl80211_send_remain_on_channel_cancel( | |||
70 | u64 cookie, struct ieee80211_channel *chan, | 70 | u64 cookie, struct ieee80211_channel *chan, |
71 | enum nl80211_channel_type channel_type, gfp_t gfp); | 71 | enum nl80211_channel_type channel_type, gfp_t gfp); |
72 | 72 | ||
73 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, | ||
74 | struct net_device *dev, const u8 *mac_addr, | ||
75 | struct station_info *sinfo, gfp_t gfp); | ||
76 | |||
73 | #endif /* __NET_WIRELESS_NL80211_H */ | 77 | #endif /* __NET_WIRELESS_NL80211_H */ |