rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | #include <linux/ieee80211.h> |
| 3 | #include <linux/export.h> |
| 4 | #include <net/cfg80211.h> |
| 5 | #include "nl80211.h" |
| 6 | #include "core.h" |
| 7 | #include "rdev-ops.h" |
| 8 | |
| 9 | |
| 10 | int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, |
| 11 | struct net_device *dev, bool notify) |
| 12 | { |
| 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 | |
| 28 | err = rdev_stop_ap(rdev, dev); |
| 29 | if (!err) { |
| 30 | wdev->beacon_interval = 0; |
| 31 | memset(&wdev->chandef, 0, sizeof(wdev->chandef)); |
| 32 | wdev->ssid_len = 0; |
| 33 | rdev_set_qos_map(rdev, dev, NULL); |
| 34 | if (notify) |
| 35 | nl80211_send_ap_stopped(wdev); |
| 36 | |
| 37 | /* Should we apply the grace period during beaconing interface |
| 38 | * shutdown also? |
| 39 | */ |
| 40 | cfg80211_sched_dfs_chan_update(rdev); |
| 41 | } |
| 42 | |
| 43 | schedule_work(&cfg80211_disconnect_work); |
| 44 | |
| 45 | return err; |
| 46 | } |
| 47 | |
| 48 | int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, |
| 49 | struct net_device *dev, bool notify) |
| 50 | { |
| 51 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 52 | int err; |
| 53 | |
| 54 | wdev_lock(wdev); |
| 55 | err = __cfg80211_stop_ap(rdev, dev, notify); |
| 56 | wdev_unlock(wdev); |
| 57 | |
| 58 | return err; |
| 59 | } |