wifi(implementation): Send NAN disabled on wlan0 down & up
When the iface state is toggled for MAC address change on the underlying
interface for NAN operations, send NAN disabled event up to the
framework. The iface down/up toggle resets all NAN operations in the
firmware. So, this callback should trigger a cleanup of any
operations initiated by the framework.
Bug: 132943959
Test: Unit tests in the follow-up CL.
Test: Will send for regression tests.
Change-Id: I760dc5ca3b9276956f5edd40a97c3c13811f442c
diff --git a/wifi/1.3/default/wifi_iface_util.h b/wifi/1.3/default/wifi_iface_util.h
index b238234..325fbe8 100644
--- a/wifi/1.3/default/wifi_iface_util.h
+++ b/wifi/1.3/default/wifi_iface_util.h
@@ -28,6 +28,13 @@
namespace implementation {
namespace iface_util {
+// Iface event handlers.
+struct IfaceEventHandlers {
+ // Callback to be invoked when the iface is set down & up for MAC address
+ // change.
+ std::function<void(const std::string& iface_name)> on_state_toggle_off_on;
+};
+
/**
* Util class for common iface operations.
*/
@@ -45,11 +52,17 @@
// daemon. (So, changes on every reboot)
virtual std::array<uint8_t, 6> getOrCreateRandomMacAddress();
+ // Register for any iface event callbacks for the provided interface.
+ virtual void registerIfaceEventHandlers(const std::string& iface_name,
+ IfaceEventHandlers handlers);
+ virtual void unregisterIfaceEventHandlers(const std::string& iface_name);
+
private:
std::array<uint8_t, 6> createRandomMacAddress();
wifi_system::InterfaceTool iface_tool_;
std::unique_ptr<std::array<uint8_t, 6>> random_mac_address_;
+ std::map<std::string, IfaceEventHandlers> event_handlers_map_;
};
} // namespace iface_util