]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / NetworkPkg / WifiConnectionManagerDxe / WifiConnectionMgrMisc.c
1 /** @file
2 The Miscellaneous Routines for WiFi Connection Manager.
3
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "WifiConnectionMgrDxe.h"
11
12 /**
13 Empty function for event process function.
14
15 @param Event The Event need to be process
16 @param Context The context of the event.
17
18 **/
19 VOID
20 EFIAPI
21 WifiMgrInternalEmptyFunction (
22 IN EFI_EVENT Event,
23 IN VOID *Context
24 )
25 {
26 return;
27 }
28
29 /**
30 Convert the mac address into a hexadecimal encoded ":" seperated string.
31
32 @param[in] Mac The mac address.
33 @param[in] StrSize The size, in bytes, of the output buffer specified by Str.
34 @param[out] Str The storage to return the mac string.
35
36 **/
37 VOID
38 WifiMgrMacAddrToStr (
39 IN EFI_80211_MAC_ADDRESS *Mac,
40 IN UINT32 StrSize,
41 OUT CHAR16 *Str
42 )
43 {
44 if ((Mac == NULL) || (Str == NULL)) {
45 return;
46 }
47
48 UnicodeSPrint (
49 Str,
50 StrSize,
51 L"%02X:%02X:%02X:%02X:%02X:%02X",
52 Mac->Addr[0],
53 Mac->Addr[1],
54 Mac->Addr[2],
55 Mac->Addr[3],
56 Mac->Addr[4],
57 Mac->Addr[5]
58 );
59 }
60
61 /**
62 Read private key file to buffer.
63
64 @param[in] FileContext The file context of private key file.
65 @param[out] PrivateKeyDataAddr The buffer address to restore private key file, should be
66 freed by caller.
67 @param[out] PrivateKeyDataSize The size of read private key file.
68
69 @retval EFI_SUCCESS Successfully read the private key file.
70 @retval EFI_INVALID_PARAMETER One or more of the parameters is invalid.
71
72 **/
73 EFI_STATUS
74 WifiMgrReadFileToBuffer (
75 IN WIFI_MGR_FILE_CONTEXT *FileContext,
76 OUT VOID **DataAddr,
77 OUT UINTN *DataSize
78 )
79 {
80 EFI_STATUS Status;
81
82 if ((FileContext != NULL) && (FileContext->FHandle != NULL)) {
83 Status = ReadFileContent (
84 FileContext->FHandle,
85 DataAddr,
86 DataSize,
87 0
88 );
89
90 if (FileContext->FHandle != NULL) {
91 FileContext->FHandle->Close (FileContext->FHandle);
92 }
93
94 FileContext->FHandle = NULL;
95 return Status;
96 }
97
98 return EFI_INVALID_PARAMETER;
99 }
100
101 /**
102 Get the Nic data by the NicIndex.
103
104 @param[in] Private The pointer to the global private data structure.
105 @param[in] NicIndex The index indicates the position of wireless NIC.
106
107 @return Pointer to the Nic data, or NULL if not found.
108
109 **/
110 WIFI_MGR_DEVICE_DATA *
111 WifiMgrGetNicByIndex (
112 IN WIFI_MGR_PRIVATE_DATA *Private,
113 IN UINT32 NicIndex
114 )
115 {
116 LIST_ENTRY *Entry;
117 WIFI_MGR_DEVICE_DATA *Nic;
118
119 if (Private == NULL) {
120 return NULL;
121 }
122
123 NET_LIST_FOR_EACH (Entry, &Private->NicList) {
124 Nic = NET_LIST_USER_STRUCT_S (
125 Entry,
126 WIFI_MGR_DEVICE_DATA,
127 Link,
128 WIFI_MGR_DEVICE_DATA_SIGNATURE
129 );
130 if (Nic->NicIndex == NicIndex) {
131 return Nic;
132 }
133 }
134
135 return NULL;
136 }
137
138 /**
139 Find a network profile through its' SSId and securit type, and the SSId is an unicode string.
140
141 @param[in] SSId The target network's SSId.
142 @param[in] SecurityType The target network's security type.
143 @param[in] ProfileList The profile list on a Nic.
144
145 @return Pointer to a network profile, or NULL if not found.
146
147 **/
148 WIFI_MGR_NETWORK_PROFILE *
149 WifiMgrGetProfileByUnicodeSSId (
150 IN CHAR16 *SSId,
151 IN UINT8 SecurityType,
152 IN LIST_ENTRY *ProfileList
153 )
154 {
155 LIST_ENTRY *Entry;
156 WIFI_MGR_NETWORK_PROFILE *Profile;
157
158 if ((SSId == NULL) || (ProfileList == NULL)) {
159 return NULL;
160 }
161
162 NET_LIST_FOR_EACH (Entry, ProfileList) {
163 Profile = NET_LIST_USER_STRUCT_S (
164 Entry,
165 WIFI_MGR_NETWORK_PROFILE,
166 Link,
167 WIFI_MGR_PROFILE_SIGNATURE
168 );
169 if ((StrCmp (SSId, Profile->SSId) == 0) && (SecurityType == Profile->SecurityType)) {
170 return Profile;
171 }
172 }
173
174 return NULL;
175 }
176
177 /**
178 Find a network profile through its' SSId and securit type, and the SSId is an ascii string.
179
180 @param[in] SSId The target network's SSId.
181 @param[in] SecurityType The target network's security type.
182 @param[in] ProfileList The profile list on a Nic.
183
184 @return Pointer to a network profile, or NULL if not found.
185
186 **/
187 WIFI_MGR_NETWORK_PROFILE *
188 WifiMgrGetProfileByAsciiSSId (
189 IN CHAR8 *SSId,
190 IN UINT8 SecurityType,
191 IN LIST_ENTRY *ProfileList
192 )
193 {
194 CHAR16 SSIdUniCode[SSID_STORAGE_SIZE];
195
196 if (SSId == NULL) {
197 return NULL;
198 }
199
200 if (AsciiStrToUnicodeStrS (SSId, SSIdUniCode, SSID_STORAGE_SIZE) != RETURN_SUCCESS) {
201 return NULL;
202 }
203
204 return WifiMgrGetProfileByUnicodeSSId (SSIdUniCode, SecurityType, ProfileList);
205 }
206
207 /**
208 Find a network profile through its' profile index.
209
210 @param[in] ProfileIndex The target network's profile index.
211 @param[in] ProfileList The profile list on a Nic.
212
213 @return Pointer to a network profile, or NULL if not found.
214
215 **/
216 WIFI_MGR_NETWORK_PROFILE *
217 WifiMgrGetProfileByProfileIndex (
218 IN UINT32 ProfileIndex,
219 IN LIST_ENTRY *ProfileList
220 )
221 {
222 WIFI_MGR_NETWORK_PROFILE *Profile;
223 LIST_ENTRY *Entry;
224
225 if (ProfileList == NULL) {
226 return NULL;
227 }
228
229 NET_LIST_FOR_EACH (Entry, ProfileList) {
230 Profile = NET_LIST_USER_STRUCT_S (
231 Entry,
232 WIFI_MGR_NETWORK_PROFILE,
233 Link,
234 WIFI_MGR_PROFILE_SIGNATURE
235 );
236 if (Profile->ProfileIndex == ProfileIndex) {
237 return Profile;
238 }
239 }
240 return NULL;
241 }
242
243 /**
244 To test if the AKMSuite is in supported AKMSuite list.
245
246 @param[in] SupportedAKMSuiteCount The count of the supported AKMSuites.
247 @param[in] SupportedAKMSuiteList The supported AKMSuite list.
248 @param[in] AKMSuite The AKMSuite to be tested.
249
250 @return True if this AKMSuite is supported, or False if not.
251
252 **/
253 BOOLEAN
254 WifiMgrSupportAKMSuite (
255 IN UINT16 SupportedAKMSuiteCount,
256 IN UINT32 *SupportedAKMSuiteList,
257 IN UINT32 *AKMSuite
258 )
259 {
260 UINT16 Index;
261
262 if ((AKMSuite == NULL) || (SupportedAKMSuiteList == NULL) ||
263 (SupportedAKMSuiteCount == 0))
264 {
265 return FALSE;
266 }
267
268 for (Index = 0; Index < SupportedAKMSuiteCount; Index++) {
269 if (SupportedAKMSuiteList[Index] == *AKMSuite) {
270 return TRUE;
271 }
272 }
273
274 return FALSE;
275 }
276
277 /**
278 To check if the CipherSuite is in supported CipherSuite list.
279
280 @param[in] SupportedCipherSuiteCount The count of the supported CipherSuites.
281 @param[in] SupportedCipherSuiteList The supported CipherSuite list.
282 @param[in] CipherSuite The CipherSuite to be tested.
283
284 @return True if this CipherSuite is supported, or False if not.
285
286 **/
287 BOOLEAN
288 WifiMgrSupportCipherSuite (
289 IN UINT16 SupportedCipherSuiteCount,
290 IN UINT32 *SupportedCipherSuiteList,
291 IN UINT32 *CipherSuite
292 )
293 {
294 UINT16 Index;
295
296 if ((CipherSuite == NULL) || (SupportedCipherSuiteCount == 0) ||
297 (SupportedCipherSuiteList == NULL))
298 {
299 return FALSE;
300 }
301
302 for (Index = 0; Index < SupportedCipherSuiteCount; Index++) {
303 if (SupportedCipherSuiteList[Index] == *CipherSuite) {
304 return TRUE;
305 }
306 }
307
308 return FALSE;
309 }
310
311 /**
312 Check an AKM suite list and a Cipher suite list to see if one or more AKM suites or Cipher suites
313 are supported and find the matchable security type.
314
315 @param[in] AKMList The target AKM suite list to be checked.
316 @param[in] CipherList The target Cipher suite list to be checked
317 @param[in] Nic The Nic to operate, contains the supported AKMSuite list
318 and supported CipherSuite list
319 @param[out] SecurityType To identify a security type from the AKM suite list and
320 Cipher suite list
321 @param[out] AKMSuiteSupported To identify if this security type is supported. If it is
322 NULL, overcome this field
323 @param[out] CipherSuiteSupported To identify if this security type is supported. If it is
324 NULL, overcome this field
325
326 @retval EFI_SUCCESS This operation has completed successfully.
327 @retval EFI_INVALID_PARAMETER No Nic found or the suite list is null.
328
329 **/
330 EFI_STATUS
331 WifiMgrCheckRSN (
332 IN EFI_80211_AKM_SUITE_SELECTOR *AKMList,
333 IN EFI_80211_CIPHER_SUITE_SELECTOR *CipherList,
334 IN WIFI_MGR_DEVICE_DATA *Nic,
335 OUT UINT8 *SecurityType,
336 OUT BOOLEAN *AKMSuiteSupported,
337 OUT BOOLEAN *CipherSuiteSupported
338 )
339 {
340 EFI_80211_AKM_SUITE_SELECTOR *SupportedAKMSuites;
341 EFI_80211_CIPHER_SUITE_SELECTOR *SupportedSwCipherSuites;
342 EFI_80211_CIPHER_SUITE_SELECTOR *SupportedHwCipherSuites;
343 EFI_80211_SUITE_SELECTOR *AKMSuite;
344 EFI_80211_SUITE_SELECTOR *CipherSuite;
345 UINT16 AKMIndex;
346 UINT16 CipherIndex;
347
348 if ((Nic == NULL) || (AKMList == NULL) || (CipherList == NULL) || (SecurityType == NULL)) {
349 return EFI_INVALID_PARAMETER;
350 }
351
352 SupportedAKMSuites = Nic->SupportedSuites.SupportedAKMSuites;
353 SupportedSwCipherSuites = Nic->SupportedSuites.SupportedSwCipherSuites;
354 SupportedHwCipherSuites = Nic->SupportedSuites.SupportedHwCipherSuites;
355
356 *SecurityType = SECURITY_TYPE_UNKNOWN;
357 if ((AKMSuiteSupported != NULL) && (CipherSuiteSupported != NULL)) {
358 *AKMSuiteSupported = FALSE;
359 *CipherSuiteSupported = FALSE;
360 }
361
362 if (AKMList->AKMSuiteCount == 0) {
363 if (CipherList->CipherSuiteCount == 0) {
364 *SecurityType = SECURITY_TYPE_NONE;
365 if ((AKMSuiteSupported != NULL) && (CipherSuiteSupported != NULL)) {
366 *AKMSuiteSupported = TRUE;
367 *CipherSuiteSupported = TRUE;
368 }
369 }
370
371 return EFI_SUCCESS;
372 }
373
374 for (AKMIndex = 0; AKMIndex < AKMList->AKMSuiteCount; AKMIndex++) {
375 AKMSuite = AKMList->AKMSuiteList + AKMIndex;
376 if (WifiMgrSupportAKMSuite (
377 SupportedAKMSuites->AKMSuiteCount,
378 (UINT32 *)SupportedAKMSuites->AKMSuiteList,
379 (UINT32 *)AKMSuite
380 ))
381 {
382 if ((AKMSuiteSupported != NULL) && (CipherSuiteSupported != NULL)) {
383 *AKMSuiteSupported = TRUE;
384 }
385
386 for (CipherIndex = 0; CipherIndex < CipherList->CipherSuiteCount; CipherIndex++) {
387 CipherSuite = CipherList->CipherSuiteList + CipherIndex;
388
389 if (SupportedSwCipherSuites != NULL) {
390 if (WifiMgrSupportCipherSuite (
391 SupportedSwCipherSuites->CipherSuiteCount,
392 (UINT32 *)SupportedSwCipherSuites->CipherSuiteList,
393 (UINT32 *)CipherSuite
394 ))
395 {
396 *SecurityType = WifiMgrGetSecurityType ((UINT32 *)AKMSuite, (UINT32 *)CipherSuite);
397
398 if (*SecurityType != SECURITY_TYPE_UNKNOWN) {
399 if ((AKMSuiteSupported != NULL) && (CipherSuiteSupported != NULL)) {
400 *CipherSuiteSupported = TRUE;
401 }
402
403 return EFI_SUCCESS;
404 }
405 }
406 }
407
408 if (SupportedHwCipherSuites != NULL) {
409 if (WifiMgrSupportCipherSuite (
410 SupportedHwCipherSuites->CipherSuiteCount,
411 (UINT32 *)SupportedHwCipherSuites->CipherSuiteList,
412 (UINT32 *)CipherSuite
413 ))
414 {
415 *SecurityType = WifiMgrGetSecurityType ((UINT32 *)AKMSuite, (UINT32 *)CipherSuite);
416
417 if (*SecurityType != SECURITY_TYPE_UNKNOWN) {
418 if ((AKMSuiteSupported != NULL) && (CipherSuiteSupported != NULL)) {
419 *CipherSuiteSupported = TRUE;
420 }
421
422 return EFI_SUCCESS;
423 }
424 }
425 }
426 }
427 }
428 }
429
430 *SecurityType = WifiMgrGetSecurityType (
431 (UINT32 *)AKMList->AKMSuiteList,
432 (UINT32 *)CipherList->CipherSuiteList
433 );
434
435 return EFI_SUCCESS;
436 }
437
438 /**
439 Get the security type for a certain AKMSuite and CipherSuite.
440
441 @param[in] AKMSuite An certain AKMSuite.
442 @param[in] CipherSuite An certain CipherSuite.
443
444 @return a security type if found, or SECURITY_TYPE_UNKNOWN.
445
446 **/
447 UINT8
448 WifiMgrGetSecurityType (
449 IN UINT32 *AKMSuite,
450 IN UINT32 *CipherSuite
451 )
452 {
453 if (CipherSuite == NULL) {
454 if (AKMSuite == NULL) {
455 return SECURITY_TYPE_NONE;
456 } else {
457 return SECURITY_TYPE_UNKNOWN;
458 }
459 } else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_USE_GROUP) {
460 if (AKMSuite == NULL) {
461 return SECURITY_TYPE_NONE;
462 } else {
463 return SECURITY_TYPE_UNKNOWN;
464 }
465 } else if ((*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_WEP40) ||
466 (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_WEP104))
467 {
468 return SECURITY_TYPE_WEP;
469 } else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_CCMP) {
470 if (AKMSuite == NULL) {
471 return SECURITY_TYPE_UNKNOWN;
472 }
473
474 if ((*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA) ||
475 (*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256))
476 {
477 return SECURITY_TYPE_WPA2_ENTERPRISE;
478 } else if ((*AKMSuite == IEEE_80211_AKM_SUITE_PSK) ||
479 (*AKMSuite == IEEE_80211_AKM_SUITE_PSK_SHA256))
480 {
481 return SECURITY_TYPE_WPA2_PERSONAL;
482 } else {
483 return SECURITY_TYPE_UNKNOWN;
484 }
485 } else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_TKIP) {
486 if (AKMSuite == NULL) {
487 return SECURITY_TYPE_UNKNOWN;
488 }
489
490 if ((*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA) ||
491 (*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256))
492 {
493 return SECURITY_TYPE_WPA_ENTERPRISE;
494 } else if ((*AKMSuite == IEEE_80211_AKM_SUITE_PSK) ||
495 (*AKMSuite == IEEE_80211_AKM_SUITE_PSK_SHA256))
496 {
497 return SECURITY_TYPE_WPA_PERSONAL;
498 } else {
499 return SECURITY_TYPE_UNKNOWN;
500 }
501 } else {
502 return SECURITY_TYPE_UNKNOWN;
503 }
504 }
505
506 /**
507 Get supported AKMSuites and CipherSuites from supplicant for a Nic.
508
509 @param[in] Nic The Nic to operate.
510
511 @retval EFI_SUCCESS Get the supported suite list successfully.
512 @retval EFI_INVALID_PARAMETER No Nic found or supplicant is NULL.
513
514 **/
515 EFI_STATUS
516 WifiMgrGetSupportedSuites (
517 IN WIFI_MGR_DEVICE_DATA *Nic
518 )
519 {
520 EFI_STATUS Status;
521 EFI_SUPPLICANT_PROTOCOL *Supplicant;
522 EFI_80211_AKM_SUITE_SELECTOR *SupportedAKMSuites;
523 EFI_80211_CIPHER_SUITE_SELECTOR *SupportedSwCipherSuites;
524 EFI_80211_CIPHER_SUITE_SELECTOR *SupportedHwCipherSuites;
525 UINTN DataSize;
526
527 SupportedAKMSuites = NULL;
528 SupportedSwCipherSuites = NULL;
529 SupportedHwCipherSuites = NULL;
530
531 if ((Nic == NULL) || (Nic->Supplicant == NULL)) {
532 return EFI_INVALID_PARAMETER;
533 }
534
535 Supplicant = Nic->Supplicant;
536
537 DataSize = 0;
538 Status = Supplicant->GetData (Supplicant, EfiSupplicant80211SupportedAKMSuites, NULL, &DataSize);
539 if ((Status == EFI_BUFFER_TOO_SMALL) && (DataSize > 0)) {
540 SupportedAKMSuites = AllocateZeroPool (DataSize);
541 if (SupportedAKMSuites == NULL) {
542 return EFI_OUT_OF_RESOURCES;
543 }
544
545 Status = Supplicant->GetData (
546 Supplicant,
547 EfiSupplicant80211SupportedAKMSuites,
548 (UINT8 *)SupportedAKMSuites,
549 &DataSize
550 );
551 if (!EFI_ERROR (Status)) {
552 Nic->SupportedSuites.SupportedAKMSuites = SupportedAKMSuites;
553 } else {
554 FreePool (SupportedAKMSuites);
555 }
556 } else {
557 SupportedAKMSuites = NULL;
558 }
559
560 DataSize = 0;
561 Status = Supplicant->GetData (Supplicant, EfiSupplicant80211SupportedSoftwareCipherSuites, NULL, &DataSize);
562 if ((Status == EFI_BUFFER_TOO_SMALL) && (DataSize > 0)) {
563 SupportedSwCipherSuites = AllocateZeroPool (DataSize);
564 if (SupportedSwCipherSuites == NULL) {
565 return EFI_OUT_OF_RESOURCES;
566 }
567
568 Status = Supplicant->GetData (
569 Supplicant,
570 EfiSupplicant80211SupportedSoftwareCipherSuites,
571 (UINT8 *)SupportedSwCipherSuites,
572 &DataSize
573 );
574 if (!EFI_ERROR (Status)) {
575 Nic->SupportedSuites.SupportedSwCipherSuites = SupportedSwCipherSuites;
576 } else {
577 FreePool (SupportedSwCipherSuites);
578 }
579 } else {
580 SupportedSwCipherSuites = NULL;
581 }
582
583 DataSize = 0;
584 Status = Supplicant->GetData (Supplicant, EfiSupplicant80211SupportedHardwareCipherSuites, NULL, &DataSize);
585 if ((Status == EFI_BUFFER_TOO_SMALL) && (DataSize > 0)) {
586 SupportedHwCipherSuites = AllocateZeroPool (DataSize);
587 if (SupportedHwCipherSuites == NULL) {
588 return EFI_OUT_OF_RESOURCES;
589 }
590
591 Status = Supplicant->GetData (
592 Supplicant,
593 EfiSupplicant80211SupportedHardwareCipherSuites,
594 (UINT8 *)SupportedHwCipherSuites,
595 &DataSize
596 );
597 if (!EFI_ERROR (Status)) {
598 Nic->SupportedSuites.SupportedHwCipherSuites = SupportedHwCipherSuites;
599 } else {
600 FreePool (SupportedHwCipherSuites);
601 }
602 } else {
603 SupportedHwCipherSuites = NULL;
604 }
605
606 return EFI_SUCCESS;
607 }
608
609 /**
610 Clean secrets from a network profile.
611
612 @param[in] Profile The profile to be cleanned.
613
614 **/
615 VOID
616 WifiMgrCleanProfileSecrets (
617 IN WIFI_MGR_NETWORK_PROFILE *Profile
618 )
619 {
620 ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE);
621 ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE);
622 ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE);
623
624 if (Profile->CACertData != NULL) {
625 ZeroMem (Profile->CACertData, Profile->CACertSize);
626 FreePool (Profile->CACertData);
627 }
628
629 Profile->CACertData = NULL;
630 Profile->CACertSize = 0;
631
632 if (Profile->ClientCertData != NULL) {
633 ZeroMem (Profile->ClientCertData, Profile->ClientCertSize);
634 FreePool (Profile->ClientCertData);
635 }
636
637 Profile->ClientCertData = NULL;
638 Profile->ClientCertSize = 0;
639
640 if (Profile->PrivateKeyData != NULL) {
641 ZeroMem (Profile->PrivateKeyData, Profile->PrivateKeyDataSize);
642 FreePool (Profile->PrivateKeyData);
643 }
644
645 Profile->PrivateKeyData = NULL;
646 Profile->PrivateKeyDataSize = 0;
647 }
648
649 /**
650 Free all network profiles in a profile list.
651
652 @param[in] ProfileList The profile list to be freed.
653
654 **/
655 VOID
656 WifiMgrFreeProfileList (
657 IN LIST_ENTRY *ProfileList
658 )
659 {
660 WIFI_MGR_NETWORK_PROFILE *Profile;
661 LIST_ENTRY *Entry;
662 LIST_ENTRY *NextEntry;
663
664 if (ProfileList == NULL) {
665 return;
666 }
667
668 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, ProfileList) {
669 Profile = NET_LIST_USER_STRUCT_S (
670 Entry,
671 WIFI_MGR_NETWORK_PROFILE,
672 Link,
673 WIFI_MGR_PROFILE_SIGNATURE
674 );
675
676 WifiMgrCleanProfileSecrets (Profile);
677
678 if (Profile->Network.AKMSuite != NULL) {
679 FreePool (Profile->Network.AKMSuite);
680 }
681
682 if (Profile->Network.CipherSuite != NULL) {
683 FreePool (Profile->Network.CipherSuite);
684 }
685
686 FreePool (Profile);
687 }
688 }
689
690 /**
691 Free user configured hidden network list.
692
693 @param[in] HiddenList The hidden network list to be freed.
694
695 **/
696 VOID
697 WifiMgrFreeHiddenList (
698 IN LIST_ENTRY *HiddenList
699 )
700 {
701 WIFI_HIDDEN_NETWORK_DATA *HiddenNetwork;
702 LIST_ENTRY *Entry;
703 LIST_ENTRY *NextEntry;
704
705 if (HiddenList == NULL) {
706 return;
707 }
708
709 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, HiddenList) {
710 HiddenNetwork = NET_LIST_USER_STRUCT_S (
711 Entry,
712 WIFI_HIDDEN_NETWORK_DATA,
713 Link,
714 WIFI_MGR_HIDDEN_NETWORK_SIGNATURE
715 );
716 FreePool (HiddenNetwork);
717 }
718 }
719
720 /**
721 Free the resources of a config token.
722
723 @param[in] ConfigToken The config token to be freed.
724 **/
725 VOID
726 WifiMgrFreeToken (
727 IN WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken
728 )
729 {
730 EFI_80211_GET_NETWORKS_RESULT *Result;
731
732 if (ConfigToken == NULL) {
733 return;
734 }
735
736 switch (ConfigToken->Type) {
737 case TokenTypeGetNetworksToken:
738
739 if (ConfigToken->Token.GetNetworksToken != NULL) {
740 gBS->CloseEvent (ConfigToken->Token.GetNetworksToken->Event);
741 if (ConfigToken->Token.GetNetworksToken->Data != NULL) {
742 FreePool (ConfigToken->Token.GetNetworksToken->Data);
743 }
744
745 Result = ConfigToken->Token.GetNetworksToken->Result;
746 if (Result != NULL) {
747 FreePool (Result);
748 }
749
750 FreePool (ConfigToken->Token.GetNetworksToken);
751 }
752
753 FreePool (ConfigToken);
754 break;
755
756 case TokenTypeConnectNetworkToken:
757
758 if (ConfigToken->Token.ConnectNetworkToken != NULL) {
759 gBS->CloseEvent (ConfigToken->Token.ConnectNetworkToken->Event);
760 if (ConfigToken->Token.ConnectNetworkToken->Data != NULL) {
761 FreePool (ConfigToken->Token.ConnectNetworkToken->Data);
762 }
763
764 FreePool (ConfigToken->Token.ConnectNetworkToken);
765 }
766
767 FreePool (ConfigToken);
768 break;
769
770 case TokenTypeDisconnectNetworkToken:
771
772 if (ConfigToken->Token.DisconnectNetworkToken != NULL) {
773 FreePool (ConfigToken->Token.DisconnectNetworkToken);
774 }
775
776 FreePool (ConfigToken);
777 break;
778
779 default:
780 break;
781 }
782 }