summaryrefslogtreecommitdiffstats
path: root/ap_interface_impl.cpp
diff options
context:
space:
mode:
authorNingyuan Wang <nywang@google.com>2017-03-08 08:44:39 -0800
committerNingyuan Wang <nywang@google.com>2017-03-16 11:40:41 -0700
commitcf51f862b31b5eb2066729660fd2caf48ecc77f8 (patch)
treec7cd2fac9a67580eab640de72e1eefce1de2d78e /ap_interface_impl.cpp
parent042abc94bc768131cd3341d677465b6aeffb5bf1 (diff)
downloadplatform_system_connectivity_wificond-cf51f862b31b5eb2066729660fd2caf48ecc77f8.tar.gz
platform_system_connectivity_wificond-cf51f862b31b5eb2066729660fd2caf48ecc77f8.tar.bz2
platform_system_connectivity_wificond-cf51f862b31b5eb2066729660fd2caf48ecc77f8.zip
Monitor station events for hotspot mode
This enables NetlinkManager to monitor NL80211_CMD_NEW_STATION, and NL80211_CMD_DEL_STATION. This could be used for ApInterfaceImpl for monitoring associated stations. This also creates a new class LoggingUtils to avoid repeating code. This also adds corresponding unit tests. Bug: 36043922 Test: compile, unit tests, manual tests Change-Id: I060062c0cd6250051da90658b229d786f287fad4
Diffstat (limited to 'ap_interface_impl.cpp')
-rw-r--r--ap_interface_impl.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/ap_interface_impl.cpp b/ap_interface_impl.cpp
index 62fa2ae..44a30b3 100644
--- a/ap_interface_impl.cpp
+++ b/ap_interface_impl.cpp
@@ -21,6 +21,7 @@
#include "wificond/net/netlink_utils.h"
#include "wificond/ap_interface_binder.h"
+#include "wificond/logging_utils.h"
using android::net::wifi::IApInterface;
using android::wifi_system::HostapdManager;
@@ -31,6 +32,8 @@ using std::vector;
using EncryptionType = android::wifi_system::HostapdManager::EncryptionType;
+using namespace std::placeholders;
+
namespace android {
namespace wificond {
@@ -48,11 +51,18 @@ ApInterfaceImpl::ApInterfaceImpl(const string& interface_name,
// This log keeps compiler happy.
LOG(DEBUG) << "Created ap interface " << interface_name_
<< " with index " << interface_index_;
+
+ netlink_utils_->SubscribeStationEvent(
+ interface_index_,
+ std::bind(&ApInterfaceImpl::OnStationEvent,
+ this,
+ _1, _2));
}
ApInterfaceImpl::~ApInterfaceImpl() {
binder_->NotifyImplDead();
if_tool_->SetUpState(interface_name_.c_str(), false);
+ netlink_utils_->UnsubscribeStationEvent(interface_index_);
}
sp<IApInterface> ApInterfaceImpl::GetBinder() const {
@@ -104,5 +114,18 @@ bool ApInterfaceImpl::WriteHostapdConfig(const vector<uint8_t>& ssid,
return hostapd_manager_->WriteHostapdConfig(config);
}
+void ApInterfaceImpl::OnStationEvent(StationEvent event,
+ const vector<uint8_t>& mac_address) {
+ if (event == NEW_STATION) {
+ LOG(INFO) << "New station "
+ << LoggingUtils::GetMacString(mac_address)
+ << " associated with hotspot";
+ } else if (event == DEL_STATION) {
+ LOG(INFO) << "Station "
+ << LoggingUtils::GetMacString(mac_address)
+ << " disassociated from hotspot";
+ }
+}
+
} // namespace wificond
} // namespace android