summaryrefslogtreecommitdiffstats
path: root/ap_interface_impl.cpp
diff options
context:
space:
mode:
authorNingyuan Wang <nywang@google.com>2017-02-28 15:49:08 -0800
committerNingyuan Wang <nywang@google.com>2017-03-01 11:44:54 -0800
commit9136ae3b1e8327ead81c3468d7808bb889077442 (patch)
tree32d3b11f4b917e4fb8111feb7c1807e7e29ca23a /ap_interface_impl.cpp
parent4cdf87972f7d5ed6b86fe002895b5b349ddefce3 (diff)
downloadplatform_system_connectivity_wificond-9136ae3b1e8327ead81c3468d7808bb889077442.tar.gz
platform_system_connectivity_wificond-9136ae3b1e8327ead81c3468d7808bb889077442.tar.bz2
platform_system_connectivity_wificond-9136ae3b1e8327ead81c3468d7808bb889077442.zip
Cleanup AP logic after Hostapd is down
Bug: 35445677 Test: compile, unit tests, manual test Change-Id: Ic7e6c593ded19955da7a85d60730bf8e9afd679a
Diffstat (limited to 'ap_interface_impl.cpp')
-rw-r--r--ap_interface_impl.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/ap_interface_impl.cpp b/ap_interface_impl.cpp
index e7f0df9..62fa2ae 100644
--- a/ap_interface_impl.cpp
+++ b/ap_interface_impl.cpp
@@ -18,6 +18,8 @@
#include <android-base/logging.h>
+#include "wificond/net/netlink_utils.h"
+
#include "wificond/ap_interface_binder.h"
using android::net::wifi::IApInterface;
@@ -34,10 +36,12 @@ namespace wificond {
ApInterfaceImpl::ApInterfaceImpl(const string& interface_name,
uint32_t interface_index,
+ NetlinkUtils* netlink_utils,
InterfaceTool* if_tool,
HostapdManager* hostapd_manager)
: interface_name_(interface_name),
interface_index_(interface_index),
+ netlink_utils_(netlink_utils),
if_tool_(if_tool),
hostapd_manager_(hostapd_manager),
binder_(new ApInterfaceBinder(this)) {
@@ -61,14 +65,28 @@ bool ApInterfaceImpl::StartHostapd() {
bool ApInterfaceImpl::StopHostapd() {
// Drop SIGKILL on hostapd.
- bool success = hostapd_manager_->StopHostapd();
+ if (!hostapd_manager_->StopHostapd()) {
+ // Logging was done internally.
+ return false;
+ }
+
+ // Take down the interface.
+ if (!if_tool_->SetUpState(interface_name_.c_str(), false)) {
+ // Logging was done internally.
+ return false;
+ }
- // Take down the interface. This has the pleasant side effect of
- // letting the driver know that we don't want any lingering AP logic
- // running in the driver.
- success = if_tool_->SetUpState(interface_name_.c_str(), false) && success;
+ // Since wificond SIGKILLs hostapd, hostapd has no chance to handle
+ // the cleanup.
+ // Besides taking down the interface, we also need to set the interface mode
+ // back to station mode for the cleanup.
+ if (!netlink_utils_->SetInterfaceMode(interface_index_,
+ NetlinkUtils::STATION_MODE)) {
+ LOG(ERROR) << "Failed to set interface back to station mode";
+ return false;
+ }
- return success;
+ return true;
}
bool ApInterfaceImpl::WriteHostapdConfig(const vector<uint8_t>& ssid,