2 The Miscellaneous Routines for WiFi Connection Manager.
4 Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "WifiConnectionMgrDxe.h"
13 // STA AKM preference order
14 // REF: https://www.wi-fi.org/file/wpa3-specification
16 STATIC UINT32 mAKMSuitePreference
[] = {
17 IEEE_80211_AKM_SUITE_8021X_SUITE_B192
, // AKM Suite 12
18 IEEE_80211_AKM_SUITE_8021X_SUITE_B
, // AKM Suite 11
19 IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256
, // AKM Suite 5
20 IEEE_80211_AKM_SUITE_8021X_OR_PMKSA
, // AKM Suite 1
22 IEEE_80211_AKM_SUITE_SAE
, // AKM Suite 8
23 IEEE_80211_AKM_SUITE_PSK_SHA256
, // AKM Suite 6
24 IEEE_80211_AKM_SUITE_PSK
, // AKM Suite 2
26 IEEE_80211_AKM_SUITE_OWE
// AKM Suite 18
28 #define AKM_SUITE_PREFERENCE_COUNT (sizeof (mAKMSuitePreference) / sizeof (UINT32))
31 Empty function for event process function.
33 @param Event The Event need to be process
34 @param Context The context of the event.
39 WifiMgrInternalEmptyFunction (
48 Convert the mac address into a hexadecimal encoded ":" seperated string.
50 @param[in] Mac The mac address.
51 @param[in] StrSize The size, in bytes, of the output buffer specified by Str.
52 @param[out] Str The storage to return the mac string.
57 IN EFI_80211_MAC_ADDRESS
*Mac
,
62 if ((Mac
== NULL
) || (Str
== NULL
)) {
69 L
"%02X:%02X:%02X:%02X:%02X:%02X",
80 Read private key file to buffer.
82 @param[in] FileContext The file context of private key file.
83 @param[out] PrivateKeyDataAddr The buffer address to restore private key file, should be
85 @param[out] PrivateKeyDataSize The size of read private key file.
87 @retval EFI_SUCCESS Successfully read the private key file.
88 @retval EFI_INVALID_PARAMETER One or more of the parameters is invalid.
92 WifiMgrReadFileToBuffer (
93 IN WIFI_MGR_FILE_CONTEXT
*FileContext
,
100 if ((FileContext
!= NULL
) && (FileContext
->FHandle
!= NULL
)) {
101 Status
= ReadFileContent (
102 FileContext
->FHandle
,
108 if (FileContext
->FHandle
!= NULL
) {
109 FileContext
->FHandle
->Close (FileContext
->FHandle
);
112 FileContext
->FHandle
= NULL
;
116 return EFI_INVALID_PARAMETER
;
120 Get the Nic data by the NicIndex.
122 @param[in] Private The pointer to the global private data structure.
123 @param[in] NicIndex The index indicates the position of wireless NIC.
125 @return Pointer to the Nic data, or NULL if not found.
128 WIFI_MGR_DEVICE_DATA
*
129 WifiMgrGetNicByIndex (
130 IN WIFI_MGR_PRIVATE_DATA
*Private
,
135 WIFI_MGR_DEVICE_DATA
*Nic
;
137 if (Private
== NULL
) {
141 NET_LIST_FOR_EACH (Entry
, &Private
->NicList
) {
142 Nic
= NET_LIST_USER_STRUCT_S (
144 WIFI_MGR_DEVICE_DATA
,
146 WIFI_MGR_DEVICE_DATA_SIGNATURE
148 if (Nic
->NicIndex
== NicIndex
) {
157 Find a network profile through its' SSId and securit type, and the SSId is an unicode string.
159 @param[in] SSId The target network's SSId.
160 @param[in] SecurityType The target network's security type.
161 @param[in] ProfileList The profile list on a Nic.
163 @return Pointer to a network profile, or NULL if not found.
166 WIFI_MGR_NETWORK_PROFILE
*
167 WifiMgrGetProfileByUnicodeSSId (
169 IN UINT8 SecurityType
,
170 IN LIST_ENTRY
*ProfileList
174 WIFI_MGR_NETWORK_PROFILE
*Profile
;
176 if ((SSId
== NULL
) || (ProfileList
== NULL
)) {
180 NET_LIST_FOR_EACH (Entry
, ProfileList
) {
181 Profile
= NET_LIST_USER_STRUCT_S (
183 WIFI_MGR_NETWORK_PROFILE
,
185 WIFI_MGR_PROFILE_SIGNATURE
187 if ((StrCmp (SSId
, Profile
->SSId
) == 0) && (SecurityType
== Profile
->SecurityType
)) {
196 Find a network profile through its' SSId and securit type, and the SSId is an ascii string.
198 @param[in] SSId The target network's SSId.
199 @param[in] SecurityType The target network's security type.
200 @param[in] ProfileList The profile list on a Nic.
202 @return Pointer to a network profile, or NULL if not found.
205 WIFI_MGR_NETWORK_PROFILE
*
206 WifiMgrGetProfileByAsciiSSId (
208 IN UINT8 SecurityType
,
209 IN LIST_ENTRY
*ProfileList
212 CHAR16 SSIdUniCode
[SSID_STORAGE_SIZE
];
218 if (AsciiStrToUnicodeStrS (SSId
, SSIdUniCode
, SSID_STORAGE_SIZE
) != RETURN_SUCCESS
) {
222 return WifiMgrGetProfileByUnicodeSSId (SSIdUniCode
, SecurityType
, ProfileList
);
226 Find a network profile through its' profile index.
228 @param[in] ProfileIndex The target network's profile index.
229 @param[in] ProfileList The profile list on a Nic.
231 @return Pointer to a network profile, or NULL if not found.
234 WIFI_MGR_NETWORK_PROFILE
*
235 WifiMgrGetProfileByProfileIndex (
236 IN UINT32 ProfileIndex
,
237 IN LIST_ENTRY
*ProfileList
240 WIFI_MGR_NETWORK_PROFILE
*Profile
;
243 if (ProfileList
== NULL
) {
247 NET_LIST_FOR_EACH (Entry
, ProfileList
) {
248 Profile
= NET_LIST_USER_STRUCT_S (
250 WIFI_MGR_NETWORK_PROFILE
,
252 WIFI_MGR_PROFILE_SIGNATURE
254 if (Profile
->ProfileIndex
== ProfileIndex
) {
262 To test if the AKMSuite is in supported AKMSuite list.
264 @param[in] SupportedAKMSuiteCount The count of the supported AKMSuites.
265 @param[in] SupportedAKMSuiteList The supported AKMSuite list.
266 @param[in] AKMSuite The AKMSuite to be tested.
268 @return True if this AKMSuite is supported, or False if not.
272 WifiMgrSupportAKMSuite (
273 IN UINT16 SupportedAKMSuiteCount
,
274 IN UINT32
*SupportedAKMSuiteList
,
280 if ((AKMSuite
== NULL
) || (SupportedAKMSuiteList
== NULL
) ||
281 (SupportedAKMSuiteCount
== 0))
286 for (Index
= 0; Index
< SupportedAKMSuiteCount
; Index
++) {
287 if (SupportedAKMSuiteList
[Index
] == *AKMSuite
) {
296 To check if the CipherSuite is in supported CipherSuite list.
298 @param[in] SupportedCipherSuiteCount The count of the supported CipherSuites.
299 @param[in] SupportedCipherSuiteList The supported CipherSuite list.
300 @param[in] CipherSuite The CipherSuite to be tested.
302 @return True if this CipherSuite is supported, or False if not.
306 WifiMgrSupportCipherSuite (
307 IN UINT16 SupportedCipherSuiteCount
,
308 IN UINT32
*SupportedCipherSuiteList
,
309 IN UINT32
*CipherSuite
314 if ((CipherSuite
== NULL
) || (SupportedCipherSuiteCount
== 0) ||
315 (SupportedCipherSuiteList
== NULL
))
320 for (Index
= 0; Index
< SupportedCipherSuiteCount
; Index
++) {
321 if (SupportedCipherSuiteList
[Index
] == *CipherSuite
) {
330 Check an AKM suite list and a Cipher suite list to see if one or more AKM suites or Cipher suites
331 are supported and find the matchable security type.
333 @param[in] AKMList The target AKM suite list to be checked.
334 @param[in] CipherList The target Cipher suite list to be checked
335 @param[in] Nic The Nic to operate, contains the supported AKMSuite list
336 and supported CipherSuite list
337 @param[out] SecurityType To identify a security type from the AKM suite list and
339 @param[out] AKMSuiteSupported To identify if this security type is supported. If it is
340 NULL, overcome this field
341 @param[out] CipherSuiteSupported To identify if this security type is supported. If it is
342 NULL, overcome this field
344 @retval EFI_SUCCESS This operation has completed successfully.
345 @retval EFI_INVALID_PARAMETER No Nic found or the suite list is null.
350 IN EFI_80211_AKM_SUITE_SELECTOR
*AKMList
,
351 IN EFI_80211_CIPHER_SUITE_SELECTOR
*CipherList
,
352 IN WIFI_MGR_DEVICE_DATA
*Nic
,
353 OUT UINT8
*SecurityType
,
354 OUT BOOLEAN
*AKMSuiteSupported
,
355 OUT BOOLEAN
*CipherSuiteSupported
358 EFI_80211_AKM_SUITE_SELECTOR
*SupportedAKMSuites
;
359 EFI_80211_CIPHER_SUITE_SELECTOR
*SupportedSwCipherSuites
;
360 EFI_80211_CIPHER_SUITE_SELECTOR
*SupportedHwCipherSuites
;
362 EFI_80211_SUITE_SELECTOR
*CipherSuite
;
366 if ((Nic
== NULL
) || (AKMList
== NULL
) || (CipherList
== NULL
) || (SecurityType
== NULL
)) {
367 return EFI_INVALID_PARAMETER
;
370 SupportedAKMSuites
= Nic
->SupportedSuites
.SupportedAKMSuites
;
371 SupportedSwCipherSuites
= Nic
->SupportedSuites
.SupportedSwCipherSuites
;
372 SupportedHwCipherSuites
= Nic
->SupportedSuites
.SupportedHwCipherSuites
;
374 *SecurityType
= SECURITY_TYPE_UNKNOWN
;
375 if ((AKMSuiteSupported
!= NULL
) && (CipherSuiteSupported
!= NULL
)) {
376 *AKMSuiteSupported
= FALSE
;
377 *CipherSuiteSupported
= FALSE
;
380 if (AKMList
->AKMSuiteCount
== 0) {
381 if (CipherList
->CipherSuiteCount
== 0) {
382 *SecurityType
= SECURITY_TYPE_NONE
;
383 if ((AKMSuiteSupported
!= NULL
) && (CipherSuiteSupported
!= NULL
)) {
384 *AKMSuiteSupported
= TRUE
;
385 *CipherSuiteSupported
= TRUE
;
392 for (AKMIndex
= 0; AKMIndex
< AKM_SUITE_PREFERENCE_COUNT
; AKMIndex
++) {
393 AKMSuite
= mAKMSuitePreference
+ AKMIndex
;
394 if (WifiMgrSupportAKMSuite (AKMList
->AKMSuiteCount
, (UINT32
*)AKMList
->AKMSuiteList
, AKMSuite
) &&
395 WifiMgrSupportAKMSuite (SupportedAKMSuites
->AKMSuiteCount
, (UINT32
*)SupportedAKMSuites
->AKMSuiteList
, AKMSuite
))
397 if ((AKMSuiteSupported
!= NULL
) && (CipherSuiteSupported
!= NULL
)) {
398 *AKMSuiteSupported
= TRUE
;
402 // OWE transition mode allow CipherSuiteCount is 0
404 if (CipherList
->CipherSuiteCount
== 0) {
405 *SecurityType
= WifiMgrGetSecurityType ((UINT32
*)AKMSuite
, NULL
);
406 if (*SecurityType
!= SECURITY_TYPE_UNKNOWN
) {
407 if ((AKMSuiteSupported
!= NULL
) && (CipherSuiteSupported
!= NULL
)) {
408 *CipherSuiteSupported
= TRUE
;
415 for (CipherIndex
= 0; CipherIndex
< CipherList
->CipherSuiteCount
; CipherIndex
++) {
416 CipherSuite
= CipherList
->CipherSuiteList
+ CipherIndex
;
418 if (SupportedSwCipherSuites
!= NULL
) {
419 if (WifiMgrSupportCipherSuite (
420 SupportedSwCipherSuites
->CipherSuiteCount
,
421 (UINT32
*)SupportedSwCipherSuites
->CipherSuiteList
,
422 (UINT32
*)CipherSuite
425 *SecurityType
= WifiMgrGetSecurityType ((UINT32
*)AKMSuite
, (UINT32
*)CipherSuite
);
427 if (*SecurityType
!= SECURITY_TYPE_UNKNOWN
) {
428 if ((AKMSuiteSupported
!= NULL
) && (CipherSuiteSupported
!= NULL
)) {
429 *CipherSuiteSupported
= TRUE
;
437 if (SupportedHwCipherSuites
!= NULL
) {
438 if (WifiMgrSupportCipherSuite (
439 SupportedHwCipherSuites
->CipherSuiteCount
,
440 (UINT32
*)SupportedHwCipherSuites
->CipherSuiteList
,
441 (UINT32
*)CipherSuite
444 *SecurityType
= WifiMgrGetSecurityType ((UINT32
*)AKMSuite
, (UINT32
*)CipherSuite
);
446 if (*SecurityType
!= SECURITY_TYPE_UNKNOWN
) {
447 if ((AKMSuiteSupported
!= NULL
) && (CipherSuiteSupported
!= NULL
)) {
448 *CipherSuiteSupported
= TRUE
;
459 *SecurityType
= WifiMgrGetSecurityType (
460 (UINT32
*)AKMList
->AKMSuiteList
,
461 (UINT32
*)CipherList
->CipherSuiteList
468 Get the security type for a certain AKMSuite and CipherSuite.
470 @param[in] AKMSuite An certain AKMSuite.
471 @param[in] CipherSuite An certain CipherSuite.
473 @return a security type if found, or SECURITY_TYPE_UNKNOWN.
477 WifiMgrGetSecurityType (
479 IN UINT32
*CipherSuite
482 if ((AKMSuite
!= NULL
) && (*AKMSuite
== IEEE_80211_AKM_SUITE_OWE
)) {
483 return SECURITY_TYPE_NONE
;
486 if (CipherSuite
== NULL
) {
487 if (AKMSuite
== NULL
) {
488 return SECURITY_TYPE_NONE
;
490 return SECURITY_TYPE_UNKNOWN
;
492 } else if (*CipherSuite
== IEEE_80211_PAIRWISE_CIPHER_SUITE_USE_GROUP
) {
493 if (AKMSuite
== NULL
) {
494 return SECURITY_TYPE_NONE
;
496 return SECURITY_TYPE_UNKNOWN
;
498 } else if ((*CipherSuite
== IEEE_80211_PAIRWISE_CIPHER_SUITE_WEP40
) ||
499 (*CipherSuite
== IEEE_80211_PAIRWISE_CIPHER_SUITE_WEP104
))
501 return SECURITY_TYPE_WEP
;
502 } else if (*CipherSuite
== IEEE_80211_PAIRWISE_CIPHER_SUITE_CCMP
) {
503 if (AKMSuite
== NULL
) {
504 return SECURITY_TYPE_UNKNOWN
;
507 if (*AKMSuite
== IEEE_80211_AKM_SUITE_SAE
) {
508 return SECURITY_TYPE_WPA3_PERSONAL
;
509 } else if ((*AKMSuite
== IEEE_80211_AKM_SUITE_8021X_OR_PMKSA
) ||
510 (*AKMSuite
== IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256
))
512 return SECURITY_TYPE_WPA2_ENTERPRISE
;
513 } else if ((*AKMSuite
== IEEE_80211_AKM_SUITE_PSK
) ||
514 (*AKMSuite
== IEEE_80211_AKM_SUITE_PSK_SHA256
))
516 return SECURITY_TYPE_WPA2_PERSONAL
;
518 return SECURITY_TYPE_UNKNOWN
;
520 } else if (*CipherSuite
== IEEE_80211_PAIRWISE_CIPHER_SUITE_TKIP
) {
521 if (AKMSuite
== NULL
) {
522 return SECURITY_TYPE_UNKNOWN
;
525 if ((*AKMSuite
== IEEE_80211_AKM_SUITE_8021X_OR_PMKSA
) ||
526 (*AKMSuite
== IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256
))
528 return SECURITY_TYPE_WPA_ENTERPRISE
;
529 } else if ((*AKMSuite
== IEEE_80211_AKM_SUITE_PSK
) ||
530 (*AKMSuite
== IEEE_80211_AKM_SUITE_PSK_SHA256
))
532 return SECURITY_TYPE_WPA_PERSONAL
;
534 return SECURITY_TYPE_UNKNOWN
;
536 } else if (*CipherSuite
== IEEE_80211_PAIRWISE_CIPHER_SUITE_GCMP
) {
537 if (AKMSuite
== NULL
) {
538 return SECURITY_TYPE_UNKNOWN
;
541 if (*AKMSuite
== IEEE_80211_AKM_SUITE_8021X_SUITE_B
) {
542 return SECURITY_TYPE_WPA3_ENTERPRISE
;
544 return SECURITY_TYPE_UNKNOWN
;
546 } else if (*CipherSuite
== IEEE_80211_PAIRWISE_CIPHER_SUITE_GCMP256
) {
547 if (AKMSuite
== NULL
) {
548 return SECURITY_TYPE_UNKNOWN
;
551 if (*AKMSuite
== IEEE_80211_AKM_SUITE_8021X_SUITE_B192
) {
552 return SECURITY_TYPE_WPA3_ENTERPRISE
;
554 return SECURITY_TYPE_UNKNOWN
;
557 return SECURITY_TYPE_UNKNOWN
;
562 Get supported AKMSuites and CipherSuites from supplicant for a Nic.
564 @param[in] Nic The Nic to operate.
566 @retval EFI_SUCCESS Get the supported suite list successfully.
567 @retval EFI_INVALID_PARAMETER No Nic found or supplicant is NULL.
571 WifiMgrGetSupportedSuites (
572 IN WIFI_MGR_DEVICE_DATA
*Nic
576 EFI_SUPPLICANT_PROTOCOL
*Supplicant
;
577 EFI_80211_AKM_SUITE_SELECTOR
*SupportedAKMSuites
;
578 EFI_80211_CIPHER_SUITE_SELECTOR
*SupportedSwCipherSuites
;
579 EFI_80211_CIPHER_SUITE_SELECTOR
*SupportedHwCipherSuites
;
582 SupportedAKMSuites
= NULL
;
583 SupportedSwCipherSuites
= NULL
;
584 SupportedHwCipherSuites
= NULL
;
586 if ((Nic
== NULL
) || (Nic
->Supplicant
== NULL
)) {
587 return EFI_INVALID_PARAMETER
;
590 Supplicant
= Nic
->Supplicant
;
593 Status
= Supplicant
->GetData (Supplicant
, EfiSupplicant80211SupportedAKMSuites
, NULL
, &DataSize
);
594 if ((Status
== EFI_BUFFER_TOO_SMALL
) && (DataSize
> 0)) {
595 SupportedAKMSuites
= AllocateZeroPool (DataSize
);
596 if (SupportedAKMSuites
== NULL
) {
597 return EFI_OUT_OF_RESOURCES
;
600 Status
= Supplicant
->GetData (
602 EfiSupplicant80211SupportedAKMSuites
,
603 (UINT8
*)SupportedAKMSuites
,
606 if (!EFI_ERROR (Status
)) {
607 Nic
->SupportedSuites
.SupportedAKMSuites
= SupportedAKMSuites
;
609 FreePool (SupportedAKMSuites
);
612 SupportedAKMSuites
= NULL
;
616 Status
= Supplicant
->GetData (Supplicant
, EfiSupplicant80211SupportedSoftwareCipherSuites
, NULL
, &DataSize
);
617 if ((Status
== EFI_BUFFER_TOO_SMALL
) && (DataSize
> 0)) {
618 SupportedSwCipherSuites
= AllocateZeroPool (DataSize
);
619 if (SupportedSwCipherSuites
== NULL
) {
620 return EFI_OUT_OF_RESOURCES
;
623 Status
= Supplicant
->GetData (
625 EfiSupplicant80211SupportedSoftwareCipherSuites
,
626 (UINT8
*)SupportedSwCipherSuites
,
629 if (!EFI_ERROR (Status
)) {
630 Nic
->SupportedSuites
.SupportedSwCipherSuites
= SupportedSwCipherSuites
;
632 FreePool (SupportedSwCipherSuites
);
635 SupportedSwCipherSuites
= NULL
;
639 Status
= Supplicant
->GetData (Supplicant
, EfiSupplicant80211SupportedHardwareCipherSuites
, NULL
, &DataSize
);
640 if ((Status
== EFI_BUFFER_TOO_SMALL
) && (DataSize
> 0)) {
641 SupportedHwCipherSuites
= AllocateZeroPool (DataSize
);
642 if (SupportedHwCipherSuites
== NULL
) {
643 return EFI_OUT_OF_RESOURCES
;
646 Status
= Supplicant
->GetData (
648 EfiSupplicant80211SupportedHardwareCipherSuites
,
649 (UINT8
*)SupportedHwCipherSuites
,
652 if (!EFI_ERROR (Status
)) {
653 Nic
->SupportedSuites
.SupportedHwCipherSuites
= SupportedHwCipherSuites
;
655 FreePool (SupportedHwCipherSuites
);
658 SupportedHwCipherSuites
= NULL
;
665 Clean secrets from a network profile.
667 @param[in] Profile The profile to be cleanned.
671 WifiMgrCleanProfileSecrets (
672 IN WIFI_MGR_NETWORK_PROFILE
*Profile
675 ZeroMem (Profile
->Password
, sizeof (CHAR16
) * PASSWORD_STORAGE_SIZE
);
676 ZeroMem (Profile
->EapPassword
, sizeof (CHAR16
) * PASSWORD_STORAGE_SIZE
);
677 ZeroMem (Profile
->PrivateKeyPassword
, sizeof (CHAR16
) * PASSWORD_STORAGE_SIZE
);
679 if (Profile
->CACertData
!= NULL
) {
680 ZeroMem (Profile
->CACertData
, Profile
->CACertSize
);
681 FreePool (Profile
->CACertData
);
684 Profile
->CACertData
= NULL
;
685 Profile
->CACertSize
= 0;
687 if (Profile
->ClientCertData
!= NULL
) {
688 ZeroMem (Profile
->ClientCertData
, Profile
->ClientCertSize
);
689 FreePool (Profile
->ClientCertData
);
692 Profile
->ClientCertData
= NULL
;
693 Profile
->ClientCertSize
= 0;
695 if (Profile
->PrivateKeyData
!= NULL
) {
696 ZeroMem (Profile
->PrivateKeyData
, Profile
->PrivateKeyDataSize
);
697 FreePool (Profile
->PrivateKeyData
);
700 Profile
->PrivateKeyData
= NULL
;
701 Profile
->PrivateKeyDataSize
= 0;
705 Free all network profiles in a profile list.
707 @param[in] ProfileList The profile list to be freed.
711 WifiMgrFreeProfileList (
712 IN LIST_ENTRY
*ProfileList
715 WIFI_MGR_NETWORK_PROFILE
*Profile
;
717 LIST_ENTRY
*NextEntry
;
719 if (ProfileList
== NULL
) {
723 NET_LIST_FOR_EACH_SAFE (Entry
, NextEntry
, ProfileList
) {
724 Profile
= NET_LIST_USER_STRUCT_S (
726 WIFI_MGR_NETWORK_PROFILE
,
728 WIFI_MGR_PROFILE_SIGNATURE
731 WifiMgrCleanProfileSecrets (Profile
);
733 if (Profile
->Network
.AKMSuite
!= NULL
) {
734 FreePool (Profile
->Network
.AKMSuite
);
737 if (Profile
->Network
.CipherSuite
!= NULL
) {
738 FreePool (Profile
->Network
.CipherSuite
);
746 Free user configured hidden network list.
748 @param[in] HiddenList The hidden network list to be freed.
752 WifiMgrFreeHiddenList (
753 IN LIST_ENTRY
*HiddenList
756 WIFI_HIDDEN_NETWORK_DATA
*HiddenNetwork
;
758 LIST_ENTRY
*NextEntry
;
760 if (HiddenList
== NULL
) {
764 NET_LIST_FOR_EACH_SAFE (Entry
, NextEntry
, HiddenList
) {
765 HiddenNetwork
= NET_LIST_USER_STRUCT_S (
767 WIFI_HIDDEN_NETWORK_DATA
,
769 WIFI_MGR_HIDDEN_NETWORK_SIGNATURE
771 FreePool (HiddenNetwork
);
776 Free the resources of a config token.
778 @param[in] ConfigToken The config token to be freed.
782 IN WIFI_MGR_MAC_CONFIG_TOKEN
*ConfigToken
785 EFI_80211_GET_NETWORKS_RESULT
*Result
;
787 if (ConfigToken
== NULL
) {
791 switch (ConfigToken
->Type
) {
792 case TokenTypeGetNetworksToken
:
794 if (ConfigToken
->Token
.GetNetworksToken
!= NULL
) {
795 gBS
->CloseEvent (ConfigToken
->Token
.GetNetworksToken
->Event
);
796 if (ConfigToken
->Token
.GetNetworksToken
->Data
!= NULL
) {
797 FreePool (ConfigToken
->Token
.GetNetworksToken
->Data
);
800 Result
= ConfigToken
->Token
.GetNetworksToken
->Result
;
801 if (Result
!= NULL
) {
805 FreePool (ConfigToken
->Token
.GetNetworksToken
);
808 FreePool (ConfigToken
);
811 case TokenTypeConnectNetworkToken
:
813 if (ConfigToken
->Token
.ConnectNetworkToken
!= NULL
) {
814 gBS
->CloseEvent (ConfigToken
->Token
.ConnectNetworkToken
->Event
);
815 if (ConfigToken
->Token
.ConnectNetworkToken
->Data
!= NULL
) {
816 FreePool (ConfigToken
->Token
.ConnectNetworkToken
->Data
);
819 FreePool (ConfigToken
->Token
.ConnectNetworkToken
);
822 FreePool (ConfigToken
);
825 case TokenTypeDisconnectNetworkToken
:
827 if (ConfigToken
->Token
.DisconnectNetworkToken
!= NULL
) {
828 FreePool (ConfigToken
->Token
.DisconnectNetworkToken
);
831 FreePool (ConfigToken
);