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