]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Application/VConfig/VConfig.c
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / NetworkPkg / Application / VConfig / VConfig.c
CommitLineData
a3bcde70
HT
1/** @file\r
2 Shell application for VLAN configuration.\r
3\r
f75a7f56 4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
a3bcde70 5\r
ecf98fbc 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a3bcde70
HT
7\r
8**/\r
9\r
10#include <Uefi.h>\r
11\r
12#include <Protocol/VlanConfig.h>\r
13\r
14#include <Library/UefiApplicationEntryPoint.h>\r
15#include <Library/UefiLib.h>\r
16#include <Library/ShellLib.h>\r
17#include <Library/MemoryAllocationLib.h>\r
18#include <Library/HiiLib.h>\r
19#include <Library/UefiBootServicesTableLib.h>\r
be6cd654 20#include <Library/UefiHiiServicesLib.h>\r
a3bcde70
HT
21#include <Library/NetLib.h>\r
22\r
be6cd654
ZL
23//\r
24// String token ID of VConfig command help message text.\r
25//\r
d1050b9d 26GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringVConfigHelpTokenId = STRING_TOKEN (STR_VCONFIG_HELP);\r
be6cd654 27\r
d1050b9d
MK
28#define INVALID_NIC_INDEX 0xffff\r
29#define INVALID_VLAN_ID 0xffff\r
a3bcde70
HT
30\r
31//\r
32// This is the generated String package data for all .UNI files.\r
33// This data array is ready to be used as input of HiiAddPackages() to\r
34// create a packagelist (which contains Form packages, String packages, etc).\r
35//\r
d1050b9d 36extern UINT8 VConfigStrings[];\r
a3bcde70 37\r
d1050b9d
MK
38EFI_HANDLE mImageHandle = NULL;\r
39EFI_HII_HANDLE mHiiHandle = NULL;\r
a3bcde70
HT
40\r
41SHELL_PARAM_ITEM mParamList[] = {\r
42 {\r
43 L"-l",\r
44 TypeValue\r
45 },\r
46 {\r
47 L"-a",\r
48 TypeMaxValue\r
49 },\r
50 {\r
51 L"-d",\r
52 TypeValue\r
53 },\r
54 {\r
55 NULL,\r
56 TypeMax\r
57 }\r
58};\r
59\r
60/**\r
61 Locate the network interface handle buffer.\r
62\r
63 @param[out] NumberOfHandles Pointer to the number of handles.\r
64 @param[out] HandleBuffer Pointer to the buffer to store the returned handles.\r
65\r
66**/\r
67VOID\r
68LocateNicHandleBuffer (\r
d1050b9d
MK
69 OUT UINTN *NumberOfHandles,\r
70 OUT EFI_HANDLE **HandleBuffer\r
a3bcde70
HT
71 )\r
72{\r
73 EFI_STATUS Status;\r
74\r
d1050b9d
MK
75 *NumberOfHandles = 0;\r
76 *HandleBuffer = NULL;\r
a3bcde70
HT
77\r
78 Status = gBS->LocateHandleBuffer (\r
79 ByProtocol,\r
80 &gEfiVlanConfigProtocolGuid,\r
81 NULL,\r
82 NumberOfHandles,\r
83 HandleBuffer\r
84 );\r
85 if (EFI_ERROR (Status)) {\r
86 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_LOCATE_FAIL), mHiiHandle, Status);\r
87 }\r
88}\r
89\r
90/**\r
91 Extract the decimal index from the network interface name.\r
92\r
93 @param[in] Name Name of the network interface.\r
94\r
95 @retval INVALID_NIC_INDEX Failed to extract the network interface index.\r
96 @return others The network interface index.\r
97\r
98**/\r
99UINTN\r
100NicNameToIndex (\r
d1050b9d 101 IN CHAR16 *Name\r
a3bcde70
HT
102 )\r
103{\r
104 CHAR16 *Str;\r
105\r
106 Str = Name + 3;\r
107 if ((StrnCmp (Name, L"eth", 3) != 0) || (*Str == 0)) {\r
108 return INVALID_NIC_INDEX;\r
109 }\r
110\r
111 while (*Str != 0) {\r
112 if ((*Str < L'0') || (*Str > L'9')) {\r
113 return INVALID_NIC_INDEX;\r
114 }\r
115\r
116 Str++;\r
117 }\r
118\r
d1050b9d 119 return (UINT16)StrDecimalToUintn (Name + 3);\r
a3bcde70
HT
120}\r
121\r
122/**\r
123 Find network interface device handle by its name.\r
124\r
125 @param[in] Name Name of the network interface.\r
126\r
127 @retval NULL Cannot find the network interface.\r
128 @return others Handle of the network interface.\r
129\r
130**/\r
131EFI_HANDLE\r
132NicNameToHandle (\r
d1050b9d 133 IN CHAR16 *Name\r
a3bcde70
HT
134 )\r
135{\r
136 UINTN NumberOfHandles;\r
137 EFI_HANDLE *HandleBuffer;\r
138 UINTN Index;\r
139 EFI_HANDLE Handle;\r
140\r
141 //\r
142 // Find all NIC handles.\r
143 //\r
144 LocateNicHandleBuffer (&NumberOfHandles, &HandleBuffer);\r
145 if (NumberOfHandles == 0) {\r
146 return NULL;\r
147 }\r
148\r
149 Index = NicNameToIndex (Name);\r
150 if (Index >= NumberOfHandles) {\r
151 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_INVALID_IF), mHiiHandle, Name);\r
152 Handle = NULL;\r
153 } else {\r
154 Handle = HandleBuffer[Index];\r
155 }\r
156\r
157 FreePool (HandleBuffer);\r
158 return Handle;\r
159}\r
160\r
161/**\r
162 Open VlanConfig protocol from a handle.\r
163\r
164 @param[in] Handle The handle to open the VlanConfig protocol.\r
165\r
166 @return The VlanConfig protocol interface.\r
167\r
168**/\r
169EFI_VLAN_CONFIG_PROTOCOL *\r
170OpenVlanConfigProtocol (\r
d1050b9d 171 IN EFI_HANDLE Handle\r
a3bcde70
HT
172 )\r
173{\r
174 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r
175\r
176 VlanConfig = NULL;\r
177 gBS->OpenProtocol (\r
178 Handle,\r
179 &gEfiVlanConfigProtocolGuid,\r
d1050b9d 180 (VOID **)&VlanConfig,\r
a3bcde70
HT
181 mImageHandle,\r
182 Handle,\r
183 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
184 );\r
185\r
186 return VlanConfig;\r
187}\r
188\r
189/**\r
190 Close VlanConfig protocol of a handle.\r
191\r
192 @param[in] Handle The handle to close the VlanConfig protocol.\r
193\r
194**/\r
195VOID\r
196CloseVlanConfigProtocol (\r
d1050b9d 197 IN EFI_HANDLE Handle\r
a3bcde70
HT
198 )\r
199{\r
200 gBS->CloseProtocol (\r
201 Handle,\r
202 &gEfiVlanConfigProtocolGuid,\r
203 mImageHandle,\r
204 Handle\r
205 );\r
206}\r
207\r
208/**\r
209 Display VLAN configuration of a network interface.\r
210\r
211 @param[in] Handle Handle of the network interface.\r
212 @param[in] NicIndex Index of the network interface.\r
213\r
214**/\r
215VOID\r
216ShowNicVlanInfo (\r
d1050b9d
MK
217 IN EFI_HANDLE Handle,\r
218 IN UINTN NicIndex\r
a3bcde70
HT
219 )\r
220{\r
221 CHAR16 *MacStr;\r
222 EFI_STATUS Status;\r
223 UINTN Index;\r
224 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r
225 UINT16 NumberOfVlan;\r
226 EFI_VLAN_FIND_DATA *VlanData;\r
227\r
228 VlanConfig = OpenVlanConfigProtocol (Handle);\r
229 if (VlanConfig == NULL) {\r
d1050b9d 230 return;\r
a3bcde70
HT
231 }\r
232\r
d1050b9d
MK
233 MacStr = NULL;\r
234 Status = NetLibGetMacString (Handle, mImageHandle, &MacStr);\r
a3bcde70
HT
235 if (EFI_ERROR (Status)) {\r
236 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_MAC_FAIL), mHiiHandle, Status);\r
237 goto Exit;\r
238 }\r
239\r
240 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_ETH_MAC), mHiiHandle, NicIndex, MacStr);\r
241\r
242 Status = VlanConfig->Find (VlanConfig, NULL, &NumberOfVlan, &VlanData);\r
243 if (EFI_ERROR (Status)) {\r
244 if (Status == EFI_NOT_FOUND) {\r
245 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_VLAN), mHiiHandle);\r
246 } else {\r
247 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_FIND_FAIL), mHiiHandle, Status);\r
248 }\r
249\r
250 goto Exit;\r
251 }\r
252\r
253 for (Index = 0; Index < NumberOfVlan; Index++) {\r
254 ShellPrintHiiEx (\r
255 -1,\r
256 -1,\r
257 NULL,\r
258 STRING_TOKEN (STR_VCONFIG_VLAN_DISPLAY),\r
259 mHiiHandle,\r
260 VlanData[Index].VlanId,\r
261 VlanData[Index].Priority\r
262 );\r
263 }\r
264\r
265 FreePool (VlanData);\r
266\r
267Exit:\r
268 CloseVlanConfigProtocol (Handle);\r
269\r
270 if (MacStr != NULL) {\r
271 FreePool (MacStr);\r
272 }\r
273}\r
274\r
275/**\r
276 Display the VLAN configuration of all, or a specified network interface.\r
277\r
278 @param[in] Name Name of the network interface. If NULL, the VLAN\r
279 configuration of all network will be displayed.\r
280\r
281**/\r
282VOID\r
283DisplayVlan (\r
d1050b9d 284 IN CHAR16 *Name OPTIONAL\r
a3bcde70
HT
285 )\r
286{\r
287 UINTN NumberOfHandles;\r
288 EFI_HANDLE *HandleBuffer;\r
289 UINTN Index;\r
290 EFI_HANDLE NicHandle;\r
291\r
292 if (Name != NULL) {\r
293 //\r
294 // Display specified NIC\r
295 //\r
296 NicHandle = NicNameToHandle (Name);\r
297 if (NicHandle == NULL) {\r
d1050b9d 298 return;\r
a3bcde70
HT
299 }\r
300\r
301 ShowNicVlanInfo (NicHandle, 0);\r
d1050b9d 302 return;\r
a3bcde70
HT
303 }\r
304\r
305 //\r
306 // Find all NIC handles\r
307 //\r
308 LocateNicHandleBuffer (&NumberOfHandles, &HandleBuffer);\r
309 if (NumberOfHandles == 0) {\r
d1050b9d 310 return;\r
a3bcde70
HT
311 }\r
312\r
313 for (Index = 0; Index < NumberOfHandles; Index++) {\r
314 ShowNicVlanInfo (HandleBuffer[Index], Index);\r
315 }\r
316\r
317 FreePool (HandleBuffer);\r
318}\r
319\r
320/**\r
321 Convert a NULL-terminated unicode decimal VLAN ID string to VLAN ID.\r
322\r
323 @param[in] String Pointer to VLAN ID string from user input.\r
324\r
325 @retval Value translated from String, or INVALID_VLAN_ID is string is invalid.\r
326\r
327**/\r
328UINT16\r
329StrToVlanId (\r
d1050b9d 330 IN CHAR16 *String\r
a3bcde70
HT
331 )\r
332{\r
333 CHAR16 *Str;\r
334\r
335 if (String == NULL) {\r
336 return INVALID_VLAN_ID;\r
337 }\r
338\r
339 Str = String;\r
340 while ((*Str >= '0') && (*Str <= '9')) {\r
341 Str++;\r
342 }\r
343\r
344 if (*Str != 0) {\r
345 return INVALID_VLAN_ID;\r
346 }\r
347\r
d1050b9d 348 return (UINT16)StrDecimalToUintn (String);\r
a3bcde70
HT
349}\r
350\r
351/**\r
352 Add a VLAN device.\r
353\r
354 @param[in] ParamStr Parameter string from user input.\r
355\r
356**/\r
357VOID\r
358AddVlan (\r
d1050b9d 359 IN CHAR16 *ParamStr\r
a3bcde70
HT
360 )\r
361{\r
362 CHAR16 *Name;\r
363 CHAR16 *VlanIdStr;\r
364 CHAR16 *PriorityStr;\r
365 CHAR16 *StrPtr;\r
366 BOOLEAN IsSpace;\r
367 UINTN VlanId;\r
368 UINTN Priority;\r
369 EFI_HANDLE Handle;\r
370 EFI_HANDLE VlanHandle;\r
371 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r
372 EFI_STATUS Status;\r
373\r
d1050b9d
MK
374 VlanConfig = NULL;\r
375 Priority = 0;\r
a3bcde70
HT
376\r
377 if (ParamStr == NULL) {\r
378 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle);\r
d1050b9d 379 return;\r
a3bcde70
HT
380 }\r
381\r
382 StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr);\r
383 if (StrPtr == NULL) {\r
d1050b9d 384 return;\r
a3bcde70
HT
385 }\r
386\r
387 Name = StrPtr;\r
388 VlanIdStr = NULL;\r
389 PriorityStr = NULL;\r
390 IsSpace = FALSE;\r
391 while (*StrPtr != 0) {\r
392 if (*StrPtr == L' ') {\r
393 *StrPtr = 0;\r
394 IsSpace = TRUE;\r
395 } else {\r
396 if (IsSpace) {\r
397 //\r
398 // Start of a parameter.\r
399 //\r
400 if (VlanIdStr == NULL) {\r
401 //\r
402 // 2nd parameter is VLAN ID.\r
403 //\r
404 VlanIdStr = StrPtr;\r
405 } else if (PriorityStr == NULL) {\r
406 //\r
407 // 3rd parameter is Priority.\r
408 //\r
409 PriorityStr = StrPtr;\r
410 } else {\r
411 //\r
412 // Ignore else parameters.\r
413 //\r
414 break;\r
415 }\r
416 }\r
417\r
418 IsSpace = FALSE;\r
419 }\r
420\r
421 StrPtr++;\r
422 }\r
423\r
424 Handle = NicNameToHandle (Name);\r
425 if (Handle == NULL) {\r
426 goto Exit;\r
427 }\r
428\r
429 VlanConfig = OpenVlanConfigProtocol (Handle);\r
430 if (VlanConfig == NULL) {\r
431 goto Exit;\r
432 }\r
433\r
434 //\r
435 // Check VLAN ID.\r
436 //\r
437 if ((VlanIdStr == NULL) || (*VlanIdStr == 0)) {\r
438 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_VID), mHiiHandle);\r
439 goto Exit;\r
440 }\r
441\r
442 VlanId = StrToVlanId (VlanIdStr);\r
443 if (VlanId > 4094) {\r
444 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_INVALID_VID), mHiiHandle, VlanIdStr);\r
445 goto Exit;\r
446 }\r
447\r
448 //\r
449 // Check Priority.\r
450 //\r
451 if ((PriorityStr != NULL) && (*PriorityStr != 0)) {\r
452 Priority = StrDecimalToUintn (PriorityStr);\r
453 if (Priority > 7) {\r
454 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_INVALID_PRIORITY), mHiiHandle, PriorityStr);\r
455 goto Exit;\r
456 }\r
457 }\r
458\r
459 //\r
460 // Set VLAN\r
461 //\r
d1050b9d 462 Status = VlanConfig->Set (VlanConfig, (UINT16)VlanId, (UINT8)Priority);\r
a3bcde70
HT
463 if (EFI_ERROR (Status)) {\r
464 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_SET_FAIL), mHiiHandle, Status);\r
465 goto Exit;\r
466 }\r
467\r
468 //\r
469 // Connect the VLAN device.\r
470 //\r
d1050b9d 471 VlanHandle = NetLibGetVlanHandle (Handle, (UINT16)VlanId);\r
a3bcde70
HT
472 if (VlanHandle != NULL) {\r
473 gBS->ConnectController (VlanHandle, NULL, NULL, TRUE);\r
474 }\r
475\r
476 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_SET_SUCCESS), mHiiHandle);\r
477\r
478Exit:\r
479 if (VlanConfig != NULL) {\r
480 CloseVlanConfigProtocol (Handle);\r
481 }\r
482\r
483 FreePool (Name);\r
484}\r
485\r
486/**\r
487 Remove a VLAN device.\r
488\r
489 @param[in] ParamStr Parameter string from user input.\r
490\r
491**/\r
492VOID\r
493DeleteVlan (\r
d1050b9d 494 IN CHAR16 *ParamStr\r
a3bcde70
HT
495 )\r
496{\r
497 CHAR16 *Name;\r
498 CHAR16 *VlanIdStr;\r
499 CHAR16 *StrPtr;\r
500 UINTN VlanId;\r
501 EFI_HANDLE Handle;\r
502 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r
503 EFI_STATUS Status;\r
504 UINT16 NumberOfVlan;\r
505 EFI_VLAN_FIND_DATA *VlanData;\r
506\r
507 VlanConfig = NULL;\r
508\r
509 if (ParamStr == NULL) {\r
510 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_IF), mHiiHandle);\r
d1050b9d 511 return;\r
a3bcde70
HT
512 }\r
513\r
514 StrPtr = AllocateCopyPool (StrSize (ParamStr), ParamStr);\r
515 if (StrPtr == NULL) {\r
d1050b9d 516 return;\r
a3bcde70
HT
517 }\r
518\r
519 Name = StrPtr;\r
520 VlanIdStr = NULL;\r
521 while (*StrPtr != 0) {\r
522 if (*StrPtr == L'.') {\r
523 *StrPtr = 0;\r
524 VlanIdStr = StrPtr + 1;\r
525 break;\r
526 }\r
527\r
528 StrPtr++;\r
529 }\r
530\r
531 Handle = NicNameToHandle (Name);\r
532 if (Handle == NULL) {\r
533 goto Exit;\r
534 }\r
535\r
536 VlanConfig = OpenVlanConfigProtocol (Handle);\r
537 if (VlanConfig == NULL) {\r
538 goto Exit;\r
539 }\r
540\r
541 //\r
542 // Check VLAN ID\r
543 //\r
d1050b9d 544 if ((VlanIdStr == NULL) || (*VlanIdStr == 0)) {\r
a3bcde70
HT
545 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_VID), mHiiHandle);\r
546 goto Exit;\r
547 }\r
548\r
549 VlanId = StrToVlanId (VlanIdStr);\r
550 if (VlanId > 4094) {\r
551 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_INVALID_VID), mHiiHandle, VlanIdStr);\r
552 goto Exit;\r
553 }\r
554\r
555 //\r
556 // Delete VLAN.\r
557 //\r
d1050b9d 558 Status = VlanConfig->Remove (VlanConfig, (UINT16)VlanId);\r
a3bcde70
HT
559 if (EFI_ERROR (Status)) {\r
560 if (Status == EFI_NOT_FOUND) {\r
561 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NOT_FOUND), mHiiHandle);\r
562 } else {\r
563 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_REMOVE_FAIL), mHiiHandle, Status);\r
564 }\r
565\r
566 goto Exit;\r
567 }\r
568\r
569 //\r
570 // Check whether this is the last VLAN to remove.\r
571 //\r
572 Status = VlanConfig->Find (VlanConfig, NULL, &NumberOfVlan, &VlanData);\r
573 if (EFI_ERROR (Status)) {\r
574 //\r
575 // This is the last VLAN to remove, try to connect the controller handle.\r
576 //\r
577 gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
578 } else {\r
579 FreePool (VlanData);\r
580 }\r
581\r
582 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_REMOVE_SUCCESS), mHiiHandle);\r
583\r
584Exit:\r
585 if (VlanConfig != NULL) {\r
586 CloseVlanConfigProtocol (Handle);\r
587 }\r
588\r
589 FreePool (Name);\r
590}\r
591\r
592/**\r
593 The actual entry point for the application.\r
594\r
595 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
596 @param[in] SystemTable A pointer to the EFI System Table.\r
597\r
598 @retval EFI_SUCCESS The entry point executed successfully.\r
599 @retval other Some error occur when executing this entry point.\r
600\r
601**/\r
602EFI_STATUS\r
603EFIAPI\r
604VlanConfigMain (\r
605 IN EFI_HANDLE ImageHandle,\r
606 IN EFI_SYSTEM_TABLE *SystemTable\r
607 )\r
608{\r
d1050b9d
MK
609 LIST_ENTRY *List;\r
610 CONST CHAR16 *Str;\r
611 EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
612 EFI_STATUS Status;\r
a3bcde70
HT
613\r
614 mImageHandle = ImageHandle;\r
f75a7f56 615\r
be6cd654
ZL
616 //\r
617 // Retrieve HII package list from ImageHandle\r
618 //\r
619 Status = gBS->OpenProtocol (\r
620 ImageHandle,\r
621 &gEfiHiiPackageListProtocolGuid,\r
d1050b9d 622 (VOID **)&PackageList,\r
be6cd654
ZL
623 ImageHandle,\r
624 NULL,\r
625 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
626 );\r
627 if (EFI_ERROR (Status)) {\r
628 return Status;\r
629 }\r
a3bcde70
HT
630\r
631 //\r
be6cd654 632 // Publish HII package list to HII Database.\r
a3bcde70 633 //\r
be6cd654 634 Status = gHiiDatabase->NewPackageList (\r
d1050b9d
MK
635 gHiiDatabase,\r
636 PackageList,\r
637 NULL,\r
638 &mHiiHandle\r
639 );\r
be6cd654
ZL
640 if (EFI_ERROR (Status)) {\r
641 return Status;\r
642 }\r
643\r
a3bcde70
HT
644 if (mHiiHandle == NULL) {\r
645 return EFI_SUCCESS;\r
646 }\r
647\r
648 List = NULL;\r
649 ShellCommandLineParseEx (mParamList, &List, NULL, FALSE, FALSE);\r
650 if (List == NULL) {\r
651 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_ARG), mHiiHandle);\r
652 goto Exit;\r
653 }\r
654\r
a3bcde70
HT
655 if (ShellCommandLineGetFlag (List, L"-l")) {\r
656 Str = ShellCommandLineGetValue (List, L"-l");\r
d1050b9d 657 DisplayVlan ((CHAR16 *)Str);\r
a3bcde70
HT
658 goto Exit;\r
659 }\r
660\r
661 if (ShellCommandLineGetFlag (List, L"-a")) {\r
662 Str = ShellCommandLineGetValue (List, L"-a");\r
d1050b9d 663 AddVlan ((CHAR16 *)Str);\r
a3bcde70
HT
664 goto Exit;\r
665 }\r
666\r
667 if (ShellCommandLineGetFlag (List, L"-d")) {\r
668 Str = ShellCommandLineGetValue (List, L"-d");\r
d1050b9d 669 DeleteVlan ((CHAR16 *)Str);\r
a3bcde70
HT
670 goto Exit;\r
671 }\r
672\r
673 //\r
674 // No valid argument till now.\r
675 //\r
676 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_ARG), mHiiHandle);\r
677\r
678Exit:\r
679 if (List != NULL) {\r
680 ShellCommandLineFreeVarList (List);\r
681 }\r
682\r
683 //\r
684 // Remove our string package from HII database.\r
685 //\r
686 HiiRemovePackages (mHiiHandle);\r
687\r
688 return EFI_SUCCESS;\r
689}\r