NetworkPkg/Application/IfConfig6/IfConfig6.c | 1793 -------------------- NetworkPkg/Application/IfConfig6/IfConfig6.h | 79 - NetworkPkg/Application/IfConfig6/IfConfig6.inf | 67 - NetworkPkg/Application/IfConfig6/IfConfig6.uni | 23 - .../Application/IfConfig6/IfConfig6Extra.uni | 20 - .../Application/IfConfig6/IfConfig6Strings.uni | 92 - NetworkPkg/Application/Ping6/Ia32/Tsc.c | 28 - NetworkPkg/Application/Ping6/Ipf/Itc.c | 28 - NetworkPkg/Application/Ping6/Ping6.c | 1200 ------------- NetworkPkg/Application/Ping6/Ping6.h | 87 - NetworkPkg/Application/Ping6/Ping6.inf | 78 - NetworkPkg/Application/Ping6/Ping6.uni | 22 - NetworkPkg/Application/Ping6/Ping6Extra.uni | 20 - NetworkPkg/Application/Ping6/Ping6Strings.uni | 53 - NetworkPkg/Application/Ping6/X64/Tsc.c | 28 - NetworkPkg/NetworkPkg.dsc | 3 - 16 files changed, 3621 deletions(-) delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.c delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.h delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.inf delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.uni delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni delete mode 100644 NetworkPkg/Application/Ping6/Ia32/Tsc.c delete mode 100644 NetworkPkg/Application/Ping6/Ipf/Itc.c delete mode 100644 NetworkPkg/Application/Ping6/Ping6.c delete mode 100644 NetworkPkg/Application/Ping6/Ping6.h delete mode 100644 NetworkPkg/Application/Ping6/Ping6.inf delete mode 100644 NetworkPkg/Application/Ping6/Ping6.uni delete mode 100644 NetworkPkg/Application/Ping6/Ping6Extra.uni delete mode 100644 NetworkPkg/Application/Ping6/Ping6Strings.uni delete mode 100644 NetworkPkg/Application/Ping6/X64/Tsc.c
Edk2 has duplicated ping6/ifconfig6 implementation in NetworkPkg and ShellPkg.
The usage and parameter format of these 2 versions are exactly same. These two
commands have been added to Shell specification so the copy under
ShellPkg\Library\UefiShellNetwork2CommandsLib\
will be actively maintained in future.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
---
NetworkPkg/Application/IfConfig6/IfConfig6.c | 1793 --------------------
NetworkPkg/Application/IfConfig6/IfConfig6.h | 79 -
NetworkPkg/Application/IfConfig6/IfConfig6.inf | 67 -
NetworkPkg/Application/IfConfig6/IfConfig6.uni | 23 -
.../Application/IfConfig6/IfConfig6Extra.uni | 20 -
.../Application/IfConfig6/IfConfig6Strings.uni | 92 -
NetworkPkg/Application/Ping6/Ia32/Tsc.c | 28 -
NetworkPkg/Application/Ping6/Ipf/Itc.c | 28 -
NetworkPkg/Application/Ping6/Ping6.c | 1200 -------------
NetworkPkg/Application/Ping6/Ping6.h | 87 -
NetworkPkg/Application/Ping6/Ping6.inf | 78 -
NetworkPkg/Application/Ping6/Ping6.uni | 22 -
NetworkPkg/Application/Ping6/Ping6Extra.uni | 20 -
NetworkPkg/Application/Ping6/Ping6Strings.uni | 53 -
NetworkPkg/Application/Ping6/X64/Tsc.c | 28 -
NetworkPkg/NetworkPkg.dsc | 3 -
16 files changed, 3621 deletions(-)
delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.c
delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.h
delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.inf
delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.uni
delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni
delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni
delete mode 100644 NetworkPkg/Application/Ping6/Ia32/Tsc.c
delete mode 100644 NetworkPkg/Application/Ping6/Ipf/Itc.c
delete mode 100644 NetworkPkg/Application/Ping6/Ping6.c
delete mode 100644 NetworkPkg/Application/Ping6/Ping6.h
delete mode 100644 NetworkPkg/Application/Ping6/Ping6.inf
delete mode 100644 NetworkPkg/Application/Ping6/Ping6.uni
delete mode 100644 NetworkPkg/Application/Ping6/Ping6Extra.uni
delete mode 100644 NetworkPkg/Application/Ping6/Ping6Strings.uni
delete mode 100644 NetworkPkg/Application/Ping6/X64/Tsc.c
diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.c b/NetworkPkg/Application/IfConfig6/IfConfig6.c
deleted file mode 100644
index 48c3be3552..0000000000
--- a/NetworkPkg/Application/IfConfig6/IfConfig6.c
+++ /dev/null
@@ -1,1793 +0,0 @@
-/** @file
- The implementation for Shell application IfConfig6.
-
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/ShellLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiHiiServicesLib.h>
-#include <Library/HiiLib.h>
-#include <Library/NetLib.h>
-
-#include <Protocol/Ip6.h>
-#include <Protocol/Ip6Config.h>
-
-#include "IfConfig6.h"
-
-//
-// String token ID of ifconfig6 command help message text.
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringIfconfig6HelpTokenId = STRING_TOKEN (STR_IFCONFIG6_HELP);
-
-EFI_HII_HANDLE mHiiHandle;
-
-SHELL_PARAM_ITEM mIfConfig6CheckList[] = {
- {
- L"-b",
- TypeFlag
- },
- {
- L"-s",
- TypeMaxValue
- },
- {
- L"-l",
- TypeValue
- },
- {
- L"-r",
- TypeValue
- },
- {
- NULL,
- TypeMax
- },
-};
-
-VAR_CHECK_ITEM mSetCheckList[] = {
- {
- L"auto",
- 0x00000001,
- 0x00000001,
- FlagTypeSingle
- },
- {
- L"man",
- 0x00000002,
- 0x00000001,
- FlagTypeSingle
- },
- {
- L"host",
- 0x00000004,
- 0x00000002,
- FlagTypeSingle
- },
- {
- L"dad",
- 0x00000008,
- 0x00000004,
- FlagTypeSingle
- },
- {
- L"gw",
- 0x00000010,
- 0x00000008,
- FlagTypeSingle
- },
- {
- L"dns",
- 0x00000020,
- 0x00000010,
- FlagTypeSingle
- },
- {
- L"id",
- 0x00000040,
- 0x00000020,
- FlagTypeSingle
- },
- {
- NULL,
- 0x0,
- 0x0,
- FlagTypeSkipUnknown
- },
-};
-
-/**
- Split a string with specified separator and save the substring to a list.
-
- @param[in] String The pointer of the input string.
- @param[in] Separator The specified separator.
-
- @return The pointer of headnode of ARG_LIST.
-
-**/
-ARG_LIST *
-SplitStrToList (
- IN CONST CHAR16 *String,
- IN CHAR16 Separator
- )
-{
- CHAR16 *Str;
- CHAR16 *ArgStr;
- ARG_LIST *ArgList;
- ARG_LIST *ArgNode;
-
- if (String == NULL || *String == L'\0') {
- return NULL;
- }
-
- //
- // Copy the CONST string to a local copy.
- //
- Str = AllocateCopyPool (StrSize (String), String);
- ASSERT (Str != NULL);
- ArgStr = Str;
-
- //
- // init a node for the list head.
- //
- ArgNode = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));
- ASSERT (ArgNode != NULL);
- ArgList = ArgNode;
-
- //
- // Split the local copy and save in the list node.
- //
- while (*Str != L'\0') {
- if (*Str == Separator) {
- *Str = L'\0';
- ArgNode->Arg = ArgStr;
- ArgStr = Str + 1;
- ArgNode->Next = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));
- ASSERT (ArgNode->Next != NULL);
- ArgNode = ArgNode->Next;
- }
-
- Str++;
- }
-
- ArgNode->Arg = ArgStr;
- ArgNode->Next = NULL;
-
- return ArgList;
-}
-
-/**
- Check the correctness of input Args with '-s' option.
-
- @param[in] CheckList The pointer of VAR_CHECK_ITEM array.
- @param[in] Name The pointer of input arg.
- @param[in] Init The switch to execute the check.
-
- @return The value of VAR_CHECK_CODE.
-
-**/
-VAR_CHECK_CODE
-IfConfig6RetriveCheckListByName(
- IN VAR_CHECK_ITEM *CheckList,
- IN CHAR16 *Name,
- IN BOOLEAN Init
-)
-{
- STATIC UINT32 CheckDuplicate;
- STATIC UINT32 CheckConflict;
- VAR_CHECK_CODE RtCode;
- UINT32 Index;
- VAR_CHECK_ITEM Arg;
-
- if (Init) {
- CheckDuplicate = 0;
- CheckConflict = 0;
- return VarCheckOk;
- }
-
- RtCode = VarCheckOk;
- Index = 0;
- Arg = CheckList[Index];
-
- //
- // Check the Duplicated/Conflicted/Unknown input Args.
- //
- while (Arg.FlagStr != NULL) {
- if (StrCmp (Arg.FlagStr, Name) == 0) {
-
- if (CheckDuplicate & Arg.FlagID) {
- RtCode = VarCheckDuplicate;
- break;
- }
-
- if (CheckConflict & Arg.ConflictMask) {
- RtCode = VarCheckConflict;
- break;
- }
-
- CheckDuplicate |= Arg.FlagID;
- CheckConflict |= Arg.ConflictMask;
- break;
- }
-
- Arg = CheckList[++Index];
- }
-
- if (Arg.FlagStr == NULL) {
- RtCode = VarCheckUnknown;
- }
-
- return RtCode;
-}
-
-/**
- The notify function of create event when performing a manual config.
-
- @param[in] Event The event this notify function registered to.
- @param[in] Context Pointer to the context data registered to the event.
-
-**/
-VOID
-EFIAPI
-IfConfig6ManualAddressNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- *((BOOLEAN *) Context) = TRUE;
-}
-
-/**
- Print MAC address.
-
- @param[in] Node The pointer of MAC address buffer.
- @param[in] Size The size of MAC address buffer.
-
-**/
-VOID
-IfConfig6PrintMacAddr (
- IN UINT8 *Node,
- IN UINT32 Size
- )
-{
- UINTN Index;
-
- ASSERT (Size <= MACADDRMAXSIZE);
-
- for (Index = 0; Index < Size; Index++) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_BODY), mHiiHandle, Node[Index]);
- if (Index + 1 < Size) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle);
- }
- }
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle);
-}
-
-/**
- Print IPv6 address.
-
- @param[in] Ip The pointer of Ip bufffer in EFI_IPv6_ADDRESS format.
- @param[in] PrefixLen The pointer of PrefixLen that describes the size Prefix.
-
-**/
-VOID
-IfConfig6PrintIpAddr (
- IN EFI_IPv6_ADDRESS *Ip,
- IN UINT8 *PrefixLen
- )
-{
- UINTN Index;
- BOOLEAN Short;
-
- Short = FALSE;
-
- for (Index = 0; Index < PREFIXMAXLEN; Index = Index + 2) {
-
- if (!Short && (Index + 1 < PREFIXMAXLEN) && (Index % 2 == 0) && (Ip->Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0)) {
- //
- // Deal with the case of ::.
- //
- if (Index == 0) {
- //
- // :: is at the beginning of the address.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle);
- }
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle);
-
- while ((Ip->Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0) && (Index < PREFIXMAXLEN)) {
- Index = Index + 2;
- if (Index > PREFIXMAXLEN - 2) {
- break;
- }
- }
-
- Short = TRUE;
-
- if (Index == PREFIXMAXLEN) {
- //
- // :: is at the end of the address.
- //
- break;
- }
- }
-
- if (Index < PREFIXMAXLEN - 1) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY), mHiiHandle, Ip->Addr[Index]);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY), mHiiHandle, Ip->Addr[Index + 1]);
- }
-
- if (Index + 2 < PREFIXMAXLEN) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle);
- }
- }
-
- if (PrefixLen != NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_PREFIX_LEN), mHiiHandle, *PrefixLen);
- }
-}
-
-/**
- Pick up host IPv6 address in string format from Args with "-s" option and convert it to EFI_IP6_CONFIG_MANUAL_ADDRESS format.
-
- @param[in, out] Arg The pointer of the address of ARG_LIST which save Args with the "-s" option.
- @param[out] Buf The pointer of the address of EFI_IP6_CONFIG_MANUAL_ADDRESS.
- @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
-
- @retval EFI_SUCCESS The convertion is successful.
- @retval Others Does't find the host address, or it is an invalid IPv6 address in string format.
-
-**/
-EFI_STATUS
-IfConfig6ParseManualAddressList (
- IN OUT ARG_LIST **Arg,
- OUT EFI_IP6_CONFIG_MANUAL_ADDRESS **Buf,
- OUT UINTN *BufSize
- )
-{
- EFI_STATUS Status;
- EFI_IP6_CONFIG_MANUAL_ADDRESS *AddrBuf;
- ARG_LIST *VarArg;
- EFI_IPv6_ADDRESS Address;
- UINT8 Prefix;
- UINT8 AddrCnt;
-
- Prefix = 0;
- AddrCnt = 0;
- *BufSize = 0;
- *Buf = NULL;
- VarArg = *Arg;
- Status = EFI_SUCCESS;
-
- //
- // Go through the list to check the correctness of input host ip6 address.
- //
- while ((!EFI_ERROR (Status)) && (VarArg != NULL)) {
-
- Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix);
-
- if (EFI_ERROR (Status)) {
- //
- // host ip ip ... gw
- //
- break;
- }
-
- VarArg = VarArg->Next;
- AddrCnt++;
- }
-
- if (AddrCnt == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- AddrBuf = AllocateZeroPool (AddrCnt * sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS));
- ASSERT (AddrBuf != NULL);
-
- AddrCnt = 0;
- VarArg = *Arg;
- Status = EFI_SUCCESS;
-
- //
- // Go through the list to fill in the EFI_IP6_CONFIG_MANUAL_ADDRESS structure.
- //
- while ((!EFI_ERROR (Status)) && (VarArg != NULL)) {
-
- Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix);
-
- if (EFI_ERROR (Status)) {
- break;
- }
-
- //
- // If prefix length is not set, set it as Zero here. In the IfConfigSetInterfaceInfo()
- // Zero prefix, length will be transfered to default prefix length.
- //
- if (Prefix == 0xFF) {
- Prefix = 0;
- }
- AddrBuf[AddrCnt].IsAnycast = FALSE;
- AddrBuf[AddrCnt].PrefixLength = Prefix;
- IP6_COPY_ADDRESS (&AddrBuf[AddrCnt].Address, &Address);
- VarArg = VarArg->Next;
- AddrCnt++;
- }
-
- *Arg = VarArg;
-
- if (EFI_ERROR (Status) && (Status != EFI_INVALID_PARAMETER)) {
- goto ON_ERROR;
- }
-
- *Buf = AddrBuf;
- *BufSize = AddrCnt * sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS);
-
- return EFI_SUCCESS;
-
-ON_ERROR:
-
- FreePool (AddrBuf);
- return Status;
-}
-
-/**
- Pick up gw/dns IPv6 address in string format from Args with "-s" option and convert it to EFI_IPv6_ADDRESS format.
-
- @param[in, out] Arg The pointer of the address of ARG_LIST that save Args with the "-s" option.
- @param[out] Buf The pointer of the address of EFI_IPv6_ADDRESS.
- @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes.
-
- @retval EFI_SUCCESS The conversion is successful.
- @retval Others Doesn't find the host address, or it is an invalid IPv6 address in string format.
-
-**/
-EFI_STATUS
-IfConfig6ParseGwDnsAddressList (
- IN OUT ARG_LIST **Arg,
- OUT EFI_IPv6_ADDRESS **Buf,
- OUT UINTN *BufSize
- )
-{
- EFI_STATUS Status;
- EFI_IPv6_ADDRESS *AddrBuf;
- ARG_LIST *VarArg;
- EFI_IPv6_ADDRESS Address;
- UINT8 Prefix;
- UINT8 AddrCnt;
-
- AddrCnt = 0;
- *BufSize = 0;
- *Buf = NULL;
- VarArg = *Arg;
- Status = EFI_SUCCESS;
-
- //
- // Go through the list to check the correctness of input gw/dns address.
- //
- while ((!EFI_ERROR (Status)) && (VarArg != NULL)) {
-
- Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix);
-
- if (EFI_ERROR (Status)) {
- //
- // gw ip ip ... host
- //
- break;
- }
-
- VarArg = VarArg->Next;
- AddrCnt++;
- }
-
- if (AddrCnt == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- AddrBuf = AllocateZeroPool (AddrCnt * sizeof (EFI_IPv6_ADDRESS));
- ASSERT (AddrBuf != NULL);
-
- AddrCnt = 0;
- VarArg = *Arg;
- Status = EFI_SUCCESS;
-
- //
- // Go through the list to fill in the EFI_IPv6_ADDRESS structure.
- //
- while ((!EFI_ERROR (Status)) && (VarArg != NULL)) {
-
- Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix);
-
- if (EFI_ERROR (Status)) {
- break;
- }
-
- IP6_COPY_ADDRESS (&AddrBuf[AddrCnt], &Address);
-
- VarArg = VarArg->Next;
- AddrCnt++;
- }
-
- *Arg = VarArg;
-
- if (EFI_ERROR (Status) && (Status != EFI_INVALID_PARAMETER)) {
- goto ON_ERROR;
- }
-
- *Buf = AddrBuf;
- *BufSize = AddrCnt * sizeof (EFI_IPv6_ADDRESS);
-
- return EFI_SUCCESS;
-
-ON_ERROR:
-
- FreePool (AddrBuf);
- return Status;
-}
-
-/**
- Parse InterfaceId in string format from Args with the "-s" option and convert it to EFI_IP6_CONFIG_INTERFACE_ID format.
-
- @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
- @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
-
- @retval EFI_SUCCESS The get status processed successfullly.
- @retval EFI_INVALID_PARAMETER The get status process failed.
-
-**/
-EFI_STATUS
-IfConfig6ParseInterfaceId (
- IN OUT ARG_LIST **Arg,
- OUT EFI_IP6_CONFIG_INTERFACE_ID **IfId
- )
-{
- UINT8 Index;
- UINT8 NodeVal;
- CHAR16 *IdStr;
-
- if (*Arg == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Index = 0;
- IdStr = (*Arg)->Arg;
- ASSERT (IfId != NULL);
- *IfId = AllocateZeroPool (sizeof (EFI_IP6_CONFIG_INTERFACE_ID));
- ASSERT (*IfId != NULL);
-
- while ((*IdStr != L'\0') && (Index < 8)) {
-
- NodeVal = 0;
- while ((*IdStr != L':') && (*IdStr != L'\0')) {
-
- if ((*IdStr <= L'F') && (*IdStr >= L'A')) {
- NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'A' + 10);
- } else if ((*IdStr <= L'f') && (*IdStr >= L'a')) {
- NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'a' + 10);
- } else if ((*IdStr <= L'9') && (*IdStr >= L'0')) {
- NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'0');
- } else {
- FreePool (*IfId);
- return EFI_INVALID_PARAMETER;
- }
-
- IdStr++;
- }
-
- (*IfId)->Id[Index++] = NodeVal;
-
- if (*IdStr == L':') {
- IdStr++;
- }
- }
-
- *Arg = (*Arg)->Next;
- return EFI_SUCCESS;
-}
-
-/**
- Parse dad in string format from Args with the "-s" option and convert it to UINT32 format.
-
- @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option.
- @param[out] Xmits The pointer of Xmits.
-
- @retval EFI_SUCCESS The get status processed successfully.
- @retval others The get status process failed.
-
-**/
-EFI_STATUS
-IfConfig6ParseDadXmits (
- IN OUT ARG_LIST **Arg,
- OUT UINT32 *Xmits
- )
-{
- CHAR16 *ValStr;
-
- if (*Arg == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ValStr = (*Arg)->Arg;
- *Xmits = 0;
-
- while (*ValStr != L'\0') {
-
- if ((*ValStr <= L'9') && (*ValStr >= L'0')) {
-
- *Xmits = (*Xmits * 10) + (*ValStr - L'0');
-
- } else {
-
- return EFI_INVALID_PARAMETER;
- }
-
- ValStr++;
- }
-
- *Arg = (*Arg)->Next;
- return EFI_SUCCESS;
-}
-
-/**
- The get current status of all handles.
-
- @param[in] ImageHandle The handle of ImageHandle.
- @param[in] IfName The pointer of IfName(interface name).
- @param[in] IfList The pointer of IfList(interface list).
-
- @retval EFI_SUCCESS The get status processed successfully.
- @retval others The get status process failed.
-
-**/
-EFI_STATUS
-IfConfig6GetInterfaceInfo (
- IN EFI_HANDLE ImageHandle,
- IN CHAR16 *IfName,
- IN LIST_ENTRY *IfList
- )
-{
- EFI_STATUS Status;
- UINTN HandleIndex;
- UINTN HandleNum;
- EFI_HANDLE *HandleBuffer;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
- IFCONFIG6_INTERFACE_CB *IfCb;
- UINTN DataSize;
-
- HandleBuffer = NULL;
- HandleNum = 0;
-
- IfInfo = NULL;
- IfCb = NULL;
-
- //
- // Locate all the handles with ip6 service binding protocol.
- //
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiIp6ServiceBindingProtocolGuid,
- NULL,
- &HandleNum,
- &HandleBuffer
- );
- if (EFI_ERROR (Status) || (HandleNum == 0)) {
- return EFI_ABORTED;
- }
-
- //
- // Enumerate all handles that installed with ip6 service binding protocol.
- //
- for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
- IfCb = NULL;
- IfInfo = NULL;
- DataSize = 0;
-
- //
- // Ip6config protocol and ip6 service binding protocol are installed
- // on the same handle.
- //
- ASSERT (HandleBuffer != NULL);
- Status = gBS->HandleProtocol (
- HandleBuffer[HandleIndex],
- &gEfiIp6ConfigProtocolGuid,
- (VOID **) &Ip6Cfg
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
- //
- // Get the interface information size.
- //
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &DataSize,
- NULL
- );
-
- if (Status != EFI_BUFFER_TOO_SMALL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
-
- IfInfo = AllocateZeroPool (DataSize);
-
- if (IfInfo == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_ERROR;
- }
- //
- // Get the interface info.
- //
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &DataSize,
- IfInfo
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
- //
- // Check the interface name if required.
- //
- if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) != 0)) {
- FreePool (IfInfo);
- continue;
- }
-
- DataSize = 0;
- //
- // Get the size of dns server list.
- //
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeDnsServer,
- &DataSize,
- NULL
- );
-
- if ((Status != EFI_BUFFER_TOO_SMALL) && (Status != EFI_NOT_FOUND)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
-
- IfCb = AllocateZeroPool (sizeof (IFCONFIG6_INTERFACE_CB) + DataSize);
-
- if (IfCb == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_ERROR;
- }
-
- IfCb->NicHandle = HandleBuffer[HandleIndex];
- IfCb->IfInfo = IfInfo;
- IfCb->IfCfg = Ip6Cfg;
- IfCb->DnsCnt = (UINT32) (DataSize / sizeof (EFI_IPv6_ADDRESS));
-
- //
- // Get the dns server list if has.
- //
- if (DataSize > 0) {
-
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeDnsServer,
- &DataSize,
- IfCb->DnsAddr
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
- }
- //
- // Get the interface id if has.
- //
- DataSize = sizeof (EFI_IP6_CONFIG_INTERFACE_ID);
- IfCb->IfId = AllocateZeroPool (DataSize);
-
- if (IfCb->IfId == NULL) {
- goto ON_ERROR;
- }
-
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeAltInterfaceId,
- &DataSize,
- IfCb->IfId
- );
-
- if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
-
- if (Status == EFI_NOT_FOUND) {
- FreePool (IfCb->IfId);
- IfCb->IfId = NULL;
- }
- //
- // Get the config policy.
- //
- DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypePolicy,
- &DataSize,
- &IfCb->Policy
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
- //
- // Get the dad transmits.
- //
- DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeDupAddrDetectTransmits,
- &DataSize,
- &IfCb->Xmits
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
-
- InsertTailList (IfList, &IfCb->Link);
-
- if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) == 0)) {
- //
- // Only need the appointed interface, keep the allocated buffer.
- //
- IfCb = NULL;
- IfInfo = NULL;
- break;
- }
- }
-
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- return EFI_SUCCESS;
-
-ON_ERROR:
-
- if (IfInfo != NULL) {
- FreePool (IfInfo);
- }
-
- if (IfCb != NULL) {
- if (IfCb->IfId != NULL) {
- FreePool (IfCb->IfId);
- }
-
- FreePool (IfCb);
- }
-
- return Status;
-}
-
-/**
- The list process of the IfConfig6 application.
-
- @param[in] IfList The pointer of IfList(interface list).
-
- @retval EFI_SUCCESS The IfConfig6 list processed successfully.
- @retval others The IfConfig6 list process failed.
-
-**/
-EFI_STATUS
-IfConfig6ShowInterfaceInfo (
- IN LIST_ENTRY *IfList
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Entry;
- IFCONFIG6_INTERFACE_CB *IfCb;
- UINTN Index;
-
- Entry = IfList->ForwardLink;
- Status = EFI_SUCCESS;
-
- if (IsListEmpty (IfList)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle);
- }
-
- //
- // Go through the interface list.
- //
- while (Entry != IfList) {
-
- IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link);
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK), mHiiHandle);
-
- //
- // Print interface name.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IF_NAME), mHiiHandle, IfCb->IfInfo->Name);
-
- //
- // Print interface config policy.
- //
- if (IfCb->Policy == Ip6ConfigPolicyAutomatic) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_AUTO), mHiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_MAN), mHiiHandle);
- }
-
- //
- // Print dad transmit.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_DAD_TRANSMITS), mHiiHandle, IfCb->Xmits);
-
- //
- // Print interface id if has.
- //
- if (IfCb->IfId != NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD), mHiiHandle);
-
- IfConfig6PrintMacAddr (
- IfCb->IfId->Id,
- 8
- );
- }
- //
- // Print mac address of the interface.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_HEAD), mHiiHandle);
-
- IfConfig6PrintMacAddr (
- IfCb->IfInfo->HwAddress.Addr,
- IfCb->IfInfo->HwAddressSize
- );
-
- //
- // Print ip addresses list of the interface.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_HEAD), mHiiHandle);
-
- for (Index = 0; Index < IfCb->IfInfo->AddressInfoCount; Index++) {
- IfConfig6PrintIpAddr (
- &IfCb->IfInfo->AddressInfo[Index].Address,
- &IfCb->IfInfo->AddressInfo[Index].PrefixLength
- );
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle);
- }
-
- //
- // Print dns server addresses list of the interface if has.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_DNS_ADDR_HEAD), mHiiHandle);
-
- for (Index = 0; Index < IfCb->DnsCnt; Index++) {
- IfConfig6PrintIpAddr (
- &IfCb->DnsAddr[Index],
- NULL
- );
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle);
- }
-
- //
- // Print route table of the interface if has.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_ROUTE_HEAD), mHiiHandle);
-
- for (Index = 0; Index < IfCb->IfInfo->RouteCount; Index++) {
- IfConfig6PrintIpAddr (
- &IfCb->IfInfo->RouteTable[Index].Destination,
- &IfCb->IfInfo->RouteTable[Index].PrefixLength
- );
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_JOINT), mHiiHandle);
-
- IfConfig6PrintIpAddr (
- &IfCb->IfInfo->RouteTable[Index].Gateway,
- NULL
- );
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle);
- }
-
- Entry = Entry->ForwardLink;
- }
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK), mHiiHandle);
-
- return Status;
-}
-
-/**
- The clean process of the IfConfig6 application.
-
- @param[in] IfList The pointer of IfList(interface list).
-
- @retval EFI_SUCCESS The IfConfig6 clean processed successfully.
- @retval others The IfConfig6 clean process failed.
-
-**/
-EFI_STATUS
-IfConfig6ClearInterfaceInfo (
- IN LIST_ENTRY *IfList
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Entry;
- IFCONFIG6_INTERFACE_CB *IfCb;
- EFI_IP6_CONFIG_POLICY Policy;
-
- Policy = Ip6ConfigPolicyAutomatic;
- Entry = IfList->ForwardLink;
- Status = EFI_SUCCESS;
-
- if (IsListEmpty (IfList)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle);
- }
-
- //
- // Go through the interface list.
- //
- while (Entry != IfList) {
-
- IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link);
-
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypePolicy,
- sizeof (EFI_IP6_CONFIG_POLICY),
- &Policy
- );
-
- if (EFI_ERROR (Status)) {
- break;
- }
-
- Entry = Entry->ForwardLink;
- }
-
- return Status;
-}
-
-/**
- The set process of the IfConfig6 application.
-
- @param[in] IfList The pointer of IfList(interface list).
- @param[in] VarArg The pointer of ARG_LIST(Args with "-s" option).
-
- @retval EFI_SUCCESS The IfConfig6 set processed successfully.
- @retval others The IfConfig6 set process failed.
-
-**/
-EFI_STATUS
-IfConfig6SetInterfaceInfo (
- IN LIST_ENTRY *IfList,
- IN ARG_LIST *VarArg
- )
-{
- EFI_STATUS Status;
- IFCONFIG6_INTERFACE_CB *IfCb;
- EFI_IP6_CONFIG_MANUAL_ADDRESS *CfgManAddr;
- EFI_IPv6_ADDRESS *CfgAddr;
- UINTN AddrSize;
- EFI_IP6_CONFIG_INTERFACE_ID *InterfaceId;
- UINT32 DadXmits;
- UINT32 CurDadXmits;
- UINTN CurDadXmitsLen;
- EFI_IP6_CONFIG_POLICY Policy;
-
- VAR_CHECK_CODE CheckCode;
- EFI_EVENT TimeOutEvt;
- EFI_EVENT MappedEvt;
- BOOLEAN IsAddressOk;
-
- UINTN DataSize;
- UINT32 Index;
- UINT32 Index2;
- BOOLEAN IsAddressSet;
- EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
-
- CfgManAddr = NULL;
- CfgAddr = NULL;
- TimeOutEvt = NULL;
- MappedEvt = NULL;
- IfInfo = NULL;
- InterfaceId = NULL;
- CurDadXmits = 0;
-
- if (IsListEmpty (IfList)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle);
- return EFI_INVALID_PARAMETER;
- }
- //
- // Make sure to set only one interface each time.
- //
- IfCb = BASE_CR (IfList->ForwardLink, IFCONFIG6_INTERFACE_CB, Link);
- Status = EFI_SUCCESS;
-
- //
- // Initialize check list mechanism.
- //
- CheckCode = IfConfig6RetriveCheckListByName(
- NULL,
- NULL,
- TRUE
- );
-
- //
- // Create events & timers for asynchronous settings.
- //
- Status = gBS->CreateEvent (
- EVT_TIMER,
- TPL_CALLBACK,
- NULL,
- NULL,
- &TimeOutEvt
- );
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- IfConfig6ManualAddressNotify,
- &IsAddressOk,
- &MappedEvt
- );
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
- //
- // Parse the setting variables.
- //
- while (VarArg != NULL) {
- //
- // Check invalid parameters (duplication & unknown & conflict).
- //
- CheckCode = IfConfig6RetriveCheckListByName(
- mSetCheckList,
- VarArg->Arg,
- FALSE
- );
-
- if (VarCheckOk != CheckCode) {
- switch (CheckCode) {
- case VarCheckDuplicate:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_DUPLICATE_COMMAND), mHiiHandle, VarArg->Arg);
- break;
-
- case VarCheckConflict:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_CONFLICT_COMMAND), mHiiHandle, VarArg->Arg);
- break;
-
- case VarCheckUnknown:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_UNKNOWN_COMMAND), mHiiHandle, VarArg->Arg);
- break;
-
- default:
- break;
- }
-
- VarArg = VarArg->Next;
- continue;
- }
- //
- // Process valid variables.
- //
- if (StrCmp(VarArg->Arg, L"auto") == 0) {
- //
- // Set automaic config policy
- //
- Policy = Ip6ConfigPolicyAutomatic;
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypePolicy,
- sizeof (EFI_IP6_CONFIG_POLICY),
- &Policy
- );
-
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
-
- VarArg= VarArg->Next;
-
- } else if (StrCmp (VarArg->Arg, L"man") == 0) {
- //
- // Set manual config policy.
- //
- Policy = Ip6ConfigPolicyManual;
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypePolicy,
- sizeof (EFI_IP6_CONFIG_POLICY),
- &Policy
- );
-
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
-
- VarArg= VarArg->Next;
-
- } else if (StrCmp (VarArg->Arg, L"host") == 0) {
- //
- // Parse till the next tag or the end of command line.
- //
- VarArg = VarArg->Next;
- Status = IfConfig6ParseManualAddressList (
- &VarArg,
- &CfgManAddr,
- &AddrSize
- );
-
- if (EFI_ERROR (Status)) {
- if (Status == EFI_INVALID_PARAMETER) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"host");
- continue;
- } else {
- goto ON_EXIT;
- }
- }
- //
- // Set static host ip6 address list.
- // This is a asynchronous process.
- //
- IsAddressOk = FALSE;
-
- Status = IfCb->IfCfg->RegisterDataNotify (
- IfCb->IfCfg,
- Ip6ConfigDataTypeManualAddress,
- MappedEvt
- );
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeManualAddress,
- AddrSize,
- CfgManAddr
- );
-
- if (Status == EFI_NOT_READY) {
- //
- // Get current dad transmits count.
- //
- CurDadXmitsLen = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);
- IfCb->IfCfg->GetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeDupAddrDetectTransmits,
- &CurDadXmitsLen,
- &CurDadXmits
- );
-
- gBS->SetTimer (TimeOutEvt, TimerRelative, 50000000 + 10000000 * CurDadXmits);
-
- while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
- if (IsAddressOk) {
- Status = EFI_SUCCESS;
- break;
- }
- }
- }
-
- IfCb->IfCfg->UnregisterDataNotify (
- IfCb->IfCfg,
- Ip6ConfigDataTypeManualAddress,
- MappedEvt
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_MAN_HOST), mHiiHandle, Status);
- goto ON_EXIT;
- }
-
- //
- // Check whether the address is set successfully.
- //
- DataSize = 0;
-
- Status = IfCb->IfCfg->GetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &DataSize,
- NULL
- );
-
- if (Status != EFI_BUFFER_TOO_SMALL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_EXIT;
- }
-
- IfInfo = AllocateZeroPool (DataSize);
-
- if (IfInfo == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_EXIT;
- }
-
- Status = IfCb->IfCfg->GetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &DataSize,
- IfInfo
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_EXIT;
- }
-
- for ( Index = 0; Index < (UINTN) (AddrSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)); Index++) {
- IsAddressSet = FALSE;
- //
- // By default, the prefix length 0 is regarded as 64.
- //
- if (CfgManAddr[Index].PrefixLength == 0) {
- CfgManAddr[Index].PrefixLength = 64;
- }
-
- for (Index2 = 0; Index2 < IfInfo->AddressInfoCount; Index2++) {
- if (EFI_IP6_EQUAL (&IfInfo->AddressInfo[Index2].Address, &CfgManAddr[Index].Address) &&
- (IfInfo->AddressInfo[Index2].PrefixLength == CfgManAddr[Index].PrefixLength)) {
- IsAddressSet = TRUE;
- break;
- }
- }
-
- if (!IsAddressSet) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_ADDRESS_FAILED), mHiiHandle);
- IfConfig6PrintIpAddr (
- &CfgManAddr[Index].Address,
- &CfgManAddr[Index].PrefixLength
- );
- }
- }
-
- } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
- //
- // Parse till the next tag or the end of command line.
- //
- VarArg = VarArg->Next;
- Status = IfConfig6ParseGwDnsAddressList (
- &VarArg,
- &CfgAddr,
- &AddrSize
- );
-
- if (EFI_ERROR (Status)) {
- if (Status == EFI_INVALID_PARAMETER) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"gw");
- continue;
- } else {
- goto ON_EXIT;
- }
- }
- //
- // Set static gateway ip6 address list.
- //
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeGateway,
- AddrSize,
- CfgAddr
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
- //
- // Parse till the next tag or the end of command line.
- //
- VarArg = VarArg->Next;
- Status = IfConfig6ParseGwDnsAddressList (
- &VarArg,
- &CfgAddr,
- &AddrSize
- );
-
- if (EFI_ERROR (Status)) {
- if (Status == EFI_INVALID_PARAMETER) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"dns");
- continue;
- } else {
- goto ON_EXIT;
- }
- }
- //
- // Set static dhs server ip6 address list.
- //
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeDnsServer,
- AddrSize,
- CfgAddr
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- } else if (StrCmp (VarArg->Arg, L"id") == 0) {
- //
- // Parse till the next tag or the end of command line.
- //
- VarArg = VarArg->Next;
- Status = IfConfig6ParseInterfaceId (&VarArg, &InterfaceId);
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
- //
- // Set alternative interface id.
- //
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeAltInterfaceId,
- sizeof (EFI_IP6_CONFIG_INTERFACE_ID),
- InterfaceId
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- } else if (StrCmp (VarArg->Arg, L"dad") == 0) {
- //
- // Parse till the next tag or the end of command line.
- //
- VarArg = VarArg->Next;
- Status = IfConfig6ParseDadXmits (&VarArg, &DadXmits);
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
- //
- // Set dad transmits count.
- //
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip6ConfigDataTypeDupAddrDetectTransmits,
- sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS),
- &DadXmits
- );
-
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- }
- }
-
-ON_EXIT:
-
- if (CfgManAddr != NULL) {
- FreePool (CfgManAddr);
- }
-
- if (CfgAddr != NULL) {
- FreePool (CfgAddr);
- }
-
- if (MappedEvt != NULL) {
- gBS->CloseEvent (MappedEvt);
- }
-
- if (TimeOutEvt != NULL) {
- gBS->CloseEvent (TimeOutEvt);
- }
-
- if (IfInfo != NULL) {
- FreePool (IfInfo);
- }
-
- return Status;
-
-}
-
-/**
- The IfConfig6 main process.
-
- @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
-
- @retval EFI_SUCCESS IfConfig6 processed successfully.
- @retval others The IfConfig6 process failed.
-
-**/
-EFI_STATUS
-IfConfig6 (
- IN IFCONFIG6_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
-
- //
- // Get configure information of all interfaces.
- //
- Status = IfConfig6GetInterfaceInfo (
- Private->ImageHandle,
- Private->IfName,
- &Private->IfList
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- switch (Private->OpCode) {
- case IfConfig6OpList:
- Status = IfConfig6ShowInterfaceInfo (&Private->IfList);
- break;
-
- case IfConfig6OpClear:
- Status = IfConfig6ClearInterfaceInfo (&Private->IfList);
- break;
-
- case IfConfig6OpSet:
- Status = IfConfig6SetInterfaceInfo (&Private->IfList, Private->VarArg);
- break;
-
- default:
- Status = EFI_ABORTED;
- }
-
-ON_EXIT:
-
- return Status;
-}
-
-/**
- The IfConfig6 cleanup process, free the allocated memory.
-
- @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA.
-
-**/
-VOID
-IfConfig6Cleanup (
- IN IFCONFIG6_PRIVATE_DATA *Private
- )
-{
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- IFCONFIG6_INTERFACE_CB *IfCb;
- ARG_LIST *ArgNode;
- ARG_LIST *ArgHead;
-
- ASSERT (Private != NULL);
-
- //
- // Clean the list which save the set config Args.
- //
- if (Private->VarArg != NULL) {
- ArgHead = Private->VarArg;
-
- while (ArgHead->Next != NULL) {
- ArgNode = ArgHead->Next;
- FreePool (ArgHead);
- ArgHead = ArgNode;
- }
-
- FreePool (ArgHead);
- }
-
- if (Private->IfName != NULL)
- FreePool (Private->IfName);
-
-
- //
- // Clean the IFCONFIG6_INTERFACE_CB list.
- //
- Entry = Private->IfList.ForwardLink;
- NextEntry = Entry->ForwardLink;
-
- while (Entry != &Private->IfList) {
-
- IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link);
-
- RemoveEntryList (&IfCb->Link);
-
- if (IfCb->IfId != NULL) {
-
- FreePool (IfCb->IfId);
- }
-
- if (IfCb->IfInfo != NULL) {
-
- FreePool (IfCb->IfInfo);
- }
-
- FreePool (IfCb);
-
- Entry = NextEntry;
- NextEntry = Entry->ForwardLink;
- }
-
- FreePool (Private);
-}
-
-/**
- This is the declaration of an EFI image entry point. This entry point is
- the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, including
- both device drivers and bus drivers.
-
- The entry point for the IfConfig6 application which parses the command line input and calls the IfConfig6 process.
-
- @param[in] ImageHandle The image handle of this application.
- @param[in] SystemTable The pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval Others Some errors occur.
-
-**/
-EFI_STATUS
-EFIAPI
-IfConfig6Initialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- IFCONFIG6_PRIVATE_DATA *Private;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- LIST_ENTRY *ParamPackage;
- CONST CHAR16 *ValueStr;
- ARG_LIST *ArgList;
- CHAR16 *ProblemParam;
- CHAR16 *Str;
-
- Private = NULL;
-
- //
- // Retrieve HII package list from ImageHandle
- //
- Status = gBS->OpenProtocol (
- ImageHandle,
- &gEfiHiiPackageListProtocolGuid,
- (VOID **) &PackageList,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Publish HII package list to HII Database.
- //
- Status = gHiiDatabase->NewPackageList (
- gHiiDatabase,
- PackageList,
- NULL,
- &mHiiHandle
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ASSERT (mHiiHandle != NULL);
-
- Status = ShellCommandLineParseEx (mIfConfig6CheckList, &ParamPackage, &ProblemParam, TRUE, FALSE);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_COMMAND), mHiiHandle, ProblemParam);
- goto ON_EXIT;
- }
-
- //
- // To handle no option.
- //
- if (!ShellCommandLineGetFlag (ParamPackage, L"-r") && !ShellCommandLineGetFlag (ParamPackage, L"-s") &&
- !ShellCommandLineGetFlag (ParamPackage, L"-l")) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_LACK_OPTION), mHiiHandle);
- goto ON_EXIT;
- }
- //
- // To handle conflict options.
- //
- if (((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-s"))) ||
- ((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-l"))) ||
- ((ShellCommandLineGetFlag (ParamPackage, L"-s")) && (ShellCommandLineGetFlag (ParamPackage, L"-l")))) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_CONFLICT_OPTIONS), mHiiHandle);
- goto ON_EXIT;
- }
-
- Status = EFI_INVALID_PARAMETER;
-
- Private = AllocateZeroPool (sizeof (IFCONFIG6_PRIVATE_DATA));
-
- if (Private == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_EXIT;
- }
-
- InitializeListHead (&Private->IfList);
-
- //
- // To get interface name for the list option.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-l")) {
- Private->OpCode = IfConfig6OpList;
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l");
- if (ValueStr != NULL) {
- Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);
- ASSERT (Str != NULL);
- Private->IfName = Str;
- }
- }
- //
- // To get interface name for the clear option.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-r")) {
- Private->OpCode = IfConfig6OpClear;
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-r");
- if (ValueStr != NULL) {
- Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);
- ASSERT (Str != NULL);
- Private->IfName = Str;
- }
- }
- //
- // To get interface name and corresponding Args for the set option.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-s")) {
-
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s");
- if (ValueStr == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_INTERFACE), mHiiHandle);
- goto ON_EXIT;
- }
- //
- // To split the configuration into multi-section.
- //
- ArgList = SplitStrToList (ValueStr, L' ');
- ASSERT (ArgList != NULL);
-
- Private->OpCode = IfConfig6OpSet;
- Private->IfName = ArgList->Arg;
-
- Private->VarArg = ArgList->Next;
-
- if (Private->IfName == NULL || Private->VarArg == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_COMMAND), mHiiHandle);
- goto ON_EXIT;
- }
- }
- //
- // Main process of ifconfig6.
- //
- Status = IfConfig6 (Private);
-
-ON_EXIT:
-
- ShellCommandLineFreeVarList (ParamPackage);
- HiiRemovePackages (mHiiHandle);
- if (Private != NULL)
- IfConfig6Cleanup (Private);
-
- return Status;
-}
-
diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.h b/NetworkPkg/Application/IfConfig6/IfConfig6.h
deleted file mode 100644
index f74897108d..0000000000
--- a/NetworkPkg/Application/IfConfig6/IfConfig6.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/** @file
- The interface function declaration of shell application IfConfig6.
-
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _IFCONFIG6_H_
-#define _IFCONFIG6_H_
-
-enum {
- IfConfig6OpList = 1,
- IfConfig6OpSet = 2,
- IfConfig6OpClear = 3
-};
-
-typedef enum {
- VarCheckReserved = -1,
- VarCheckOk = 0,
- VarCheckDuplicate,
- VarCheckConflict,
- VarCheckUnknown,
- VarCheckLackValue,
- VarCheckOutOfMem
-} VAR_CHECK_CODE;
-
-typedef enum {
- FlagTypeSingle = 0,
- FlagTypeNeedVar,
- FlagTypeNeedSet,
- FlagTypeSkipUnknown
-} VAR_CHECK_FLAG_TYPE;
-
-#define MACADDRMAXSIZE 32
-#define PREFIXMAXLEN 16
-
-typedef struct _IFCONFIG6_INTERFACE_CB {
- EFI_HANDLE NicHandle;
- LIST_ENTRY Link;
- EFI_IP6_CONFIG_PROTOCOL *IfCfg;
- EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
- EFI_IP6_CONFIG_INTERFACE_ID *IfId;
- EFI_IP6_CONFIG_POLICY Policy;
- EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS Xmits;
- UINT32 DnsCnt;
- EFI_IPv6_ADDRESS DnsAddr[1];
-} IFCONFIG6_INTERFACE_CB;
-
-typedef struct _ARG_LIST ARG_LIST;
-
-struct _ARG_LIST {
- ARG_LIST *Next;
- CHAR16 *Arg;
-};
-
-typedef struct _IFCONFIG6_PRIVATE_DATA {
- EFI_HANDLE ImageHandle;
- LIST_ENTRY IfList;
-
- UINT32 OpCode;
- CHAR16 *IfName;
- ARG_LIST *VarArg;
-} IFCONFIG6_PRIVATE_DATA;
-
-typedef struct _VAR_CHECK_ITEM{
- CHAR16 *FlagStr;
- UINT32 FlagID;
- UINT32 ConflictMask;
- VAR_CHECK_FLAG_TYPE FlagType;
-} VAR_CHECK_ITEM;
-#endif
diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.inf b/NetworkPkg/Application/IfConfig6/IfConfig6.inf
deleted file mode 100644
index 519b7c3279..0000000000
--- a/NetworkPkg/Application/IfConfig6/IfConfig6.inf
+++ /dev/null
@@ -1,67 +0,0 @@
-## @file
-# Shell application IfConfig6.
-#
-# It is shell application which is used to set and get configurations for the
-# EFI IPv6 network stack.
-#
-# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = IfConfig6
- FILE_GUID = 6F71926E-60CE-428d-AA58-A3D9FB879429
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- ENTRY_POINT = IfConfig6Initialize
- MODULE_UNI_FILE = IfConfig6.uni
-
-#
-#
-# This flag specifies whether HII resource section is generated into PE image.
-#
- UEFI_HII_RESOURCE_SECTION = TRUE
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF
-#
-[Sources]
- IfConfig6Strings.uni
- IfConfig6.c
- IfConfig6.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ShellPkg/ShellPkg.dec
-
-[LibraryClasses]
- BaseLib
- UefiBootServicesTableLib
- UefiApplicationEntryPoint
- UefiHiiServicesLib
- BaseMemoryLib
- ShellLib
- MemoryAllocationLib
- DebugLib
- HiiLib
- NetLib
-
-[Protocols]
- gEfiIp6ServiceBindingProtocolGuid ## CONSUMES
- gEfiIp6ConfigProtocolGuid ## CONSUMES
- gEfiHiiPackageListProtocolGuid ## CONSUMES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- IfConfig6Extra.uni
diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.uni b/NetworkPkg/Application/IfConfig6/IfConfig6.uni
deleted file mode 100644
index e0ea589771..0000000000
--- a/NetworkPkg/Application/IfConfig6/IfConfig6.uni
+++ /dev/null
@@ -1,23 +0,0 @@
-// /** @file
-// Shell application IfConfig6.
-//
-// It is shell application which is used to set and get configurations for the
-// EFI IPv6 network stack.
-//
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php.
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Shell application IfConfig6"
-
-#string STR_MODULE_DESCRIPTION #language en-US "It is shell application which is used to set and get configurations for the EFI IPv6 network stack."
-
diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni b/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni
deleted file mode 100644
index 7d3f27a073..0000000000
--- a/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni
+++ /dev/null
@@ -1,20 +0,0 @@
-// /** @file
-// IfConfig6 Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php.
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"IfConfig6 App"
-
-
diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni b/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni
deleted file mode 100644
index 0c10bbdf78..0000000000
--- a/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni
+++ /dev/null
@@ -1,92 +0,0 @@
-/** @file
- String definitions for the Shell application IfConfig6.
-
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions
- of the BSD License which accompanies this distribution. The full
- text of the license may be found at<BR>
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#langdef en-US "English"
-
-#string STR_IFCONFIG6_ERR_IP6CFG_GETDATA #language en-US "Ip6Config->GetData return %hr\n"
-#string STR_IFCONFIG6_INFO_BREAK #language en-US "-----------------------------------------------------------------"
-#string STR_IFCONFIG6_INFO_COLON #language en-US ":"
-#string STR_IFCONFIG6_INFO_JOINT #language en-US " >> "
-#string STR_IFCONFIG6_INFO_NEWLINE #language en-US "\n"
-#string STR_IFCONFIG6_INFO_IF_NAME #language en-US "\n%Hname : %s%N\n"
-#string STR_IFCONFIG6_INFO_POLICY_AUTO #language en-US "%Hpolicy : automatic%N\n"
-#string STR_IFCONFIG6_INFO_POLICY_MAN #language en-US "%Hpolicy : manual%N\n"
-#string STR_IFCONFIG6_INFO_DAD_TRANSMITS #language en-US "%Hdad xmits : %d%N\n"
-#string STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD #language en-US "%Hinterface id : %N"
-#string STR_IFCONFIG6_INFO_MAC_ADDR_HEAD #language en-US "%Hmac addr : %N"
-#string STR_IFCONFIG6_INFO_MAC_ADDR_BODY #language en-US "%02x"
-#string STR_IFCONFIG6_INFO_IP_ADDR_HEAD #language en-US "\n%Hhost addr : %N\n"
-#string STR_IFCONFIG6_INFO_DNS_ADDR_HEAD #language en-US "\n%Hdns server : %N\n"
-#string STR_IFCONFIG6_INFO_IP_ADDR_BODY #language en-US "%02x"
-#string STR_IFCONFIG6_INFO_IP_ADDR_BODY4BIT #language en-US "%x"
-#string STR_IFCONFIG6_INFO_ROUTE_HEAD #language en-US "\n%Hroute table : %N\n"
-#string STR_IFCONFIG6_INFO_PREFIX_LEN #language en-US "/%d"
-
-#string STR_IFCONFIG6_LINE_HELP #language en-US "Displays or modifies the IPv6 configuration"
-#string STR_IFCONFIG6_ERR_LACK_INTERFACE #language en-US "Lack interface name.\n"
- "Usage: IfConfig6 -s {ifname} {config options ...}\n"
- "Example: IfConfig6 -s eth0 auto\n"
-#string STR_IFCONFIG6_LACK_OPTION #language en-US "Flags lack. Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_CONFLICT_OPTIONS #language en-US "Flags conflict. Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_ERR_LACK_COMMAND #language en-US "Lack interface config option.\n"
- "Usage: IfConfig6 -s {ifname} {config options ...}\n"
- "Example: IfConfig6 -s eth0 auto\n"
-#string STR_IFCONFIG6_ERR_INVALID_INTERFACE #language en-US "Invalid interface name.\n"
- "Hint: Use {IfConfig6 -l} to check existing interface names.\n"
-#string STR_IFCONFIG6_ERR_INVALID_COMMAND #language en-US "Invalid command. Bad command %H%s%N is skipped.\n"
- "Hint: Incorrect option or arguments. Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_ERR_LACK_ARGUMENTS #language en-US "Lack arguments. Bad command %H%s%N is skipped.\n"
- "Hint: Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_ERR_LACK_OPTION #language en-US "Lack options.\n"
- "Hint: Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_ERR_MAN_HOST #language en-US "Manual address configuration failed. Please retry.\n"
-#string STR_IFCONFIG6_ERR_DUPLICATE_COMMAND #language en-US "Duplicate commands. Bad command %H%s%N is skipped.\n"
- "Hint: Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_ERR_CONFLICT_COMMAND #language en-US "Conflict commands. Bad command %H%s%N is skipped.\n"
- "Hint: Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_ERR_UNKNOWN_COMMAND #language en-US "Unknown commands. Bad command %H%s%N is skipped.\n"
- "Hint: Please type 'IfConfig6 -?' for help info.\n"
-#string STR_IFCONFIG6_ERR_ADDRESS_FAILED #language en-US "It failed to set .\n"
-#string STR_IFCONFIG6_INVALID_IP #language en-US "%IfConfig6: Invalid IP6 address, %s\n"
-
-#string STR_IFCONFIG6_HELP #language en-US ""
-".TH IfConfig6 0 "Displays or modifies IPv6 configuration for network interface."\r\n"
-".SH NAME\r\n"
-"Displays or modifies IPv6 configuration for network interface.\r\n"
-".SH SYNOPSIS\r\n"
-" \r\n"
-"IfConfig6 [-b] [-r {ifname}] [-l {ifname}] [-s {ifname} {command ...}] [-?]\r\n"
-".SH OPTIONS\r\n"
-" \r\n"
-" -b (break) enable page break.\r\n"
-" -r (renew) renew configuration of interface and set automatic policy.\r\n"
-" -l (list) list the configuration of interface.\r\n"
-" -s (set) set configuration of interface as follows.\r\n"
-" |man/auto manual or automatic policy\r\n"
-" |id {mac} alternative interface id.\r\n"
-" |dad {num} dad transmits count.\r\n"
-" |host{ip} static host ip address, must under manual policy.\r\n"
-" |gw {ip} gateway ip address, must under manual policy.\r\n"
-" |dns {ip} dns server ip address, must under manual policy.\r\n"
-".SH EXAMPLES\r\n"
-" \r\n"
-"Examples:\r\n"
-" IfConfig6 -l\r\n"
-" IfConfig6 -b -l\r\n"
-" IfConfig6 -r eth0\r\n"
-" IfConfig6 -s eth0 auto dad 10\r\n"
-" IfConfig6 -s eth0 man id ff:dd:aa:88:66:cc\r\n"
-" IfConfig6 -s eth1 man host 2002::1/64 2002::2/64 gw 2002::3\r\n"
diff --git a/NetworkPkg/Application/Ping6/Ia32/Tsc.c b/NetworkPkg/Application/Ping6/Ia32/Tsc.c
deleted file mode 100644
index e2eae99077..0000000000
--- a/NetworkPkg/Application/Ping6/Ia32/Tsc.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- The implement to read TSC in IA32 platform.
-
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-
-/**
- Reads and returns the current value of the Time Stamp Counter (TSC).
-
- @return The current value of TSC.
-
-**/
-UINT64
-ReadTime ()
-{
- return AsmReadTsc ();
-}
diff --git a/NetworkPkg/Application/Ping6/Ipf/Itc.c b/NetworkPkg/Application/Ping6/Ipf/Itc.c
deleted file mode 100644
index 131e5c0e30..0000000000
--- a/NetworkPkg/Application/Ping6/Ipf/Itc.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- The implement to read ITC in IA64 platform.
-
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-
-/**
- Reads and returns the current value of the Interval Timer Counter Register (ITC).
-
- @return The current value of ITC.
-
-**/
-UINT64
-ReadTime ()
-{
- return AsmReadItc ();
-}
diff --git a/NetworkPkg/Application/Ping6/Ping6.c b/NetworkPkg/Application/Ping6/Ping6.c
deleted file mode 100644
index 66daac27be..0000000000
--- a/NetworkPkg/Application/Ping6/Ping6.c
+++ /dev/null
@@ -1,1200 +0,0 @@
-/** @file
- The implementation for Ping6 application.
-
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/ShellLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiHiiServicesLib.h>
-#include <Library/HiiLib.h>
-#include <Library/NetLib.h>
-
-#include <Protocol/Cpu.h>
-#include <Protocol/ServiceBinding.h>
-#include <Protocol/Ip6.h>
-#include <Protocol/Ip6Config.h>
-
-#include "Ping6.h"
-
-//
-// String token ID of Ping6 command help message text.
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringPing6HelpToken = STRING_TOKEN (STR_PING6_HELP);
-
-SHELL_PARAM_ITEM Ping6ParamList[] = {
- {
- L"-l",
- TypeValue
- },
- {
- L"-n",
- TypeValue
- },
- {
- L"-s",
- TypeValue
- },
- {
- NULL,
- TypeMax
- },
-};
-
-//
-// Global Variables in Ping6 application.
-//
-EFI_HII_HANDLE mHiiHandle;
-CONST CHAR16 *mIp6DstString;
-CONST CHAR16 *mIp6SrcString;
-UINT64 mFrequency = 0;
-/**
- Get and calculate the frequency in tick/ms.
- The result is saved in the globle variable mFrequency
-
- @retval EFI_SUCCESS Calculated the frequency successfully.
- @retval Others Failed to calculate the frequency.
-
-**/
-EFI_STATUS
-Ping6GetFrequency (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_CPU_ARCH_PROTOCOL *Cpu;
- UINT64 CurrentTick;
- UINT64 TimerPeriod;
-
- Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &Cpu);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = Cpu->GetTimerValue (Cpu, 0, &CurrentTick, &TimerPeriod);
-
- if (EFI_ERROR (Status)) {
- //
- // For NT32 Simulator only. 358049 is a similar value to keep timer granularity.
- // Set the timer period by ourselves.
- //
- TimerPeriod = (UINT64) NTTIMERPERIOD;
- }
- //
- // The timer period is in femtosecond (1 femtosecond is 1e-15 second).
- // So 1e+12 is divided by timer period to produce the freq in tick/ms.
- //
- mFrequency = DivU64x64Remainder (1000000000000ULL, TimerPeriod, NULL);
-
- return EFI_SUCCESS;
-}
-
-/**
- Get and calculate the duration in ms.
-
- @param[in] Begin The start point of time.
- @param[in] End The end point of time.
-
- @return The duration in ms.
-
-**/
-UINT64
-Ping6CalculateTick (
- IN UINT64 Begin,
- IN UINT64 End
- )
-{
- ASSERT (End > Begin);
- return DivU64x64Remainder (End - Begin, mFrequency, NULL);
-}
-
-/**
- Destroy IPING6_ICMP6_TX_INFO, and recollect the memory.
-
- @param[in] TxInfo The pointer to PING6_ICMP6_TX_INFO.
-
-**/
-VOID
-Ping6DestroyTxInfo (
- IN PING6_ICMP6_TX_INFO *TxInfo
- )
-{
- EFI_IP6_TRANSMIT_DATA *TxData;
- EFI_IP6_FRAGMENT_DATA *FragData;
- UINTN Index;
-
- ASSERT (TxInfo != NULL);
-
- if (TxInfo->Token != NULL) {
-
- if (TxInfo->Token->Event != NULL) {
- gBS->CloseEvent (TxInfo->Token->Event);
- }
-
- TxData = TxInfo->Token->Packet.TxData;
- if (TxData != NULL) {
-
- if (TxData->OverrideData != NULL) {
- FreePool (TxData->OverrideData);
- }
-
- if (TxData->ExtHdrs != NULL) {
- FreePool (TxData->ExtHdrs);
- }
-
- for (Index = 0; Index < TxData->FragmentCount; Index++) {
- FragData = TxData->FragmentTable[Index].FragmentBuffer;
- if (FragData != NULL) {
- FreePool (FragData);
- }
- }
- }
-
- FreePool (TxInfo->Token);
- }
-
- FreePool (TxInfo);
-}
-
-/**
- Match the request, and reply with SequenceNum/TimeStamp.
-
- @param[in] Private The pointer to PING6_PRIVATE_DATA.
- @param[in] Packet The pointer to ICMP6_ECHO_REQUEST_REPLY.
-
- @retval EFI_SUCCESS The match is successful.
- @retval EFI_NOT_FOUND The reply can't be matched with any request.
-
-**/
-EFI_STATUS
-Ping6MatchEchoReply (
- IN PING6_PRIVATE_DATA *Private,
- IN ICMP6_ECHO_REQUEST_REPLY *Packet
- )
-{
- PING6_ICMP6_TX_INFO *TxInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
-
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) {
- TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link);
-
- if ((TxInfo->SequenceNum == Packet->SequenceNum) && (TxInfo->TimeStamp == Packet->TimeStamp)) {
- Private->RxCount++;
- RemoveEntryList (&TxInfo->Link);
- Ping6DestroyTxInfo (TxInfo);
- return EFI_SUCCESS;
- }
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- The original intention is to send a request.
- Currently, the application retransmits an icmp6 echo request packet
- per second in sendnumber times that is specified by the user.
- Because nothing can be done here, all things move to the timer rountine.
-
- @param[in] Event A EFI_EVENT type event.
- @param[in] Context The pointer to Context.
-
-**/
-VOID
-EFIAPI
-Ping6OnEchoRequestSent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
-}
-
-/**
- receive reply, match and print reply infomation.
-
- @param[in] Event A EFI_EVENT type event.
- @param[in] Context The pointer to context.
-
-**/
-VOID
-EFIAPI
-Ping6OnEchoReplyReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- PING6_PRIVATE_DATA *Private;
- EFI_IP6_COMPLETION_TOKEN *RxToken;
- EFI_IP6_RECEIVE_DATA *RxData;
- ICMP6_ECHO_REQUEST_REPLY *Reply;
- UINT32 PayLoad;
- UINT64 Rtt;
- CHAR8 Near;
-
- Private = (PING6_PRIVATE_DATA *) Context;
-
- if (Private->Status == EFI_ABORTED) {
- return;
- }
-
- RxToken = &Private->RxToken;
- RxData = RxToken->Packet.RxData;
- Reply = RxData->FragmentTable[0].FragmentBuffer;
- PayLoad = RxData->DataLength;
-
- if (RxData->Header->NextHeader != IP6_ICMP) {
- goto ON_EXIT;
- }
-
- if (!IP6_IS_MULTICAST (&Private->DstAddress) &&
- !EFI_IP6_EQUAL (&RxData->Header->SourceAddress, &Private->DstAddress)) {
- goto ON_EXIT;
- }
-
- if ((Reply->Type != ICMP_V6_ECHO_REPLY) || (Reply->Code != 0)) {
- goto ON_EXIT;
- }
-
- if (PayLoad != Private->BufferSize) {
- goto ON_EXIT;
- }
- //
- // Check whether the reply matches the sent request before.
- //
- Status = Ping6MatchEchoReply (Private, Reply);
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- //
- // Display statistics on this icmp6 echo reply packet.
- //
- Rtt = Ping6CalculateTick (Reply->TimeStamp, ReadTime ());
- if (Rtt != 0) {
- Near = (CHAR8) '=';
- } else {
- Near = (CHAR8) '<';
- }
-
- Private->RttSum += Rtt;
- Private->RttMin = Private->RttMin > Rtt ? Rtt : Private->RttMin;
- Private->RttMax = Private->RttMax < Rtt ? Rtt : Private->RttMax;
-
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_PING6_REPLY_INFO),
- mHiiHandle,
- PayLoad,
- mIp6DstString,
- Reply->SequenceNum,
- RxData->Header->HopLimit,
- Near,
- Rtt
- );
-
-ON_EXIT:
-
- if (Private->RxCount < Private->SendNum) {
- //
- // Continue to receive icmp6 echo reply packets.
- //
- RxToken->Status = EFI_ABORTED;
-
- Status = Private->Ip6->Receive (Private->Ip6, RxToken);
-
- if (EFI_ERROR (Status)) {
- Private->Status = EFI_ABORTED;
- }
- } else {
- //
- // All reply have already been received from the dest host.
- //
- Private->Status = EFI_SUCCESS;
- }
- //
- // Singal to recycle the each rxdata here, not at the end of process.
- //
- gBS->SignalEvent (RxData->RecycleSignal);
-}
-
-/**
- Initial EFI_IP6_COMPLETION_TOKEN.
-
- @param[in] Private The pointer of PING6_PRIVATE_DATA.
- @param[in] TimeStamp The TimeStamp of request.
- @param[in] SequenceNum The SequenceNum of request.
-
- @return The pointer of EFI_IP6_COMPLETION_TOKEN.
-
-**/
-EFI_IP6_COMPLETION_TOKEN *
-Ping6GenerateToken (
- IN PING6_PRIVATE_DATA *Private,
- IN UINT64 TimeStamp,
- IN UINT16 SequenceNum
- )
-{
- EFI_STATUS Status;
- EFI_IP6_COMPLETION_TOKEN *Token;
- EFI_IP6_TRANSMIT_DATA *TxData;
- ICMP6_ECHO_REQUEST_REPLY *Request;
-
- Request = AllocateZeroPool (Private->BufferSize);
-
- if (Request == NULL) {
- return NULL;
- }
- //
- // Assembly icmp6 echo request packet.
- //
- Request->Type = ICMP_V6_ECHO_REQUEST;
- Request->Code = 0;
- Request->SequenceNum = SequenceNum;
- Request->TimeStamp = TimeStamp;
- Request->Identifier = 0;
- //
- // Leave check sum to ip6 layer, since it has no idea of source address
- // selection.
- //
- Request->Checksum = 0;
-
- TxData = AllocateZeroPool (sizeof (EFI_IP6_TRANSMIT_DATA));
-
- if (TxData == NULL) {
- FreePool (Request);
- return NULL;
- }
- //
- // Assembly ipv6 token for transmit.
- //
- TxData->OverrideData = 0;
- TxData->ExtHdrsLength = 0;
- TxData->ExtHdrs = NULL;
- TxData->DataLength = Private->BufferSize;
- TxData->FragmentCount = 1;
- TxData->FragmentTable[0].FragmentBuffer = (VOID *) Request;
- TxData->FragmentTable[0].FragmentLength = Private->BufferSize;
-
- Token = AllocateZeroPool (sizeof (EFI_IP6_COMPLETION_TOKEN));
-
- if (Token == NULL) {
- FreePool (Request);
- FreePool (TxData);
- return NULL;
- }
-
- Token->Status = EFI_ABORTED;
- Token->Packet.TxData = TxData;
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- Ping6OnEchoRequestSent,
- Private,
- &Token->Event
- );
-
- if (EFI_ERROR (Status)) {
- FreePool (Request);
- FreePool (TxData);
- FreePool (Token);
- return NULL;
- }
-
- return Token;
-}
-
-/**
- Transmit the EFI_IP6_COMPLETION_TOKEN.
-
- @param[in] Private The pointer of PING6_PRIVATE_DATA.
-
- @retval EFI_SUCCESS Transmitted successfully.
- @retval EFI_OUT_OF_RESOURCES No memory is available on the platform.
- @retval others Transmitted unsuccessfully.
-
-**/
-EFI_STATUS
-Ping6SendEchoRequest (
- IN PING6_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
- PING6_ICMP6_TX_INFO *TxInfo;
-
- TxInfo = AllocateZeroPool (sizeof (PING6_ICMP6_TX_INFO));
-
- if (TxInfo == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- TxInfo->TimeStamp = ReadTime ();
- TxInfo->SequenceNum = (UINT16) (Private->TxCount + 1);
-
- TxInfo->Token = Ping6GenerateToken (
- Private,
- TxInfo->TimeStamp,
- TxInfo->SequenceNum
- );
-
- if (TxInfo->Token == NULL) {
- Ping6DestroyTxInfo (TxInfo);
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = Private->Ip6->Transmit (Private->Ip6, TxInfo->Token);
-
- if (EFI_ERROR (Status)) {
- Ping6DestroyTxInfo (TxInfo);
- return Status;
- }
-
- InsertTailList (&Private->TxList, &TxInfo->Link);
- Private->TxCount++;
-
- return EFI_SUCCESS;
-}
-
-/**
- Place a completion token into the receive packet queue to receive the echo reply.
-
- @param[in] Private The pointer of PING6_PRIVATE_DATA.
-
- @retval EFI_SUCCESS Put the token into the receive packet queue successfully.
- @retval others Put the token into the receive packet queue unsuccessfully.
-
-**/
-EFI_STATUS
-Ping6ReceiveEchoReply (
- IN PING6_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
-
- ZeroMem (&Private->RxToken, sizeof (EFI_IP6_COMPLETION_TOKEN));
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- Ping6OnEchoReplyReceived,
- Private,
- &Private->RxToken.Event
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Private->RxToken.Status = EFI_NOT_READY;
-
- return Private->Ip6->Receive (Private->Ip6, &Private->RxToken);
-}
-
-/**
- Remove the timeout request from the list.
-
- @param[in] Event A EFI_EVENT type event.
- @param[in] Context The pointer to Context.
-
-**/
-VOID
-EFIAPI
-Ping6OnTimerRoutine (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- PING6_PRIVATE_DATA *Private;
- PING6_ICMP6_TX_INFO *TxInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- UINT64 Time;
-
- Private = (PING6_PRIVATE_DATA *) Context;
-
- //
- // Retransmit icmp6 echo request packets per second in sendnumber times.
- //
- if (Private->TxCount < Private->SendNum) {
-
- Status = Ping6SendEchoRequest (Private);
- if (Private->TxCount != 0){
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_SEND_REQUEST), mHiiHandle, Private->TxCount + 1);
- }
- }
- }
- //
- // Check whether any icmp6 echo request in the list timeout.
- //
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) {
- TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link);
- Time = Ping6CalculateTick (TxInfo->TimeStamp, ReadTime ());
-
- //
- // Remove the timeout echo request from txlist.
- //
- if (Time > PING6_DEFAULT_TIMEOUT) {
-
- if (EFI_ERROR (TxInfo->Token->Status)) {
- Private->Ip6->Cancel (Private->Ip6, TxInfo->Token);
- }
- //
- // Remove the timeout icmp6 echo request from list.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_TIMEOUT), mHiiHandle, TxInfo->SequenceNum);
-
- RemoveEntryList (&TxInfo->Link);
- Ping6DestroyTxInfo (TxInfo);
-
- if (IsListEmpty (&Private->TxList) && (Private->TxCount == Private->SendNum)) {
- //
- // All the left icmp6 echo request in the list timeout.
- //
- Private->Status = EFI_TIMEOUT;
- }
- }
- }
-}
-
-/**
- Create a valid IP6 instance.
-
- @param[in] Private The pointer of PING6_PRIVATE_DATA.
-
- @retval EFI_SUCCESS Create a valid IP6 instance successfully.
- @retval EFI_ABORTED Locate handle with ip6 service binding protocol unsuccessfully.
- @retval EFI_INVALID_PARAMETER The source address is unspecified when the destination address is a link -ocal address.
- @retval EFI_OUT_OF_RESOURCES No memory is available on the platform.
- @retval EFI_NOT_FOUND The source address is not found.
-**/
-EFI_STATUS
-Ping6CreateIp6Instance (
- IN PING6_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
- UINTN HandleIndex;
- UINTN HandleNum;
- EFI_HANDLE *HandleBuffer;
- EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- EFI_IP6_CONFIG_DATA Ip6Config;
- EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
- UINTN IfInfoSize;
- EFI_IPv6_ADDRESS *Addr;
- UINTN AddrIndex;
-
- HandleBuffer = NULL;
- Ip6Sb = NULL;
- IfInfo = NULL;
- IfInfoSize = 0;
-
- //
- // Locate all the handles with ip6 service binding protocol.
- //
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiIp6ServiceBindingProtocolGuid,
- NULL,
- &HandleNum,
- &HandleBuffer
- );
- if (EFI_ERROR (Status) || (HandleNum == 0)) {
- return EFI_ABORTED;
- }
- //
- // Source address is required when pinging a link-local address on multi-
- // interfaces host.
- //
- if (NetIp6IsLinkLocalAddr (&Private->DstAddress) &&
- NetIp6IsUnspecifiedAddr (&Private->SrcAddress) &&
- (HandleNum > 1)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_SOURCE), mHiiHandle);
- Status = EFI_INVALID_PARAMETER;
- goto ON_ERROR;
- }
- //
- // For each ip6 protocol, check interface addresses list.
- //
- for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
-
- Ip6Sb = NULL;
- IfInfo = NULL;
- IfInfoSize = 0;
-
- Status = gBS->HandleProtocol (
- HandleBuffer[HandleIndex],
- &gEfiIp6ServiceBindingProtocolGuid,
- (VOID **) &Ip6Sb
- );
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
- if (NetIp6IsUnspecifiedAddr (&Private->SrcAddress)) {
- //
- // No need to match interface address.
- //
- break;
- } else {
- //
- // Ip6config protocol and ip6 service binding protocol are installed
- // on the same handle.
- //
- Status = gBS->HandleProtocol (
- HandleBuffer[HandleIndex],
- &gEfiIp6ConfigProtocolGuid,
- (VOID **) &Ip6Cfg
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
- //
- // Get the interface information size.
- //
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &IfInfoSize,
- NULL
- );
-
- if (Status != EFI_BUFFER_TOO_SMALL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
-
- IfInfo = AllocateZeroPool (IfInfoSize);
-
- if (IfInfo == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_ERROR;
- }
- //
- // Get the interface info.
- //
- Status = Ip6Cfg->GetData (
- Ip6Cfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &IfInfoSize,
- IfInfo
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_IP6CFG_GETDATA), mHiiHandle, Status);
- goto ON_ERROR;
- }
- //
- // Check whether the source address is one of the interface addresses.
- //
- for (AddrIndex = 0; AddrIndex < IfInfo->AddressInfoCount; AddrIndex++) {
-
- Addr = &(IfInfo->AddressInfo[AddrIndex].Address);
- if (EFI_IP6_EQUAL (&Private->SrcAddress, Addr)) {
- //
- // Match a certain interface address.
- //
- break;
- }
- }
-
- if (AddrIndex < IfInfo->AddressInfoCount) {
- //
- // Found a nic handle with right interface address.
- //
- break;
- }
- }
-
- FreePool (IfInfo);
- IfInfo = NULL;
- }
- //
- // No exact interface address matched.
- //
-
- if (HandleIndex == HandleNum) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_SOURCE_NOT_FOUND), mHiiHandle, mIp6SrcString);
- Status = EFI_NOT_FOUND;
- goto ON_ERROR;
- }
-
- Private->NicHandle = HandleBuffer[HandleIndex];
-
- ASSERT (Ip6Sb != NULL);
- Status = Ip6Sb->CreateChild (Ip6Sb, &Private->Ip6ChildHandle);
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
- Status = gBS->OpenProtocol (
- Private->Ip6ChildHandle,
- &gEfiIp6ProtocolGuid,
- (VOID **) &Private->Ip6,
- Private->ImageHandle,
- Private->Ip6ChildHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
- ZeroMem (&Ip6Config, sizeof (EFI_IP6_CONFIG_DATA));
-
- //
- // Configure the ip6 instance for icmp6 packet exchange.
- //
- Ip6Config.DefaultProtocol = 58;
- Ip6Config.AcceptAnyProtocol = FALSE;
- Ip6Config.AcceptIcmpErrors = TRUE;
- Ip6Config.AcceptPromiscuous = FALSE;
- Ip6Config.TrafficClass = 0;
- Ip6Config.HopLimit = 128;
- Ip6Config.FlowLabel = 0;
- Ip6Config.ReceiveTimeout = 0;
- Ip6Config.TransmitTimeout = 0;
-
- IP6_COPY_ADDRESS (&Ip6Config.StationAddress, &Private->SrcAddress);
-
- IP6_COPY_ADDRESS (&Ip6Config.DestinationAddress, &Private->DstAddress);
-
- Status = Private->Ip6->Configure (Private->Ip6, &Ip6Config);
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_IP6_CONFIG), mHiiHandle, Status);
- goto ON_ERROR;
- }
-
- return EFI_SUCCESS;
-
-ON_ERROR:
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- if (IfInfo != NULL) {
- FreePool (IfInfo);
- }
-
- if ((Ip6Sb != NULL) && (Private->Ip6ChildHandle != NULL)) {
- Ip6Sb->DestroyChild (Ip6Sb, Private->Ip6ChildHandle);
- }
-
- return Status;
-}
-
-/**
- Destroy the IP6 instance.
-
- @param[in] Private The pointer of PING6_PRIVATE_DATA.
-
-**/
-VOID
-Ping6DestroyIp6Instance (
- IN PING6_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
- EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb;
-
- gBS->CloseProtocol (
- Private->Ip6ChildHandle,
- &gEfiIp6ProtocolGuid,
- Private->ImageHandle,
- Private->Ip6ChildHandle
- );
-
- Status = gBS->HandleProtocol (
- Private->NicHandle,
- &gEfiIp6ServiceBindingProtocolGuid,
- (VOID **) &Ip6Sb
- );
-
- if (!EFI_ERROR(Status)) {
- Ip6Sb->DestroyChild (Ip6Sb, Private->Ip6ChildHandle);
- }
-}
-
-/**
- The Ping6 Process.
-
- @param[in] ImageHandle The firmware allocated handle for the UEFI image.
- @param[in] SendNumber The send request count.
- @param[in] BufferSize The send buffer size.
- @param[in] SrcAddress The source IPv6 address.
- @param[in] DstAddress The destination IPv6 address.
-
- @retval EFI_SUCCESS The ping6 processed successfullly.
- @retval others The ping6 processed unsuccessfully.
-
-**/
-EFI_STATUS
-Ping6 (
- IN EFI_HANDLE ImageHandle,
- IN UINT32 SendNumber,
- IN UINT32 BufferSize,
- IN EFI_IPv6_ADDRESS *SrcAddress,
- IN EFI_IPv6_ADDRESS *DstAddress
- )
-{
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- PING6_PRIVATE_DATA *Private;
- PING6_ICMP6_TX_INFO *TxInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
-
- Private = AllocateZeroPool (sizeof (PING6_PRIVATE_DATA));
-
- ASSERT (Private != NULL);
-
- Private->ImageHandle = ImageHandle;
- Private->SendNum = SendNumber;
- Private->BufferSize = BufferSize;
- Private->RttMin = ~((UINT64 )(0x0));
- Private->Status = EFI_NOT_READY;
-
- InitializeListHead (&Private->TxList);
-
- IP6_COPY_ADDRESS (&Private->SrcAddress, SrcAddress);
- IP6_COPY_ADDRESS (&Private->DstAddress, DstAddress);
-
- //
- // Open and configure a ip6 instance for ping6.
- //
- Status = Ping6CreateIp6Instance (Private);
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
- //
- // Print the command line itself.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_START), mHiiHandle, mIp6DstString, Private->BufferSize);
- //
- // Create a ipv6 token to receive the first icmp6 echo reply packet.
- //
- Status = Ping6ReceiveEchoReply (Private);
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
- //
- // Create and start timer to send icmp6 echo request packet per second.
- //
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- Ping6OnTimerRoutine,
- Private,
- &Private->Timer
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
- //
- // Create a ipv6 token to send the first icmp6 echo request packet.
- //
- Status = Ping6SendEchoRequest (Private);
- //
- // EFI_NOT_READY for IPsec is enable and IKE is not established.
- //
- if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
- if(Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_NOSOURCE_INDOMAIN), mHiiHandle, mIp6DstString);
- }
-
- goto ON_EXIT;
- }
-
- Status = gBS->SetTimer (
- Private->Timer,
- TimerPeriodic,
- PING6_ONE_SECOND
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
- //
- // Control the ping6 process by two factors:
- // 1. Hot key
- // 2. Private->Status
- // 2.1. success means all icmp6 echo request packets get reply packets.
- // 2.2. timeout means the last icmp6 echo reply request timeout to get reply.
- // 2.3. noready means ping6 process is on-the-go.
- //
- while (Private->Status == EFI_NOT_READY) {
- Private->Ip6->Poll (Private->Ip6);
-
- //
- // Terminate the ping6 process by 'esc' or 'ctl-c'.
- //
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
-
- if (!EFI_ERROR(Status)) {
- if ((Key.UnicodeChar == 0x1b) || (Key.UnicodeChar == 0x03) ||
- ((Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_ESC))) {
- goto ON_STAT;
- }
- }
- }
-
-ON_STAT:
- //
- // Display the statistics in all.
- //
- gBS->SetTimer (Private->Timer, TimerCancel, 0);
-
- if (Private->TxCount != 0) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_PING6_STAT),
- mHiiHandle,
- Private->TxCount,
- Private->RxCount,
- (100 * (Private->TxCount - Private->RxCount)) / Private->TxCount,
- Private->RttSum
- );
- }
-
- if (Private->RxCount != 0) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_PING6_RTT),
- mHiiHandle,
- Private->RttMin,
- Private->RttMax,
- DivU64x64Remainder (Private->RttSum, Private->RxCount, NULL)
- );
- }
-
-ON_EXIT:
-
- if (Private != NULL) {
- Private->Status = EFI_ABORTED;
-
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) {
- TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link);
-
- Status = Private->Ip6->Cancel (Private->Ip6, TxInfo->Token);
-
- RemoveEntryList (&TxInfo->Link);
- Ping6DestroyTxInfo (TxInfo);
- }
-
- if (Private->Timer != NULL) {
- gBS->CloseEvent (Private->Timer);
- }
-
- if (Private->Ip6 != NULL) {
- Status = Private->Ip6->Cancel (Private->Ip6, &Private->RxToken);
- }
-
- if (Private->RxToken.Event != NULL) {
- gBS->CloseEvent (Private->RxToken.Event);
- }
-
- if (Private->Ip6ChildHandle != NULL) {
- Ping6DestroyIp6Instance (Private);
- }
-
- FreePool (Private);
- }
-
- return Status;
-}
-
-/**
- This is the declaration of an EFI image entry point. This entry point is
- the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, including
- both device drivers and bus drivers.
-
- The entry point for the Ping6 application that parses the command line input and calls the Ping6 process.
-
- @param[in] ImageHandle The firmware allocated handle for the UEFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETETR Input parameters combination is invalid.
- @retval Others Some errors occur.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializePing6 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_IPv6_ADDRESS DstAddress;
- EFI_IPv6_ADDRESS SrcAddress;
- UINT64 BufferSize;
- UINTN SendNumber;
- LIST_ENTRY *ParamPackage;
- CONST CHAR16 *ValueStr;
- CONST CHAR16 *ValueStrPtr;
- UINTN NonOptionCount;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
-
- //
- // Retrieve HII package list from ImageHandle
- //
- Status = gBS->OpenProtocol (
- ImageHandle,
- &gEfiHiiPackageListProtocolGuid,
- (VOID **) &PackageList,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Publish HII package list to HII Database.
- //
- Status = gHiiDatabase->NewPackageList (
- gHiiDatabase,
- PackageList,
- NULL,
- &mHiiHandle
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ASSERT (mHiiHandle != NULL);
-
- Status = ShellCommandLineParseEx (Ping6ParamList, &ParamPackage, NULL, TRUE, FALSE);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_INPUT), mHiiHandle);
- goto ON_EXIT;
- }
-
- SendNumber = 10;
- BufferSize = 16;
-
- //
- // Parse the parameter of count number.
- //
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-n");
- ValueStrPtr = ValueStr;
- if (ValueStr != NULL) {
- SendNumber = ShellStrToUintn (ValueStrPtr);
-
- //
- // ShellStrToUintn will return 0 when input is 0 or an invalid input string.
- //
- if ((SendNumber == 0) || (SendNumber > PING6_MAX_SEND_NUMBER)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_SEND_NUMBER), mHiiHandle, ValueStr);
- Status = EFI_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- }
- //
- // Parse the parameter of buffer size.
- //
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l");
- ValueStrPtr = ValueStr;
- if (ValueStr != NULL) {
- BufferSize = ShellStrToUintn (ValueStrPtr);
-
- //
- // ShellStrToUintn will return 0 when input is 0 or an invalid input string.
- //
- if ((BufferSize < 16) || (BufferSize > PING6_MAX_BUFFER_SIZE)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_BUFFER_SIZE), mHiiHandle, ValueStr);
- Status = EFI_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- }
-
- ZeroMem (&SrcAddress, sizeof (EFI_IPv6_ADDRESS));
- ZeroMem (&DstAddress, sizeof (EFI_IPv6_ADDRESS));
-
- //
- // Parse the parameter of source ip address.
- //
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s");
- ValueStrPtr = ValueStr;
- if (ValueStr != NULL) {
- mIp6SrcString = ValueStr;
- Status = NetLibStrToIp6 (ValueStrPtr, &SrcAddress);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_IP), mHiiHandle, ValueStr);
- Status = EFI_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- }
- //
- // Parse the parameter of destination ip address.
- //
- NonOptionCount = ShellCommandLineGetCount(ParamPackage);
- ValueStr = ShellCommandLineGetRawValue (ParamPackage, (UINT32)(NonOptionCount-1));
- if (NonOptionCount != 2) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_INPUT), mHiiHandle);
- Status = EFI_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- ValueStrPtr = ValueStr;
- if (ValueStr != NULL) {
- mIp6DstString = ValueStr;
- Status = NetLibStrToIp6 (ValueStrPtr, &DstAddress);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_IP), mHiiHandle, ValueStr);
- Status = EFI_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- }
- //
- // Get frequency to calculate the time from ticks.
- //
- Status = Ping6GetFrequency ();
-
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- //
- // Enter into ping6 process.
- //
- Status = Ping6 (
- ImageHandle,
- (UINT32)SendNumber,
- (UINT32)BufferSize,
- &SrcAddress,
- &DstAddress
- );
-
-ON_EXIT:
- ShellCommandLineFreeVarList (ParamPackage);
- HiiRemovePackages (mHiiHandle);
- return Status;
-}
diff --git a/NetworkPkg/Application/Ping6/Ping6.h b/NetworkPkg/Application/Ping6/Ping6.h
deleted file mode 100644
index 6f590af8c0..0000000000
--- a/NetworkPkg/Application/Ping6/Ping6.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/** @file
- The interface function declaration of shell application Ping6 (Ping for v6 series).
-
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _PING6_H_
-#define _PING6_H_
-
-#define PING6_DEFAULT_TIMEOUT 5000
-#define PING6_MAX_SEND_NUMBER 10000
-#define PING6_MAX_BUFFER_SIZE 32768
-#define PING6_ONE_SECOND 10000000
-
-//
-// A similar amount of time that passes in femtoseconds
-// for each increment of TimerValue. It is for NT32 only.
-//
-#define NTTIMERPERIOD 358049
-
-#pragma pack(1)
-
-typedef struct _ICMP6_ECHO_REQUEST_REPLY {
- UINT8 Type;
- UINT8 Code;
- UINT16 Checksum;
- UINT16 Identifier;
- UINT16 SequenceNum;
- UINT64 TimeStamp;
- UINT8 Data[1];
-} ICMP6_ECHO_REQUEST_REPLY;
-
-#pragma pack()
-
-typedef struct _PING6_ICMP6_TX_INFO {
- LIST_ENTRY Link;
- UINT16 SequenceNum;
- UINT64 TimeStamp;
- EFI_IP6_COMPLETION_TOKEN *Token;
-} PING6_ICMP6_TX_INFO;
-
-typedef struct _PING6_PRIVATE_DATA {
- EFI_HANDLE ImageHandle;
- EFI_HANDLE NicHandle;
- EFI_HANDLE Ip6ChildHandle;
- EFI_IP6_PROTOCOL *Ip6;
- EFI_EVENT Timer;
-
- EFI_STATUS Status;
- LIST_ENTRY TxList;
- EFI_IP6_COMPLETION_TOKEN RxToken;
- UINT16 RxCount;
- UINT16 TxCount;
- UINT64 RttSum;
- UINT64 RttMin;
- UINT64 RttMax;
- UINT32 SequenceNum;
-
- EFI_IPv6_ADDRESS SrcAddress;
- EFI_IPv6_ADDRESS DstAddress;
- UINT32 SendNum;
- UINT32 BufferSize;
-} PING6_PRIVATE_DATA;
-
-/**
- Reads and returns the current value of register.
- In IA64, the register is the Interval Timer Vector (ITV).
- In X86(IA32/X64), the register is the Time Stamp Counter (TSC)
-
- @return The current value of the register.
-
-**/
-UINT64
-ReadTime (
- VOID
- );
-
-#endif
diff --git a/NetworkPkg/Application/Ping6/Ping6.inf b/NetworkPkg/Application/Ping6/Ping6.inf
deleted file mode 100644
index 68b5f2d32f..0000000000
--- a/NetworkPkg/Application/Ping6/Ping6.inf
+++ /dev/null
@@ -1,78 +0,0 @@
-## @file
-# Shell application Ping6.
-#
-# It is an shell application which is used to Ping the target host with IPv6 stack.
-#
-# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = Ping6
- FILE_GUID = F35F733F-5235-4d7b-83FA-97780CEBCB20
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializePing6
- MODULE_UNI_FILE = Ping6.uni
-
-#
-#
-# This flag specifies whether HII resource section is generated into PE image.
-#
- UEFI_HII_RESOURCE_SECTION = TRUE
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF
-#
-
-[Sources]
- Ping6.c
- Ping6Strings.uni
- Ping6.h
-
-[Sources.IA32]
- Ia32/Tsc.c
-
-[Sources.X64]
- X64/Tsc.c
-
-[Sources.IPF]
- Ipf/Itc.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ShellPkg/ShellPkg.dec
-
-[LibraryClasses]
- BaseLib
- UefiBootServicesTableLib
- UefiApplicationEntryPoint
- UefiHiiServicesLib
- BaseMemoryLib
- ShellLib
- MemoryAllocationLib
- DebugLib
- HiiLib
- NetLib
-
-[Protocols]
- gEfiCpuArchProtocolGuid ## CONSUMES
- gEfiIp6ProtocolGuid ## CONSUMES
- gEfiIp6ServiceBindingProtocolGuid ## CONSUMES
- gEfiIp6ConfigProtocolGuid ## CONSUMES
- gEfiHiiPackageListProtocolGuid ## CONSUMES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- Ping6Extra.uni
diff --git a/NetworkPkg/Application/Ping6/Ping6.uni b/NetworkPkg/Application/Ping6/Ping6.uni
deleted file mode 100644
index afd14b796a..0000000000
--- a/NetworkPkg/Application/Ping6/Ping6.uni
+++ /dev/null
@@ -1,22 +0,0 @@
-// /** @file
-// Shell application Ping6.
-//
-// It is an shell application which is used to Ping the target host with IPv6 stack.
-//
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php.
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Shell application Ping6"
-
-#string STR_MODULE_DESCRIPTION #language en-US "It is an shell application which is used to Ping the target host with IPv6 stack."
-
diff --git a/NetworkPkg/Application/Ping6/Ping6Extra.uni b/NetworkPkg/Application/Ping6/Ping6Extra.uni
deleted file mode 100644
index 097ea5578a..0000000000
--- a/NetworkPkg/Application/Ping6/Ping6Extra.uni
+++ /dev/null
@@ -1,20 +0,0 @@
-// /** @file
-// Ping6 Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php.
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"Ping6 App"
-
-
diff --git a/NetworkPkg/Application/Ping6/Ping6Strings.uni b/NetworkPkg/Application/Ping6/Ping6Strings.uni
deleted file mode 100644
index e4ab19fe63..0000000000
--- a/NetworkPkg/Application/Ping6/Ping6Strings.uni
+++ /dev/null
@@ -1,53 +0,0 @@
-/** @file
- String definitions for the Shell Ping6 application.
-
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#langdef en-US "English"
-
-#string STR_PING6_INVALID_IP #language en-US "%Ping6: Invalid IP6 address, %s\n"
-#string STR_PING6_INVALID_INPUT #language en-US "%Ping6: Invalid input, please type 'Ping6 -?'for help\n"
-#string STR_PING6_INVALID_SEND_NUMBER #language en-US "%Ping6: Invalid send number, %s\n"
-#string STR_PING6_INVALID_BUFFER_SIZE #language en-US "%Ping6: Invalid buffer size, %s\n"
-#string STR_PING6_INVALID_SOURCE #language en-US "%Ping6: Require source interface option\n"
-#string STR_PING6_IP6_CONFIG #language en-US "%Ping6: Ip6->Config %r\n"
-#string STR_PING6_IP6_GETMODE #language en-US "%Ping6: Ip6->GetModeData %r\n"
-#string STR_PING6_IP6CFG_GETDATA #language en-US "%Ping6: Ip6Config->GetData %r\n"
-#string STR_PING6_SEND_REQUEST #language en-US "Echo request sequence %d fails.\n"
-#string STR_PING6_SOURCE_NOT_FOUND #language en-US "Source %s not found.\n"
-#string STR_PING6_NOSOURCE_INDOMAIN #language en-US "No sources in %s's multicast domain.\n"
-#string STR_PING6_START #language en-US "Ping %s %d data bytes\n\n"
-#string STR_PING6_TIMEOUT #language en-US "Echo request sequence %d timeout.\n"
-#string STR_PING6_REPLY_INFO #language en-US "%d bytes from %s : icmp_seq=%d ttl=%d time%c%dms\n"
-#string STR_PING6_STAT #language en-US "\n%d packets transmitted, %d received, %d%% packet loss, time %dms\n"
-#string STR_PING6_RTT #language en-US "\nRtt(round trip time) min=%dms max=%dms avg=%dms\n"
-#string STR_PING6_LINE_HELP #language en-US "Ping a target machine with UEFI IPv6 network stack"
-
-#string STR_PING6_HELP #language en-US ""
-".TH Ping6 0 "Ping a target machine with UEFI IPv6 network stack."\r\n"
-".SH NAME\r\n"
-"Ping a target machine with UEFI IPv6 network stack.\r\n"
-".SH SYNOPSIS\r\n"
-" \r\n"
-"Ping6 [-l size] [-n count] [-s SourceIp] TargetIp\r\n"
-".SH OPTIONS\r\n"
-" \r\n"
-" -l size Send buffer size, in bytes(default=16, min=16, max=32768).\r\n"
-" -n count Send request count, (default=10, min=1, max=10000).\r\n"
-" -s SourceIp Source IPv6 address.\r\n"
-" TargetIp Target IPv6 address.\r\n"
-".SH EXAMPLES\r\n"
-" \r\n"
-"Examples:\r\n"
-" Ping6 -s 2002::1 2002::2 -l 1000 -n 5\r\n"
-" Ping6 2002::2 -l 1000\r\n"
diff --git a/NetworkPkg/Application/Ping6/X64/Tsc.c b/NetworkPkg/Application/Ping6/X64/Tsc.c
deleted file mode 100644
index b3e7bdbb96..0000000000
--- a/NetworkPkg/Application/Ping6/X64/Tsc.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- The implement to read TSC in X64 platform.
-
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-
-/**
- Reads and returns the current value of Time Stamp Counter (TSC).
-
- @return The current value of TSC
-
-**/
-UINT64
-ReadTime ()
-{
- return AsmReadTsc ();
-}
diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index 56a1a6b617..b193f5f38b 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -116,7 +116,6 @@
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
NetworkPkg/HttpBootDxe/HttpBootDxe.inf
- NetworkPkg/Application/IfConfig6/IfConfig6.inf
NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
NetworkPkg/Application/VConfig/VConfig.inf
@@ -126,8 +125,6 @@
NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
NetworkPkg/TlsDxe/TlsDxe.inf
NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf
-
- NetworkPkg/Application/Ping6/Ping6.inf
[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
--
2.13.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com> > -----Original Message----- > From: Fu, Siyuan > Sent: Tuesday, October 17, 2017 9:08 PM > To: edk2-devel@lists.01.org > Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com> > Subject: [Patch] NetworkPkg: Remove ping6 and ifconfig shell application. > > Edk2 has duplicated ping6/ifconfig6 implementation in NetworkPkg and > ShellPkg. > The usage and parameter format of these 2 versions are exactly same. These > two > commands have been added to Shell specification so the copy under > ShellPkg\Library\UefiShellNetwork2CommandsLib\ > will be actively maintained in future. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> > Cc: Wu Jiaxin <jiaxin.wu@intel.com> > Cc: Ye Ting <ting.ye@intel.com> > --- > NetworkPkg/Application/IfConfig6/IfConfig6.c | 1793 -------------------- > NetworkPkg/Application/IfConfig6/IfConfig6.h | 79 - > NetworkPkg/Application/IfConfig6/IfConfig6.inf | 67 - > NetworkPkg/Application/IfConfig6/IfConfig6.uni | 23 - > .../Application/IfConfig6/IfConfig6Extra.uni | 20 - > .../Application/IfConfig6/IfConfig6Strings.uni | 92 - > NetworkPkg/Application/Ping6/Ia32/Tsc.c | 28 - > NetworkPkg/Application/Ping6/Ipf/Itc.c | 28 - > NetworkPkg/Application/Ping6/Ping6.c | 1200 ------------- > NetworkPkg/Application/Ping6/Ping6.h | 87 - > NetworkPkg/Application/Ping6/Ping6.inf | 78 - > NetworkPkg/Application/Ping6/Ping6.uni | 22 - > NetworkPkg/Application/Ping6/Ping6Extra.uni | 20 - > NetworkPkg/Application/Ping6/Ping6Strings.uni | 53 - > NetworkPkg/Application/Ping6/X64/Tsc.c | 28 - > NetworkPkg/NetworkPkg.dsc | 3 - > 16 files changed, 3621 deletions(-) > delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.c > delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.h > delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.inf > delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.uni > delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni > delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni > delete mode 100644 NetworkPkg/Application/Ping6/Ia32/Tsc.c > delete mode 100644 NetworkPkg/Application/Ping6/Ipf/Itc.c > delete mode 100644 NetworkPkg/Application/Ping6/Ping6.c > delete mode 100644 NetworkPkg/Application/Ping6/Ping6.h > delete mode 100644 NetworkPkg/Application/Ping6/Ping6.inf > delete mode 100644 NetworkPkg/Application/Ping6/Ping6.uni > delete mode 100644 NetworkPkg/Application/Ping6/Ping6Extra.uni > delete mode 100644 NetworkPkg/Application/Ping6/Ping6Strings.uni > delete mode 100644 NetworkPkg/Application/Ping6/X64/Tsc.c > > diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.c > b/NetworkPkg/Application/IfConfig6/IfConfig6.c > deleted file mode 100644 > index 48c3be3552..0000000000 > --- a/NetworkPkg/Application/IfConfig6/IfConfig6.c > +++ /dev/null > @@ -1,1793 +0,0 @@ > -/** @file > - The implementation for Shell application IfConfig6. > - > - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#include <Library/ShellLib.h> > -#include <Library/BaseMemoryLib.h> > -#include <Library/BaseLib.h> > -#include <Library/MemoryAllocationLib.h> > -#include <Library/DebugLib.h> > -#include <Library/UefiBootServicesTableLib.h> > -#include <Library/UefiHiiServicesLib.h> > -#include <Library/HiiLib.h> > -#include <Library/NetLib.h> > - > -#include <Protocol/Ip6.h> > -#include <Protocol/Ip6Config.h> > - > -#include "IfConfig6.h" > - > -// > -// String token ID of ifconfig6 command help message text. > -// > -GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID > mStringIfconfig6HelpTokenId = STRING_TOKEN (STR_IFCONFIG6_HELP); > - > -EFI_HII_HANDLE mHiiHandle; > - > -SHELL_PARAM_ITEM mIfConfig6CheckList[] = { > - { > - L"-b", > - TypeFlag > - }, > - { > - L"-s", > - TypeMaxValue > - }, > - { > - L"-l", > - TypeValue > - }, > - { > - L"-r", > - TypeValue > - }, > - { > - NULL, > - TypeMax > - }, > -}; > - > -VAR_CHECK_ITEM mSetCheckList[] = { > - { > - L"auto", > - 0x00000001, > - 0x00000001, > - FlagTypeSingle > - }, > - { > - L"man", > - 0x00000002, > - 0x00000001, > - FlagTypeSingle > - }, > - { > - L"host", > - 0x00000004, > - 0x00000002, > - FlagTypeSingle > - }, > - { > - L"dad", > - 0x00000008, > - 0x00000004, > - FlagTypeSingle > - }, > - { > - L"gw", > - 0x00000010, > - 0x00000008, > - FlagTypeSingle > - }, > - { > - L"dns", > - 0x00000020, > - 0x00000010, > - FlagTypeSingle > - }, > - { > - L"id", > - 0x00000040, > - 0x00000020, > - FlagTypeSingle > - }, > - { > - NULL, > - 0x0, > - 0x0, > - FlagTypeSkipUnknown > - }, > -}; > - > -/** > - Split a string with specified separator and save the substring to a list. > - > - @param[in] String The pointer of the input string. > - @param[in] Separator The specified separator. > - > - @return The pointer of headnode of ARG_LIST. > - > -**/ > -ARG_LIST * > -SplitStrToList ( > - IN CONST CHAR16 *String, > - IN CHAR16 Separator > - ) > -{ > - CHAR16 *Str; > - CHAR16 *ArgStr; > - ARG_LIST *ArgList; > - ARG_LIST *ArgNode; > - > - if (String == NULL || *String == L'\0') { > - return NULL; > - } > - > - // > - // Copy the CONST string to a local copy. > - // > - Str = AllocateCopyPool (StrSize (String), String); > - ASSERT (Str != NULL); > - ArgStr = Str; > - > - // > - // init a node for the list head. > - // > - ArgNode = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST)); > - ASSERT (ArgNode != NULL); > - ArgList = ArgNode; > - > - // > - // Split the local copy and save in the list node. > - // > - while (*Str != L'\0') { > - if (*Str == Separator) { > - *Str = L'\0'; > - ArgNode->Arg = ArgStr; > - ArgStr = Str + 1; > - ArgNode->Next = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST)); > - ASSERT (ArgNode->Next != NULL); > - ArgNode = ArgNode->Next; > - } > - > - Str++; > - } > - > - ArgNode->Arg = ArgStr; > - ArgNode->Next = NULL; > - > - return ArgList; > -} > - > -/** > - Check the correctness of input Args with '-s' option. > - > - @param[in] CheckList The pointer of VAR_CHECK_ITEM array. > - @param[in] Name The pointer of input arg. > - @param[in] Init The switch to execute the check. > - > - @return The value of VAR_CHECK_CODE. > - > -**/ > -VAR_CHECK_CODE > -IfConfig6RetriveCheckListByName( > - IN VAR_CHECK_ITEM *CheckList, > - IN CHAR16 *Name, > - IN BOOLEAN Init > -) > -{ > - STATIC UINT32 CheckDuplicate; > - STATIC UINT32 CheckConflict; > - VAR_CHECK_CODE RtCode; > - UINT32 Index; > - VAR_CHECK_ITEM Arg; > - > - if (Init) { > - CheckDuplicate = 0; > - CheckConflict = 0; > - return VarCheckOk; > - } > - > - RtCode = VarCheckOk; > - Index = 0; > - Arg = CheckList[Index]; > - > - // > - // Check the Duplicated/Conflicted/Unknown input Args. > - // > - while (Arg.FlagStr != NULL) { > - if (StrCmp (Arg.FlagStr, Name) == 0) { > - > - if (CheckDuplicate & Arg.FlagID) { > - RtCode = VarCheckDuplicate; > - break; > - } > - > - if (CheckConflict & Arg.ConflictMask) { > - RtCode = VarCheckConflict; > - break; > - } > - > - CheckDuplicate |= Arg.FlagID; > - CheckConflict |= Arg.ConflictMask; > - break; > - } > - > - Arg = CheckList[++Index]; > - } > - > - if (Arg.FlagStr == NULL) { > - RtCode = VarCheckUnknown; > - } > - > - return RtCode; > -} > - > -/** > - The notify function of create event when performing a manual config. > - > - @param[in] Event The event this notify function registered to. > - @param[in] Context Pointer to the context data registered to the > event. > - > -**/ > -VOID > -EFIAPI > -IfConfig6ManualAddressNotify ( > - IN EFI_EVENT Event, > - IN VOID *Context > - ) > -{ > - *((BOOLEAN *) Context) = TRUE; > -} > - > -/** > - Print MAC address. > - > - @param[in] Node The pointer of MAC address buffer. > - @param[in] Size The size of MAC address buffer. > - > -**/ > -VOID > -IfConfig6PrintMacAddr ( > - IN UINT8 *Node, > - IN UINT32 Size > - ) > -{ > - UINTN Index; > - > - ASSERT (Size <= MACADDRMAXSIZE); > - > - for (Index = 0; Index < Size; Index++) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_MAC_ADDR_BODY), mHiiHandle, Node[Index]); > - if (Index + 1 < Size) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_COLON), mHiiHandle); > - } > - } > - > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); > -} > - > -/** > - Print IPv6 address. > - > - @param[in] Ip The pointer of Ip bufffer in EFI_IPv6_ADDRESS format. > - @param[in] PrefixLen The pointer of PrefixLen that describes the size > Prefix. > - > -**/ > -VOID > -IfConfig6PrintIpAddr ( > - IN EFI_IPv6_ADDRESS *Ip, > - IN UINT8 *PrefixLen > - ) > -{ > - UINTN Index; > - BOOLEAN Short; > - > - Short = FALSE; > - > - for (Index = 0; Index < PREFIXMAXLEN; Index = Index + 2) { > - > - if (!Short && (Index + 1 < PREFIXMAXLEN) && (Index % 2 == 0) && (Ip- > >Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0)) { > - // > - // Deal with the case of ::. > - // > - if (Index == 0) { > - // > - // :: is at the beginning of the address. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_COLON), mHiiHandle); > - } > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_COLON), mHiiHandle); > - > - while ((Ip->Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0) && (Index < > PREFIXMAXLEN)) { > - Index = Index + 2; > - if (Index > PREFIXMAXLEN - 2) { > - break; > - } > - } > - > - Short = TRUE; > - > - if (Index == PREFIXMAXLEN) { > - // > - // :: is at the end of the address. > - // > - break; > - } > - } > - > - if (Index < PREFIXMAXLEN - 1) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_IP_ADDR_BODY), mHiiHandle, Ip->Addr[Index]); > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_IP_ADDR_BODY), mHiiHandle, Ip->Addr[Index + 1]); > - } > - > - if (Index + 2 < PREFIXMAXLEN) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_COLON), mHiiHandle); > - } > - } > - > - if (PrefixLen != NULL) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_PREFIX_LEN), mHiiHandle, *PrefixLen); > - } > -} > - > -/** > - Pick up host IPv6 address in string format from Args with "-s" option and > convert it to EFI_IP6_CONFIG_MANUAL_ADDRESS format. > - > - @param[in, out] Arg The pointer of the address of ARG_LIST which > save Args with the "-s" option. > - @param[out] Buf The pointer of the address of > EFI_IP6_CONFIG_MANUAL_ADDRESS. > - @param[out] BufSize The pointer of BufSize that describes the size of > Buf in bytes. > - > - @retval EFI_SUCCESS The convertion is successful. > - @retval Others Does't find the host address, or it is an invalid IPv6 > address in string format. > - > -**/ > -EFI_STATUS > -IfConfig6ParseManualAddressList ( > - IN OUT ARG_LIST **Arg, > - OUT EFI_IP6_CONFIG_MANUAL_ADDRESS **Buf, > - OUT UINTN *BufSize > - ) > -{ > - EFI_STATUS Status; > - EFI_IP6_CONFIG_MANUAL_ADDRESS *AddrBuf; > - ARG_LIST *VarArg; > - EFI_IPv6_ADDRESS Address; > - UINT8 Prefix; > - UINT8 AddrCnt; > - > - Prefix = 0; > - AddrCnt = 0; > - *BufSize = 0; > - *Buf = NULL; > - VarArg = *Arg; > - Status = EFI_SUCCESS; > - > - // > - // Go through the list to check the correctness of input host ip6 address. > - // > - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { > - > - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); > - > - if (EFI_ERROR (Status)) { > - // > - // host ip ip ... gw > - // > - break; > - } > - > - VarArg = VarArg->Next; > - AddrCnt++; > - } > - > - if (AddrCnt == 0) { > - return EFI_INVALID_PARAMETER; > - } > - > - AddrBuf = AllocateZeroPool (AddrCnt * sizeof > (EFI_IP6_CONFIG_MANUAL_ADDRESS)); > - ASSERT (AddrBuf != NULL); > - > - AddrCnt = 0; > - VarArg = *Arg; > - Status = EFI_SUCCESS; > - > - // > - // Go through the list to fill in the EFI_IP6_CONFIG_MANUAL_ADDRESS > structure. > - // > - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { > - > - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); > - > - if (EFI_ERROR (Status)) { > - break; > - } > - > - // > - // If prefix length is not set, set it as Zero here. In the > IfConfigSetInterfaceInfo() > - // Zero prefix, length will be transfered to default prefix length. > - // > - if (Prefix == 0xFF) { > - Prefix = 0; > - } > - AddrBuf[AddrCnt].IsAnycast = FALSE; > - AddrBuf[AddrCnt].PrefixLength = Prefix; > - IP6_COPY_ADDRESS (&AddrBuf[AddrCnt].Address, &Address); > - VarArg = VarArg->Next; > - AddrCnt++; > - } > - > - *Arg = VarArg; > - > - if (EFI_ERROR (Status) && (Status != EFI_INVALID_PARAMETER)) { > - goto ON_ERROR; > - } > - > - *Buf = AddrBuf; > - *BufSize = AddrCnt * sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS); > - > - return EFI_SUCCESS; > - > -ON_ERROR: > - > - FreePool (AddrBuf); > - return Status; > -} > - > -/** > - Pick up gw/dns IPv6 address in string format from Args with "-s" option and > convert it to EFI_IPv6_ADDRESS format. > - > - @param[in, out] Arg The pointer of the address of ARG_LIST that save > Args with the "-s" option. > - @param[out] Buf The pointer of the address of EFI_IPv6_ADDRESS. > - @param[out] BufSize The pointer of BufSize that describes the size of > Buf in bytes. > - > - @retval EFI_SUCCESS The conversion is successful. > - @retval Others Doesn't find the host address, or it is an invalid IPv6 > address in string format. > - > -**/ > -EFI_STATUS > -IfConfig6ParseGwDnsAddressList ( > - IN OUT ARG_LIST **Arg, > - OUT EFI_IPv6_ADDRESS **Buf, > - OUT UINTN *BufSize > - ) > -{ > - EFI_STATUS Status; > - EFI_IPv6_ADDRESS *AddrBuf; > - ARG_LIST *VarArg; > - EFI_IPv6_ADDRESS Address; > - UINT8 Prefix; > - UINT8 AddrCnt; > - > - AddrCnt = 0; > - *BufSize = 0; > - *Buf = NULL; > - VarArg = *Arg; > - Status = EFI_SUCCESS; > - > - // > - // Go through the list to check the correctness of input gw/dns address. > - // > - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { > - > - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); > - > - if (EFI_ERROR (Status)) { > - // > - // gw ip ip ... host > - // > - break; > - } > - > - VarArg = VarArg->Next; > - AddrCnt++; > - } > - > - if (AddrCnt == 0) { > - return EFI_INVALID_PARAMETER; > - } > - > - AddrBuf = AllocateZeroPool (AddrCnt * sizeof (EFI_IPv6_ADDRESS)); > - ASSERT (AddrBuf != NULL); > - > - AddrCnt = 0; > - VarArg = *Arg; > - Status = EFI_SUCCESS; > - > - // > - // Go through the list to fill in the EFI_IPv6_ADDRESS structure. > - // > - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { > - > - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); > - > - if (EFI_ERROR (Status)) { > - break; > - } > - > - IP6_COPY_ADDRESS (&AddrBuf[AddrCnt], &Address); > - > - VarArg = VarArg->Next; > - AddrCnt++; > - } > - > - *Arg = VarArg; > - > - if (EFI_ERROR (Status) && (Status != EFI_INVALID_PARAMETER)) { > - goto ON_ERROR; > - } > - > - *Buf = AddrBuf; > - *BufSize = AddrCnt * sizeof (EFI_IPv6_ADDRESS); > - > - return EFI_SUCCESS; > - > -ON_ERROR: > - > - FreePool (AddrBuf); > - return Status; > -} > - > -/** > - Parse InterfaceId in string format from Args with the "-s" option and > convert it to EFI_IP6_CONFIG_INTERFACE_ID format. > - > - @param[in, out] Arg The pointer of the address of ARG_LIST that saves > Args with the "-s" option. > - @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID. > - > - @retval EFI_SUCCESS The get status processed successfullly. > - @retval EFI_INVALID_PARAMETER The get status process failed. > - > -**/ > -EFI_STATUS > -IfConfig6ParseInterfaceId ( > - IN OUT ARG_LIST **Arg, > - OUT EFI_IP6_CONFIG_INTERFACE_ID **IfId > - ) > -{ > - UINT8 Index; > - UINT8 NodeVal; > - CHAR16 *IdStr; > - > - if (*Arg == NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - Index = 0; > - IdStr = (*Arg)->Arg; > - ASSERT (IfId != NULL); > - *IfId = AllocateZeroPool (sizeof (EFI_IP6_CONFIG_INTERFACE_ID)); > - ASSERT (*IfId != NULL); > - > - while ((*IdStr != L'\0') && (Index < 8)) { > - > - NodeVal = 0; > - while ((*IdStr != L':') && (*IdStr != L'\0')) { > - > - if ((*IdStr <= L'F') && (*IdStr >= L'A')) { > - NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'A' + 10); > - } else if ((*IdStr <= L'f') && (*IdStr >= L'a')) { > - NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'a' + 10); > - } else if ((*IdStr <= L'9') && (*IdStr >= L'0')) { > - NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'0'); > - } else { > - FreePool (*IfId); > - return EFI_INVALID_PARAMETER; > - } > - > - IdStr++; > - } > - > - (*IfId)->Id[Index++] = NodeVal; > - > - if (*IdStr == L':') { > - IdStr++; > - } > - } > - > - *Arg = (*Arg)->Next; > - return EFI_SUCCESS; > -} > - > -/** > - Parse dad in string format from Args with the "-s" option and convert it to > UINT32 format. > - > - @param[in, out] Arg The pointer of the address of ARG_LIST that saves > Args with the "-s" option. > - @param[out] Xmits The pointer of Xmits. > - > - @retval EFI_SUCCESS The get status processed successfully. > - @retval others The get status process failed. > - > -**/ > -EFI_STATUS > -IfConfig6ParseDadXmits ( > - IN OUT ARG_LIST **Arg, > - OUT UINT32 *Xmits > - ) > -{ > - CHAR16 *ValStr; > - > - if (*Arg == NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - ValStr = (*Arg)->Arg; > - *Xmits = 0; > - > - while (*ValStr != L'\0') { > - > - if ((*ValStr <= L'9') && (*ValStr >= L'0')) { > - > - *Xmits = (*Xmits * 10) + (*ValStr - L'0'); > - > - } else { > - > - return EFI_INVALID_PARAMETER; > - } > - > - ValStr++; > - } > - > - *Arg = (*Arg)->Next; > - return EFI_SUCCESS; > -} > - > -/** > - The get current status of all handles. > - > - @param[in] ImageHandle The handle of ImageHandle. > - @param[in] IfName The pointer of IfName(interface name). > - @param[in] IfList The pointer of IfList(interface list). > - > - @retval EFI_SUCCESS The get status processed successfully. > - @retval others The get status process failed. > - > -**/ > -EFI_STATUS > -IfConfig6GetInterfaceInfo ( > - IN EFI_HANDLE ImageHandle, > - IN CHAR16 *IfName, > - IN LIST_ENTRY *IfList > - ) > -{ > - EFI_STATUS Status; > - UINTN HandleIndex; > - UINTN HandleNum; > - EFI_HANDLE *HandleBuffer; > - EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; > - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; > - IFCONFIG6_INTERFACE_CB *IfCb; > - UINTN DataSize; > - > - HandleBuffer = NULL; > - HandleNum = 0; > - > - IfInfo = NULL; > - IfCb = NULL; > - > - // > - // Locate all the handles with ip6 service binding protocol. > - // > - Status = gBS->LocateHandleBuffer ( > - ByProtocol, > - &gEfiIp6ServiceBindingProtocolGuid, > - NULL, > - &HandleNum, > - &HandleBuffer > - ); > - if (EFI_ERROR (Status) || (HandleNum == 0)) { > - return EFI_ABORTED; > - } > - > - // > - // Enumerate all handles that installed with ip6 service binding protocol. > - // > - for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) { > - IfCb = NULL; > - IfInfo = NULL; > - DataSize = 0; > - > - // > - // Ip6config protocol and ip6 service binding protocol are installed > - // on the same handle. > - // > - ASSERT (HandleBuffer != NULL); > - Status = gBS->HandleProtocol ( > - HandleBuffer[HandleIndex], > - &gEfiIp6ConfigProtocolGuid, > - (VOID **) &Ip6Cfg > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - // > - // Get the interface information size. > - // > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeInterfaceInfo, > - &DataSize, > - NULL > - ); > - > - if (Status != EFI_BUFFER_TOO_SMALL) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - > - IfInfo = AllocateZeroPool (DataSize); > - > - if (IfInfo == NULL) { > - Status = EFI_OUT_OF_RESOURCES; > - goto ON_ERROR; > - } > - // > - // Get the interface info. > - // > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeInterfaceInfo, > - &DataSize, > - IfInfo > - ); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - // > - // Check the interface name if required. > - // > - if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) != 0)) { > - FreePool (IfInfo); > - continue; > - } > - > - DataSize = 0; > - // > - // Get the size of dns server list. > - // > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeDnsServer, > - &DataSize, > - NULL > - ); > - > - if ((Status != EFI_BUFFER_TOO_SMALL) && (Status != EFI_NOT_FOUND)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - > - IfCb = AllocateZeroPool (sizeof (IFCONFIG6_INTERFACE_CB) + DataSize); > - > - if (IfCb == NULL) { > - Status = EFI_OUT_OF_RESOURCES; > - goto ON_ERROR; > - } > - > - IfCb->NicHandle = HandleBuffer[HandleIndex]; > - IfCb->IfInfo = IfInfo; > - IfCb->IfCfg = Ip6Cfg; > - IfCb->DnsCnt = (UINT32) (DataSize / sizeof (EFI_IPv6_ADDRESS)); > - > - // > - // Get the dns server list if has. > - // > - if (DataSize > 0) { > - > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeDnsServer, > - &DataSize, > - IfCb->DnsAddr > - ); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - } > - // > - // Get the interface id if has. > - // > - DataSize = sizeof (EFI_IP6_CONFIG_INTERFACE_ID); > - IfCb->IfId = AllocateZeroPool (DataSize); > - > - if (IfCb->IfId == NULL) { > - goto ON_ERROR; > - } > - > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeAltInterfaceId, > - &DataSize, > - IfCb->IfId > - ); > - > - if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - > - if (Status == EFI_NOT_FOUND) { > - FreePool (IfCb->IfId); > - IfCb->IfId = NULL; > - } > - // > - // Get the config policy. > - // > - DataSize = sizeof (EFI_IP6_CONFIG_POLICY); > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypePolicy, > - &DataSize, > - &IfCb->Policy > - ); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - // > - // Get the dad transmits. > - // > - DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS); > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeDupAddrDetectTransmits, > - &DataSize, > - &IfCb->Xmits > - ); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - > - InsertTailList (IfList, &IfCb->Link); > - > - if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) == 0)) { > - // > - // Only need the appointed interface, keep the allocated buffer. > - // > - IfCb = NULL; > - IfInfo = NULL; > - break; > - } > - } > - > - if (HandleBuffer != NULL) { > - FreePool (HandleBuffer); > - } > - > - return EFI_SUCCESS; > - > -ON_ERROR: > - > - if (IfInfo != NULL) { > - FreePool (IfInfo); > - } > - > - if (IfCb != NULL) { > - if (IfCb->IfId != NULL) { > - FreePool (IfCb->IfId); > - } > - > - FreePool (IfCb); > - } > - > - return Status; > -} > - > -/** > - The list process of the IfConfig6 application. > - > - @param[in] IfList The pointer of IfList(interface list). > - > - @retval EFI_SUCCESS The IfConfig6 list processed successfully. > - @retval others The IfConfig6 list process failed. > - > -**/ > -EFI_STATUS > -IfConfig6ShowInterfaceInfo ( > - IN LIST_ENTRY *IfList > - ) > -{ > - EFI_STATUS Status; > - LIST_ENTRY *Entry; > - IFCONFIG6_INTERFACE_CB *IfCb; > - UINTN Index; > - > - Entry = IfList->ForwardLink; > - Status = EFI_SUCCESS; > - > - if (IsListEmpty (IfList)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle); > - } > - > - // > - // Go through the interface list. > - // > - while (Entry != IfList) { > - > - IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link); > - > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_BREAK), mHiiHandle); > - > - // > - // Print interface name. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_IF_NAME), mHiiHandle, IfCb->IfInfo->Name); > - > - // > - // Print interface config policy. > - // > - if (IfCb->Policy == Ip6ConfigPolicyAutomatic) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_POLICY_AUTO), mHiiHandle); > - } else { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_POLICY_MAN), mHiiHandle); > - } > - > - // > - // Print dad transmit. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_DAD_TRANSMITS), mHiiHandle, IfCb->Xmits); > - > - // > - // Print interface id if has. > - // > - if (IfCb->IfId != NULL) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD), mHiiHandle); > - > - IfConfig6PrintMacAddr ( > - IfCb->IfId->Id, > - 8 > - ); > - } > - // > - // Print mac address of the interface. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_MAC_ADDR_HEAD), mHiiHandle); > - > - IfConfig6PrintMacAddr ( > - IfCb->IfInfo->HwAddress.Addr, > - IfCb->IfInfo->HwAddressSize > - ); > - > - // > - // Print ip addresses list of the interface. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_IP_ADDR_HEAD), mHiiHandle); > - > - for (Index = 0; Index < IfCb->IfInfo->AddressInfoCount; Index++) { > - IfConfig6PrintIpAddr ( > - &IfCb->IfInfo->AddressInfo[Index].Address, > - &IfCb->IfInfo->AddressInfo[Index].PrefixLength > - ); > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); > - } > - > - // > - // Print dns server addresses list of the interface if has. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_DNS_ADDR_HEAD), mHiiHandle); > - > - for (Index = 0; Index < IfCb->DnsCnt; Index++) { > - IfConfig6PrintIpAddr ( > - &IfCb->DnsAddr[Index], > - NULL > - ); > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); > - } > - > - // > - // Print route table of the interface if has. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_ROUTE_HEAD), mHiiHandle); > - > - for (Index = 0; Index < IfCb->IfInfo->RouteCount; Index++) { > - IfConfig6PrintIpAddr ( > - &IfCb->IfInfo->RouteTable[Index].Destination, > - &IfCb->IfInfo->RouteTable[Index].PrefixLength > - ); > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_JOINT), mHiiHandle); > - > - IfConfig6PrintIpAddr ( > - &IfCb->IfInfo->RouteTable[Index].Gateway, > - NULL > - ); > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); > - } > - > - Entry = Entry->ForwardLink; > - } > - > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_INFO_BREAK), mHiiHandle); > - > - return Status; > -} > - > -/** > - The clean process of the IfConfig6 application. > - > - @param[in] IfList The pointer of IfList(interface list). > - > - @retval EFI_SUCCESS The IfConfig6 clean processed successfully. > - @retval others The IfConfig6 clean process failed. > - > -**/ > -EFI_STATUS > -IfConfig6ClearInterfaceInfo ( > - IN LIST_ENTRY *IfList > - ) > -{ > - EFI_STATUS Status; > - LIST_ENTRY *Entry; > - IFCONFIG6_INTERFACE_CB *IfCb; > - EFI_IP6_CONFIG_POLICY Policy; > - > - Policy = Ip6ConfigPolicyAutomatic; > - Entry = IfList->ForwardLink; > - Status = EFI_SUCCESS; > - > - if (IsListEmpty (IfList)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle); > - } > - > - // > - // Go through the interface list. > - // > - while (Entry != IfList) { > - > - IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link); > - > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypePolicy, > - sizeof (EFI_IP6_CONFIG_POLICY), > - &Policy > - ); > - > - if (EFI_ERROR (Status)) { > - break; > - } > - > - Entry = Entry->ForwardLink; > - } > - > - return Status; > -} > - > -/** > - The set process of the IfConfig6 application. > - > - @param[in] IfList The pointer of IfList(interface list). > - @param[in] VarArg The pointer of ARG_LIST(Args with "-s" option). > - > - @retval EFI_SUCCESS The IfConfig6 set processed successfully. > - @retval others The IfConfig6 set process failed. > - > -**/ > -EFI_STATUS > -IfConfig6SetInterfaceInfo ( > - IN LIST_ENTRY *IfList, > - IN ARG_LIST *VarArg > - ) > -{ > - EFI_STATUS Status; > - IFCONFIG6_INTERFACE_CB *IfCb; > - EFI_IP6_CONFIG_MANUAL_ADDRESS *CfgManAddr; > - EFI_IPv6_ADDRESS *CfgAddr; > - UINTN AddrSize; > - EFI_IP6_CONFIG_INTERFACE_ID *InterfaceId; > - UINT32 DadXmits; > - UINT32 CurDadXmits; > - UINTN CurDadXmitsLen; > - EFI_IP6_CONFIG_POLICY Policy; > - > - VAR_CHECK_CODE CheckCode; > - EFI_EVENT TimeOutEvt; > - EFI_EVENT MappedEvt; > - BOOLEAN IsAddressOk; > - > - UINTN DataSize; > - UINT32 Index; > - UINT32 Index2; > - BOOLEAN IsAddressSet; > - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; > - > - CfgManAddr = NULL; > - CfgAddr = NULL; > - TimeOutEvt = NULL; > - MappedEvt = NULL; > - IfInfo = NULL; > - InterfaceId = NULL; > - CurDadXmits = 0; > - > - if (IsListEmpty (IfList)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle); > - return EFI_INVALID_PARAMETER; > - } > - // > - // Make sure to set only one interface each time. > - // > - IfCb = BASE_CR (IfList->ForwardLink, IFCONFIG6_INTERFACE_CB, Link); > - Status = EFI_SUCCESS; > - > - // > - // Initialize check list mechanism. > - // > - CheckCode = IfConfig6RetriveCheckListByName( > - NULL, > - NULL, > - TRUE > - ); > - > - // > - // Create events & timers for asynchronous settings. > - // > - Status = gBS->CreateEvent ( > - EVT_TIMER, > - TPL_CALLBACK, > - NULL, > - NULL, > - &TimeOutEvt > - ); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - Status = gBS->CreateEvent ( > - EVT_NOTIFY_SIGNAL, > - TPL_NOTIFY, > - IfConfig6ManualAddressNotify, > - &IsAddressOk, > - &MappedEvt > - ); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - // > - // Parse the setting variables. > - // > - while (VarArg != NULL) { > - // > - // Check invalid parameters (duplication & unknown & conflict). > - // > - CheckCode = IfConfig6RetriveCheckListByName( > - mSetCheckList, > - VarArg->Arg, > - FALSE > - ); > - > - if (VarCheckOk != CheckCode) { > - switch (CheckCode) { > - case VarCheckDuplicate: > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_DUPLICATE_COMMAND), mHiiHandle, VarArg->Arg); > - break; > - > - case VarCheckConflict: > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_CONFLICT_COMMAND), mHiiHandle, VarArg->Arg); > - break; > - > - case VarCheckUnknown: > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_UNKNOWN_COMMAND), mHiiHandle, VarArg->Arg); > - break; > - > - default: > - break; > - } > - > - VarArg = VarArg->Next; > - continue; > - } > - // > - // Process valid variables. > - // > - if (StrCmp(VarArg->Arg, L"auto") == 0) { > - // > - // Set automaic config policy > - // > - Policy = Ip6ConfigPolicyAutomatic; > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypePolicy, > - sizeof (EFI_IP6_CONFIG_POLICY), > - &Policy > - ); > - > - if (EFI_ERROR(Status)) { > - goto ON_EXIT; > - } > - > - VarArg= VarArg->Next; > - > - } else if (StrCmp (VarArg->Arg, L"man") == 0) { > - // > - // Set manual config policy. > - // > - Policy = Ip6ConfigPolicyManual; > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypePolicy, > - sizeof (EFI_IP6_CONFIG_POLICY), > - &Policy > - ); > - > - if (EFI_ERROR(Status)) { > - goto ON_EXIT; > - } > - > - VarArg= VarArg->Next; > - > - } else if (StrCmp (VarArg->Arg, L"host") == 0) { > - // > - // Parse till the next tag or the end of command line. > - // > - VarArg = VarArg->Next; > - Status = IfConfig6ParseManualAddressList ( > - &VarArg, > - &CfgManAddr, > - &AddrSize > - ); > - > - if (EFI_ERROR (Status)) { > - if (Status == EFI_INVALID_PARAMETER) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"host"); > - continue; > - } else { > - goto ON_EXIT; > - } > - } > - // > - // Set static host ip6 address list. > - // This is a asynchronous process. > - // > - IsAddressOk = FALSE; > - > - Status = IfCb->IfCfg->RegisterDataNotify ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeManualAddress, > - MappedEvt > - ); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeManualAddress, > - AddrSize, > - CfgManAddr > - ); > - > - if (Status == EFI_NOT_READY) { > - // > - // Get current dad transmits count. > - // > - CurDadXmitsLen = sizeof > (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS); > - IfCb->IfCfg->GetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeDupAddrDetectTransmits, > - &CurDadXmitsLen, > - &CurDadXmits > - ); > - > - gBS->SetTimer (TimeOutEvt, TimerRelative, 50000000 + 10000000 * > CurDadXmits); > - > - while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) { > - if (IsAddressOk) { > - Status = EFI_SUCCESS; > - break; > - } > - } > - } > - > - IfCb->IfCfg->UnregisterDataNotify ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeManualAddress, > - MappedEvt > - ); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_MAN_HOST), mHiiHandle, Status); > - goto ON_EXIT; > - } > - > - // > - // Check whether the address is set successfully. > - // > - DataSize = 0; > - > - Status = IfCb->IfCfg->GetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeInterfaceInfo, > - &DataSize, > - NULL > - ); > - > - if (Status != EFI_BUFFER_TOO_SMALL) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_EXIT; > - } > - > - IfInfo = AllocateZeroPool (DataSize); > - > - if (IfInfo == NULL) { > - Status = EFI_OUT_OF_RESOURCES; > - goto ON_EXIT; > - } > - > - Status = IfCb->IfCfg->GetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeInterfaceInfo, > - &DataSize, > - IfInfo > - ); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_EXIT; > - } > - > - for ( Index = 0; Index < (UINTN) (AddrSize / sizeof > (EFI_IP6_CONFIG_MANUAL_ADDRESS)); Index++) { > - IsAddressSet = FALSE; > - // > - // By default, the prefix length 0 is regarded as 64. > - // > - if (CfgManAddr[Index].PrefixLength == 0) { > - CfgManAddr[Index].PrefixLength = 64; > - } > - > - for (Index2 = 0; Index2 < IfInfo->AddressInfoCount; Index2++) { > - if (EFI_IP6_EQUAL (&IfInfo->AddressInfo[Index2].Address, > &CfgManAddr[Index].Address) && > - (IfInfo->AddressInfo[Index2].PrefixLength == > CfgManAddr[Index].PrefixLength)) { > - IsAddressSet = TRUE; > - break; > - } > - } > - > - if (!IsAddressSet) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_ADDRESS_FAILED), mHiiHandle); > - IfConfig6PrintIpAddr ( > - &CfgManAddr[Index].Address, > - &CfgManAddr[Index].PrefixLength > - ); > - } > - } > - > - } else if (StrCmp (VarArg->Arg, L"gw") == 0) { > - // > - // Parse till the next tag or the end of command line. > - // > - VarArg = VarArg->Next; > - Status = IfConfig6ParseGwDnsAddressList ( > - &VarArg, > - &CfgAddr, > - &AddrSize > - ); > - > - if (EFI_ERROR (Status)) { > - if (Status == EFI_INVALID_PARAMETER) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"gw"); > - continue; > - } else { > - goto ON_EXIT; > - } > - } > - // > - // Set static gateway ip6 address list. > - // > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeGateway, > - AddrSize, > - CfgAddr > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - } else if (StrCmp (VarArg->Arg, L"dns") == 0) { > - // > - // Parse till the next tag or the end of command line. > - // > - VarArg = VarArg->Next; > - Status = IfConfig6ParseGwDnsAddressList ( > - &VarArg, > - &CfgAddr, > - &AddrSize > - ); > - > - if (EFI_ERROR (Status)) { > - if (Status == EFI_INVALID_PARAMETER) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"dns"); > - continue; > - } else { > - goto ON_EXIT; > - } > - } > - // > - // Set static dhs server ip6 address list. > - // > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeDnsServer, > - AddrSize, > - CfgAddr > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - } else if (StrCmp (VarArg->Arg, L"id") == 0) { > - // > - // Parse till the next tag or the end of command line. > - // > - VarArg = VarArg->Next; > - Status = IfConfig6ParseInterfaceId (&VarArg, &InterfaceId); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - // > - // Set alternative interface id. > - // > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeAltInterfaceId, > - sizeof (EFI_IP6_CONFIG_INTERFACE_ID), > - InterfaceId > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - } else if (StrCmp (VarArg->Arg, L"dad") == 0) { > - // > - // Parse till the next tag or the end of command line. > - // > - VarArg = VarArg->Next; > - Status = IfConfig6ParseDadXmits (&VarArg, &DadXmits); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - // > - // Set dad transmits count. > - // > - Status = IfCb->IfCfg->SetData ( > - IfCb->IfCfg, > - Ip6ConfigDataTypeDupAddrDetectTransmits, > - sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS), > - &DadXmits > - ); > - > - if (EFI_ERROR(Status)) { > - goto ON_EXIT; > - } > - } > - } > - > -ON_EXIT: > - > - if (CfgManAddr != NULL) { > - FreePool (CfgManAddr); > - } > - > - if (CfgAddr != NULL) { > - FreePool (CfgAddr); > - } > - > - if (MappedEvt != NULL) { > - gBS->CloseEvent (MappedEvt); > - } > - > - if (TimeOutEvt != NULL) { > - gBS->CloseEvent (TimeOutEvt); > - } > - > - if (IfInfo != NULL) { > - FreePool (IfInfo); > - } > - > - return Status; > - > -} > - > -/** > - The IfConfig6 main process. > - > - @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA. > - > - @retval EFI_SUCCESS IfConfig6 processed successfully. > - @retval others The IfConfig6 process failed. > - > -**/ > -EFI_STATUS > -IfConfig6 ( > - IN IFCONFIG6_PRIVATE_DATA *Private > - ) > -{ > - EFI_STATUS Status; > - > - // > - // Get configure information of all interfaces. > - // > - Status = IfConfig6GetInterfaceInfo ( > - Private->ImageHandle, > - Private->IfName, > - &Private->IfList > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - switch (Private->OpCode) { > - case IfConfig6OpList: > - Status = IfConfig6ShowInterfaceInfo (&Private->IfList); > - break; > - > - case IfConfig6OpClear: > - Status = IfConfig6ClearInterfaceInfo (&Private->IfList); > - break; > - > - case IfConfig6OpSet: > - Status = IfConfig6SetInterfaceInfo (&Private->IfList, Private->VarArg); > - break; > - > - default: > - Status = EFI_ABORTED; > - } > - > -ON_EXIT: > - > - return Status; > -} > - > -/** > - The IfConfig6 cleanup process, free the allocated memory. > - > - @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA. > - > -**/ > -VOID > -IfConfig6Cleanup ( > - IN IFCONFIG6_PRIVATE_DATA *Private > - ) > -{ > - LIST_ENTRY *Entry; > - LIST_ENTRY *NextEntry; > - IFCONFIG6_INTERFACE_CB *IfCb; > - ARG_LIST *ArgNode; > - ARG_LIST *ArgHead; > - > - ASSERT (Private != NULL); > - > - // > - // Clean the list which save the set config Args. > - // > - if (Private->VarArg != NULL) { > - ArgHead = Private->VarArg; > - > - while (ArgHead->Next != NULL) { > - ArgNode = ArgHead->Next; > - FreePool (ArgHead); > - ArgHead = ArgNode; > - } > - > - FreePool (ArgHead); > - } > - > - if (Private->IfName != NULL) > - FreePool (Private->IfName); > - > - > - // > - // Clean the IFCONFIG6_INTERFACE_CB list. > - // > - Entry = Private->IfList.ForwardLink; > - NextEntry = Entry->ForwardLink; > - > - while (Entry != &Private->IfList) { > - > - IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link); > - > - RemoveEntryList (&IfCb->Link); > - > - if (IfCb->IfId != NULL) { > - > - FreePool (IfCb->IfId); > - } > - > - if (IfCb->IfInfo != NULL) { > - > - FreePool (IfCb->IfInfo); > - } > - > - FreePool (IfCb); > - > - Entry = NextEntry; > - NextEntry = Entry->ForwardLink; > - } > - > - FreePool (Private); > -} > - > -/** > - This is the declaration of an EFI image entry point. This entry point is > - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, > including > - both device drivers and bus drivers. > - > - The entry point for the IfConfig6 application which parses the command > line input and calls the IfConfig6 process. > - > - @param[in] ImageHandle The image handle of this application. > - @param[in] SystemTable The pointer to the EFI System Table. > - > - @retval EFI_SUCCESS The operation completed successfully. > - @retval Others Some errors occur. > - > -**/ > -EFI_STATUS > -EFIAPI > -IfConfig6Initialize ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE *SystemTable > - ) > -{ > - EFI_STATUS Status; > - IFCONFIG6_PRIVATE_DATA *Private; > - EFI_HII_PACKAGE_LIST_HEADER *PackageList; > - LIST_ENTRY *ParamPackage; > - CONST CHAR16 *ValueStr; > - ARG_LIST *ArgList; > - CHAR16 *ProblemParam; > - CHAR16 *Str; > - > - Private = NULL; > - > - // > - // Retrieve HII package list from ImageHandle > - // > - Status = gBS->OpenProtocol ( > - ImageHandle, > - &gEfiHiiPackageListProtocolGuid, > - (VOID **) &PackageList, > - ImageHandle, > - NULL, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL > - ); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - // > - // Publish HII package list to HII Database. > - // > - Status = gHiiDatabase->NewPackageList ( > - gHiiDatabase, > - PackageList, > - NULL, > - &mHiiHandle > - ); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - ASSERT (mHiiHandle != NULL); > - > - Status = ShellCommandLineParseEx (mIfConfig6CheckList, &ParamPackage, > &ProblemParam, TRUE, FALSE); > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_INVALID_COMMAND), mHiiHandle, ProblemParam); > - goto ON_EXIT; > - } > - > - // > - // To handle no option. > - // > - if (!ShellCommandLineGetFlag (ParamPackage, L"-r") > && !ShellCommandLineGetFlag (ParamPackage, L"-s") && > - !ShellCommandLineGetFlag (ParamPackage, L"-l")) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_LACK_OPTION), mHiiHandle); > - goto ON_EXIT; > - } > - // > - // To handle conflict options. > - // > - if (((ShellCommandLineGetFlag (ParamPackage, L"-r")) && > (ShellCommandLineGetFlag (ParamPackage, L"-s"))) || > - ((ShellCommandLineGetFlag (ParamPackage, L"-r")) && > (ShellCommandLineGetFlag (ParamPackage, L"-l"))) || > - ((ShellCommandLineGetFlag (ParamPackage, L"-s")) && > (ShellCommandLineGetFlag (ParamPackage, L"-l")))) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_CONFLICT_OPTIONS), mHiiHandle); > - goto ON_EXIT; > - } > - > - Status = EFI_INVALID_PARAMETER; > - > - Private = AllocateZeroPool (sizeof (IFCONFIG6_PRIVATE_DATA)); > - > - if (Private == NULL) { > - Status = EFI_OUT_OF_RESOURCES; > - goto ON_EXIT; > - } > - > - InitializeListHead (&Private->IfList); > - > - // > - // To get interface name for the list option. > - // > - if (ShellCommandLineGetFlag (ParamPackage, L"-l")) { > - Private->OpCode = IfConfig6OpList; > - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l"); > - if (ValueStr != NULL) { > - Str = AllocateCopyPool (StrSize (ValueStr), ValueStr); > - ASSERT (Str != NULL); > - Private->IfName = Str; > - } > - } > - // > - // To get interface name for the clear option. > - // > - if (ShellCommandLineGetFlag (ParamPackage, L"-r")) { > - Private->OpCode = IfConfig6OpClear; > - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-r"); > - if (ValueStr != NULL) { > - Str = AllocateCopyPool (StrSize (ValueStr), ValueStr); > - ASSERT (Str != NULL); > - Private->IfName = Str; > - } > - } > - // > - // To get interface name and corresponding Args for the set option. > - // > - if (ShellCommandLineGetFlag (ParamPackage, L"-s")) { > - > - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s"); > - if (ValueStr == NULL) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_LACK_INTERFACE), mHiiHandle); > - goto ON_EXIT; > - } > - // > - // To split the configuration into multi-section. > - // > - ArgList = SplitStrToList (ValueStr, L' '); > - ASSERT (ArgList != NULL); > - > - Private->OpCode = IfConfig6OpSet; > - Private->IfName = ArgList->Arg; > - > - Private->VarArg = ArgList->Next; > - > - if (Private->IfName == NULL || Private->VarArg == NULL) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG6_ERR_LACK_COMMAND), mHiiHandle); > - goto ON_EXIT; > - } > - } > - // > - // Main process of ifconfig6. > - // > - Status = IfConfig6 (Private); > - > -ON_EXIT: > - > - ShellCommandLineFreeVarList (ParamPackage); > - HiiRemovePackages (mHiiHandle); > - if (Private != NULL) > - IfConfig6Cleanup (Private); > - > - return Status; > -} > - > diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.h > b/NetworkPkg/Application/IfConfig6/IfConfig6.h > deleted file mode 100644 > index f74897108d..0000000000 > --- a/NetworkPkg/Application/IfConfig6/IfConfig6.h > +++ /dev/null > @@ -1,79 +0,0 @@ > -/** @file > - The interface function declaration of shell application IfConfig6. > - > - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#ifndef _IFCONFIG6_H_ > -#define _IFCONFIG6_H_ > - > -enum { > - IfConfig6OpList = 1, > - IfConfig6OpSet = 2, > - IfConfig6OpClear = 3 > -}; > - > -typedef enum { > - VarCheckReserved = -1, > - VarCheckOk = 0, > - VarCheckDuplicate, > - VarCheckConflict, > - VarCheckUnknown, > - VarCheckLackValue, > - VarCheckOutOfMem > -} VAR_CHECK_CODE; > - > -typedef enum { > - FlagTypeSingle = 0, > - FlagTypeNeedVar, > - FlagTypeNeedSet, > - FlagTypeSkipUnknown > -} VAR_CHECK_FLAG_TYPE; > - > -#define MACADDRMAXSIZE 32 > -#define PREFIXMAXLEN 16 > - > -typedef struct _IFCONFIG6_INTERFACE_CB { > - EFI_HANDLE NicHandle; > - LIST_ENTRY Link; > - EFI_IP6_CONFIG_PROTOCOL *IfCfg; > - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; > - EFI_IP6_CONFIG_INTERFACE_ID *IfId; > - EFI_IP6_CONFIG_POLICY Policy; > - EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS Xmits; > - UINT32 DnsCnt; > - EFI_IPv6_ADDRESS DnsAddr[1]; > -} IFCONFIG6_INTERFACE_CB; > - > -typedef struct _ARG_LIST ARG_LIST; > - > -struct _ARG_LIST { > - ARG_LIST *Next; > - CHAR16 *Arg; > -}; > - > -typedef struct _IFCONFIG6_PRIVATE_DATA { > - EFI_HANDLE ImageHandle; > - LIST_ENTRY IfList; > - > - UINT32 OpCode; > - CHAR16 *IfName; > - ARG_LIST *VarArg; > -} IFCONFIG6_PRIVATE_DATA; > - > -typedef struct _VAR_CHECK_ITEM{ > - CHAR16 *FlagStr; > - UINT32 FlagID; > - UINT32 ConflictMask; > - VAR_CHECK_FLAG_TYPE FlagType; > -} VAR_CHECK_ITEM; > -#endif > diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.inf > b/NetworkPkg/Application/IfConfig6/IfConfig6.inf > deleted file mode 100644 > index 519b7c3279..0000000000 > --- a/NetworkPkg/Application/IfConfig6/IfConfig6.inf > +++ /dev/null > @@ -1,67 +0,0 @@ > -## @file > -# Shell application IfConfig6. > -# > -# It is shell application which is used to set and get configurations for the > -# EFI IPv6 network stack. > -# > -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > -# > -# This program and the accompanying materials > -# are licensed and made available under the terms and conditions of the > BSD License > -# which accompanies this distribution. The full text of the license may be > found at > -# http://opensource.org/licenses/bsd-license.php. > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -# > -## > - > -[Defines] > - INF_VERSION = 0x00010006 > - BASE_NAME = IfConfig6 > - FILE_GUID = 6F71926E-60CE-428d-AA58-A3D9FB879429 > - MODULE_TYPE = UEFI_APPLICATION > - VERSION_STRING = 1.0 > - ENTRY_POINT = IfConfig6Initialize > - MODULE_UNI_FILE = IfConfig6.uni > - > -# > -# > -# This flag specifies whether HII resource section is generated into PE image. > -# > - UEFI_HII_RESOURCE_SECTION = TRUE > - > -# > -# The following information is for reference only and not required by the > build tools. > -# > -# VALID_ARCHITECTURES = IA32 X64 IPF > -# > -[Sources] > - IfConfig6Strings.uni > - IfConfig6.c > - IfConfig6.h > - > -[Packages] > - MdePkg/MdePkg.dec > - MdeModulePkg/MdeModulePkg.dec > - ShellPkg/ShellPkg.dec > - > -[LibraryClasses] > - BaseLib > - UefiBootServicesTableLib > - UefiApplicationEntryPoint > - UefiHiiServicesLib > - BaseMemoryLib > - ShellLib > - MemoryAllocationLib > - DebugLib > - HiiLib > - NetLib > - > -[Protocols] > - gEfiIp6ServiceBindingProtocolGuid ## CONSUMES > - gEfiIp6ConfigProtocolGuid ## CONSUMES > - gEfiHiiPackageListProtocolGuid ## CONSUMES > - > -[UserExtensions.TianoCore."ExtraFiles"] > - IfConfig6Extra.uni > diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.uni > b/NetworkPkg/Application/IfConfig6/IfConfig6.uni > deleted file mode 100644 > index e0ea589771..0000000000 > --- a/NetworkPkg/Application/IfConfig6/IfConfig6.uni > +++ /dev/null > @@ -1,23 +0,0 @@ > -// /** @file > -// Shell application IfConfig6. > -// > -// It is shell application which is used to set and get configurations for the > -// EFI IPv6 network stack. > -// > -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> > -// > -// This program and the accompanying materials > -// are licensed and made available under the terms and conditions of the > BSD License > -// which accompanies this distribution. The full text of the license may be > found at > -// http://opensource.org/licenses/bsd-license.php. > -// > -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -// > -// **/ > - > - > -#string STR_MODULE_ABSTRACT #language en-US "Shell application > IfConfig6" > - > -#string STR_MODULE_DESCRIPTION #language en-US "It is shell > application which is used to set and get configurations for the EFI IPv6 > network stack." > - > diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni > b/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni > deleted file mode 100644 > index 7d3f27a073..0000000000 > --- a/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni > +++ /dev/null > @@ -1,20 +0,0 @@ > -// /** @file > -// IfConfig6 Localized Strings and Content > -// > -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR> > -// > -// This program and the accompanying materials > -// are licensed and made available under the terms and conditions of the > BSD License > -// which accompanies this distribution. The full text of the license may be > found at > -// http://opensource.org/licenses/bsd-license.php. > -// > -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -// > -// **/ > - > -#string STR_PROPERTIES_MODULE_NAME > -#language en-US > -"IfConfig6 App" > - > - > diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni > b/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni > deleted file mode 100644 > index 0c10bbdf78..0000000000 > --- a/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni > +++ /dev/null > @@ -1,92 +0,0 @@ > -/** @file > - String definitions for the Shell application IfConfig6. > - > - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions > - of the BSD License which accompanies this distribution. The full > - text of the license may be found at<BR> > - http://opensource.org/licenses/bsd-license.php > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#langdef en-US "English" > - > -#string STR_IFCONFIG6_ERR_IP6CFG_GETDATA #language en-US > "Ip6Config->GetData return %hr\n" > -#string STR_IFCONFIG6_INFO_BREAK #language en-US "------------- > ----------------------------------------------------" > -#string STR_IFCONFIG6_INFO_COLON #language en-US ":" > -#string STR_IFCONFIG6_INFO_JOINT #language en-US " >> " > -#string STR_IFCONFIG6_INFO_NEWLINE #language en-US "\n" > -#string STR_IFCONFIG6_INFO_IF_NAME #language en-US > "\n%Hname : %s%N\n" > -#string STR_IFCONFIG6_INFO_POLICY_AUTO #language en-US > "%Hpolicy : automatic%N\n" > -#string STR_IFCONFIG6_INFO_POLICY_MAN #language en-US > "%Hpolicy : manual%N\n" > -#string STR_IFCONFIG6_INFO_DAD_TRANSMITS #language en-US > "%Hdad xmits : %d%N\n" > -#string STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD #language en-US > "%Hinterface id : %N" > -#string STR_IFCONFIG6_INFO_MAC_ADDR_HEAD #language en-US > "%Hmac addr : %N" > -#string STR_IFCONFIG6_INFO_MAC_ADDR_BODY #language en-US > "%02x" > -#string STR_IFCONFIG6_INFO_IP_ADDR_HEAD #language en-US > "\n%Hhost addr : %N\n" > -#string STR_IFCONFIG6_INFO_DNS_ADDR_HEAD #language en-US > "\n%Hdns server : %N\n" > -#string STR_IFCONFIG6_INFO_IP_ADDR_BODY #language en-US > "%02x" > -#string STR_IFCONFIG6_INFO_IP_ADDR_BODY4BIT #language en-US > "%x" > -#string STR_IFCONFIG6_INFO_ROUTE_HEAD #language en-US > "\n%Hroute table : %N\n" > -#string STR_IFCONFIG6_INFO_PREFIX_LEN #language en-US "/%d" > - > -#string STR_IFCONFIG6_LINE_HELP #language en-US "Displays or > modifies the IPv6 configuration" > -#string STR_IFCONFIG6_ERR_LACK_INTERFACE #language en-US "Lack > interface name.\n" > - "Usage: IfConfig6 -s {ifname} {config > options ...}\n" > - "Example: IfConfig6 -s eth0 auto\n" > -#string STR_IFCONFIG6_LACK_OPTION #language en-US "Flags lack. > Please type 'IfConfig6 -?' for help info.\n" > -#string STR_IFCONFIG6_CONFLICT_OPTIONS #language en-US "Flags > conflict. Please type 'IfConfig6 -?' for help info.\n" > -#string STR_IFCONFIG6_ERR_LACK_COMMAND #language en-US > "Lack interface config option.\n" > - "Usage: IfConfig6 -s {ifname} {config > options ...}\n" > - "Example: IfConfig6 -s eth0 auto\n" > -#string STR_IFCONFIG6_ERR_INVALID_INTERFACE #language en-US > "Invalid interface name.\n" > - "Hint: Use {IfConfig6 -l} to check existing > interface names.\n" > -#string STR_IFCONFIG6_ERR_INVALID_COMMAND #language en-US > "Invalid command. Bad command %H%s%N is skipped.\n" > - "Hint: Incorrect option or arguments. > Please type 'IfConfig6 -?' for help info.\n" > -#string STR_IFCONFIG6_ERR_LACK_ARGUMENTS #language en-US > "Lack arguments. Bad command %H%s%N is skipped.\n" > - "Hint: Please type 'IfConfig6 -?' for help > info.\n" > -#string STR_IFCONFIG6_ERR_LACK_OPTION #language en-US "Lack > options.\n" > - "Hint: Please type 'IfConfig6 -?' for help > info.\n" > -#string STR_IFCONFIG6_ERR_MAN_HOST #language en-US "Manual > address configuration failed. Please retry.\n" > -#string STR_IFCONFIG6_ERR_DUPLICATE_COMMAND #language en-US > "Duplicate commands. Bad command %H%s%N is skipped.\n" > - "Hint: Please type 'IfConfig6 -?' for help > info.\n" > -#string STR_IFCONFIG6_ERR_CONFLICT_COMMAND #language en-US > "Conflict commands. Bad command %H%s%N is skipped.\n" > - "Hint: Please type 'IfConfig6 -?' for help > info.\n" > -#string STR_IFCONFIG6_ERR_UNKNOWN_COMMAND #language en-US > "Unknown commands. Bad command %H%s%N is skipped.\n" > - "Hint: Please type 'IfConfig6 -?' for help > info.\n" > -#string STR_IFCONFIG6_ERR_ADDRESS_FAILED #language en-US "It > failed to set .\n" > -#string STR_IFCONFIG6_INVALID_IP #language en-US "%IfConfig6: > Invalid IP6 address, %s\n" > - > -#string STR_IFCONFIG6_HELP #language en-US "" > -".TH IfConfig6 0 "Displays or modifies IPv6 configuration for network > interface."\r\n" > -".SH NAME\r\n" > -"Displays or modifies IPv6 configuration for network interface.\r\n" > -".SH SYNOPSIS\r\n" > -" \r\n" > -"IfConfig6 [-b] [-r {ifname}] [-l {ifname}] [-s {ifname} {command ...}] [- > ?]\r\n" > -".SH OPTIONS\r\n" > -" \r\n" > -" -b (break) enable page break.\r\n" > -" -r (renew) renew configuration of interface and set automatic policy.\r\n" > -" -l (list) list the configuration of interface.\r\n" > -" -s (set) set configuration of interface as follows.\r\n" > -" |man/auto manual or automatic policy\r\n" > -" |id {mac} alternative interface id.\r\n" > -" |dad {num} dad transmits count.\r\n" > -" |host{ip} static host ip address, must under manual policy.\r\n" > -" |gw {ip} gateway ip address, must under manual policy.\r\n" > -" |dns {ip} dns server ip address, must under manual policy.\r\n" > -".SH EXAMPLES\r\n" > -" \r\n" > -"Examples:\r\n" > -" IfConfig6 -l\r\n" > -" IfConfig6 -b -l\r\n" > -" IfConfig6 -r eth0\r\n" > -" IfConfig6 -s eth0 auto dad 10\r\n" > -" IfConfig6 -s eth0 man id ff:dd:aa:88:66:cc\r\n" > -" IfConfig6 -s eth1 man host 2002::1/64 2002::2/64 gw 2002::3\r\n" > diff --git a/NetworkPkg/Application/Ping6/Ia32/Tsc.c > b/NetworkPkg/Application/Ping6/Ia32/Tsc.c > deleted file mode 100644 > index e2eae99077..0000000000 > --- a/NetworkPkg/Application/Ping6/Ia32/Tsc.c > +++ /dev/null > @@ -1,28 +0,0 @@ > -/** @file > - The implement to read TSC in IA32 platform. > - > - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#include <Library/BaseLib.h> > - > -/** > - Reads and returns the current value of the Time Stamp Counter (TSC). > - > - @return The current value of TSC. > - > -**/ > -UINT64 > -ReadTime () > -{ > - return AsmReadTsc (); > -} > diff --git a/NetworkPkg/Application/Ping6/Ipf/Itc.c > b/NetworkPkg/Application/Ping6/Ipf/Itc.c > deleted file mode 100644 > index 131e5c0e30..0000000000 > --- a/NetworkPkg/Application/Ping6/Ipf/Itc.c > +++ /dev/null > @@ -1,28 +0,0 @@ > -/** @file > - The implement to read ITC in IA64 platform. > - > - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#include <Library/BaseLib.h> > - > -/** > - Reads and returns the current value of the Interval Timer Counter Register > (ITC). > - > - @return The current value of ITC. > - > -**/ > -UINT64 > -ReadTime () > -{ > - return AsmReadItc (); > -} > diff --git a/NetworkPkg/Application/Ping6/Ping6.c > b/NetworkPkg/Application/Ping6/Ping6.c > deleted file mode 100644 > index 66daac27be..0000000000 > --- a/NetworkPkg/Application/Ping6/Ping6.c > +++ /dev/null > @@ -1,1200 +0,0 @@ > -/** @file > - The implementation for Ping6 application. > - > - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#include <Library/ShellLib.h> > -#include <Library/BaseMemoryLib.h> > -#include <Library/BaseLib.h> > -#include <Library/MemoryAllocationLib.h> > -#include <Library/DebugLib.h> > -#include <Library/UefiBootServicesTableLib.h> > -#include <Library/UefiHiiServicesLib.h> > -#include <Library/HiiLib.h> > -#include <Library/NetLib.h> > - > -#include <Protocol/Cpu.h> > -#include <Protocol/ServiceBinding.h> > -#include <Protocol/Ip6.h> > -#include <Protocol/Ip6Config.h> > - > -#include "Ping6.h" > - > -// > -// String token ID of Ping6 command help message text. > -// > -GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID > mStringPing6HelpToken = STRING_TOKEN (STR_PING6_HELP); > - > -SHELL_PARAM_ITEM Ping6ParamList[] = { > - { > - L"-l", > - TypeValue > - }, > - { > - L"-n", > - TypeValue > - }, > - { > - L"-s", > - TypeValue > - }, > - { > - NULL, > - TypeMax > - }, > -}; > - > -// > -// Global Variables in Ping6 application. > -// > -EFI_HII_HANDLE mHiiHandle; > -CONST CHAR16 *mIp6DstString; > -CONST CHAR16 *mIp6SrcString; > -UINT64 mFrequency = 0; > -/** > - Get and calculate the frequency in tick/ms. > - The result is saved in the globle variable mFrequency > - > - @retval EFI_SUCCESS Calculated the frequency successfully. > - @retval Others Failed to calculate the frequency. > - > -**/ > -EFI_STATUS > -Ping6GetFrequency ( > - VOID > - ) > -{ > - EFI_STATUS Status; > - EFI_CPU_ARCH_PROTOCOL *Cpu; > - UINT64 CurrentTick; > - UINT64 TimerPeriod; > - > - Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) > &Cpu); > - > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - Status = Cpu->GetTimerValue (Cpu, 0, &CurrentTick, &TimerPeriod); > - > - if (EFI_ERROR (Status)) { > - // > - // For NT32 Simulator only. 358049 is a similar value to keep timer > granularity. > - // Set the timer period by ourselves. > - // > - TimerPeriod = (UINT64) NTTIMERPERIOD; > - } > - // > - // The timer period is in femtosecond (1 femtosecond is 1e-15 second). > - // So 1e+12 is divided by timer period to produce the freq in tick/ms. > - // > - mFrequency = DivU64x64Remainder (1000000000000ULL, TimerPeriod, > NULL); > - > - return EFI_SUCCESS; > -} > - > -/** > - Get and calculate the duration in ms. > - > - @param[in] Begin The start point of time. > - @param[in] End The end point of time. > - > - @return The duration in ms. > - > -**/ > -UINT64 > -Ping6CalculateTick ( > - IN UINT64 Begin, > - IN UINT64 End > - ) > -{ > - ASSERT (End > Begin); > - return DivU64x64Remainder (End - Begin, mFrequency, NULL); > -} > - > -/** > - Destroy IPING6_ICMP6_TX_INFO, and recollect the memory. > - > - @param[in] TxInfo The pointer to PING6_ICMP6_TX_INFO. > - > -**/ > -VOID > -Ping6DestroyTxInfo ( > - IN PING6_ICMP6_TX_INFO *TxInfo > - ) > -{ > - EFI_IP6_TRANSMIT_DATA *TxData; > - EFI_IP6_FRAGMENT_DATA *FragData; > - UINTN Index; > - > - ASSERT (TxInfo != NULL); > - > - if (TxInfo->Token != NULL) { > - > - if (TxInfo->Token->Event != NULL) { > - gBS->CloseEvent (TxInfo->Token->Event); > - } > - > - TxData = TxInfo->Token->Packet.TxData; > - if (TxData != NULL) { > - > - if (TxData->OverrideData != NULL) { > - FreePool (TxData->OverrideData); > - } > - > - if (TxData->ExtHdrs != NULL) { > - FreePool (TxData->ExtHdrs); > - } > - > - for (Index = 0; Index < TxData->FragmentCount; Index++) { > - FragData = TxData->FragmentTable[Index].FragmentBuffer; > - if (FragData != NULL) { > - FreePool (FragData); > - } > - } > - } > - > - FreePool (TxInfo->Token); > - } > - > - FreePool (TxInfo); > -} > - > -/** > - Match the request, and reply with SequenceNum/TimeStamp. > - > - @param[in] Private The pointer to PING6_PRIVATE_DATA. > - @param[in] Packet The pointer to ICMP6_ECHO_REQUEST_REPLY. > - > - @retval EFI_SUCCESS The match is successful. > - @retval EFI_NOT_FOUND The reply can't be matched with any request. > - > -**/ > -EFI_STATUS > -Ping6MatchEchoReply ( > - IN PING6_PRIVATE_DATA *Private, > - IN ICMP6_ECHO_REQUEST_REPLY *Packet > - ) > -{ > - PING6_ICMP6_TX_INFO *TxInfo; > - LIST_ENTRY *Entry; > - LIST_ENTRY *NextEntry; > - > - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) { > - TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link); > - > - if ((TxInfo->SequenceNum == Packet->SequenceNum) && (TxInfo- > >TimeStamp == Packet->TimeStamp)) { > - Private->RxCount++; > - RemoveEntryList (&TxInfo->Link); > - Ping6DestroyTxInfo (TxInfo); > - return EFI_SUCCESS; > - } > - } > - > - return EFI_NOT_FOUND; > -} > - > -/** > - The original intention is to send a request. > - Currently, the application retransmits an icmp6 echo request packet > - per second in sendnumber times that is specified by the user. > - Because nothing can be done here, all things move to the timer rountine. > - > - @param[in] Event A EFI_EVENT type event. > - @param[in] Context The pointer to Context. > - > -**/ > -VOID > -EFIAPI > -Ping6OnEchoRequestSent ( > - IN EFI_EVENT Event, > - IN VOID *Context > - ) > -{ > -} > - > -/** > - receive reply, match and print reply infomation. > - > - @param[in] Event A EFI_EVENT type event. > - @param[in] Context The pointer to context. > - > -**/ > -VOID > -EFIAPI > -Ping6OnEchoReplyReceived ( > - IN EFI_EVENT Event, > - IN VOID *Context > - ) > -{ > - EFI_STATUS Status; > - PING6_PRIVATE_DATA *Private; > - EFI_IP6_COMPLETION_TOKEN *RxToken; > - EFI_IP6_RECEIVE_DATA *RxData; > - ICMP6_ECHO_REQUEST_REPLY *Reply; > - UINT32 PayLoad; > - UINT64 Rtt; > - CHAR8 Near; > - > - Private = (PING6_PRIVATE_DATA *) Context; > - > - if (Private->Status == EFI_ABORTED) { > - return; > - } > - > - RxToken = &Private->RxToken; > - RxData = RxToken->Packet.RxData; > - Reply = RxData->FragmentTable[0].FragmentBuffer; > - PayLoad = RxData->DataLength; > - > - if (RxData->Header->NextHeader != IP6_ICMP) { > - goto ON_EXIT; > - } > - > - if (!IP6_IS_MULTICAST (&Private->DstAddress) && > - !EFI_IP6_EQUAL (&RxData->Header->SourceAddress, &Private- > >DstAddress)) { > - goto ON_EXIT; > - } > - > - if ((Reply->Type != ICMP_V6_ECHO_REPLY) || (Reply->Code != 0)) { > - goto ON_EXIT; > - } > - > - if (PayLoad != Private->BufferSize) { > - goto ON_EXIT; > - } > - // > - // Check whether the reply matches the sent request before. > - // > - Status = Ping6MatchEchoReply (Private, Reply); > - if (EFI_ERROR(Status)) { > - goto ON_EXIT; > - } > - // > - // Display statistics on this icmp6 echo reply packet. > - // > - Rtt = Ping6CalculateTick (Reply->TimeStamp, ReadTime ()); > - if (Rtt != 0) { > - Near = (CHAR8) '='; > - } else { > - Near = (CHAR8) '<'; > - } > - > - Private->RttSum += Rtt; > - Private->RttMin = Private->RttMin > Rtt ? Rtt : Private->RttMin; > - Private->RttMax = Private->RttMax < Rtt ? Rtt : Private->RttMax; > - > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_PING6_REPLY_INFO), > - mHiiHandle, > - PayLoad, > - mIp6DstString, > - Reply->SequenceNum, > - RxData->Header->HopLimit, > - Near, > - Rtt > - ); > - > -ON_EXIT: > - > - if (Private->RxCount < Private->SendNum) { > - // > - // Continue to receive icmp6 echo reply packets. > - // > - RxToken->Status = EFI_ABORTED; > - > - Status = Private->Ip6->Receive (Private->Ip6, RxToken); > - > - if (EFI_ERROR (Status)) { > - Private->Status = EFI_ABORTED; > - } > - } else { > - // > - // All reply have already been received from the dest host. > - // > - Private->Status = EFI_SUCCESS; > - } > - // > - // Singal to recycle the each rxdata here, not at the end of process. > - // > - gBS->SignalEvent (RxData->RecycleSignal); > -} > - > -/** > - Initial EFI_IP6_COMPLETION_TOKEN. > - > - @param[in] Private The pointer of PING6_PRIVATE_DATA. > - @param[in] TimeStamp The TimeStamp of request. > - @param[in] SequenceNum The SequenceNum of request. > - > - @return The pointer of EFI_IP6_COMPLETION_TOKEN. > - > -**/ > -EFI_IP6_COMPLETION_TOKEN * > -Ping6GenerateToken ( > - IN PING6_PRIVATE_DATA *Private, > - IN UINT64 TimeStamp, > - IN UINT16 SequenceNum > - ) > -{ > - EFI_STATUS Status; > - EFI_IP6_COMPLETION_TOKEN *Token; > - EFI_IP6_TRANSMIT_DATA *TxData; > - ICMP6_ECHO_REQUEST_REPLY *Request; > - > - Request = AllocateZeroPool (Private->BufferSize); > - > - if (Request == NULL) { > - return NULL; > - } > - // > - // Assembly icmp6 echo request packet. > - // > - Request->Type = ICMP_V6_ECHO_REQUEST; > - Request->Code = 0; > - Request->SequenceNum = SequenceNum; > - Request->TimeStamp = TimeStamp; > - Request->Identifier = 0; > - // > - // Leave check sum to ip6 layer, since it has no idea of source address > - // selection. > - // > - Request->Checksum = 0; > - > - TxData = AllocateZeroPool (sizeof (EFI_IP6_TRANSMIT_DATA)); > - > - if (TxData == NULL) { > - FreePool (Request); > - return NULL; > - } > - // > - // Assembly ipv6 token for transmit. > - // > - TxData->OverrideData = 0; > - TxData->ExtHdrsLength = 0; > - TxData->ExtHdrs = NULL; > - TxData->DataLength = Private->BufferSize; > - TxData->FragmentCount = 1; > - TxData->FragmentTable[0].FragmentBuffer = (VOID *) Request; > - TxData->FragmentTable[0].FragmentLength = Private->BufferSize; > - > - Token = AllocateZeroPool (sizeof (EFI_IP6_COMPLETION_TOKEN)); > - > - if (Token == NULL) { > - FreePool (Request); > - FreePool (TxData); > - return NULL; > - } > - > - Token->Status = EFI_ABORTED; > - Token->Packet.TxData = TxData; > - > - Status = gBS->CreateEvent ( > - EVT_NOTIFY_SIGNAL, > - TPL_CALLBACK, > - Ping6OnEchoRequestSent, > - Private, > - &Token->Event > - ); > - > - if (EFI_ERROR (Status)) { > - FreePool (Request); > - FreePool (TxData); > - FreePool (Token); > - return NULL; > - } > - > - return Token; > -} > - > -/** > - Transmit the EFI_IP6_COMPLETION_TOKEN. > - > - @param[in] Private The pointer of PING6_PRIVATE_DATA. > - > - @retval EFI_SUCCESS Transmitted successfully. > - @retval EFI_OUT_OF_RESOURCES No memory is available on the > platform. > - @retval others Transmitted unsuccessfully. > - > -**/ > -EFI_STATUS > -Ping6SendEchoRequest ( > - IN PING6_PRIVATE_DATA *Private > - ) > -{ > - EFI_STATUS Status; > - PING6_ICMP6_TX_INFO *TxInfo; > - > - TxInfo = AllocateZeroPool (sizeof (PING6_ICMP6_TX_INFO)); > - > - if (TxInfo == NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - > - TxInfo->TimeStamp = ReadTime (); > - TxInfo->SequenceNum = (UINT16) (Private->TxCount + 1); > - > - TxInfo->Token = Ping6GenerateToken ( > - Private, > - TxInfo->TimeStamp, > - TxInfo->SequenceNum > - ); > - > - if (TxInfo->Token == NULL) { > - Ping6DestroyTxInfo (TxInfo); > - return EFI_OUT_OF_RESOURCES; > - } > - > - Status = Private->Ip6->Transmit (Private->Ip6, TxInfo->Token); > - > - if (EFI_ERROR (Status)) { > - Ping6DestroyTxInfo (TxInfo); > - return Status; > - } > - > - InsertTailList (&Private->TxList, &TxInfo->Link); > - Private->TxCount++; > - > - return EFI_SUCCESS; > -} > - > -/** > - Place a completion token into the receive packet queue to receive the > echo reply. > - > - @param[in] Private The pointer of PING6_PRIVATE_DATA. > - > - @retval EFI_SUCCESS Put the token into the receive packet queue > successfully. > - @retval others Put the token into the receive packet queue > unsuccessfully. > - > -**/ > -EFI_STATUS > -Ping6ReceiveEchoReply ( > - IN PING6_PRIVATE_DATA *Private > - ) > -{ > - EFI_STATUS Status; > - > - ZeroMem (&Private->RxToken, sizeof (EFI_IP6_COMPLETION_TOKEN)); > - > - Status = gBS->CreateEvent ( > - EVT_NOTIFY_SIGNAL, > - TPL_CALLBACK, > - Ping6OnEchoReplyReceived, > - Private, > - &Private->RxToken.Event > - ); > - > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - Private->RxToken.Status = EFI_NOT_READY; > - > - return Private->Ip6->Receive (Private->Ip6, &Private->RxToken); > -} > - > -/** > - Remove the timeout request from the list. > - > - @param[in] Event A EFI_EVENT type event. > - @param[in] Context The pointer to Context. > - > -**/ > -VOID > -EFIAPI > -Ping6OnTimerRoutine ( > - IN EFI_EVENT Event, > - IN VOID *Context > - ) > -{ > - EFI_STATUS Status; > - PING6_PRIVATE_DATA *Private; > - PING6_ICMP6_TX_INFO *TxInfo; > - LIST_ENTRY *Entry; > - LIST_ENTRY *NextEntry; > - UINT64 Time; > - > - Private = (PING6_PRIVATE_DATA *) Context; > - > - // > - // Retransmit icmp6 echo request packets per second in sendnumber times. > - // > - if (Private->TxCount < Private->SendNum) { > - > - Status = Ping6SendEchoRequest (Private); > - if (Private->TxCount != 0){ > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_SEND_REQUEST), mHiiHandle, Private->TxCount + 1); > - } > - } > - } > - // > - // Check whether any icmp6 echo request in the list timeout. > - // > - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) { > - TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link); > - Time = Ping6CalculateTick (TxInfo->TimeStamp, ReadTime ()); > - > - // > - // Remove the timeout echo request from txlist. > - // > - if (Time > PING6_DEFAULT_TIMEOUT) { > - > - if (EFI_ERROR (TxInfo->Token->Status)) { > - Private->Ip6->Cancel (Private->Ip6, TxInfo->Token); > - } > - // > - // Remove the timeout icmp6 echo request from list. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_TIMEOUT), > mHiiHandle, TxInfo->SequenceNum); > - > - RemoveEntryList (&TxInfo->Link); > - Ping6DestroyTxInfo (TxInfo); > - > - if (IsListEmpty (&Private->TxList) && (Private->TxCount == Private- > >SendNum)) { > - // > - // All the left icmp6 echo request in the list timeout. > - // > - Private->Status = EFI_TIMEOUT; > - } > - } > - } > -} > - > -/** > - Create a valid IP6 instance. > - > - @param[in] Private The pointer of PING6_PRIVATE_DATA. > - > - @retval EFI_SUCCESS Create a valid IP6 instance successfully. > - @retval EFI_ABORTED Locate handle with ip6 service binding > protocol unsuccessfully. > - @retval EFI_INVALID_PARAMETER The source address is unspecified > when the destination address is a link -ocal address. > - @retval EFI_OUT_OF_RESOURCES No memory is available on the > platform. > - @retval EFI_NOT_FOUND The source address is not found. > -**/ > -EFI_STATUS > -Ping6CreateIp6Instance ( > - IN PING6_PRIVATE_DATA *Private > - ) > -{ > - EFI_STATUS Status; > - UINTN HandleIndex; > - UINTN HandleNum; > - EFI_HANDLE *HandleBuffer; > - EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb; > - EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; > - EFI_IP6_CONFIG_DATA Ip6Config; > - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; > - UINTN IfInfoSize; > - EFI_IPv6_ADDRESS *Addr; > - UINTN AddrIndex; > - > - HandleBuffer = NULL; > - Ip6Sb = NULL; > - IfInfo = NULL; > - IfInfoSize = 0; > - > - // > - // Locate all the handles with ip6 service binding protocol. > - // > - Status = gBS->LocateHandleBuffer ( > - ByProtocol, > - &gEfiIp6ServiceBindingProtocolGuid, > - NULL, > - &HandleNum, > - &HandleBuffer > - ); > - if (EFI_ERROR (Status) || (HandleNum == 0)) { > - return EFI_ABORTED; > - } > - // > - // Source address is required when pinging a link-local address on multi- > - // interfaces host. > - // > - if (NetIp6IsLinkLocalAddr (&Private->DstAddress) && > - NetIp6IsUnspecifiedAddr (&Private->SrcAddress) && > - (HandleNum > 1)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_INVALID_SOURCE), mHiiHandle); > - Status = EFI_INVALID_PARAMETER; > - goto ON_ERROR; > - } > - // > - // For each ip6 protocol, check interface addresses list. > - // > - for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) { > - > - Ip6Sb = NULL; > - IfInfo = NULL; > - IfInfoSize = 0; > - > - Status = gBS->HandleProtocol ( > - HandleBuffer[HandleIndex], > - &gEfiIp6ServiceBindingProtocolGuid, > - (VOID **) &Ip6Sb > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - if (NetIp6IsUnspecifiedAddr (&Private->SrcAddress)) { > - // > - // No need to match interface address. > - // > - break; > - } else { > - // > - // Ip6config protocol and ip6 service binding protocol are installed > - // on the same handle. > - // > - Status = gBS->HandleProtocol ( > - HandleBuffer[HandleIndex], > - &gEfiIp6ConfigProtocolGuid, > - (VOID **) &Ip6Cfg > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - // > - // Get the interface information size. > - // > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeInterfaceInfo, > - &IfInfoSize, > - NULL > - ); > - > - if (Status != EFI_BUFFER_TOO_SMALL) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - > - IfInfo = AllocateZeroPool (IfInfoSize); > - > - if (IfInfo == NULL) { > - Status = EFI_OUT_OF_RESOURCES; > - goto ON_ERROR; > - } > - // > - // Get the interface info. > - // > - Status = Ip6Cfg->GetData ( > - Ip6Cfg, > - Ip6ConfigDataTypeInterfaceInfo, > - &IfInfoSize, > - IfInfo > - ); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_IP6CFG_GETDATA), mHiiHandle, Status); > - goto ON_ERROR; > - } > - // > - // Check whether the source address is one of the interface addresses. > - // > - for (AddrIndex = 0; AddrIndex < IfInfo->AddressInfoCount; AddrIndex++) > { > - > - Addr = &(IfInfo->AddressInfo[AddrIndex].Address); > - if (EFI_IP6_EQUAL (&Private->SrcAddress, Addr)) { > - // > - // Match a certain interface address. > - // > - break; > - } > - } > - > - if (AddrIndex < IfInfo->AddressInfoCount) { > - // > - // Found a nic handle with right interface address. > - // > - break; > - } > - } > - > - FreePool (IfInfo); > - IfInfo = NULL; > - } > - // > - // No exact interface address matched. > - // > - > - if (HandleIndex == HandleNum) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_SOURCE_NOT_FOUND), mHiiHandle, mIp6SrcString); > - Status = EFI_NOT_FOUND; > - goto ON_ERROR; > - } > - > - Private->NicHandle = HandleBuffer[HandleIndex]; > - > - ASSERT (Ip6Sb != NULL); > - Status = Ip6Sb->CreateChild (Ip6Sb, &Private->Ip6ChildHandle); > - > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status = gBS->OpenProtocol ( > - Private->Ip6ChildHandle, > - &gEfiIp6ProtocolGuid, > - (VOID **) &Private->Ip6, > - Private->ImageHandle, > - Private->Ip6ChildHandle, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - ZeroMem (&Ip6Config, sizeof (EFI_IP6_CONFIG_DATA)); > - > - // > - // Configure the ip6 instance for icmp6 packet exchange. > - // > - Ip6Config.DefaultProtocol = 58; > - Ip6Config.AcceptAnyProtocol = FALSE; > - Ip6Config.AcceptIcmpErrors = TRUE; > - Ip6Config.AcceptPromiscuous = FALSE; > - Ip6Config.TrafficClass = 0; > - Ip6Config.HopLimit = 128; > - Ip6Config.FlowLabel = 0; > - Ip6Config.ReceiveTimeout = 0; > - Ip6Config.TransmitTimeout = 0; > - > - IP6_COPY_ADDRESS (&Ip6Config.StationAddress, &Private->SrcAddress); > - > - IP6_COPY_ADDRESS (&Ip6Config.DestinationAddress, &Private- > >DstAddress); > - > - Status = Private->Ip6->Configure (Private->Ip6, &Ip6Config); > - > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_IP6_CONFIG), > mHiiHandle, Status); > - goto ON_ERROR; > - } > - > - return EFI_SUCCESS; > - > -ON_ERROR: > - if (HandleBuffer != NULL) { > - FreePool (HandleBuffer); > - } > - > - if (IfInfo != NULL) { > - FreePool (IfInfo); > - } > - > - if ((Ip6Sb != NULL) && (Private->Ip6ChildHandle != NULL)) { > - Ip6Sb->DestroyChild (Ip6Sb, Private->Ip6ChildHandle); > - } > - > - return Status; > -} > - > -/** > - Destroy the IP6 instance. > - > - @param[in] Private The pointer of PING6_PRIVATE_DATA. > - > -**/ > -VOID > -Ping6DestroyIp6Instance ( > - IN PING6_PRIVATE_DATA *Private > - ) > -{ > - EFI_STATUS Status; > - EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb; > - > - gBS->CloseProtocol ( > - Private->Ip6ChildHandle, > - &gEfiIp6ProtocolGuid, > - Private->ImageHandle, > - Private->Ip6ChildHandle > - ); > - > - Status = gBS->HandleProtocol ( > - Private->NicHandle, > - &gEfiIp6ServiceBindingProtocolGuid, > - (VOID **) &Ip6Sb > - ); > - > - if (!EFI_ERROR(Status)) { > - Ip6Sb->DestroyChild (Ip6Sb, Private->Ip6ChildHandle); > - } > -} > - > -/** > - The Ping6 Process. > - > - @param[in] ImageHandle The firmware allocated handle for the UEFI > image. > - @param[in] SendNumber The send request count. > - @param[in] BufferSize The send buffer size. > - @param[in] SrcAddress The source IPv6 address. > - @param[in] DstAddress The destination IPv6 address. > - > - @retval EFI_SUCCESS The ping6 processed successfullly. > - @retval others The ping6 processed unsuccessfully. > - > -**/ > -EFI_STATUS > -Ping6 ( > - IN EFI_HANDLE ImageHandle, > - IN UINT32 SendNumber, > - IN UINT32 BufferSize, > - IN EFI_IPv6_ADDRESS *SrcAddress, > - IN EFI_IPv6_ADDRESS *DstAddress > - ) > -{ > - EFI_STATUS Status; > - EFI_INPUT_KEY Key; > - PING6_PRIVATE_DATA *Private; > - PING6_ICMP6_TX_INFO *TxInfo; > - LIST_ENTRY *Entry; > - LIST_ENTRY *NextEntry; > - > - Private = AllocateZeroPool (sizeof (PING6_PRIVATE_DATA)); > - > - ASSERT (Private != NULL); > - > - Private->ImageHandle = ImageHandle; > - Private->SendNum = SendNumber; > - Private->BufferSize = BufferSize; > - Private->RttMin = ~((UINT64 )(0x0)); > - Private->Status = EFI_NOT_READY; > - > - InitializeListHead (&Private->TxList); > - > - IP6_COPY_ADDRESS (&Private->SrcAddress, SrcAddress); > - IP6_COPY_ADDRESS (&Private->DstAddress, DstAddress); > - > - // > - // Open and configure a ip6 instance for ping6. > - // > - Status = Ping6CreateIp6Instance (Private); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - // > - // Print the command line itself. > - // > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_START), > mHiiHandle, mIp6DstString, Private->BufferSize); > - // > - // Create a ipv6 token to receive the first icmp6 echo reply packet. > - // > - Status = Ping6ReceiveEchoReply (Private); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - // > - // Create and start timer to send icmp6 echo request packet per second. > - // > - Status = gBS->CreateEvent ( > - EVT_TIMER | EVT_NOTIFY_SIGNAL, > - TPL_CALLBACK, > - Ping6OnTimerRoutine, > - Private, > - &Private->Timer > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - // > - // Create a ipv6 token to send the first icmp6 echo request packet. > - // > - Status = Ping6SendEchoRequest (Private); > - // > - // EFI_NOT_READY for IPsec is enable and IKE is not established. > - // > - if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) { > - if(Status == EFI_NOT_FOUND) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_NOSOURCE_INDOMAIN), mHiiHandle, mIp6DstString); > - } > - > - goto ON_EXIT; > - } > - > - Status = gBS->SetTimer ( > - Private->Timer, > - TimerPeriodic, > - PING6_ONE_SECOND > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - // > - // Control the ping6 process by two factors: > - // 1. Hot key > - // 2. Private->Status > - // 2.1. success means all icmp6 echo request packets get reply packets. > - // 2.2. timeout means the last icmp6 echo reply request timeout to get > reply. > - // 2.3. noready means ping6 process is on-the-go. > - // > - while (Private->Status == EFI_NOT_READY) { > - Private->Ip6->Poll (Private->Ip6); > - > - // > - // Terminate the ping6 process by 'esc' or 'ctl-c'. > - // > - Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); > - > - if (!EFI_ERROR(Status)) { > - if ((Key.UnicodeChar == 0x1b) || (Key.UnicodeChar == 0x03) || > - ((Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_ESC))) { > - goto ON_STAT; > - } > - } > - } > - > -ON_STAT: > - // > - // Display the statistics in all. > - // > - gBS->SetTimer (Private->Timer, TimerCancel, 0); > - > - if (Private->TxCount != 0) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_PING6_STAT), > - mHiiHandle, > - Private->TxCount, > - Private->RxCount, > - (100 * (Private->TxCount - Private->RxCount)) / Private->TxCount, > - Private->RttSum > - ); > - } > - > - if (Private->RxCount != 0) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_PING6_RTT), > - mHiiHandle, > - Private->RttMin, > - Private->RttMax, > - DivU64x64Remainder (Private->RttSum, Private->RxCount, NULL) > - ); > - } > - > -ON_EXIT: > - > - if (Private != NULL) { > - Private->Status = EFI_ABORTED; > - > - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) { > - TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link); > - > - Status = Private->Ip6->Cancel (Private->Ip6, TxInfo->Token); > - > - RemoveEntryList (&TxInfo->Link); > - Ping6DestroyTxInfo (TxInfo); > - } > - > - if (Private->Timer != NULL) { > - gBS->CloseEvent (Private->Timer); > - } > - > - if (Private->Ip6 != NULL) { > - Status = Private->Ip6->Cancel (Private->Ip6, &Private->RxToken); > - } > - > - if (Private->RxToken.Event != NULL) { > - gBS->CloseEvent (Private->RxToken.Event); > - } > - > - if (Private->Ip6ChildHandle != NULL) { > - Ping6DestroyIp6Instance (Private); > - } > - > - FreePool (Private); > - } > - > - return Status; > -} > - > -/** > - This is the declaration of an EFI image entry point. This entry point is > - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, > including > - both device drivers and bus drivers. > - > - The entry point for the Ping6 application that parses the command line > input and calls the Ping6 process. > - > - @param[in] ImageHandle The firmware allocated handle for the UEFI > image. > - @param[in] SystemTable A pointer to the EFI System Table. > - > - @retval EFI_SUCCESS The operation completed successfully. > - @retval EFI_INVALID_PARAMETETR Input parameters combination is > invalid. > - @retval Others Some errors occur. > - > -**/ > -EFI_STATUS > -EFIAPI > -InitializePing6 ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE *SystemTable > - ) > -{ > - EFI_STATUS Status; > - EFI_IPv6_ADDRESS DstAddress; > - EFI_IPv6_ADDRESS SrcAddress; > - UINT64 BufferSize; > - UINTN SendNumber; > - LIST_ENTRY *ParamPackage; > - CONST CHAR16 *ValueStr; > - CONST CHAR16 *ValueStrPtr; > - UINTN NonOptionCount; > - EFI_HII_PACKAGE_LIST_HEADER *PackageList; > - > - // > - // Retrieve HII package list from ImageHandle > - // > - Status = gBS->OpenProtocol ( > - ImageHandle, > - &gEfiHiiPackageListProtocolGuid, > - (VOID **) &PackageList, > - ImageHandle, > - NULL, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL > - ); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - // > - // Publish HII package list to HII Database. > - // > - Status = gHiiDatabase->NewPackageList ( > - gHiiDatabase, > - PackageList, > - NULL, > - &mHiiHandle > - ); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - ASSERT (mHiiHandle != NULL); > - > - Status = ShellCommandLineParseEx (Ping6ParamList, &ParamPackage, > NULL, TRUE, FALSE); > - if (EFI_ERROR(Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_INVALID_INPUT), mHiiHandle); > - goto ON_EXIT; > - } > - > - SendNumber = 10; > - BufferSize = 16; > - > - // > - // Parse the parameter of count number. > - // > - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-n"); > - ValueStrPtr = ValueStr; > - if (ValueStr != NULL) { > - SendNumber = ShellStrToUintn (ValueStrPtr); > - > - // > - // ShellStrToUintn will return 0 when input is 0 or an invalid input string. > - // > - if ((SendNumber == 0) || (SendNumber > PING6_MAX_SEND_NUMBER)) > { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_INVALID_SEND_NUMBER), mHiiHandle, ValueStr); > - Status = EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - } > - // > - // Parse the parameter of buffer size. > - // > - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l"); > - ValueStrPtr = ValueStr; > - if (ValueStr != NULL) { > - BufferSize = ShellStrToUintn (ValueStrPtr); > - > - // > - // ShellStrToUintn will return 0 when input is 0 or an invalid input string. > - // > - if ((BufferSize < 16) || (BufferSize > PING6_MAX_BUFFER_SIZE)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_INVALID_BUFFER_SIZE), mHiiHandle, ValueStr); > - Status = EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - } > - > - ZeroMem (&SrcAddress, sizeof (EFI_IPv6_ADDRESS)); > - ZeroMem (&DstAddress, sizeof (EFI_IPv6_ADDRESS)); > - > - // > - // Parse the parameter of source ip address. > - // > - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s"); > - ValueStrPtr = ValueStr; > - if (ValueStr != NULL) { > - mIp6SrcString = ValueStr; > - Status = NetLibStrToIp6 (ValueStrPtr, &SrcAddress); > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_IP), > mHiiHandle, ValueStr); > - Status = EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - } > - // > - // Parse the parameter of destination ip address. > - // > - NonOptionCount = ShellCommandLineGetCount(ParamPackage); > - ValueStr = ShellCommandLineGetRawValue (ParamPackage, > (UINT32)(NonOptionCount-1)); > - if (NonOptionCount != 2) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_PING6_INVALID_INPUT), mHiiHandle); > - Status = EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - ValueStrPtr = ValueStr; > - if (ValueStr != NULL) { > - mIp6DstString = ValueStr; > - Status = NetLibStrToIp6 (ValueStrPtr, &DstAddress); > - if (EFI_ERROR (Status)) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_IP), > mHiiHandle, ValueStr); > - Status = EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - } > - // > - // Get frequency to calculate the time from ticks. > - // > - Status = Ping6GetFrequency (); > - > - if (EFI_ERROR(Status)) { > - goto ON_EXIT; > - } > - // > - // Enter into ping6 process. > - // > - Status = Ping6 ( > - ImageHandle, > - (UINT32)SendNumber, > - (UINT32)BufferSize, > - &SrcAddress, > - &DstAddress > - ); > - > -ON_EXIT: > - ShellCommandLineFreeVarList (ParamPackage); > - HiiRemovePackages (mHiiHandle); > - return Status; > -} > diff --git a/NetworkPkg/Application/Ping6/Ping6.h > b/NetworkPkg/Application/Ping6/Ping6.h > deleted file mode 100644 > index 6f590af8c0..0000000000 > --- a/NetworkPkg/Application/Ping6/Ping6.h > +++ /dev/null > @@ -1,87 +0,0 @@ > -/** @file > - The interface function declaration of shell application Ping6 (Ping for v6 > series). > - > - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#ifndef _PING6_H_ > -#define _PING6_H_ > - > -#define PING6_DEFAULT_TIMEOUT 5000 > -#define PING6_MAX_SEND_NUMBER 10000 > -#define PING6_MAX_BUFFER_SIZE 32768 > -#define PING6_ONE_SECOND 10000000 > - > -// > -// A similar amount of time that passes in femtoseconds > -// for each increment of TimerValue. It is for NT32 only. > -// > -#define NTTIMERPERIOD 358049 > - > -#pragma pack(1) > - > -typedef struct _ICMP6_ECHO_REQUEST_REPLY { > - UINT8 Type; > - UINT8 Code; > - UINT16 Checksum; > - UINT16 Identifier; > - UINT16 SequenceNum; > - UINT64 TimeStamp; > - UINT8 Data[1]; > -} ICMP6_ECHO_REQUEST_REPLY; > - > -#pragma pack() > - > -typedef struct _PING6_ICMP6_TX_INFO { > - LIST_ENTRY Link; > - UINT16 SequenceNum; > - UINT64 TimeStamp; > - EFI_IP6_COMPLETION_TOKEN *Token; > -} PING6_ICMP6_TX_INFO; > - > -typedef struct _PING6_PRIVATE_DATA { > - EFI_HANDLE ImageHandle; > - EFI_HANDLE NicHandle; > - EFI_HANDLE Ip6ChildHandle; > - EFI_IP6_PROTOCOL *Ip6; > - EFI_EVENT Timer; > - > - EFI_STATUS Status; > - LIST_ENTRY TxList; > - EFI_IP6_COMPLETION_TOKEN RxToken; > - UINT16 RxCount; > - UINT16 TxCount; > - UINT64 RttSum; > - UINT64 RttMin; > - UINT64 RttMax; > - UINT32 SequenceNum; > - > - EFI_IPv6_ADDRESS SrcAddress; > - EFI_IPv6_ADDRESS DstAddress; > - UINT32 SendNum; > - UINT32 BufferSize; > -} PING6_PRIVATE_DATA; > - > -/** > - Reads and returns the current value of register. > - In IA64, the register is the Interval Timer Vector (ITV). > - In X86(IA32/X64), the register is the Time Stamp Counter (TSC) > - > - @return The current value of the register. > - > -**/ > -UINT64 > -ReadTime ( > - VOID > - ); > - > -#endif > diff --git a/NetworkPkg/Application/Ping6/Ping6.inf > b/NetworkPkg/Application/Ping6/Ping6.inf > deleted file mode 100644 > index 68b5f2d32f..0000000000 > --- a/NetworkPkg/Application/Ping6/Ping6.inf > +++ /dev/null > @@ -1,78 +0,0 @@ > -## @file > -# Shell application Ping6. > -# > -# It is an shell application which is used to Ping the target host with IPv6 > stack. > -# > -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > -# > -# This program and the accompanying materials > -# are licensed and made available under the terms and conditions of the > BSD License > -# which accompanies this distribution. The full text of the license may be > found at > -# http://opensource.org/licenses/bsd-license.php. > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -# > -## > - > -[Defines] > - INF_VERSION = 0x00010006 > - BASE_NAME = Ping6 > - FILE_GUID = F35F733F-5235-4d7b-83FA-97780CEBCB20 > - MODULE_TYPE = UEFI_APPLICATION > - VERSION_STRING = 1.0 > - ENTRY_POINT = InitializePing6 > - MODULE_UNI_FILE = Ping6.uni > - > -# > -# > -# This flag specifies whether HII resource section is generated into PE image. > -# > - UEFI_HII_RESOURCE_SECTION = TRUE > - > -# > -# The following information is for reference only and not required by the > build tools. > -# > -# VALID_ARCHITECTURES = IA32 X64 IPF > -# > - > -[Sources] > - Ping6.c > - Ping6Strings.uni > - Ping6.h > - > -[Sources.IA32] > - Ia32/Tsc.c > - > -[Sources.X64] > - X64/Tsc.c > - > -[Sources.IPF] > - Ipf/Itc.c > - > -[Packages] > - MdePkg/MdePkg.dec > - MdeModulePkg/MdeModulePkg.dec > - ShellPkg/ShellPkg.dec > - > -[LibraryClasses] > - BaseLib > - UefiBootServicesTableLib > - UefiApplicationEntryPoint > - UefiHiiServicesLib > - BaseMemoryLib > - ShellLib > - MemoryAllocationLib > - DebugLib > - HiiLib > - NetLib > - > -[Protocols] > - gEfiCpuArchProtocolGuid ## CONSUMES > - gEfiIp6ProtocolGuid ## CONSUMES > - gEfiIp6ServiceBindingProtocolGuid ## CONSUMES > - gEfiIp6ConfigProtocolGuid ## CONSUMES > - gEfiHiiPackageListProtocolGuid ## CONSUMES > - > -[UserExtensions.TianoCore."ExtraFiles"] > - Ping6Extra.uni > diff --git a/NetworkPkg/Application/Ping6/Ping6.uni > b/NetworkPkg/Application/Ping6/Ping6.uni > deleted file mode 100644 > index afd14b796a..0000000000 > --- a/NetworkPkg/Application/Ping6/Ping6.uni > +++ /dev/null > @@ -1,22 +0,0 @@ > -// /** @file > -// Shell application Ping6. > -// > -// It is an shell application which is used to Ping the target host with IPv6 > stack. > -// > -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> > -// > -// This program and the accompanying materials > -// are licensed and made available under the terms and conditions of the > BSD License > -// which accompanies this distribution. The full text of the license may be > found at > -// http://opensource.org/licenses/bsd-license.php. > -// > -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -// > -// **/ > - > - > -#string STR_MODULE_ABSTRACT #language en-US "Shell application > Ping6" > - > -#string STR_MODULE_DESCRIPTION #language en-US "It is an shell > application which is used to Ping the target host with IPv6 stack." > - > diff --git a/NetworkPkg/Application/Ping6/Ping6Extra.uni > b/NetworkPkg/Application/Ping6/Ping6Extra.uni > deleted file mode 100644 > index 097ea5578a..0000000000 > --- a/NetworkPkg/Application/Ping6/Ping6Extra.uni > +++ /dev/null > @@ -1,20 +0,0 @@ > -// /** @file > -// Ping6 Localized Strings and Content > -// > -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR> > -// > -// This program and the accompanying materials > -// are licensed and made available under the terms and conditions of the > BSD License > -// which accompanies this distribution. The full text of the license may be > found at > -// http://opensource.org/licenses/bsd-license.php. > -// > -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -// > -// **/ > - > -#string STR_PROPERTIES_MODULE_NAME > -#language en-US > -"Ping6 App" > - > - > diff --git a/NetworkPkg/Application/Ping6/Ping6Strings.uni > b/NetworkPkg/Application/Ping6/Ping6Strings.uni > deleted file mode 100644 > index e4ab19fe63..0000000000 > --- a/NetworkPkg/Application/Ping6/Ping6Strings.uni > +++ /dev/null > @@ -1,53 +0,0 @@ > -/** @file > - String definitions for the Shell Ping6 application. > - > - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#langdef en-US "English" > - > -#string STR_PING6_INVALID_IP #language en-US "%Ping6: Invalid > IP6 address, %s\n" > -#string STR_PING6_INVALID_INPUT #language en-US "%Ping6: Invalid > input, please type 'Ping6 -?'for help\n" > -#string STR_PING6_INVALID_SEND_NUMBER #language en-US "%Ping6: > Invalid send number, %s\n" > -#string STR_PING6_INVALID_BUFFER_SIZE #language en-US "%Ping6: > Invalid buffer size, %s\n" > -#string STR_PING6_INVALID_SOURCE #language en-US "%Ping6: > Require source interface option\n" > -#string STR_PING6_IP6_CONFIG #language en-US "%Ping6: Ip6- > >Config %r\n" > -#string STR_PING6_IP6_GETMODE #language en-US "%Ping6: Ip6- > >GetModeData %r\n" > -#string STR_PING6_IP6CFG_GETDATA #language en-US "%Ping6: > Ip6Config->GetData %r\n" > -#string STR_PING6_SEND_REQUEST #language en-US "Echo request > sequence %d fails.\n" > -#string STR_PING6_SOURCE_NOT_FOUND #language en-US > "Source %s not found.\n" > -#string STR_PING6_NOSOURCE_INDOMAIN #language en-US "No > sources in %s's multicast domain.\n" > -#string STR_PING6_START #language en-US "Ping %s %d data > bytes\n\n" > -#string STR_PING6_TIMEOUT #language en-US "Echo request > sequence %d timeout.\n" > -#string STR_PING6_REPLY_INFO #language en-US "%d bytes > from %s : icmp_seq=%d ttl=%d time%c%dms\n" > -#string STR_PING6_STAT #language en-US "\n%d packets > transmitted, %d received, %d%% packet loss, time %dms\n" > -#string STR_PING6_RTT #language en-US "\nRtt(round trip time) > min=%dms max=%dms avg=%dms\n" > -#string STR_PING6_LINE_HELP #language en-US "Ping a target > machine with UEFI IPv6 network stack" > - > -#string STR_PING6_HELP #language en-US "" > -".TH Ping6 0 "Ping a target machine with UEFI IPv6 network stack."\r\n" > -".SH NAME\r\n" > -"Ping a target machine with UEFI IPv6 network stack.\r\n" > -".SH SYNOPSIS\r\n" > -" \r\n" > -"Ping6 [-l size] [-n count] [-s SourceIp] TargetIp\r\n" > -".SH OPTIONS\r\n" > -" \r\n" > -" -l size Send buffer size, in bytes(default=16, min=16, max=32768).\r\n" > -" -n count Send request count, (default=10, min=1, max=10000).\r\n" > -" -s SourceIp Source IPv6 address.\r\n" > -" TargetIp Target IPv6 address.\r\n" > -".SH EXAMPLES\r\n" > -" \r\n" > -"Examples:\r\n" > -" Ping6 -s 2002::1 2002::2 -l 1000 -n 5\r\n" > -" Ping6 2002::2 -l 1000\r\n" > diff --git a/NetworkPkg/Application/Ping6/X64/Tsc.c > b/NetworkPkg/Application/Ping6/X64/Tsc.c > deleted file mode 100644 > index b3e7bdbb96..0000000000 > --- a/NetworkPkg/Application/Ping6/X64/Tsc.c > +++ /dev/null > @@ -1,28 +0,0 @@ > -/** @file > - The implement to read TSC in X64 platform. > - > - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> > - > - This program and the accompanying materials > - are licensed and made available under the terms and conditions of the BSD > License > - which accompanies this distribution. The full text of the license may be > found at > - http://opensource.org/licenses/bsd-license.php. > - > - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > - > -**/ > - > -#include <Library/BaseLib.h> > - > -/** > - Reads and returns the current value of Time Stamp Counter (TSC). > - > - @return The current value of TSC > - > -**/ > -UINT64 > -ReadTime () > -{ > - return AsmReadTsc (); > -} > diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc > index 56a1a6b617..b193f5f38b 100644 > --- a/NetworkPkg/NetworkPkg.dsc > +++ b/NetworkPkg/NetworkPkg.dsc > @@ -116,7 +116,6 @@ > NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf > NetworkPkg/HttpBootDxe/HttpBootDxe.inf > > - NetworkPkg/Application/IfConfig6/IfConfig6.inf > NetworkPkg/Application/IpsecConfig/IpSecConfig.inf > NetworkPkg/Application/VConfig/VConfig.inf > > @@ -126,8 +125,6 @@ > NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf > NetworkPkg/TlsDxe/TlsDxe.inf > NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf > - > - NetworkPkg/Application/Ping6/Ping6.inf > > [BuildOptions] > *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES > -- > 2.13.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Ye Ting <ting.ye@intel.com> -----Original Message----- From: Fu, Siyuan Sent: Tuesday, October 17, 2017 9:08 PM To: edk2-devel@lists.01.org Cc: Wu, Jiaxin; Ye, Ting Subject: [Patch] NetworkPkg: Remove ping6 and ifconfig shell application. Edk2 has duplicated ping6/ifconfig6 implementation in NetworkPkg and ShellPkg. The usage and parameter format of these 2 versions are exactly same. These two commands have been added to Shell specification so the copy under ShellPkg\Library\UefiShellNetwork2CommandsLib\ will be actively maintained in future. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Ye Ting <ting.ye@intel.com> --- NetworkPkg/Application/IfConfig6/IfConfig6.c | 1793 -------------------- NetworkPkg/Application/IfConfig6/IfConfig6.h | 79 - NetworkPkg/Application/IfConfig6/IfConfig6.inf | 67 - NetworkPkg/Application/IfConfig6/IfConfig6.uni | 23 - .../Application/IfConfig6/IfConfig6Extra.uni | 20 - .../Application/IfConfig6/IfConfig6Strings.uni | 92 - NetworkPkg/Application/Ping6/Ia32/Tsc.c | 28 - NetworkPkg/Application/Ping6/Ipf/Itc.c | 28 - NetworkPkg/Application/Ping6/Ping6.c | 1200 ------------- NetworkPkg/Application/Ping6/Ping6.h | 87 - NetworkPkg/Application/Ping6/Ping6.inf | 78 - NetworkPkg/Application/Ping6/Ping6.uni | 22 - NetworkPkg/Application/Ping6/Ping6Extra.uni | 20 - NetworkPkg/Application/Ping6/Ping6Strings.uni | 53 - NetworkPkg/Application/Ping6/X64/Tsc.c | 28 - NetworkPkg/NetworkPkg.dsc | 3 - 16 files changed, 3621 deletions(-) delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.c delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.h delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.inf delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6.uni delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni delete mode 100644 NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni delete mode 100644 NetworkPkg/Application/Ping6/Ia32/Tsc.c delete mode 100644 NetworkPkg/Application/Ping6/Ipf/Itc.c delete mode 100644 NetworkPkg/Application/Ping6/Ping6.c delete mode 100644 NetworkPkg/Application/Ping6/Ping6.h delete mode 100644 NetworkPkg/Application/Ping6/Ping6.inf delete mode 100644 NetworkPkg/Application/Ping6/Ping6.uni delete mode 100644 NetworkPkg/Application/Ping6/Ping6Extra.uni delete mode 100644 NetworkPkg/Application/Ping6/Ping6Strings.uni delete mode 100644 NetworkPkg/Application/Ping6/X64/Tsc.c diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.c b/NetworkPkg/Application/IfConfig6/IfConfig6.c deleted file mode 100644 index 48c3be3552..0000000000 --- a/NetworkPkg/Application/IfConfig6/IfConfig6.c +++ /dev/null @@ -1,1793 +0,0 @@ -/** @file - The implementation for Shell application IfConfig6. - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Library/ShellLib.h> -#include <Library/BaseMemoryLib.h> -#include <Library/BaseLib.h> -#include <Library/MemoryAllocationLib.h> -#include <Library/DebugLib.h> -#include <Library/UefiBootServicesTableLib.h> -#include <Library/UefiHiiServicesLib.h> -#include <Library/HiiLib.h> -#include <Library/NetLib.h> - -#include <Protocol/Ip6.h> -#include <Protocol/Ip6Config.h> - -#include "IfConfig6.h" - -// -// String token ID of ifconfig6 command help message text. -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringIfconfig6HelpTokenId = STRING_TOKEN (STR_IFCONFIG6_HELP); - -EFI_HII_HANDLE mHiiHandle; - -SHELL_PARAM_ITEM mIfConfig6CheckList[] = { - { - L"-b", - TypeFlag - }, - { - L"-s", - TypeMaxValue - }, - { - L"-l", - TypeValue - }, - { - L"-r", - TypeValue - }, - { - NULL, - TypeMax - }, -}; - -VAR_CHECK_ITEM mSetCheckList[] = { - { - L"auto", - 0x00000001, - 0x00000001, - FlagTypeSingle - }, - { - L"man", - 0x00000002, - 0x00000001, - FlagTypeSingle - }, - { - L"host", - 0x00000004, - 0x00000002, - FlagTypeSingle - }, - { - L"dad", - 0x00000008, - 0x00000004, - FlagTypeSingle - }, - { - L"gw", - 0x00000010, - 0x00000008, - FlagTypeSingle - }, - { - L"dns", - 0x00000020, - 0x00000010, - FlagTypeSingle - }, - { - L"id", - 0x00000040, - 0x00000020, - FlagTypeSingle - }, - { - NULL, - 0x0, - 0x0, - FlagTypeSkipUnknown - }, -}; - -/** - Split a string with specified separator and save the substring to a list. - - @param[in] String The pointer of the input string. - @param[in] Separator The specified separator. - - @return The pointer of headnode of ARG_LIST. - -**/ -ARG_LIST * -SplitStrToList ( - IN CONST CHAR16 *String, - IN CHAR16 Separator - ) -{ - CHAR16 *Str; - CHAR16 *ArgStr; - ARG_LIST *ArgList; - ARG_LIST *ArgNode; - - if (String == NULL || *String == L'\0') { - return NULL; - } - - // - // Copy the CONST string to a local copy. - // - Str = AllocateCopyPool (StrSize (String), String); - ASSERT (Str != NULL); - ArgStr = Str; - - // - // init a node for the list head. - // - ArgNode = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST)); - ASSERT (ArgNode != NULL); - ArgList = ArgNode; - - // - // Split the local copy and save in the list node. - // - while (*Str != L'\0') { - if (*Str == Separator) { - *Str = L'\0'; - ArgNode->Arg = ArgStr; - ArgStr = Str + 1; - ArgNode->Next = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST)); - ASSERT (ArgNode->Next != NULL); - ArgNode = ArgNode->Next; - } - - Str++; - } - - ArgNode->Arg = ArgStr; - ArgNode->Next = NULL; - - return ArgList; -} - -/** - Check the correctness of input Args with '-s' option. - - @param[in] CheckList The pointer of VAR_CHECK_ITEM array. - @param[in] Name The pointer of input arg. - @param[in] Init The switch to execute the check. - - @return The value of VAR_CHECK_CODE. - -**/ -VAR_CHECK_CODE -IfConfig6RetriveCheckListByName( - IN VAR_CHECK_ITEM *CheckList, - IN CHAR16 *Name, - IN BOOLEAN Init -) -{ - STATIC UINT32 CheckDuplicate; - STATIC UINT32 CheckConflict; - VAR_CHECK_CODE RtCode; - UINT32 Index; - VAR_CHECK_ITEM Arg; - - if (Init) { - CheckDuplicate = 0; - CheckConflict = 0; - return VarCheckOk; - } - - RtCode = VarCheckOk; - Index = 0; - Arg = CheckList[Index]; - - // - // Check the Duplicated/Conflicted/Unknown input Args. - // - while (Arg.FlagStr != NULL) { - if (StrCmp (Arg.FlagStr, Name) == 0) { - - if (CheckDuplicate & Arg.FlagID) { - RtCode = VarCheckDuplicate; - break; - } - - if (CheckConflict & Arg.ConflictMask) { - RtCode = VarCheckConflict; - break; - } - - CheckDuplicate |= Arg.FlagID; - CheckConflict |= Arg.ConflictMask; - break; - } - - Arg = CheckList[++Index]; - } - - if (Arg.FlagStr == NULL) { - RtCode = VarCheckUnknown; - } - - return RtCode; -} - -/** - The notify function of create event when performing a manual config. - - @param[in] Event The event this notify function registered to. - @param[in] Context Pointer to the context data registered to the event. - -**/ -VOID -EFIAPI -IfConfig6ManualAddressNotify ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - *((BOOLEAN *) Context) = TRUE; -} - -/** - Print MAC address. - - @param[in] Node The pointer of MAC address buffer. - @param[in] Size The size of MAC address buffer. - -**/ -VOID -IfConfig6PrintMacAddr ( - IN UINT8 *Node, - IN UINT32 Size - ) -{ - UINTN Index; - - ASSERT (Size <= MACADDRMAXSIZE); - - for (Index = 0; Index < Size; Index++) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_BODY), mHiiHandle, Node[Index]); - if (Index + 1 < Size) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle); - } - } - - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); -} - -/** - Print IPv6 address. - - @param[in] Ip The pointer of Ip bufffer in EFI_IPv6_ADDRESS format. - @param[in] PrefixLen The pointer of PrefixLen that describes the size Prefix. - -**/ -VOID -IfConfig6PrintIpAddr ( - IN EFI_IPv6_ADDRESS *Ip, - IN UINT8 *PrefixLen - ) -{ - UINTN Index; - BOOLEAN Short; - - Short = FALSE; - - for (Index = 0; Index < PREFIXMAXLEN; Index = Index + 2) { - - if (!Short && (Index + 1 < PREFIXMAXLEN) && (Index % 2 == 0) && (Ip->Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0)) { - // - // Deal with the case of ::. - // - if (Index == 0) { - // - // :: is at the beginning of the address. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle); - } - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle); - - while ((Ip->Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0) && (Index < PREFIXMAXLEN)) { - Index = Index + 2; - if (Index > PREFIXMAXLEN - 2) { - break; - } - } - - Short = TRUE; - - if (Index == PREFIXMAXLEN) { - // - // :: is at the end of the address. - // - break; - } - } - - if (Index < PREFIXMAXLEN - 1) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY), mHiiHandle, Ip->Addr[Index]); - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_BODY), mHiiHandle, Ip->Addr[Index + 1]); - } - - if (Index + 2 < PREFIXMAXLEN) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), mHiiHandle); - } - } - - if (PrefixLen != NULL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_PREFIX_LEN), mHiiHandle, *PrefixLen); - } -} - -/** - Pick up host IPv6 address in string format from Args with "-s" option and convert it to EFI_IP6_CONFIG_MANUAL_ADDRESS format. - - @param[in, out] Arg The pointer of the address of ARG_LIST which save Args with the "-s" option. - @param[out] Buf The pointer of the address of EFI_IP6_CONFIG_MANUAL_ADDRESS. - @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes. - - @retval EFI_SUCCESS The convertion is successful. - @retval Others Does't find the host address, or it is an invalid IPv6 address in string format. - -**/ -EFI_STATUS -IfConfig6ParseManualAddressList ( - IN OUT ARG_LIST **Arg, - OUT EFI_IP6_CONFIG_MANUAL_ADDRESS **Buf, - OUT UINTN *BufSize - ) -{ - EFI_STATUS Status; - EFI_IP6_CONFIG_MANUAL_ADDRESS *AddrBuf; - ARG_LIST *VarArg; - EFI_IPv6_ADDRESS Address; - UINT8 Prefix; - UINT8 AddrCnt; - - Prefix = 0; - AddrCnt = 0; - *BufSize = 0; - *Buf = NULL; - VarArg = *Arg; - Status = EFI_SUCCESS; - - // - // Go through the list to check the correctness of input host ip6 address. - // - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { - - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); - - if (EFI_ERROR (Status)) { - // - // host ip ip ... gw - // - break; - } - - VarArg = VarArg->Next; - AddrCnt++; - } - - if (AddrCnt == 0) { - return EFI_INVALID_PARAMETER; - } - - AddrBuf = AllocateZeroPool (AddrCnt * sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)); - ASSERT (AddrBuf != NULL); - - AddrCnt = 0; - VarArg = *Arg; - Status = EFI_SUCCESS; - - // - // Go through the list to fill in the EFI_IP6_CONFIG_MANUAL_ADDRESS structure. - // - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { - - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); - - if (EFI_ERROR (Status)) { - break; - } - - // - // If prefix length is not set, set it as Zero here. In the IfConfigSetInterfaceInfo() - // Zero prefix, length will be transfered to default prefix length. - // - if (Prefix == 0xFF) { - Prefix = 0; - } - AddrBuf[AddrCnt].IsAnycast = FALSE; - AddrBuf[AddrCnt].PrefixLength = Prefix; - IP6_COPY_ADDRESS (&AddrBuf[AddrCnt].Address, &Address); - VarArg = VarArg->Next; - AddrCnt++; - } - - *Arg = VarArg; - - if (EFI_ERROR (Status) && (Status != EFI_INVALID_PARAMETER)) { - goto ON_ERROR; - } - - *Buf = AddrBuf; - *BufSize = AddrCnt * sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS); - - return EFI_SUCCESS; - -ON_ERROR: - - FreePool (AddrBuf); - return Status; -} - -/** - Pick up gw/dns IPv6 address in string format from Args with "-s" option and convert it to EFI_IPv6_ADDRESS format. - - @param[in, out] Arg The pointer of the address of ARG_LIST that save Args with the "-s" option. - @param[out] Buf The pointer of the address of EFI_IPv6_ADDRESS. - @param[out] BufSize The pointer of BufSize that describes the size of Buf in bytes. - - @retval EFI_SUCCESS The conversion is successful. - @retval Others Doesn't find the host address, or it is an invalid IPv6 address in string format. - -**/ -EFI_STATUS -IfConfig6ParseGwDnsAddressList ( - IN OUT ARG_LIST **Arg, - OUT EFI_IPv6_ADDRESS **Buf, - OUT UINTN *BufSize - ) -{ - EFI_STATUS Status; - EFI_IPv6_ADDRESS *AddrBuf; - ARG_LIST *VarArg; - EFI_IPv6_ADDRESS Address; - UINT8 Prefix; - UINT8 AddrCnt; - - AddrCnt = 0; - *BufSize = 0; - *Buf = NULL; - VarArg = *Arg; - Status = EFI_SUCCESS; - - // - // Go through the list to check the correctness of input gw/dns address. - // - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { - - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); - - if (EFI_ERROR (Status)) { - // - // gw ip ip ... host - // - break; - } - - VarArg = VarArg->Next; - AddrCnt++; - } - - if (AddrCnt == 0) { - return EFI_INVALID_PARAMETER; - } - - AddrBuf = AllocateZeroPool (AddrCnt * sizeof (EFI_IPv6_ADDRESS)); - ASSERT (AddrBuf != NULL); - - AddrCnt = 0; - VarArg = *Arg; - Status = EFI_SUCCESS; - - // - // Go through the list to fill in the EFI_IPv6_ADDRESS structure. - // - while ((!EFI_ERROR (Status)) && (VarArg != NULL)) { - - Status = NetLibStrToIp6andPrefix (VarArg->Arg, &Address, &Prefix); - - if (EFI_ERROR (Status)) { - break; - } - - IP6_COPY_ADDRESS (&AddrBuf[AddrCnt], &Address); - - VarArg = VarArg->Next; - AddrCnt++; - } - - *Arg = VarArg; - - if (EFI_ERROR (Status) && (Status != EFI_INVALID_PARAMETER)) { - goto ON_ERROR; - } - - *Buf = AddrBuf; - *BufSize = AddrCnt * sizeof (EFI_IPv6_ADDRESS); - - return EFI_SUCCESS; - -ON_ERROR: - - FreePool (AddrBuf); - return Status; -} - -/** - Parse InterfaceId in string format from Args with the "-s" option and convert it to EFI_IP6_CONFIG_INTERFACE_ID format. - - @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option. - @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID. - - @retval EFI_SUCCESS The get status processed successfullly. - @retval EFI_INVALID_PARAMETER The get status process failed. - -**/ -EFI_STATUS -IfConfig6ParseInterfaceId ( - IN OUT ARG_LIST **Arg, - OUT EFI_IP6_CONFIG_INTERFACE_ID **IfId - ) -{ - UINT8 Index; - UINT8 NodeVal; - CHAR16 *IdStr; - - if (*Arg == NULL) { - return EFI_INVALID_PARAMETER; - } - - Index = 0; - IdStr = (*Arg)->Arg; - ASSERT (IfId != NULL); - *IfId = AllocateZeroPool (sizeof (EFI_IP6_CONFIG_INTERFACE_ID)); - ASSERT (*IfId != NULL); - - while ((*IdStr != L'\0') && (Index < 8)) { - - NodeVal = 0; - while ((*IdStr != L':') && (*IdStr != L'\0')) { - - if ((*IdStr <= L'F') && (*IdStr >= L'A')) { - NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'A' + 10); - } else if ((*IdStr <= L'f') && (*IdStr >= L'a')) { - NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'a' + 10); - } else if ((*IdStr <= L'9') && (*IdStr >= L'0')) { - NodeVal = (UINT8)((NodeVal << 4) + *IdStr - L'0'); - } else { - FreePool (*IfId); - return EFI_INVALID_PARAMETER; - } - - IdStr++; - } - - (*IfId)->Id[Index++] = NodeVal; - - if (*IdStr == L':') { - IdStr++; - } - } - - *Arg = (*Arg)->Next; - return EFI_SUCCESS; -} - -/** - Parse dad in string format from Args with the "-s" option and convert it to UINT32 format. - - @param[in, out] Arg The pointer of the address of ARG_LIST that saves Args with the "-s" option. - @param[out] Xmits The pointer of Xmits. - - @retval EFI_SUCCESS The get status processed successfully. - @retval others The get status process failed. - -**/ -EFI_STATUS -IfConfig6ParseDadXmits ( - IN OUT ARG_LIST **Arg, - OUT UINT32 *Xmits - ) -{ - CHAR16 *ValStr; - - if (*Arg == NULL) { - return EFI_INVALID_PARAMETER; - } - - ValStr = (*Arg)->Arg; - *Xmits = 0; - - while (*ValStr != L'\0') { - - if ((*ValStr <= L'9') && (*ValStr >= L'0')) { - - *Xmits = (*Xmits * 10) + (*ValStr - L'0'); - - } else { - - return EFI_INVALID_PARAMETER; - } - - ValStr++; - } - - *Arg = (*Arg)->Next; - return EFI_SUCCESS; -} - -/** - The get current status of all handles. - - @param[in] ImageHandle The handle of ImageHandle. - @param[in] IfName The pointer of IfName(interface name). - @param[in] IfList The pointer of IfList(interface list). - - @retval EFI_SUCCESS The get status processed successfully. - @retval others The get status process failed. - -**/ -EFI_STATUS -IfConfig6GetInterfaceInfo ( - IN EFI_HANDLE ImageHandle, - IN CHAR16 *IfName, - IN LIST_ENTRY *IfList - ) -{ - EFI_STATUS Status; - UINTN HandleIndex; - UINTN HandleNum; - EFI_HANDLE *HandleBuffer; - EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; - IFCONFIG6_INTERFACE_CB *IfCb; - UINTN DataSize; - - HandleBuffer = NULL; - HandleNum = 0; - - IfInfo = NULL; - IfCb = NULL; - - // - // Locate all the handles with ip6 service binding protocol. - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiIp6ServiceBindingProtocolGuid, - NULL, - &HandleNum, - &HandleBuffer - ); - if (EFI_ERROR (Status) || (HandleNum == 0)) { - return EFI_ABORTED; - } - - // - // Enumerate all handles that installed with ip6 service binding protocol. - // - for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) { - IfCb = NULL; - IfInfo = NULL; - DataSize = 0; - - // - // Ip6config protocol and ip6 service binding protocol are installed - // on the same handle. - // - ASSERT (HandleBuffer != NULL); - Status = gBS->HandleProtocol ( - HandleBuffer[HandleIndex], - &gEfiIp6ConfigProtocolGuid, - (VOID **) &Ip6Cfg - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - // - // Get the interface information size. - // - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeInterfaceInfo, - &DataSize, - NULL - ); - - if (Status != EFI_BUFFER_TOO_SMALL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - - IfInfo = AllocateZeroPool (DataSize); - - if (IfInfo == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_ERROR; - } - // - // Get the interface info. - // - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeInterfaceInfo, - &DataSize, - IfInfo - ); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - // - // Check the interface name if required. - // - if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) != 0)) { - FreePool (IfInfo); - continue; - } - - DataSize = 0; - // - // Get the size of dns server list. - // - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeDnsServer, - &DataSize, - NULL - ); - - if ((Status != EFI_BUFFER_TOO_SMALL) && (Status != EFI_NOT_FOUND)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - - IfCb = AllocateZeroPool (sizeof (IFCONFIG6_INTERFACE_CB) + DataSize); - - if (IfCb == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_ERROR; - } - - IfCb->NicHandle = HandleBuffer[HandleIndex]; - IfCb->IfInfo = IfInfo; - IfCb->IfCfg = Ip6Cfg; - IfCb->DnsCnt = (UINT32) (DataSize / sizeof (EFI_IPv6_ADDRESS)); - - // - // Get the dns server list if has. - // - if (DataSize > 0) { - - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeDnsServer, - &DataSize, - IfCb->DnsAddr - ); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - } - // - // Get the interface id if has. - // - DataSize = sizeof (EFI_IP6_CONFIG_INTERFACE_ID); - IfCb->IfId = AllocateZeroPool (DataSize); - - if (IfCb->IfId == NULL) { - goto ON_ERROR; - } - - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeAltInterfaceId, - &DataSize, - IfCb->IfId - ); - - if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - - if (Status == EFI_NOT_FOUND) { - FreePool (IfCb->IfId); - IfCb->IfId = NULL; - } - // - // Get the config policy. - // - DataSize = sizeof (EFI_IP6_CONFIG_POLICY); - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypePolicy, - &DataSize, - &IfCb->Policy - ); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - // - // Get the dad transmits. - // - DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS); - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeDupAddrDetectTransmits, - &DataSize, - &IfCb->Xmits - ); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - - InsertTailList (IfList, &IfCb->Link); - - if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) == 0)) { - // - // Only need the appointed interface, keep the allocated buffer. - // - IfCb = NULL; - IfInfo = NULL; - break; - } - } - - if (HandleBuffer != NULL) { - FreePool (HandleBuffer); - } - - return EFI_SUCCESS; - -ON_ERROR: - - if (IfInfo != NULL) { - FreePool (IfInfo); - } - - if (IfCb != NULL) { - if (IfCb->IfId != NULL) { - FreePool (IfCb->IfId); - } - - FreePool (IfCb); - } - - return Status; -} - -/** - The list process of the IfConfig6 application. - - @param[in] IfList The pointer of IfList(interface list). - - @retval EFI_SUCCESS The IfConfig6 list processed successfully. - @retval others The IfConfig6 list process failed. - -**/ -EFI_STATUS -IfConfig6ShowInterfaceInfo ( - IN LIST_ENTRY *IfList - ) -{ - EFI_STATUS Status; - LIST_ENTRY *Entry; - IFCONFIG6_INTERFACE_CB *IfCb; - UINTN Index; - - Entry = IfList->ForwardLink; - Status = EFI_SUCCESS; - - if (IsListEmpty (IfList)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle); - } - - // - // Go through the interface list. - // - while (Entry != IfList) { - - IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link); - - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK), mHiiHandle); - - // - // Print interface name. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IF_NAME), mHiiHandle, IfCb->IfInfo->Name); - - // - // Print interface config policy. - // - if (IfCb->Policy == Ip6ConfigPolicyAutomatic) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_AUTO), mHiiHandle); - } else { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_POLICY_MAN), mHiiHandle); - } - - // - // Print dad transmit. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_DAD_TRANSMITS), mHiiHandle, IfCb->Xmits); - - // - // Print interface id if has. - // - if (IfCb->IfId != NULL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD), mHiiHandle); - - IfConfig6PrintMacAddr ( - IfCb->IfId->Id, - 8 - ); - } - // - // Print mac address of the interface. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_MAC_ADDR_HEAD), mHiiHandle); - - IfConfig6PrintMacAddr ( - IfCb->IfInfo->HwAddress.Addr, - IfCb->IfInfo->HwAddressSize - ); - - // - // Print ip addresses list of the interface. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_IP_ADDR_HEAD), mHiiHandle); - - for (Index = 0; Index < IfCb->IfInfo->AddressInfoCount; Index++) { - IfConfig6PrintIpAddr ( - &IfCb->IfInfo->AddressInfo[Index].Address, - &IfCb->IfInfo->AddressInfo[Index].PrefixLength - ); - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); - } - - // - // Print dns server addresses list of the interface if has. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_DNS_ADDR_HEAD), mHiiHandle); - - for (Index = 0; Index < IfCb->DnsCnt; Index++) { - IfConfig6PrintIpAddr ( - &IfCb->DnsAddr[Index], - NULL - ); - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); - } - - // - // Print route table of the interface if has. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_ROUTE_HEAD), mHiiHandle); - - for (Index = 0; Index < IfCb->IfInfo->RouteCount; Index++) { - IfConfig6PrintIpAddr ( - &IfCb->IfInfo->RouteTable[Index].Destination, - &IfCb->IfInfo->RouteTable[Index].PrefixLength - ); - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_JOINT), mHiiHandle); - - IfConfig6PrintIpAddr ( - &IfCb->IfInfo->RouteTable[Index].Gateway, - NULL - ); - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), mHiiHandle); - } - - Entry = Entry->ForwardLink; - } - - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK), mHiiHandle); - - return Status; -} - -/** - The clean process of the IfConfig6 application. - - @param[in] IfList The pointer of IfList(interface list). - - @retval EFI_SUCCESS The IfConfig6 clean processed successfully. - @retval others The IfConfig6 clean process failed. - -**/ -EFI_STATUS -IfConfig6ClearInterfaceInfo ( - IN LIST_ENTRY *IfList - ) -{ - EFI_STATUS Status; - LIST_ENTRY *Entry; - IFCONFIG6_INTERFACE_CB *IfCb; - EFI_IP6_CONFIG_POLICY Policy; - - Policy = Ip6ConfigPolicyAutomatic; - Entry = IfList->ForwardLink; - Status = EFI_SUCCESS; - - if (IsListEmpty (IfList)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle); - } - - // - // Go through the interface list. - // - while (Entry != IfList) { - - IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link); - - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypePolicy, - sizeof (EFI_IP6_CONFIG_POLICY), - &Policy - ); - - if (EFI_ERROR (Status)) { - break; - } - - Entry = Entry->ForwardLink; - } - - return Status; -} - -/** - The set process of the IfConfig6 application. - - @param[in] IfList The pointer of IfList(interface list). - @param[in] VarArg The pointer of ARG_LIST(Args with "-s" option). - - @retval EFI_SUCCESS The IfConfig6 set processed successfully. - @retval others The IfConfig6 set process failed. - -**/ -EFI_STATUS -IfConfig6SetInterfaceInfo ( - IN LIST_ENTRY *IfList, - IN ARG_LIST *VarArg - ) -{ - EFI_STATUS Status; - IFCONFIG6_INTERFACE_CB *IfCb; - EFI_IP6_CONFIG_MANUAL_ADDRESS *CfgManAddr; - EFI_IPv6_ADDRESS *CfgAddr; - UINTN AddrSize; - EFI_IP6_CONFIG_INTERFACE_ID *InterfaceId; - UINT32 DadXmits; - UINT32 CurDadXmits; - UINTN CurDadXmitsLen; - EFI_IP6_CONFIG_POLICY Policy; - - VAR_CHECK_CODE CheckCode; - EFI_EVENT TimeOutEvt; - EFI_EVENT MappedEvt; - BOOLEAN IsAddressOk; - - UINTN DataSize; - UINT32 Index; - UINT32 Index2; - BOOLEAN IsAddressSet; - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; - - CfgManAddr = NULL; - CfgAddr = NULL; - TimeOutEvt = NULL; - MappedEvt = NULL; - IfInfo = NULL; - InterfaceId = NULL; - CurDadXmits = 0; - - if (IsListEmpty (IfList)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_INTERFACE), mHiiHandle); - return EFI_INVALID_PARAMETER; - } - // - // Make sure to set only one interface each time. - // - IfCb = BASE_CR (IfList->ForwardLink, IFCONFIG6_INTERFACE_CB, Link); - Status = EFI_SUCCESS; - - // - // Initialize check list mechanism. - // - CheckCode = IfConfig6RetriveCheckListByName( - NULL, - NULL, - TRUE - ); - - // - // Create events & timers for asynchronous settings. - // - Status = gBS->CreateEvent ( - EVT_TIMER, - TPL_CALLBACK, - NULL, - NULL, - &TimeOutEvt - ); - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - IfConfig6ManualAddressNotify, - &IsAddressOk, - &MappedEvt - ); - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - // - // Parse the setting variables. - // - while (VarArg != NULL) { - // - // Check invalid parameters (duplication & unknown & conflict). - // - CheckCode = IfConfig6RetriveCheckListByName( - mSetCheckList, - VarArg->Arg, - FALSE - ); - - if (VarCheckOk != CheckCode) { - switch (CheckCode) { - case VarCheckDuplicate: - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_DUPLICATE_COMMAND), mHiiHandle, VarArg->Arg); - break; - - case VarCheckConflict: - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_CONFLICT_COMMAND), mHiiHandle, VarArg->Arg); - break; - - case VarCheckUnknown: - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_UNKNOWN_COMMAND), mHiiHandle, VarArg->Arg); - break; - - default: - break; - } - - VarArg = VarArg->Next; - continue; - } - // - // Process valid variables. - // - if (StrCmp(VarArg->Arg, L"auto") == 0) { - // - // Set automaic config policy - // - Policy = Ip6ConfigPolicyAutomatic; - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypePolicy, - sizeof (EFI_IP6_CONFIG_POLICY), - &Policy - ); - - if (EFI_ERROR(Status)) { - goto ON_EXIT; - } - - VarArg= VarArg->Next; - - } else if (StrCmp (VarArg->Arg, L"man") == 0) { - // - // Set manual config policy. - // - Policy = Ip6ConfigPolicyManual; - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypePolicy, - sizeof (EFI_IP6_CONFIG_POLICY), - &Policy - ); - - if (EFI_ERROR(Status)) { - goto ON_EXIT; - } - - VarArg= VarArg->Next; - - } else if (StrCmp (VarArg->Arg, L"host") == 0) { - // - // Parse till the next tag or the end of command line. - // - VarArg = VarArg->Next; - Status = IfConfig6ParseManualAddressList ( - &VarArg, - &CfgManAddr, - &AddrSize - ); - - if (EFI_ERROR (Status)) { - if (Status == EFI_INVALID_PARAMETER) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"host"); - continue; - } else { - goto ON_EXIT; - } - } - // - // Set static host ip6 address list. - // This is a asynchronous process. - // - IsAddressOk = FALSE; - - Status = IfCb->IfCfg->RegisterDataNotify ( - IfCb->IfCfg, - Ip6ConfigDataTypeManualAddress, - MappedEvt - ); - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeManualAddress, - AddrSize, - CfgManAddr - ); - - if (Status == EFI_NOT_READY) { - // - // Get current dad transmits count. - // - CurDadXmitsLen = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS); - IfCb->IfCfg->GetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeDupAddrDetectTransmits, - &CurDadXmitsLen, - &CurDadXmits - ); - - gBS->SetTimer (TimeOutEvt, TimerRelative, 50000000 + 10000000 * CurDadXmits); - - while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) { - if (IsAddressOk) { - Status = EFI_SUCCESS; - break; - } - } - } - - IfCb->IfCfg->UnregisterDataNotify ( - IfCb->IfCfg, - Ip6ConfigDataTypeManualAddress, - MappedEvt - ); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_MAN_HOST), mHiiHandle, Status); - goto ON_EXIT; - } - - // - // Check whether the address is set successfully. - // - DataSize = 0; - - Status = IfCb->IfCfg->GetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeInterfaceInfo, - &DataSize, - NULL - ); - - if (Status != EFI_BUFFER_TOO_SMALL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_EXIT; - } - - IfInfo = AllocateZeroPool (DataSize); - - if (IfInfo == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } - - Status = IfCb->IfCfg->GetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeInterfaceInfo, - &DataSize, - IfInfo - ); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_EXIT; - } - - for ( Index = 0; Index < (UINTN) (AddrSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)); Index++) { - IsAddressSet = FALSE; - // - // By default, the prefix length 0 is regarded as 64. - // - if (CfgManAddr[Index].PrefixLength == 0) { - CfgManAddr[Index].PrefixLength = 64; - } - - for (Index2 = 0; Index2 < IfInfo->AddressInfoCount; Index2++) { - if (EFI_IP6_EQUAL (&IfInfo->AddressInfo[Index2].Address, &CfgManAddr[Index].Address) && - (IfInfo->AddressInfo[Index2].PrefixLength == CfgManAddr[Index].PrefixLength)) { - IsAddressSet = TRUE; - break; - } - } - - if (!IsAddressSet) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_ADDRESS_FAILED), mHiiHandle); - IfConfig6PrintIpAddr ( - &CfgManAddr[Index].Address, - &CfgManAddr[Index].PrefixLength - ); - } - } - - } else if (StrCmp (VarArg->Arg, L"gw") == 0) { - // - // Parse till the next tag or the end of command line. - // - VarArg = VarArg->Next; - Status = IfConfig6ParseGwDnsAddressList ( - &VarArg, - &CfgAddr, - &AddrSize - ); - - if (EFI_ERROR (Status)) { - if (Status == EFI_INVALID_PARAMETER) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"gw"); - continue; - } else { - goto ON_EXIT; - } - } - // - // Set static gateway ip6 address list. - // - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeGateway, - AddrSize, - CfgAddr - ); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - } else if (StrCmp (VarArg->Arg, L"dns") == 0) { - // - // Parse till the next tag or the end of command line. - // - VarArg = VarArg->Next; - Status = IfConfig6ParseGwDnsAddressList ( - &VarArg, - &CfgAddr, - &AddrSize - ); - - if (EFI_ERROR (Status)) { - if (Status == EFI_INVALID_PARAMETER) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_ARGUMENTS), mHiiHandle, L"dns"); - continue; - } else { - goto ON_EXIT; - } - } - // - // Set static dhs server ip6 address list. - // - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeDnsServer, - AddrSize, - CfgAddr - ); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - } else if (StrCmp (VarArg->Arg, L"id") == 0) { - // - // Parse till the next tag or the end of command line. - // - VarArg = VarArg->Next; - Status = IfConfig6ParseInterfaceId (&VarArg, &InterfaceId); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - // - // Set alternative interface id. - // - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeAltInterfaceId, - sizeof (EFI_IP6_CONFIG_INTERFACE_ID), - InterfaceId - ); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - } else if (StrCmp (VarArg->Arg, L"dad") == 0) { - // - // Parse till the next tag or the end of command line. - // - VarArg = VarArg->Next; - Status = IfConfig6ParseDadXmits (&VarArg, &DadXmits); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - // - // Set dad transmits count. - // - Status = IfCb->IfCfg->SetData ( - IfCb->IfCfg, - Ip6ConfigDataTypeDupAddrDetectTransmits, - sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS), - &DadXmits - ); - - if (EFI_ERROR(Status)) { - goto ON_EXIT; - } - } - } - -ON_EXIT: - - if (CfgManAddr != NULL) { - FreePool (CfgManAddr); - } - - if (CfgAddr != NULL) { - FreePool (CfgAddr); - } - - if (MappedEvt != NULL) { - gBS->CloseEvent (MappedEvt); - } - - if (TimeOutEvt != NULL) { - gBS->CloseEvent (TimeOutEvt); - } - - if (IfInfo != NULL) { - FreePool (IfInfo); - } - - return Status; - -} - -/** - The IfConfig6 main process. - - @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA. - - @retval EFI_SUCCESS IfConfig6 processed successfully. - @retval others The IfConfig6 process failed. - -**/ -EFI_STATUS -IfConfig6 ( - IN IFCONFIG6_PRIVATE_DATA *Private - ) -{ - EFI_STATUS Status; - - // - // Get configure information of all interfaces. - // - Status = IfConfig6GetInterfaceInfo ( - Private->ImageHandle, - Private->IfName, - &Private->IfList - ); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - switch (Private->OpCode) { - case IfConfig6OpList: - Status = IfConfig6ShowInterfaceInfo (&Private->IfList); - break; - - case IfConfig6OpClear: - Status = IfConfig6ClearInterfaceInfo (&Private->IfList); - break; - - case IfConfig6OpSet: - Status = IfConfig6SetInterfaceInfo (&Private->IfList, Private->VarArg); - break; - - default: - Status = EFI_ABORTED; - } - -ON_EXIT: - - return Status; -} - -/** - The IfConfig6 cleanup process, free the allocated memory. - - @param[in] Private The pointer of IFCONFIG6_PRIVATE_DATA. - -**/ -VOID -IfConfig6Cleanup ( - IN IFCONFIG6_PRIVATE_DATA *Private - ) -{ - LIST_ENTRY *Entry; - LIST_ENTRY *NextEntry; - IFCONFIG6_INTERFACE_CB *IfCb; - ARG_LIST *ArgNode; - ARG_LIST *ArgHead; - - ASSERT (Private != NULL); - - // - // Clean the list which save the set config Args. - // - if (Private->VarArg != NULL) { - ArgHead = Private->VarArg; - - while (ArgHead->Next != NULL) { - ArgNode = ArgHead->Next; - FreePool (ArgHead); - ArgHead = ArgNode; - } - - FreePool (ArgHead); - } - - if (Private->IfName != NULL) - FreePool (Private->IfName); - - - // - // Clean the IFCONFIG6_INTERFACE_CB list. - // - Entry = Private->IfList.ForwardLink; - NextEntry = Entry->ForwardLink; - - while (Entry != &Private->IfList) { - - IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link); - - RemoveEntryList (&IfCb->Link); - - if (IfCb->IfId != NULL) { - - FreePool (IfCb->IfId); - } - - if (IfCb->IfInfo != NULL) { - - FreePool (IfCb->IfInfo); - } - - FreePool (IfCb); - - Entry = NextEntry; - NextEntry = Entry->ForwardLink; - } - - FreePool (Private); -} - -/** - This is the declaration of an EFI image entry point. This entry point is - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, including - both device drivers and bus drivers. - - The entry point for the IfConfig6 application which parses the command line input and calls the IfConfig6 process. - - @param[in] ImageHandle The image handle of this application. - @param[in] SystemTable The pointer to the EFI System Table. - - @retval EFI_SUCCESS The operation completed successfully. - @retval Others Some errors occur. - -**/ -EFI_STATUS -EFIAPI -IfConfig6Initialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - IFCONFIG6_PRIVATE_DATA *Private; - EFI_HII_PACKAGE_LIST_HEADER *PackageList; - LIST_ENTRY *ParamPackage; - CONST CHAR16 *ValueStr; - ARG_LIST *ArgList; - CHAR16 *ProblemParam; - CHAR16 *Str; - - Private = NULL; - - // - // Retrieve HII package list from ImageHandle - // - Status = gBS->OpenProtocol ( - ImageHandle, - &gEfiHiiPackageListProtocolGuid, - (VOID **) &PackageList, - ImageHandle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Publish HII package list to HII Database. - // - Status = gHiiDatabase->NewPackageList ( - gHiiDatabase, - PackageList, - NULL, - &mHiiHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } - - ASSERT (mHiiHandle != NULL); - - Status = ShellCommandLineParseEx (mIfConfig6CheckList, &ParamPackage, &ProblemParam, TRUE, FALSE); - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_COMMAND), mHiiHandle, ProblemParam); - goto ON_EXIT; - } - - // - // To handle no option. - // - if (!ShellCommandLineGetFlag (ParamPackage, L"-r") && !ShellCommandLineGetFlag (ParamPackage, L"-s") && - !ShellCommandLineGetFlag (ParamPackage, L"-l")) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_LACK_OPTION), mHiiHandle); - goto ON_EXIT; - } - // - // To handle conflict options. - // - if (((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-s"))) || - ((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-l"))) || - ((ShellCommandLineGetFlag (ParamPackage, L"-s")) && (ShellCommandLineGetFlag (ParamPackage, L"-l")))) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_CONFLICT_OPTIONS), mHiiHandle); - goto ON_EXIT; - } - - Status = EFI_INVALID_PARAMETER; - - Private = AllocateZeroPool (sizeof (IFCONFIG6_PRIVATE_DATA)); - - if (Private == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } - - InitializeListHead (&Private->IfList); - - // - // To get interface name for the list option. - // - if (ShellCommandLineGetFlag (ParamPackage, L"-l")) { - Private->OpCode = IfConfig6OpList; - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l"); - if (ValueStr != NULL) { - Str = AllocateCopyPool (StrSize (ValueStr), ValueStr); - ASSERT (Str != NULL); - Private->IfName = Str; - } - } - // - // To get interface name for the clear option. - // - if (ShellCommandLineGetFlag (ParamPackage, L"-r")) { - Private->OpCode = IfConfig6OpClear; - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-r"); - if (ValueStr != NULL) { - Str = AllocateCopyPool (StrSize (ValueStr), ValueStr); - ASSERT (Str != NULL); - Private->IfName = Str; - } - } - // - // To get interface name and corresponding Args for the set option. - // - if (ShellCommandLineGetFlag (ParamPackage, L"-s")) { - - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s"); - if (ValueStr == NULL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_INTERFACE), mHiiHandle); - goto ON_EXIT; - } - // - // To split the configuration into multi-section. - // - ArgList = SplitStrToList (ValueStr, L' '); - ASSERT (ArgList != NULL); - - Private->OpCode = IfConfig6OpSet; - Private->IfName = ArgList->Arg; - - Private->VarArg = ArgList->Next; - - if (Private->IfName == NULL || Private->VarArg == NULL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_COMMAND), mHiiHandle); - goto ON_EXIT; - } - } - // - // Main process of ifconfig6. - // - Status = IfConfig6 (Private); - -ON_EXIT: - - ShellCommandLineFreeVarList (ParamPackage); - HiiRemovePackages (mHiiHandle); - if (Private != NULL) - IfConfig6Cleanup (Private); - - return Status; -} - diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.h b/NetworkPkg/Application/IfConfig6/IfConfig6.h deleted file mode 100644 index f74897108d..0000000000 --- a/NetworkPkg/Application/IfConfig6/IfConfig6.h +++ /dev/null @@ -1,79 +0,0 @@ -/** @file - The interface function declaration of shell application IfConfig6. - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _IFCONFIG6_H_ -#define _IFCONFIG6_H_ - -enum { - IfConfig6OpList = 1, - IfConfig6OpSet = 2, - IfConfig6OpClear = 3 -}; - -typedef enum { - VarCheckReserved = -1, - VarCheckOk = 0, - VarCheckDuplicate, - VarCheckConflict, - VarCheckUnknown, - VarCheckLackValue, - VarCheckOutOfMem -} VAR_CHECK_CODE; - -typedef enum { - FlagTypeSingle = 0, - FlagTypeNeedVar, - FlagTypeNeedSet, - FlagTypeSkipUnknown -} VAR_CHECK_FLAG_TYPE; - -#define MACADDRMAXSIZE 32 -#define PREFIXMAXLEN 16 - -typedef struct _IFCONFIG6_INTERFACE_CB { - EFI_HANDLE NicHandle; - LIST_ENTRY Link; - EFI_IP6_CONFIG_PROTOCOL *IfCfg; - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; - EFI_IP6_CONFIG_INTERFACE_ID *IfId; - EFI_IP6_CONFIG_POLICY Policy; - EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS Xmits; - UINT32 DnsCnt; - EFI_IPv6_ADDRESS DnsAddr[1]; -} IFCONFIG6_INTERFACE_CB; - -typedef struct _ARG_LIST ARG_LIST; - -struct _ARG_LIST { - ARG_LIST *Next; - CHAR16 *Arg; -}; - -typedef struct _IFCONFIG6_PRIVATE_DATA { - EFI_HANDLE ImageHandle; - LIST_ENTRY IfList; - - UINT32 OpCode; - CHAR16 *IfName; - ARG_LIST *VarArg; -} IFCONFIG6_PRIVATE_DATA; - -typedef struct _VAR_CHECK_ITEM{ - CHAR16 *FlagStr; - UINT32 FlagID; - UINT32 ConflictMask; - VAR_CHECK_FLAG_TYPE FlagType; -} VAR_CHECK_ITEM; -#endif diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.inf b/NetworkPkg/Application/IfConfig6/IfConfig6.inf deleted file mode 100644 index 519b7c3279..0000000000 --- a/NetworkPkg/Application/IfConfig6/IfConfig6.inf +++ /dev/null @@ -1,67 +0,0 @@ -## @file -# Shell application IfConfig6. -# -# It is shell application which is used to set and get configurations for the -# EFI IPv6 network stack. -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> -# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010006 - BASE_NAME = IfConfig6 - FILE_GUID = 6F71926E-60CE-428d-AA58-A3D9FB879429 - MODULE_TYPE = UEFI_APPLICATION - VERSION_STRING = 1.0 - ENTRY_POINT = IfConfig6Initialize - MODULE_UNI_FILE = IfConfig6.uni - -# -# -# This flag specifies whether HII resource section is generated into PE image. -# - UEFI_HII_RESOURCE_SECTION = TRUE - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF -# -[Sources] - IfConfig6Strings.uni - IfConfig6.c - IfConfig6.h - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - ShellPkg/ShellPkg.dec - -[LibraryClasses] - BaseLib - UefiBootServicesTableLib - UefiApplicationEntryPoint - UefiHiiServicesLib - BaseMemoryLib - ShellLib - MemoryAllocationLib - DebugLib - HiiLib - NetLib - -[Protocols] - gEfiIp6ServiceBindingProtocolGuid ## CONSUMES - gEfiIp6ConfigProtocolGuid ## CONSUMES - gEfiHiiPackageListProtocolGuid ## CONSUMES - -[UserExtensions.TianoCore."ExtraFiles"] - IfConfig6Extra.uni diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6.uni b/NetworkPkg/Application/IfConfig6/IfConfig6.uni deleted file mode 100644 index e0ea589771..0000000000 --- a/NetworkPkg/Application/IfConfig6/IfConfig6.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file -// Shell application IfConfig6. -// -// It is shell application which is used to set and get configurations for the -// EFI IPv6 network stack. -// -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> -// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php. -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Shell application IfConfig6" - -#string STR_MODULE_DESCRIPTION #language en-US "It is shell application which is used to set and get configurations for the EFI IPv6 network stack." - diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni b/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni deleted file mode 100644 index 7d3f27a073..0000000000 --- a/NetworkPkg/Application/IfConfig6/IfConfig6Extra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// IfConfig6 Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR> -// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php. -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"IfConfig6 App" - - diff --git a/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni b/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni deleted file mode 100644 index 0c10bbdf78..0000000000 --- a/NetworkPkg/Application/IfConfig6/IfConfig6Strings.uni +++ /dev/null @@ -1,92 +0,0 @@ -/** @file - String definitions for the Shell application IfConfig6. - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions - of the BSD License which accompanies this distribution. The full - text of the license may be found at<BR> - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#langdef en-US "English" - -#string STR_IFCONFIG6_ERR_IP6CFG_GETDATA #language en-US "Ip6Config->GetData return %hr\n" -#string STR_IFCONFIG6_INFO_BREAK #language en-US "-----------------------------------------------------------------" -#string STR_IFCONFIG6_INFO_COLON #language en-US ":" -#string STR_IFCONFIG6_INFO_JOINT #language en-US " >> " -#string STR_IFCONFIG6_INFO_NEWLINE #language en-US "\n" -#string STR_IFCONFIG6_INFO_IF_NAME #language en-US "\n%Hname : %s%N\n" -#string STR_IFCONFIG6_INFO_POLICY_AUTO #language en-US "%Hpolicy : automatic%N\n" -#string STR_IFCONFIG6_INFO_POLICY_MAN #language en-US "%Hpolicy : manual%N\n" -#string STR_IFCONFIG6_INFO_DAD_TRANSMITS #language en-US "%Hdad xmits : %d%N\n" -#string STR_IFCONFIG6_INFO_INTERFACE_ID_HEAD #language en-US "%Hinterface id : %N" -#string STR_IFCONFIG6_INFO_MAC_ADDR_HEAD #language en-US "%Hmac addr : %N" -#string STR_IFCONFIG6_INFO_MAC_ADDR_BODY #language en-US "%02x" -#string STR_IFCONFIG6_INFO_IP_ADDR_HEAD #language en-US "\n%Hhost addr : %N\n" -#string STR_IFCONFIG6_INFO_DNS_ADDR_HEAD #language en-US "\n%Hdns server : %N\n" -#string STR_IFCONFIG6_INFO_IP_ADDR_BODY #language en-US "%02x" -#string STR_IFCONFIG6_INFO_IP_ADDR_BODY4BIT #language en-US "%x" -#string STR_IFCONFIG6_INFO_ROUTE_HEAD #language en-US "\n%Hroute table : %N\n" -#string STR_IFCONFIG6_INFO_PREFIX_LEN #language en-US "/%d" - -#string STR_IFCONFIG6_LINE_HELP #language en-US "Displays or modifies the IPv6 configuration" -#string STR_IFCONFIG6_ERR_LACK_INTERFACE #language en-US "Lack interface name.\n" - "Usage: IfConfig6 -s {ifname} {config options ...}\n" - "Example: IfConfig6 -s eth0 auto\n" -#string STR_IFCONFIG6_LACK_OPTION #language en-US "Flags lack. Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_CONFLICT_OPTIONS #language en-US "Flags conflict. Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_ERR_LACK_COMMAND #language en-US "Lack interface config option.\n" - "Usage: IfConfig6 -s {ifname} {config options ...}\n" - "Example: IfConfig6 -s eth0 auto\n" -#string STR_IFCONFIG6_ERR_INVALID_INTERFACE #language en-US "Invalid interface name.\n" - "Hint: Use {IfConfig6 -l} to check existing interface names.\n" -#string STR_IFCONFIG6_ERR_INVALID_COMMAND #language en-US "Invalid command. Bad command %H%s%N is skipped.\n" - "Hint: Incorrect option or arguments. Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_ERR_LACK_ARGUMENTS #language en-US "Lack arguments. Bad command %H%s%N is skipped.\n" - "Hint: Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_ERR_LACK_OPTION #language en-US "Lack options.\n" - "Hint: Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_ERR_MAN_HOST #language en-US "Manual address configuration failed. Please retry.\n" -#string STR_IFCONFIG6_ERR_DUPLICATE_COMMAND #language en-US "Duplicate commands. Bad command %H%s%N is skipped.\n" - "Hint: Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_ERR_CONFLICT_COMMAND #language en-US "Conflict commands. Bad command %H%s%N is skipped.\n" - "Hint: Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_ERR_UNKNOWN_COMMAND #language en-US "Unknown commands. Bad command %H%s%N is skipped.\n" - "Hint: Please type 'IfConfig6 -?' for help info.\n" -#string STR_IFCONFIG6_ERR_ADDRESS_FAILED #language en-US "It failed to set .\n" -#string STR_IFCONFIG6_INVALID_IP #language en-US "%IfConfig6: Invalid IP6 address, %s\n" - -#string STR_IFCONFIG6_HELP #language en-US "" -".TH IfConfig6 0 "Displays or modifies IPv6 configuration for network interface."\r\n" -".SH NAME\r\n" -"Displays or modifies IPv6 configuration for network interface.\r\n" -".SH SYNOPSIS\r\n" -" \r\n" -"IfConfig6 [-b] [-r {ifname}] [-l {ifname}] [-s {ifname} {command ...}] [-?]\r\n" -".SH OPTIONS\r\n" -" \r\n" -" -b (break) enable page break.\r\n" -" -r (renew) renew configuration of interface and set automatic policy.\r\n" -" -l (list) list the configuration of interface.\r\n" -" -s (set) set configuration of interface as follows.\r\n" -" |man/auto manual or automatic policy\r\n" -" |id {mac} alternative interface id.\r\n" -" |dad {num} dad transmits count.\r\n" -" |host{ip} static host ip address, must under manual policy.\r\n" -" |gw {ip} gateway ip address, must under manual policy.\r\n" -" |dns {ip} dns server ip address, must under manual policy.\r\n" -".SH EXAMPLES\r\n" -" \r\n" -"Examples:\r\n" -" IfConfig6 -l\r\n" -" IfConfig6 -b -l\r\n" -" IfConfig6 -r eth0\r\n" -" IfConfig6 -s eth0 auto dad 10\r\n" -" IfConfig6 -s eth0 man id ff:dd:aa:88:66:cc\r\n" -" IfConfig6 -s eth1 man host 2002::1/64 2002::2/64 gw 2002::3\r\n" diff --git a/NetworkPkg/Application/Ping6/Ia32/Tsc.c b/NetworkPkg/Application/Ping6/Ia32/Tsc.c deleted file mode 100644 index e2eae99077..0000000000 --- a/NetworkPkg/Application/Ping6/Ia32/Tsc.c +++ /dev/null @@ -1,28 +0,0 @@ -/** @file - The implement to read TSC in IA32 platform. - - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Library/BaseLib.h> - -/** - Reads and returns the current value of the Time Stamp Counter (TSC). - - @return The current value of TSC. - -**/ -UINT64 -ReadTime () -{ - return AsmReadTsc (); -} diff --git a/NetworkPkg/Application/Ping6/Ipf/Itc.c b/NetworkPkg/Application/Ping6/Ipf/Itc.c deleted file mode 100644 index 131e5c0e30..0000000000 --- a/NetworkPkg/Application/Ping6/Ipf/Itc.c +++ /dev/null @@ -1,28 +0,0 @@ -/** @file - The implement to read ITC in IA64 platform. - - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Library/BaseLib.h> - -/** - Reads and returns the current value of the Interval Timer Counter Register (ITC). - - @return The current value of ITC. - -**/ -UINT64 -ReadTime () -{ - return AsmReadItc (); -} diff --git a/NetworkPkg/Application/Ping6/Ping6.c b/NetworkPkg/Application/Ping6/Ping6.c deleted file mode 100644 index 66daac27be..0000000000 --- a/NetworkPkg/Application/Ping6/Ping6.c +++ /dev/null @@ -1,1200 +0,0 @@ -/** @file - The implementation for Ping6 application. - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Library/ShellLib.h> -#include <Library/BaseMemoryLib.h> -#include <Library/BaseLib.h> -#include <Library/MemoryAllocationLib.h> -#include <Library/DebugLib.h> -#include <Library/UefiBootServicesTableLib.h> -#include <Library/UefiHiiServicesLib.h> -#include <Library/HiiLib.h> -#include <Library/NetLib.h> - -#include <Protocol/Cpu.h> -#include <Protocol/ServiceBinding.h> -#include <Protocol/Ip6.h> -#include <Protocol/Ip6Config.h> - -#include "Ping6.h" - -// -// String token ID of Ping6 command help message text. -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringPing6HelpToken = STRING_TOKEN (STR_PING6_HELP); - -SHELL_PARAM_ITEM Ping6ParamList[] = { - { - L"-l", - TypeValue - }, - { - L"-n", - TypeValue - }, - { - L"-s", - TypeValue - }, - { - NULL, - TypeMax - }, -}; - -// -// Global Variables in Ping6 application. -// -EFI_HII_HANDLE mHiiHandle; -CONST CHAR16 *mIp6DstString; -CONST CHAR16 *mIp6SrcString; -UINT64 mFrequency = 0; -/** - Get and calculate the frequency in tick/ms. - The result is saved in the globle variable mFrequency - - @retval EFI_SUCCESS Calculated the frequency successfully. - @retval Others Failed to calculate the frequency. - -**/ -EFI_STATUS -Ping6GetFrequency ( - VOID - ) -{ - EFI_STATUS Status; - EFI_CPU_ARCH_PROTOCOL *Cpu; - UINT64 CurrentTick; - UINT64 TimerPeriod; - - Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &Cpu); - - if (EFI_ERROR (Status)) { - return Status; - } - - Status = Cpu->GetTimerValue (Cpu, 0, &CurrentTick, &TimerPeriod); - - if (EFI_ERROR (Status)) { - // - // For NT32 Simulator only. 358049 is a similar value to keep timer granularity. - // Set the timer period by ourselves. - // - TimerPeriod = (UINT64) NTTIMERPERIOD; - } - // - // The timer period is in femtosecond (1 femtosecond is 1e-15 second). - // So 1e+12 is divided by timer period to produce the freq in tick/ms. - // - mFrequency = DivU64x64Remainder (1000000000000ULL, TimerPeriod, NULL); - - return EFI_SUCCESS; -} - -/** - Get and calculate the duration in ms. - - @param[in] Begin The start point of time. - @param[in] End The end point of time. - - @return The duration in ms. - -**/ -UINT64 -Ping6CalculateTick ( - IN UINT64 Begin, - IN UINT64 End - ) -{ - ASSERT (End > Begin); - return DivU64x64Remainder (End - Begin, mFrequency, NULL); -} - -/** - Destroy IPING6_ICMP6_TX_INFO, and recollect the memory. - - @param[in] TxInfo The pointer to PING6_ICMP6_TX_INFO. - -**/ -VOID -Ping6DestroyTxInfo ( - IN PING6_ICMP6_TX_INFO *TxInfo - ) -{ - EFI_IP6_TRANSMIT_DATA *TxData; - EFI_IP6_FRAGMENT_DATA *FragData; - UINTN Index; - - ASSERT (TxInfo != NULL); - - if (TxInfo->Token != NULL) { - - if (TxInfo->Token->Event != NULL) { - gBS->CloseEvent (TxInfo->Token->Event); - } - - TxData = TxInfo->Token->Packet.TxData; - if (TxData != NULL) { - - if (TxData->OverrideData != NULL) { - FreePool (TxData->OverrideData); - } - - if (TxData->ExtHdrs != NULL) { - FreePool (TxData->ExtHdrs); - } - - for (Index = 0; Index < TxData->FragmentCount; Index++) { - FragData = TxData->FragmentTable[Index].FragmentBuffer; - if (FragData != NULL) { - FreePool (FragData); - } - } - } - - FreePool (TxInfo->Token); - } - - FreePool (TxInfo); -} - -/** - Match the request, and reply with SequenceNum/TimeStamp. - - @param[in] Private The pointer to PING6_PRIVATE_DATA. - @param[in] Packet The pointer to ICMP6_ECHO_REQUEST_REPLY. - - @retval EFI_SUCCESS The match is successful. - @retval EFI_NOT_FOUND The reply can't be matched with any request. - -**/ -EFI_STATUS -Ping6MatchEchoReply ( - IN PING6_PRIVATE_DATA *Private, - IN ICMP6_ECHO_REQUEST_REPLY *Packet - ) -{ - PING6_ICMP6_TX_INFO *TxInfo; - LIST_ENTRY *Entry; - LIST_ENTRY *NextEntry; - - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) { - TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link); - - if ((TxInfo->SequenceNum == Packet->SequenceNum) && (TxInfo->TimeStamp == Packet->TimeStamp)) { - Private->RxCount++; - RemoveEntryList (&TxInfo->Link); - Ping6DestroyTxInfo (TxInfo); - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} - -/** - The original intention is to send a request. - Currently, the application retransmits an icmp6 echo request packet - per second in sendnumber times that is specified by the user. - Because nothing can be done here, all things move to the timer rountine. - - @param[in] Event A EFI_EVENT type event. - @param[in] Context The pointer to Context. - -**/ -VOID -EFIAPI -Ping6OnEchoRequestSent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ -} - -/** - receive reply, match and print reply infomation. - - @param[in] Event A EFI_EVENT type event. - @param[in] Context The pointer to context. - -**/ -VOID -EFIAPI -Ping6OnEchoReplyReceived ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - PING6_PRIVATE_DATA *Private; - EFI_IP6_COMPLETION_TOKEN *RxToken; - EFI_IP6_RECEIVE_DATA *RxData; - ICMP6_ECHO_REQUEST_REPLY *Reply; - UINT32 PayLoad; - UINT64 Rtt; - CHAR8 Near; - - Private = (PING6_PRIVATE_DATA *) Context; - - if (Private->Status == EFI_ABORTED) { - return; - } - - RxToken = &Private->RxToken; - RxData = RxToken->Packet.RxData; - Reply = RxData->FragmentTable[0].FragmentBuffer; - PayLoad = RxData->DataLength; - - if (RxData->Header->NextHeader != IP6_ICMP) { - goto ON_EXIT; - } - - if (!IP6_IS_MULTICAST (&Private->DstAddress) && - !EFI_IP6_EQUAL (&RxData->Header->SourceAddress, &Private->DstAddress)) { - goto ON_EXIT; - } - - if ((Reply->Type != ICMP_V6_ECHO_REPLY) || (Reply->Code != 0)) { - goto ON_EXIT; - } - - if (PayLoad != Private->BufferSize) { - goto ON_EXIT; - } - // - // Check whether the reply matches the sent request before. - // - Status = Ping6MatchEchoReply (Private, Reply); - if (EFI_ERROR(Status)) { - goto ON_EXIT; - } - // - // Display statistics on this icmp6 echo reply packet. - // - Rtt = Ping6CalculateTick (Reply->TimeStamp, ReadTime ()); - if (Rtt != 0) { - Near = (CHAR8) '='; - } else { - Near = (CHAR8) '<'; - } - - Private->RttSum += Rtt; - Private->RttMin = Private->RttMin > Rtt ? Rtt : Private->RttMin; - Private->RttMax = Private->RttMax < Rtt ? Rtt : Private->RttMax; - - ShellPrintHiiEx ( - -1, - -1, - NULL, - STRING_TOKEN (STR_PING6_REPLY_INFO), - mHiiHandle, - PayLoad, - mIp6DstString, - Reply->SequenceNum, - RxData->Header->HopLimit, - Near, - Rtt - ); - -ON_EXIT: - - if (Private->RxCount < Private->SendNum) { - // - // Continue to receive icmp6 echo reply packets. - // - RxToken->Status = EFI_ABORTED; - - Status = Private->Ip6->Receive (Private->Ip6, RxToken); - - if (EFI_ERROR (Status)) { - Private->Status = EFI_ABORTED; - } - } else { - // - // All reply have already been received from the dest host. - // - Private->Status = EFI_SUCCESS; - } - // - // Singal to recycle the each rxdata here, not at the end of process. - // - gBS->SignalEvent (RxData->RecycleSignal); -} - -/** - Initial EFI_IP6_COMPLETION_TOKEN. - - @param[in] Private The pointer of PING6_PRIVATE_DATA. - @param[in] TimeStamp The TimeStamp of request. - @param[in] SequenceNum The SequenceNum of request. - - @return The pointer of EFI_IP6_COMPLETION_TOKEN. - -**/ -EFI_IP6_COMPLETION_TOKEN * -Ping6GenerateToken ( - IN PING6_PRIVATE_DATA *Private, - IN UINT64 TimeStamp, - IN UINT16 SequenceNum - ) -{ - EFI_STATUS Status; - EFI_IP6_COMPLETION_TOKEN *Token; - EFI_IP6_TRANSMIT_DATA *TxData; - ICMP6_ECHO_REQUEST_REPLY *Request; - - Request = AllocateZeroPool (Private->BufferSize); - - if (Request == NULL) { - return NULL; - } - // - // Assembly icmp6 echo request packet. - // - Request->Type = ICMP_V6_ECHO_REQUEST; - Request->Code = 0; - Request->SequenceNum = SequenceNum; - Request->TimeStamp = TimeStamp; - Request->Identifier = 0; - // - // Leave check sum to ip6 layer, since it has no idea of source address - // selection. - // - Request->Checksum = 0; - - TxData = AllocateZeroPool (sizeof (EFI_IP6_TRANSMIT_DATA)); - - if (TxData == NULL) { - FreePool (Request); - return NULL; - } - // - // Assembly ipv6 token for transmit. - // - TxData->OverrideData = 0; - TxData->ExtHdrsLength = 0; - TxData->ExtHdrs = NULL; - TxData->DataLength = Private->BufferSize; - TxData->FragmentCount = 1; - TxData->FragmentTable[0].FragmentBuffer = (VOID *) Request; - TxData->FragmentTable[0].FragmentLength = Private->BufferSize; - - Token = AllocateZeroPool (sizeof (EFI_IP6_COMPLETION_TOKEN)); - - if (Token == NULL) { - FreePool (Request); - FreePool (TxData); - return NULL; - } - - Token->Status = EFI_ABORTED; - Token->Packet.TxData = TxData; - - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - Ping6OnEchoRequestSent, - Private, - &Token->Event - ); - - if (EFI_ERROR (Status)) { - FreePool (Request); - FreePool (TxData); - FreePool (Token); - return NULL; - } - - return Token; -} - -/** - Transmit the EFI_IP6_COMPLETION_TOKEN. - - @param[in] Private The pointer of PING6_PRIVATE_DATA. - - @retval EFI_SUCCESS Transmitted successfully. - @retval EFI_OUT_OF_RESOURCES No memory is available on the platform. - @retval others Transmitted unsuccessfully. - -**/ -EFI_STATUS -Ping6SendEchoRequest ( - IN PING6_PRIVATE_DATA *Private - ) -{ - EFI_STATUS Status; - PING6_ICMP6_TX_INFO *TxInfo; - - TxInfo = AllocateZeroPool (sizeof (PING6_ICMP6_TX_INFO)); - - if (TxInfo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - TxInfo->TimeStamp = ReadTime (); - TxInfo->SequenceNum = (UINT16) (Private->TxCount + 1); - - TxInfo->Token = Ping6GenerateToken ( - Private, - TxInfo->TimeStamp, - TxInfo->SequenceNum - ); - - if (TxInfo->Token == NULL) { - Ping6DestroyTxInfo (TxInfo); - return EFI_OUT_OF_RESOURCES; - } - - Status = Private->Ip6->Transmit (Private->Ip6, TxInfo->Token); - - if (EFI_ERROR (Status)) { - Ping6DestroyTxInfo (TxInfo); - return Status; - } - - InsertTailList (&Private->TxList, &TxInfo->Link); - Private->TxCount++; - - return EFI_SUCCESS; -} - -/** - Place a completion token into the receive packet queue to receive the echo reply. - - @param[in] Private The pointer of PING6_PRIVATE_DATA. - - @retval EFI_SUCCESS Put the token into the receive packet queue successfully. - @retval others Put the token into the receive packet queue unsuccessfully. - -**/ -EFI_STATUS -Ping6ReceiveEchoReply ( - IN PING6_PRIVATE_DATA *Private - ) -{ - EFI_STATUS Status; - - ZeroMem (&Private->RxToken, sizeof (EFI_IP6_COMPLETION_TOKEN)); - - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - Ping6OnEchoReplyReceived, - Private, - &Private->RxToken.Event - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Private->RxToken.Status = EFI_NOT_READY; - - return Private->Ip6->Receive (Private->Ip6, &Private->RxToken); -} - -/** - Remove the timeout request from the list. - - @param[in] Event A EFI_EVENT type event. - @param[in] Context The pointer to Context. - -**/ -VOID -EFIAPI -Ping6OnTimerRoutine ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - PING6_PRIVATE_DATA *Private; - PING6_ICMP6_TX_INFO *TxInfo; - LIST_ENTRY *Entry; - LIST_ENTRY *NextEntry; - UINT64 Time; - - Private = (PING6_PRIVATE_DATA *) Context; - - // - // Retransmit icmp6 echo request packets per second in sendnumber times. - // - if (Private->TxCount < Private->SendNum) { - - Status = Ping6SendEchoRequest (Private); - if (Private->TxCount != 0){ - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_SEND_REQUEST), mHiiHandle, Private->TxCount + 1); - } - } - } - // - // Check whether any icmp6 echo request in the list timeout. - // - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) { - TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link); - Time = Ping6CalculateTick (TxInfo->TimeStamp, ReadTime ()); - - // - // Remove the timeout echo request from txlist. - // - if (Time > PING6_DEFAULT_TIMEOUT) { - - if (EFI_ERROR (TxInfo->Token->Status)) { - Private->Ip6->Cancel (Private->Ip6, TxInfo->Token); - } - // - // Remove the timeout icmp6 echo request from list. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_TIMEOUT), mHiiHandle, TxInfo->SequenceNum); - - RemoveEntryList (&TxInfo->Link); - Ping6DestroyTxInfo (TxInfo); - - if (IsListEmpty (&Private->TxList) && (Private->TxCount == Private->SendNum)) { - // - // All the left icmp6 echo request in the list timeout. - // - Private->Status = EFI_TIMEOUT; - } - } - } -} - -/** - Create a valid IP6 instance. - - @param[in] Private The pointer of PING6_PRIVATE_DATA. - - @retval EFI_SUCCESS Create a valid IP6 instance successfully. - @retval EFI_ABORTED Locate handle with ip6 service binding protocol unsuccessfully. - @retval EFI_INVALID_PARAMETER The source address is unspecified when the destination address is a link -ocal address. - @retval EFI_OUT_OF_RESOURCES No memory is available on the platform. - @retval EFI_NOT_FOUND The source address is not found. -**/ -EFI_STATUS -Ping6CreateIp6Instance ( - IN PING6_PRIVATE_DATA *Private - ) -{ - EFI_STATUS Status; - UINTN HandleIndex; - UINTN HandleNum; - EFI_HANDLE *HandleBuffer; - EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb; - EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; - EFI_IP6_CONFIG_DATA Ip6Config; - EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; - UINTN IfInfoSize; - EFI_IPv6_ADDRESS *Addr; - UINTN AddrIndex; - - HandleBuffer = NULL; - Ip6Sb = NULL; - IfInfo = NULL; - IfInfoSize = 0; - - // - // Locate all the handles with ip6 service binding protocol. - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiIp6ServiceBindingProtocolGuid, - NULL, - &HandleNum, - &HandleBuffer - ); - if (EFI_ERROR (Status) || (HandleNum == 0)) { - return EFI_ABORTED; - } - // - // Source address is required when pinging a link-local address on multi- - // interfaces host. - // - if (NetIp6IsLinkLocalAddr (&Private->DstAddress) && - NetIp6IsUnspecifiedAddr (&Private->SrcAddress) && - (HandleNum > 1)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_SOURCE), mHiiHandle); - Status = EFI_INVALID_PARAMETER; - goto ON_ERROR; - } - // - // For each ip6 protocol, check interface addresses list. - // - for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) { - - Ip6Sb = NULL; - IfInfo = NULL; - IfInfoSize = 0; - - Status = gBS->HandleProtocol ( - HandleBuffer[HandleIndex], - &gEfiIp6ServiceBindingProtocolGuid, - (VOID **) &Ip6Sb - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - if (NetIp6IsUnspecifiedAddr (&Private->SrcAddress)) { - // - // No need to match interface address. - // - break; - } else { - // - // Ip6config protocol and ip6 service binding protocol are installed - // on the same handle. - // - Status = gBS->HandleProtocol ( - HandleBuffer[HandleIndex], - &gEfiIp6ConfigProtocolGuid, - (VOID **) &Ip6Cfg - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - // - // Get the interface information size. - // - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeInterfaceInfo, - &IfInfoSize, - NULL - ); - - if (Status != EFI_BUFFER_TOO_SMALL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - - IfInfo = AllocateZeroPool (IfInfoSize); - - if (IfInfo == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_ERROR; - } - // - // Get the interface info. - // - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeInterfaceInfo, - &IfInfoSize, - IfInfo - ); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_IP6CFG_GETDATA), mHiiHandle, Status); - goto ON_ERROR; - } - // - // Check whether the source address is one of the interface addresses. - // - for (AddrIndex = 0; AddrIndex < IfInfo->AddressInfoCount; AddrIndex++) { - - Addr = &(IfInfo->AddressInfo[AddrIndex].Address); - if (EFI_IP6_EQUAL (&Private->SrcAddress, Addr)) { - // - // Match a certain interface address. - // - break; - } - } - - if (AddrIndex < IfInfo->AddressInfoCount) { - // - // Found a nic handle with right interface address. - // - break; - } - } - - FreePool (IfInfo); - IfInfo = NULL; - } - // - // No exact interface address matched. - // - - if (HandleIndex == HandleNum) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_SOURCE_NOT_FOUND), mHiiHandle, mIp6SrcString); - Status = EFI_NOT_FOUND; - goto ON_ERROR; - } - - Private->NicHandle = HandleBuffer[HandleIndex]; - - ASSERT (Ip6Sb != NULL); - Status = Ip6Sb->CreateChild (Ip6Sb, &Private->Ip6ChildHandle); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - Status = gBS->OpenProtocol ( - Private->Ip6ChildHandle, - &gEfiIp6ProtocolGuid, - (VOID **) &Private->Ip6, - Private->ImageHandle, - Private->Ip6ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - ZeroMem (&Ip6Config, sizeof (EFI_IP6_CONFIG_DATA)); - - // - // Configure the ip6 instance for icmp6 packet exchange. - // - Ip6Config.DefaultProtocol = 58; - Ip6Config.AcceptAnyProtocol = FALSE; - Ip6Config.AcceptIcmpErrors = TRUE; - Ip6Config.AcceptPromiscuous = FALSE; - Ip6Config.TrafficClass = 0; - Ip6Config.HopLimit = 128; - Ip6Config.FlowLabel = 0; - Ip6Config.ReceiveTimeout = 0; - Ip6Config.TransmitTimeout = 0; - - IP6_COPY_ADDRESS (&Ip6Config.StationAddress, &Private->SrcAddress); - - IP6_COPY_ADDRESS (&Ip6Config.DestinationAddress, &Private->DstAddress); - - Status = Private->Ip6->Configure (Private->Ip6, &Ip6Config); - - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_IP6_CONFIG), mHiiHandle, Status); - goto ON_ERROR; - } - - return EFI_SUCCESS; - -ON_ERROR: - if (HandleBuffer != NULL) { - FreePool (HandleBuffer); - } - - if (IfInfo != NULL) { - FreePool (IfInfo); - } - - if ((Ip6Sb != NULL) && (Private->Ip6ChildHandle != NULL)) { - Ip6Sb->DestroyChild (Ip6Sb, Private->Ip6ChildHandle); - } - - return Status; -} - -/** - Destroy the IP6 instance. - - @param[in] Private The pointer of PING6_PRIVATE_DATA. - -**/ -VOID -Ping6DestroyIp6Instance ( - IN PING6_PRIVATE_DATA *Private - ) -{ - EFI_STATUS Status; - EFI_SERVICE_BINDING_PROTOCOL *Ip6Sb; - - gBS->CloseProtocol ( - Private->Ip6ChildHandle, - &gEfiIp6ProtocolGuid, - Private->ImageHandle, - Private->Ip6ChildHandle - ); - - Status = gBS->HandleProtocol ( - Private->NicHandle, - &gEfiIp6ServiceBindingProtocolGuid, - (VOID **) &Ip6Sb - ); - - if (!EFI_ERROR(Status)) { - Ip6Sb->DestroyChild (Ip6Sb, Private->Ip6ChildHandle); - } -} - -/** - The Ping6 Process. - - @param[in] ImageHandle The firmware allocated handle for the UEFI image. - @param[in] SendNumber The send request count. - @param[in] BufferSize The send buffer size. - @param[in] SrcAddress The source IPv6 address. - @param[in] DstAddress The destination IPv6 address. - - @retval EFI_SUCCESS The ping6 processed successfullly. - @retval others The ping6 processed unsuccessfully. - -**/ -EFI_STATUS -Ping6 ( - IN EFI_HANDLE ImageHandle, - IN UINT32 SendNumber, - IN UINT32 BufferSize, - IN EFI_IPv6_ADDRESS *SrcAddress, - IN EFI_IPv6_ADDRESS *DstAddress - ) -{ - EFI_STATUS Status; - EFI_INPUT_KEY Key; - PING6_PRIVATE_DATA *Private; - PING6_ICMP6_TX_INFO *TxInfo; - LIST_ENTRY *Entry; - LIST_ENTRY *NextEntry; - - Private = AllocateZeroPool (sizeof (PING6_PRIVATE_DATA)); - - ASSERT (Private != NULL); - - Private->ImageHandle = ImageHandle; - Private->SendNum = SendNumber; - Private->BufferSize = BufferSize; - Private->RttMin = ~((UINT64 )(0x0)); - Private->Status = EFI_NOT_READY; - - InitializeListHead (&Private->TxList); - - IP6_COPY_ADDRESS (&Private->SrcAddress, SrcAddress); - IP6_COPY_ADDRESS (&Private->DstAddress, DstAddress); - - // - // Open and configure a ip6 instance for ping6. - // - Status = Ping6CreateIp6Instance (Private); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - // - // Print the command line itself. - // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_START), mHiiHandle, mIp6DstString, Private->BufferSize); - // - // Create a ipv6 token to receive the first icmp6 echo reply packet. - // - Status = Ping6ReceiveEchoReply (Private); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - // - // Create and start timer to send icmp6 echo request packet per second. - // - Status = gBS->CreateEvent ( - EVT_TIMER | EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - Ping6OnTimerRoutine, - Private, - &Private->Timer - ); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - // - // Create a ipv6 token to send the first icmp6 echo request packet. - // - Status = Ping6SendEchoRequest (Private); - // - // EFI_NOT_READY for IPsec is enable and IKE is not established. - // - if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) { - if(Status == EFI_NOT_FOUND) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_NOSOURCE_INDOMAIN), mHiiHandle, mIp6DstString); - } - - goto ON_EXIT; - } - - Status = gBS->SetTimer ( - Private->Timer, - TimerPeriodic, - PING6_ONE_SECOND - ); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - // - // Control the ping6 process by two factors: - // 1. Hot key - // 2. Private->Status - // 2.1. success means all icmp6 echo request packets get reply packets. - // 2.2. timeout means the last icmp6 echo reply request timeout to get reply. - // 2.3. noready means ping6 process is on-the-go. - // - while (Private->Status == EFI_NOT_READY) { - Private->Ip6->Poll (Private->Ip6); - - // - // Terminate the ping6 process by 'esc' or 'ctl-c'. - // - Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); - - if (!EFI_ERROR(Status)) { - if ((Key.UnicodeChar == 0x1b) || (Key.UnicodeChar == 0x03) || - ((Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_ESC))) { - goto ON_STAT; - } - } - } - -ON_STAT: - // - // Display the statistics in all. - // - gBS->SetTimer (Private->Timer, TimerCancel, 0); - - if (Private->TxCount != 0) { - ShellPrintHiiEx ( - -1, - -1, - NULL, - STRING_TOKEN (STR_PING6_STAT), - mHiiHandle, - Private->TxCount, - Private->RxCount, - (100 * (Private->TxCount - Private->RxCount)) / Private->TxCount, - Private->RttSum - ); - } - - if (Private->RxCount != 0) { - ShellPrintHiiEx ( - -1, - -1, - NULL, - STRING_TOKEN (STR_PING6_RTT), - mHiiHandle, - Private->RttMin, - Private->RttMax, - DivU64x64Remainder (Private->RttSum, Private->RxCount, NULL) - ); - } - -ON_EXIT: - - if (Private != NULL) { - Private->Status = EFI_ABORTED; - - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) { - TxInfo = BASE_CR (Entry, PING6_ICMP6_TX_INFO, Link); - - Status = Private->Ip6->Cancel (Private->Ip6, TxInfo->Token); - - RemoveEntryList (&TxInfo->Link); - Ping6DestroyTxInfo (TxInfo); - } - - if (Private->Timer != NULL) { - gBS->CloseEvent (Private->Timer); - } - - if (Private->Ip6 != NULL) { - Status = Private->Ip6->Cancel (Private->Ip6, &Private->RxToken); - } - - if (Private->RxToken.Event != NULL) { - gBS->CloseEvent (Private->RxToken.Event); - } - - if (Private->Ip6ChildHandle != NULL) { - Ping6DestroyIp6Instance (Private); - } - - FreePool (Private); - } - - return Status; -} - -/** - This is the declaration of an EFI image entry point. This entry point is - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, including - both device drivers and bus drivers. - - The entry point for the Ping6 application that parses the command line input and calls the Ping6 process. - - @param[in] ImageHandle The firmware allocated handle for the UEFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The operation completed successfully. - @retval EFI_INVALID_PARAMETETR Input parameters combination is invalid. - @retval Others Some errors occur. - -**/ -EFI_STATUS -EFIAPI -InitializePing6 ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_IPv6_ADDRESS DstAddress; - EFI_IPv6_ADDRESS SrcAddress; - UINT64 BufferSize; - UINTN SendNumber; - LIST_ENTRY *ParamPackage; - CONST CHAR16 *ValueStr; - CONST CHAR16 *ValueStrPtr; - UINTN NonOptionCount; - EFI_HII_PACKAGE_LIST_HEADER *PackageList; - - // - // Retrieve HII package list from ImageHandle - // - Status = gBS->OpenProtocol ( - ImageHandle, - &gEfiHiiPackageListProtocolGuid, - (VOID **) &PackageList, - ImageHandle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Publish HII package list to HII Database. - // - Status = gHiiDatabase->NewPackageList ( - gHiiDatabase, - PackageList, - NULL, - &mHiiHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } - - ASSERT (mHiiHandle != NULL); - - Status = ShellCommandLineParseEx (Ping6ParamList, &ParamPackage, NULL, TRUE, FALSE); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_INPUT), mHiiHandle); - goto ON_EXIT; - } - - SendNumber = 10; - BufferSize = 16; - - // - // Parse the parameter of count number. - // - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-n"); - ValueStrPtr = ValueStr; - if (ValueStr != NULL) { - SendNumber = ShellStrToUintn (ValueStrPtr); - - // - // ShellStrToUintn will return 0 when input is 0 or an invalid input string. - // - if ((SendNumber == 0) || (SendNumber > PING6_MAX_SEND_NUMBER)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_SEND_NUMBER), mHiiHandle, ValueStr); - Status = EFI_INVALID_PARAMETER; - goto ON_EXIT; - } - } - // - // Parse the parameter of buffer size. - // - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l"); - ValueStrPtr = ValueStr; - if (ValueStr != NULL) { - BufferSize = ShellStrToUintn (ValueStrPtr); - - // - // ShellStrToUintn will return 0 when input is 0 or an invalid input string. - // - if ((BufferSize < 16) || (BufferSize > PING6_MAX_BUFFER_SIZE)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_BUFFER_SIZE), mHiiHandle, ValueStr); - Status = EFI_INVALID_PARAMETER; - goto ON_EXIT; - } - } - - ZeroMem (&SrcAddress, sizeof (EFI_IPv6_ADDRESS)); - ZeroMem (&DstAddress, sizeof (EFI_IPv6_ADDRESS)); - - // - // Parse the parameter of source ip address. - // - ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s"); - ValueStrPtr = ValueStr; - if (ValueStr != NULL) { - mIp6SrcString = ValueStr; - Status = NetLibStrToIp6 (ValueStrPtr, &SrcAddress); - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_IP), mHiiHandle, ValueStr); - Status = EFI_INVALID_PARAMETER; - goto ON_EXIT; - } - } - // - // Parse the parameter of destination ip address. - // - NonOptionCount = ShellCommandLineGetCount(ParamPackage); - ValueStr = ShellCommandLineGetRawValue (ParamPackage, (UINT32)(NonOptionCount-1)); - if (NonOptionCount != 2) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_INPUT), mHiiHandle); - Status = EFI_INVALID_PARAMETER; - goto ON_EXIT; - } - ValueStrPtr = ValueStr; - if (ValueStr != NULL) { - mIp6DstString = ValueStr; - Status = NetLibStrToIp6 (ValueStrPtr, &DstAddress); - if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_INVALID_IP), mHiiHandle, ValueStr); - Status = EFI_INVALID_PARAMETER; - goto ON_EXIT; - } - } - // - // Get frequency to calculate the time from ticks. - // - Status = Ping6GetFrequency (); - - if (EFI_ERROR(Status)) { - goto ON_EXIT; - } - // - // Enter into ping6 process. - // - Status = Ping6 ( - ImageHandle, - (UINT32)SendNumber, - (UINT32)BufferSize, - &SrcAddress, - &DstAddress - ); - -ON_EXIT: - ShellCommandLineFreeVarList (ParamPackage); - HiiRemovePackages (mHiiHandle); - return Status; -} diff --git a/NetworkPkg/Application/Ping6/Ping6.h b/NetworkPkg/Application/Ping6/Ping6.h deleted file mode 100644 index 6f590af8c0..0000000000 --- a/NetworkPkg/Application/Ping6/Ping6.h +++ /dev/null @@ -1,87 +0,0 @@ -/** @file - The interface function declaration of shell application Ping6 (Ping for v6 series). - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _PING6_H_ -#define _PING6_H_ - -#define PING6_DEFAULT_TIMEOUT 5000 -#define PING6_MAX_SEND_NUMBER 10000 -#define PING6_MAX_BUFFER_SIZE 32768 -#define PING6_ONE_SECOND 10000000 - -// -// A similar amount of time that passes in femtoseconds -// for each increment of TimerValue. It is for NT32 only. -// -#define NTTIMERPERIOD 358049 - -#pragma pack(1) - -typedef struct _ICMP6_ECHO_REQUEST_REPLY { - UINT8 Type; - UINT8 Code; - UINT16 Checksum; - UINT16 Identifier; - UINT16 SequenceNum; - UINT64 TimeStamp; - UINT8 Data[1]; -} ICMP6_ECHO_REQUEST_REPLY; - -#pragma pack() - -typedef struct _PING6_ICMP6_TX_INFO { - LIST_ENTRY Link; - UINT16 SequenceNum; - UINT64 TimeStamp; - EFI_IP6_COMPLETION_TOKEN *Token; -} PING6_ICMP6_TX_INFO; - -typedef struct _PING6_PRIVATE_DATA { - EFI_HANDLE ImageHandle; - EFI_HANDLE NicHandle; - EFI_HANDLE Ip6ChildHandle; - EFI_IP6_PROTOCOL *Ip6; - EFI_EVENT Timer; - - EFI_STATUS Status; - LIST_ENTRY TxList; - EFI_IP6_COMPLETION_TOKEN RxToken; - UINT16 RxCount; - UINT16 TxCount; - UINT64 RttSum; - UINT64 RttMin; - UINT64 RttMax; - UINT32 SequenceNum; - - EFI_IPv6_ADDRESS SrcAddress; - EFI_IPv6_ADDRESS DstAddress; - UINT32 SendNum; - UINT32 BufferSize; -} PING6_PRIVATE_DATA; - -/** - Reads and returns the current value of register. - In IA64, the register is the Interval Timer Vector (ITV). - In X86(IA32/X64), the register is the Time Stamp Counter (TSC) - - @return The current value of the register. - -**/ -UINT64 -ReadTime ( - VOID - ); - -#endif diff --git a/NetworkPkg/Application/Ping6/Ping6.inf b/NetworkPkg/Application/Ping6/Ping6.inf deleted file mode 100644 index 68b5f2d32f..0000000000 --- a/NetworkPkg/Application/Ping6/Ping6.inf +++ /dev/null @@ -1,78 +0,0 @@ -## @file -# Shell application Ping6. -# -# It is an shell application which is used to Ping the target host with IPv6 stack. -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> -# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010006 - BASE_NAME = Ping6 - FILE_GUID = F35F733F-5235-4d7b-83FA-97780CEBCB20 - MODULE_TYPE = UEFI_APPLICATION - VERSION_STRING = 1.0 - ENTRY_POINT = InitializePing6 - MODULE_UNI_FILE = Ping6.uni - -# -# -# This flag specifies whether HII resource section is generated into PE image. -# - UEFI_HII_RESOURCE_SECTION = TRUE - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF -# - -[Sources] - Ping6.c - Ping6Strings.uni - Ping6.h - -[Sources.IA32] - Ia32/Tsc.c - -[Sources.X64] - X64/Tsc.c - -[Sources.IPF] - Ipf/Itc.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - ShellPkg/ShellPkg.dec - -[LibraryClasses] - BaseLib - UefiBootServicesTableLib - UefiApplicationEntryPoint - UefiHiiServicesLib - BaseMemoryLib - ShellLib - MemoryAllocationLib - DebugLib - HiiLib - NetLib - -[Protocols] - gEfiCpuArchProtocolGuid ## CONSUMES - gEfiIp6ProtocolGuid ## CONSUMES - gEfiIp6ServiceBindingProtocolGuid ## CONSUMES - gEfiIp6ConfigProtocolGuid ## CONSUMES - gEfiHiiPackageListProtocolGuid ## CONSUMES - -[UserExtensions.TianoCore."ExtraFiles"] - Ping6Extra.uni diff --git a/NetworkPkg/Application/Ping6/Ping6.uni b/NetworkPkg/Application/Ping6/Ping6.uni deleted file mode 100644 index afd14b796a..0000000000 --- a/NetworkPkg/Application/Ping6/Ping6.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// Shell application Ping6. -// -// It is an shell application which is used to Ping the target host with IPv6 stack. -// -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> -// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php. -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Shell application Ping6" - -#string STR_MODULE_DESCRIPTION #language en-US "It is an shell application which is used to Ping the target host with IPv6 stack." - diff --git a/NetworkPkg/Application/Ping6/Ping6Extra.uni b/NetworkPkg/Application/Ping6/Ping6Extra.uni deleted file mode 100644 index 097ea5578a..0000000000 --- a/NetworkPkg/Application/Ping6/Ping6Extra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// Ping6 Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR> -// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php. -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"Ping6 App" - - diff --git a/NetworkPkg/Application/Ping6/Ping6Strings.uni b/NetworkPkg/Application/Ping6/Ping6Strings.uni deleted file mode 100644 index e4ab19fe63..0000000000 --- a/NetworkPkg/Application/Ping6/Ping6Strings.uni +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - String definitions for the Shell Ping6 application. - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#langdef en-US "English" - -#string STR_PING6_INVALID_IP #language en-US "%Ping6: Invalid IP6 address, %s\n" -#string STR_PING6_INVALID_INPUT #language en-US "%Ping6: Invalid input, please type 'Ping6 -?'for help\n" -#string STR_PING6_INVALID_SEND_NUMBER #language en-US "%Ping6: Invalid send number, %s\n" -#string STR_PING6_INVALID_BUFFER_SIZE #language en-US "%Ping6: Invalid buffer size, %s\n" -#string STR_PING6_INVALID_SOURCE #language en-US "%Ping6: Require source interface option\n" -#string STR_PING6_IP6_CONFIG #language en-US "%Ping6: Ip6->Config %r\n" -#string STR_PING6_IP6_GETMODE #language en-US "%Ping6: Ip6->GetModeData %r\n" -#string STR_PING6_IP6CFG_GETDATA #language en-US "%Ping6: Ip6Config->GetData %r\n" -#string STR_PING6_SEND_REQUEST #language en-US "Echo request sequence %d fails.\n" -#string STR_PING6_SOURCE_NOT_FOUND #language en-US "Source %s not found.\n" -#string STR_PING6_NOSOURCE_INDOMAIN #language en-US "No sources in %s's multicast domain.\n" -#string STR_PING6_START #language en-US "Ping %s %d data bytes\n\n" -#string STR_PING6_TIMEOUT #language en-US "Echo request sequence %d timeout.\n" -#string STR_PING6_REPLY_INFO #language en-US "%d bytes from %s : icmp_seq=%d ttl=%d time%c%dms\n" -#string STR_PING6_STAT #language en-US "\n%d packets transmitted, %d received, %d%% packet loss, time %dms\n" -#string STR_PING6_RTT #language en-US "\nRtt(round trip time) min=%dms max=%dms avg=%dms\n" -#string STR_PING6_LINE_HELP #language en-US "Ping a target machine with UEFI IPv6 network stack" - -#string STR_PING6_HELP #language en-US "" -".TH Ping6 0 "Ping a target machine with UEFI IPv6 network stack."\r\n" -".SH NAME\r\n" -"Ping a target machine with UEFI IPv6 network stack.\r\n" -".SH SYNOPSIS\r\n" -" \r\n" -"Ping6 [-l size] [-n count] [-s SourceIp] TargetIp\r\n" -".SH OPTIONS\r\n" -" \r\n" -" -l size Send buffer size, in bytes(default=16, min=16, max=32768).\r\n" -" -n count Send request count, (default=10, min=1, max=10000).\r\n" -" -s SourceIp Source IPv6 address.\r\n" -" TargetIp Target IPv6 address.\r\n" -".SH EXAMPLES\r\n" -" \r\n" -"Examples:\r\n" -" Ping6 -s 2002::1 2002::2 -l 1000 -n 5\r\n" -" Ping6 2002::2 -l 1000\r\n" diff --git a/NetworkPkg/Application/Ping6/X64/Tsc.c b/NetworkPkg/Application/Ping6/X64/Tsc.c deleted file mode 100644 index b3e7bdbb96..0000000000 --- a/NetworkPkg/Application/Ping6/X64/Tsc.c +++ /dev/null @@ -1,28 +0,0 @@ -/** @file - The implement to read TSC in X64 platform. - - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Library/BaseLib.h> - -/** - Reads and returns the current value of Time Stamp Counter (TSC). - - @return The current value of TSC - -**/ -UINT64 -ReadTime () -{ - return AsmReadTsc (); -} diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc index 56a1a6b617..b193f5f38b 100644 --- a/NetworkPkg/NetworkPkg.dsc +++ b/NetworkPkg/NetworkPkg.dsc @@ -116,7 +116,6 @@ NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf NetworkPkg/HttpBootDxe/HttpBootDxe.inf - NetworkPkg/Application/IfConfig6/IfConfig6.inf NetworkPkg/Application/IpsecConfig/IpSecConfig.inf NetworkPkg/Application/VConfig/VConfig.inf @@ -126,8 +125,6 @@ NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf NetworkPkg/TlsDxe/TlsDxe.inf NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf - - NetworkPkg/Application/Ping6/Ping6.inf [BuildOptions] *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES -- 2.13.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.