diff --git a/src/linux/wpa-controller/Hostapd.cxx b/src/linux/wpa-controller/Hostapd.cxx index f38414b1..c8bbad8b 100644 --- a/src/linux/wpa-controller/Hostapd.cxx +++ b/src/linux/wpa-controller/Hostapd.cxx @@ -43,7 +43,7 @@ Hostapd::Hostapd(std::string_view interfaceName) : throw HostapdException("Failed to create hostapd event handler control socket connection"); } - auto eventHandler{ std::make_unique(std::move(controlSocketConnection), WpaType::Hostapd) }; + auto eventHandler{ std::make_shared(std::move(controlSocketConnection), WpaType::Hostapd) }; if (!eventHandler) { throw HostapdException("Failed to create hostapd event handler"); } @@ -64,6 +64,12 @@ Hostapd::GetInterface() return m_interface; } +std::shared_ptr +Hostapd::GetEventHandler() const noexcept +{ + return m_eventHandler; +} + void Hostapd::Ping() { diff --git a/src/linux/wpa-controller/include/Wpa/Hostapd.hxx b/src/linux/wpa-controller/include/Wpa/Hostapd.hxx index 6c2e542d..5d1c3794 100644 --- a/src/linux/wpa-controller/include/Wpa/Hostapd.hxx +++ b/src/linux/wpa-controller/include/Wpa/Hostapd.hxx @@ -93,6 +93,14 @@ struct Hostapd : std::string_view GetInterface() override; + /** + * @brief Obtain the event handler for the interface. + * + * @return std::shared_ptr + */ + std::shared_ptr + GetEventHandler() const noexcept override; + /** * @brief Get the status for the interface. * @@ -271,7 +279,7 @@ private: WpaController m_controller; std::unique_ptr m_eventHandlerControlSocketConnection{ nullptr }; std::shared_ptr m_eventListenerProxy; - std::unique_ptr m_eventHandler{ nullptr }; + std::shared_ptr m_eventHandler{ nullptr }; WpaEventListenerRegistrationToken m_eventHandlerRegistrationToken{}; }; } // namespace Wpa diff --git a/src/linux/wpa-controller/include/Wpa/IHostapd.hxx b/src/linux/wpa-controller/include/Wpa/IHostapd.hxx index f69112af..ea8b143a 100644 --- a/src/linux/wpa-controller/include/Wpa/IHostapd.hxx +++ b/src/linux/wpa-controller/include/Wpa/IHostapd.hxx @@ -12,6 +12,7 @@ #include #include +#include namespace Wpa { @@ -90,6 +91,14 @@ struct IHostapd virtual std::string_view GetInterface() = 0; + /** + * @brief Obtain the event handler for the interface. + * + * @return std::shared_ptr + */ + virtual std::shared_ptr + GetEventHandler() const noexcept = 0; + /** * @brief Get the status for the interface. * @@ -217,7 +226,7 @@ struct IHostapd * @brief Add RADIUS server endpoints to the interface. This may contain multiple endpoints of various types. The * first endpoint configuration for each type is used as the primary server, and any following are used as fallbacks * in case the primary server is unreachable. - * + * * @param endpointConfigurations The endpoint configurations to add. * @param enforceConfigurationChange When to enforce the configuration change. A value of 'Now' will trigger a * configuration reload.