blob: 3e02ade508d8804d4158a03ad5de474d64bf7594 [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,
Ilan Peer7c8d5e02014-02-25 15:33:38 +020010 struct net_device *dev, bool notify)
Michal Kazior60771782012-06-29 12:46:56 +020011{
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 Kazior9e0e2962014-01-29 14:22:27 +010030 memset(&wdev->chandef, 0, sizeof(wdev->chandef));
Antonio Quartulli06e191e2012-11-07 12:52:19 +010031 wdev->ssid_len = 0;
Kyeyoon Parkfa9ffc72013-12-16 23:01:30 -080032 rdev_set_qos_map(rdev, dev, NULL);
Ilan Peer7c8d5e02014-02-25 15:33:38 +020033 if (notify)
34 nl80211_send_ap_stopped(wdev);
Michal Kaziorf4489eb2012-06-29 12:46:58 +020035 }
Michal Kazior60771782012-06-29 12:46:56 +020036
37 return err;
38}
39
40int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
Ilan Peer7c8d5e02014-02-25 15:33:38 +020041 struct net_device *dev, bool notify)
Michal Kazior60771782012-06-29 12:46:56 +020042{
43 struct wireless_dev *wdev = dev->ieee80211_ptr;
44 int err;
45
46 wdev_lock(wdev);
Ilan Peer7c8d5e02014-02-25 15:33:38 +020047 err = __cfg80211_stop_ap(rdev, dev, notify);
Michal Kazior60771782012-06-29 12:46:56 +020048 wdev_unlock(wdev);
49
50 return err;
51}