Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APIs to update AP configuration #121

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions protocol/protos/NetRemoteService.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ service NetRemote
rpc WifiAccessPointEnable (Microsoft.Net.Remote.Wifi.WifiAccessPointEnableRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointEnableResult);
rpc WifiAccessPointDisable (Microsoft.Net.Remote.Wifi.WifiAccessPointDisableRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointDisableResult);
rpc WifiAccessPointSetPhyType (Microsoft.Net.Remote.Wifi.WifiAccessPointSetPhyTypeRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetPhyTypeResult);
rpc WifiAccessPointSetAuthenticationConfiguration (Microsoft.Net.Remote.Wifi.WifiAccessPointSetAuthenticationConfigurationRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetAuthenticationConfigurationResult);
rpc WifiAccessPointSetFrequencyBands (Microsoft.Net.Remote.Wifi.WifiAccessPointSetFrequencyBandsRequest) returns (Microsoft.Net.Remote.Wifi.WifiAccessPointSetFrequencyBandsResult);
}
24 changes: 24 additions & 0 deletions protocol/protos/NetRemoteWifi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,27 @@ message WifiAccessPointSetPhyTypeResult
string AccessPointId = 1;
WifiAccessPointOperationStatus Status = 2;
abeltrano marked this conversation as resolved.
Show resolved Hide resolved
}

message WifiAccessPointSetAuthenticationConfigurationRequest
{
string AccessPointId = 1;
Microsoft.Net.Wifi.Dot11AccessPointAuthenticationConfiguration AuthenticationConfiguration = 2;
}

message WifiAccessPointSetAuthenticationConfigurationResult
{
string AccessPointId = 1;
WifiAccessPointOperationStatus Status = 2;
}

message WifiAccessPointSetFrequencyBandsRequest
{
string AccessPointId = 1;
repeated Microsoft.Net.Wifi.Dot11FrequencyBand FrequencyBands = 2;
}

message WifiAccessPointSetFrequencyBandsResult
{
string AccessPointId = 1;
WifiAccessPointOperationStatus Status = 2;
}
41 changes: 41 additions & 0 deletions protocol/protos/WifiCore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,44 @@ enum Dot11AccessPointState
{
AccessPointStateUnknown = 0;
}

message Dot11RadiusServerConfiguration
{
string Address = 1;
uint32 Port = 2;
Microsoft.Net.Wifi.Dot11SharedKey SharedSecret = 3;
}

message Dot11AkmSuiteConfigurationNone
{

}

message Dot11AkmSuiteConfigurationSharedKey
{
Microsoft.Net.Wifi.Dot11SharedKey SharedKey = 1;
}

message Dot11AkmSuiteConfigurationEnterprise
{
Microsoft.Net.Wifi.Dot11RadiusServerConfiguration RadiusServerConfiguration = 1;
}

message Dot11AkmSuiteConfiguration
{
Microsoft.Net.Wifi.Dot11AuthenticationAlgorithm AuthenticationAlgorithm = 1;
Microsoft.Net.Wifi.Dot11AkmSuite AkmSuite = 2;
oneof Configuration
{
Dot11AkmSuiteConfigurationNone ConfigurationNone = 3;
Dot11AkmSuiteConfigurationSharedKey ConfigurationSharedKey = 4;
Dot11AkmSuiteConfigurationEnterprise ConfigurationEnterprise = 5;
}
abeltrano marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +183 to +192
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I'm still trying to parse out whether this is the best encoding of all the auth args w.r.t. to the 802.11 specification. I think it's very close, if not completely correct.

I'm giving the auth-related parts of the spec a careful read through to hopefully resolve this.

}


