2 The implementation for Shell command IfConfig6.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellNetwork2CommandsLib.h"
25 VarCheckReserved
= -1,
39 } VAR_CHECK_FLAG_TYPE
;
41 #define MACADDRMAXSIZE 32
42 #define PREFIXMAXLEN 16
44 typedef struct _IFCONFIG6_INTERFACE_CB
{
47 EFI_IP6_CONFIG_PROTOCOL
*IfCfg
;
48 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
49 EFI_IP6_CONFIG_INTERFACE_ID
*IfId
;
50 EFI_IP6_CONFIG_POLICY Policy
;
51 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS Xmits
;
53 EFI_IPv6_ADDRESS DnsAddr
[1];
54 } IFCONFIG6_INTERFACE_CB
;
56 typedef struct _ARG_LIST ARG_LIST
;
63 typedef struct _IFCONFIG6_PRIVATE_DATA
{
64 EFI_HANDLE ImageHandle
;
70 } IFCONFIG6_PRIVATE_DATA
;
72 typedef struct _VAR_CHECK_ITEM
{
76 VAR_CHECK_FLAG_TYPE FlagType
;
80 SHELL_PARAM_ITEM mIfConfig6CheckList
[] = {
107 VAR_CHECK_ITEM mIfConfig6SetCheckList
[] = {
161 @param List Pointer to ARG_LIST to free.
164 IfConfig6FreeArgList (
169 while (List
->Next
!= NULL
) {
179 Split a string with specified separator and save the substring to a list.
181 @param[in] String The pointer of the input string.
182 @param[in] Separator The specified separator.
184 @return The pointer of headnode of ARG_LIST.
188 IfConfig6SplitStrToList (
189 IN CONST CHAR16
*String
,
198 if (String
== NULL
|| *String
== L
'\0') {
203 // Copy the CONST string to a local copy.
205 Str
= AllocateCopyPool (StrSize (String
), String
);
212 // init a node for the list head.
214 ArgNode
= (ARG_LIST
*) AllocateZeroPool (sizeof (ARG_LIST
));
215 if (ArgNode
== NULL
) {
221 // Split the local copy and save in the list node.
223 while (*Str
!= L
'\0') {
224 if (*Str
== Separator
) {
226 ArgNode
->Arg
= ArgStr
;
228 ArgNode
->Next
= (ARG_LIST
*) AllocateZeroPool (sizeof (ARG_LIST
));
229 if (ArgNode
->Next
== NULL
) {
231 // Free the local copy of string stored in the first node
233 FreePool (ArgList
->Arg
);
234 IfConfig6FreeArgList (ArgList
);
237 ArgNode
= ArgNode
->Next
;
243 ArgNode
->Arg
= ArgStr
;
244 ArgNode
->Next
= NULL
;
250 Check the correctness of input Args with '-s' option.
252 @param[in] CheckList The pointer of VAR_CHECK_ITEM array.
253 @param[in] Name The pointer of input arg.
254 @param[in] Init The switch to execute the check.
256 @return The value of VAR_CHECK_CODE.
260 IfConfig6RetriveCheckListByName(
261 IN VAR_CHECK_ITEM
*CheckList
,
266 STATIC UINT32 CheckDuplicate
;
267 STATIC UINT32 CheckConflict
;
268 VAR_CHECK_CODE RtCode
;
280 Arg
= CheckList
[Index
];
283 // Check the Duplicated/Conflicted/Unknown input Args.
285 while (Arg
.FlagStr
!= NULL
) {
286 if (StrCmp (Arg
.FlagStr
, Name
) == 0) {
288 if (CheckDuplicate
& Arg
.FlagID
) {
289 RtCode
= VarCheckDuplicate
;
293 if (CheckConflict
& Arg
.ConflictMask
) {
294 RtCode
= VarCheckConflict
;
298 CheckDuplicate
|= Arg
.FlagID
;
299 CheckConflict
|= Arg
.ConflictMask
;
303 Arg
= CheckList
[++Index
];
306 if (Arg
.FlagStr
== NULL
) {
307 RtCode
= VarCheckUnknown
;
314 The notify function of create event when performing a manual config.
316 @param[in] Event The event this notify function registered to.
317 @param[in] Context Pointer to the context data registered to the event.
322 IfConfig6ManualAddressNotify (
327 *((BOOLEAN
*) Context
) = TRUE
;
333 @param[in] Node The pointer of MAC address buffer.
334 @param[in] Size The size of MAC address buffer.
338 IfConfig6PrintMacAddr (
345 ASSERT (Size
<= MACADDRMAXSIZE
);
347 for (Index
= 0; Index
< Size
; Index
++) {
348 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_BODY
), gShellNetwork2HiiHandle
, Node
[Index
]);
349 if (Index
+ 1 < Size
) {
350 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
354 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
360 @param[in] Ip The pointer of Ip bufffer in EFI_IPv6_ADDRESS format.
361 @param[in] PrefixLen The pointer of PrefixLen that describes the size Prefix.
365 IfConfig6PrintIpAddr (
366 IN EFI_IPv6_ADDRESS
*Ip
,
375 for (Index
= 0; Index
< PREFIXMAXLEN
; Index
= Index
+ 2) {
377 if (!Short
&& (Index
+ 1 < PREFIXMAXLEN
) && (Index
% 2 == 0) && (Ip
->Addr
[Index
] == 0) && (Ip
->Addr
[Index
+ 1] == 0)) {
379 // Deal with the case of ::.
383 // :: is at the beginning of the address.
385 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
387 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
389 while ((Ip
->Addr
[Index
] == 0) && (Ip
->Addr
[Index
+ 1] == 0) && (Index
< PREFIXMAXLEN
)) {
391 if (Index
> PREFIXMAXLEN
- 2) {
398 if (Index
== PREFIXMAXLEN
) {
400 // :: is at the end of the address.
406 if (Index
< PREFIXMAXLEN
- 1) {
407 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY
), gShellNetwork2HiiHandle
, Ip
->Addr
[Index
]);
408 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY
), gShellNetwork2HiiHandle
, Ip
->Addr
[Index
+ 1]);
411 if (Index
+ 2 < PREFIXMAXLEN
) {
412 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
416 if (PrefixLen
!= NULL
) {
417 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_PREFIX_LEN
), gShellNetwork2HiiHandle
, *PrefixLen
);
422 Pick up host IPv6 address in string format from Args with "-s" option and convert it to EFI_IP6_CONFIG_MANUAL_ADDRESS format.
424 @param[in, out] Arg The pointer of the address of ARG_LIST which save Args with the "-s" option.
425 @param[out] Buf The pointer of the address of EFI_IP6_CONFIG_MANUAL_ADDRESS.
426 @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
428 @retval EFI_SUCCESS The convertion is successful.
429 @retval Others Does't find the host address, or it is an invalid IPv6 address in string format.
433 IfConfig6ParseManualAddressList (
434 IN OUT ARG_LIST
**Arg
,
435 OUT EFI_IP6_CONFIG_MANUAL_ADDRESS
**Buf
,
440 EFI_IP6_CONFIG_MANUAL_ADDRESS
*AddrBuf
;
442 EFI_IPv6_ADDRESS Address
;
451 Status
= EFI_SUCCESS
;
454 // Go through the list to check the correctness of input host ip6 address.
456 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
458 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
460 if (EFI_ERROR (Status
)) {
467 VarArg
= VarArg
->Next
;
472 return EFI_INVALID_PARAMETER
;
475 AddrBuf
= AllocateZeroPool (AddrCnt
* sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
));
476 ASSERT (AddrBuf
!= NULL
);
480 Status
= EFI_SUCCESS
;
483 // Go through the list to fill in the EFI_IP6_CONFIG_MANUAL_ADDRESS structure.
485 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
487 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
489 if (EFI_ERROR (Status
)) {
494 // If prefix length is not set, set it as Zero here. In the IfConfigSetInterfaceInfo()
495 // Zero prefix, length will be transfered to default prefix length.
497 if (Prefix
== 0xFF) {
500 AddrBuf
[AddrCnt
].IsAnycast
= FALSE
;
501 AddrBuf
[AddrCnt
].PrefixLength
= Prefix
;
502 IP6_COPY_ADDRESS (&AddrBuf
[AddrCnt
].Address
, &Address
);
503 VarArg
= VarArg
->Next
;
509 if (EFI_ERROR (Status
) && (Status
!= EFI_INVALID_PARAMETER
)) {
514 *BufSize
= AddrCnt
* sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
);
525 Pick up gw/dns IPv6 address in string format from Args with "-s" option and convert it to EFI_IPv6_ADDRESS format.
527 @param[in, out] Arg The pointer of the address of ARG_LIST that save Args with the "-s" option.
528 @param[out] Buf The pointer of the address of EFI_IPv6_ADDRESS.
529 @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
531 @retval EFI_SUCCESS The conversion is successful.
532 @retval Others Doesn't find the host address, or it is an invalid IPv6 address in string format.
536 IfConfig6ParseGwDnsAddressList (
537 IN OUT ARG_LIST
**Arg
,
538 OUT EFI_IPv6_ADDRESS
**Buf
,
543 EFI_IPv6_ADDRESS
*AddrBuf
;
545 EFI_IPv6_ADDRESS Address
;
553 Status
= EFI_SUCCESS
;
556 // Go through the list to check the correctness of input gw/dns address.
558 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
560 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
562 if (EFI_ERROR (Status
)) {
569 VarArg
= VarArg
->Next
;
574 return EFI_INVALID_PARAMETER
;
577 AddrBuf
= AllocateZeroPool (AddrCnt
* sizeof (EFI_IPv6_ADDRESS
));
578 ASSERT (AddrBuf
!= NULL
);
582 Status
= EFI_SUCCESS
;
585 // Go through the list to fill in the EFI_IPv6_ADDRESS structure.
587 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
589 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
591 if (EFI_ERROR (Status
)) {
595 IP6_COPY_ADDRESS (&AddrBuf
[AddrCnt
], &Address
);
597 VarArg
= VarArg
->Next
;
603 if (EFI_ERROR (Status
) && (Status
!= EFI_INVALID_PARAMETER
)) {
608 *BufSize
= AddrCnt
* sizeof (EFI_IPv6_ADDRESS
);
619 Parse InterfaceId in string format from Args with the "-s" option and convert it to EFI_IP6_CONFIG_INTERFACE_ID format.
621 @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
622 @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
624 @retval EFI_SUCCESS The get status processed successfullly.
625 @retval EFI_INVALID_PARAMETER The get status process failed.
629 IfConfig6ParseInterfaceId (
630 IN OUT ARG_LIST
**Arg
,
631 OUT EFI_IP6_CONFIG_INTERFACE_ID
**IfId
639 return EFI_INVALID_PARAMETER
;
644 ASSERT (IfId
!= NULL
);
645 *IfId
= AllocateZeroPool (sizeof (EFI_IP6_CONFIG_INTERFACE_ID
));
646 ASSERT (*IfId
!= NULL
);
648 while ((*IdStr
!= L
'\0') && (Index
< 8)) {
651 while ((*IdStr
!= L
':') && (*IdStr
!= L
'\0')) {
653 if ((*IdStr
<= L
'F') && (*IdStr
>= L
'A')) {
654 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'A' + 10);
655 } else if ((*IdStr
<= L
'f') && (*IdStr
>= L
'a')) {
656 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'a' + 10);
657 } else if ((*IdStr
<= L
'9') && (*IdStr
>= L
'0')) {
658 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'0');
661 return EFI_INVALID_PARAMETER
;
667 (*IfId
)->Id
[Index
++] = NodeVal
;
669 if (*IdStr
== L
':') {
679 Parse dad in string format from Args with the "-s" option and convert it to UINT32 format.
681 @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
682 @param[out] Xmits The pointer of Xmits.
684 @retval EFI_SUCCESS The get status processed successfully.
685 @retval others The get status process failed.
689 IfConfig6ParseDadXmits (
690 IN OUT ARG_LIST
**Arg
,
697 return EFI_INVALID_PARAMETER
;
700 ValStr
= (*Arg
)->Arg
;
703 while (*ValStr
!= L
'\0') {
705 if ((*ValStr
<= L
'9') && (*ValStr
>= L
'0')) {
707 *Xmits
= (*Xmits
* 10) + (*ValStr
- L
'0');
711 return EFI_INVALID_PARAMETER
;
722 The get current status of all handles.
724 @param[in] ImageHandle The handle of ImageHandle.
725 @param[in] IfName The pointer of IfName(interface name).
726 @param[in] IfList The pointer of IfList(interface list).
728 @retval EFI_SUCCESS The get status processed successfully.
729 @retval others The get status process failed.
733 IfConfig6GetInterfaceInfo (
734 IN EFI_HANDLE ImageHandle
,
736 IN LIST_ENTRY
*IfList
742 EFI_HANDLE
*HandleBuffer
;
743 EFI_IP6_CONFIG_PROTOCOL
*Ip6Cfg
;
744 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
745 IFCONFIG6_INTERFACE_CB
*IfCb
;
755 // Locate all the handles with ip6 service binding protocol.
757 Status
= gBS
->LocateHandleBuffer (
759 &gEfiIp6ServiceBindingProtocolGuid
,
764 if (EFI_ERROR (Status
) || (HandleNum
== 0)) {
769 // Enumerate all handles that installed with ip6 service binding protocol.
771 for (HandleIndex
= 0; HandleIndex
< HandleNum
; HandleIndex
++) {
777 // Ip6config protocol and ip6 service binding protocol are installed
778 // on the same handle.
780 ASSERT (HandleBuffer
!= NULL
);
781 Status
= gBS
->HandleProtocol (
782 HandleBuffer
[HandleIndex
],
783 &gEfiIp6ConfigProtocolGuid
,
787 if (EFI_ERROR (Status
)) {
791 // Get the interface information size.
793 Status
= Ip6Cfg
->GetData (
795 Ip6ConfigDataTypeInterfaceInfo
,
800 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
801 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
805 IfInfo
= AllocateZeroPool (DataSize
);
807 if (IfInfo
== NULL
) {
808 Status
= EFI_OUT_OF_RESOURCES
;
812 // Get the interface info.
814 Status
= Ip6Cfg
->GetData (
816 Ip6ConfigDataTypeInterfaceInfo
,
821 if (EFI_ERROR (Status
)) {
822 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
826 // Check the interface name if required.
828 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfInfo
->Name
) != 0)) {
835 // Get the size of dns server list.
837 Status
= Ip6Cfg
->GetData (
839 Ip6ConfigDataTypeDnsServer
,
844 if ((Status
!= EFI_BUFFER_TOO_SMALL
) && (Status
!= EFI_NOT_FOUND
)) {
845 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
849 IfCb
= AllocateZeroPool (sizeof (IFCONFIG6_INTERFACE_CB
) + DataSize
);
852 Status
= EFI_OUT_OF_RESOURCES
;
856 IfCb
->NicHandle
= HandleBuffer
[HandleIndex
];
857 IfCb
->IfInfo
= IfInfo
;
858 IfCb
->IfCfg
= Ip6Cfg
;
859 IfCb
->DnsCnt
= (UINT32
) (DataSize
/ sizeof (EFI_IPv6_ADDRESS
));
862 // Get the dns server list if has.
866 Status
= Ip6Cfg
->GetData (
868 Ip6ConfigDataTypeDnsServer
,
873 if (EFI_ERROR (Status
)) {
874 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
879 // Get the interface id if has.
881 DataSize
= sizeof (EFI_IP6_CONFIG_INTERFACE_ID
);
882 IfCb
->IfId
= AllocateZeroPool (DataSize
);
884 if (IfCb
->IfId
== NULL
) {
888 Status
= Ip6Cfg
->GetData (
890 Ip6ConfigDataTypeAltInterfaceId
,
895 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
896 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
900 if (Status
== EFI_NOT_FOUND
) {
901 FreePool (IfCb
->IfId
);
905 // Get the config policy.
907 DataSize
= sizeof (EFI_IP6_CONFIG_POLICY
);
908 Status
= Ip6Cfg
->GetData (
910 Ip6ConfigDataTypePolicy
,
915 if (EFI_ERROR (Status
)) {
916 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
920 // Get the dad transmits.
922 DataSize
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
923 Status
= Ip6Cfg
->GetData (
925 Ip6ConfigDataTypeDupAddrDetectTransmits
,
930 if (EFI_ERROR (Status
)) {
931 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
935 InsertTailList (IfList
, &IfCb
->Link
);
937 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfInfo
->Name
) == 0)) {
939 // Only need the appointed interface, keep the allocated buffer.
947 if (HandleBuffer
!= NULL
) {
948 FreePool (HandleBuffer
);
955 if (IfInfo
!= NULL
) {
960 if (IfCb
->IfId
!= NULL
) {
961 FreePool (IfCb
->IfId
);
971 The list process of the IfConfig6 application.
973 @param[in] IfList The pointer of IfList(interface list).
975 @retval SHELL_SUCCESS The IfConfig6 list processed successfully.
976 @retval others The IfConfig6 list process failed.
980 IfConfig6ShowInterfaceInfo (
981 IN LIST_ENTRY
*IfList
985 IFCONFIG6_INTERFACE_CB
*IfCb
;
988 Entry
= IfList
->ForwardLink
;
990 if (IsListEmpty (IfList
)) {
991 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
995 // Go through the interface list.
997 while (Entry
!= IfList
) {
999 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1001 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK
), gShellNetwork2HiiHandle
);
1004 // Print interface name.
1006 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IF_NAME
), gShellNetwork2HiiHandle
, IfCb
->IfInfo
->Name
);
1009 // Print interface config policy.
1011 if (IfCb
->Policy
== Ip6ConfigPolicyAutomatic
) {
1012 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_AUTO
), gShellNetwork2HiiHandle
);
1014 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_MAN
), gShellNetwork2HiiHandle
);
1018 // Print dad transmit.
1020 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_DAD_TRANSMITS
), gShellNetwork2HiiHandle
, IfCb
->Xmits
);
1023 // Print interface id if has.
1025 if (IfCb
->IfId
!= NULL
) {
1026 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD
), gShellNetwork2HiiHandle
);
1028 IfConfig6PrintMacAddr (
1034 // Print mac address of the interface.
1036 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1038 IfConfig6PrintMacAddr (
1039 IfCb
->IfInfo
->HwAddress
.Addr
,
1040 IfCb
->IfInfo
->HwAddressSize
1044 // Print ip addresses list of the interface.
1046 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1048 for (Index
= 0; Index
< IfCb
->IfInfo
->AddressInfoCount
; Index
++) {
1049 IfConfig6PrintIpAddr (
1050 &IfCb
->IfInfo
->AddressInfo
[Index
].Address
,
1051 &IfCb
->IfInfo
->AddressInfo
[Index
].PrefixLength
1053 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1057 // Print dns server addresses list of the interface if has.
1059 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_DNS_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1061 for (Index
= 0; Index
< IfCb
->DnsCnt
; Index
++) {
1062 IfConfig6PrintIpAddr (
1063 &IfCb
->DnsAddr
[Index
],
1066 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1070 // Print route table of the interface if has.
1072 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_ROUTE_HEAD
), gShellNetwork2HiiHandle
);
1074 for (Index
= 0; Index
< IfCb
->IfInfo
->RouteCount
; Index
++) {
1075 IfConfig6PrintIpAddr (
1076 &IfCb
->IfInfo
->RouteTable
[Index
].Destination
,
1077 &IfCb
->IfInfo
->RouteTable
[Index
].PrefixLength
1079 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_JOINT
), gShellNetwork2HiiHandle
);
1081 IfConfig6PrintIpAddr (
1082 &IfCb
->IfInfo
->RouteTable
[Index
].Gateway
,
1085 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1088 Entry
= Entry
->ForwardLink
;
1091 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK
), gShellNetwork2HiiHandle
);
1092 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1094 return SHELL_SUCCESS
;
1098 The clean process of the IfConfig6 application.
1100 @param[in] IfList The pointer of IfList(interface list).
1101 @param[in] IfName The pointer of interface name.
1103 @retval SHELL_SUCCESS The IfConfig6 clean processed successfully.
1104 @retval others The IfConfig6 clean process failed.
1108 IfConfig6ClearInterfaceInfo (
1109 IN LIST_ENTRY
*IfList
,
1114 SHELL_STATUS ShellStatus
;
1116 IFCONFIG6_INTERFACE_CB
*IfCb
;
1117 EFI_IP6_CONFIG_POLICY Policy
;
1119 Entry
= IfList
->ForwardLink
;
1120 Status
= EFI_SUCCESS
;
1121 ShellStatus
= SHELL_SUCCESS
;
1123 if (IsListEmpty (IfList
)) {
1124 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
1128 // Go through the interface list.If the interface name is specified, then
1129 // need to refresh the configuration.
1131 while (Entry
!= IfList
) {
1133 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1135 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfCb
->IfInfo
->Name
) == 0)) {
1136 Policy
= Ip6ConfigPolicyManual
;
1138 Status
= IfCb
->IfCfg
->SetData (
1140 Ip6ConfigDataTypePolicy
,
1141 sizeof (EFI_IP6_CONFIG_POLICY
),
1144 if (EFI_ERROR (Status
)) {
1145 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_AD
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1146 ShellStatus
= SHELL_ACCESS_DENIED
;
1151 Policy
= Ip6ConfigPolicyAutomatic
;
1153 Status
= IfCb
->IfCfg
->SetData (
1155 Ip6ConfigDataTypePolicy
,
1156 sizeof (EFI_IP6_CONFIG_POLICY
),
1160 if (EFI_ERROR (Status
)) {
1161 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_AD
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1162 ShellStatus
= SHELL_ACCESS_DENIED
;
1166 Entry
= Entry
->ForwardLink
;
1173 The set process of the IfConfig6 application.
1175 @param[in] IfList The pointer of IfList(interface list).
1176 @param[in] VarArg The pointer of ARG_LIST(Args with "-s" option).
1178 @retval SHELL_SUCCESS The IfConfig6 set processed successfully.
1179 @retval others The IfConfig6 set process failed.
1183 IfConfig6SetInterfaceInfo (
1184 IN LIST_ENTRY
*IfList
,
1189 SHELL_STATUS ShellStatus
;
1190 IFCONFIG6_INTERFACE_CB
*IfCb
;
1191 EFI_IP6_CONFIG_MANUAL_ADDRESS
*CfgManAddr
;
1192 EFI_IPv6_ADDRESS
*CfgAddr
;
1194 EFI_IP6_CONFIG_INTERFACE_ID
*InterfaceId
;
1197 UINTN CurDadXmitsLen
;
1198 EFI_IP6_CONFIG_POLICY Policy
;
1200 VAR_CHECK_CODE CheckCode
;
1201 EFI_EVENT TimeOutEvt
;
1202 EFI_EVENT MappedEvt
;
1203 BOOLEAN IsAddressOk
;
1208 BOOLEAN IsAddressSet
;
1209 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
1219 if (IsListEmpty (IfList
)) {
1220 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
1221 return SHELL_INVALID_PARAMETER
;
1224 // Make sure to set only one interface each time.
1226 IfCb
= BASE_CR (IfList
->ForwardLink
, IFCONFIG6_INTERFACE_CB
, Link
);
1227 Status
= EFI_SUCCESS
;
1228 ShellStatus
= SHELL_SUCCESS
;
1231 // Initialize check list mechanism.
1233 CheckCode
= IfConfig6RetriveCheckListByName(
1240 // Create events & timers for asynchronous settings.
1242 Status
= gBS
->CreateEvent (
1249 if (EFI_ERROR (Status
)) {
1250 ShellStatus
= SHELL_ACCESS_DENIED
;
1254 Status
= gBS
->CreateEvent (
1257 IfConfig6ManualAddressNotify
,
1261 if (EFI_ERROR (Status
)) {
1262 ShellStatus
= SHELL_ACCESS_DENIED
;
1266 // Parse the setting variables.
1268 while (VarArg
!= NULL
) {
1270 // Check invalid parameters (duplication & unknown & conflict).
1272 CheckCode
= IfConfig6RetriveCheckListByName(
1273 mIfConfig6SetCheckList
,
1278 if (VarCheckOk
!= CheckCode
) {
1279 switch (CheckCode
) {
1280 case VarCheckDuplicate
:
1281 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_DUPLICATE_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1284 case VarCheckConflict
:
1285 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_CONFLICT_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1288 case VarCheckUnknown
:
1289 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_UNKNOWN_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1296 VarArg
= VarArg
->Next
;
1300 // Process valid variables.
1302 if (StrCmp(VarArg
->Arg
, L
"auto") == 0) {
1304 // Set automaic config policy
1306 Policy
= Ip6ConfigPolicyAutomatic
;
1307 Status
= IfCb
->IfCfg
->SetData (
1309 Ip6ConfigDataTypePolicy
,
1310 sizeof (EFI_IP6_CONFIG_POLICY
),
1314 if (EFI_ERROR(Status
)) {
1315 ShellStatus
= SHELL_ACCESS_DENIED
;
1319 VarArg
= VarArg
->Next
;
1321 if (VarArg
!= NULL
) {
1322 if (StrCmp (VarArg
->Arg
, L
"host") == 0) {
1323 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG
), gShellNetwork2HiiHandle
, Status
);
1324 ShellStatus
= SHELL_INVALID_PARAMETER
;
1326 } else if (StrCmp (VarArg
->Arg
, L
"gw") == 0) {
1327 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG
), gShellNetwork2HiiHandle
, Status
);
1328 ShellStatus
= SHELL_INVALID_PARAMETER
;
1330 } else if (StrCmp (VarArg
->Arg
, L
"dns") == 0) {
1331 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG
), gShellNetwork2HiiHandle
, Status
);
1332 ShellStatus
= SHELL_INVALID_PARAMETER
;
1336 } else if (StrCmp (VarArg
->Arg
, L
"man") == 0) {
1338 // Set manual config policy.
1340 Policy
= Ip6ConfigPolicyManual
;
1341 Status
= IfCb
->IfCfg
->SetData (
1343 Ip6ConfigDataTypePolicy
,
1344 sizeof (EFI_IP6_CONFIG_POLICY
),
1348 if (EFI_ERROR(Status
)) {
1349 ShellStatus
= SHELL_ACCESS_DENIED
;
1353 VarArg
= VarArg
->Next
;
1355 } else if (StrCmp (VarArg
->Arg
, L
"host") == 0) {
1357 // Parse till the next tag or the end of command line.
1359 VarArg
= VarArg
->Next
;
1360 Status
= IfConfig6ParseManualAddressList (
1366 if (EFI_ERROR (Status
)) {
1367 if (Status
== EFI_INVALID_PARAMETER
) {
1368 ShellStatus
= SHELL_INVALID_PARAMETER
;
1369 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"host");
1372 ShellStatus
= SHELL_ACCESS_DENIED
;
1377 // Set static host ip6 address list.
1378 // This is a asynchronous process.
1380 IsAddressOk
= FALSE
;
1382 Status
= IfCb
->IfCfg
->RegisterDataNotify (
1384 Ip6ConfigDataTypeManualAddress
,
1387 if (EFI_ERROR (Status
)) {
1388 ShellStatus
= SHELL_ACCESS_DENIED
;
1392 Status
= IfCb
->IfCfg
->SetData (
1394 Ip6ConfigDataTypeManualAddress
,
1399 if (Status
== EFI_NOT_READY
) {
1401 // Get current dad transmits count.
1403 CurDadXmitsLen
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
1404 IfCb
->IfCfg
->GetData (
1406 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1411 gBS
->SetTimer (TimeOutEvt
, TimerRelative
, 50000000 + 10000000 * CurDadXmits
);
1413 while (EFI_ERROR (gBS
->CheckEvent (TimeOutEvt
))) {
1415 Status
= EFI_SUCCESS
;
1421 IfCb
->IfCfg
->UnregisterDataNotify (
1423 Ip6ConfigDataTypeManualAddress
,
1427 if (EFI_ERROR (Status
)) {
1428 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_MAN_HOST
), gShellNetwork2HiiHandle
, Status
);
1429 ShellStatus
= SHELL_ACCESS_DENIED
;
1434 // Check whether the address is set successfully.
1438 Status
= IfCb
->IfCfg
->GetData (
1440 Ip6ConfigDataTypeInterfaceInfo
,
1445 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
1446 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
1447 ShellStatus
= SHELL_ACCESS_DENIED
;
1451 IfInfo
= AllocateZeroPool (DataSize
);
1453 if (IfInfo
== NULL
) {
1454 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1458 Status
= IfCb
->IfCfg
->GetData (
1460 Ip6ConfigDataTypeInterfaceInfo
,
1465 if (EFI_ERROR (Status
)) {
1466 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
1467 ShellStatus
= SHELL_ACCESS_DENIED
;
1471 for ( Index
= 0; Index
< (UINTN
) (AddrSize
/ sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
)); Index
++) {
1472 IsAddressSet
= FALSE
;
1474 // By default, the prefix length 0 is regarded as 64.
1476 if (CfgManAddr
[Index
].PrefixLength
== 0) {
1477 CfgManAddr
[Index
].PrefixLength
= 64;
1480 for (Index2
= 0; Index2
< IfInfo
->AddressInfoCount
; Index2
++) {
1481 if (EFI_IP6_EQUAL (&IfInfo
->AddressInfo
[Index2
].Address
, &CfgManAddr
[Index
].Address
) &&
1482 (IfInfo
->AddressInfo
[Index2
].PrefixLength
== CfgManAddr
[Index
].PrefixLength
)) {
1483 IsAddressSet
= TRUE
;
1488 if (!IsAddressSet
) {
1489 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_ADDRESS_FAILED
), gShellNetwork2HiiHandle
);
1490 IfConfig6PrintIpAddr (
1491 &CfgManAddr
[Index
].Address
,
1492 &CfgManAddr
[Index
].PrefixLength
1494 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1498 } else if (StrCmp (VarArg
->Arg
, L
"gw") == 0) {
1500 // Parse till the next tag or the end of command line.
1502 VarArg
= VarArg
->Next
;
1503 Status
= IfConfig6ParseGwDnsAddressList (
1509 if (EFI_ERROR (Status
)) {
1510 if (Status
== EFI_INVALID_PARAMETER
) {
1511 ShellStatus
= SHELL_INVALID_PARAMETER
;
1512 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"gw");
1515 ShellStatus
= SHELL_ACCESS_DENIED
;
1520 // Set static gateway ip6 address list.
1522 Status
= IfCb
->IfCfg
->SetData (
1524 Ip6ConfigDataTypeGateway
,
1529 if (EFI_ERROR (Status
)) {
1530 ShellStatus
= SHELL_ACCESS_DENIED
;
1531 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_MAN_GW
), gShellNetwork2HiiHandle
, Status
);
1535 } else if (StrCmp (VarArg
->Arg
, L
"dns") == 0) {
1537 // Parse till the next tag or the end of command line.
1539 VarArg
= VarArg
->Next
;
1540 Status
= IfConfig6ParseGwDnsAddressList (
1546 if (EFI_ERROR (Status
)) {
1547 if (Status
== EFI_INVALID_PARAMETER
) {
1548 ShellStatus
= SHELL_INVALID_PARAMETER
;
1549 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"dns");
1552 ShellStatus
= SHELL_ACCESS_DENIED
;
1557 // Set static DNS server ip6 address list.
1559 Status
= IfCb
->IfCfg
->SetData (
1561 Ip6ConfigDataTypeDnsServer
,
1566 if (EFI_ERROR (Status
)) {
1567 ShellStatus
= SHELL_ACCESS_DENIED
;
1571 } else if (StrCmp (VarArg
->Arg
, L
"id") == 0) {
1573 // Parse till the next tag or the end of command line.
1575 VarArg
= VarArg
->Next
;
1576 Status
= IfConfig6ParseInterfaceId (&VarArg
, &InterfaceId
);
1578 if (EFI_ERROR (Status
)) {
1579 ShellStatus
= SHELL_INVALID_PARAMETER
;
1583 // Set alternative interface id.
1585 Status
= IfCb
->IfCfg
->SetData (
1587 Ip6ConfigDataTypeAltInterfaceId
,
1588 sizeof (EFI_IP6_CONFIG_INTERFACE_ID
),
1592 if (EFI_ERROR (Status
)) {
1593 ShellStatus
= SHELL_ACCESS_DENIED
;
1597 } else if (StrCmp (VarArg
->Arg
, L
"dad") == 0) {
1599 // Parse till the next tag or the end of command line.
1601 VarArg
= VarArg
->Next
;
1602 Status
= IfConfig6ParseDadXmits (&VarArg
, &DadXmits
);
1604 if (EFI_ERROR (Status
)) {
1605 ShellStatus
= SHELL_ACCESS_DENIED
;
1609 // Set dad transmits count.
1611 Status
= IfCb
->IfCfg
->SetData (
1613 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1614 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
),
1618 if (EFI_ERROR(Status
)) {
1619 ShellStatus
= SHELL_ACCESS_DENIED
;
1627 if (CfgManAddr
!= NULL
) {
1628 FreePool (CfgManAddr
);
1631 if (CfgAddr
!= NULL
) {
1635 if (MappedEvt
!= NULL
) {
1636 gBS
->CloseEvent (MappedEvt
);
1639 if (TimeOutEvt
!= NULL
) {
1640 gBS
->CloseEvent (TimeOutEvt
);
1643 if (IfInfo
!= NULL
) {
1652 The IfConfig6 main process.
1654 @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
1656 @retval SHELL_SUCCESS IfConfig6 processed successfully.
1657 @retval others The IfConfig6 process failed.
1662 IN IFCONFIG6_PRIVATE_DATA
*Private
1666 SHELL_STATUS ShellStatus
;
1668 ShellStatus
= SHELL_SUCCESS
;
1671 // Get configure information of all interfaces.
1673 Status
= IfConfig6GetInterfaceInfo (
1674 Private
->ImageHandle
,
1679 if (EFI_ERROR (Status
)) {
1680 ShellStatus
= SHELL_NOT_FOUND
;
1684 switch (Private
->OpCode
) {
1685 case IfConfig6OpList
:
1686 ShellStatus
= IfConfig6ShowInterfaceInfo (&Private
->IfList
);
1689 case IfConfig6OpClear
:
1690 ShellStatus
= IfConfig6ClearInterfaceInfo (&Private
->IfList
, Private
->IfName
);
1693 case IfConfig6OpSet
:
1694 ShellStatus
= IfConfig6SetInterfaceInfo (&Private
->IfList
, Private
->VarArg
);
1698 ShellStatus
= SHELL_UNSUPPORTED
;
1707 The IfConfig6 cleanup process, free the allocated memory.
1709 @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
1714 IN IFCONFIG6_PRIVATE_DATA
*Private
1718 LIST_ENTRY
*NextEntry
;
1719 IFCONFIG6_INTERFACE_CB
*IfCb
;
1721 ASSERT (Private
!= NULL
);
1724 // Clean the list which save the set config Args.
1726 if (Private
->VarArg
!= NULL
) {
1727 IfConfig6FreeArgList (Private
->VarArg
);
1730 if (Private
->IfName
!= NULL
)
1731 FreePool (Private
->IfName
);
1735 // Clean the IFCONFIG6_INTERFACE_CB list.
1737 Entry
= Private
->IfList
.ForwardLink
;
1738 NextEntry
= Entry
->ForwardLink
;
1740 while (Entry
!= &Private
->IfList
) {
1742 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1744 RemoveEntryList (&IfCb
->Link
);
1746 if (IfCb
->IfId
!= NULL
) {
1748 FreePool (IfCb
->IfId
);
1751 if (IfCb
->IfInfo
!= NULL
) {
1753 FreePool (IfCb
->IfInfo
);
1759 NextEntry
= Entry
->ForwardLink
;
1766 Function for 'ifconfig6' command.
1768 @param[in] ImageHandle Handle to the Image (NULL if Internal).
1769 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
1771 @retval SHELL_SUCCESS ifconfig6 command processed successfully.
1772 @retval others The ifconfig6 command process failed.
1777 ShellCommandRunIfconfig6 (
1778 IN EFI_HANDLE ImageHandle
,
1779 IN EFI_SYSTEM_TABLE
*SystemTable
1783 SHELL_STATUS ShellStatus
;
1784 IFCONFIG6_PRIVATE_DATA
*Private
;
1785 LIST_ENTRY
*ParamPackage
;
1786 CONST CHAR16
*ValueStr
;
1788 CHAR16
*ProblemParam
;
1792 Status
= EFI_INVALID_PARAMETER
;
1793 ShellStatus
= SHELL_SUCCESS
;
1795 Status
= ShellCommandLineParseEx (mIfConfig6CheckList
, &ParamPackage
, &ProblemParam
, TRUE
, FALSE
);
1796 if (EFI_ERROR (Status
)) {
1797 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_COMMAND
), gShellNetwork2HiiHandle
, L
"ifconfig6", ProblemParam
);
1798 ShellStatus
= SHELL_INVALID_PARAMETER
;
1803 // To handle no option.
1805 if (!ShellCommandLineGetFlag (ParamPackage
, L
"-r") && !ShellCommandLineGetFlag (ParamPackage
, L
"-s") &&
1806 !ShellCommandLineGetFlag (ParamPackage
, L
"-?") && !ShellCommandLineGetFlag (ParamPackage
, L
"-l")) {
1807 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_LACK_OPTION
), gShellNetwork2HiiHandle
);
1808 ShellStatus
= SHELL_INVALID_PARAMETER
;
1812 // To handle conflict options.
1814 if (((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-s"))) ||
1815 ((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-l"))) ||
1816 ((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?"))) ||
1817 ((ShellCommandLineGetFlag (ParamPackage
, L
"-s")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-l"))) ||
1818 ((ShellCommandLineGetFlag (ParamPackage
, L
"-s")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?"))) ||
1819 ((ShellCommandLineGetFlag (ParamPackage
, L
"-l")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?")))) {
1820 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_CONFLICT_OPTIONS
), gShellNetwork2HiiHandle
);
1821 ShellStatus
= SHELL_INVALID_PARAMETER
;
1825 Private
= AllocateZeroPool (sizeof (IFCONFIG6_PRIVATE_DATA
));
1827 if (Private
== NULL
) {
1828 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1832 InitializeListHead (&Private
->IfList
);
1835 // To get interface name for the list option.
1837 if (ShellCommandLineGetFlag (ParamPackage
, L
"-l")) {
1838 Private
->OpCode
= IfConfig6OpList
;
1839 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-l");
1840 if (ValueStr
!= NULL
) {
1841 Str
= AllocateCopyPool (StrSize (ValueStr
), ValueStr
);
1843 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1844 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1847 Private
->IfName
= Str
;
1851 // To get interface name for the clear option.
1853 if (ShellCommandLineGetFlag (ParamPackage
, L
"-r")) {
1854 Private
->OpCode
= IfConfig6OpClear
;
1855 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-r");
1856 if (ValueStr
!= NULL
) {
1857 Str
= AllocateCopyPool (StrSize (ValueStr
), ValueStr
);
1859 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1860 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1863 Private
->IfName
= Str
;
1867 // To get interface name and corresponding Args for the set option.
1869 if (ShellCommandLineGetFlag (ParamPackage
, L
"-s")) {
1871 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-s");
1872 if (ValueStr
== NULL
) {
1873 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_INTERFACE
), gShellNetwork2HiiHandle
);
1874 ShellStatus
= SHELL_INVALID_PARAMETER
;
1878 // To split the configuration into multi-section.
1880 ArgList
= IfConfig6SplitStrToList (ValueStr
, L
' ');
1881 if (ArgList
== NULL
) {
1882 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1883 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1887 Private
->OpCode
= IfConfig6OpSet
;
1888 Private
->IfName
= ArgList
->Arg
;
1890 Private
->VarArg
= ArgList
->Next
;
1892 if (Private
->IfName
== NULL
|| Private
->VarArg
== NULL
) {
1893 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_COMMAND
), gShellNetwork2HiiHandle
);
1894 ShellStatus
= SHELL_INVALID_PARAMETER
;
1899 // Main process of ifconfig6.
1901 ShellStatus
= IfConfig6 (Private
);
1905 ShellCommandLineFreeVarList (ParamPackage
);
1906 if (Private
!= NULL
) {
1907 IfConfig6Cleanup (Private
);