From 16a059333eb6ea1957fba25db3424ffb0a6c36b4 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jul 2024 20:53:48 +0000 Subject: [PATCH 01/11] Expand IAccessPoint interface with static properties getter. --- src/common/net/wifi/core/AccessPoint.cxx | 6 ++++++ .../include/microsoft/net/wifi/AccessPoint.hxx | 9 +++++++++ .../include/microsoft/net/wifi/IAccessPoint.hxx | 17 +++++++++++++++++ tests/unit/net/wifi/helpers/AccessPointTest.cxx | 6 ++++++ .../microsoft/net/wifi/test/AccessPointTest.hxx | 9 +++++++++ 5 files changed, 47 insertions(+) diff --git a/src/common/net/wifi/core/AccessPoint.cxx b/src/common/net/wifi/core/AccessPoint.cxx index d26f778f..8abb2b08 100644 --- a/src/common/net/wifi/core/AccessPoint.cxx +++ b/src/common/net/wifi/core/AccessPoint.cxx @@ -29,6 +29,12 @@ AccessPoint::GetMacAddress() const noexcept return m_macAddress.value_or(Ieee80211MacAddress{}); } +AccessPointProperties +AccessPoint::GetProperties() const noexcept +{ + return m_properties; +} + std::unique_ptr AccessPoint::CreateController() { diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx index d385fac1..9d5685fb 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx @@ -43,6 +43,14 @@ struct AccessPoint : Ieee80211MacAddress GetMacAddress() const noexcept override; + /** + * @brief Get the static properties of an access point. + * + * @return AccessPointProperties + */ + AccessPointProperties + GetProperties() const noexcept override; + /** * @brief Create a controller object. * @@ -55,6 +63,7 @@ private: const std::string m_interfaceName; std::shared_ptr m_accessPointControllerFactory; std::optional m_macAddress; + AccessPointProperties m_properties{}; }; /** diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx index 7741c5d2..cbafc74c 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx @@ -10,6 +10,15 @@ namespace Microsoft::Net::Wifi { + +/** + * @brief Container to hold static properties about an access point. + */ +struct AccessPointProperties +{ + // TODO: add properties here +}; + /** * @brief Represents a wireless access point. */ @@ -51,6 +60,14 @@ struct IAccessPoint virtual Ieee80211MacAddress GetMacAddress() const noexcept = 0; + /** + * @brief Get the static properties of an access point. + * + * @return AccessPointProperties + */ + virtual AccessPointProperties + GetProperties() const noexcept = 0; + /** * @brief Create a new instance that can control the access point. * diff --git a/tests/unit/net/wifi/helpers/AccessPointTest.cxx b/tests/unit/net/wifi/helpers/AccessPointTest.cxx index d9dc5cd4..9431ae2e 100644 --- a/tests/unit/net/wifi/helpers/AccessPointTest.cxx +++ b/tests/unit/net/wifi/helpers/AccessPointTest.cxx @@ -33,6 +33,12 @@ AccessPointTest::GetMacAddress() const noexcept return MacAddress; } +AccessPointProperties +AccessPointTest::GetProperties() const noexcept +{ + return Properties; +} + std::unique_ptr AccessPointTest::CreateController() { diff --git a/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx b/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx index 4c15941e..10245732 100644 --- a/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx +++ b/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx @@ -40,6 +40,7 @@ struct AccessPointTest final : std::vector AkmSuites; std::unordered_map> CipherSuites; AccessPointOperationalState OperationalState{ AccessPointOperationalState::Disabled }; + AccessPointProperties Properties{}; /** * @brief Construct a new AccessPointTest object with the given interface name and default capabilities. @@ -88,6 +89,14 @@ struct AccessPointTest final : Microsoft::Net::Wifi::Ieee80211MacAddress GetMacAddress() const noexcept override; + /** + * @brief Get the static properties of an access point. + * + * @return AccessPointProperties + */ + AccessPointProperties + GetProperties() const noexcept override; + /** * @brief Create a new instance that can control the access point. * From 0b0220fca00d549d5b66df62bd9c9051baf68222 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jul 2024 21:05:57 +0000 Subject: [PATCH 02/11] Add new skeleton API for obtaining access point properties. --- protocol/protos/NetRemoteService.proto | 1 + protocol/protos/NetRemoteWifi.proto | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/protocol/protos/NetRemoteService.proto b/protocol/protos/NetRemoteService.proto index 5ba02acd..84643398 100644 --- a/protocol/protos/NetRemoteService.proto +++ b/protocol/protos/NetRemoteService.proto @@ -20,4 +20,5 @@ service NetRemote rpc WifiAccessPointSetSsid (Microsoft.Net.Remote.Wifi.WifiAccessPointSetSsidRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetSsidResult); rpc WifiAccessPointSetNetworkBridge (Microsoft.Net.Remote.Wifi.WifiAccessPointSetNetworkBridgeRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetNetworkBridgeResult); rpc WifiAccessPointSetAuthenticationDot1x (Microsoft.Net.Remote.Wifi.WifiAccessPointSetAuthenticationDot1xRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetAuthenticationDot1xResult); + rpc WifiAccessPointGetProperties (Microsoft.Net.Remote.Wifi.WifiAccessPointGetPropertiesRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointGetPropertiesResult); } diff --git a/protocol/protos/NetRemoteWifi.proto b/protocol/protos/NetRemoteWifi.proto index 6d233759..458d42f2 100644 --- a/protocol/protos/NetRemoteWifi.proto +++ b/protocol/protos/NetRemoteWifi.proto @@ -124,3 +124,14 @@ message WifiAccessPointSetAuthenticationDot1xResult string AccessPointId = 1; WifiAccessPointOperationStatus Status = 2; } + +message WifiAccessPointGetPropertiesRequest +{ + string AccessPointId = 1; +} + +message WifiAccessPointGetPropertiesResult +{ + string AccessPointId = 1; + repeated string Properties = 2; +} From dfd19dd099c0e4c8453d410bfb88cfda4149e5f1 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jul 2024 21:06:09 +0000 Subject: [PATCH 03/11] Add properties list to AccessPointProperties. --- protocol/protos/NetRemoteWifi.proto | 3 ++- .../net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/protocol/protos/NetRemoteWifi.proto b/protocol/protos/NetRemoteWifi.proto index 458d42f2..ef96c683 100644 --- a/protocol/protos/NetRemoteWifi.proto +++ b/protocol/protos/NetRemoteWifi.proto @@ -133,5 +133,6 @@ message WifiAccessPointGetPropertiesRequest message WifiAccessPointGetPropertiesResult { string AccessPointId = 1; - repeated string Properties = 2; + WifiAccessPointOperationStatus Status = 2; + repeated string Properties = 3; } diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx index cbafc74c..21405a8c 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx @@ -16,7 +16,7 @@ namespace Microsoft::Net::Wifi */ struct AccessPointProperties { - // TODO: add properties here + std::vector Properties{}; }; /** From f4561ecfc8e9fd9360f33c795d4cdf0be9780fe5 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jul 2024 21:17:25 +0000 Subject: [PATCH 04/11] Add skeleton implementation of WifiAccessPointGetProperties. --- src/common/service/NetRemoteService.cxx | 9 +++++++++ .../net/remote/service/NetRemoteService.hxx | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/common/service/NetRemoteService.cxx b/src/common/service/NetRemoteService.cxx index 4c27f90b..eb74b78d 100644 --- a/src/common/service/NetRemoteService.cxx +++ b/src/common/service/NetRemoteService.cxx @@ -420,6 +420,15 @@ NetRemoteService::WifiAccessPointSetAuthenticationDot1x([[maybe_unused]] grpc::S return grpc::Status::OK; } +::grpc::Status +NetRemoteService::WifiAccessPointGetProperties(grpc::ServerContext* context, const WifiAccessPointGetPropertiesRequest* request, WifiAccessPointGetPropertiesResult* result) +{ + AccessPointOperationStatus operationStatus{ request->accesspointid() }; + const NetRemoteWifiApiTrace traceMe{ request->accesspointid(), result->mutable_status() }; + + return grpc::Status::OK; +} + AccessPointOperationStatus NetRemoteService::TryGetAccessPoint(std::string_view accessPointId, std::shared_ptr& accessPoint) { diff --git a/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx b/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx index 5512d94a..05b4faa2 100644 --- a/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx +++ b/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx @@ -146,6 +146,17 @@ private: grpc::Status WifiAccessPointSetAuthenticationDot1x(grpc::ServerContext* context, const Microsoft::Net::Remote::Wifi::WifiAccessPointSetAuthenticationDot1xRequest* request, Microsoft::Net::Remote::Wifi::WifiAccessPointSetAuthenticationDot1xResult* result) override; + /** + * @brief Get the properties of the specified access point. + * + * @param context + * @param request + * @param result + * @return ::grpc::Status + */ + ::grpc::Status + WifiAccessPointGetProperties(grpc::ServerContext* context, const Microsoft::Net::Remote::Wifi::WifiAccessPointGetPropertiesRequest* request, Microsoft::Net::Remote::Wifi::WifiAccessPointGetPropertiesResult* result) override; + protected: /** * @brief Attempt to obtain an IAccessPoint instance for the specified access point identifier. @@ -294,11 +305,11 @@ protected: /** * @brief Set the IEEE 802.1x configuration for the access point. - * + * * @param accessPointId The access point identifier. * @param dot11AuthenticationDot1x The new IEEE 802.1x configuration to set. * @param accessPointController The access point controller for the specified access point (optional). - * @return Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus + * @return Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus */ Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus WifiAccessPointSetAuthenticationDot1xImpl(std::string_view accessPointId, const Microsoft::Net::Wifi::Dot11AuthenticationDot1x& dot11AuthenticationDot1x, std::shared_ptr accessPointController = nullptr); From 29610edd696ee0196e06e67fa9b588929a92e35c Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jul 2024 21:30:35 +0000 Subject: [PATCH 05/11] Add initial implementation of WifiAcessPointGetProperties. --- src/common/service/NetRemoteService.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/common/service/NetRemoteService.cxx b/src/common/service/NetRemoteService.cxx index eb74b78d..238efb9a 100644 --- a/src/common/service/NetRemoteService.cxx +++ b/src/common/service/NetRemoteService.cxx @@ -421,10 +421,28 @@ NetRemoteService::WifiAccessPointSetAuthenticationDot1x([[maybe_unused]] grpc::S } ::grpc::Status -NetRemoteService::WifiAccessPointGetProperties(grpc::ServerContext* context, const WifiAccessPointGetPropertiesRequest* request, WifiAccessPointGetPropertiesResult* result) +NetRemoteService::WifiAccessPointGetProperties([[maybe_unused]] grpc::ServerContext* context, const WifiAccessPointGetPropertiesRequest* request, WifiAccessPointGetPropertiesResult* result) { - AccessPointOperationStatus operationStatus{ request->accesspointid() }; + WifiAccessPointOperationStatus wifiOperationStatus{}; const NetRemoteWifiApiTrace traceMe{ request->accesspointid(), result->mutable_status() }; + const auto accessPointId{ request->accesspointid() }; + + // Obtain the access point specified in the request. + std::shared_ptr accessPoint{}; + auto operationStatus = TryGetAccessPoint(accessPointId, accessPoint); + if (!operationStatus.Succeeded()) { + wifiOperationStatus.set_code(ToDot11AccessPointOperationStatusCode(operationStatus.Code)); + return grpc::Status::OK; + } + + // Populate the result with the access point properties. + { + auto properties = accessPoint->GetProperties(); + *result->mutable_properties() = { + std::make_move_iterator(std::begin(properties.Properties)), + std::make_move_iterator(std::end(properties.Properties)), + }; + } return grpc::Status::OK; } From 9a7d2cd5edb6a01e16888d4004d0ee189f7b976c Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jul 2024 21:49:06 +0000 Subject: [PATCH 06/11] Ensure access point id is reflected in result. --- src/common/service/NetRemoteService.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/service/NetRemoteService.cxx b/src/common/service/NetRemoteService.cxx index 238efb9a..a2cd89ae 100644 --- a/src/common/service/NetRemoteService.cxx +++ b/src/common/service/NetRemoteService.cxx @@ -427,6 +427,8 @@ NetRemoteService::WifiAccessPointGetProperties([[maybe_unused]] grpc::ServerCont const NetRemoteWifiApiTrace traceMe{ request->accesspointid(), result->mutable_status() }; const auto accessPointId{ request->accesspointid() }; + *result->mutable_accesspointid() = accessPointId; + // Obtain the access point specified in the request. std::shared_ptr accessPoint{}; auto operationStatus = TryGetAccessPoint(accessPointId, accessPoint); From c192c674b6b86d8185745cbee7ad599b7621f91b Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jul 2024 21:49:26 +0000 Subject: [PATCH 07/11] Add basic unit test for WifiAccessPointGetProperties. --- tests/unit/TestNetRemoteServiceClient.cxx | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/unit/TestNetRemoteServiceClient.cxx b/tests/unit/TestNetRemoteServiceClient.cxx index 66ae534c..58ecce77 100644 --- a/tests/unit/TestNetRemoteServiceClient.cxx +++ b/tests/unit/TestNetRemoteServiceClient.cxx @@ -1124,3 +1124,62 @@ TEST_CASE("WifiAccessPointSetAuthenticationDot1x API", "[basic][rpc][client][rem } } } + +TEST_CASE("WifiAccessPointGetProperties API", "[basic][rpc][client][remote]") +{ + using namespace Microsoft::Net::Remote; + using namespace Microsoft::Net::Remote::Service; + using namespace Microsoft::Net::Remote::Test; + using namespace Microsoft::Net::Remote::Wifi; + using namespace Microsoft::Net::Wifi; + using namespace Microsoft::Net::Wifi::Test; + + constexpr auto InterfaceName{ "TestWifiAccessPointGetProperties" }; + constexpr auto InterfaceProperty{ "TestProperty1" }; + + auto apManagerTest = std::make_shared(); + const Ieee80211AccessPointCapabilities apCapabilities{ + .PhyTypes{ std::cbegin(AllPhyTypes), std::cend(AllPhyTypes) } + }; + + auto apTest = std::make_shared(InterfaceName, apCapabilities); + apTest->Properties.Properties.push_back(InterfaceProperty); + apManagerTest->AddAccessPoint(apTest); + + const auto serverConfiguration = CreateServerConfiguration(apManagerTest); + NetRemoteServer server{ serverConfiguration }; + server.Run(); + + auto channel = grpc::CreateChannel(RemoteServiceAddressHttp, grpc::InsecureChannelCredentials()); + auto client = NetRemote::NewStub(channel); + + SECTION("Can be called") + { + WifiAccessPointGetPropertiesRequest request{}; + request.set_accesspointid(InterfaceName); + + WifiAccessPointGetPropertiesResult result{}; + grpc::ClientContext clientContext{}; + + grpc::Status status; + REQUIRE_NOTHROW(status = client->WifiAccessPointGetProperties(&clientContext, request, &result)); + REQUIRE(status.ok()); + REQUIRE(result.accesspointid() == request.accesspointid()); + } + + SECTION("Properties are properly reflected") + { + WifiAccessPointGetPropertiesRequest request{}; + request.set_accesspointid(InterfaceName); + + WifiAccessPointGetPropertiesResult result{}; + grpc::ClientContext clientContext{}; + + grpc::Status status; + REQUIRE_NOTHROW(status = client->WifiAccessPointGetProperties(&clientContext, request, &result)); + REQUIRE(status.ok()); + REQUIRE(result.accesspointid() == request.accesspointid()); + REQUIRE(std::size(result.properties()) == 1); + REQUIRE(result.properties()[0] == InterfaceProperty); + } +} From a315274da024d5e7393a02424ce28c9f89ebd879 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Fri, 26 Jul 2024 22:32:01 +0000 Subject: [PATCH 08/11] Add ap properties to ap ctors. --- src/common/net/wifi/core/AccessPoint.cxx | 3 ++- .../wifi/core/include/microsoft/net/wifi/AccessPoint.hxx | 6 ++++-- .../wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx | 2 ++ src/linux/net/wifi/core/AccessPointLinux.cxx | 6 +++--- .../core/include/microsoft/net/wifi/AccessPointLinux.hxx | 3 ++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/common/net/wifi/core/AccessPoint.cxx b/src/common/net/wifi/core/AccessPoint.cxx index 8abb2b08..a7e0e80c 100644 --- a/src/common/net/wifi/core/AccessPoint.cxx +++ b/src/common/net/wifi/core/AccessPoint.cxx @@ -11,9 +11,10 @@ using namespace Microsoft::Net::Wifi; -AccessPoint::AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, std::optional macAddress) : +AccessPoint::AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, AccessPointProperties properties, std::optional macAddress) : m_interfaceName(interfaceName), m_accessPointControllerFactory(std::move(accessPointControllerFactory)), + m_properties(std::move(properties)), m_macAddress(macAddress) {} diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx index 9d5685fb..0881297b 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx @@ -24,8 +24,10 @@ struct AccessPoint : * * @param interfaceName The network interface name representing the access point. * @param accessPointControllerFactory The factory used to create controller objects. + * @param properties The static properties of the access point. + * @param macAddress The mac address of the access point. */ - AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, std::optional macAddress = std::nullopt); + AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, AccessPointProperties properties = {}, std::optional macAddress = std::nullopt); /** * @brief Get the network interface name representing the access point. @@ -62,8 +64,8 @@ struct AccessPoint : private: const std::string m_interfaceName; std::shared_ptr m_accessPointControllerFactory; - std::optional m_macAddress; AccessPointProperties m_properties{}; + std::optional m_macAddress; }; /** diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx index 21405a8c..2f2c58b7 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx @@ -98,6 +98,8 @@ struct IAccessPointCreateArgs IAccessPointCreateArgs& operator=(IAccessPointCreateArgs&&) = delete; + + AccessPointProperties Properties{}; }; /** diff --git a/src/linux/net/wifi/core/AccessPointLinux.cxx b/src/linux/net/wifi/core/AccessPointLinux.cxx index fc580bd5..e3faf876 100644 --- a/src/linux/net/wifi/core/AccessPointLinux.cxx +++ b/src/linux/net/wifi/core/AccessPointLinux.cxx @@ -16,8 +16,8 @@ using Microsoft::Net::Netlink::Nl80211::Nl80211Interface; using namespace Microsoft::Net::Wifi; -AccessPointLinux::AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Nl80211Interface nl80211Interface) : - AccessPoint(interfaceName, std::move(accessPointControllerFactory)), +AccessPointLinux::AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Nl80211Interface nl80211Interface, AccessPointProperties properties) : + AccessPoint(interfaceName, std::move(accessPointControllerFactory), std::move(properties)), m_nl80211Interface{ std::move(nl80211Interface) } { } @@ -42,7 +42,7 @@ AccessPointFactoryLinux::Create(std::string_view interfaceName, std::unique_ptr< throw std::runtime_error("invalid arguments passed to AccessPointFactoryLinux::Create; this is a bug!"); } - return std::make_shared(interfaceName, GetControllerFactory(), std::move(createArgsLinux->Interface)); + return std::make_shared(interfaceName, GetControllerFactory(), std::move(createArgsLinux->Interface), std::move(createArgs->Properties)); } AccessPointCreateArgsLinux::AccessPointCreateArgsLinux(Nl80211Interface nl80211Interface) : diff --git a/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx b/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx index 740fdbcf..99802942 100644 --- a/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx +++ b/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx @@ -26,8 +26,9 @@ struct AccessPointLinux : * @param interfaceName The name of the interface. * @param accessPointControllerFactory The access point controller factory to use for creating access point. * @param nl80211Interface The nl80211 interface object. + * @param properties The static properties of the access point. */ - AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Microsoft::Net::Netlink::Nl80211::Nl80211Interface nl80211Interface); + AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Microsoft::Net::Netlink::Nl80211::Nl80211Interface nl80211Interface, AccessPointProperties properties = {}); /** * @brief Get the mac address of the access point. From f540afc169fed1b5aef24b7f48e60e572fd9f779 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Fri, 26 Jul 2024 22:46:55 +0000 Subject: [PATCH 09/11] Update IAccessPoint::GetProperties() to return const& instead of value-copy. --- src/common/net/wifi/core/AccessPoint.cxx | 2 +- .../net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx | 4 ++-- .../net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx | 4 ++-- tests/unit/net/wifi/helpers/AccessPointTest.cxx | 2 +- .../include/microsoft/net/wifi/test/AccessPointTest.hxx | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/net/wifi/core/AccessPoint.cxx b/src/common/net/wifi/core/AccessPoint.cxx index a7e0e80c..d031853a 100644 --- a/src/common/net/wifi/core/AccessPoint.cxx +++ b/src/common/net/wifi/core/AccessPoint.cxx @@ -30,7 +30,7 @@ AccessPoint::GetMacAddress() const noexcept return m_macAddress.value_or(Ieee80211MacAddress{}); } -AccessPointProperties +const AccessPointProperties& AccessPoint::GetProperties() const noexcept { return m_properties; diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx index 0881297b..fb4b8403 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx @@ -48,9 +48,9 @@ struct AccessPoint : /** * @brief Get the static properties of an access point. * - * @return AccessPointProperties + * @return AccessPointProperties& */ - AccessPointProperties + const AccessPointProperties& GetProperties() const noexcept override; /** diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx index 2f2c58b7..ad2ed2cc 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx @@ -63,9 +63,9 @@ struct IAccessPoint /** * @brief Get the static properties of an access point. * - * @return AccessPointProperties + * @return AccessPointProperties& */ - virtual AccessPointProperties + virtual const AccessPointProperties& GetProperties() const noexcept = 0; /** diff --git a/tests/unit/net/wifi/helpers/AccessPointTest.cxx b/tests/unit/net/wifi/helpers/AccessPointTest.cxx index 9431ae2e..0ed50de9 100644 --- a/tests/unit/net/wifi/helpers/AccessPointTest.cxx +++ b/tests/unit/net/wifi/helpers/AccessPointTest.cxx @@ -33,7 +33,7 @@ AccessPointTest::GetMacAddress() const noexcept return MacAddress; } -AccessPointProperties +const AccessPointProperties& AccessPointTest::GetProperties() const noexcept { return Properties; diff --git a/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx b/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx index 10245732..5eac2a43 100644 --- a/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx +++ b/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx @@ -92,9 +92,9 @@ struct AccessPointTest final : /** * @brief Get the static properties of an access point. * - * @return AccessPointProperties + * @return AccessPointProperties& */ - AccessPointProperties + const AccessPointProperties& GetProperties() const noexcept override; /** From 3e8a214ba4d82c418b20804d1c0a808b3fd8a251 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Fri, 26 Jul 2024 22:59:24 +0000 Subject: [PATCH 10/11] Add impl function for WifiAccessPointGetProperties. --- src/common/service/NetRemoteService.cxx | 54 ++++++++++++------- .../net/remote/service/NetRemoteService.hxx | 20 +++++-- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/common/service/NetRemoteService.cxx b/src/common/service/NetRemoteService.cxx index a2cd89ae..faf4edf9 100644 --- a/src/common/service/NetRemoteService.cxx +++ b/src/common/service/NetRemoteService.cxx @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -423,28 +424,11 @@ NetRemoteService::WifiAccessPointSetAuthenticationDot1x([[maybe_unused]] grpc::S ::grpc::Status NetRemoteService::WifiAccessPointGetProperties([[maybe_unused]] grpc::ServerContext* context, const WifiAccessPointGetPropertiesRequest* request, WifiAccessPointGetPropertiesResult* result) { - WifiAccessPointOperationStatus wifiOperationStatus{}; const NetRemoteWifiApiTrace traceMe{ request->accesspointid(), result->mutable_status() }; - const auto accessPointId{ request->accesspointid() }; - - *result->mutable_accesspointid() = accessPointId; - // Obtain the access point specified in the request. - std::shared_ptr accessPoint{}; - auto operationStatus = TryGetAccessPoint(accessPointId, accessPoint); - if (!operationStatus.Succeeded()) { - wifiOperationStatus.set_code(ToDot11AccessPointOperationStatusCode(operationStatus.Code)); - return grpc::Status::OK; - } - - // Populate the result with the access point properties. - { - auto properties = accessPoint->GetProperties(); - *result->mutable_properties() = { - std::make_move_iterator(std::begin(properties.Properties)), - std::make_move_iterator(std::end(properties.Properties)), - }; - } + auto wifiOperationStatus = WifiAccessPointGetPropertiesImpl(request->accesspointid(), *result->mutable_properties()); + result->set_accesspointid(request->accesspointid()); + *result->mutable_status() = std::move(wifiOperationStatus); return grpc::Status::OK; } @@ -1282,3 +1266,33 @@ NetRemoteService::WifiAccessPointSetAuthenticationDot1xImpl(std::string_view acc return wifiOperationStatus; } + +using google::protobuf::RepeatedPtrField; + +WifiAccessPointOperationStatus +NetRemoteService::WifiAccessPointGetPropertiesImpl(std::string_view accessPointId, RepeatedPtrField& accessPointProperties) +{ + WifiAccessPointOperationStatus wifiOperationStatus{}; + + // Obtain the access point specified in the request. + std::shared_ptr accessPoint{}; + auto operationStatus = TryGetAccessPoint(accessPointId, accessPoint); + if (!operationStatus.Succeeded()) { + wifiOperationStatus.set_code(ToDot11AccessPointOperationStatusCode(operationStatus.Code)); + wifiOperationStatus.set_message(std::format("Failed to get access point {} - {}", accessPointId, operationStatus.ToString())); + return wifiOperationStatus; + } + + // Populate output argument with a copy of the access point properties. + { + auto properties = accessPoint->GetProperties(); + accessPointProperties = { + std::make_move_iterator(std::begin(properties.Properties)), + std::make_move_iterator(std::end(properties.Properties)), + }; + } + + wifiOperationStatus.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded); + + return wifiOperationStatus; +} diff --git a/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx b/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx index 05b4faa2..9788ec16 100644 --- a/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx +++ b/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx @@ -3,8 +3,10 @@ #define NET_REMOTE_SERVICE_HXX #include +#include #include +#include #include #include #include @@ -148,11 +150,11 @@ private: /** * @brief Get the properties of the specified access point. - * - * @param context - * @param request + * + * @param context + * @param request * @param result - * @return ::grpc::Status + * @return ::grpc::Status */ ::grpc::Status WifiAccessPointGetProperties(grpc::ServerContext* context, const Microsoft::Net::Remote::Wifi::WifiAccessPointGetPropertiesRequest* request, Microsoft::Net::Remote::Wifi::WifiAccessPointGetPropertiesResult* result) override; @@ -314,6 +316,16 @@ protected: Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus WifiAccessPointSetAuthenticationDot1xImpl(std::string_view accessPointId, const Microsoft::Net::Wifi::Dot11AuthenticationDot1x& dot11AuthenticationDot1x, std::shared_ptr accessPointController = nullptr); + /** + * @brief Get the properties of the specified access point. + * + * @param accessPointId The access point identifier. + * @param accessPointProperties Output variable to receive the access point properties. + * @return Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus + */ + Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus + WifiAccessPointGetPropertiesImpl(std::string_view accessPointId, google::protobuf::RepeatedPtrField& accessPointProperties); + private: std::shared_ptr m_networkManager; std::shared_ptr m_accessPointManager; From c8fd8953f6070335c0b561718cc26fb375fa5a29 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Sat, 27 Jul 2024 03:27:16 +0000 Subject: [PATCH 11/11] Overhaul properties -> attributes. --- protocol/protos/NetRemoteService.proto | 2 +- protocol/protos/NetRemoteWifi.proto | 6 ++-- protocol/protos/WifiCore.proto | 5 +++ src/common/net/wifi/core/AccessPoint.cxx | 10 +++--- .../microsoft/net/wifi/AccessPoint.hxx | 14 ++++---- .../microsoft/net/wifi/IAccessPoint.hxx | 17 +++++----- .../dot11/adapter/Ieee80211Dot11Adapters.cxx | 32 +++++++++++++++++-- .../net/wifi/Ieee80211Dot11Adapters.hxx | 27 +++++++++++++--- src/common/service/NetRemoteService.cxx | 19 +++++------ .../net/remote/service/NetRemoteService.hxx | 10 +++--- src/linux/net/wifi/core/AccessPointLinux.cxx | 6 ++-- .../microsoft/net/wifi/AccessPointLinux.hxx | 4 +-- tests/unit/TestNetRemoteServiceClient.cxx | 32 ++++++++++++------- .../unit/net/wifi/helpers/AccessPointTest.cxx | 6 ++-- .../net/wifi/test/AccessPointTest.hxx | 10 +++--- 15 files changed, 128 insertions(+), 72 deletions(-) diff --git a/protocol/protos/NetRemoteService.proto b/protocol/protos/NetRemoteService.proto index 84643398..849ecfbb 100644 --- a/protocol/protos/NetRemoteService.proto +++ b/protocol/protos/NetRemoteService.proto @@ -20,5 +20,5 @@ service NetRemote rpc WifiAccessPointSetSsid (Microsoft.Net.Remote.Wifi.WifiAccessPointSetSsidRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetSsidResult); rpc WifiAccessPointSetNetworkBridge (Microsoft.Net.Remote.Wifi.WifiAccessPointSetNetworkBridgeRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetNetworkBridgeResult); rpc WifiAccessPointSetAuthenticationDot1x (Microsoft.Net.Remote.Wifi.WifiAccessPointSetAuthenticationDot1xRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetAuthenticationDot1xResult); - rpc WifiAccessPointGetProperties (Microsoft.Net.Remote.Wifi.WifiAccessPointGetPropertiesRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointGetPropertiesResult); + rpc WifiAccessPointGetAttributes (Microsoft.Net.Remote.Wifi.WifiAccessPointGetAttributesRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointGetAttributesResult); } diff --git a/protocol/protos/NetRemoteWifi.proto b/protocol/protos/NetRemoteWifi.proto index ef96c683..9e905caa 100644 --- a/protocol/protos/NetRemoteWifi.proto +++ b/protocol/protos/NetRemoteWifi.proto @@ -125,14 +125,14 @@ message WifiAccessPointSetAuthenticationDot1xResult WifiAccessPointOperationStatus Status = 2; } -message WifiAccessPointGetPropertiesRequest +message WifiAccessPointGetAttributesRequest { string AccessPointId = 1; } -message WifiAccessPointGetPropertiesResult +message WifiAccessPointGetAttributesResult { string AccessPointId = 1; WifiAccessPointOperationStatus Status = 2; - repeated string Properties = 3; + Microsoft.Net.Wifi.Dot11AccessPointAttributes Attributes = 3; } diff --git a/protocol/protos/WifiCore.proto b/protocol/protos/WifiCore.proto index 58f799f9..219c2d76 100644 --- a/protocol/protos/WifiCore.proto +++ b/protocol/protos/WifiCore.proto @@ -224,6 +224,11 @@ message Dot11AccessPointCapabilities repeated Microsoft.Net.Wifi.Dot11AkmSuite AkmSuites = 5; } +message Dot11AccessPointAttributes +{ + map Properties = 1; +} + enum Dot11AccessPointState { AccessPointStateUnknown = 0; diff --git a/src/common/net/wifi/core/AccessPoint.cxx b/src/common/net/wifi/core/AccessPoint.cxx index d031853a..2f325215 100644 --- a/src/common/net/wifi/core/AccessPoint.cxx +++ b/src/common/net/wifi/core/AccessPoint.cxx @@ -11,10 +11,10 @@ using namespace Microsoft::Net::Wifi; -AccessPoint::AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, AccessPointProperties properties, std::optional macAddress) : +AccessPoint::AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, AccessPointAttributes attributes, std::optional macAddress) : m_interfaceName(interfaceName), m_accessPointControllerFactory(std::move(accessPointControllerFactory)), - m_properties(std::move(properties)), + m_attributes(std::move(attributes)), m_macAddress(macAddress) {} @@ -30,10 +30,10 @@ AccessPoint::GetMacAddress() const noexcept return m_macAddress.value_or(Ieee80211MacAddress{}); } -const AccessPointProperties& -AccessPoint::GetProperties() const noexcept +const AccessPointAttributes& +AccessPoint::GetAttributes() const noexcept { - return m_properties; + return m_attributes; } std::unique_ptr diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx index fb4b8403..6dcca029 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/AccessPoint.hxx @@ -24,10 +24,10 @@ struct AccessPoint : * * @param interfaceName The network interface name representing the access point. * @param accessPointControllerFactory The factory used to create controller objects. - * @param properties The static properties of the access point. + * @param attributes The static attributes of the access point. * @param macAddress The mac address of the access point. */ - AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, AccessPointProperties properties = {}, std::optional macAddress = std::nullopt); + AccessPoint(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, AccessPointAttributes attributes = {}, std::optional macAddress = std::nullopt); /** * @brief Get the network interface name representing the access point. @@ -46,12 +46,12 @@ struct AccessPoint : GetMacAddress() const noexcept override; /** - * @brief Get the static properties of an access point. + * @brief Get the static attributes of an access point. * - * @return AccessPointProperties& + * @return AccessPointAttributes& */ - const AccessPointProperties& - GetProperties() const noexcept override; + const AccessPointAttributes& + GetAttributes() const noexcept override; /** * @brief Create a controller object. @@ -64,7 +64,7 @@ struct AccessPoint : private: const std::string m_interfaceName; std::shared_ptr m_accessPointControllerFactory; - AccessPointProperties m_properties{}; + AccessPointAttributes m_attributes{}; std::optional m_macAddress; }; diff --git a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx index ad2ed2cc..936921d8 100644 --- a/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx +++ b/src/common/net/wifi/core/include/microsoft/net/wifi/IAccessPoint.hxx @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -12,11 +13,11 @@ namespace Microsoft::Net::Wifi { /** - * @brief Container to hold static properties about an access point. + * @brief Container to hold static attributes about an access point. */ -struct AccessPointProperties +struct AccessPointAttributes { - std::vector Properties{}; + std::unordered_map Properties{}; }; /** @@ -61,12 +62,12 @@ struct IAccessPoint GetMacAddress() const noexcept = 0; /** - * @brief Get the static properties of an access point. + * @brief Get the static attributes of an access point. * - * @return AccessPointProperties& + * @return AccessPointAttributes& */ - virtual const AccessPointProperties& - GetProperties() const noexcept = 0; + virtual const AccessPointAttributes& + GetAttributes() const noexcept = 0; /** * @brief Create a new instance that can control the access point. @@ -99,7 +100,7 @@ struct IAccessPointCreateArgs IAccessPointCreateArgs& operator=(IAccessPointCreateArgs&&) = delete; - AccessPointProperties Properties{}; + AccessPointAttributes Attributes{}; }; /** diff --git a/src/common/net/wifi/dot11/adapter/Ieee80211Dot11Adapters.cxx b/src/common/net/wifi/dot11/adapter/Ieee80211Dot11Adapters.cxx index 8a14c132..39082cf8 100644 --- a/src/common/net/wifi/dot11/adapter/Ieee80211Dot11Adapters.cxx +++ b/src/common/net/wifi/dot11/adapter/Ieee80211Dot11Adapters.cxx @@ -835,15 +835,41 @@ FromDot11AuthenticationDot1x(const Dot11AuthenticationDot1x& Dot11Authentication Dot11AuthenticationDot1x ToDot11AuthenticationDot1x(const Ieee80211Authentication8021x& ieee8021xAuthentication) noexcept { - Dot11AuthenticationDot1x Dot11AuthenticationDot1x{}; + Dot11AuthenticationDot1x dot11AuthenticationDot1x{}; // Convert RADIUS configuration, if present. if (ieee8021xAuthentication.Radius.has_value()) { auto dot1xRadiusConfiguration = ToServiceDot1xRadiusConfiguration(ieee8021xAuthentication.Radius.value()); - *Dot11AuthenticationDot1x.mutable_radius() = std::move(dot1xRadiusConfiguration); + *dot11AuthenticationDot1x.mutable_radius() = std::move(dot1xRadiusConfiguration); } - return Dot11AuthenticationDot1x; + return dot11AuthenticationDot1x; +} + +AccessPointAttributes +FromDot11AccessPointAttributes(const Dot11AccessPointAttributes& dot11AccessPointConfiguration) noexcept +{ + AccessPointAttributes accessPointAttributes{}; + + accessPointAttributes.Properties = { + std::cbegin(dot11AccessPointConfiguration.properties()), + std::cend(dot11AccessPointConfiguration.properties()), + }; + + return accessPointAttributes; +} + +Dot11AccessPointAttributes +ToDot11AccessPointAttributes(const AccessPointAttributes& accessPointAttributes) noexcept +{ + Dot11AccessPointAttributes dot11AccessPointAttributes{}; + + *dot11AccessPointAttributes.mutable_properties() = { + std::make_move_iterator(std::begin(accessPointAttributes.Properties)), + std::make_move_iterator(std::end(accessPointAttributes.Properties)), + }; + + return dot11AccessPointAttributes; } } // namespace Microsoft::Net::Wifi diff --git a/src/common/net/wifi/dot11/adapter/include/microsoft/net/wifi/Ieee80211Dot11Adapters.hxx b/src/common/net/wifi/dot11/adapter/include/microsoft/net/wifi/Ieee80211Dot11Adapters.hxx index 266cdef5..b941c6eb 100644 --- a/src/common/net/wifi/dot11/adapter/include/microsoft/net/wifi/Ieee80211Dot11Adapters.hxx +++ b/src/common/net/wifi/dot11/adapter/include/microsoft/net/wifi/Ieee80211Dot11Adapters.hxx @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -360,22 +361,40 @@ ToDot11AuthenticationData(const Ieee80211AuthenticationData& ieee80211Authentica /** * @brief Convert the specified Dot11AuthenticationDot1x to the equivalent IEEE 802.1x authentication. - * + * * @param dot11AuthenticationDot1x The Dot11AuthenticationDot1x to convert. - * @return Ieee80211Authentication8021x + * @return Ieee80211Authentication8021x */ Ieee80211Authentication8021x FromDot11AuthenticationDot1x(const Dot11AuthenticationDot1x& dot11AuthenticationDot1x) noexcept; /** * @brief Convert the specified IEEE 802.1x authentication to the equivalent Dot11AuthenticationDot1x. - * + * * @param ieee8021xAuthentication The IEEE 802.1x authentication to convert. - * @return Dot11AuthenticationDot1x + * @return Dot11AuthenticationDot1x */ Dot11AuthenticationDot1x ToDot11AuthenticationDot1x(const Ieee80211Authentication8021x& ieee8021xAuthentication) noexcept; +/** + * @brief Convert the specified Dot11AccessPointAttributes to the equivalent neutral type access point attributes. + * + * @param dot11AccessPointConfiguration The Dot11AccessPointAttributes to convert. + * @return AccessPointAttributes + */ +AccessPointAttributes +FromDot11AccessPointAttributes(const Dot11AccessPointAttributes& dot11AccessPointConfiguration) noexcept; + +/** + * @brief Convert the specified neutral type access point attributes to the equivalent Dot11AccessPointAttributes. + * + * @param accessPointAttributes The IEEE 802.11 access point configuration to convert. + * @return Dot11AccessPointAttributes + */ +Dot11AccessPointAttributes +ToDot11AccessPointAttributes(const AccessPointAttributes& accessPointAttributes) noexcept; + } // namespace Microsoft::Net::Wifi #endif // IEEE_80211_DOT11_ADAPTERS_HXX diff --git a/src/common/service/NetRemoteService.cxx b/src/common/service/NetRemoteService.cxx index faf4edf9..f8e4eb83 100644 --- a/src/common/service/NetRemoteService.cxx +++ b/src/common/service/NetRemoteService.cxx @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -422,11 +422,11 @@ NetRemoteService::WifiAccessPointSetAuthenticationDot1x([[maybe_unused]] grpc::S } ::grpc::Status -NetRemoteService::WifiAccessPointGetProperties([[maybe_unused]] grpc::ServerContext* context, const WifiAccessPointGetPropertiesRequest* request, WifiAccessPointGetPropertiesResult* result) +NetRemoteService::WifiAccessPointGetAttributes([[maybe_unused]] grpc::ServerContext* context, const WifiAccessPointGetAttributesRequest* request, WifiAccessPointGetAttributesResult* result) { const NetRemoteWifiApiTrace traceMe{ request->accesspointid(), result->mutable_status() }; - auto wifiOperationStatus = WifiAccessPointGetPropertiesImpl(request->accesspointid(), *result->mutable_properties()); + auto wifiOperationStatus = WifiAccessPointGetAttributesImpl(request->accesspointid(), *result->mutable_attributes()); result->set_accesspointid(request->accesspointid()); *result->mutable_status() = std::move(wifiOperationStatus); @@ -1267,10 +1267,10 @@ NetRemoteService::WifiAccessPointSetAuthenticationDot1xImpl(std::string_view acc return wifiOperationStatus; } -using google::protobuf::RepeatedPtrField; +using google::protobuf::Map; WifiAccessPointOperationStatus -NetRemoteService::WifiAccessPointGetPropertiesImpl(std::string_view accessPointId, RepeatedPtrField& accessPointProperties) +NetRemoteService::WifiAccessPointGetAttributesImpl(std::string_view accessPointId, Dot11AccessPointAttributes& dot11AccessPointAttributes) { WifiAccessPointOperationStatus wifiOperationStatus{}; @@ -1283,13 +1283,10 @@ NetRemoteService::WifiAccessPointGetPropertiesImpl(std::string_view accessPointI return wifiOperationStatus; } - // Populate output argument with a copy of the access point properties. + // Populate output argument with a copy of the access point attributes. { - auto properties = accessPoint->GetProperties(); - accessPointProperties = { - std::make_move_iterator(std::begin(properties.Properties)), - std::make_move_iterator(std::end(properties.Properties)), - }; + auto accessPointAttributes = accessPoint->GetAttributes(); + dot11AccessPointAttributes = ToDot11AccessPointAttributes(accessPointAttributes); } wifiOperationStatus.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded); diff --git a/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx b/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx index 9788ec16..806db09b 100644 --- a/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx +++ b/src/common/service/include/microsoft/net/remote/service/NetRemoteService.hxx @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -157,7 +157,7 @@ private: * @return ::grpc::Status */ ::grpc::Status - WifiAccessPointGetProperties(grpc::ServerContext* context, const Microsoft::Net::Remote::Wifi::WifiAccessPointGetPropertiesRequest* request, Microsoft::Net::Remote::Wifi::WifiAccessPointGetPropertiesResult* result) override; + WifiAccessPointGetAttributes(grpc::ServerContext* context, const Microsoft::Net::Remote::Wifi::WifiAccessPointGetAttributesRequest* request, Microsoft::Net::Remote::Wifi::WifiAccessPointGetAttributesResult* result) override; protected: /** @@ -317,14 +317,14 @@ protected: WifiAccessPointSetAuthenticationDot1xImpl(std::string_view accessPointId, const Microsoft::Net::Wifi::Dot11AuthenticationDot1x& dot11AuthenticationDot1x, std::shared_ptr accessPointController = nullptr); /** - * @brief Get the properties of the specified access point. + * @brief Get the sttaic attributes of the specified access point. * * @param accessPointId The access point identifier. - * @param accessPointProperties Output variable to receive the access point properties. + * @param dot11AccessPointAttributes Output variable to receive the access point attributes. * @return Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus */ Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus - WifiAccessPointGetPropertiesImpl(std::string_view accessPointId, google::protobuf::RepeatedPtrField& accessPointProperties); + WifiAccessPointGetAttributesImpl(std::string_view accessPointId, Microsoft::Net::Wifi::Dot11AccessPointAttributes& dot11AccessPointAttributes); private: std::shared_ptr m_networkManager; diff --git a/src/linux/net/wifi/core/AccessPointLinux.cxx b/src/linux/net/wifi/core/AccessPointLinux.cxx index e3faf876..6d3e4d9e 100644 --- a/src/linux/net/wifi/core/AccessPointLinux.cxx +++ b/src/linux/net/wifi/core/AccessPointLinux.cxx @@ -16,8 +16,8 @@ using Microsoft::Net::Netlink::Nl80211::Nl80211Interface; using namespace Microsoft::Net::Wifi; -AccessPointLinux::AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Nl80211Interface nl80211Interface, AccessPointProperties properties) : - AccessPoint(interfaceName, std::move(accessPointControllerFactory), std::move(properties)), +AccessPointLinux::AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Nl80211Interface nl80211Interface, AccessPointAttributes attributes) : + AccessPoint(interfaceName, std::move(accessPointControllerFactory), std::move(attributes)), m_nl80211Interface{ std::move(nl80211Interface) } { } @@ -42,7 +42,7 @@ AccessPointFactoryLinux::Create(std::string_view interfaceName, std::unique_ptr< throw std::runtime_error("invalid arguments passed to AccessPointFactoryLinux::Create; this is a bug!"); } - return std::make_shared(interfaceName, GetControllerFactory(), std::move(createArgsLinux->Interface), std::move(createArgs->Properties)); + return std::make_shared(interfaceName, GetControllerFactory(), std::move(createArgsLinux->Interface), std::move(createArgs->Attributes)); } AccessPointCreateArgsLinux::AccessPointCreateArgsLinux(Nl80211Interface nl80211Interface) : diff --git a/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx b/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx index 99802942..eb30154a 100644 --- a/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx +++ b/src/linux/net/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx @@ -26,9 +26,9 @@ struct AccessPointLinux : * @param interfaceName The name of the interface. * @param accessPointControllerFactory The access point controller factory to use for creating access point. * @param nl80211Interface The nl80211 interface object. - * @param properties The static properties of the access point. + * @param attributes The static attributes of the access point. */ - AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Microsoft::Net::Netlink::Nl80211::Nl80211Interface nl80211Interface, AccessPointProperties properties = {}); + AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Microsoft::Net::Netlink::Nl80211::Nl80211Interface nl80211Interface, AccessPointAttributes attributes = {}); /** * @brief Get the mac address of the access point. diff --git a/tests/unit/TestNetRemoteServiceClient.cxx b/tests/unit/TestNetRemoteServiceClient.cxx index 58ecce77..843be489 100644 --- a/tests/unit/TestNetRemoteServiceClient.cxx +++ b/tests/unit/TestNetRemoteServiceClient.cxx @@ -1125,7 +1125,7 @@ TEST_CASE("WifiAccessPointSetAuthenticationDot1x API", "[basic][rpc][client][rem } } -TEST_CASE("WifiAccessPointGetProperties API", "[basic][rpc][client][remote]") +TEST_CASE("WifiAccessPointGetAttributes API", "[basic][rpc][client][remote]") { using namespace Microsoft::Net::Remote; using namespace Microsoft::Net::Remote::Service; @@ -1134,8 +1134,9 @@ TEST_CASE("WifiAccessPointGetProperties API", "[basic][rpc][client][remote]") using namespace Microsoft::Net::Wifi; using namespace Microsoft::Net::Wifi::Test; - constexpr auto InterfaceName{ "TestWifiAccessPointGetProperties" }; - constexpr auto InterfaceProperty{ "TestProperty1" }; + constexpr auto InterfaceName{ "TestWifiAccessPointGetAttributes" }; + constexpr auto InterfaceAttributesPropertyKey{ "TestAttributePropertyKey1" }; + constexpr auto InterfaceAttributesPropertyValue{ "TestAttributePropertyValue1" }; auto apManagerTest = std::make_shared(); const Ieee80211AccessPointCapabilities apCapabilities{ @@ -1143,7 +1144,8 @@ TEST_CASE("WifiAccessPointGetProperties API", "[basic][rpc][client][remote]") }; auto apTest = std::make_shared(InterfaceName, apCapabilities); - apTest->Properties.Properties.push_back(InterfaceProperty); + auto& apProperties = apTest->Attributes.Properties; + apProperties[InterfaceAttributesPropertyKey] = InterfaceAttributesPropertyValue; apManagerTest->AddAccessPoint(apTest); const auto serverConfiguration = CreateServerConfiguration(apManagerTest); @@ -1155,31 +1157,37 @@ TEST_CASE("WifiAccessPointGetProperties API", "[basic][rpc][client][remote]") SECTION("Can be called") { - WifiAccessPointGetPropertiesRequest request{}; + WifiAccessPointGetAttributesRequest request{}; request.set_accesspointid(InterfaceName); - WifiAccessPointGetPropertiesResult result{}; + WifiAccessPointGetAttributesResult result{}; grpc::ClientContext clientContext{}; grpc::Status status; - REQUIRE_NOTHROW(status = client->WifiAccessPointGetProperties(&clientContext, request, &result)); + REQUIRE_NOTHROW(status = client->WifiAccessPointGetAttributes(&clientContext, request, &result)); REQUIRE(status.ok()); REQUIRE(result.accesspointid() == request.accesspointid()); } SECTION("Properties are properly reflected") { - WifiAccessPointGetPropertiesRequest request{}; + WifiAccessPointGetAttributesRequest request{}; request.set_accesspointid(InterfaceName); - WifiAccessPointGetPropertiesResult result{}; + WifiAccessPointGetAttributesResult result{}; grpc::ClientContext clientContext{}; grpc::Status status; - REQUIRE_NOTHROW(status = client->WifiAccessPointGetProperties(&clientContext, request, &result)); + REQUIRE_NOTHROW(status = client->WifiAccessPointGetAttributes(&clientContext, request, &result)); REQUIRE(status.ok()); REQUIRE(result.accesspointid() == request.accesspointid()); - REQUIRE(std::size(result.properties()) == 1); - REQUIRE(result.properties()[0] == InterfaceProperty); + REQUIRE(result.has_attributes()); + + const auto& attributes = result.attributes(); + const auto& properties = attributes.properties(); + + REQUIRE(std::size(properties) == 1); + REQUIRE(properties.contains(InterfaceAttributesPropertyKey)); + REQUIRE(properties.at(InterfaceAttributesPropertyKey) == InterfaceAttributesPropertyValue); } } diff --git a/tests/unit/net/wifi/helpers/AccessPointTest.cxx b/tests/unit/net/wifi/helpers/AccessPointTest.cxx index 0ed50de9..e52a7b6f 100644 --- a/tests/unit/net/wifi/helpers/AccessPointTest.cxx +++ b/tests/unit/net/wifi/helpers/AccessPointTest.cxx @@ -33,10 +33,10 @@ AccessPointTest::GetMacAddress() const noexcept return MacAddress; } -const AccessPointProperties& -AccessPointTest::GetProperties() const noexcept +const AccessPointAttributes& +AccessPointTest::GetAttributes() const noexcept { - return Properties; + return Attributes; } std::unique_ptr diff --git a/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx b/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx index 5eac2a43..6aea74c2 100644 --- a/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx +++ b/tests/unit/net/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx @@ -40,7 +40,7 @@ struct AccessPointTest final : std::vector AkmSuites; std::unordered_map> CipherSuites; AccessPointOperationalState OperationalState{ AccessPointOperationalState::Disabled }; - AccessPointProperties Properties{}; + AccessPointAttributes Attributes{}; /** * @brief Construct a new AccessPointTest object with the given interface name and default capabilities. @@ -90,12 +90,12 @@ struct AccessPointTest final : GetMacAddress() const noexcept override; /** - * @brief Get the static properties of an access point. + * @brief Get the static attributes of an access point. * - * @return AccessPointProperties& + * @return AccessPointAttributes& */ - const AccessPointProperties& - GetProperties() const noexcept override; + const AccessPointAttributes& + GetAttributes() const noexcept override; /** * @brief Create a new instance that can control the access point.