|
10 | 10 | #include <ranges> |
11 | 11 | #include <string> |
12 | 12 | #include <string_view> |
| 13 | +#include <sys/utsname.h> |
13 | 14 | #include <thread> |
14 | 15 | #include <utility> |
15 | 16 | #include <vector> |
@@ -613,6 +614,32 @@ NetRemoteService::WifiAccessPointEnableImpl(std::string_view accessPointId, cons |
613 | 614 | return wifiOperationStatus; |
614 | 615 | } |
615 | 616 | } |
| 617 | + |
| 618 | + // Check Linux kernel version before setting MLD AP |
| 619 | + bool shouldSetMldAp = false; |
| 620 | + struct utsname buffer; |
| 621 | + if (uname(&buffer) == 0) { |
| 622 | + std::string release(buffer.release); |
| 623 | + std::smatch match; |
| 624 | + std::regex versionRegex(R"((\d+)\.(\d+))"); |
| 625 | + if (std::regex_search(release, match, versionRegex) && match.size() >= 3) { |
| 626 | + int major = std::stoi(match[1]); |
| 627 | + int minor = std::stoi(match[2]); |
| 628 | + if (major > 6 || (major == 6 && minor >= 11)) { |
| 629 | + shouldSetMldAp = true; |
| 630 | + } |
| 631 | + } |
| 632 | + } |
| 633 | + |
| 634 | + if (shouldSetMldAp) { |
| 635 | + bool mldAp = dot11AccessPointConfiguration->mldap(); |
| 636 | + wifiOperationStatus = WifiAccessPointSetMldApImpl(accessPointId, mldAp, accessPointController); |
| 637 | + if (wifiOperationStatus.code() != WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded) { |
| 638 | + return wifiOperationStatus; |
| 639 | + } |
| 640 | + } else { |
| 641 | + LOGW << "Skipping setting MLD AP configuration due to unsupported kernel version"; |
| 642 | + } |
616 | 643 | } |
617 | 644 |
|
618 | 645 | // Obtain current operational state. |
@@ -1467,6 +1494,36 @@ NetRemoteService::WifiAccessPointSetAuthenticationDot1xImpl(std::string_view acc |
1467 | 1494 | return wifiOperationStatus; |
1468 | 1495 | } |
1469 | 1496 |
|
| 1497 | +WifiAccessPointOperationStatus |
| 1498 | +NetRemoteService::WifiAccessPointSetMldApImpl(std::string_view accessPointId, bool mldAp, std::shared_ptr<IAccessPointController> accessPointController) |
| 1499 | +{ |
| 1500 | + WifiAccessPointOperationStatus wifiOperationStatus{}; |
| 1501 | + |
| 1502 | + AccessPointOperationStatus operationStatus{ accessPointId }; |
| 1503 | + |
| 1504 | + // Create an AP controller for the requested AP if one wasn't specified. |
| 1505 | + if (accessPointController == nullptr) { |
| 1506 | + operationStatus = TryGetAccessPointController(accessPointId, accessPointController); |
| 1507 | + if (!operationStatus.Succeeded() || accessPointController == nullptr) { |
| 1508 | + wifiOperationStatus.set_code(ToDot11AccessPointOperationStatusCode(operationStatus.Code)); |
| 1509 | + wifiOperationStatus.set_message(std::format("Failed to create access point controller for access point {} - {}", accessPointId, operationStatus.ToString())); |
| 1510 | + return wifiOperationStatus; |
| 1511 | + } |
| 1512 | + } |
| 1513 | + |
| 1514 | + // Attempt to set the MLD AP setting. |
| 1515 | + operationStatus = accessPointController->SetMldAp(mldAp); |
| 1516 | + if (!operationStatus.Succeeded()) { |
| 1517 | + wifiOperationStatus.set_code(ToDot11AccessPointOperationStatusCode(operationStatus.Code)); |
| 1518 | + wifiOperationStatus.set_message(std::format("Failed to set MLD AP setting for access point {} - {}", accessPointId, operationStatus.ToString())); |
| 1519 | + return wifiOperationStatus; |
| 1520 | + } |
| 1521 | + |
| 1522 | + wifiOperationStatus.set_code(WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded); |
| 1523 | + |
| 1524 | + return wifiOperationStatus; |
| 1525 | +} |
| 1526 | + |
1470 | 1527 | using google::protobuf::Map; |
1471 | 1528 |
|
1472 | 1529 | WifiAccessPointOperationStatus |
|
0 commit comments