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;