message Dot11AccessPointAuthenticationConfiguration
{
repeated Microsoft.Net.Wifi.Dot11AkmSuiteConfiguration AkmSuites = 1;
repeated Microsoft.Net.Wifi.Dot11CipherSuite CipherSuites = 2;
}
91 changes: 81 additions & 10 deletions src/common/service/NetRemoteService.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,6 @@ NetRemoteService::WifiEnumerateAccessPoints([[maybe_unused]] ::grpc::ServerConte

using Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus;
using Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatusCode;
using Microsoft::Net::Wifi::Dot11AuthenticationAlgorithm;
using Microsoft::Net::Wifi::Dot11CipherSuite;
using Microsoft::Net::Wifi::Dot11PhyType;

::grpc::Status
NetRemoteService::WifiAccessPointEnable([[maybe_unused]] ::grpc::ServerContext* context, const ::Microsoft::Net::Remote::Wifi::WifiAccessPointEnableRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointEnableResult* response)
Expand Down Expand Up @@ -477,14 +474,52 @@ NetRemoteService::WifiAccessPointSetPhyType([[maybe_unused]] ::grpc::ServerConte
return handleFailure(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeOperationNotSupported, std::format("Failed to get capabilities for access point {}", request->accesspointid()));
}

// Set the Ieee80211 protocol.
try {
if (!accessPointController->SetProtocol(ieeeProtocol)) {
return handleFailure(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeOperationNotSupported, std::format("Failed to set PHY type for access point {}", request->accesspointid()));
response->set_accesspointid(request->accesspointid());
*response->mutable_status() = std::move(status);

return grpc::Status::OK;
}

using Microsoft::Net::Wifi::Dot11AccessPointAuthenticationConfiguration;
using Microsoft::Net::Wifi::Dot11AkmSuite;
using Microsoft::Net::Wifi::Dot11AkmSuiteConfiguration;
using Microsoft::Net::Wifi::Dot11AuthenticationAlgorithm;
using Microsoft::Net::Wifi::Dot11CipherSuite;

::grpc::Status
NetRemoteService::WifiAccessPointSetAuthenticationConfiguration([[maybe_unused]] ::grpc::ServerContext* context, const ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetAuthenticationConfigurationRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetAuthenticationConfigurationResult* response)
{
LOGD << std::format("Received WifiAccessPointSetAuthenticationConfiguration request for access point id {}", request->accesspointid());

WifiAccessPointOperationStatus status{};

const auto& authenticationConfiguration = request->authenticationconfiguration();
const auto& akmSuites = authenticationConfiguration.akmsuites();
const auto& cipherSuites = authenticationConfiguration.ciphersuites();

if (std::empty(akmSuites) && std::empty(cipherSuites)) {
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeInvalidParameter);
status.set_message("No AKM suite or cipher suite provided");
} else if (!std::empty(akmSuites) && std::ranges::find(akmSuites, Dot11AkmSuite::Dot11AkmSuiteUnknown, &Dot11AkmSuiteConfiguration::akmsuite) != std::cend(akmSuites)) {
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeInvalidParameter);
status.set_message("Invalid AKM suite provided");
} else if (!std::empty(akmSuites) && std::ranges::find(akmSuites, Dot11AuthenticationAlgorithm::Dot11AuthenticationAlgorithmUnknown, &Dot11AkmSuiteConfiguration::authenticationalgorithm) != std::cend(akmSuites)) {
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeInvalidParameter);
status.set_message("Invalid authentication algorithm provided");
} else if (!std::empty(cipherSuites) && std::ranges::find(cipherSuites, Dot11CipherSuite::Dot11CipherSuiteUnknown) != std::cend(cipherSuites)) {
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeInvalidParameter);
status.set_message("Invalid cipher suite provided");
} else {
auto accessPointWeak = m_accessPointManager->GetAccessPoint(request->accesspointid());
auto accessPointController = detail::IAccessPointWeakToAccessPointController(accessPointWeak);
if (!accessPointController) {
LOGE << std::format("Failed to create controller for access point {}", request->accesspointid());
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeAccessPointInvalid);
status.set_message(std::format("Failed to create controller for access point {}", request->accesspointid()));
}
} catch (const AccessPointControllerException& apce) {
LOGE << std::format("Failed to set Ieee80211 protocol for access point {} ({})", request->accesspointid(), apce.what());
return handleFailure(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeOperationNotSupported, std::format("Failed to set PHY type for access point {}", request->accesspointid()));

// TODO: Use accessPointController to set authentication configuration.
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
}

status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
Expand All @@ -494,6 +529,42 @@ NetRemoteService::WifiAccessPointSetPhyType([[maybe_unused]] ::grpc::ServerConte
return grpc::Status::OK;
}

using Microsoft::Net::Wifi::Dot11FrequencyBand;

::grpc::Status
NetRemoteService::WifiAccessPointSetFrequencyBands([[maybe_unused]] ::grpc::ServerContext* context, const ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetFrequencyBandsRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetFrequencyBandsResult* response)
{
LOGD << std::format("Received WifiAccessPointSetFrequencyBands request for access point id {}", request->accesspointid());

WifiAccessPointOperationStatus status{};

const auto& frequencyBands = request->frequencybands();

if (std::empty(frequencyBands)) {
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeInvalidParameter);
status.set_message("No frequency band provided");
} else if (std::ranges::find(frequencyBands, Dot11FrequencyBand::Dot11FrequencyBandUnknown) != std::cend(frequencyBands)) {
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeInvalidParameter);
status.set_message("Invalid frequency band provided");
} else {
auto accessPointWeak = m_accessPointManager->GetAccessPoint(request->accesspointid());
auto accessPointController = detail::IAccessPointWeakToAccessPointController(accessPointWeak);
if (!accessPointController) {
LOGE << std::format("Failed to create controller for access point {}", request->accesspointid());
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeAccessPointInvalid);
status.set_message(std::format("Failed to create controller for access point {}", request->accesspointid()));
}

// TODO: Use accessPointController to set frequency bands.
status.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
}

response->set_accesspointid(request->accesspointid());
*response->mutable_status() = std::move(status);

return grpc::Status::OK;
}

bool
NetRemoteService::ValidateWifiAccessPointEnableRequest(const ::Microsoft::Net::Remote::Wifi::WifiAccessPointEnableRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus& status)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ private:
virtual ::grpc::Status
WifiAccessPointSetPhyType(::grpc::ServerContext* context, const ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetPhyTypeRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetPhyTypeResult* response) override;

virtual ::grpc::Status
WifiAccessPointSetAuthenticationConfiguration(::grpc::ServerContext* context, const ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetAuthenticationConfigurationRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetAuthenticationConfigurationResult* response) override;

virtual ::grpc::Status
WifiAccessPointSetFrequencyBands(::grpc::ServerContext* context, const ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetFrequencyBandsRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointSetFrequencyBandsResult* response) override;

protected:
bool
ValidateWifiAccessPointEnableRequest(const ::Microsoft::Net::Remote::Wifi::WifiAccessPointEnableRequest* request, ::Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus& status);
Expand Down
Loading
Loading