blob: a4a14e8f55cc42f2c77146f73b4c55b8434337b5 [file] [log] [blame]
Michal Kazior60771782012-06-29 12:46:56 +02001#include <linux/ieee80211.h>
2#include <linux/export.h>
3#include <net/cfg80211.h>
4#include "nl80211.h"
5#include "core.h"
Hila Gonene35e4d22012-06-27 17:19:42 +03006#include "rdev-ops.h"
Michal Kazior60771782012-06-29 12:46:56 +02007
8
9static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
10 struct net_device *dev)
11{
12 struct wireless_dev *wdev = dev->ieee80211_ptr;
13 int err;
14
15 ASSERT_WDEV_LOCK(wdev);
16
17 if (!rdev->ops->stop_ap)
18 return -EOPNOTSUPP;
19
20 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
21 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
22 return -EOPNOTSUPP;
23
24 if (!wdev->beacon_interval)
25 return -ENOENT;
26
Hila Gonene35e4d22012-06-27 17:19:42 +030027 err = rdev_stop_ap(rdev, dev);
Michal Kaziorf4489eb2012-06-29 12:46:58 +020028 if (!err) {
Michal Kazior60771782012-06-29 12:46:56 +020029 wdev->beacon_interval = 0;
Michal Kaziorf4489eb2012-06-29 12:46:58 +020030 wdev->channel = NULL;
Antonio Quartulli06e191e2012-11-07 12:52:19 +010031 wdev->ssid_len = 0;
Michal Kaziorf4489eb2012-06-29 12:46:58 +020032 }
Michal Kazior60771782012-06-29 12:46:56 +020033
34 return err;
35}
36
37int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
38 struct net_device *dev)
39{
40 struct wireless_dev *wdev = dev->ieee80211_ptr;
41 int err;
42
43 wdev_lock(wdev);
44 err = __cfg80211_stop_ap(rdev, dev);
45 wdev_unlock(wdev);
46
47 return err;
48}
Johannes Bergdfa674d2012-12-20 18:23:01 +010049
50void cfg80211_ch_switch_notify(struct net_device *dev,
51 struct cfg80211_chan_def *chandef)
52{
53 struct wireless_dev *wdev = dev->ieee80211_ptr;
54 struct wiphy *wiphy = wdev->wiphy;
55 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
56
57 trace_cfg80211_ch_switch_notify(dev, chandef);
58
59 wdev_lock(wdev);
60
61 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
62 wdev->iftype != NL80211_IFTYPE_P2P_GO))
63 goto out;
64
65 wdev->channel = chandef->chan;
66 nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL);
67out:
68 wdev_unlock(wdev);
69 return;
70}
71EXPORT_SYMBOL(cfg80211_ch_switch_notify);
72
73bool cfg80211_rx_spurious_frame(struct net_device *dev,
74 const u8 *addr, gfp_t gfp)
75{
76 struct wireless_dev *wdev = dev->ieee80211_ptr;
77 bool ret;
78
79 trace_cfg80211_rx_spurious_frame(dev, addr);
80
81 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
82 wdev->iftype != NL80211_IFTYPE_P2P_GO)) {
83 trace_cfg80211_return_bool(false);
84 return false;
85 }
86 ret = nl80211_unexpected_frame(dev, addr, gfp);
87 trace_cfg80211_return_bool(ret);
88 return ret;
89}
90EXPORT_SYMBOL(cfg80211_rx_spurious_frame);
91
92bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
93 const u8 *addr, gfp_t gfp)
94{
95 struct wireless_dev *wdev = dev->ieee80211_ptr;
96 bool ret;
97
98 trace_cfg80211_rx_unexpected_4addr_frame(dev, addr);
99
100 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
101 wdev->iftype != NL80211_IFTYPE_P2P_GO &&
102 wdev->iftype != NL80211_IFTYPE_AP_VLAN)) {
103 trace_cfg80211_return_bool(false);
104 return false;
105 }
106 ret = nl80211_unexpected_4addr_frame(dev, addr, gfp);
107 trace_cfg80211_return_bool(ret);
108 return ret;
109}
110EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame);