22UINT8 mWifiConnectionCount = 0;
51 BOOLEAN AKMSuiteSupported;
52 BOOLEAN CipherSuiteSupported;
56 ASSERT (Context !=
NULL);
59 ASSERT (ConfigToken->Nic !=
NULL);
60 ASSERT (ConfigToken->Type == TokenTypeGetNetworksToken);
65 ConfigToken->Nic->ScanState = WifiMgrScanFinished;
67 ASSERT (ConfigToken->Token.GetNetworksToken !=
NULL);
68 Result = ConfigToken->Token.GetNetworksToken->Result;
69 Nic = ConfigToken->Nic;
74 Nic->AvailableCount = 0;
76 NET_LIST_FOR_EACH (Entry, &Nic->ProfileList) {
77 Profile = NET_LIST_USER_STRUCT_S (
81 WIFI_MGR_PROFILE_SIGNATURE
83 Profile->IsAvailable =
FALSE;
87 gBS->SignalEvent (Nic->Private->NetworkListRefreshEvent);
92 for (Index = 0; Index < Result->NumOfNetworkDesc; Index++) {
93 NetworkDescription = Result->NetworkDesc + Index;
94 if (NetworkDescription ==
NULL) {
98 Network = &NetworkDescription->Network;
99 if ((Network ==
NULL) || (Network->SSId.SSIdLen == 0)) {
105 Network->CipherSuite,
109 &CipherSuiteSupported
111 if (EFI_ERROR (Status)) {
112 SecurityType = SECURITY_TYPE_UNKNOWN;
113 AKMSuiteSupported =
FALSE;
114 CipherSuiteSupported =
FALSE;
117 AsciiSSId = (CHAR8 *)
AllocateZeroPool (
sizeof (CHAR8) * (Network->SSId.SSIdLen + 1));
118 if (AsciiSSId ==
NULL) {
122 CopyMem (AsciiSSId, (CHAR8 *)Network->SSId.SSId, sizeof (CHAR8) * Network->SSId.SSIdLen);
123 *(AsciiSSId + Network->SSId.SSIdLen) =
'\0';
126 if (Profile ==
NULL) {
127 if (Nic->MaxProfileIndex >= NETWORK_LIST_COUNT_MAX) {
136 if (Profile ==
NULL) {
141 Profile->Signature = WIFI_MGR_PROFILE_SIGNATURE;
142 Profile->NicIndex = Nic->NicIndex;
143 Profile->ProfileIndex = Nic->MaxProfileIndex + 1;
146 Nic->MaxProfileIndex++;
155 if (!Profile->IsAvailable) {
156 Profile->IsAvailable =
TRUE;
157 Profile->SecurityType = SecurityType;
158 Profile->AKMSuiteSupported = AKMSuiteSupported;
159 Profile->CipherSuiteSupported = CipherSuiteSupported;
160 Profile->NetworkQuality = NetworkDescription->NetworkQuality;
161 Nic->AvailableCount++;
171 if (Network->AKMSuite !=
NULL) {
172 if (Network->AKMSuite->AKMSuiteCount == 0) {
176 * (Network->AKMSuite->AKMSuiteCount - 1);
180 if (Profile->Network.AKMSuite ==
NULL) {
184 CopyMem (Profile->Network.AKMSuite, Network->AKMSuite, DataSize);
190 if (Network->CipherSuite !=
NULL) {
191 if (Network->CipherSuite->CipherSuiteCount == 0) {
195 * (Network->CipherSuite->CipherSuiteCount - 1);
199 if (Profile->Network.CipherSuite ==
NULL) {
203 CopyMem (Profile->Network.CipherSuite, Network->CipherSuite, DataSize);
209 if (Profile->NetworkQuality < NetworkDescription->NetworkQuality) {
210 Profile->NetworkQuality = NetworkDescription->NetworkQuality;
217 gBS->SignalEvent (Nic->Private->NetworkListRefreshEvent);
223 if ((Nic->ConnectState == WifiMgrConnectedToAp) && (Nic->CurrentOperateNetwork !=
NULL)) {
224 if (!Nic->CurrentOperateNetwork->IsAvailable) {
225 Nic->CurrentOperateNetwork->IsAvailable =
TRUE;
226 Nic->AvailableCount++;
254 UINT32 HiddenSSIdIndex;
255 UINT32 HiddenSSIdCount;
260 if ((Nic ==
NULL) || (Nic->Wmp ==
NULL)) {
261 return EFI_INVALID_PARAMETER;
264 if (Nic->ScanState == WifiMgrScanning) {
265 return EFI_ALREADY_STARTED;
268 Nic->ScanState = WifiMgrScanning;
269 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
271 HiddenSSIdList =
NULL;
272 HiddenSSIdCount = Nic->Private->HiddenNetworkCount;
279 if (ConfigToken ==
NULL) {
280 gBS->RestoreTPL (OldTpl);
281 return EFI_OUT_OF_RESOURCES;
284 ConfigToken->Type = TokenTypeGetNetworksToken;
285 ConfigToken->Nic = Nic;
287 if (ConfigToken->Token.GetNetworksToken ==
NULL) {
289 gBS->RestoreTPL (OldTpl);
290 return EFI_OUT_OF_RESOURCES;
293 GetNetworksToken = ConfigToken->Token.GetNetworksToken;
298 if (HiddenSSIdCount > 0) {
300 if (HiddenSSIdList ==
NULL) {
302 gBS->RestoreTPL (OldTpl);
303 return EFI_OUT_OF_RESOURCES;
307 NET_LIST_FOR_EACH (Entry, &Nic->Private->HiddenNetworkList) {
308 HiddenNetwork = NET_LIST_USER_STRUCT_S (
312 WIFI_MGR_HIDDEN_NETWORK_SIGNATURE
314 HiddenSSIdList[HiddenSSIdIndex].SSIdLen = (UINT8)
StrLen (HiddenNetwork->SSId);
317 (CHAR8 *)HiddenSSIdList[HiddenSSIdIndex].SSId,
326 if (GetNetworksToken->Data ==
NULL) {
329 gBS->RestoreTPL (OldTpl);
330 return EFI_OUT_OF_RESOURCES;
333 GetNetworksToken->Data->NumOfSSID = HiddenSSIdCount;
334 CopyMem (GetNetworksToken->Data->SSIDList, HiddenSSIdList, HiddenSSIdCount * sizeof (
EFI_80211_SSID));
338 if (GetNetworksToken->Data ==
NULL) {
340 gBS->RestoreTPL (OldTpl);
341 return EFI_OUT_OF_RESOURCES;
344 GetNetworksToken->Data->NumOfSSID = 0;
350 Status =
gBS->CreateEvent (
355 &GetNetworksToken->Event
357 if (EFI_ERROR (Status)) {
359 gBS->RestoreTPL (OldTpl);
366 Status = Nic->Wmp->GetNetworks (Nic->Wmp, GetNetworksToken);
367 if (EFI_ERROR (Status)) {
368 Nic->ScanState = WifiMgrScanFinished;
370 gBS->RestoreTPL (OldTpl);
374 gBS->RestoreTPL (OldTpl);
400 UINT8 *AsciiPassword;
402 if ((Nic ==
NULL) || (Nic->Supplicant ==
NULL) || (Profile ==
NULL)) {
403 return EFI_INVALID_PARAMETER;
406 Supplicant = Nic->Supplicant;
410 SSId.SSIdLen = Profile->Network.SSId.SSIdLen;
411 CopyMem (SSId.SSId, Profile->Network.SSId.SSId, sizeof (Profile->Network.SSId.SSId));
412 Status = Supplicant->SetData (
414 EfiSupplicant80211TargetSSIDName,
418 if (EFI_ERROR (Status)) {
425 if (
StrLen (Profile->Password) < PASSWORD_MIN_LEN) {
426 return EFI_NOT_FOUND;
429 if (
StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) {
430 ASSERT (EFI_INVALID_PARAMETER);
431 return EFI_INVALID_PARAMETER;
435 if (AsciiPassword ==
NULL) {
436 return EFI_OUT_OF_RESOURCES;
440 if (!EFI_ERROR (Status)) {
441 Status = Supplicant->SetData (
443 EfiSupplicant80211PskPassword,
445 (
StrLen (Profile->Password) + 1) * sizeof (CHAR8)
488 UINTN EncryptPasswordLen;
489 CHAR8 *AsciiEncryptPassword;
490 UINTN AuthMethodListSize;
493 if ((Nic ==
NULL) || (Nic->EapConfig ==
NULL) || (Profile ==
NULL)) {
494 return EFI_INVALID_PARAMETER;
497 EapConfig = Nic->EapConfig;
499 if (Profile->EapAuthMethod >= EAP_AUTH_METHOD_MAX) {
500 return EFI_INVALID_PARAMETER;
503 EapAuthMethod = mEapAuthMethod[Profile->EapAuthMethod];
505 if (EapAuthMethod != EFI_EAP_TYPE_EAPTLS) {
506 if (Profile->EapSecondAuthMethod >= EAP_SEAUTH_METHOD_MAX) {
507 return EFI_INVALID_PARAMETER;
510 EapSecondAuthMethod = mEapSecondAuthMethod[Profile->EapSecondAuthMethod];
516 AuthMethodListSize = 0;
517 AuthMethodList =
NULL;
518 Status = EapConfig->GetData (
521 EfiEapConfigEapSupportedAuthMethod,
522 (VOID *)AuthMethodList,
529 return EFI_UNSUPPORTED;
530 }
else if (Status != EFI_BUFFER_TOO_SMALL) {
539 if (AuthMethodList ==
NULL) {
540 return EFI_OUT_OF_RESOURCES;
543 Status = EapConfig->GetData (
546 EfiEapConfigEapSupportedAuthMethod,
547 (VOID *)AuthMethodList,
550 if (EFI_ERROR (Status)) {
558 for (Index = 0; Index < AuthMethodListSize /
sizeof (
EFI_EAP_TYPE); Index++) {
559 if (EapAuthMethod == AuthMethodList[Index]) {
564 if (Index == AuthMethodListSize /
sizeof (
EFI_EAP_TYPE)) {
566 return EFI_UNSUPPORTED;
574 if (
StrLen (Profile->EapIdentity) > 0) {
575 Status =
gBS->LocateProtocol (&gEdkiiWiFiProfileSyncProtocolGuid,
NULL, (VOID **)&WiFiProfileSyncProtocol);
576 if (!EFI_ERROR (Status)) {
580 IdentitySize =
sizeof (CHAR8) * (
AsciiStrnLenS ((CHAR8 *)Profile->EapIdentity, sizeof (CHAR16) *
sizeof (Profile->EapIdentity)) + 1);
582 IdentitySize =
sizeof (CHAR8) * (
StrLen (Profile->EapIdentity) + 1);
586 if (Identity ==
NULL) {
587 return EFI_OUT_OF_RESOURCES;
590 if (!EFI_ERROR (Status)) {
596 CopyMem (Identity, &Profile->EapIdentity, IdentitySize - 1);
601 Status = EapConfig->SetData (
603 EFI_EAP_TYPE_IDENTITY,
608 if (EFI_ERROR (Status)) {
615 if (EapAuthMethod != EFI_EAP_TYPE_EAPTLS) {
616 return EFI_INVALID_PARAMETER;
623 Status = EapConfig->SetData (
627 (VOID *)&EapAuthMethod,
628 sizeof (EapAuthMethod)
630 if (EFI_ERROR (Status)) {
634 if ((EapAuthMethod == EFI_EAP_TYPE_TTLS) || (EapAuthMethod == EFI_EAP_TYPE_PEAP)) {
635 Status = EapConfig->SetData (
639 (VOID *)&EapSecondAuthMethod,
640 sizeof (EapSecondAuthMethod)
642 if (EFI_ERROR (Status)) {
649 if (
StrLen (Profile->EapPassword) < PASSWORD_MIN_LEN) {
650 DEBUG ((DEBUG_ERROR,
"[WiFi Connection Manager] Error: No Eap Password for Network: %s.\n", Profile->SSId));
651 return EFI_INVALID_PARAMETER;
654 PasswordSize =
sizeof (CHAR16) * (
StrLen (Profile->EapPassword) + 1);
656 if (Password ==
NULL) {
657 return EFI_OUT_OF_RESOURCES;
660 StrCpyS (Password, PasswordSize, Profile->EapPassword);
661 Status = EapConfig->SetData (
663 EFI_EAP_TYPE_MSCHAPV2,
668 ZeroMem (Password, PasswordSize);
670 if (EFI_ERROR (Status)) {
677 if (Profile->CACertData !=
NULL) {
678 Status = EapConfig->SetData (
685 if (EFI_ERROR (Status)) {
689 return EFI_INVALID_PARAMETER;
691 }
else if (EapAuthMethod == EFI_EAP_TYPE_EAPTLS) {
695 if (Profile->CACertData ==
NULL) {
696 return EFI_INVALID_PARAMETER;
699 Status = EapConfig->SetData (
706 if (EFI_ERROR (Status)) {
713 if (Profile->ClientCertData ==
NULL) {
714 return EFI_INVALID_PARAMETER;
717 Status = EapConfig->SetData (
720 EfiEapConfigEapTlsClientCert,
721 Profile->ClientCertData,
722 Profile->ClientCertSize
724 if (EFI_ERROR (Status)) {
731 if (Profile->PrivateKeyData ==
NULL) {
732 DEBUG ((DEBUG_ERROR,
"[WiFi Connection Manager] Error: No Private Key for Network: %s.\n", Profile->SSId));
733 return EFI_INVALID_PARAMETER;
736 Status = EapConfig->SetData (
739 EfiEapConfigEapTlsClientPrivateKeyFile,
740 Profile->PrivateKeyData,
741 Profile->PrivateKeyDataSize
743 if (EFI_ERROR (Status)) {
747 if (
StrLen (Profile->PrivateKeyPassword) > 0) {
748 EncryptPasswordLen =
StrLen (Profile->PrivateKeyPassword);
750 if (AsciiEncryptPassword ==
NULL) {
751 return EFI_OUT_OF_RESOURCES;
755 Status = EapConfig->SetData (
758 EfiEapConfigEapTlsClientPrivateKeyFilePassword,
759 (VOID *)AsciiEncryptPassword,
760 EncryptPasswordLen + 1
762 if (EFI_ERROR (Status)) {
763 ZeroMem (AsciiEncryptPassword, EncryptPasswordLen + 1);
768 ZeroMem (AsciiEncryptPassword, EncryptPasswordLen + 1);
772 return EFI_INVALID_PARAMETER;
802 if ((Nic ==
NULL) || (LinkState ==
NULL)) {
803 return EFI_INVALID_PARAMETER;
806 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
807 Status =
gBS->OpenProtocol (
808 Nic->ControllerHandle,
809 &gEfiAdapterInformationProtocolGuid,
812 Nic->ControllerHandle,
813 EFI_OPEN_PROTOCOL_GET_PROTOCOL
815 if (EFI_ERROR (Status)) {
816 gBS->RestoreTPL (OldTpl);
817 return EFI_UNSUPPORTED;
820 Status = Aip->GetInformation (
822 &gEfiAdapterInfoMediaStateGuid,
826 if (EFI_ERROR (Status)) {
827 gBS->RestoreTPL (OldTpl);
831 gBS->RestoreTPL (OldTpl);
859 BOOLEAN AKMSuiteSupported;
860 BOOLEAN CipherSuiteSupported;
862 if ((Profile ==
NULL) || (Nic ==
NULL)) {
863 return EFI_INVALID_PARAMETER;
867 Profile->Network.AKMSuite,
868 Profile->Network.CipherSuite,
872 &CipherSuiteSupported
874 if (EFI_ERROR (Status)) {
878 if (AKMSuiteSupported && CipherSuiteSupported) {
879 switch (SecurityType) {
880 case SECURITY_TYPE_WPA2_PERSONAL:
881 case SECURITY_TYPE_WPA3_PERSONAL:
884 if (EFI_ERROR (Status)) {
885 if (Status == EFI_NOT_FOUND) {
886 if (Nic->OneTimeConnectRequest) {
896 case SECURITY_TYPE_WPA2_ENTERPRISE:
897 case SECURITY_TYPE_WPA3_ENTERPRISE:
900 if (EFI_ERROR (Status)) {
901 if (Status == EFI_INVALID_PARAMETER) {
902 if (Nic->OneTimeConnectRequest) {
912 case SECURITY_TYPE_NONE:
916 return EFI_UNSUPPORTED;
919 return EFI_UNSUPPORTED;
949 Status =
gBS->LocateProtocol (
950 &gEfiWiFi2ProtocolGuid,
954 if (EFI_ERROR (Status)) {
958 Status =
gBS->LocateProtocol (
959 &gEfiSupplicantProtocolGuid,
963 if (EFI_ERROR (Status)) {
967 Status =
gBS->LocateProtocol (
968 &gEfiEapConfigurationProtocolGuid,
972 if (EFI_ERROR (Status)) {
981 Status = EFI_OUT_OF_RESOURCES;
985 Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE;
986 Nic->Private = mPrivate;
988 Nic->Supplicant = Supplicant;
989 Nic->EapConfig = EapConfig;
990 Nic->UserSelectedProfile =
NULL;
991 Nic->OneTimeScanRequest =
FALSE;
993 if (Nic->Supplicant !=
NULL) {
997 if (!EFI_ERROR (Status)) {
1001 if (Nic->ConnectPendingNetwork ==
NULL) {
1002 Status = EFI_OUT_OF_RESOURCES;
1003 DEBUG ((DEBUG_ERROR,
"[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n"));
1007 Status = WiFiProfileSyncProtocol->GetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress);
1008 if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork !=
NULL)) {
1010 if (!EFI_ERROR (Status)) {
1014 DEBUG ((DEBUG_ERROR,
"[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status));
1017 DEBUG ((DEBUG_ERROR,
"[WiFi Connection Manager] Failed to get Supported suites with status %r\n", Status));
1020 if (Nic->ConnectPendingNetwork !=
NULL) {
1021 if (Nic->ConnectPendingNetwork->Network.AKMSuite !=
NULL) {
1022 FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite);
1025 if (Nic->ConnectPendingNetwork->Network.CipherSuite !=
NULL) {
1026 FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite);
1029 FreePool (Nic->ConnectPendingNetwork);
1033 if (Nic->Supplicant !=
NULL) {
1034 if (Nic->SupportedSuites.SupportedAKMSuites !=
NULL) {
1035 FreePool (Nic->SupportedSuites.SupportedAKMSuites);
1038 if (Nic->SupportedSuites.SupportedSwCipherSuites !=
NULL) {
1039 FreePool (Nic->SupportedSuites.SupportedSwCipherSuites);
1042 if (Nic->SupportedSuites.SupportedHwCipherSuites !=
NULL) {
1043 FreePool (Nic->SupportedSuites.SupportedHwCipherSuites);
1076 ASSERT (Context !=
NULL);
1078 ConnectedProfile =
NULL;
1080 ASSERT (ConfigToken->Nic !=
NULL);
1082 ConfigToken->Nic->ConnectState = WifiMgrDisconnected;
1083 ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken);
1085 ASSERT (ConfigToken->Token.ConnectNetworkToken !=
NULL);
1087 Status =
gBS->LocateProtocol (&gEdkiiWiFiProfileSyncProtocolGuid,
NULL, (VOID **)&WiFiProfileSyncProtocol);
1088 if (!EFI_ERROR (Status)) {
1089 WiFiProfileSyncProtocol->SetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode);
1090 if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) &&
1091 (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess))
1093 mWifiConnectionCount++;
1094 gBS->CloseEvent (Event);
1096 if (!EFI_ERROR (Status)) {
1100 WiFiProfileSyncProtocol->SetConnectState (Status);
1104 if (ConfigToken->Token.ConnectNetworkToken->Status !=
EFI_SUCCESS) {
1105 if (ConfigToken->Nic->OneTimeConnectRequest) {
1109 if (ConfigToken->Token.ConnectNetworkToken->Status == EFI_ACCESS_DENIED) {
1115 ConfigToken->Nic->OneTimeConnectRequest =
FALSE;
1118 ConfigToken->Nic->CurrentOperateNetwork =
NULL;
1122 if (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess) {
1123 if (ConfigToken->Nic->OneTimeConnectRequest) {
1124 if (ConfigToken->Token.ConnectNetworkToken->ResultCode == ConnectFailedReasonUnspecified) {
1134 if ((ConfigToken->Token.ConnectNetworkToken->Data ==
NULL) ||
1135 (ConfigToken->Token.ConnectNetworkToken->Data->Network ==
NULL))
1140 ConfigToken->Nic->HasDisconnectPendingNetwork =
TRUE;
1149 ConfigToken->Token.ConnectNetworkToken->Data->Network->AKMSuite,
1150 ConfigToken->Token.ConnectNetworkToken->Data->Network->CipherSuite,
1156 if (EFI_ERROR (Status)) {
1157 SecurityType = SECURITY_TYPE_UNKNOWN;
1160 SSIdLen = ConfigToken->Token.ConnectNetworkToken->Data->Network->SSId.SSIdLen;
1162 if (AsciiSSId ==
NULL) {
1163 ConfigToken->Nic->HasDisconnectPendingNetwork =
TRUE;
1168 CopyMem (AsciiSSId, ConfigToken->Token.ConnectNetworkToken->Data->Network->SSId.SSId, SSIdLen);
1169 *(AsciiSSId + SSIdLen) =
'\0';
1173 if (ConnectedProfile ==
NULL) {
1174 ConfigToken->Nic->HasDisconnectPendingNetwork =
TRUE;
1179 ConfigToken->Nic->ConnectState = WifiMgrConnectedToAp;
1184 if (ConfigToken->Nic->ConnectState == WifiMgrDisconnected) {
1185 ConfigToken->Nic->CurrentOperateNetwork =
NULL;
1188 ConfigToken->Nic->OneTimeConnectRequest =
FALSE;
1218 if ((Nic ==
NULL) || (Nic->Wmp ==
NULL) || (Profile ==
NULL)) {
1219 return EFI_INVALID_PARAMETER;
1223 if (EFI_ERROR (Status)) {
1228 return EFI_ALREADY_STARTED;
1231 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1233 if (EFI_ERROR (Status)) {
1234 gBS->RestoreTPL (OldTpl);
1242 if (ConfigToken ==
NULL) {
1243 Status = EFI_OUT_OF_RESOURCES;
1247 ConfigToken->Type = TokenTypeConnectNetworkToken;
1248 ConfigToken->Nic = Nic;
1250 if (ConfigToken->Token.ConnectNetworkToken ==
NULL) {
1254 ConnectToken = ConfigToken->Token.ConnectNetworkToken;
1256 if (ConnectToken->Data ==
NULL) {
1261 if (ConnectToken->Data->Network ==
NULL) {
1270 Status =
gBS->CreateEvent (
1275 &ConnectToken->Event
1277 if (EFI_ERROR (Status)) {
1281 Nic->ConnectState = WifiMgrConnectingToAp;
1282 Nic->CurrentOperateNetwork = Profile;
1288 Status = Nic->Wmp->ConnectNetwork (Nic->Wmp, ConnectToken);
1295 if (EFI_ERROR (Status)) {
1296 if (Status == EFI_ALREADY_STARTED) {
1297 Nic->ConnectState = WifiMgrConnectedToAp;
1300 Nic->ConnectState = WifiMgrDisconnected;
1301 Nic->CurrentOperateNetwork =
NULL;
1303 if (Nic->OneTimeConnectRequest) {
1304 if (Status == EFI_NOT_FOUND) {
1317 if (EFI_ERROR (Status)) {
1321 gBS->RestoreTPL (OldTpl);
1323 DEBUG ((DEBUG_INFO,
"[WiFi Connection Manager] WifiMgrConnectToNetwork: %r\n", Status));
1345 ASSERT (Context !=
NULL);
1348 ASSERT (ConfigToken->Nic !=
NULL);
1349 ASSERT (ConfigToken->Type == TokenTypeDisconnectNetworkToken);
1351 ASSERT (ConfigToken->Token.DisconnectNetworkToken !=
NULL);
1352 if (ConfigToken->Token.DisconnectNetworkToken->Status !=
EFI_SUCCESS) {
1353 ConfigToken->Nic->ConnectState = WifiMgrConnectedToAp;
1355 ConfigToken->Nic->OneTimeDisconnectRequest =
FALSE;
1359 ConfigToken->Nic->ConnectState = WifiMgrDisconnected;
1360 ConfigToken->Nic->CurrentOperateNetwork =
NULL;
1362 ConfigToken->Nic->OneTimeDisconnectRequest =
FALSE;
1367 ConfigToken->Nic->OneTimeScanRequest =
TRUE;
1397 return EFI_INVALID_PARAMETER;
1400 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1403 if (ConfigToken ==
NULL) {
1404 gBS->RestoreTPL (OldTpl);
1405 return EFI_OUT_OF_RESOURCES;
1408 ConfigToken->Type = TokenTypeDisconnectNetworkToken;
1409 ConfigToken->Nic = Nic;
1411 if (ConfigToken->Token.DisconnectNetworkToken ==
NULL) {
1413 gBS->RestoreTPL (OldTpl);
1414 return EFI_OUT_OF_RESOURCES;
1417 DisconnectToken = ConfigToken->Token.DisconnectNetworkToken;
1419 Status =
gBS->CreateEvent (
1424 &DisconnectToken->Event
1426 if (EFI_ERROR (Status)) {
1428 gBS->RestoreTPL (OldTpl);
1432 Nic->ConnectState = WifiMgrDisconnectingToAp;
1435 Status = Nic->Wmp->DisconnectNetwork (Nic->Wmp, DisconnectToken);
1436 if (EFI_ERROR (Status)) {
1437 if (Status == EFI_NOT_FOUND) {
1438 Nic->ConnectState = WifiMgrDisconnected;
1439 Nic->CurrentOperateNetwork =
NULL;
1444 Nic->OneTimeScanRequest =
TRUE;
1452 if (Nic->OneTimeDisconnectRequest) {
1456 Nic->ConnectState = WifiMgrConnectedToAp;
1463 gBS->RestoreTPL (OldTpl);
1487 if (Context ==
NULL) {
1492 NET_CHECK_SIGNATURE (Nic, WIFI_MGR_DEVICE_DATA_SIGNATURE);
1495 if (EFI_ERROR (Status)) {
1496 DEBUG ((DEBUG_INFO,
"[WiFi Connection Manager] Error: Failed to get link state!\n"));
1502 Nic->HasDisconnectPendingNetwork =
TRUE;
1508 Nic->ScanTickTime++;
1509 if ((((Nic->ScanTickTime > WIFI_SCAN_FREQUENCY) && (Nic->ConnectState != WifiMgrConnectedToAp)) ||
1510 Nic->OneTimeScanRequest) && (Nic->ScanState == WifiMgrScanFinished))
1512 Nic->OneTimeScanRequest =
FALSE;
1513 Nic->ScanTickTime = 0;
1515 DEBUG ((DEBUG_INFO,
"[WiFi Connection Manager] Scan is triggered.\n"));
1519 if ((Nic->AvailableCount > 0) && (Nic->ScanState == WifiMgrScanFinished)) {
1520 switch (Nic->ConnectState) {
1521 case WifiMgrDisconnected:
1523 if (Nic->HasDisconnectPendingNetwork) {
1524 Nic->HasDisconnectPendingNetwork =
FALSE;
1527 if (Nic->ConnectPendingNetwork !=
NULL) {
1528 Profile = Nic->ConnectPendingNetwork;
1530 Nic->ConnectPendingNetwork =
NULL;
1531 if (EFI_ERROR (Status)) {
1535 Nic->OneTimeConnectRequest =
FALSE;
1541 case WifiMgrConnectingToAp:
1544 case WifiMgrDisconnectingToAp:
1547 case WifiMgrConnectedToAp:
1549 if ((Nic->ConnectPendingNetwork !=
NULL) || Nic->HasDisconnectPendingNetwork) {
1551 if (EFI_ERROR (Status)) {
1555 Nic->OneTimeDisconnectRequest =
FALSE;
UINTN EFIAPI AsciiStrnLenS(IN CONST CHAR8 *String, IN UINTN MaxSize)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
RETURN_STATUS EFIAPI UnicodeStrToAsciiStrS(IN CONST CHAR16 *Source, OUT CHAR8 *Destination, IN UINTN DestMax)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define EFI_EAP_TYPE_ATTRIBUTE
@ EfiEapConfigEapAuthMethod
@ EfiEapConfigEapMSChapV2Password
@ EfiEapConfigEapTlsCACert
@ EfiEapConfigEap2ndAuthMethod
@ EfiEapConfigIdentityString
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG(Expression)
VOID EFIAPI Exit(IN EFI_STATUS Status)
VOID WifiMgrUpdateConnectMessage(IN WIFI_MGR_DEVICE_DATA *Nic, IN BOOLEAN ConnectStateChanged, IN EFI_STRING ConnectStatusMessage)
EFI_STATUS WifiMgrPrepareConnection(IN WIFI_MGR_DEVICE_DATA *Nic, IN WIFI_MGR_NETWORK_PROFILE *Profile)
VOID EFIAPI WifiMgrOnTimerTick(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS WifiMgrGetLinkState(IN WIFI_MGR_DEVICE_DATA *Nic, OUT EFI_ADAPTER_INFO_MEDIA_STATE *LinkState)
EFI_STATUS WifiMgrConfigPassword(IN WIFI_MGR_DEVICE_DATA *Nic, IN WIFI_MGR_NETWORK_PROFILE *Profile)
EFI_STATUS WifiMgrStartScan(IN WIFI_MGR_DEVICE_DATA *Nic)
EFI_STATUS WifiMgrConnectToNetwork(IN WIFI_MGR_DEVICE_DATA *Nic, IN WIFI_MGR_NETWORK_PROFILE *Profile)
EFI_STATUS WifiMgrDisconnectToNetwork(IN WIFI_MGR_DEVICE_DATA *Nic)
VOID EFIAPI WifiMgrOnConnectFinished(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS ConnectionRetry(IN EDKII_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol)
EFI_STATUS WifiMgrConfigEap(IN WIFI_MGR_DEVICE_DATA *Nic, IN WIFI_MGR_NETWORK_PROFILE *Profile)
VOID EFIAPI WifiMgrOnDisconnectFinished(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI WifiMgrOnScanFinished(IN EFI_EVENT Event, IN VOID *Context)
WIFI_MGR_NETWORK_PROFILE * WifiMgrGetProfileByAsciiSSId(IN CHAR8 *SSId, IN UINT8 SecurityType, IN LIST_ENTRY *ProfileList)
EFI_STATUS WifiMgrCheckRSN(IN EFI_80211_AKM_SUITE_SELECTOR *AKMList, IN EFI_80211_CIPHER_SUITE_SELECTOR *CipherList, IN WIFI_MGR_DEVICE_DATA *Nic, OUT UINT8 *SecurityType, OUT BOOLEAN *AKMSuiteSupported, OUT BOOLEAN *CipherSuiteSupported)
EFI_STATUS WifiMgrGetSupportedSuites(IN WIFI_MGR_DEVICE_DATA *Nic)
VOID WifiMgrCleanProfileSecrets(IN WIFI_MGR_NETWORK_PROFILE *Profile)
VOID WifiMgrFreeToken(IN WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken)