From be6cd654eb27370bfa127dd387846ad983f4ef72 Mon Sep 17 00:00:00 2001 From: "Zhang, Lubo" Date: Mon, 29 Feb 2016 14:25:50 +0800 Subject: NetworkPkg: Support print help information using -? command. v2: *Modify the logic of show SAD,SPD and PAD help info, include them in -? instead of follow -p command. Since Shell supports finding help information from resource section of application image. We modify the Shell application Under NetworkPkg to support print help information string using -? command. Cc: Fu Siyuan Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Reviewed-by: Jiaxin Wu Reviewed-by: Fu Siyuan --- NetworkPkg/Application/Ping6/Ping6.c | 41 +++++++++++++++++++-------- NetworkPkg/Application/Ping6/Ping6.h | 7 ++++- NetworkPkg/Application/Ping6/Ping6.inf | 10 ++++++- NetworkPkg/Application/Ping6/Ping6Strings.uni | 35 +++++++++++++---------- 4 files changed, 64 insertions(+), 29 deletions(-) (limited to 'NetworkPkg/Application/Ping6') diff --git a/NetworkPkg/Application/Ping6/Ping6.c b/NetworkPkg/Application/Ping6/Ping6.c index 596ee3b007..f1685f710b 100644 --- a/NetworkPkg/Application/Ping6/Ping6.c +++ b/NetworkPkg/Application/Ping6/Ping6.c @@ -1,7 +1,7 @@ /** @file The implementation for Ping6 application. - Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -42,10 +43,6 @@ SHELL_PARAM_ITEM Ping6ParamList[] = { L"-s", TypeValue }, - { - L"-?", - TypeFlag - }, { NULL, TypeMax @@ -1059,11 +1056,36 @@ InitializePing6 ( CONST CHAR16 *ValueStr; CONST CHAR16 *ValueStrPtr; UINTN NonOptionCount; + EFI_HII_PACKAGE_LIST_HEADER *PackageList; // - // Register our string package with HII and return the handle to it. + // Retrieve HII package list from ImageHandle // - mHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, Ping6Strings, NULL); + 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); @@ -1072,11 +1094,6 @@ InitializePing6 ( goto ON_EXIT; } - if (ShellCommandLineGetFlag (ParamPackage, L"-?")) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_HELP), mHiiHandle); - goto ON_EXIT; - } - SendNumber = 10; BufferSize = 16; diff --git a/NetworkPkg/Application/Ping6/Ping6.h b/NetworkPkg/Application/Ping6/Ping6.h index b152ff18bc..4660b0e3be 100644 --- a/NetworkPkg/Application/Ping6/Ping6.h +++ b/NetworkPkg/Application/Ping6/Ping6.h @@ -1,7 +1,7 @@ /** @file The interface function declaration of shell application Ping6 (Ping for v6 series). - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -21,6 +21,11 @@ #define PING6_MAX_BUFFER_SIZE 32768 #define PING6_ONE_SECOND 10000000 +// +// String token ID of Ping6 command help message text. +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringPing6HelpToken = STRING_TOKEN (STR_PING6_HELP); + // // A similar amount of time that passes in femtoseconds // for each increment of TimerValue. It is for NT32 only. diff --git a/NetworkPkg/Application/Ping6/Ping6.inf b/NetworkPkg/Application/Ping6/Ping6.inf index f8851b98b0..68b5f2d32f 100644 --- a/NetworkPkg/Application/Ping6/Ping6.inf +++ b/NetworkPkg/Application/Ping6/Ping6.inf @@ -3,7 +3,7 @@ # # 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.
+# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -24,6 +24,12 @@ 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. # @@ -53,6 +59,7 @@ BaseLib UefiBootServicesTableLib UefiApplicationEntryPoint + UefiHiiServicesLib BaseMemoryLib ShellLib MemoryAllocationLib @@ -65,6 +72,7 @@ gEfiIp6ProtocolGuid ## CONSUMES gEfiIp6ServiceBindingProtocolGuid ## CONSUMES gEfiIp6ConfigProtocolGuid ## CONSUMES + gEfiHiiPackageListProtocolGuid ## CONSUMES [UserExtensions.TianoCore."ExtraFiles"] Ping6Extra.uni diff --git a/NetworkPkg/Application/Ping6/Ping6Strings.uni b/NetworkPkg/Application/Ping6/Ping6Strings.uni index c2f003defb..e4ab19fe63 100644 --- a/NetworkPkg/Application/Ping6/Ping6Strings.uni +++ b/NetworkPkg/Application/Ping6/Ping6Strings.uni @@ -1,7 +1,7 @@ /** @file String definitions for the Shell Ping6 application. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -32,17 +32,22 @@ #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 "Ping a target machine with UEFI IPv6 network stack.\n\n" - "Usage: Ping6 [-l size] [-n count] [-s SourceIp] TargetIp\n" - " Use ESC and Ctrl+C to interrupt Ping6 process.\n" - "\n" - "Options:\n" - " -l size Send buffer size, in bytes(default=16, min=16, max=32768).\n" - " -n count Send request count, (default=10, min=1, max=10000).\n" - " -s SourceIp Source IPv6 address.\n" - " TargetIp Target IPv6 address.\n" - " -? Help document.\n" - "\n" - "Examples:\n" - " Ping6 -s 2002::1 2002::2 -l 1000 -n 5\n" - " Ping6 2002::2 -l 1000\n" \ No newline at end of file + +#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" -- cgit v1.2.3