Skip to content

Commit

Permalink
Merge pull request #305 from microsoft/hapdifevents
Browse files Browse the repository at this point in the history
Make hostapd WpaEventHandler available to upper layers
  • Loading branch information
abeltrano authored Jul 2, 2024
2 parents 201d04c + 09502dd commit 1445207
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/linux/wpa-controller/Hostapd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<WpaEventHandler>(std::move(controlSocketConnection), WpaType::Hostapd) };
auto eventHandler{ std::make_shared<WpaEventHandler>(std::move(controlSocketConnection), WpaType::Hostapd) };
if (!eventHandler) {
throw HostapdException("Failed to create hostapd event handler");
}
Expand All @@ -64,6 +64,12 @@ Hostapd::GetInterface()
return m_interface;
}

std::shared_ptr<WpaEventHandler>
Hostapd::GetEventHandler() const noexcept
{
return m_eventHandler;
}

void
Hostapd::Ping()
{
Expand Down
10 changes: 9 additions & 1 deletion src/linux/wpa-controller/include/Wpa/Hostapd.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ struct Hostapd :
std::string_view
GetInterface() override;

/**
* @brief Obtain the event handler for the interface.
*
* @return std::shared_ptr<WpaEventHandler>
*/
std::shared_ptr<WpaEventHandler>
GetEventHandler() const noexcept override;

/**
* @brief Get the status for the interface.
*
Expand Down Expand Up @@ -271,7 +279,7 @@ private:
WpaController m_controller;
std::unique_ptr<WpaControlSocketConnection> m_eventHandlerControlSocketConnection{ nullptr };
std::shared_ptr<WpaEventListenerProxy> m_eventListenerProxy;
std::unique_ptr<WpaEventHandler> m_eventHandler{ nullptr };
std::shared_ptr<WpaEventHandler> m_eventHandler{ nullptr };
WpaEventListenerRegistrationToken m_eventHandlerRegistrationToken{};
};
} // namespace Wpa
Expand Down
11 changes: 10 additions & 1 deletion src/linux/wpa-controller/include/Wpa/IHostapd.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <Wpa/ProtocolHostapd.hxx>
#include <Wpa/ProtocolWpa.hxx>
#include <Wpa/WpaEventHandler.hxx>

namespace Wpa
{
Expand Down Expand Up @@ -90,6 +91,14 @@ struct IHostapd
virtual std::string_view
GetInterface() = 0;

/**
* @brief Obtain the event handler for the interface.
*
* @return std::shared_ptr<WpaEventHandler>
*/
virtual std::shared_ptr<WpaEventHandler>
GetEventHandler() const noexcept = 0;

/**
* @brief Get the status for the interface.
*
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1445207

Please sign in to comment.