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
[] = {
160 @param List Pointer to ARG_LIST to free.
163 IfConfig6FreeArgList (
168 while (List
->Next
!= NULL
) {
178 Split a string with specified separator and save the substring to a list.
180 @param[in] String The pointer of the input string.
181 @param[in] Separator The specified separator.
183 @return The pointer of headnode of ARG_LIST.
187 IfConfig6SplitStrToList (
188 IN CONST CHAR16
*String
,
197 if (String
== NULL
|| *String
== L
'\0') {
202 // Copy the CONST string to a local copy.
204 Str
= AllocateCopyPool (StrSize (String
), String
);
211 // init a node for the list head.
213 ArgNode
= (ARG_LIST
*) AllocateZeroPool (sizeof (ARG_LIST
));
214 if (ArgNode
== NULL
) {
220 // Split the local copy and save in the list node.
222 while (*Str
!= L
'\0') {
223 if (*Str
== Separator
) {
225 ArgNode
->Arg
= ArgStr
;
227 ArgNode
->Next
= (ARG_LIST
*) AllocateZeroPool (sizeof (ARG_LIST
));
228 if (ArgNode
->Next
== NULL
) {
230 // Free the local copy of string stored in the first node
232 FreePool (ArgList
->Arg
);
233 IfConfig6FreeArgList (ArgList
);
236 ArgNode
= ArgNode
->Next
;
242 ArgNode
->Arg
= ArgStr
;
243 ArgNode
->Next
= NULL
;
249 Check the correctness of input Args with '-s' option.
251 @param[in] CheckList The pointer of VAR_CHECK_ITEM array.
252 @param[in] Name The pointer of input arg.
253 @param[in] Init The switch to execute the check.
255 @return The value of VAR_CHECK_CODE.
259 IfConfig6RetriveCheckListByName(
260 IN VAR_CHECK_ITEM
*CheckList
,
265 STATIC UINT32 CheckDuplicate
;
266 STATIC UINT32 CheckConflict
;
267 VAR_CHECK_CODE RtCode
;
279 Arg
= CheckList
[Index
];
282 // Check the Duplicated/Conflicted/Unknown input Args.
284 while (Arg
.FlagStr
!= NULL
) {
285 if (StrCmp (Arg
.FlagStr
, Name
) == 0) {
287 if (CheckDuplicate
& Arg
.FlagID
) {
288 RtCode
= VarCheckDuplicate
;
292 if (CheckConflict
& Arg
.ConflictMask
) {
293 RtCode
= VarCheckConflict
;
297 CheckDuplicate
|= Arg
.FlagID
;
298 CheckConflict
|= Arg
.ConflictMask
;
302 Arg
= CheckList
[++Index
];
305 if (Arg
.FlagStr
== NULL
) {
306 RtCode
= VarCheckUnknown
;
313 The notify function of create event when performing a manual config.
315 @param[in] Event The event this notify function registered to.
316 @param[in] Context Pointer to the context data registered to the event.
321 IfConfig6ManualAddressNotify (
326 *((BOOLEAN
*) Context
) = TRUE
;
332 @param[in] Node The pointer of MAC address buffer.
333 @param[in] Size The size of MAC address buffer.
337 IfConfig6PrintMacAddr (
344 ASSERT (Size
<= MACADDRMAXSIZE
);
346 for (Index
= 0; Index
< Size
; Index
++) {
347 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_BODY
), gShellNetwork2HiiHandle
, Node
[Index
]);
348 if (Index
+ 1 < Size
) {
349 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
353 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
359 @param[in] Ip The pointer of Ip bufffer in EFI_IPv6_ADDRESS format.
360 @param[in] PrefixLen The pointer of PrefixLen that describes the size Prefix.
364 IfConfig6PrintIpAddr (
365 IN EFI_IPv6_ADDRESS
*Ip
,
374 for (Index
= 0; Index
< PREFIXMAXLEN
; Index
= Index
+ 2) {
376 if (!Short
&& (Index
+ 1 < PREFIXMAXLEN
) && (Index
% 2 == 0) && (Ip
->Addr
[Index
] == 0) && (Ip
->Addr
[Index
+ 1] == 0)) {
378 // Deal with the case of ::.
382 // :: is at the beginning of the address.
384 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
386 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
388 while ((Ip
->Addr
[Index
] == 0) && (Ip
->Addr
[Index
+ 1] == 0) && (Index
< PREFIXMAXLEN
)) {
390 if (Index
> PREFIXMAXLEN
- 2) {
397 if (Index
== PREFIXMAXLEN
) {
399 // :: is at the end of the address.
405 if (Index
< PREFIXMAXLEN
- 1) {
406 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY
), gShellNetwork2HiiHandle
, Ip
->Addr
[Index
]);
407 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY
), gShellNetwork2HiiHandle
, Ip
->Addr
[Index
+ 1]);
410 if (Index
+ 2 < PREFIXMAXLEN
) {
411 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON
), gShellNetwork2HiiHandle
);
415 if (PrefixLen
!= NULL
) {
416 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_PREFIX_LEN
), gShellNetwork2HiiHandle
, *PrefixLen
);
421 Pick up host IPv6 address in string format from Args with "-s" option and convert it to EFI_IP6_CONFIG_MANUAL_ADDRESS format.
423 @param[in, out] Arg The pointer of the address of ARG_LIST which save Args with the "-s" option.
424 @param[out] Buf The pointer of the address of EFI_IP6_CONFIG_MANUAL_ADDRESS.
425 @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
427 @retval EFI_SUCCESS The convertion is successful.
428 @retval Others Does't find the host address, or it is an invalid IPv6 address in string format.
432 IfConfig6ParseManualAddressList (
433 IN OUT ARG_LIST
**Arg
,
434 OUT EFI_IP6_CONFIG_MANUAL_ADDRESS
**Buf
,
439 EFI_IP6_CONFIG_MANUAL_ADDRESS
*AddrBuf
;
441 EFI_IPv6_ADDRESS Address
;
450 Status
= EFI_SUCCESS
;
453 // Go through the list to check the correctness of input host ip6 address.
455 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
457 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
459 if (EFI_ERROR (Status
)) {
466 VarArg
= VarArg
->Next
;
471 return EFI_INVALID_PARAMETER
;
474 AddrBuf
= AllocateZeroPool (AddrCnt
* sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
));
475 ASSERT (AddrBuf
!= NULL
);
479 Status
= EFI_SUCCESS
;
482 // Go through the list to fill in the EFI_IP6_CONFIG_MANUAL_ADDRESS structure.
484 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
486 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
488 if (EFI_ERROR (Status
)) {
493 // If prefix length is not set, set it as Zero here. In the IfConfigSetInterfaceInfo()
494 // Zero prefix, length will be transfered to default prefix length.
496 if (Prefix
== 0xFF) {
499 AddrBuf
[AddrCnt
].IsAnycast
= FALSE
;
500 AddrBuf
[AddrCnt
].PrefixLength
= Prefix
;
501 IP6_COPY_ADDRESS (&AddrBuf
[AddrCnt
].Address
, &Address
);
502 VarArg
= VarArg
->Next
;
508 if (EFI_ERROR (Status
) && (Status
!= EFI_INVALID_PARAMETER
)) {
513 *BufSize
= AddrCnt
* sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
);
524 Pick up gw/dns IPv6 address in string format from Args with "-s" option and convert it to EFI_IPv6_ADDRESS format.
526 @param[in, out] Arg The pointer of the address of ARG_LIST that save Args with the "-s" option.
527 @param[out] Buf The pointer of the address of EFI_IPv6_ADDRESS.
528 @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
530 @retval EFI_SUCCESS The conversion is successful.
531 @retval Others Doesn't find the host address, or it is an invalid IPv6 address in string format.
535 IfConfig6ParseGwDnsAddressList (
536 IN OUT ARG_LIST
**Arg
,
537 OUT EFI_IPv6_ADDRESS
**Buf
,
542 EFI_IPv6_ADDRESS
*AddrBuf
;
544 EFI_IPv6_ADDRESS Address
;
552 Status
= EFI_SUCCESS
;
555 // Go through the list to check the correctness of input gw/dns address.
557 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
559 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
561 if (EFI_ERROR (Status
)) {
568 VarArg
= VarArg
->Next
;
573 return EFI_INVALID_PARAMETER
;
576 AddrBuf
= AllocateZeroPool (AddrCnt
* sizeof (EFI_IPv6_ADDRESS
));
577 ASSERT (AddrBuf
!= NULL
);
581 Status
= EFI_SUCCESS
;
584 // Go through the list to fill in the EFI_IPv6_ADDRESS structure.
586 while ((!EFI_ERROR (Status
)) && (VarArg
!= NULL
)) {
588 Status
= NetLibStrToIp6andPrefix (VarArg
->Arg
, &Address
, &Prefix
);
590 if (EFI_ERROR (Status
)) {
594 IP6_COPY_ADDRESS (&AddrBuf
[AddrCnt
], &Address
);
596 VarArg
= VarArg
->Next
;
602 if (EFI_ERROR (Status
) && (Status
!= EFI_INVALID_PARAMETER
)) {
607 *BufSize
= AddrCnt
* sizeof (EFI_IPv6_ADDRESS
);
618 Parse InterfaceId in string format from Args with the "-s" option and convert it to EFI_IP6_CONFIG_INTERFACE_ID format.
620 @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
621 @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
623 @retval EFI_SUCCESS The get status processed successfullly.
624 @retval EFI_INVALID_PARAMETER The get status process failed.
628 IfConfig6ParseInterfaceId (
629 IN OUT ARG_LIST
**Arg
,
630 OUT EFI_IP6_CONFIG_INTERFACE_ID
**IfId
638 return EFI_INVALID_PARAMETER
;
643 ASSERT (IfId
!= NULL
);
644 *IfId
= AllocateZeroPool (sizeof (EFI_IP6_CONFIG_INTERFACE_ID
));
645 ASSERT (*IfId
!= NULL
);
647 while ((*IdStr
!= L
'\0') && (Index
< 8)) {
650 while ((*IdStr
!= L
':') && (*IdStr
!= L
'\0')) {
652 if ((*IdStr
<= L
'F') && (*IdStr
>= L
'A')) {
653 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'A' + 10);
654 } else if ((*IdStr
<= L
'f') && (*IdStr
>= L
'a')) {
655 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'a' + 10);
656 } else if ((*IdStr
<= L
'9') && (*IdStr
>= L
'0')) {
657 NodeVal
= (UINT8
)((NodeVal
<< 4) + *IdStr
- L
'0');
660 return EFI_INVALID_PARAMETER
;
666 (*IfId
)->Id
[Index
++] = NodeVal
;
668 if (*IdStr
== L
':') {
678 Parse dad in string format from Args with the "-s" option and convert it to UINT32 format.
680 @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
681 @param[out] Xmits The pointer of Xmits.
683 @retval EFI_SUCCESS The get status processed successfully.
684 @retval others The get status process failed.
688 IfConfig6ParseDadXmits (
689 IN OUT ARG_LIST
**Arg
,
696 return EFI_INVALID_PARAMETER
;
699 ValStr
= (*Arg
)->Arg
;
702 while (*ValStr
!= L
'\0') {
704 if ((*ValStr
<= L
'9') && (*ValStr
>= L
'0')) {
706 *Xmits
= (*Xmits
* 10) + (*ValStr
- L
'0');
710 return EFI_INVALID_PARAMETER
;
721 The get current status of all handles.
723 @param[in] ImageHandle The handle of ImageHandle.
724 @param[in] IfName The pointer of IfName(interface name).
725 @param[in] IfList The pointer of IfList(interface list).
727 @retval EFI_SUCCESS The get status processed successfully.
728 @retval others The get status process failed.
732 IfConfig6GetInterfaceInfo (
733 IN EFI_HANDLE ImageHandle
,
735 IN LIST_ENTRY
*IfList
741 EFI_HANDLE
*HandleBuffer
;
742 EFI_IP6_CONFIG_PROTOCOL
*Ip6Cfg
;
743 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
744 IFCONFIG6_INTERFACE_CB
*IfCb
;
754 // Locate all the handles with ip6 service binding protocol.
756 Status
= gBS
->LocateHandleBuffer (
758 &gEfiIp6ServiceBindingProtocolGuid
,
763 if (EFI_ERROR (Status
) || (HandleNum
== 0)) {
768 // Enumerate all handles that installed with ip6 service binding protocol.
770 for (HandleIndex
= 0; HandleIndex
< HandleNum
; HandleIndex
++) {
776 // Ip6config protocol and ip6 service binding protocol are installed
777 // on the same handle.
779 ASSERT (HandleBuffer
!= NULL
);
780 Status
= gBS
->HandleProtocol (
781 HandleBuffer
[HandleIndex
],
782 &gEfiIp6ConfigProtocolGuid
,
786 if (EFI_ERROR (Status
)) {
790 // Get the interface information size.
792 Status
= Ip6Cfg
->GetData (
794 Ip6ConfigDataTypeInterfaceInfo
,
799 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
800 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
804 IfInfo
= AllocateZeroPool (DataSize
);
806 if (IfInfo
== NULL
) {
807 Status
= EFI_OUT_OF_RESOURCES
;
811 // Get the interface info.
813 Status
= Ip6Cfg
->GetData (
815 Ip6ConfigDataTypeInterfaceInfo
,
820 if (EFI_ERROR (Status
)) {
821 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
825 // Check the interface name if required.
827 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfInfo
->Name
) != 0)) {
834 // Get the size of dns server list.
836 Status
= Ip6Cfg
->GetData (
838 Ip6ConfigDataTypeDnsServer
,
843 if ((Status
!= EFI_BUFFER_TOO_SMALL
) && (Status
!= EFI_NOT_FOUND
)) {
844 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
848 IfCb
= AllocateZeroPool (sizeof (IFCONFIG6_INTERFACE_CB
) + DataSize
);
851 Status
= EFI_OUT_OF_RESOURCES
;
855 IfCb
->NicHandle
= HandleBuffer
[HandleIndex
];
856 IfCb
->IfInfo
= IfInfo
;
857 IfCb
->IfCfg
= Ip6Cfg
;
858 IfCb
->DnsCnt
= (UINT32
) (DataSize
/ sizeof (EFI_IPv6_ADDRESS
));
861 // Get the dns server list if has.
865 Status
= Ip6Cfg
->GetData (
867 Ip6ConfigDataTypeDnsServer
,
872 if (EFI_ERROR (Status
)) {
873 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
878 // Get the interface id if has.
880 DataSize
= sizeof (EFI_IP6_CONFIG_INTERFACE_ID
);
881 IfCb
->IfId
= AllocateZeroPool (DataSize
);
883 if (IfCb
->IfId
== NULL
) {
887 Status
= Ip6Cfg
->GetData (
889 Ip6ConfigDataTypeAltInterfaceId
,
894 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
895 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
899 if (Status
== EFI_NOT_FOUND
) {
900 FreePool (IfCb
->IfId
);
904 // Get the config policy.
906 DataSize
= sizeof (EFI_IP6_CONFIG_POLICY
);
907 Status
= Ip6Cfg
->GetData (
909 Ip6ConfigDataTypePolicy
,
914 if (EFI_ERROR (Status
)) {
915 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
919 // Get the dad transmits.
921 DataSize
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
922 Status
= Ip6Cfg
->GetData (
924 Ip6ConfigDataTypeDupAddrDetectTransmits
,
929 if (EFI_ERROR (Status
)) {
930 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
934 InsertTailList (IfList
, &IfCb
->Link
);
936 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfInfo
->Name
) == 0)) {
938 // Only need the appointed interface, keep the allocated buffer.
946 if (HandleBuffer
!= NULL
) {
947 FreePool (HandleBuffer
);
954 if (IfInfo
!= NULL
) {
959 if (IfCb
->IfId
!= NULL
) {
960 FreePool (IfCb
->IfId
);
970 The list process of the IfConfig6 application.
972 @param[in] IfList The pointer of IfList(interface list).
974 @retval SHELL_SUCCESS The IfConfig6 list processed successfully.
975 @retval others The IfConfig6 list process failed.
979 IfConfig6ShowInterfaceInfo (
980 IN LIST_ENTRY
*IfList
984 IFCONFIG6_INTERFACE_CB
*IfCb
;
987 Entry
= IfList
->ForwardLink
;
989 if (IsListEmpty (IfList
)) {
990 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
994 // Go through the interface list.
996 while (Entry
!= IfList
) {
998 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1000 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK
), gShellNetwork2HiiHandle
);
1003 // Print interface name.
1005 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IF_NAME
), gShellNetwork2HiiHandle
, IfCb
->IfInfo
->Name
);
1008 // Print interface config policy.
1010 if (IfCb
->Policy
== Ip6ConfigPolicyAutomatic
) {
1011 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_AUTO
), gShellNetwork2HiiHandle
);
1013 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_MAN
), gShellNetwork2HiiHandle
);
1017 // Print dad transmit.
1019 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_DAD_TRANSMITS
), gShellNetwork2HiiHandle
, IfCb
->Xmits
);
1022 // Print interface id if has.
1024 if (IfCb
->IfId
!= NULL
) {
1025 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD
), gShellNetwork2HiiHandle
);
1027 IfConfig6PrintMacAddr (
1033 // Print mac address of the interface.
1035 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1037 IfConfig6PrintMacAddr (
1038 IfCb
->IfInfo
->HwAddress
.Addr
,
1039 IfCb
->IfInfo
->HwAddressSize
1043 // Print ip addresses list of the interface.
1045 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1047 for (Index
= 0; Index
< IfCb
->IfInfo
->AddressInfoCount
; Index
++) {
1048 IfConfig6PrintIpAddr (
1049 &IfCb
->IfInfo
->AddressInfo
[Index
].Address
,
1050 &IfCb
->IfInfo
->AddressInfo
[Index
].PrefixLength
1052 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1056 // Print dns server addresses list of the interface if has.
1058 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_DNS_ADDR_HEAD
), gShellNetwork2HiiHandle
);
1060 for (Index
= 0; Index
< IfCb
->DnsCnt
; Index
++) {
1061 IfConfig6PrintIpAddr (
1062 &IfCb
->DnsAddr
[Index
],
1065 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1069 // Print route table of the interface if has.
1071 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_ROUTE_HEAD
), gShellNetwork2HiiHandle
);
1073 for (Index
= 0; Index
< IfCb
->IfInfo
->RouteCount
; Index
++) {
1074 IfConfig6PrintIpAddr (
1075 &IfCb
->IfInfo
->RouteTable
[Index
].Destination
,
1076 &IfCb
->IfInfo
->RouteTable
[Index
].PrefixLength
1078 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_JOINT
), gShellNetwork2HiiHandle
);
1080 IfConfig6PrintIpAddr (
1081 &IfCb
->IfInfo
->RouteTable
[Index
].Gateway
,
1084 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1087 Entry
= Entry
->ForwardLink
;
1090 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK
), gShellNetwork2HiiHandle
);
1091 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE
), gShellNetwork2HiiHandle
);
1093 return SHELL_SUCCESS
;
1097 The clean process of the IfConfig6 application.
1099 @param[in] IfList The pointer of IfList(interface list).
1100 @param[in] IfName The pointer of interface name.
1102 @retval SHELL_SUCCESS The IfConfig6 clean processed successfully.
1103 @retval others The IfConfig6 clean process failed.
1107 IfConfig6ClearInterfaceInfo (
1108 IN LIST_ENTRY
*IfList
,
1113 SHELL_STATUS ShellStatus
;
1115 IFCONFIG6_INTERFACE_CB
*IfCb
;
1116 EFI_IP6_CONFIG_POLICY Policy
;
1118 Entry
= IfList
->ForwardLink
;
1119 Status
= EFI_SUCCESS
;
1120 ShellStatus
= SHELL_SUCCESS
;
1122 if (IsListEmpty (IfList
)) {
1123 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
1127 // Go through the interface list.If the interface name is specified, then
1128 // need to refresh the configuration.
1130 while (Entry
!= IfList
) {
1132 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1134 if ((IfName
!= NULL
) && (StrCmp (IfName
, IfCb
->IfInfo
->Name
) == 0)) {
1135 Policy
= Ip6ConfigPolicyManual
;
1137 Status
= IfCb
->IfCfg
->SetData (
1139 Ip6ConfigDataTypePolicy
,
1140 sizeof (EFI_IP6_CONFIG_POLICY
),
1143 if (EFI_ERROR (Status
)) {
1144 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_AD
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1145 ShellStatus
= SHELL_ACCESS_DENIED
;
1150 Policy
= Ip6ConfigPolicyAutomatic
;
1152 Status
= IfCb
->IfCfg
->SetData (
1154 Ip6ConfigDataTypePolicy
,
1155 sizeof (EFI_IP6_CONFIG_POLICY
),
1159 if (EFI_ERROR (Status
)) {
1160 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_AD
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1161 ShellStatus
= SHELL_ACCESS_DENIED
;
1165 Entry
= Entry
->ForwardLink
;
1172 The set process of the IfConfig6 application.
1174 @param[in] IfList The pointer of IfList(interface list).
1175 @param[in] VarArg The pointer of ARG_LIST(Args with "-s" option).
1177 @retval SHELL_SUCCESS The IfConfig6 set processed successfully.
1178 @retval others The IfConfig6 set process failed.
1182 IfConfig6SetInterfaceInfo (
1183 IN LIST_ENTRY
*IfList
,
1188 SHELL_STATUS ShellStatus
;
1189 IFCONFIG6_INTERFACE_CB
*IfCb
;
1190 EFI_IP6_CONFIG_MANUAL_ADDRESS
*CfgManAddr
;
1191 EFI_IPv6_ADDRESS
*CfgAddr
;
1193 EFI_IP6_CONFIG_INTERFACE_ID
*InterfaceId
;
1196 UINTN CurDadXmitsLen
;
1197 EFI_IP6_CONFIG_POLICY Policy
;
1199 VAR_CHECK_CODE CheckCode
;
1200 EFI_EVENT TimeOutEvt
;
1201 EFI_EVENT MappedEvt
;
1202 BOOLEAN IsAddressOk
;
1207 BOOLEAN IsAddressSet
;
1208 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
1218 if (IsListEmpty (IfList
)) {
1219 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE
), gShellNetwork2HiiHandle
);
1220 return SHELL_INVALID_PARAMETER
;
1223 // Make sure to set only one interface each time.
1225 IfCb
= BASE_CR (IfList
->ForwardLink
, IFCONFIG6_INTERFACE_CB
, Link
);
1226 Status
= EFI_SUCCESS
;
1227 ShellStatus
= SHELL_SUCCESS
;
1230 // Initialize check list mechanism.
1232 CheckCode
= IfConfig6RetriveCheckListByName(
1239 // Create events & timers for asynchronous settings.
1241 Status
= gBS
->CreateEvent (
1248 if (EFI_ERROR (Status
)) {
1249 ShellStatus
= SHELL_ACCESS_DENIED
;
1253 Status
= gBS
->CreateEvent (
1256 IfConfig6ManualAddressNotify
,
1260 if (EFI_ERROR (Status
)) {
1261 ShellStatus
= SHELL_ACCESS_DENIED
;
1265 // Parse the setting variables.
1267 while (VarArg
!= NULL
) {
1269 // Check invalid parameters (duplication & unknown & conflict).
1271 CheckCode
= IfConfig6RetriveCheckListByName(
1272 mIfConfig6SetCheckList
,
1277 if (VarCheckOk
!= CheckCode
) {
1278 switch (CheckCode
) {
1279 case VarCheckDuplicate
:
1280 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_DUPLICATE_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1283 case VarCheckConflict
:
1284 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_CONFLICT_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1287 case VarCheckUnknown
:
1288 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_UNKNOWN_COMMAND
), gShellNetwork2HiiHandle
, VarArg
->Arg
);
1295 VarArg
= VarArg
->Next
;
1299 // Process valid variables.
1301 if (StrCmp(VarArg
->Arg
, L
"auto") == 0) {
1303 // Set automaic config policy
1305 Policy
= Ip6ConfigPolicyAutomatic
;
1306 Status
= IfCb
->IfCfg
->SetData (
1308 Ip6ConfigDataTypePolicy
,
1309 sizeof (EFI_IP6_CONFIG_POLICY
),
1313 if (EFI_ERROR(Status
)) {
1314 ShellStatus
= SHELL_ACCESS_DENIED
;
1318 VarArg
= VarArg
->Next
;
1320 if (VarArg
!= NULL
) {
1321 if (StrCmp (VarArg
->Arg
, L
"host") == 0) {
1322 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG
), gShellNetwork2HiiHandle
, Status
);
1323 ShellStatus
= SHELL_INVALID_PARAMETER
;
1325 } else if (StrCmp (VarArg
->Arg
, L
"gw") == 0) {
1326 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG
), gShellNetwork2HiiHandle
, Status
);
1327 ShellStatus
= SHELL_INVALID_PARAMETER
;
1329 } else if (StrCmp (VarArg
->Arg
, L
"dns") == 0) {
1330 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG
), gShellNetwork2HiiHandle
, Status
);
1331 ShellStatus
= SHELL_INVALID_PARAMETER
;
1335 } else if (StrCmp (VarArg
->Arg
, L
"man") == 0) {
1337 // Set manual config policy.
1339 Policy
= Ip6ConfigPolicyManual
;
1340 Status
= IfCb
->IfCfg
->SetData (
1342 Ip6ConfigDataTypePolicy
,
1343 sizeof (EFI_IP6_CONFIG_POLICY
),
1347 if (EFI_ERROR(Status
)) {
1348 ShellStatus
= SHELL_ACCESS_DENIED
;
1352 VarArg
= VarArg
->Next
;
1354 } else if (StrCmp (VarArg
->Arg
, L
"host") == 0) {
1356 // Parse till the next tag or the end of command line.
1358 VarArg
= VarArg
->Next
;
1359 Status
= IfConfig6ParseManualAddressList (
1365 if (EFI_ERROR (Status
)) {
1366 if (Status
== EFI_INVALID_PARAMETER
) {
1367 ShellStatus
= SHELL_INVALID_PARAMETER
;
1368 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"host");
1371 ShellStatus
= SHELL_ACCESS_DENIED
;
1376 // Set static host ip6 address list.
1377 // This is a asynchronous process.
1379 IsAddressOk
= FALSE
;
1381 Status
= IfCb
->IfCfg
->RegisterDataNotify (
1383 Ip6ConfigDataTypeManualAddress
,
1386 if (EFI_ERROR (Status
)) {
1387 ShellStatus
= SHELL_ACCESS_DENIED
;
1391 Status
= IfCb
->IfCfg
->SetData (
1393 Ip6ConfigDataTypeManualAddress
,
1398 if (Status
== EFI_NOT_READY
) {
1400 // Get current dad transmits count.
1402 CurDadXmitsLen
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
1403 IfCb
->IfCfg
->GetData (
1405 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1410 gBS
->SetTimer (TimeOutEvt
, TimerRelative
, 50000000 + 10000000 * CurDadXmits
);
1412 while (EFI_ERROR (gBS
->CheckEvent (TimeOutEvt
))) {
1414 Status
= EFI_SUCCESS
;
1420 IfCb
->IfCfg
->UnregisterDataNotify (
1422 Ip6ConfigDataTypeManualAddress
,
1426 if (EFI_ERROR (Status
)) {
1427 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_MAN_HOST
), gShellNetwork2HiiHandle
, Status
);
1428 ShellStatus
= SHELL_ACCESS_DENIED
;
1433 // Check whether the address is set successfully.
1437 Status
= IfCb
->IfCfg
->GetData (
1439 Ip6ConfigDataTypeInterfaceInfo
,
1444 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
1445 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
1446 ShellStatus
= SHELL_ACCESS_DENIED
;
1450 IfInfo
= AllocateZeroPool (DataSize
);
1452 if (IfInfo
== NULL
) {
1453 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1457 Status
= IfCb
->IfCfg
->GetData (
1459 Ip6ConfigDataTypeInterfaceInfo
,
1464 if (EFI_ERROR (Status
)) {
1465 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA
), gShellNetwork2HiiHandle
, Status
);
1466 ShellStatus
= SHELL_ACCESS_DENIED
;
1470 for ( Index
= 0; Index
< (UINTN
) (AddrSize
/ sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
)); Index
++) {
1471 IsAddressSet
= FALSE
;
1473 // By default, the prefix length 0 is regarded as 64.
1475 if (CfgManAddr
[Index
].PrefixLength
== 0) {
1476 CfgManAddr
[Index
].PrefixLength
= 64;
1479 for (Index2
= 0; Index2
< IfInfo
->AddressInfoCount
; Index2
++) {
1480 if (EFI_IP6_EQUAL (&IfInfo
->AddressInfo
[Index2
].Address
, &CfgManAddr
[Index
].Address
) &&
1481 (IfInfo
->AddressInfo
[Index2
].PrefixLength
== CfgManAddr
[Index
].PrefixLength
)) {
1482 IsAddressSet
= TRUE
;
1487 if (!IsAddressSet
) {
1488 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_ADDRESS_FAILED
), gShellNetwork2HiiHandle
);
1489 IfConfig6PrintIpAddr (
1490 &CfgManAddr
[Index
].Address
,
1491 &CfgManAddr
[Index
].PrefixLength
1496 } else if (StrCmp (VarArg
->Arg
, L
"gw") == 0) {
1498 // Parse till the next tag or the end of command line.
1500 VarArg
= VarArg
->Next
;
1501 Status
= IfConfig6ParseGwDnsAddressList (
1507 if (EFI_ERROR (Status
)) {
1508 if (Status
== EFI_INVALID_PARAMETER
) {
1509 ShellStatus
= SHELL_INVALID_PARAMETER
;
1510 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"gw");
1513 ShellStatus
= SHELL_ACCESS_DENIED
;
1518 // Set static gateway ip6 address list.
1520 Status
= IfCb
->IfCfg
->SetData (
1522 Ip6ConfigDataTypeGateway
,
1527 if (EFI_ERROR (Status
)) {
1528 ShellStatus
= SHELL_ACCESS_DENIED
;
1529 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_MAN_GW
), gShellNetwork2HiiHandle
, Status
);
1533 } else if (StrCmp (VarArg
->Arg
, L
"dns") == 0) {
1535 // Parse till the next tag or the end of command line.
1537 VarArg
= VarArg
->Next
;
1538 Status
= IfConfig6ParseGwDnsAddressList (
1544 if (EFI_ERROR (Status
)) {
1545 if (Status
== EFI_INVALID_PARAMETER
) {
1546 ShellStatus
= SHELL_INVALID_PARAMETER
;
1547 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS
), gShellNetwork2HiiHandle
, L
"dns");
1550 ShellStatus
= SHELL_ACCESS_DENIED
;
1555 // Set static DNS server ip6 address list.
1557 Status
= IfCb
->IfCfg
->SetData (
1559 Ip6ConfigDataTypeDnsServer
,
1564 if (EFI_ERROR (Status
)) {
1565 ShellStatus
= SHELL_ACCESS_DENIED
;
1569 } else if (StrCmp (VarArg
->Arg
, L
"id") == 0) {
1571 // Parse till the next tag or the end of command line.
1573 VarArg
= VarArg
->Next
;
1574 Status
= IfConfig6ParseInterfaceId (&VarArg
, &InterfaceId
);
1576 if (EFI_ERROR (Status
)) {
1577 ShellStatus
= SHELL_INVALID_PARAMETER
;
1581 // Set alternative interface id.
1583 Status
= IfCb
->IfCfg
->SetData (
1585 Ip6ConfigDataTypeAltInterfaceId
,
1586 sizeof (EFI_IP6_CONFIG_INTERFACE_ID
),
1590 if (EFI_ERROR (Status
)) {
1591 ShellStatus
= SHELL_ACCESS_DENIED
;
1595 } else if (StrCmp (VarArg
->Arg
, L
"dad") == 0) {
1597 // Parse till the next tag or the end of command line.
1599 VarArg
= VarArg
->Next
;
1600 Status
= IfConfig6ParseDadXmits (&VarArg
, &DadXmits
);
1602 if (EFI_ERROR (Status
)) {
1603 ShellStatus
= SHELL_ACCESS_DENIED
;
1607 // Set dad transmits count.
1609 Status
= IfCb
->IfCfg
->SetData (
1611 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1612 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
),
1616 if (EFI_ERROR(Status
)) {
1617 ShellStatus
= SHELL_ACCESS_DENIED
;
1625 if (CfgManAddr
!= NULL
) {
1626 FreePool (CfgManAddr
);
1629 if (CfgAddr
!= NULL
) {
1633 if (MappedEvt
!= NULL
) {
1634 gBS
->CloseEvent (MappedEvt
);
1637 if (TimeOutEvt
!= NULL
) {
1638 gBS
->CloseEvent (TimeOutEvt
);
1641 if (IfInfo
!= NULL
) {
1650 The IfConfig6 main process.
1652 @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
1654 @retval SHELL_SUCCESS IfConfig6 processed successfully.
1655 @retval others The IfConfig6 process failed.
1660 IN IFCONFIG6_PRIVATE_DATA
*Private
1664 SHELL_STATUS ShellStatus
;
1666 ShellStatus
= SHELL_SUCCESS
;
1669 // Get configure information of all interfaces.
1671 Status
= IfConfig6GetInterfaceInfo (
1672 Private
->ImageHandle
,
1677 if (EFI_ERROR (Status
)) {
1678 ShellStatus
= SHELL_NOT_FOUND
;
1682 switch (Private
->OpCode
) {
1683 case IfConfig6OpList
:
1684 ShellStatus
= IfConfig6ShowInterfaceInfo (&Private
->IfList
);
1687 case IfConfig6OpClear
:
1688 ShellStatus
= IfConfig6ClearInterfaceInfo (&Private
->IfList
, Private
->IfName
);
1691 case IfConfig6OpSet
:
1692 ShellStatus
= IfConfig6SetInterfaceInfo (&Private
->IfList
, Private
->VarArg
);
1696 ShellStatus
= SHELL_UNSUPPORTED
;
1705 The IfConfig6 cleanup process, free the allocated memory.
1707 @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
1712 IN IFCONFIG6_PRIVATE_DATA
*Private
1716 LIST_ENTRY
*NextEntry
;
1717 IFCONFIG6_INTERFACE_CB
*IfCb
;
1719 ASSERT (Private
!= NULL
);
1722 // Clean the list which save the set config Args.
1724 if (Private
->VarArg
!= NULL
) {
1725 IfConfig6FreeArgList (Private
->VarArg
);
1728 if (Private
->IfName
!= NULL
)
1729 FreePool (Private
->IfName
);
1733 // Clean the IFCONFIG6_INTERFACE_CB list.
1735 Entry
= Private
->IfList
.ForwardLink
;
1736 NextEntry
= Entry
->ForwardLink
;
1738 while (Entry
!= &Private
->IfList
) {
1740 IfCb
= BASE_CR (Entry
, IFCONFIG6_INTERFACE_CB
, Link
);
1742 RemoveEntryList (&IfCb
->Link
);
1744 if (IfCb
->IfId
!= NULL
) {
1746 FreePool (IfCb
->IfId
);
1749 if (IfCb
->IfInfo
!= NULL
) {
1751 FreePool (IfCb
->IfInfo
);
1757 NextEntry
= Entry
->ForwardLink
;
1764 Function for 'ifconfig6' command.
1766 @param[in] ImageHandle Handle to the Image (NULL if Internal).
1767 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
1769 @retval SHELL_SUCCESS ifconfig6 command processed successfully.
1770 @retval others The ifconfig6 command process failed.
1775 ShellCommandRunIfconfig6 (
1776 IN EFI_HANDLE ImageHandle
,
1777 IN EFI_SYSTEM_TABLE
*SystemTable
1781 SHELL_STATUS ShellStatus
;
1782 IFCONFIG6_PRIVATE_DATA
*Private
;
1783 LIST_ENTRY
*ParamPackage
;
1784 CONST CHAR16
*ValueStr
;
1786 CHAR16
*ProblemParam
;
1790 Status
= EFI_INVALID_PARAMETER
;
1791 ShellStatus
= SHELL_SUCCESS
;
1793 Status
= ShellCommandLineParseEx (mIfConfig6CheckList
, &ParamPackage
, &ProblemParam
, TRUE
, FALSE
);
1794 if (EFI_ERROR (Status
)) {
1795 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_COMMAND
), gShellNetwork2HiiHandle
, L
"ifconfig6", ProblemParam
);
1796 ShellStatus
= SHELL_INVALID_PARAMETER
;
1801 // To handle no option.
1803 if (!ShellCommandLineGetFlag (ParamPackage
, L
"-r") && !ShellCommandLineGetFlag (ParamPackage
, L
"-s") &&
1804 !ShellCommandLineGetFlag (ParamPackage
, L
"-?") && !ShellCommandLineGetFlag (ParamPackage
, L
"-l")) {
1805 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_LACK_OPTION
), gShellNetwork2HiiHandle
);
1806 ShellStatus
= SHELL_INVALID_PARAMETER
;
1810 // To handle conflict options.
1812 if (((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-s"))) ||
1813 ((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-l"))) ||
1814 ((ShellCommandLineGetFlag (ParamPackage
, L
"-r")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?"))) ||
1815 ((ShellCommandLineGetFlag (ParamPackage
, L
"-s")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-l"))) ||
1816 ((ShellCommandLineGetFlag (ParamPackage
, L
"-s")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?"))) ||
1817 ((ShellCommandLineGetFlag (ParamPackage
, L
"-l")) && (ShellCommandLineGetFlag (ParamPackage
, L
"-?")))) {
1818 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_CONFLICT_OPTIONS
), gShellNetwork2HiiHandle
);
1819 ShellStatus
= SHELL_INVALID_PARAMETER
;
1823 Private
= AllocateZeroPool (sizeof (IFCONFIG6_PRIVATE_DATA
));
1825 if (Private
== NULL
) {
1826 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1830 InitializeListHead (&Private
->IfList
);
1833 // To get interface name for the list option.
1835 if (ShellCommandLineGetFlag (ParamPackage
, L
"-l")) {
1836 Private
->OpCode
= IfConfig6OpList
;
1837 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-l");
1838 if (ValueStr
!= NULL
) {
1839 Str
= AllocateCopyPool (StrSize (ValueStr
), ValueStr
);
1841 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1842 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1845 Private
->IfName
= Str
;
1849 // To get interface name for the clear option.
1851 if (ShellCommandLineGetFlag (ParamPackage
, L
"-r")) {
1852 Private
->OpCode
= IfConfig6OpClear
;
1853 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-r");
1854 if (ValueStr
!= NULL
) {
1855 Str
= AllocateCopyPool (StrSize (ValueStr
), ValueStr
);
1857 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1858 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1861 Private
->IfName
= Str
;
1865 // To get interface name and corresponding Args for the set option.
1867 if (ShellCommandLineGetFlag (ParamPackage
, L
"-s")) {
1869 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-s");
1870 if (ValueStr
== NULL
) {
1871 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_INTERFACE
), gShellNetwork2HiiHandle
);
1872 ShellStatus
= SHELL_INVALID_PARAMETER
;
1876 // To split the configuration into multi-section.
1878 ArgList
= IfConfig6SplitStrToList (ValueStr
, L
' ');
1879 if (ArgList
== NULL
) {
1880 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellNetwork2HiiHandle
, L
"ifconfig6");
1881 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1885 Private
->OpCode
= IfConfig6OpSet
;
1886 Private
->IfName
= ArgList
->Arg
;
1888 Private
->VarArg
= ArgList
->Next
;
1890 if (Private
->IfName
== NULL
|| Private
->VarArg
== NULL
) {
1891 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_COMMAND
), gShellNetwork2HiiHandle
);
1892 ShellStatus
= SHELL_INVALID_PARAMETER
;
1897 // Main process of ifconfig6.
1899 ShellStatus
= IfConfig6 (Private
);
1903 ShellCommandLineFreeVarList (ParamPackage
);
1904 if (Private
!= NULL
) {
1905 IfConfig6Cleanup (Private
);