2 The implementation for Shell command IfConfig6.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellNetwork2CommandsLib.h"
24 VarCheckReserved
= -1,
38 } VAR_CHECK_FLAG_TYPE
;
40 #define MACADDRMAXSIZE 32
41 #define PREFIXMAXLEN 16
43 typedef struct _IFCONFIG6_INTERFACE_CB
{
46 EFI_IP6_CONFIG_PROTOCOL
*IfCfg
;
47 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
48 EFI_IP6_CONFIG_INTERFACE_ID
*IfId
;
49 EFI_IP6_CONFIG_POLICY Policy
;
50 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS Xmits
;
52 EFI_IPv6_ADDRESS DnsAddr
[1];
53 } IFCONFIG6_INTERFACE_CB
;
55 typedef struct _ARG_LIST ARG_LIST
;
62 typedef struct _IFCONFIG6_PRIVATE_DATA
{
63 EFI_HANDLE ImageHandle
;
69 } IFCONFIG6_PRIVATE_DATA
;
71 typedef struct _VAR_CHECK_ITEM
{
75 VAR_CHECK_FLAG_TYPE FlagType
;
79 SHELL_PARAM_ITEM mIfConfig6CheckList
[] = {
106 VAR_CHECK_ITEM mIfConfig6SetCheckList
[] = {
158 Split a string with specified separator and save the substring to a list.
160 @param[in] String The pointer of the input string.
161 @param[in] Separator The specified separator.
163 @return The pointer of headnode of ARG_LIST.
167 IfConfig6SplitStrToList (
168 IN CONST CHAR16
*String
,
177 if (String
== NULL
|| *String
== L
'\0') {
182 // Copy the CONST string to a local copy.
184 Str
= AllocateCopyPool (StrSize (String
), String
);
185 ASSERT (Str
!= NULL
);
189 // init a node for the list head.
191 ArgNode
= (ARG_LIST
*) AllocateZeroPool (sizeof (ARG_LIST
));
192 ASSERT (ArgNode
!= NULL
);
196 // Split the local copy and save in the list node.
198 while (*Str
!= L
'\0') {
199 if (*Str
== Separator
) {
201 ArgNode
->Arg
= ArgStr
;
203 ArgNode
->Next
= (ARG_LIST
*) AllocateZeroPool (sizeof (ARG_LIST
));
204 ASSERT (ArgNode
->Next
!= NULL
);
205 ArgNode
= ArgNode
->Next
;
211 ArgNode
->Arg
= ArgStr
;
212 ArgNode
->Next
= NULL
;
218 Check the correctness of input Args with '-s' option.
220 @param[in] CheckList The pointer of VAR_CHECK_ITEM array.
221 @param[in] Name The pointer of input arg.
222 @param[in] Init The switch to execute the check.
224 @return The value of VAR_CHECK_CODE.
228 IfConfig6RetriveCheckListByName(
229 IN VAR_CHECK_ITEM
*CheckList
,
234 STATIC UINT32 CheckDuplicate
;
235 STATIC UINT32 CheckConflict
;
236 VAR_CHECK_CODE RtCode
;
248 Arg
= CheckList
[Index
];
251 // Check the Duplicated/Conflicted/Unknown input Args.
253 while (Arg
.FlagStr
!= NULL
) {
254 if (StrCmp (Arg
.FlagStr
, Name
) == 0) {
256 if (CheckDuplicate
& Arg
.FlagID
) {
257 RtCode
= VarCheckDuplicate
;
261 if (CheckConflict
& Arg
.ConflictMask
) {
262 RtCode
= VarCheckConflict
;
266 CheckDuplicate
|= Arg
.FlagID
;
267 CheckConflict
|= Arg
.ConflictMask
;
271 Arg
= CheckList
[++Index
];
274 if (Arg
.FlagStr
== NULL
) {
275 RtCode
= VarCheckUnknown
;
282 The notify function of create event when performing a manual config.
284 @param[in] Event The event this notify function registered to.
285 @param[in] Context Pointer to the context data registered to the event.
290 IfConfig6ManualAddressNotify (
295 *((BOOLEAN
*) Context
) = TRUE
;
301 @param[in] Node The pointer of MAC address buffer.
302 @param[in] Size The size of MAC address buffer.
306 IfConfig6PrintMacAddr (
313 ASSERT (Size
<= MACADDRMAXSIZE
);
315 for (Index
= 0; Index
< Size
; Index
++) {
316 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_BODY
), gShellNetwork2HiiHandle
, Node
[Index
]);
317 if (Index
+ 1 < Size
) {
318 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
322 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
328 @param[in] Ip The pointer of Ip bufffer in EFI_IPv6_ADDRESS format.
329 @param[in] PrefixLen The pointer of PrefixLen that describes the size Prefix.
333 IfConfig6PrintIpAddr (
334 IN EFI_IPv6_ADDRESS
*Ip
,
343 for (Index
= 0; Index
< PREFIXMAXLEN
; Index
= Index
+ 2) {
345 if (!Short
&& (Index
+ 1 < PREFIXMAXLEN
) && (Index
% 2 == 0) && (Ip
->Addr
[Index
] == 0) && (Ip
->Addr
[Index
+ 1] == 0)) {
347 // Deal with the case of ::.
351 // :: is at the beginning of the address.
353 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
355 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
357 while ((Ip
->Addr
[Index
] == 0) && (Ip
->Addr
[Index
+ 1] == 0) && (Index
< PREFIXMAXLEN
)) {
359 if (Index
> PREFIXMAXLEN
- 2) {
366 if (Index
== PREFIXMAXLEN
) {
368 // :: is at the end of the address.
374 if (Index
< PREFIXMAXLEN
- 1) {
375 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY
), gShellNetwork2HiiHandle
, Ip
->Addr
[Index
]);
376 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY
), gShellNetwork2HiiHandle
, Ip
->Addr
[Index
+ 1]);
379 if (Index
+ 2 < PREFIXMAXLEN
) {
380 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
384 if (PrefixLen
!= NULL
) {
385 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_PREFIX_LEN
), gShellNetwork2HiiHandle
, *PrefixLen
);
390 Pick up host IPv6 address in string format from Args with "-s" option and convert it to EFI_IP6_CONFIG_MANUAL_ADDRESS format.
392 @param[in, out] Arg The pointer of the address of ARG_LIST which save Args with the "-s" option.
393 @param[out] Buf The pointer of the address of EFI_IP6_CONFIG_MANUAL_ADDRESS.
394 @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
396 @retval EFI_SUCCESS The convertion is successful.
397 @retval Others Does't find the host address, or it is an invalid IPv6 address in string format.
401 IfConfig6ParseManualAddressList (
402 IN OUT ARG_LIST
**Arg
,
403 OUT EFI_IP6_CONFIG_MANUAL_ADDRESS
**Buf
,
408 EFI_IP6_CONFIG_MANUAL_ADDRESS
*AddrBuf
;
410 EFI_IPv6_ADDRESS Address
;
419 Status
= EFI_SUCCESS
;
422 // Go through the list to check the correctness of input host ip6 address.
424 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
426 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
428 if (EFI_ERROR (Status
)) {
435 VarArg
= VarArg
->Next
;
440 return EFI_INVALID_PARAMETER
;
443 AddrBuf
= AllocateZeroPool (AddrCnt
* sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
));
444 ASSERT (AddrBuf
!= NULL
);
448 Status
= EFI_SUCCESS
;
451 // Go through the list to fill in the EFI_IP6_CONFIG_MANUAL_ADDRESS structure.
453 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
455 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
457 if (EFI_ERROR (Status
)) {
462 // If prefix length is not set, set it as Zero here. In the IfConfigSetInterfaceInfo()
463 // Zero prefix, length will be transfered to default prefix length.
465 if (Prefix
== 0xFF) {
468 AddrBuf
[AddrCnt
].IsAnycast
= FALSE
;
469 AddrBuf
[AddrCnt
].PrefixLength
= Prefix
;
470 IP6_COPY_ADDRESS (&AddrBuf
[AddrCnt
].Address
, &Address
);
471 VarArg
= VarArg
->Next
;
477 if (EFI_ERROR (Status
) && (Status
!= EFI_INVALID_PARAMETER
)) {
482 *BufSize
= AddrCnt
* sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
);
493 Pick up gw/dns IPv6 address in string format from Args with "-s" option and convert it to EFI_IPv6_ADDRESS format.
495 @param[in, out] Arg The pointer of the address of ARG_LIST that save Args with the "-s" option.
496 @param[out] Buf The pointer of the address of EFI_IPv6_ADDRESS.
497 @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
499 @retval EFI_SUCCESS The conversion is successful.
500 @retval Others Doesn't find the host address, or it is an invalid IPv6 address in string format.
504 IfConfig6ParseGwDnsAddressList (
505 IN OUT ARG_LIST
**Arg
,
506 OUT EFI_IPv6_ADDRESS
**Buf
,
511 EFI_IPv6_ADDRESS
*AddrBuf
;
513 EFI_IPv6_ADDRESS Address
;
521 Status
= EFI_SUCCESS
;
524 // Go through the list to check the correctness of input gw/dns address.
526 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
528 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
530 if (EFI_ERROR (Status
)) {
537 VarArg
= VarArg
->Next
;
542 return EFI_INVALID_PARAMETER
;
545 AddrBuf
= AllocateZeroPool (AddrCnt
* sizeof (EFI_IPv6_ADDRESS
));
546 ASSERT (AddrBuf
!= NULL
);
550 Status
= EFI_SUCCESS
;
553 // Go through the list to fill in the EFI_IPv6_ADDRESS structure.
555 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
557 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
559 if (EFI_ERROR (Status
)) {
563 IP6_COPY_ADDRESS (&AddrBuf
[AddrCnt
], &Address
);
565 VarArg
= VarArg
->Next
;
571 if (EFI_ERROR (Status
) && (Status
!= EFI_INVALID_PARAMETER
)) {
576 *BufSize
= AddrCnt
* sizeof (EFI_IPv6_ADDRESS
);
587 Parse InterfaceId in string format from Args with the "-s" option and convert it to EFI_IP6_CONFIG_INTERFACE_ID format.
589 @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
590 @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
592 @retval EFI_SUCCESS The get status processed successfullly.
593 @retval EFI_INVALID_PARAMETER The get status process failed.
597 IfConfig6ParseInterfaceId (
598 IN OUT ARG_LIST
**Arg
,
599 OUT EFI_IP6_CONFIG_INTERFACE_ID
**IfId
607 return EFI_INVALID_PARAMETER
;
612 ASSERT (IfId
!= NULL
);
613 *IfId
= AllocateZeroPool (sizeof (EFI_IP6_CONFIG_INTERFACE_ID
));
614 ASSERT (*IfId
!= NULL
);
616 while ((*IdStr
!= L
'\0') && (Index
< 8)) {
619 while ((*IdStr
!= L
':') && (*IdStr
!= L
'\0')) {
621 if ((*IdStr
<= L
'F') && (*IdStr
>= L
'A')) {
622 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'A' + 10);
623 } else if ((*IdStr
<= L
'f') && (*IdStr
>= L
'a')) {
624 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'a' + 10);
625 } else if ((*IdStr
<= L
'9') && (*IdStr
>= L
'0')) {
626 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'0');
629 return EFI_INVALID_PARAMETER
;
635 (*IfId
)->Id
[Index
++] = NodeVal
;
637 if (*IdStr
== L
':') {
647 Parse dad in string format from Args with the "-s" option and convert it to UINT32 format.
649 @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
650 @param[out] Xmits The pointer of Xmits.
652 @retval EFI_SUCCESS The get status processed successfully.
653 @retval others The get status process failed.
657 IfConfig6ParseDadXmits (
658 IN OUT ARG_LIST
**Arg
,
665 return EFI_INVALID_PARAMETER
;
668 ValStr
= (*Arg
)->Arg
;
671 while (*ValStr
!= L
'\0') {
673 if ((*ValStr
<= L
'9') && (*ValStr
>= L
'0')) {
675 *Xmits
= (*Xmits
* 10) + (*ValStr
- L
'0');
679 return EFI_INVALID_PARAMETER
;
690 The get current status of all handles.
692 @param[in] ImageHandle The handle of ImageHandle.
693 @param[in] IfName The pointer of IfName(interface name).
694 @param[in] IfList The pointer of IfList(interface list).
696 @retval EFI_SUCCESS The get status processed successfully.
697 @retval others The get status process failed.
701 IfConfig6GetInterfaceInfo (
702 IN EFI_HANDLE ImageHandle
,
704 IN LIST_ENTRY
*IfList
710 EFI_HANDLE
*HandleBuffer
;
711 EFI_IP6_CONFIG_PROTOCOL
*Ip6Cfg
;
712 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
713 IFCONFIG6_INTERFACE_CB
*IfCb
;
723 // Locate all the handles with ip6 service binding protocol.
725 Status
= gBS
->LocateHandleBuffer (
727 &gEfiIp6ServiceBindingProtocolGuid
,
732 if (EFI_ERROR (Status
) || (HandleNum
== 0)) {
737 // Enumerate all handles that installed with ip6 service binding protocol.
739 for (HandleIndex
= 0; HandleIndex
< HandleNum
; HandleIndex
++) {
745 // Ip6config protocol and ip6 service binding protocol are installed
746 // on the same handle.
748 ASSERT (HandleBuffer
!= NULL
);
749 Status
= gBS
->HandleProtocol (
750 HandleBuffer
[HandleIndex
],
751 &gEfiIp6ConfigProtocolGuid
,
755 if (EFI_ERROR (Status
)) {
759 // Get the interface information size.
761 Status
= Ip6Cfg
->GetData (
763 Ip6ConfigDataTypeInterfaceInfo
,
768 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
769 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
773 IfInfo
= AllocateZeroPool (DataSize
);
775 if (IfInfo
== NULL
) {
776 Status
= EFI_OUT_OF_RESOURCES
;
780 // Get the interface info.
782 Status
= Ip6Cfg
->GetData (
784 Ip6ConfigDataTypeInterfaceInfo
,
789 if (EFI_ERROR (Status
)) {
790 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
794 // Check the interface name if required.
796 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfInfo
->Name
) != 0)) {
803 // Get the size of dns server list.
805 Status
= Ip6Cfg
->GetData (
807 Ip6ConfigDataTypeDnsServer
,
812 if ((Status
!= EFI_BUFFER_TOO_SMALL
) && (Status
!= EFI_NOT_FOUND
)) {
813 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
817 IfCb
= AllocateZeroPool (sizeof (IFCONFIG6_INTERFACE_CB
) + DataSize
);
820 Status
= EFI_OUT_OF_RESOURCES
;
824 IfCb
->NicHandle
= HandleBuffer
[HandleIndex
];
825 IfCb
->IfInfo
= IfInfo
;
826 IfCb
->IfCfg
= Ip6Cfg
;
827 IfCb
->DnsCnt
= (UINT32
) (DataSize
/ sizeof (EFI_IPv6_ADDRESS
));
830 // Get the dns server list if has.
834 Status
= Ip6Cfg
->GetData (
836 Ip6ConfigDataTypeDnsServer
,
841 if (EFI_ERROR (Status
)) {
842 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
847 // Get the interface id if has.
849 DataSize
= sizeof (EFI_IP6_CONFIG_INTERFACE_ID
);
850 IfCb
->IfId
= AllocateZeroPool (DataSize
);
852 if (IfCb
->IfId
== NULL
) {
856 Status
= Ip6Cfg
->GetData (
858 Ip6ConfigDataTypeAltInterfaceId
,
863 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
864 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
868 if (Status
== EFI_NOT_FOUND
) {
869 FreePool (IfCb
->IfId
);
873 // Get the config policy.
875 DataSize
= sizeof (EFI_IP6_CONFIG_POLICY
);
876 Status
= Ip6Cfg
->GetData (
878 Ip6ConfigDataTypePolicy
,
883 if (EFI_ERROR (Status
)) {
884 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
888 // Get the dad transmits.
890 DataSize
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
891 Status
= Ip6Cfg
->GetData (
893 Ip6ConfigDataTypeDupAddrDetectTransmits
,
898 if (EFI_ERROR (Status
)) {
899 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
903 InsertTailList (IfList
, &IfCb
->Link
);
905 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfInfo
->Name
) == 0)) {
907 // Only need the appointed interface, keep the allocated buffer.
915 if (HandleBuffer
!= NULL
) {
916 FreePool (HandleBuffer
);
923 if (IfInfo
!= NULL
) {
928 if (IfCb
->IfId
!= NULL
) {
929 FreePool (IfCb
->IfId
);
939 The list process of the IfConfig6 application.
941 @param[in] IfList The pointer of IfList(interface list).
943 @retval SHELL_SUCCESS The IfConfig6 list processed successfully.
944 @retval others The IfConfig6 list process failed.
948 IfConfig6ShowInterfaceInfo (
949 IN LIST_ENTRY
*IfList
953 IFCONFIG6_INTERFACE_CB
*IfCb
;
956 Entry
= IfList
->ForwardLink
;
958 if (IsListEmpty (IfList
)) {
959 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
963 // Go through the interface list.
965 while (Entry
!= IfList
) {
967 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
969 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK
), gShellNetwork2HiiHandle
);
972 // Print interface name.
974 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IF_NAME
), gShellNetwork2HiiHandle
, IfCb
->IfInfo
->Name
);
977 // Print interface config policy.
979 if (IfCb
->Policy
== Ip6ConfigPolicyAutomatic
) {
980 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_AUTO
), gShellNetwork2HiiHandle
);
982 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_MAN
), gShellNetwork2HiiHandle
);
986 // Print dad transmit.
988 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_DAD_TRANSMITS
), gShellNetwork2HiiHandle
, IfCb
->Xmits
);
991 // Print interface id if has.
993 if (IfCb
->IfId
!= NULL
) {
994 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD
), gShellNetwork2HiiHandle
);
996 IfConfig6PrintMacAddr (
1002 // Print mac address of the interface.
1004 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1006 IfConfig6PrintMacAddr (
1007 IfCb
->IfInfo
->HwAddress
.Addr
,
1008 IfCb
->IfInfo
->HwAddressSize
1012 // Print ip addresses list of the interface.
1014 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1016 for (Index
= 0; Index
< IfCb
->IfInfo
->AddressInfoCount
; Index
++) {
1017 IfConfig6PrintIpAddr (
1018 &IfCb
->IfInfo
->AddressInfo
[Index
].Address
,
1019 &IfCb
->IfInfo
->AddressInfo
[Index
].PrefixLength
1021 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1025 // Print dns server addresses list of the interface if has.
1027 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_DNS_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1029 for (Index
= 0; Index
< IfCb
->DnsCnt
; Index
++) {
1030 IfConfig6PrintIpAddr (
1031 &IfCb
->DnsAddr
[Index
],
1034 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1038 // Print route table of the interface if has.
1040 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_ROUTE_HEAD
), gShellNetwork2HiiHandle
);
1042 for (Index
= 0; Index
< IfCb
->IfInfo
->RouteCount
; Index
++) {
1043 IfConfig6PrintIpAddr (
1044 &IfCb
->IfInfo
->RouteTable
[Index
].Destination
,
1045 &IfCb
->IfInfo
->RouteTable
[Index
].PrefixLength
1047 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_JOINT
), gShellNetwork2HiiHandle
);
1049 IfConfig6PrintIpAddr (
1050 &IfCb
->IfInfo
->RouteTable
[Index
].Gateway
,
1053 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1056 Entry
= Entry
->ForwardLink
;
1059 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK
), gShellNetwork2HiiHandle
);
1060 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1062 return SHELL_SUCCESS
;
1066 The clean process of the IfConfig6 application.
1068 @param[in] IfList The pointer of IfList(interface list).
1069 @param[in] IfName The pointer of interface name.
1071 @retval SHELL_SUCCESS The IfConfig6 clean processed successfully.
1072 @retval others The IfConfig6 clean process failed.
1076 IfConfig6ClearInterfaceInfo (
1077 IN LIST_ENTRY
*IfList
,
1082 SHELL_STATUS ShellStatus
;
1084 IFCONFIG6_INTERFACE_CB
*IfCb
;
1085 EFI_IP6_CONFIG_POLICY Policy
;
1087 Entry
= IfList
->ForwardLink
;
1088 Status
= EFI_SUCCESS
;
1089 ShellStatus
= SHELL_SUCCESS
;
1091 if (IsListEmpty (IfList
)) {
1092 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
1096 // Go through the interface list.If the interface name is specified, then
1097 // need to refresh the configuration.
1099 while (Entry
!= IfList
) {
1101 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1103 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfCb
->IfInfo
->Name
) == 0)) {
1104 Policy
= Ip6ConfigPolicyManual
;
1106 Status
= IfCb
->IfCfg
->SetData (
1108 Ip6ConfigDataTypePolicy
,
1109 sizeof (EFI_IP6_CONFIG_POLICY
),
1112 if (EFI_ERROR (Status
)) {
1113 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_AD
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1114 ShellStatus
= SHELL_ACCESS_DENIED
;
1119 Policy
= Ip6ConfigPolicyAutomatic
;
1121 Status
= IfCb
->IfCfg
->SetData (
1123 Ip6ConfigDataTypePolicy
,
1124 sizeof (EFI_IP6_CONFIG_POLICY
),
1128 if (EFI_ERROR (Status
)) {
1129 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_AD
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1130 ShellStatus
= SHELL_ACCESS_DENIED
;
1134 Entry
= Entry
->ForwardLink
;
1141 The set process of the IfConfig6 application.
1143 @param[in] IfList The pointer of IfList(interface list).
1144 @param[in] VarArg The pointer of ARG_LIST(Args with "-s" option).
1146 @retval SHELL_SUCCESS The IfConfig6 set processed successfully.
1147 @retval others The IfConfig6 set process failed.
1151 IfConfig6SetInterfaceInfo (
1152 IN LIST_ENTRY
*IfList
,
1157 SHELL_STATUS ShellStatus
;
1158 IFCONFIG6_INTERFACE_CB
*IfCb
;
1159 EFI_IP6_CONFIG_MANUAL_ADDRESS
*CfgManAddr
;
1160 EFI_IPv6_ADDRESS
*CfgAddr
;
1162 EFI_IP6_CONFIG_INTERFACE_ID
*InterfaceId
;
1165 UINTN CurDadXmitsLen
;
1166 EFI_IP6_CONFIG_POLICY Policy
;
1168 VAR_CHECK_CODE CheckCode
;
1169 EFI_EVENT TimeOutEvt
;
1170 EFI_EVENT MappedEvt
;
1171 BOOLEAN IsAddressOk
;
1176 BOOLEAN IsAddressSet
;
1177 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
1187 if (IsListEmpty (IfList
)) {
1188 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
1189 return SHELL_INVALID_PARAMETER
;
1192 // Make sure to set only one interface each time.
1194 IfCb
= BASE_CR (IfList
->ForwardLink
, IFCONFIG6_INTERFACE_CB
, Link
);
1195 Status
= EFI_SUCCESS
;
1196 ShellStatus
= SHELL_SUCCESS
;
1199 // Initialize check list mechanism.
1201 CheckCode
= IfConfig6RetriveCheckListByName(
1208 // Create events & timers for asynchronous settings.
1210 Status
= gBS
->CreateEvent (
1217 if (EFI_ERROR (Status
)) {
1218 ShellStatus
= SHELL_ACCESS_DENIED
;
1222 Status
= gBS
->CreateEvent (
1225 IfConfig6ManualAddressNotify
,
1229 if (EFI_ERROR (Status
)) {
1230 ShellStatus
= SHELL_ACCESS_DENIED
;
1234 // Parse the setting variables.
1236 while (VarArg
!= NULL
) {
1238 // Check invalid parameters (duplication & unknown & conflict).
1240 CheckCode
= IfConfig6RetriveCheckListByName(
1241 mIfConfig6SetCheckList
,
1246 if (VarCheckOk
!= CheckCode
) {
1247 switch (CheckCode
) {
1248 case VarCheckDuplicate
:
1249 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_DUPLICATE_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1252 case VarCheckConflict
:
1253 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_CONFLICT_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1256 case VarCheckUnknown
:
1257 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_UNKNOWN_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1264 VarArg
= VarArg
->Next
;
1268 // Process valid variables.
1270 if (StrCmp(VarArg
->Arg
, L
"auto") == 0) {
1272 // Set automaic config policy
1274 Policy
= Ip6ConfigPolicyAutomatic
;
1275 Status
= IfCb
->IfCfg
->SetData (
1277 Ip6ConfigDataTypePolicy
,
1278 sizeof (EFI_IP6_CONFIG_POLICY
),
1282 if (EFI_ERROR(Status
)) {
1283 ShellStatus
= SHELL_ACCESS_DENIED
;
1287 VarArg
= VarArg
->Next
;
1289 } else if (StrCmp (VarArg
->Arg
, L
"man") == 0) {
1291 // Set manual config policy.
1293 Policy
= Ip6ConfigPolicyManual
;
1294 Status
= IfCb
->IfCfg
->SetData (
1296 Ip6ConfigDataTypePolicy
,
1297 sizeof (EFI_IP6_CONFIG_POLICY
),
1301 if (EFI_ERROR(Status
)) {
1302 ShellStatus
= SHELL_ACCESS_DENIED
;
1306 VarArg
= VarArg
->Next
;
1308 } else if (StrCmp (VarArg
->Arg
, L
"host") == 0) {
1310 // Parse till the next tag or the end of command line.
1312 VarArg
= VarArg
->Next
;
1313 Status
= IfConfig6ParseManualAddressList (
1319 if (EFI_ERROR (Status
)) {
1320 if (Status
== EFI_INVALID_PARAMETER
) {
1321 ShellStatus
= SHELL_INVALID_PARAMETER
;
1322 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"host");
1325 ShellStatus
= SHELL_ACCESS_DENIED
;
1330 // Set static host ip6 address list.
1331 // This is a asynchronous process.
1333 IsAddressOk
= FALSE
;
1335 Status
= IfCb
->IfCfg
->RegisterDataNotify (
1337 Ip6ConfigDataTypeManualAddress
,
1340 if (EFI_ERROR (Status
)) {
1341 ShellStatus
= SHELL_ACCESS_DENIED
;
1345 Status
= IfCb
->IfCfg
->SetData (
1347 Ip6ConfigDataTypeManualAddress
,
1352 if (Status
== EFI_NOT_READY
) {
1354 // Get current dad transmits count.
1356 CurDadXmitsLen
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
1357 IfCb
->IfCfg
->GetData (
1359 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1364 gBS
->SetTimer (TimeOutEvt
, TimerRelative
, 50000000 + 10000000 * CurDadXmits
);
1366 while (EFI_ERROR (gBS
->CheckEvent (TimeOutEvt
))) {
1368 Status
= EFI_SUCCESS
;
1374 IfCb
->IfCfg
->UnregisterDataNotify (
1376 Ip6ConfigDataTypeManualAddress
,
1380 if (EFI_ERROR (Status
)) {
1381 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_MAN_HOST
), gShellNetwork2HiiHandle
, Status
);
1382 ShellStatus
= SHELL_ACCESS_DENIED
;
1387 // Check whether the address is set successfully.
1391 Status
= IfCb
->IfCfg
->GetData (
1393 Ip6ConfigDataTypeInterfaceInfo
,
1398 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
1399 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
1400 ShellStatus
= SHELL_ACCESS_DENIED
;
1404 IfInfo
= AllocateZeroPool (DataSize
);
1406 if (IfInfo
== NULL
) {
1407 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1411 Status
= IfCb
->IfCfg
->GetData (
1413 Ip6ConfigDataTypeInterfaceInfo
,
1418 if (EFI_ERROR (Status
)) {
1419 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
1420 ShellStatus
= SHELL_ACCESS_DENIED
;
1424 for ( Index
= 0; Index
< (UINTN
) (AddrSize
/ sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
)); Index
++) {
1425 IsAddressSet
= FALSE
;
1427 // By default, the prefix length 0 is regarded as 64.
1429 if (CfgManAddr
[Index
].PrefixLength
== 0) {
1430 CfgManAddr
[Index
].PrefixLength
= 64;
1433 for (Index2
= 0; Index2
< IfInfo
->AddressInfoCount
; Index2
++) {
1434 if (EFI_IP6_EQUAL (&IfInfo
->AddressInfo
[Index2
].Address
, &CfgManAddr
[Index
].Address
) &&
1435 (IfInfo
->AddressInfo
[Index2
].PrefixLength
== CfgManAddr
[Index
].PrefixLength
)) {
1436 IsAddressSet
= TRUE
;
1441 if (!IsAddressSet
) {
1442 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_ADDRESS_FAILED
), gShellNetwork2HiiHandle
);
1443 IfConfig6PrintIpAddr (
1444 &CfgManAddr
[Index
].Address
,
1445 &CfgManAddr
[Index
].PrefixLength
1450 } else if (StrCmp (VarArg
->Arg
, L
"gw") == 0) {
1452 // Parse till the next tag or the end of command line.
1454 VarArg
= VarArg
->Next
;
1455 Status
= IfConfig6ParseGwDnsAddressList (
1461 if (EFI_ERROR (Status
)) {
1462 if (Status
== EFI_INVALID_PARAMETER
) {
1463 ShellStatus
= SHELL_INVALID_PARAMETER
;
1464 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"gw");
1467 ShellStatus
= SHELL_ACCESS_DENIED
;
1472 // Set static gateway ip6 address list.
1474 Status
= IfCb
->IfCfg
->SetData (
1476 Ip6ConfigDataTypeGateway
,
1481 if (EFI_ERROR (Status
)) {
1482 ShellStatus
= SHELL_ACCESS_DENIED
;
1486 } else if (StrCmp (VarArg
->Arg
, L
"dns") == 0) {
1488 // Parse till the next tag or the end of command line.
1490 VarArg
= VarArg
->Next
;
1491 Status
= IfConfig6ParseGwDnsAddressList (
1497 if (EFI_ERROR (Status
)) {
1498 if (Status
== EFI_INVALID_PARAMETER
) {
1499 ShellStatus
= SHELL_INVALID_PARAMETER
;
1500 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"dns");
1503 ShellStatus
= SHELL_ACCESS_DENIED
;
1508 // Set static DNS server ip6 address list.
1510 Status
= IfCb
->IfCfg
->SetData (
1512 Ip6ConfigDataTypeDnsServer
,
1517 if (EFI_ERROR (Status
)) {
1518 ShellStatus
= SHELL_ACCESS_DENIED
;
1522 } else if (StrCmp (VarArg
->Arg
, L
"id") == 0) {
1524 // Parse till the next tag or the end of command line.
1526 VarArg
= VarArg
->Next
;
1527 Status
= IfConfig6ParseInterfaceId (&VarArg
, &InterfaceId
);
1529 if (EFI_ERROR (Status
)) {
1530 ShellStatus
= SHELL_INVALID_PARAMETER
;
1534 // Set alternative interface id.
1536 Status
= IfCb
->IfCfg
->SetData (
1538 Ip6ConfigDataTypeAltInterfaceId
,
1539 sizeof (EFI_IP6_CONFIG_INTERFACE_ID
),
1543 if (EFI_ERROR (Status
)) {
1544 ShellStatus
= SHELL_ACCESS_DENIED
;
1548 } else if (StrCmp (VarArg
->Arg
, L
"dad") == 0) {
1550 // Parse till the next tag or the end of command line.
1552 VarArg
= VarArg
->Next
;
1553 Status
= IfConfig6ParseDadXmits (&VarArg
, &DadXmits
);
1555 if (EFI_ERROR (Status
)) {
1556 ShellStatus
= SHELL_ACCESS_DENIED
;
1560 // Set dad transmits count.
1562 Status
= IfCb
->IfCfg
->SetData (
1564 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1565 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
),
1569 if (EFI_ERROR(Status
)) {
1570 ShellStatus
= SHELL_ACCESS_DENIED
;
1578 if (CfgManAddr
!= NULL
) {
1579 FreePool (CfgManAddr
);
1582 if (CfgAddr
!= NULL
) {
1586 if (MappedEvt
!= NULL
) {
1587 gBS
->CloseEvent (MappedEvt
);
1590 if (TimeOutEvt
!= NULL
) {
1591 gBS
->CloseEvent (TimeOutEvt
);
1594 if (IfInfo
!= NULL
) {
1603 The IfConfig6 main process.
1605 @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
1607 @retval SHELL_SUCCESS IfConfig6 processed successfully.
1608 @retval others The IfConfig6 process failed.
1613 IN IFCONFIG6_PRIVATE_DATA
*Private
1617 SHELL_STATUS ShellStatus
;
1619 ShellStatus
= SHELL_SUCCESS
;
1622 // Get configure information of all interfaces.
1624 Status
= IfConfig6GetInterfaceInfo (
1625 Private
->ImageHandle
,
1630 if (EFI_ERROR (Status
)) {
1631 ShellStatus
= SHELL_NOT_FOUND
;
1635 switch (Private
->OpCode
) {
1636 case IfConfig6OpList
:
1637 ShellStatus
= IfConfig6ShowInterfaceInfo (&Private
->IfList
);
1640 case IfConfig6OpClear
:
1641 ShellStatus
= IfConfig6ClearInterfaceInfo (&Private
->IfList
, Private
->IfName
);
1644 case IfConfig6OpSet
:
1645 ShellStatus
= IfConfig6SetInterfaceInfo (&Private
->IfList
, Private
->VarArg
);
1649 ShellStatus
= SHELL_UNSUPPORTED
;
1658 The IfConfig6 cleanup process, free the allocated memory.
1660 @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
1665 IN IFCONFIG6_PRIVATE_DATA
*Private
1669 LIST_ENTRY
*NextEntry
;
1670 IFCONFIG6_INTERFACE_CB
*IfCb
;
1674 ASSERT (Private
!= NULL
);
1677 // Clean the list which save the set config Args.
1679 if (Private
->VarArg
!= NULL
) {
1680 ArgHead
= Private
->VarArg
;
1682 while (ArgHead
->Next
!= NULL
) {
1683 ArgNode
= ArgHead
->Next
;
1691 if (Private
->IfName
!= NULL
)
1692 FreePool (Private
->IfName
);
1696 // Clean the IFCONFIG6_INTERFACE_CB list.
1698 Entry
= Private
->IfList
.ForwardLink
;
1699 NextEntry
= Entry
->ForwardLink
;
1701 while (Entry
!= &Private
->IfList
) {
1703 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1705 RemoveEntryList (&IfCb
->Link
);
1707 if (IfCb
->IfId
!= NULL
) {
1709 FreePool (IfCb
->IfId
);
1712 if (IfCb
->IfInfo
!= NULL
) {
1714 FreePool (IfCb
->IfInfo
);
1720 NextEntry
= Entry
->ForwardLink
;
1727 Function for 'ifconfig6' command.
1729 @param[in] ImageHandle Handle to the Image (NULL if Internal).
1730 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
1732 @retval SHELL_SUCCESS ifconfig6 command processed successfully.
1733 @retval others The ifconfig6 command process failed.
1738 ShellCommandRunIfconfig6 (
1739 IN EFI_HANDLE ImageHandle
,
1740 IN EFI_SYSTEM_TABLE
*SystemTable
1744 SHELL_STATUS ShellStatus
;
1745 IFCONFIG6_PRIVATE_DATA
*Private
;
1746 LIST_ENTRY
*ParamPackage
;
1747 CONST CHAR16
*ValueStr
;
1749 CHAR16
*ProblemParam
;
1753 Status
= EFI_INVALID_PARAMETER
;
1754 ShellStatus
= SHELL_SUCCESS
;
1756 Status
= ShellCommandLineParseEx (mIfConfig6CheckList
, &ParamPackage
, &ProblemParam
, TRUE
, FALSE
);
1757 if (EFI_ERROR (Status
)) {
1758 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_COMMAND
), gShellNetwork2HiiHandle
, L
"ifconfig6", ProblemParam
);
1759 ShellStatus
= SHELL_INVALID_PARAMETER
;
1764 // To handle no option.
1766 if (!ShellCommandLineGetFlag (ParamPackage
, L
"-r") && !ShellCommandLineGetFlag (ParamPackage
, L
"-s") &&
1767 !ShellCommandLineGetFlag (ParamPackage
, L
"-?") && !ShellCommandLineGetFlag (ParamPackage
, L
"-l")) {
1768 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_LACK_OPTION
), gShellNetwork2HiiHandle
);
1769 ShellStatus
= SHELL_INVALID_PARAMETER
;
1773 // To handle conflict options.
1775 if (((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-s"))) ||
1776 ((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-l"))) ||
1777 ((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?"))) ||
1778 ((ShellCommandLineGetFlag (ParamPackage
, L
"-s")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-l"))) ||
1779 ((ShellCommandLineGetFlag (ParamPackage
, L
"-s")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?"))) ||
1780 ((ShellCommandLineGetFlag (ParamPackage
, L
"-l")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?")))) {
1781 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_CONFLICT_OPTIONS
), gShellNetwork2HiiHandle
);
1782 ShellStatus
= SHELL_INVALID_PARAMETER
;
1786 Private
= AllocateZeroPool (sizeof (IFCONFIG6_PRIVATE_DATA
));
1788 if (Private
== NULL
) {
1789 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1793 InitializeListHead (&Private
->IfList
);
1796 // To get interface name for the list option.
1798 if (ShellCommandLineGetFlag (ParamPackage
, L
"-l")) {
1799 Private
->OpCode
= IfConfig6OpList
;
1800 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-l");
1801 if (ValueStr
!= NULL
) {
1802 Str
= AllocateCopyPool (StrSize (ValueStr
), ValueStr
);
1803 ASSERT (Str
!= NULL
);
1804 Private
->IfName
= Str
;
1808 // To get interface name for the clear option.
1810 if (ShellCommandLineGetFlag (ParamPackage
, L
"-r")) {
1811 Private
->OpCode
= IfConfig6OpClear
;
1812 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-r");
1813 if (ValueStr
!= NULL
) {
1814 Str
= AllocateCopyPool (StrSize (ValueStr
), ValueStr
);
1815 ASSERT (Str
!= NULL
);
1816 Private
->IfName
= Str
;
1820 // To get interface name and corresponding Args for the set option.
1822 if (ShellCommandLineGetFlag (ParamPackage
, L
"-s")) {
1824 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-s");
1825 if (ValueStr
== NULL
) {
1826 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_INTERFACE
), gShellNetwork2HiiHandle
);
1827 ShellStatus
= SHELL_INVALID_PARAMETER
;
1831 // To split the configuration into multi-section.
1833 ArgList
= IfConfig6SplitStrToList (ValueStr
, L
' ');
1834 ASSERT (ArgList
!= NULL
);
1836 Private
->OpCode
= IfConfig6OpSet
;
1837 Private
->IfName
= ArgList
->Arg
;
1839 Private
->VarArg
= ArgList
->Next
;
1841 if (Private
->IfName
== NULL
|| Private
->VarArg
== NULL
) {
1842 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_COMMAND
), gShellNetwork2HiiHandle
);
1843 ShellStatus
= SHELL_INVALID_PARAMETER
;
1848 // Main process of ifconfig6.
1850 ShellStatus
= IfConfig6 (Private
);
1854 ShellCommandLineFreeVarList (ParamPackage
);
1855 if (Private
!= NULL
) {
1856 IfConfig6Cleanup (Private
);