]>
Commit | Line | Data |
---|---|---|
90b24889 WF |
1 | /** @file\r |
2 | The Hii functions for WiFi Connection Manager.\r | |
3 | \r | |
e1eef3a8 | 4 | Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>\r |
90b24889 | 5 | \r |
ecf98fbc | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
90b24889 WF |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include "WifiConnectionMgrDxe.h"\r | |
11 | \r | |
12 | CHAR16 mVendorStorageName[] = L"WIFI_MANAGER_IFR_NVDATA";\r | |
13 | \r | |
14 | HII_VENDOR_DEVICE_PATH mWifiMgrDxeHiiVendorDevicePath = {\r | |
15 | {\r | |
16 | {\r | |
17 | HARDWARE_DEVICE_PATH,\r | |
18 | HW_VENDOR_DP,\r | |
19 | {\r | |
d1050b9d MK |
20 | (UINT8)(sizeof (VENDOR_DEVICE_PATH)),\r |
21 | (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r | |
90b24889 WF |
22 | }\r |
23 | },\r | |
24 | WIFI_CONNECTION_MANAGER_CONFIG_GUID\r | |
25 | },\r | |
26 | {\r | |
27 | END_DEVICE_PATH_TYPE,\r | |
28 | END_ENTIRE_DEVICE_PATH_SUBTYPE,\r | |
29 | {\r | |
d1050b9d MK |
30 | (UINT8)(END_DEVICE_PATH_LENGTH),\r |
31 | (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)\r | |
90b24889 WF |
32 | }\r |
33 | }\r | |
34 | };\r | |
35 | \r | |
36 | //\r | |
37 | // HII Config Access Protocol instance\r | |
38 | //\r | |
39 | GLOBAL_REMOVE_IF_UNREFERENCED\r | |
d1050b9d | 40 | EFI_HII_CONFIG_ACCESS_PROTOCOL gWifiMgrDxeHiiConfigAccess = {\r |
90b24889 WF |
41 | WifiMgrDxeHiiConfigAccessExtractConfig,\r |
42 | WifiMgrDxeHiiConfigAccessRouteConfig,\r | |
43 | WifiMgrDxeHiiConfigAccessCallback\r | |
44 | };\r | |
45 | \r | |
d1050b9d | 46 | CHAR16 *mSecurityType[] = {\r |
90b24889 WF |
47 | L"OPEN ",\r |
48 | L"WPA-Enterprise ",\r | |
49 | L"WPA2-Enterprise",\r | |
50 | L"WPA-Personal ",\r | |
51 | L"WPA2-Personal ",\r | |
52 | L"WEP ",\r | |
e1eef3a8 HL |
53 | L"WPA3-Personal ",\r |
54 | L"WPA3-Enterprise",\r | |
90b24889 WF |
55 | L"UnKnown "\r |
56 | };\r | |
57 | \r | |
d1050b9d | 58 | CHAR16 *mSignalStrengthBar[] = {\r |
90b24889 WF |
59 | L"[-----]",\r |
60 | L"[*----]",\r | |
61 | L"[**---]",\r | |
62 | L"[***--]",\r | |
63 | L"[****-]",\r | |
64 | L"[*****]"\r | |
65 | };\r | |
66 | \r | |
67 | #define RSSI_TO_SIGNAL_STRENGTH_BAR(Rssi) mSignalStrengthBar[((Rssi + 19)/20)]\r | |
68 | \r | |
69 | #define NET_LIST_FOR_EACH_FROM_NODE(Entry, Node, ListHead) \\r | |
70 | for(Entry = Node->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r | |
71 | \r | |
d1050b9d | 72 | extern EFI_GUID gWifiConfigFormSetGuid;\r |
90b24889 WF |
73 | \r |
74 | /**\r | |
75 | Create Hii Extend Label OpCode as the start opcode and end opcode.\r | |
76 | The caller is responsible for freeing the OpCode with HiiFreeOpCodeHandle().\r | |
77 | \r | |
78 | @param[in] StartLabelNumber The number of start label.\r | |
79 | @param[out] StartOpCodeHandle Points to the start opcode handle.\r | |
80 | @param[out] EndOpCodeHandle Points to the end opcode handle.\r | |
81 | \r | |
82 | @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this\r | |
83 | operation.\r | |
84 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
85 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
86 | @retval Other Errors Returned errors when updating the HII form.\r | |
87 | \r | |
88 | **/\r | |
89 | EFI_STATUS\r | |
90 | WifiMgrCreateOpCode (\r | |
d1050b9d MK |
91 | IN UINT16 StartLabelNumber,\r |
92 | OUT VOID **StartOpCodeHandle,\r | |
93 | OUT VOID **EndOpCodeHandle\r | |
90b24889 WF |
94 | )\r |
95 | {\r | |
d1050b9d MK |
96 | EFI_STATUS Status;\r |
97 | EFI_IFR_GUID_LABEL *InternalStartLabel;\r | |
98 | EFI_IFR_GUID_LABEL *InternalEndLabel;\r | |
90b24889 | 99 | \r |
d1050b9d | 100 | if ((StartOpCodeHandle == NULL) || (EndOpCodeHandle == NULL)) {\r |
90b24889 WF |
101 | return EFI_INVALID_PARAMETER;\r |
102 | }\r | |
103 | \r | |
104 | Status = EFI_OUT_OF_RESOURCES;\r | |
105 | *StartOpCodeHandle = NULL;\r | |
106 | *EndOpCodeHandle = NULL;\r | |
107 | \r | |
108 | //\r | |
109 | // Initialize the container for dynamic opcodes.\r | |
110 | //\r | |
111 | *StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r | |
112 | if (*StartOpCodeHandle == NULL) {\r | |
113 | goto Exit;\r | |
114 | }\r | |
d1050b9d | 115 | \r |
90b24889 WF |
116 | *EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r |
117 | if (*EndOpCodeHandle == NULL) {\r | |
118 | goto Exit;\r | |
119 | }\r | |
120 | \r | |
121 | //\r | |
122 | // Create Hii Extend Label OpCode as the start opcode.\r | |
123 | //\r | |
d1050b9d MK |
124 | InternalStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (\r |
125 | *StartOpCodeHandle,\r | |
126 | &gEfiIfrTianoGuid,\r | |
127 | NULL,\r | |
128 | sizeof (EFI_IFR_GUID_LABEL)\r | |
129 | );\r | |
90b24889 WF |
130 | if (InternalStartLabel == NULL) {\r |
131 | goto Exit;\r | |
132 | }\r | |
d1050b9d | 133 | \r |
90b24889 WF |
134 | InternalStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r |
135 | InternalStartLabel->Number = StartLabelNumber;\r | |
136 | \r | |
137 | //\r | |
138 | // Create Hii Extend Label OpCode as the end opcode.\r | |
139 | //\r | |
d1050b9d MK |
140 | InternalEndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (\r |
141 | *EndOpCodeHandle,\r | |
142 | &gEfiIfrTianoGuid,\r | |
143 | NULL,\r | |
144 | sizeof (EFI_IFR_GUID_LABEL)\r | |
145 | );\r | |
90b24889 WF |
146 | if (InternalEndLabel == NULL) {\r |
147 | goto Exit;\r | |
148 | }\r | |
d1050b9d | 149 | \r |
90b24889 WF |
150 | InternalEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r |
151 | InternalEndLabel->Number = LABEL_END;\r | |
152 | \r | |
153 | return EFI_SUCCESS;\r | |
154 | \r | |
155 | Exit:\r | |
156 | \r | |
157 | if (*StartOpCodeHandle != NULL) {\r | |
158 | HiiFreeOpCodeHandle (*StartOpCodeHandle);\r | |
159 | }\r | |
d1050b9d | 160 | \r |
90b24889 WF |
161 | if (*EndOpCodeHandle != NULL) {\r |
162 | HiiFreeOpCodeHandle (*EndOpCodeHandle);\r | |
163 | }\r | |
d1050b9d | 164 | \r |
90b24889 WF |
165 | return Status;\r |
166 | }\r | |
167 | \r | |
168 | /**\r | |
169 | Display the Nic list contains all available Nics.\r | |
170 | \r | |
171 | @param[in] Private The pointer to the global private data structure.\r | |
172 | \r | |
173 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
174 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
175 | \r | |
176 | **/\r | |
177 | EFI_STATUS\r | |
178 | WifiMgrShowNicList (\r | |
d1050b9d MK |
179 | IN WIFI_MGR_PRIVATE_DATA *Private\r |
180 | )\r | |
90b24889 | 181 | {\r |
d1050b9d MK |
182 | EFI_STATUS Status;\r |
183 | CHAR16 MacString[WIFI_MGR_MAX_MAC_STRING_LEN];\r | |
184 | CHAR16 PortString[WIFI_STR_MAX_SIZE];\r | |
185 | EFI_STRING_ID PortTitleToken;\r | |
186 | EFI_STRING_ID PortTitleHelpToken;\r | |
187 | WIFI_MGR_DEVICE_DATA *Nic;\r | |
188 | LIST_ENTRY *Entry;\r | |
189 | VOID *StartOpCodeHandle;\r | |
190 | VOID *EndOpCodeHandle;\r | |
90b24889 WF |
191 | \r |
192 | if (Private == NULL) {\r | |
193 | return EFI_INVALID_PARAMETER;\r | |
194 | }\r | |
195 | \r | |
196 | Status = WifiMgrCreateOpCode (\r | |
197 | LABEL_MAC_ENTRY,\r | |
198 | &StartOpCodeHandle,\r | |
199 | &EndOpCodeHandle\r | |
200 | );\r | |
201 | if (EFI_ERROR (Status)) {\r | |
202 | return Status;\r | |
203 | }\r | |
204 | \r | |
205 | NET_LIST_FOR_EACH (Entry, &Private->NicList) {\r | |
206 | Nic = NET_LIST_USER_STRUCT_S (Entry, WIFI_MGR_DEVICE_DATA, Link, WIFI_MGR_DEVICE_DATA_SIGNATURE);\r | |
207 | WifiMgrMacAddrToStr (&Nic->MacAddress, sizeof (MacString), MacString);\r | |
208 | UnicodeSPrint (PortString, sizeof (PortString), L"MAC %s", MacString);\r | |
209 | PortTitleToken = HiiSetString (\r | |
210 | Private->RegisteredHandle,\r | |
211 | 0,\r | |
212 | PortString,\r | |
213 | NULL\r | |
214 | );\r | |
215 | if (PortTitleToken == 0) {\r | |
216 | Status = EFI_INVALID_PARAMETER;\r | |
217 | goto Exit;\r | |
218 | }\r | |
219 | \r | |
220 | UnicodeSPrint (PortString, sizeof (PortString), L"MAC Address");\r | |
221 | PortTitleHelpToken = HiiSetString (\r | |
222 | Private->RegisteredHandle,\r | |
223 | 0,\r | |
224 | PortString,\r | |
225 | NULL\r | |
226 | );\r | |
227 | if (PortTitleHelpToken == 0) {\r | |
228 | Status = EFI_INVALID_PARAMETER;\r | |
229 | goto Exit;\r | |
230 | }\r | |
231 | \r | |
232 | HiiCreateGotoOpCode (\r | |
233 | StartOpCodeHandle,\r | |
234 | FORMID_WIFI_MAINPAGE,\r | |
235 | PortTitleToken,\r | |
236 | PortTitleHelpToken,\r | |
237 | EFI_IFR_FLAG_CALLBACK,\r | |
d1050b9d | 238 | (UINT16)(KEY_MAC_ENTRY_BASE + Nic->NicIndex)\r |
90b24889 WF |
239 | );\r |
240 | }\r | |
241 | \r | |
242 | Status = HiiUpdateForm (\r | |
243 | Private->RegisteredHandle, // HII handle\r | |
244 | &gWifiConfigFormSetGuid, // Formset GUID\r | |
245 | FORMID_MAC_SELECTION, // Form ID\r | |
246 | StartOpCodeHandle, // Label for where to insert opcodes\r | |
247 | EndOpCodeHandle // Replace data\r | |
248 | );\r | |
249 | \r | |
250 | Exit:\r | |
251 | \r | |
252 | HiiFreeOpCodeHandle (StartOpCodeHandle);\r | |
253 | HiiFreeOpCodeHandle (EndOpCodeHandle);\r | |
254 | return Status;\r | |
255 | }\r | |
256 | \r | |
257 | /**\r | |
258 | Retreive the unicode string of the AKM Suite list of a profile.\r | |
259 | The caller is responsible for freeing the string with FreePool().\r | |
260 | \r | |
261 | @param[in] Profile The network profile contains a AKM suite list.\r | |
262 | \r | |
263 | @return the unicode string of AKM suite list or "None".\r | |
264 | \r | |
265 | **/\r | |
d1050b9d | 266 | CHAR16 *\r |
90b24889 | 267 | WifiMgrGetStrAKMList (\r |
d1050b9d MK |
268 | IN WIFI_MGR_NETWORK_PROFILE *Profile\r |
269 | )\r | |
90b24889 | 270 | {\r |
d1050b9d MK |
271 | UINT8 Index;\r |
272 | UINT16 AKMSuiteCount;\r | |
273 | CHAR16 *AKMListDisplay;\r | |
e1eef3a8 | 274 | UINTN Length;\r |
90b24889 WF |
275 | \r |
276 | AKMListDisplay = NULL;\r | |
d1050b9d | 277 | if ((Profile == NULL) || (Profile->Network.AKMSuite == NULL)) {\r |
90b24889 WF |
278 | goto Exit;\r |
279 | }\r | |
280 | \r | |
281 | AKMSuiteCount = Profile->Network.AKMSuite->AKMSuiteCount;\r | |
282 | if (AKMSuiteCount != 0) {\r | |
90b24889 | 283 | //\r |
e1eef3a8 | 284 | // Current AKM Suite is between 1-18\r |
90b24889 | 285 | //\r |
e1eef3a8 HL |
286 | AKMListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * (AKMSuiteCount * 3 + 1));\r |
287 | Length = 0;\r | |
90b24889 | 288 | if (AKMListDisplay != NULL) {\r |
d1050b9d | 289 | for (Index = 0; Index < AKMSuiteCount; Index++) {\r |
b24306f1 | 290 | //\r |
e1eef3a8 | 291 | // The size of buffer should be 4 CHAR16 for Null-terminated Unicode string.\r |
b24306f1 | 292 | //\r |
90b24889 | 293 | UnicodeSPrint (\r |
e1eef3a8 HL |
294 | AKMListDisplay + Length,\r |
295 | sizeof (CHAR16) * 4,\r | |
90b24889 WF |
296 | L"%d ",\r |
297 | Profile->Network.AKMSuite->AKMSuiteList[Index].SuiteType\r | |
298 | );\r | |
e1eef3a8 | 299 | Length = StrLen (AKMListDisplay + Length) + Length;\r |
90b24889 | 300 | if (Index == AKMSuiteCount - 1) {\r |
e1eef3a8 | 301 | *(AKMListDisplay + (Length - 1)) = L'\0';\r |
90b24889 WF |
302 | }\r |
303 | }\r | |
304 | }\r | |
305 | }\r | |
306 | \r | |
307 | Exit:\r | |
308 | \r | |
309 | if (AKMListDisplay == NULL) {\r | |
310 | AKMListDisplay = AllocateCopyPool (sizeof (L"None"), L"None");\r | |
311 | }\r | |
d1050b9d | 312 | \r |
90b24889 WF |
313 | return AKMListDisplay;\r |
314 | }\r | |
315 | \r | |
316 | /**\r | |
317 | Retreive the unicode string of the Cipher Suite list of a profile.\r | |
318 | The caller is responsible for freeing the string with FreePool().\r | |
319 | \r | |
320 | @param[in] Profile The network profile contains a Cipher suite list.\r | |
321 | \r | |
322 | @return the unicode string of Cipher suite list or "None".\r | |
323 | \r | |
324 | **/\r | |
d1050b9d | 325 | CHAR16 *\r |
90b24889 | 326 | WifiMgrGetStrCipherList (\r |
d1050b9d MK |
327 | IN WIFI_MGR_NETWORK_PROFILE *Profile\r |
328 | )\r | |
90b24889 | 329 | {\r |
d1050b9d MK |
330 | UINT8 Index;\r |
331 | UINT16 CipherSuiteCount;\r | |
332 | CHAR16 *CipherListDisplay;\r | |
90b24889 WF |
333 | \r |
334 | CipherListDisplay = NULL;\r | |
d1050b9d | 335 | if ((Profile == NULL) || (Profile->Network.CipherSuite == NULL)) {\r |
90b24889 WF |
336 | goto Exit;\r |
337 | }\r | |
338 | \r | |
d1050b9d | 339 | CipherSuiteCount = Profile->Network.CipherSuite->CipherSuiteCount;\r |
90b24889 | 340 | if (CipherSuiteCount != 0) {\r |
90b24889 WF |
341 | //\r |
342 | // Current Cipher Suite is between 1-9\r | |
343 | //\r | |
b24306f1 | 344 | CipherListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * (CipherSuiteCount * 2 + 1));\r |
90b24889 | 345 | if (CipherListDisplay != NULL) {\r |
d1050b9d | 346 | for (Index = 0; Index < CipherSuiteCount; Index++) {\r |
b24306f1 HL |
347 | //\r |
348 | // The size of buffer should be 3 CHAR16 for Null-terminated Unicode string.\r | |
349 | // The first char is the Cipher Suite number, the second char is ' ', the third char is '\0'.\r | |
350 | //\r | |
90b24889 WF |
351 | UnicodeSPrint (\r |
352 | CipherListDisplay + (Index * 2),\r | |
b24306f1 | 353 | sizeof (CHAR16) * 3,\r |
90b24889 WF |
354 | L"%d ",\r |
355 | Profile->Network.CipherSuite->CipherSuiteList[Index].SuiteType\r | |
356 | );\r | |
357 | if (Index == CipherSuiteCount - 1) {\r | |
358 | *(CipherListDisplay + (Index * 2 + 1)) = L'\0';\r | |
359 | }\r | |
360 | }\r | |
361 | }\r | |
362 | }\r | |
363 | \r | |
364 | Exit:\r | |
365 | \r | |
366 | if (CipherListDisplay == NULL) {\r | |
367 | CipherListDisplay = AllocateCopyPool (sizeof (L"None"), L"None");\r | |
368 | }\r | |
d1050b9d | 369 | \r |
90b24889 WF |
370 | return CipherListDisplay;\r |
371 | }\r | |
372 | \r | |
373 | /**\r | |
374 | Refresh the network list display of the current Nic.\r | |
375 | \r | |
376 | @param[in] Private The pointer to the global private data structure.\r | |
377 | @param[out] IfrNvData The IFR NV data.\r | |
378 | \r | |
379 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
380 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
381 | @retval Other Errors Returned errors when creating Opcodes or updating the\r | |
382 | Hii form.\r | |
383 | \r | |
384 | **/\r | |
385 | EFI_STATUS\r | |
386 | WifiMgrRefreshNetworkList (\r | |
d1050b9d MK |
387 | IN WIFI_MGR_PRIVATE_DATA *Private,\r |
388 | OUT WIFI_MANAGER_IFR_NVDATA *IfrNvData\r | |
90b24889 WF |
389 | )\r |
390 | {\r | |
d1050b9d MK |
391 | EFI_STATUS Status;\r |
392 | EFI_TPL OldTpl;\r | |
393 | UINT32 AvailableCount;\r | |
394 | EFI_STRING_ID PortPromptToken;\r | |
395 | EFI_STRING_ID PortTextToken;\r | |
396 | EFI_STRING_ID PortHelpToken;\r | |
397 | WIFI_MGR_NETWORK_PROFILE *Profile;\r | |
398 | LIST_ENTRY *Entry;\r | |
399 | VOID *StartOpCodeHandle;\r | |
400 | VOID *EndOpCodeHandle;\r | |
401 | CHAR16 *AKMListDisplay;\r | |
402 | CHAR16 *CipherListDisplay;\r | |
403 | CHAR16 PortString[WIFI_STR_MAX_SIZE];\r | |
404 | UINTN PortStringSize;\r | |
405 | WIFI_MGR_NETWORK_PROFILE *ConnectedProfile;\r | |
90b24889 WF |
406 | \r |
407 | if (Private->CurrentNic == NULL) {\r | |
408 | return EFI_SUCCESS;\r | |
409 | }\r | |
410 | \r | |
411 | Status = WifiMgrCreateOpCode (\r | |
412 | LABEL_NETWORK_LIST_ENTRY,\r | |
413 | &StartOpCodeHandle,\r | |
414 | &EndOpCodeHandle\r | |
415 | );\r | |
416 | if (EFI_ERROR (Status)) {\r | |
417 | return Status;\r | |
418 | }\r | |
419 | \r | |
d1050b9d | 420 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r |
90b24889 WF |
421 | AvailableCount = 0;\r |
422 | PortStringSize = sizeof (PortString);\r | |
423 | ConnectedProfile = NULL;\r | |
424 | AKMListDisplay = NULL;\r | |
425 | CipherListDisplay = NULL;\r | |
426 | \r | |
427 | if (Private->CurrentNic->ConnectState == WifiMgrConnectedToAp) {\r | |
90b24889 WF |
428 | //\r |
429 | // Display the current connected network.\r | |
430 | // Find the current operate network under connected status.\r | |
431 | //\r | |
d1050b9d MK |
432 | if ((Private->CurrentNic->CurrentOperateNetwork != NULL) &&\r |
433 | Private->CurrentNic->CurrentOperateNetwork->IsAvailable)\r | |
434 | {\r | |
90b24889 | 435 | Profile = Private->CurrentNic->CurrentOperateNetwork;\r |
d1050b9d | 436 | AvailableCount++;\r |
90b24889 WF |
437 | \r |
438 | AKMListDisplay = WifiMgrGetStrAKMList (Profile);\r | |
439 | if (AKMListDisplay == NULL) {\r | |
440 | Status = EFI_OUT_OF_RESOURCES;\r | |
441 | goto Exit;\r | |
442 | }\r | |
d1050b9d MK |
443 | \r |
444 | CipherListDisplay = WifiMgrGetStrCipherList (Profile);\r | |
90b24889 WF |
445 | if (CipherListDisplay == NULL) {\r |
446 | Status = EFI_OUT_OF_RESOURCES;\r | |
447 | goto Exit;\r | |
448 | }\r | |
449 | \r | |
450 | UnicodeSPrint (PortString, PortStringSize, L"%s (Connected)", Profile->SSId);\r | |
451 | PortPromptToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL);\r | |
452 | \r | |
453 | if (Profile->SecurityType == SECURITY_TYPE_NONE) {\r | |
454 | PortHelpToken = 0;\r | |
455 | } else {\r | |
456 | UnicodeSPrint (PortString, PortStringSize, L"AKMSuite: %s CipherSuite: %s", AKMListDisplay, CipherListDisplay);\r | |
457 | PortHelpToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL);\r | |
458 | }\r | |
d1050b9d | 459 | \r |
90b24889 WF |
460 | FreePool (AKMListDisplay);\r |
461 | FreePool (CipherListDisplay);\r | |
a6c63ee6 WF |
462 | AKMListDisplay = NULL;\r |
463 | CipherListDisplay = NULL;\r | |
90b24889 WF |
464 | \r |
465 | HiiCreateGotoOpCode (\r | |
466 | StartOpCodeHandle,\r | |
467 | FORMID_CONNECT_NETWORK,\r | |
468 | PortPromptToken,\r | |
469 | PortHelpToken,\r | |
470 | EFI_IFR_FLAG_CALLBACK,\r | |
d1050b9d | 471 | (UINT16)(KEY_AVAILABLE_NETWORK_ENTRY_BASE + Profile->ProfileIndex)\r |
90b24889 WF |
472 | );\r |
473 | \r | |
474 | UnicodeSPrint (\r | |
475 | PortString,\r | |
476 | PortStringSize,\r | |
477 | L"%s %s %s",\r | |
478 | (Profile->SecurityType != SECURITY_TYPE_NONE ? L"Secured" : L"Open "),\r | |
479 | mSecurityType[Profile->SecurityType],\r | |
d1050b9d | 480 | RSSI_TO_SIGNAL_STRENGTH_BAR (Profile->NetworkQuality)\r |
90b24889 WF |
481 | );\r |
482 | PortTextToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL);\r | |
483 | \r | |
484 | HiiCreateTextOpCode (\r | |
485 | StartOpCodeHandle,\r | |
486 | PortTextToken,\r | |
487 | 0,\r | |
488 | 0\r | |
d1050b9d | 489 | );\r |
90b24889 WF |
490 | \r |
491 | ConnectedProfile = Profile;\r | |
492 | } else {\r | |
493 | Private->CurrentNic->HasDisconnectPendingNetwork = TRUE;\r | |
494 | }\r | |
495 | }\r | |
496 | \r | |
497 | //\r | |
498 | // Display all supported available networks.\r | |
499 | //\r | |
500 | NET_LIST_FOR_EACH (Entry, &Private->CurrentNic->ProfileList) {\r | |
90b24889 WF |
501 | Profile = NET_LIST_USER_STRUCT_S (\r |
502 | Entry,\r | |
503 | WIFI_MGR_NETWORK_PROFILE,\r | |
504 | Link,\r | |
505 | WIFI_MGR_PROFILE_SIGNATURE\r | |
506 | );\r | |
507 | if (ConnectedProfile == Profile) {\r | |
508 | continue;\r | |
509 | }\r | |
90b24889 | 510 | \r |
d1050b9d MK |
511 | if (Profile->IsAvailable && Profile->CipherSuiteSupported) {\r |
512 | AvailableCount++;\r | |
90b24889 WF |
513 | \r |
514 | AKMListDisplay = WifiMgrGetStrAKMList (Profile);\r | |
515 | if (AKMListDisplay == NULL) {\r | |
516 | Status = EFI_OUT_OF_RESOURCES;\r | |
517 | goto Exit;\r | |
518 | }\r | |
d1050b9d MK |
519 | \r |
520 | CipherListDisplay = WifiMgrGetStrCipherList (Profile);\r | |
90b24889 WF |
521 | if (CipherListDisplay == NULL) {\r |
522 | Status = EFI_OUT_OF_RESOURCES;\r | |
523 | goto Exit;\r | |
524 | }\r | |
525 | \r | |
526 | PortPromptToken = HiiSetString (Private->RegisteredHandle, 0, Profile->SSId, NULL);\r | |
527 | if (PortPromptToken == 0) {\r | |
528 | Status = EFI_OUT_OF_RESOURCES;\r | |
529 | goto Exit;\r | |
530 | }\r | |
531 | \r | |
532 | if (Profile->SecurityType == SECURITY_TYPE_NONE) {\r | |
533 | PortHelpToken = 0;\r | |
534 | } else {\r | |
535 | UnicodeSPrint (\r | |
536 | PortString,\r | |
537 | PortStringSize,\r | |
538 | L"AKMSuite: %s CipherSuite: %s",\r | |
d1050b9d MK |
539 | AKMListDisplay,\r |
540 | CipherListDisplay\r | |
90b24889 WF |
541 | );\r |
542 | PortHelpToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL);\r | |
543 | if (PortHelpToken == 0) {\r | |
544 | Status = EFI_OUT_OF_RESOURCES;\r | |
545 | goto Exit;\r | |
546 | }\r | |
547 | }\r | |
d1050b9d | 548 | \r |
90b24889 WF |
549 | FreePool (AKMListDisplay);\r |
550 | FreePool (CipherListDisplay);\r | |
a6c63ee6 WF |
551 | AKMListDisplay = NULL;\r |
552 | CipherListDisplay = NULL;\r | |
90b24889 WF |
553 | \r |
554 | HiiCreateGotoOpCode (\r | |
555 | StartOpCodeHandle,\r | |
556 | FORMID_CONNECT_NETWORK,\r | |
557 | PortPromptToken,\r | |
558 | PortHelpToken,\r | |
559 | EFI_IFR_FLAG_CALLBACK,\r | |
d1050b9d | 560 | (UINT16)(KEY_AVAILABLE_NETWORK_ENTRY_BASE + Profile->ProfileIndex)\r |
90b24889 WF |
561 | );\r |
562 | \r | |
563 | UnicodeSPrint (\r | |
564 | PortString,\r | |
565 | PortStringSize,\r | |
566 | L"%s %s %s",\r | |
567 | (Profile->SecurityType != SECURITY_TYPE_NONE ? L"Secured" : L"Open "),\r | |
568 | mSecurityType[Profile->SecurityType],\r | |
d1050b9d | 569 | RSSI_TO_SIGNAL_STRENGTH_BAR (Profile->NetworkQuality)\r |
90b24889 WF |
570 | );\r |
571 | PortTextToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL);\r | |
572 | if (PortTextToken == 0) {\r | |
573 | Status = EFI_OUT_OF_RESOURCES;\r | |
574 | goto Exit;\r | |
575 | }\r | |
d1050b9d | 576 | \r |
90b24889 WF |
577 | HiiCreateTextOpCode (\r |
578 | StartOpCodeHandle,\r | |
579 | PortTextToken,\r | |
580 | 0,\r | |
581 | 0\r | |
582 | );\r | |
583 | }\r | |
584 | }\r | |
585 | \r | |
586 | //\r | |
587 | // Display all Unsupported available networks.\r | |
588 | //\r | |
589 | NET_LIST_FOR_EACH (Entry, &Private->CurrentNic->ProfileList) {\r | |
90b24889 WF |
590 | Profile = NET_LIST_USER_STRUCT_S (\r |
591 | Entry,\r | |
592 | WIFI_MGR_NETWORK_PROFILE,\r | |
593 | Link,\r | |
594 | WIFI_MGR_PROFILE_SIGNATURE\r | |
595 | );\r | |
596 | if (ConnectedProfile == Profile) {\r | |
597 | continue;\r | |
598 | }\r | |
90b24889 | 599 | \r |
d1050b9d MK |
600 | if (Profile->IsAvailable && !Profile->CipherSuiteSupported) {\r |
601 | AvailableCount++;\r | |
90b24889 WF |
602 | \r |
603 | AKMListDisplay = WifiMgrGetStrAKMList (Profile);\r | |
604 | if (AKMListDisplay == NULL) {\r | |
605 | Status = EFI_OUT_OF_RESOURCES;\r | |
606 | goto Exit;\r | |
607 | }\r | |
d1050b9d MK |
608 | \r |
609 | CipherListDisplay = WifiMgrGetStrCipherList (Profile);\r | |
90b24889 WF |
610 | if (CipherListDisplay == NULL) {\r |
611 | Status = EFI_OUT_OF_RESOURCES;\r | |
612 | goto Exit;\r | |
613 | }\r | |
614 | \r | |
615 | PortPromptToken = HiiSetString (Private->RegisteredHandle, 0, Profile->SSId, NULL);\r | |
616 | \r | |
617 | if (Profile->AKMSuiteSupported) {\r | |
618 | UnicodeSPrint (\r | |
619 | PortString,\r | |
620 | PortStringSize,\r | |
621 | L"AKMSuite: %s CipherSuite(UnSupported): %s",\r | |
d1050b9d MK |
622 | AKMListDisplay,\r |
623 | CipherListDisplay\r | |
90b24889 WF |
624 | );\r |
625 | } else {\r | |
626 | UnicodeSPrint (\r | |
627 | PortString,\r | |
628 | PortStringSize,\r | |
629 | L"AKMSuite(UnSupported): %s CipherSuite(UnSupported): %s",\r | |
d1050b9d MK |
630 | AKMListDisplay,\r |
631 | CipherListDisplay\r | |
90b24889 WF |
632 | );\r |
633 | }\r | |
d1050b9d | 634 | \r |
90b24889 WF |
635 | FreePool (AKMListDisplay);\r |
636 | FreePool (CipherListDisplay);\r | |
a6c63ee6 WF |
637 | AKMListDisplay = NULL;\r |
638 | CipherListDisplay = NULL;\r | |
90b24889 WF |
639 | \r |
640 | PortHelpToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL);\r | |
641 | \r | |
642 | HiiCreateGotoOpCode (\r | |
643 | StartOpCodeHandle,\r | |
644 | FORMID_CONNECT_NETWORK,\r | |
645 | PortPromptToken,\r | |
646 | PortHelpToken,\r | |
647 | EFI_IFR_FLAG_CALLBACK,\r | |
d1050b9d | 648 | (UINT16)(KEY_AVAILABLE_NETWORK_ENTRY_BASE + Profile->ProfileIndex)\r |
90b24889 WF |
649 | );\r |
650 | \r | |
651 | UnicodeSPrint (\r | |
652 | PortString,\r | |
653 | PortStringSize,\r | |
654 | L"%s %s %s",\r | |
655 | L"UnSupported",\r | |
656 | mSecurityType[Profile->SecurityType],\r | |
d1050b9d | 657 | RSSI_TO_SIGNAL_STRENGTH_BAR (Profile->NetworkQuality)\r |
90b24889 WF |
658 | );\r |
659 | PortTextToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL);\r | |
660 | \r | |
661 | HiiCreateTextOpCode (\r | |
662 | StartOpCodeHandle,\r | |
663 | PortTextToken,\r | |
664 | 0,\r | |
665 | 0\r | |
666 | );\r | |
667 | }\r | |
668 | }\r | |
669 | \r | |
670 | Status = HiiUpdateForm (\r | |
671 | Private->RegisteredHandle, // HII handle\r | |
672 | &gWifiConfigFormSetGuid, // Formset GUID\r | |
673 | FORMID_NETWORK_LIST, // Form ID\r | |
674 | StartOpCodeHandle, // Label for where to insert opcodes\r | |
675 | EndOpCodeHandle // Replace data\r | |
676 | );\r | |
677 | \r | |
678 | Exit:\r | |
679 | \r | |
680 | gBS->RestoreTPL (OldTpl);\r | |
681 | \r | |
682 | if (AKMListDisplay != NULL) {\r | |
683 | FreePool (AKMListDisplay);\r | |
684 | }\r | |
d1050b9d | 685 | \r |
90b24889 WF |
686 | if (CipherListDisplay != NULL) {\r |
687 | FreePool (CipherListDisplay);\r | |
688 | }\r | |
689 | \r | |
690 | HiiFreeOpCodeHandle (StartOpCodeHandle);\r | |
691 | HiiFreeOpCodeHandle (EndOpCodeHandle);\r | |
692 | \r | |
693 | DEBUG ((DEBUG_INFO, "[WiFi Connection Manager] Network List is Refreshed!\n"));\r | |
694 | return Status;\r | |
695 | }\r | |
696 | \r | |
697 | /**\r | |
698 | Refresh the hidden network list configured by user.\r | |
699 | \r | |
700 | @param[in] Private The pointer to the global private data structure.\r | |
701 | \r | |
702 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
703 | @retval Other Errors Returned errors when creating Opcodes or updating the\r | |
704 | Hii form.\r | |
705 | **/\r | |
706 | EFI_STATUS\r | |
707 | WifiMgrRefreshHiddenList (\r | |
d1050b9d | 708 | IN WIFI_MGR_PRIVATE_DATA *Private\r |
90b24889 WF |
709 | )\r |
710 | {\r | |
d1050b9d MK |
711 | EFI_STATUS Status;\r |
712 | EFI_TPL OldTpl;\r | |
713 | UINTN Index;\r | |
714 | EFI_STRING_ID StringId;\r | |
715 | VOID *StartOpCodeHandle;\r | |
716 | VOID *EndOpCodeHandle;\r | |
717 | WIFI_HIDDEN_NETWORK_DATA *HiddenNetwork;\r | |
718 | LIST_ENTRY *Entry;\r | |
90b24889 WF |
719 | \r |
720 | if (Private == NULL) {\r | |
721 | return EFI_SUCCESS;\r | |
722 | }\r | |
723 | \r | |
724 | Status = WifiMgrCreateOpCode (\r | |
725 | LABEL_HIDDEN_NETWORK_ENTRY,\r | |
726 | &StartOpCodeHandle,\r | |
727 | &EndOpCodeHandle\r | |
728 | );\r | |
729 | if (EFI_ERROR (Status)) {\r | |
730 | return Status;\r | |
731 | }\r | |
732 | \r | |
733 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
734 | Index = 0;\r | |
735 | \r | |
736 | NET_LIST_FOR_EACH (Entry, &Private->HiddenNetworkList) {\r | |
90b24889 WF |
737 | HiddenNetwork = NET_LIST_USER_STRUCT_S (\r |
738 | Entry,\r | |
739 | WIFI_HIDDEN_NETWORK_DATA,\r | |
740 | Link,\r | |
741 | WIFI_MGR_HIDDEN_NETWORK_SIGNATURE\r | |
742 | );\r | |
743 | StringId = HiiSetString (Private->RegisteredHandle, 0, HiddenNetwork->SSId, NULL);\r | |
744 | \r | |
745 | HiiCreateCheckBoxOpCode (\r | |
746 | StartOpCodeHandle,\r | |
d1050b9d | 747 | (EFI_QUESTION_ID)(KEY_HIDDEN_NETWORK_ENTRY_BASE + Index),\r |
90b24889 | 748 | MANAGER_VARSTORE_ID,\r |
d1050b9d | 749 | (UINT16)(HIDDEN_NETWORK_LIST_VAR_OFFSET + Index),\r |
90b24889 WF |
750 | StringId,\r |
751 | 0,\r | |
752 | 0,\r | |
753 | 0,\r | |
754 | NULL\r | |
755 | );\r | |
d1050b9d | 756 | Index++;\r |
90b24889 WF |
757 | }\r |
758 | \r | |
759 | Status = HiiUpdateForm (\r | |
760 | Private->RegisteredHandle, // HII handle\r | |
761 | &gWifiConfigFormSetGuid, // Formset GUID\r | |
762 | FORMID_HIDDEN_NETWORK_LIST, // Form ID\r | |
763 | StartOpCodeHandle, // Label for where to insert opcodes\r | |
764 | EndOpCodeHandle // Replace data\r | |
765 | );\r | |
766 | \r | |
767 | gBS->RestoreTPL (OldTpl);\r | |
768 | HiiFreeOpCodeHandle (StartOpCodeHandle);\r | |
769 | HiiFreeOpCodeHandle (EndOpCodeHandle);\r | |
770 | return Status;\r | |
771 | }\r | |
772 | \r | |
90b24889 WF |
773 | /**\r |
774 | Callback function for user to select a Nic.\r | |
775 | \r | |
776 | @param[in] Private The pointer to the global private data structure.\r | |
777 | @param[in] KeyValue The key value received from HII input.\r | |
778 | \r | |
779 | @retval EFI_NOT_FOUND The corresponding Nic is not found.\r | |
780 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
781 | \r | |
782 | **/\r | |
783 | EFI_STATUS\r | |
784 | WifiMgrSelectNic (\r | |
d1050b9d MK |
785 | IN WIFI_MGR_PRIVATE_DATA *Private,\r |
786 | IN EFI_QUESTION_ID KeyValue\r | |
90b24889 WF |
787 | )\r |
788 | {\r | |
d1050b9d MK |
789 | WIFI_MGR_DEVICE_DATA *Nic;\r |
790 | UINT32 NicIndex;\r | |
791 | CHAR16 MacString[WIFI_MGR_MAX_MAC_STRING_LEN];\r | |
90b24889 WF |
792 | \r |
793 | NicIndex = KeyValue - KEY_MAC_ENTRY_BASE;\r | |
794 | Nic = WifiMgrGetNicByIndex (Private, NicIndex);\r | |
795 | if (Nic == NULL) {\r | |
796 | return EFI_NOT_FOUND;\r | |
797 | }\r | |
d1050b9d | 798 | \r |
90b24889 WF |
799 | Private->CurrentNic = Nic;\r |
800 | \r | |
801 | WifiMgrMacAddrToStr (&Nic->MacAddress, sizeof (MacString), MacString);\r | |
d1050b9d | 802 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_MAC_ADDRESS), MacString, NULL);\r |
90b24889 WF |
803 | return EFI_SUCCESS;\r |
804 | }\r | |
805 | \r | |
806 | /**\r | |
807 | Restore the NV data to be default.\r | |
808 | \r | |
809 | @param[in] Private The pointer to the global private data structure.\r | |
810 | @param[out] IfrNvData The IFR NV data.\r | |
811 | \r | |
812 | **/\r | |
813 | VOID\r | |
814 | WifiMgrCleanUserInput (\r | |
d1050b9d | 815 | IN WIFI_MGR_PRIVATE_DATA *Private\r |
90b24889 WF |
816 | )\r |
817 | {\r | |
818 | Private->SecurityType = SECURITY_TYPE_NONE;\r | |
819 | Private->EapAuthMethod = EAP_AUTH_METHOD_TTLS;\r | |
820 | Private->EapSecondAuthMethod = EAP_SEAUTH_METHOD_MSCHAPV2;\r | |
821 | Private->FileType = FileTypeMax;\r | |
822 | }\r | |
823 | \r | |
824 | /**\r | |
825 | UI handle function when user select a network to connect.\r | |
826 | \r | |
827 | @param[in] Private The pointer to the global private data structure.\r | |
828 | @param[in] ProfileIndex The profile index user selected to connect.\r | |
829 | \r | |
830 | @retval EFI_INVALID_PARAMETER Nic is null.\r | |
831 | @retval EFI_NOT_FOUND Profile could not be found.\r | |
832 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
833 | \r | |
834 | **/\r | |
835 | EFI_STATUS\r | |
d1050b9d MK |
836 | WifiMgrUserSelectProfileToConnect (\r |
837 | IN WIFI_MGR_PRIVATE_DATA *Private,\r | |
838 | IN UINT32 ProfileIndex\r | |
90b24889 WF |
839 | )\r |
840 | {\r | |
d1050b9d MK |
841 | WIFI_MGR_NETWORK_PROFILE *Profile;\r |
842 | WIFI_MGR_DEVICE_DATA *Nic;\r | |
90b24889 WF |
843 | \r |
844 | Nic = Private->CurrentNic;\r | |
845 | if (Nic == NULL) {\r | |
846 | return EFI_INVALID_PARAMETER;\r | |
847 | }\r | |
848 | \r | |
849 | //\r | |
d1050b9d | 850 | // Initialize the connection page\r |
90b24889 | 851 | //\r |
d1050b9d | 852 | WifiMgrCleanUserInput (Private);\r |
90b24889 WF |
853 | \r |
854 | Profile = WifiMgrGetProfileByProfileIndex (ProfileIndex, &Nic->ProfileList);\r | |
855 | if (Profile == NULL) {\r | |
856 | return EFI_NOT_FOUND;\r | |
857 | }\r | |
d1050b9d | 858 | \r |
90b24889 WF |
859 | Private->CurrentNic->UserSelectedProfile = Profile;\r |
860 | \r | |
861 | return EFI_SUCCESS;\r | |
862 | }\r | |
863 | \r | |
864 | /**\r | |
865 | Record password from a HII input string.\r | |
866 | \r | |
867 | @param[in] Private The pointer to the global private data structure.\r | |
868 | @param[in] StringId The QuestionId received from HII input.\r | |
869 | @param[in] StringBuffer The unicode string buffer to store password.\r | |
870 | @param[in] StringBufferLen The len of unicode string buffer.\r | |
871 | \r | |
872 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
873 | @retval EFI_NOT_FOUND The password string is not found or invalid.\r | |
874 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
875 | \r | |
876 | **/\r | |
877 | EFI_STATUS\r | |
878 | WifiMgrRecordPassword (\r | |
d1050b9d MK |
879 | IN WIFI_MGR_PRIVATE_DATA *Private,\r |
880 | IN EFI_STRING_ID StringId,\r | |
881 | IN CHAR16 *StringBuffer,\r | |
882 | IN UINTN StringBufferLen\r | |
90b24889 WF |
883 | )\r |
884 | {\r | |
d1050b9d | 885 | CHAR16 *Password;\r |
90b24889 | 886 | \r |
d1050b9d | 887 | if ((StringId == 0) || (StringBuffer == NULL) || (StringBufferLen <= 0)) {\r |
90b24889 WF |
888 | return EFI_INVALID_PARAMETER;\r |
889 | }\r | |
890 | \r | |
891 | Password = HiiGetString (Private->RegisteredHandle, StringId, NULL);\r | |
892 | if (Password == NULL) {\r | |
893 | return EFI_NOT_FOUND;\r | |
894 | }\r | |
d1050b9d | 895 | \r |
90b24889 WF |
896 | if (StrLen (Password) > StringBufferLen) {\r |
897 | FreePool (Password);\r | |
898 | return EFI_NOT_FOUND;\r | |
899 | }\r | |
d1050b9d | 900 | \r |
90b24889 WF |
901 | StrnCpyS (StringBuffer, StringBufferLen, Password, StrLen (Password));\r |
902 | ZeroMem (Password, (StrLen (Password) + 1) * sizeof (CHAR16));\r | |
903 | FreePool (Password);\r | |
904 | \r | |
905 | //\r | |
906 | // Clean password in string package\r | |
907 | //\r | |
908 | HiiSetString (Private->RegisteredHandle, StringId, L"", NULL);\r | |
909 | return EFI_SUCCESS;\r | |
910 | }\r | |
911 | \r | |
912 | /**\r | |
913 | Update connection message on connect configuration page, and trigger related form refresh.\r | |
914 | \r | |
915 | @param[in] Nic The related Nic for updating message.\r | |
916 | @param[in] ConnectStateChanged The tag to tell if the connection state has been changed, only\r | |
917 | when the connection changes from "Connected" or "Disconnecting"\r | |
918 | to "Disconnected", or from "Disconnected" or "Connecting" to\r | |
919 | "Connected", this tag can be set as TRUE.\r | |
920 | @param[in] ConnectStatusMessage The message to show on connected status bar, if NULL, will\r | |
921 | use default message.\r | |
922 | \r | |
923 | **/\r | |
924 | VOID\r | |
925 | WifiMgrUpdateConnectMessage (\r | |
d1050b9d MK |
926 | IN WIFI_MGR_DEVICE_DATA *Nic,\r |
927 | IN BOOLEAN ConnectStateChanged,\r | |
928 | IN EFI_STRING ConnectStatusMessage\r | |
90b24889 WF |
929 | )\r |
930 | {\r | |
d1050b9d MK |
931 | CHAR16 ConnectStatusStr[WIFI_STR_MAX_SIZE];\r |
932 | WIFI_MGR_PRIVATE_DATA *Private;\r | |
90b24889 WF |
933 | \r |
934 | Private = Nic->Private;\r | |
d1050b9d | 935 | if ((Private == NULL) || (Private->CurrentNic != Nic)) {\r |
90b24889 WF |
936 | return;\r |
937 | }\r | |
938 | \r | |
939 | //\r | |
940 | // Update Connection Status Bar\r | |
941 | //\r | |
942 | if (ConnectStatusMessage != NULL) {\r | |
943 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECT_STATUS), ConnectStatusMessage, NULL);\r | |
944 | } else {\r | |
945 | if (Nic->ConnectState == WifiMgrConnectedToAp) {\r | |
d1050b9d MK |
946 | UnicodeSPrint (\r |
947 | ConnectStatusStr,\r | |
948 | sizeof (ConnectStatusStr),\r | |
949 | L"Connected to %s",\r | |
950 | Nic->CurrentOperateNetwork->SSId\r | |
951 | );\r | |
90b24889 WF |
952 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECT_STATUS), ConnectStatusStr, NULL);\r |
953 | } else if (Nic->ConnectState == WifiMgrDisconnected) {\r | |
90b24889 WF |
954 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECT_STATUS), L"Disconnected", NULL);\r |
955 | } else if (Nic->ConnectState == WifiMgrConnectingToAp) {\r | |
d1050b9d MK |
956 | UnicodeSPrint (\r |
957 | ConnectStatusStr,\r | |
958 | sizeof (ConnectStatusStr),\r | |
959 | L"Connecting to %s ...",\r | |
960 | Nic->CurrentOperateNetwork->SSId\r | |
961 | );\r | |
90b24889 WF |
962 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECT_STATUS), ConnectStatusStr, NULL);\r |
963 | } else if (Nic->ConnectState == WifiMgrDisconnectingToAp) {\r | |
d1050b9d MK |
964 | UnicodeSPrint (\r |
965 | ConnectStatusStr,\r | |
966 | sizeof (ConnectStatusStr),\r | |
967 | L"Disconnecting from %s ...",\r | |
968 | Nic->CurrentOperateNetwork->SSId\r | |
969 | );\r | |
90b24889 WF |
970 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECT_STATUS), ConnectStatusStr, NULL);\r |
971 | } else {\r | |
972 | return;\r | |
973 | }\r | |
974 | }\r | |
975 | \r | |
976 | //\r | |
977 | // Update Connect Button\r | |
978 | //\r | |
d1050b9d MK |
979 | if ((Nic->ConnectState == WifiMgrConnectedToAp) && (Nic->UserSelectedProfile == Nic->CurrentOperateNetwork)) {\r |
980 | HiiSetString (\r | |
981 | Private->RegisteredHandle,\r | |
982 | STRING_TOKEN (STR_CONNECT_NOW),\r | |
983 | L"Disconnect from this Network",\r | |
984 | NULL\r | |
985 | );\r | |
90b24889 WF |
986 | } else {\r |
987 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECT_NOW), L"Connect to this Network", NULL);\r | |
988 | }\r | |
d1050b9d | 989 | \r |
90b24889 WF |
990 | gBS->SignalEvent (Private->ConnectFormRefreshEvent);\r |
991 | \r | |
992 | //\r | |
993 | // Update Main Page and Network List\r | |
994 | //\r | |
995 | if (ConnectStateChanged) {\r | |
90b24889 | 996 | if (Nic->ConnectState == WifiMgrConnectedToAp) {\r |
90b24889 | 997 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECTION_INFO), L"Connected to", NULL);\r |
d1050b9d MK |
998 | HiiSetString (\r |
999 | Private->RegisteredHandle,\r | |
1000 | STRING_TOKEN (STR_CONNECTED_SSID),\r | |
1001 | Nic->CurrentOperateNetwork->SSId,\r | |
1002 | NULL\r | |
1003 | );\r | |
90b24889 WF |
1004 | } else {\r |
1005 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECTION_INFO), L"Disconnected", NULL);\r | |
1006 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_CONNECTED_SSID), L"", NULL);\r | |
1007 | }\r | |
1008 | \r | |
1009 | gBS->SignalEvent (Private->NetworkListRefreshEvent);\r | |
1010 | gBS->SignalEvent (Private->MainPageRefreshEvent);\r | |
1011 | }\r | |
1012 | }\r | |
1013 | \r | |
1014 | /**\r | |
1015 | Convert the driver configuration data into the IFR data.\r | |
1016 | \r | |
1017 | @param[in] Private The pointer to the global private data structure.\r | |
1018 | @param[out] IfrNvData The IFR NV data.\r | |
1019 | \r | |
1020 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
1021 | \r | |
1022 | **/\r | |
1023 | EFI_STATUS\r | |
1024 | WifiMgrConvertConfigDataToIfrNvData (\r | |
d1050b9d MK |
1025 | IN WIFI_MGR_PRIVATE_DATA *Private,\r |
1026 | OUT WIFI_MANAGER_IFR_NVDATA *IfrNvData\r | |
90b24889 WF |
1027 | )\r |
1028 | {\r | |
1029 | //\r | |
1030 | // Private shouldn't be NULL here, assert if Private is NULL.\r | |
1031 | //\r | |
1032 | ASSERT (Private != NULL);\r | |
1033 | \r | |
1034 | if (Private->CurrentNic != NULL) {\r | |
1035 | IfrNvData->ProfileCount = Private->CurrentNic->AvailableCount;\r | |
1036 | } else {\r | |
1037 | IfrNvData->ProfileCount = 0;\r | |
1038 | }\r | |
1039 | \r | |
1040 | return EFI_SUCCESS;\r | |
1041 | }\r | |
1042 | \r | |
1043 | /**\r | |
1044 | Convert the IFR data into the driver configuration data.\r | |
1045 | \r | |
1046 | @param[in] Private The pointer to the global private data structure.\r | |
1047 | @param[in, out] IfrNvData The IFR NV data.\r | |
1048 | \r | |
1049 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
1050 | \r | |
1051 | **/\r | |
1052 | EFI_STATUS\r | |
1053 | WifiMgrConvertIfrNvDataToConfigData (\r | |
d1050b9d MK |
1054 | IN WIFI_MGR_PRIVATE_DATA *Private,\r |
1055 | IN OUT WIFI_MANAGER_IFR_NVDATA *IfrNvData\r | |
90b24889 WF |
1056 | )\r |
1057 | {\r | |
1058 | return EFI_SUCCESS;\r | |
1059 | }\r | |
1060 | \r | |
1061 | /**\r | |
1062 | This function allows the caller to request the current\r | |
1063 | configuration for one or more named elements. The resulting\r | |
1064 | string is in <ConfigAltResp> format. Any and all alternative\r | |
1065 | configuration strings shall also be appended to the end of the\r | |
1066 | current configuration string. If they are, they must appear\r | |
1067 | after the current configuration. They must contain the same\r | |
1068 | routing (GUID, NAME, PATH) as the current configuration string.\r | |
1069 | They must have an additional description indicating the type of\r | |
1070 | alternative configuration the string represents,\r | |
1071 | "ALTCFG=<StringToken>". That <StringToken> (when\r | |
1072 | converted from Hex UNICODE to binary) is a reference to a\r | |
1073 | string in the associated string pack.\r | |
1074 | \r | |
1075 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
1076 | \r | |
1077 | @param Request A null-terminated Unicode string in\r | |
1078 | <ConfigRequest> format. Note that this\r | |
1079 | includes the routing information as well as\r | |
1080 | the configurable name / value pairs. It is\r | |
1081 | invalid for this string to be in\r | |
1082 | <MultiConfigRequest> format.\r | |
1083 | If a NULL is passed in for the Request field,\r | |
1084 | all of the settings being abstracted by this function\r | |
1085 | will be returned in the Results field. In addition,\r | |
1086 | if a ConfigHdr is passed in with no request elements,\r | |
1087 | all of the settings being abstracted for that particular\r | |
1088 | ConfigHdr reference will be returned in the Results Field.\r | |
1089 | \r | |
1090 | @param Progress On return, points to a character in the\r | |
1091 | Request string. Points to the string's null\r | |
1092 | terminator if request was successful. Points\r | |
1093 | to the most recent "&" before the first\r | |
1094 | failing name / value pair (or the beginning\r | |
1095 | of the string if the failure is in the first\r | |
1096 | name / value pair) if the request was not\r | |
1097 | successful.\r | |
1098 | \r | |
1099 | @param Results A null-terminated Unicode string in\r | |
1100 | <MultiConfigAltResp> format which has all values\r | |
1101 | filled in for the names in the Request string.\r | |
1102 | String to be allocated by the called function.\r | |
1103 | \r | |
1104 | @retval EFI_SUCCESS The Results string is filled with the\r | |
1105 | values corresponding to all requested\r | |
1106 | names.\r | |
1107 | \r | |
1108 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the\r | |
1109 | parts of the results that must be\r | |
1110 | stored awaiting possible future\r | |
1111 | protocols.\r | |
1112 | \r | |
1113 | @retval EFI_NOT_FOUND Routing data doesn't match any\r | |
1114 | known driver. Progress set to the\r | |
1115 | first character in the routing header.\r | |
1116 | Note: There is no requirement that the\r | |
1117 | driver validate the routing data. It\r | |
1118 | must skip the <ConfigHdr> in order to\r | |
1119 | process the names.\r | |
1120 | \r | |
1121 | @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set\r | |
1122 | to most recent "&" before the\r | |
1123 | error or the beginning of the\r | |
1124 | string.\r | |
1125 | \r | |
1126 | @retval EFI_INVALID_PARAMETER Unknown name. Progress points\r | |
1127 | to the & before the name in\r | |
1128 | question.\r | |
1129 | \r | |
1130 | **/\r | |
1131 | EFI_STATUS\r | |
1132 | EFIAPI\r | |
1133 | WifiMgrDxeHiiConfigAccessExtractConfig (\r | |
1134 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
1135 | IN CONST EFI_STRING Request,\r | |
1136 | OUT EFI_STRING *Progress,\r | |
1137 | OUT EFI_STRING *Results\r | |
1138 | )\r | |
1139 | {\r | |
d1050b9d MK |
1140 | WIFI_MGR_PRIVATE_DATA *Private;\r |
1141 | WIFI_MANAGER_IFR_NVDATA *IfrNvData;\r | |
1142 | EFI_STRING ConfigRequestHdr;\r | |
1143 | EFI_STRING ConfigRequest;\r | |
1144 | UINTN Size;\r | |
1145 | BOOLEAN AllocatedRequest;\r | |
1146 | UINTN BufferSize;\r | |
1147 | EFI_STATUS Status;\r | |
1148 | \r | |
1149 | if ((This == NULL) || (Progress == NULL) || (Results == NULL)) {\r | |
90b24889 WF |
1150 | return EFI_INVALID_PARAMETER;\r |
1151 | }\r | |
1152 | \r | |
1153 | *Progress = Request;\r | |
1154 | if ((Request != NULL) &&\r | |
d1050b9d MK |
1155 | !HiiIsConfigHdrMatch (Request, &gWifiConfigFormSetGuid, mVendorStorageName))\r |
1156 | {\r | |
90b24889 WF |
1157 | return EFI_NOT_FOUND;\r |
1158 | }\r | |
1159 | \r | |
1160 | ConfigRequestHdr = NULL;\r | |
1161 | ConfigRequest = NULL;\r | |
1162 | AllocatedRequest = FALSE;\r | |
1163 | Size = 0;\r | |
1164 | \r | |
d1050b9d | 1165 | Private = WIFI_MGR_PRIVATE_DATA_FROM_CONFIG_ACCESS (This);\r |
90b24889 WF |
1166 | \r |
1167 | BufferSize = sizeof (WIFI_MANAGER_IFR_NVDATA);\r | |
d1050b9d | 1168 | IfrNvData = AllocateZeroPool (BufferSize);\r |
90b24889 WF |
1169 | if (IfrNvData == NULL) {\r |
1170 | return EFI_OUT_OF_RESOURCES;\r | |
1171 | }\r | |
1172 | \r | |
1173 | WifiMgrConvertConfigDataToIfrNvData (Private, IfrNvData);\r | |
1174 | \r | |
1175 | ConfigRequest = Request;\r | |
1176 | if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r | |
1177 | //\r | |
1178 | // Request has no request element, construct full request string.\r | |
1179 | // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r | |
1180 | // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator.\r | |
1181 | //\r | |
1182 | ConfigRequestHdr = HiiConstructConfigHdr (\r | |
1183 | &gWifiConfigFormSetGuid,\r | |
1184 | mVendorStorageName,\r | |
d1050b9d MK |
1185 | Private->DriverHandle\r |
1186 | );\r | |
90b24889 WF |
1187 | if (ConfigRequestHdr == NULL) {\r |
1188 | FreePool (IfrNvData);\r | |
1189 | return EFI_OUT_OF_RESOURCES;\r | |
1190 | }\r | |
1191 | \r | |
d1050b9d | 1192 | Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r |
90b24889 WF |
1193 | ConfigRequest = AllocateZeroPool (Size);\r |
1194 | if (ConfigRequest == NULL) {\r | |
90b24889 WF |
1195 | FreePool (IfrNvData);\r |
1196 | FreePool (ConfigRequestHdr);\r | |
1197 | return EFI_OUT_OF_RESOURCES;\r | |
1198 | }\r | |
1199 | \r | |
1200 | AllocatedRequest = TRUE;\r | |
1201 | UnicodeSPrint (\r | |
1202 | ConfigRequest,\r | |
1203 | Size,\r | |
1204 | L"%s&OFFSET=0&WIDTH=%016LX",\r | |
1205 | ConfigRequestHdr,\r | |
d1050b9d | 1206 | (UINT64)BufferSize\r |
90b24889 WF |
1207 | );\r |
1208 | FreePool (ConfigRequestHdr);\r | |
1209 | }\r | |
1210 | \r | |
1211 | //\r | |
1212 | // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r | |
1213 | //\r | |
1214 | Status = gHiiConfigRouting->BlockToConfig (\r | |
1215 | gHiiConfigRouting,\r | |
1216 | ConfigRequest,\r | |
d1050b9d | 1217 | (UINT8 *)IfrNvData,\r |
90b24889 WF |
1218 | BufferSize,\r |
1219 | Results,\r | |
1220 | Progress\r | |
1221 | );\r | |
1222 | \r | |
1223 | FreePool (IfrNvData);\r | |
1224 | //\r | |
1225 | // Free the allocated config request string.\r | |
1226 | //\r | |
1227 | if (AllocatedRequest) {\r | |
1228 | FreePool (ConfigRequest);\r | |
1229 | ConfigRequest = NULL;\r | |
1230 | }\r | |
d1050b9d | 1231 | \r |
90b24889 WF |
1232 | //\r |
1233 | // Set Progress string to the original request string.\r | |
1234 | //\r | |
1235 | if (Request == NULL) {\r | |
1236 | *Progress = NULL;\r | |
1237 | } else if (StrStr (Request, L"OFFSET") == NULL) {\r | |
1238 | *Progress = Request + StrLen (Request);\r | |
1239 | }\r | |
1240 | \r | |
1241 | return Status;\r | |
1242 | }\r | |
1243 | \r | |
1244 | /**\r | |
1245 | This function applies changes in a driver's configuration.\r | |
1246 | Input is a Configuration, which has the routing data for this\r | |
1247 | driver followed by name / value configuration pairs. The driver\r | |
1248 | must apply those pairs to its configurable storage. If the\r | |
1249 | driver's configuration is stored in a linear block of data\r | |
1250 | and the driver's name / value pairs are in <BlockConfig>\r | |
1251 | format, it may use the ConfigToBlock helper function (above) to\r | |
1252 | simplify the job.\r | |
1253 | \r | |
1254 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
1255 | \r | |
1256 | @param Configuration A null-terminated Unicode string in\r | |
1257 | <ConfigString> format.\r | |
1258 | \r | |
1259 | @param Progress A pointer to a string filled in with the\r | |
1260 | offset of the most recent '&' before the\r | |
1261 | first failing name / value pair (or the\r | |
1262 | beginn ing of the string if the failure\r | |
1263 | is in the first name / value pair) or\r | |
1264 | the terminating NULL if all was\r | |
1265 | successful.\r | |
1266 | \r | |
1267 | @retval EFI_SUCCESS The results have been distributed or are\r | |
1268 | awaiting distribution.\r | |
1269 | \r | |
1270 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the\r | |
1271 | parts of the results that must be\r | |
1272 | stored awaiting possible future\r | |
1273 | protocols.\r | |
1274 | \r | |
1275 | @retval EFI_INVALID_PARAMETERS Passing in a NULL for the\r | |
1276 | Results parameter would result\r | |
1277 | in this type of error.\r | |
1278 | \r | |
1279 | @retval EFI_NOT_FOUND Target for the specified routing data\r | |
1280 | was not found\r | |
1281 | \r | |
1282 | **/\r | |
1283 | EFI_STATUS\r | |
1284 | EFIAPI\r | |
1285 | WifiMgrDxeHiiConfigAccessRouteConfig (\r | |
1286 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
1287 | IN CONST EFI_STRING Configuration,\r | |
1288 | OUT EFI_STRING *Progress\r | |
1289 | )\r | |
1290 | {\r | |
d1050b9d MK |
1291 | EFI_STATUS Status;\r |
1292 | UINTN BufferSize;\r | |
1293 | WIFI_MGR_PRIVATE_DATA *Private;\r | |
1294 | WIFI_MANAGER_IFR_NVDATA *IfrNvData;\r | |
90b24889 | 1295 | \r |
d1050b9d | 1296 | if ((Configuration == NULL) || (Progress == NULL)) {\r |
90b24889 WF |
1297 | return EFI_INVALID_PARAMETER;\r |
1298 | }\r | |
1299 | \r | |
1300 | IfrNvData = NULL;\r | |
1301 | *Progress = Configuration;\r | |
1302 | BufferSize = sizeof (WIFI_MANAGER_IFR_NVDATA);\r | |
1303 | Private = WIFI_MGR_PRIVATE_DATA_FROM_CONFIG_ACCESS (This);\r | |
1304 | \r | |
1305 | if (!HiiIsConfigHdrMatch (Configuration, &gWifiConfigFormSetGuid, mVendorStorageName)) {\r | |
1306 | return EFI_NOT_FOUND;\r | |
1307 | }\r | |
1308 | \r | |
1309 | IfrNvData = AllocateZeroPool (BufferSize);\r | |
1310 | if (IfrNvData == NULL) {\r | |
1311 | return EFI_OUT_OF_RESOURCES;\r | |
1312 | }\r | |
1313 | \r | |
1314 | WifiMgrConvertConfigDataToIfrNvData (Private, IfrNvData);\r | |
1315 | \r | |
1316 | Status = gHiiConfigRouting->ConfigToBlock (\r | |
1317 | gHiiConfigRouting,\r | |
1318 | Configuration,\r | |
d1050b9d | 1319 | (UINT8 *)IfrNvData,\r |
90b24889 WF |
1320 | &BufferSize,\r |
1321 | Progress\r | |
1322 | );\r | |
1323 | if (EFI_ERROR (Status)) {\r | |
1324 | return Status;\r | |
1325 | }\r | |
1326 | \r | |
1327 | Status = WifiMgrConvertIfrNvDataToConfigData (Private, IfrNvData);\r | |
1328 | ZeroMem (IfrNvData, sizeof (WIFI_MANAGER_IFR_NVDATA));\r | |
1329 | FreePool (IfrNvData);\r | |
1330 | \r | |
1331 | return Status;\r | |
1332 | }\r | |
1333 | \r | |
1334 | /**\r | |
1335 | This function is called to provide results data to the driver.\r | |
1336 | This data consists of a unique key that is used to identify\r | |
1337 | which data is either being passed back or being asked for.\r | |
1338 | \r | |
1339 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
1340 | @param Action Specifies the type of action taken by the browser.\r | |
1341 | @param QuestionId A unique value which is sent to the original\r | |
1342 | exporting driver so that it can identify the type\r | |
1343 | of data to expect. The format of the data tends to\r | |
1344 | vary based on the opcode that generated the callback.\r | |
1345 | @param Type The type of value for the question.\r | |
1346 | @param Value A pointer to the data being sent to the original\r | |
1347 | exporting driver.\r | |
1348 | @param ActionRequest On return, points to the action requested by the\r | |
1349 | callback function.\r | |
1350 | \r | |
1351 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
1352 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r | |
1353 | variable and its data.\r | |
1354 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
1355 | @retval EFI_UNSUPPORTED The specified Action is not supported by the\r | |
1356 | callback.\r | |
1357 | \r | |
1358 | **/\r | |
1359 | EFI_STATUS\r | |
1360 | EFIAPI\r | |
1361 | WifiMgrDxeHiiConfigAccessCallback (\r | |
d1050b9d MK |
1362 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r |
1363 | IN EFI_BROWSER_ACTION Action,\r | |
1364 | IN EFI_QUESTION_ID QuestionId,\r | |
1365 | IN UINT8 Type,\r | |
1366 | IN OUT EFI_IFR_TYPE_VALUE *Value,\r | |
1367 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
90b24889 WF |
1368 | )\r |
1369 | {\r | |
d1050b9d MK |
1370 | EFI_STATUS Status;\r |
1371 | EFI_INPUT_KEY Key;\r | |
1372 | UINTN BufferSize;\r | |
1373 | WIFI_MGR_PRIVATE_DATA *Private;\r | |
1374 | WIFI_MANAGER_IFR_NVDATA *IfrNvData;\r | |
1375 | EFI_DEVICE_PATH_PROTOCOL *FilePath;\r | |
1376 | WIFI_MGR_NETWORK_PROFILE *Profile;\r | |
1377 | WIFI_MGR_NETWORK_PROFILE *ProfileToConnect;\r | |
1378 | WIFI_HIDDEN_NETWORK_DATA *HiddenNetwork;\r | |
1379 | UINTN TempDataSize;\r | |
1380 | VOID *TempData;\r | |
1381 | LIST_ENTRY *Entry;\r | |
1382 | UINT32 Index;\r | |
1383 | UINT32 RemoveCount;\r | |
1384 | CHAR16 *TempPassword;\r | |
1385 | CHAR16 *ErrorMessage;\r | |
1386 | \r | |
1387 | if ((Action != EFI_BROWSER_ACTION_FORM_OPEN) &&\r | |
1388 | (Action != EFI_BROWSER_ACTION_FORM_CLOSE) &&\r | |
1389 | (Action != EFI_BROWSER_ACTION_CHANGING) &&\r | |
1390 | (Action != EFI_BROWSER_ACTION_CHANGED) &&\r | |
1391 | (Action != EFI_BROWSER_ACTION_RETRIEVE))\r | |
1392 | {\r | |
90b24889 WF |
1393 | return EFI_UNSUPPORTED;\r |
1394 | }\r | |
d1050b9d | 1395 | \r |
90b24889 WF |
1396 | if ((Value == NULL) || (ActionRequest == NULL)) {\r |
1397 | return EFI_INVALID_PARAMETER;\r | |
1398 | }\r | |
1399 | \r | |
1400 | Status = EFI_SUCCESS;\r | |
1401 | Private = WIFI_MGR_PRIVATE_DATA_FROM_CONFIG_ACCESS (This);\r | |
1402 | if (Private->CurrentNic == NULL) {\r | |
1403 | return EFI_DEVICE_ERROR;\r | |
1404 | }\r | |
1405 | \r | |
1406 | //\r | |
1407 | // Retrieve uncommitted data from Browser\r | |
1408 | //\r | |
1409 | BufferSize = sizeof (WIFI_MANAGER_IFR_NVDATA);\r | |
d1050b9d | 1410 | IfrNvData = AllocateZeroPool (BufferSize);\r |
90b24889 WF |
1411 | if (IfrNvData == NULL) {\r |
1412 | return EFI_OUT_OF_RESOURCES;\r | |
1413 | }\r | |
d1050b9d MK |
1414 | \r |
1415 | HiiGetBrowserData (&gWifiConfigFormSetGuid, mVendorStorageName, BufferSize, (UINT8 *)IfrNvData);\r | |
90b24889 WF |
1416 | \r |
1417 | if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r | |
1418 | switch (QuestionId) {\r | |
d1050b9d | 1419 | case KEY_MAC_LIST:\r |
90b24889 | 1420 | \r |
d1050b9d MK |
1421 | Status = WifiMgrShowNicList (Private);\r |
1422 | break;\r | |
90b24889 | 1423 | \r |
d1050b9d | 1424 | case KEY_REFRESH_NETWORK_LIST:\r |
90b24889 | 1425 | \r |
d1050b9d MK |
1426 | if (Private->CurrentNic->UserSelectedProfile != NULL) {\r |
1427 | Profile = Private->CurrentNic->UserSelectedProfile;\r | |
90b24889 | 1428 | \r |
d1050b9d MK |
1429 | //\r |
1430 | // Erase secrets since user has left Connection Page\r | |
1431 | // Connection Page may direct to Network List Page or Eap Configuration Page,\r | |
1432 | // secrets only need to be erased when head to Network List Page\r | |
1433 | //\r | |
1434 | WifiMgrCleanProfileSecrets (Profile);\r | |
1435 | \r | |
1436 | Private->CurrentNic->UserSelectedProfile = NULL;\r | |
1437 | }\r | |
1438 | \r | |
1439 | break;\r | |
1440 | \r | |
1441 | case KEY_CONNECT_ACTION:\r | |
1442 | \r | |
1443 | if (Private->CurrentNic->UserSelectedProfile == NULL) {\r | |
1444 | break;\r | |
1445 | }\r | |
90b24889 WF |
1446 | \r |
1447 | Profile = Private->CurrentNic->UserSelectedProfile;\r | |
1448 | \r | |
1449 | //\r | |
d1050b9d MK |
1450 | // Enter the network connection configuration page\r |
1451 | // Recovery from restored data\r | |
90b24889 | 1452 | //\r |
d1050b9d MK |
1453 | if (HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_SSID), Profile->SSId, NULL) == 0) {\r |
1454 | return EFI_OUT_OF_RESOURCES;\r | |
1455 | }\r | |
90b24889 | 1456 | \r |
d1050b9d MK |
1457 | IfrNvData->SecurityType = Profile->SecurityType;\r |
1458 | if (HiiSetString (\r | |
1459 | Private->RegisteredHandle,\r | |
1460 | STRING_TOKEN (STR_SECURITY_TYPE),\r | |
1461 | mSecurityType[IfrNvData->SecurityType],\r | |
1462 | NULL\r | |
1463 | ) == 0)\r | |
1464 | {\r | |
1465 | return EFI_OUT_OF_RESOURCES;\r | |
1466 | }\r | |
90b24889 | 1467 | \r |
e1eef3a8 HL |
1468 | if ((IfrNvData->SecurityType == SECURITY_TYPE_WPA2_ENTERPRISE) ||\r |
1469 | (IfrNvData->SecurityType == SECURITY_TYPE_WPA3_ENTERPRISE))\r | |
1470 | {\r | |
d1050b9d MK |
1471 | IfrNvData->EapAuthMethod = Profile->EapAuthMethod;\r |
1472 | IfrNvData->EapSecondAuthMethod = Profile->EapSecondAuthMethod;\r | |
1473 | StrCpyS (IfrNvData->EapIdentity, EAP_IDENTITY_SIZE, Profile->EapIdentity);\r | |
1474 | }\r | |
90b24889 | 1475 | \r |
90b24889 | 1476 | break;\r |
90b24889 | 1477 | \r |
d1050b9d | 1478 | case KEY_ENROLLED_CERT_NAME:\r |
90b24889 | 1479 | \r |
d1050b9d MK |
1480 | if (Private->CurrentNic->UserSelectedProfile == NULL) {\r |
1481 | break;\r | |
1482 | }\r | |
90b24889 | 1483 | \r |
d1050b9d | 1484 | Profile = Private->CurrentNic->UserSelectedProfile;\r |
90b24889 | 1485 | \r |
d1050b9d MK |
1486 | //\r |
1487 | // Enter the key enrollment page\r | |
1488 | // For TTLS and PEAP, only CA cert needs to be cared\r | |
1489 | //\r | |
1490 | if (Private->FileType == FileTypeCACert) {\r | |
1491 | if (Profile->CACertData != NULL) {\r | |
1492 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_EAP_ENROLLED_CERT_NAME), Profile->CACertName, NULL);\r | |
1493 | } else {\r | |
1494 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_EAP_ENROLLED_CERT_NAME), L"", NULL);\r | |
1495 | }\r | |
1496 | } else if (Private->FileType == FileTypeClientCert) {\r | |
1497 | if (Profile->ClientCertData != NULL) {\r | |
1498 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_EAP_ENROLLED_CERT_NAME), Profile->ClientCertName, NULL);\r | |
1499 | } else {\r | |
1500 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_EAP_ENROLLED_CERT_NAME), L"", NULL);\r | |
1501 | }\r | |
1502 | }\r | |
90b24889 | 1503 | \r |
90b24889 | 1504 | break;\r |
90b24889 | 1505 | \r |
d1050b9d | 1506 | case KEY_ENROLLED_PRIVATE_KEY_NAME:\r |
90b24889 | 1507 | \r |
d1050b9d MK |
1508 | if (Private->CurrentNic->UserSelectedProfile == NULL) {\r |
1509 | break;\r | |
90b24889 | 1510 | }\r |
90b24889 | 1511 | \r |
d1050b9d MK |
1512 | Profile = Private->CurrentNic->UserSelectedProfile;\r |
1513 | \r | |
1514 | if (Profile->PrivateKeyData != NULL) {\r | |
1515 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_EAP_ENROLLED_PRIVATE_KEY_NAME), Profile->PrivateKeyName, NULL);\r | |
90b24889 | 1516 | } else {\r |
d1050b9d | 1517 | HiiSetString (Private->RegisteredHandle, STRING_TOKEN (STR_EAP_ENROLLED_PRIVATE_KEY_NAME), L"", NULL);\r |
90b24889 | 1518 | }\r |
90b24889 | 1519 | \r |
90b24889 | 1520 | break;\r |
90b24889 | 1521 | \r |
d1050b9d MK |
1522 | default:\r |
1523 | break;\r | |
90b24889 WF |
1524 | }\r |
1525 | } else if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {\r | |
1526 | switch (QuestionId) {\r | |
d1050b9d | 1527 | case KEY_CONNECT_ACTION:\r |
90b24889 | 1528 | \r |
d1050b9d MK |
1529 | if (Private->CurrentNic->UserSelectedProfile == NULL) {\r |
1530 | break;\r | |
1531 | }\r | |
90b24889 | 1532 | \r |
d1050b9d | 1533 | Profile = Private->CurrentNic->UserSelectedProfile;\r |
90b24889 | 1534 | \r |
d1050b9d MK |
1535 | //\r |
1536 | // Restore User Config Data for Page recovery\r | |
1537 | //\r | |
e1eef3a8 HL |
1538 | if ((IfrNvData->SecurityType == SECURITY_TYPE_WPA2_ENTERPRISE) ||\r |
1539 | (IfrNvData->SecurityType == SECURITY_TYPE_WPA3_ENTERPRISE))\r | |
1540 | {\r | |
d1050b9d MK |
1541 | Profile->EapAuthMethod = IfrNvData->EapAuthMethod;\r |
1542 | Profile->EapSecondAuthMethod = IfrNvData->EapSecondAuthMethod;\r | |
1543 | StrCpyS (Profile->EapIdentity, EAP_IDENTITY_SIZE, IfrNvData->EapIdentity);\r | |
1544 | }\r | |
90b24889 | 1545 | \r |
d1050b9d | 1546 | break;\r |
90b24889 | 1547 | \r |
d1050b9d MK |
1548 | default:\r |
1549 | break;\r | |
90b24889 WF |
1550 | }\r |
1551 | } else if (Action == EFI_BROWSER_ACTION_CHANGING) {\r | |
1552 | switch (QuestionId) {\r | |
d1050b9d | 1553 | case KEY_NETWORK_LIST:\r |
90b24889 | 1554 | \r |
d1050b9d MK |
1555 | //\r |
1556 | // User triggered a scan process.\r | |
1557 | //\r | |
1558 | Private->CurrentNic->OneTimeScanRequest = TRUE;\r | |
90b24889 | 1559 | break;\r |
90b24889 | 1560 | \r |
d1050b9d MK |
1561 | case KEY_PASSWORD_CONNECT_NETWORK:\r |
1562 | case KEY_EAP_PASSWORD_CONNECT_NETWORK:\r | |
1563 | case KEY_PRIVATE_KEY_PASSWORD:\r | |
90b24889 | 1564 | \r |
d1050b9d MK |
1565 | if (Private->CurrentNic->UserSelectedProfile == NULL) {\r |
1566 | break;\r | |
1567 | }\r | |
90b24889 | 1568 | \r |
d1050b9d | 1569 | Profile = Private->CurrentNic->UserSelectedProfile;\r |
90b24889 | 1570 | \r |
d1050b9d MK |
1571 | if (QuestionId == KEY_PASSWORD_CONNECT_NETWORK) {\r |
1572 | TempPassword = Profile->Password;\r | |
1573 | } else if (QuestionId == KEY_EAP_PASSWORD_CONNECT_NETWORK) {\r | |
1574 | TempPassword = Profile->EapPassword;\r | |
1575 | } else {\r | |
1576 | TempPassword = Profile->PrivateKeyPassword;\r | |
1577 | }\r | |
90b24889 | 1578 | \r |
d1050b9d MK |
1579 | Status = WifiMgrRecordPassword (Private, Value->string, TempPassword, PASSWORD_STORAGE_SIZE);\r |
1580 | if (EFI_ERROR (Status)) {\r | |
1581 | DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Error: Failed to input password!"));\r | |
1582 | break;\r | |
1583 | }\r | |
90b24889 WF |
1584 | \r |
1585 | //\r | |
d1050b9d | 1586 | // This password is not a new created password, so no need to confirm.\r |
90b24889 | 1587 | //\r |
d1050b9d MK |
1588 | Status = EFI_NOT_FOUND;\r |
1589 | break;\r | |
90b24889 | 1590 | \r |
d1050b9d | 1591 | case KEY_CONNECT_ACTION:\r |
90b24889 | 1592 | \r |
d1050b9d MK |
1593 | ErrorMessage = NULL;\r |
1594 | ProfileToConnect = NULL;\r | |
90b24889 | 1595 | \r |
d1050b9d MK |
1596 | if (Private->CurrentNic->UserSelectedProfile == NULL) {\r |
1597 | break;\r | |
1598 | }\r | |
90b24889 | 1599 | \r |
d1050b9d | 1600 | Profile = Private->CurrentNic->UserSelectedProfile;\r |
90b24889 | 1601 | \r |
d1050b9d MK |
1602 | if ((Private->CurrentNic->ConnectState == WifiMgrDisconnected) ||\r |
1603 | (Profile != Private->CurrentNic->CurrentOperateNetwork))\r | |
1604 | {\r | |
1605 | //\r | |
1606 | // When this network is not currently connected, pend it to connect.\r | |
1607 | //\r | |
1608 | if (Profile->AKMSuiteSupported && Profile->CipherSuiteSupported) {\r | |
e1eef3a8 HL |
1609 | if ((Profile->SecurityType == SECURITY_TYPE_NONE) ||\r |
1610 | (Profile->SecurityType == SECURITY_TYPE_WPA2_PERSONAL) ||\r | |
1611 | (Profile->SecurityType == SECURITY_TYPE_WPA3_PERSONAL))\r | |
1612 | {\r | |
d1050b9d MK |
1613 | //\r |
1614 | // For Open network, connect directly.\r | |
1615 | //\r | |
90b24889 | 1616 | ProfileToConnect = Profile;\r |
e1eef3a8 HL |
1617 | } else if ((Profile->SecurityType == SECURITY_TYPE_WPA2_ENTERPRISE) ||\r |
1618 | (Profile->SecurityType == SECURITY_TYPE_WPA3_ENTERPRISE))\r | |
1619 | {\r | |
d1050b9d MK |
1620 | //\r |
1621 | // For WPA/WPA2-Enterprise network, conduct eap configuration first.\r | |
1622 | // Only EAP-TLS, TTLS and PEAP is supported now!\r | |
1623 | //\r | |
1624 | Profile->EapAuthMethod = IfrNvData->EapAuthMethod;\r | |
1625 | StrCpyS (Profile->EapIdentity, EAP_IDENTITY_SIZE, IfrNvData->EapIdentity);\r | |
1626 | \r | |
1627 | if ((IfrNvData->EapAuthMethod == EAP_AUTH_METHOD_TTLS) || (IfrNvData->EapAuthMethod == EAP_AUTH_METHOD_PEAP)) {\r | |
1628 | Profile->EapSecondAuthMethod = IfrNvData->EapSecondAuthMethod;\r | |
1629 | ProfileToConnect = Profile;\r | |
1630 | } else if (IfrNvData->EapAuthMethod == EAP_AUTH_METHOD_TLS) {\r | |
1631 | ProfileToConnect = Profile;\r | |
1632 | } else {\r | |
1633 | ErrorMessage = L"ERROR: Only EAP-TLS, TTLS or PEAP is supported now!";\r | |
1634 | }\r | |
90b24889 | 1635 | } else {\r |
d1050b9d | 1636 | ErrorMessage = L"ERROR: Can't connect to this network!";\r |
90b24889 WF |
1637 | }\r |
1638 | } else {\r | |
d1050b9d | 1639 | ErrorMessage = L"ERROR: This network is not supported!";\r |
90b24889 | 1640 | }\r |
90b24889 | 1641 | \r |
d1050b9d MK |
1642 | if (ErrorMessage != NULL) {\r |
1643 | CreatePopUp (\r | |
1644 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
1645 | &Key,\r | |
1646 | ErrorMessage,\r | |
1647 | NULL\r | |
1648 | );\r | |
1649 | }\r | |
90b24889 | 1650 | \r |
d1050b9d MK |
1651 | if (ProfileToConnect != NULL) {\r |
1652 | Private->CurrentNic->OneTimeConnectRequest = TRUE;\r | |
1653 | Private->CurrentNic->ConnectPendingNetwork = ProfileToConnect;\r | |
1654 | }\r | |
1655 | } else if (Private->CurrentNic->ConnectState == WifiMgrConnectedToAp) {\r | |
1656 | //\r | |
1657 | // This network is currently connected, just disconnect from it.\r | |
1658 | //\r | |
1659 | Private->CurrentNic->OneTimeDisconnectRequest = TRUE;\r | |
1660 | Private->CurrentNic->HasDisconnectPendingNetwork = TRUE;\r | |
90b24889 | 1661 | }\r |
90b24889 | 1662 | \r |
d1050b9d | 1663 | break;\r |
90b24889 | 1664 | \r |
d1050b9d | 1665 | case KEY_ENROLL_CA_CERT_CONNECT_NETWORK:\r |
90b24889 | 1666 | \r |
d1050b9d MK |
1667 | Private->FileType = FileTypeCACert;\r |
1668 | break;\r | |
90b24889 | 1669 | \r |
d1050b9d | 1670 | case KEY_ENROLL_CLIENT_CERT_CONNECT_NETWORK:\r |
90b24889 | 1671 | \r |
d1050b9d MK |
1672 | Private->FileType = FileTypeClientCert;\r |
1673 | break;\r | |
90b24889 | 1674 | \r |
d1050b9d | 1675 | case KEY_EAP_ENROLL_PRIVATE_KEY_FROM_FILE:\r |
90b24889 | 1676 | \r |
d1050b9d MK |
1677 | FilePath = NULL;\r |
1678 | ChooseFile (NULL, NULL, NULL, &FilePath);\r | |
90b24889 | 1679 | \r |
d1050b9d MK |
1680 | if (FilePath != NULL) {\r |
1681 | UpdatePrivateKeyFromFile (Private, FilePath);\r | |
1682 | FreePool (FilePath);\r | |
1683 | }\r | |
90b24889 | 1684 | \r |
d1050b9d | 1685 | break;\r |
90b24889 | 1686 | \r |
d1050b9d | 1687 | case KEY_EAP_ENROLL_CERT_FROM_FILE:\r |
90b24889 WF |
1688 | \r |
1689 | //\r | |
d1050b9d | 1690 | // User will select a cert file from File Explore\r |
90b24889 | 1691 | //\r |
d1050b9d MK |
1692 | FilePath = NULL;\r |
1693 | ChooseFile (NULL, NULL, NULL, &FilePath);\r | |
90b24889 | 1694 | \r |
d1050b9d MK |
1695 | if (FilePath != NULL) {\r |
1696 | UpdateCAFromFile (Private, FilePath);\r | |
1697 | FreePool (FilePath);\r | |
90b24889 WF |
1698 | }\r |
1699 | \r | |
d1050b9d | 1700 | break;\r |
90b24889 | 1701 | \r |
d1050b9d MK |
1702 | case KEY_SAVE_PRIVATE_KEY_TO_MEM:\r |
1703 | \r | |
1704 | if ((Private->FileContext != NULL) && (Private->FileContext->FHandle != NULL) &&\r | |
1705 | (Private->CurrentNic->UserSelectedProfile != NULL))\r | |
1706 | {\r | |
1707 | //\r | |
1708 | // Read Private Key file to Buffer\r | |
1709 | //\r | |
1710 | Profile = Private->CurrentNic->UserSelectedProfile;\r | |
1711 | if (Profile->PrivateKeyData != NULL) {\r | |
1712 | ZeroMem (Profile->PrivateKeyData, Profile->PrivateKeyDataSize);\r | |
1713 | FreePool (Profile->PrivateKeyData);\r | |
1714 | Profile->PrivateKeyData = NULL;\r | |
90b24889 | 1715 | }\r |
90b24889 | 1716 | \r |
d1050b9d MK |
1717 | Status = WifiMgrReadFileToBuffer (\r |
1718 | Private->FileContext,\r | |
1719 | &TempData,\r | |
1720 | &TempDataSize\r | |
1721 | );\r | |
1722 | if (EFI_ERROR (Status)) {\r | |
1723 | CreatePopUp (\r | |
1724 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
1725 | &Key,\r | |
1726 | L"ERROR: Can't read this private key file!",\r | |
1727 | NULL\r | |
1728 | );\r | |
1729 | } else {\r | |
1730 | ASSERT (Private->FileContext->FileName != NULL);\r | |
1731 | \r | |
1732 | Profile->PrivateKeyData = TempData;\r | |
1733 | Profile->PrivateKeyDataSize = TempDataSize;\r | |
1734 | StrCpyS (Profile->PrivateKeyName, WIFI_FILENAME_STR_MAX_SIZE, Private->FileContext->FileName);\r | |
1735 | \r | |
1736 | DEBUG ((\r | |
1737 | DEBUG_INFO,\r | |
1738 | "[WiFi Connection Manager] Private Key: %s has been enrolled! Size: %d\n",\r | |
1739 | Profile->PrivateKeyName,\r | |
1740 | Profile->PrivateKeyDataSize\r | |
1741 | ));\r | |
90b24889 | 1742 | }\r |
90b24889 WF |
1743 | }\r |
1744 | \r | |
d1050b9d | 1745 | break;\r |
90b24889 | 1746 | \r |
d1050b9d MK |
1747 | case KEY_SAVE_CERT_TO_MEM:\r |
1748 | \r | |
1749 | if ((Private->FileContext != NULL) && (Private->FileContext->FHandle != NULL) &&\r | |
1750 | (Private->CurrentNic->UserSelectedProfile != NULL))\r | |
1751 | {\r | |
1752 | //\r | |
1753 | // Read Cert file to Buffer\r | |
1754 | //\r | |
1755 | Profile = Private->CurrentNic->UserSelectedProfile;\r | |
90b24889 | 1756 | \r |
d1050b9d MK |
1757 | if (Private->FileType == FileTypeCACert) {\r |
1758 | if (Profile->CACertData != NULL) {\r | |
1759 | ZeroMem (Profile->CACertData, Profile->CACertSize);\r | |
1760 | FreePool (Profile->CACertData);\r | |
1761 | Profile->CACertData = NULL;\r | |
1762 | }\r | |
1763 | } else if (Private->FileType == FileTypeClientCert) {\r | |
1764 | if (Profile->ClientCertData != NULL) {\r | |
1765 | ZeroMem (Profile->ClientCertData, Profile->ClientCertSize);\r | |
1766 | FreePool (Profile->ClientCertData);\r | |
1767 | Profile->ClientCertData = NULL;\r | |
1768 | }\r | |
90b24889 | 1769 | } else {\r |
d1050b9d MK |
1770 | break;\r |
1771 | }\r | |
90b24889 | 1772 | \r |
d1050b9d MK |
1773 | Status = WifiMgrReadFileToBuffer (\r |
1774 | Private->FileContext,\r | |
1775 | &TempData,\r | |
1776 | &TempDataSize\r | |
1777 | );\r | |
1778 | if (EFI_ERROR (Status)) {\r | |
1779 | CreatePopUp (\r | |
1780 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
1781 | &Key,\r | |
1782 | L"ERROR: Can't read this certificate file!",\r | |
1783 | NULL\r | |
1784 | );\r | |
1785 | } else {\r | |
1786 | ASSERT (Private->FileContext->FileName != NULL);\r | |
1787 | if (Private->FileType == FileTypeCACert) {\r | |
1788 | Profile->CACertData = TempData;\r | |
1789 | Profile->CACertSize = TempDataSize;\r | |
1790 | StrCpyS (Profile->CACertName, WIFI_FILENAME_STR_MAX_SIZE, Private->FileContext->FileName);\r | |
1791 | DEBUG ((\r | |
1792 | DEBUG_INFO,\r | |
1793 | "[WiFi Connection Manager] CA Cert: %s has been enrolled! Size: %d\n",\r | |
1794 | Profile->CACertName,\r | |
1795 | Profile->CACertSize\r | |
1796 | ));\r | |
1797 | } else {\r | |
1798 | Profile->ClientCertData = TempData;\r | |
1799 | Profile->ClientCertSize = TempDataSize;\r | |
1800 | StrCpyS (Profile->ClientCertName, WIFI_FILENAME_STR_MAX_SIZE, Private->FileContext->FileName);\r | |
1801 | DEBUG ((\r | |
1802 | DEBUG_INFO,\r | |
1803 | "[WiFi Connection Manager] Client Cert: %s has been enrolled! Size: %d\n",\r | |
1804 | Profile->ClientCertName,\r | |
1805 | Profile->ClientCertSize\r | |
1806 | ));\r | |
1807 | }\r | |
90b24889 WF |
1808 | }\r |
1809 | }\r | |
90b24889 | 1810 | \r |
90b24889 | 1811 | break;\r |
d1050b9d MK |
1812 | \r |
1813 | case KEY_ADD_HIDDEN_NETWORK:\r | |
90b24889 WF |
1814 | \r |
1815 | //\r | |
d1050b9d | 1816 | // Add a Hidden Network\r |
90b24889 | 1817 | //\r |
d1050b9d MK |
1818 | if ((StrLen (IfrNvData->SSId) < SSID_MIN_LEN) ||\r |
1819 | (Private->HiddenNetworkCount >= HIDDEN_NETWORK_LIST_COUNT_MAX))\r | |
1820 | {\r | |
1821 | Status = EFI_ABORTED;\r | |
1822 | break;\r | |
1823 | } else {\r | |
1824 | //\r | |
1825 | // Check if this SSId is already in Hidden Network List\r | |
1826 | //\r | |
1827 | NET_LIST_FOR_EACH (Entry, &Private->HiddenNetworkList) {\r | |
1828 | HiddenNetwork = NET_LIST_USER_STRUCT_S (\r | |
1829 | Entry,\r | |
1830 | WIFI_HIDDEN_NETWORK_DATA,\r | |
1831 | Link,\r | |
1832 | WIFI_MGR_HIDDEN_NETWORK_SIGNATURE\r | |
1833 | );\r | |
1834 | if (StrCmp (HiddenNetwork->SSId, IfrNvData->SSId) == 0) {\r | |
1835 | Status = EFI_ABORTED;\r | |
1836 | break;\r | |
1837 | }\r | |
90b24889 WF |
1838 | }\r |
1839 | }\r | |
90b24889 | 1840 | \r |
d1050b9d MK |
1841 | HiddenNetwork = (WIFI_HIDDEN_NETWORK_DATA *)AllocateZeroPool (sizeof (WIFI_HIDDEN_NETWORK_DATA));\r |
1842 | if (HiddenNetwork == NULL) {\r | |
1843 | Status = EFI_OUT_OF_RESOURCES;\r | |
1844 | break;\r | |
1845 | }\r | |
90b24889 | 1846 | \r |
d1050b9d MK |
1847 | HiddenNetwork->Signature = WIFI_MGR_HIDDEN_NETWORK_SIGNATURE;\r |
1848 | StrCpyS (HiddenNetwork->SSId, SSID_STORAGE_SIZE, IfrNvData->SSId);\r | |
90b24889 | 1849 | \r |
d1050b9d MK |
1850 | InsertTailList (&Private->HiddenNetworkList, &HiddenNetwork->Link);\r |
1851 | Private->HiddenNetworkCount++;\r | |
90b24889 | 1852 | \r |
d1050b9d MK |
1853 | WifiMgrRefreshHiddenList (Private);\r |
1854 | break;\r | |
90b24889 | 1855 | \r |
d1050b9d | 1856 | case KEY_REMOVE_HIDDEN_NETWORK:\r |
90b24889 | 1857 | \r |
90b24889 | 1858 | //\r |
d1050b9d | 1859 | // Remove Hidden Networks\r |
90b24889 | 1860 | //\r |
d1050b9d MK |
1861 | Entry = GetFirstNode (&Private->HiddenNetworkList);\r |
1862 | RemoveCount = 0;\r | |
1863 | for (Index = 0; Index < Private->HiddenNetworkCount; Index++) {\r | |
1864 | if (IfrNvData->HiddenNetworkList[Index] != 0) {\r | |
1865 | HiddenNetwork = NET_LIST_USER_STRUCT_S (Entry, WIFI_HIDDEN_NETWORK_DATA, Link, WIFI_MGR_HIDDEN_NETWORK_SIGNATURE);\r | |
1866 | Entry = RemoveEntryList (Entry);\r | |
1867 | RemoveCount++;\r | |
1868 | \r | |
1869 | FreePool (HiddenNetwork);\r | |
1870 | } else {\r | |
1871 | Entry = GetNextNode (&Private->HiddenNetworkList, Entry);\r | |
1872 | }\r | |
90b24889 | 1873 | }\r |
90b24889 | 1874 | \r |
d1050b9d MK |
1875 | Private->HiddenNetworkCount -= RemoveCount;\r |
1876 | WifiMgrRefreshHiddenList (Private);\r | |
1877 | break;\r | |
1878 | \r | |
1879 | default:\r | |
1880 | \r | |
1881 | if ((QuestionId >= KEY_MAC_ENTRY_BASE) && (QuestionId < KEY_MAC_ENTRY_BASE + Private->NicCount)) {\r | |
1882 | //\r | |
1883 | // User selects a wireless NIC.\r | |
1884 | //\r | |
1885 | Status = WifiMgrSelectNic (Private, QuestionId);\r | |
1886 | if (EFI_ERROR (Status)) {\r | |
1887 | CreatePopUp (\r | |
1888 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
1889 | &Key,\r | |
1890 | L"ERROR: Fail to operate the wireless NIC!",\r | |
1891 | NULL\r | |
1892 | );\r | |
1893 | }\r | |
1894 | } else if (Private->CurrentNic != NULL) {\r | |
1895 | if ((QuestionId >= KEY_AVAILABLE_NETWORK_ENTRY_BASE) &&\r | |
1896 | (QuestionId <= KEY_AVAILABLE_NETWORK_ENTRY_BASE + Private->CurrentNic->MaxProfileIndex))\r | |
1897 | {\r | |
1898 | Status = WifiMgrUserSelectProfileToConnect (Private, QuestionId - KEY_AVAILABLE_NETWORK_ENTRY_BASE);\r | |
1899 | if (!EFI_ERROR (Status)) {\r | |
1900 | WifiMgrUpdateConnectMessage (Private->CurrentNic, FALSE, NULL);\r | |
1901 | }\r | |
90b24889 | 1902 | }\r |
90b24889 | 1903 | \r |
d1050b9d MK |
1904 | if (EFI_ERROR (Status)) {\r |
1905 | CreatePopUp (\r | |
1906 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
1907 | &Key,\r | |
1908 | L"ERROR: Fail to operate this profile!",\r | |
1909 | NULL\r | |
1910 | );\r | |
1911 | }\r | |
90b24889 | 1912 | }\r |
90b24889 | 1913 | \r |
d1050b9d | 1914 | break;\r |
90b24889 WF |
1915 | }\r |
1916 | } else if (Action == EFI_BROWSER_ACTION_CHANGED) {\r | |
1917 | switch (QuestionId) {\r | |
d1050b9d MK |
1918 | case KEY_SAVE_CERT_TO_MEM:\r |
1919 | case KEY_SAVE_PRIVATE_KEY_TO_MEM:\r | |
90b24889 | 1920 | \r |
d1050b9d MK |
1921 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r |
1922 | break;\r | |
90b24889 | 1923 | \r |
d1050b9d MK |
1924 | case KEY_NO_SAVE_CERT_TO_MEM:\r |
1925 | case KEY_NO_SAVE_PRIVATE_KEY_TO_MEM:\r | |
90b24889 | 1926 | \r |
d1050b9d MK |
1927 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;\r |
1928 | break;\r | |
90b24889 | 1929 | \r |
d1050b9d | 1930 | default:\r |
90b24889 | 1931 | \r |
d1050b9d MK |
1932 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r |
1933 | break;\r | |
90b24889 WF |
1934 | }\r |
1935 | } else if (Action == EFI_BROWSER_ACTION_RETRIEVE) {\r | |
90b24889 | 1936 | switch (QuestionId) {\r |
d1050b9d | 1937 | case KEY_REFRESH_NETWORK_LIST:\r |
90b24889 | 1938 | \r |
d1050b9d MK |
1939 | WifiMgrRefreshNetworkList (Private, IfrNvData);\r |
1940 | break;\r | |
90b24889 | 1941 | \r |
d1050b9d MK |
1942 | default:\r |
1943 | break;\r | |
90b24889 WF |
1944 | }\r |
1945 | }\r | |
1946 | \r | |
1947 | if (!EFI_ERROR (Status)) {\r | |
1948 | //\r | |
1949 | // Pass changed uncommitted data back to Form Browser.\r | |
1950 | //\r | |
1951 | BufferSize = sizeof (WIFI_MANAGER_IFR_NVDATA);\r | |
d1050b9d | 1952 | HiiSetBrowserData (&gWifiConfigFormSetGuid, mVendorStorageName, BufferSize, (UINT8 *)IfrNvData, NULL);\r |
90b24889 WF |
1953 | }\r |
1954 | \r | |
1955 | ZeroMem (IfrNvData, sizeof (WIFI_MANAGER_IFR_NVDATA));\r | |
1956 | FreePool (IfrNvData);\r | |
1957 | return Status;\r | |
1958 | }\r | |
1959 | \r | |
1960 | /**\r | |
1961 | Initialize the WiFi configuration form.\r | |
1962 | \r | |
1963 | @param[in] Private The pointer to the global private data structure.\r | |
1964 | \r | |
1965 | @retval EFI_SUCCESS The configuration form is initialized.\r | |
1966 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
1967 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
1968 | @retval Other Erros Returned Errors when installing protocols.\r | |
1969 | \r | |
1970 | **/\r | |
1971 | EFI_STATUS\r | |
1972 | WifiMgrDxeConfigFormInit (\r | |
d1050b9d MK |
1973 | WIFI_MGR_PRIVATE_DATA *Private\r |
1974 | )\r | |
90b24889 | 1975 | {\r |
d1050b9d | 1976 | EFI_STATUS Status;\r |
90b24889 WF |
1977 | \r |
1978 | if (Private == NULL) {\r | |
1979 | return EFI_INVALID_PARAMETER;\r | |
1980 | }\r | |
1981 | \r | |
1982 | Private->ConfigAccess.ExtractConfig = WifiMgrDxeHiiConfigAccessExtractConfig;\r | |
1983 | Private->ConfigAccess.RouteConfig = WifiMgrDxeHiiConfigAccessRouteConfig;\r | |
1984 | Private->ConfigAccess.Callback = WifiMgrDxeHiiConfigAccessCallback;\r | |
1985 | \r | |
1986 | //\r | |
1987 | // Install Device Path Protocol and Config Access protocol to driver handle.\r | |
1988 | //\r | |
1989 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
1990 | &Private->DriverHandle,\r | |
1991 | &gEfiDevicePathProtocolGuid,\r | |
1992 | &mWifiMgrDxeHiiVendorDevicePath,\r | |
1993 | &gEfiHiiConfigAccessProtocolGuid,\r | |
1994 | &Private->ConfigAccess,\r | |
1995 | NULL\r | |
1996 | );\r | |
1997 | if (EFI_ERROR (Status)) {\r | |
1998 | return Status;\r | |
1999 | }\r | |
2000 | \r | |
2001 | //\r | |
2002 | // Publish our HII data.\r | |
2003 | //\r | |
2004 | Private->RegisteredHandle = HiiAddPackages (\r | |
2005 | &gWifiConfigFormSetGuid,\r | |
2006 | Private->DriverHandle,\r | |
2007 | WifiConnectionManagerDxeStrings,\r | |
2008 | WifiConnectionManagerDxeBin,\r | |
2009 | NULL\r | |
2010 | );\r | |
2011 | if (Private->RegisteredHandle == NULL) {\r | |
2012 | gBS->UninstallMultipleProtocolInterfaces (\r | |
2013 | Private->DriverHandle,\r | |
2014 | &gEfiDevicePathProtocolGuid,\r | |
2015 | &mWifiMgrDxeHiiVendorDevicePath,\r | |
2016 | &gEfiHiiConfigAccessProtocolGuid,\r | |
2017 | &Private->ConfigAccess,\r | |
2018 | NULL\r | |
2019 | );\r | |
2020 | return EFI_OUT_OF_RESOURCES;\r | |
2021 | }\r | |
2022 | \r | |
2023 | Private->FileContext = AllocateZeroPool (sizeof (WIFI_MGR_FILE_CONTEXT));\r | |
2024 | if (Private->FileContext == NULL) {\r | |
2025 | return EFI_OUT_OF_RESOURCES;\r | |
2026 | }\r | |
2027 | \r | |
2028 | return EFI_SUCCESS;\r | |
2029 | }\r | |
2030 | \r | |
2031 | /**\r | |
2032 | Unload the WiFi configuration form.\r | |
2033 | \r | |
2034 | @param[in] Private The pointer to the global private data structure.\r | |
2035 | \r | |
2036 | @retval EFI_SUCCESS The configuration form is unloaded successfully.\r | |
2037 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
2038 | @retval Other Errors Returned Erros when uninstalling protocols.\r | |
2039 | \r | |
2040 | **/\r | |
2041 | EFI_STATUS\r | |
2042 | WifiMgrDxeConfigFormUnload (\r | |
d1050b9d MK |
2043 | WIFI_MGR_PRIVATE_DATA *Private\r |
2044 | )\r | |
90b24889 | 2045 | {\r |
d1050b9d | 2046 | EFI_STATUS Status;\r |
90b24889 WF |
2047 | \r |
2048 | if (Private == NULL) {\r | |
2049 | return EFI_INVALID_PARAMETER;\r | |
2050 | }\r | |
2051 | \r | |
2052 | if (Private->FileContext != NULL) {\r | |
90b24889 WF |
2053 | if (Private->FileContext->FHandle != NULL) {\r |
2054 | Private->FileContext->FHandle->Close (Private->FileContext->FHandle);\r | |
2055 | }\r | |
2056 | \r | |
2057 | if (Private->FileContext->FileName != NULL) {\r | |
2058 | FreePool (Private->FileContext->FileName);\r | |
2059 | }\r | |
d1050b9d | 2060 | \r |
90b24889 WF |
2061 | FreePool (Private->FileContext);\r |
2062 | }\r | |
2063 | \r | |
d1050b9d | 2064 | HiiRemovePackages (Private->RegisteredHandle);\r |
90b24889 WF |
2065 | \r |
2066 | Status = gBS->UninstallMultipleProtocolInterfaces (\r | |
d1050b9d MK |
2067 | Private->DriverHandle,\r |
2068 | &gEfiDevicePathProtocolGuid,\r | |
2069 | &mWifiMgrDxeHiiVendorDevicePath,\r | |
2070 | &gEfiHiiConfigAccessProtocolGuid,\r | |
2071 | &Private->ConfigAccess,\r | |
2072 | NULL\r | |
2073 | );\r | |
90b24889 WF |
2074 | \r |
2075 | return Status;\r | |
2076 | }\r |