blob: 882d97bdc6bfd49ac3acf80f5674821b15f46e35 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Michal Kazior60771782012-06-29 12:46:56 +02002#include <linux/ieee80211.h>
3#include <linux/export.h>
4#include <net/cfg80211.h>
5#include "nl80211.h"
6#include "core.h"
Hila Gonene35e4d22012-06-27 17:19:42 +03007#include "rdev-ops.h"
Michal Kazior60771782012-06-29 12:46:56 +02008
9
Michal Kaziorf04c2202014-04-09 15:11:01 +020010int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
11 struct net_device *dev, bool notify)
Michal Kazior60771782012-06-29 12:46:56 +020012{
13 struct wireless_dev *wdev = dev->ieee80211_ptr;
14 int err;
15
16 ASSERT_WDEV_LOCK(wdev);
17
18 if (!rdev->ops->stop_ap)
19 return -EOPNOTSUPP;
20
21 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
22 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
23 return -EOPNOTSUPP;
24
25 if (!wdev->beacon_interval)
26 return -ENOENT;
27
Hila Gonene35e4d22012-06-27 17:19:42 +030028 err = rdev_stop_ap(rdev, dev);
Michal Kaziorf4489eb2012-06-29 12:46:58 +020029 if (!err) {
Denis Kenzior466a3062018-03-26 12:52:47 -050030 wdev->conn_owner_nlportid = 0;
Michal Kazior60771782012-06-29 12:46:56 +020031 wdev->beacon_interval = 0;
Michal Kazior9e0e2962014-01-29 14:22:27 +010032 memset(&wdev->chandef, 0, sizeof(wdev->chandef));
Antonio Quartulli06e191e2012-11-07 12:52:19 +010033 wdev->ssid_len = 0;
Kyeyoon Parkfa9ffc72013-12-16 23:01:30 -080034 rdev_set_qos_map(rdev, dev, NULL);
Ilan Peer7c8d5e02014-02-25 15:33:38 +020035 if (notify)
36 nl80211_send_ap_stopped(wdev);
Vasanthakumar Thiagarajanb35a51c2017-02-27 17:04:33 +053037
38 /* Should we apply the grace period during beaconing interface
39 * shutdown also?
40 */
41 cfg80211_sched_dfs_chan_update(rdev);
Michal Kaziorf4489eb2012-06-29 12:46:58 +020042 }
Michal Kazior60771782012-06-29 12:46:56 +020043
44 return err;
45}
46
47int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
Ilan Peer7c8d5e02014-02-25 15:33:38 +020048 struct net_device *dev, bool notify)
Michal Kazior60771782012-06-29 12:46:56 +020049{
50 struct wireless_dev *wdev = dev->ieee80211_ptr;
51 int err;
52
53 wdev_lock(wdev);
Ilan Peer7c8d5e02014-02-25 15:33:38 +020054 err = __cfg80211_stop_ap(rdev, dev, notify);
Michal Kazior60771782012-06-29 12:46:56 +020055 wdev_unlock(wdev);
56
57 return err;
58}