diff options
author | Zhang, Lubo <C:/Program Files (x86)/Git/o=Intel/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Zhang, Lubob8d> | 2016-02-29 14:25:50 +0800 |
---|---|---|
committer | Jiaxin Wu <jiaxin.wu@intel.com> | 2016-03-07 09:57:09 +0800 |
commit | be6cd654eb27370bfa127dd387846ad983f4ef72 (patch) | |
tree | 2a219f73811787324d3d3a03ff96a872fd9f63e1 /NetworkPkg/Application/IpsecConfig | |
parent | fa848a4048943251fc057fe8d6c5a82e01d2ffb6 (diff) | |
download | edk2-platforms-be6cd654eb27370bfa127dd387846ad983f4ef72.tar.xz |
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 <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Diffstat (limited to 'NetworkPkg/Application/IpsecConfig')
4 files changed, 103 insertions, 100 deletions
diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.c b/NetworkPkg/Application/IpsecConfig/IpSecConfig.c index e4f6057f40..ff895bccf0 100644 --- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.c +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.c @@ -40,7 +40,6 @@ SHELL_PARAM_ITEM mIpSecConfigParamList[] = { { L"-enable", TypeFlag },
{ L"-disable", TypeFlag },
{ L"-status", TypeFlag },
- { L"-?", TypeFlag },
//
// SPD Selector
@@ -622,11 +621,36 @@ InitializeIpSecConfig ( CONST CHAR16 *ValueStr;
CHAR16 *ProblemParam;
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, IpSecConfigStrings, 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 (mIpSecConfigParamList, &ParamPackage, &ProblemParam, TRUE, FALSE);
@@ -728,33 +752,6 @@ InitializeIpSecConfig ( }
}
- if (ShellCommandLineGetFlag (ParamPackage, L"-?")) {
- if (DataType == -1) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_HELP), mHiiHandle);
- goto Done;
- }
-
- switch (DataType) {
- case IPsecConfigDataTypeSpd:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_SPD_HELP), mHiiHandle);
- break;
-
- case IPsecConfigDataTypeSad:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_SAD_HELP), mHiiHandle);
- break;
-
- case IPsecConfigDataTypePad:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_PAD_HELP), mHiiHandle);
- break;
-
- default:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_INCORRECT_DB), mHiiHandle);
- break;
- }
-
- goto Done;
- }
-
NonOptionCount = ShellCommandLineGetCount (ParamPackage);
if ((NonOptionCount - 1) > 0) {
ValueStr = ShellCommandLineGetRawValue (ParamPackage, (UINT32) (NonOptionCount - 1));
diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h index 17044fef79..244926f888 100644 --- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h @@ -22,10 +22,16 @@ #include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiHiiServicesLib.h>
#include <Library/NetLib.h>
#include <Protocol/IpSecConfig.h>
+//
+// String token ID of VConfig command help message text.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringIpSecHelpTokenId = STRING_TOKEN (STR_IPSEC_CONFIG_HELP);
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define IPSECCONFIG_STATUS_NAME L"IpSecStatus"
diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.inf b/NetworkPkg/Application/IpsecConfig/IpSecConfig.inf index 52cf6b0341..02371e535d 100644 --- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.inf +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.inf @@ -25,6 +25,12 @@ ENTRY_POINT = InitializeIpSecConfig
MODULE_UNI_FILE = IpSecConfig.uni
+#
+#
+# This flag specifies whether HII resource section is generated into PE image.
+#
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
[Sources]
IpSecConfigStrings.uni
IpSecConfig.c
@@ -52,6 +58,7 @@ [LibraryClasses]
UefiBootServicesTableLib
UefiApplicationEntryPoint
+ UefiHiiServicesLib
BaseMemoryLib
ShellLib
MemoryAllocationLib
@@ -63,6 +70,7 @@ [Protocols]
gEfiIpSec2ProtocolGuid ##CONSUMES
gEfiIpSecConfigProtocolGuid ##CONSUMES
+ gEfiHiiPackageListProtocolGuid ##CONSUMES
[UserExtensions.TianoCore."ExtraFiles"]
IpSecConfigExtra.uni
diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfigStrings.uni b/NetworkPkg/Application/IpsecConfig/IpSecConfigStrings.uni index 2c342d38cd..bd7f546327 100644 --- a/NetworkPkg/Application/IpsecConfig/IpSecConfigStrings.uni +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfigStrings.uni @@ -49,76 +49,6 @@ #string STR_IPSEC_CONFIG_INSERT_UNSUPPORT #language en-US "%s: Policy entry insertion not supported!\n"
-#string STR_IPSEC_CONFIG_LINE_HELP #language en-US "Displays or modifies the IPsec configuration"
-
-#string STR_IPSEC_CONFIG_HELP #language en-US "Displays or modifies the current IPsec configuration.\n"
- "%HUsage: IpSecConfig [-p {SPD|SAD|PAD}] [command] [options[parameters]]%N\n"
- "\n"
- "%H-p (SPD|SAD|PAD)%N required.point to certain policy database.\n"
- "%Hcommand%N:\n"
- " -a [options[parameters]] Add new policy entry.\n"
- " -i entryid [options[parameters]] Insert new policy entry before the one\n"
- " matched by the entryid.\n"
- " It's only supported on SPD policy database.\n"
- " -d entryid Delete the policy entry matched by the \n"
- " entryid.\n"
- " -e entryid [options[parameters]] Edit the policy entry matched by the\n"
- " entryid.\n"
- " -f Flush the entire policy database.\n"
- " -l List all entries for specified database.\n"
- " -enable Enable IPsec.\n"
- " -disable Disable IPsec.\n"
- " -status Show IPsec current status.\n"
- "%H[options[parametes]]%N depend on the type of policy database.Type\n "
- " 'IpSecConfig -p'followed by the database \n"
- " name, and then type ' -?'.\n"
- " e.g.: 'IpSecConfig -p SPD -?'\n"
-
-#string STR_IPSEC_CONFIG_SPD_HELP #language en-US "Explain the %H[options[parametes]%N for %HSPD%N\n"
- "\n"
- "%H[options[parameters]]%N:\n"
- " --local localaddress optional local address\n"
- " --remote remoteaddress required remote address\n"
- " --proto (TCP|UDP|ICMP|...) required IP protocol\n"
- " --local-port port optional local port for tcp/udp protocol\n"
- " --remote-port port optional remote port for tcp/udp protocol\n"
- " --name name optional SPD name\n"
- " --action (Bypass|Discard|Protect) required \n"
- " required IPsec action\n"
- " --mode (Transport|Tunnel) optional IPsec mode, transport by default\n"
- " --ipsec-proto (AH|ESP) optional IPsec protocol, ESP by default\n"
- " --auth-algo (NONE|SHA1HMAC) optional authentication algorithm\n"
- " --encrypt-algo(NONE|DESCBC|3DESCBC)optional encryption algorithm\n"
- " --tunnel-local tunnellocaladdr optional tunnel local address(only for tunnel mode)\n"
- " --tunnel-remote tunnelremoteaddr optional tunnel remote address(only for tunnel mode)\n"
- "\n"
-
-#string STR_IPSEC_CONFIG_SAD_HELP #language en-US "Explain the %H[options[parameters]]%N for %HSAD%N\n"
- "\n"
- "%H[options[parameters]]%N:\n"
- " --spi spi required SPI value\n"
- " --ipsec-proto (AH|ESP) required IPsec protocol\n"
- " --local localaddress optional local address\n"
- " --remote remoteaddress required destination address\n"
- " --auth-algo (NONE|SHA1HMAC) required for AH. authentication algorithm\n"
- " --auth-key key required for AH. key for authentication\n"
- " --encrypt-algo (NONE|DESCBC|3DESCBC) required for ESP. encryption algorithm\n"
- " --encrypt-key key required for ESP. key for encryption\n"
- " --mode (Transport|Tunnel) optional IPsec mode, transport by default\n"
- " --tunnel-dest tunneldestaddr optional tunnel destination address(only for tunnel mode)\n"
- " --tunnel-source tunnelsourceaddr optional tunnel source address(only for tunnel mode)\n"
- "\n"
-
-#string STR_IPSEC_CONFIG_PAD_HELP #language en-US "Explain the %H[options[parameters]]%N for %HPAD%N\n"
- "\n"
- "%H[options[parameters]]%N:\n"
- " --peer-address address required peer address\n"
- " --auth-proto (IKEv1|IKEv2) optional IKE protocol, IKEv1 by\n"
- " default\n"
- " --auth-method (PreSharedSecret|Certificates) required authentication method\n"
- " --auth-data authdata required data for authentication\n"
- "\n"
-
#string STR_IPSEC_MISTAKEN_OPTIONS #language en-US "Mistaken Input. Please refer to %H"IpSecConfig -?"%N for more help information.\n"
#string STR_IPSEC_REDUNDANCY_MANY #language en-US "%s has one redundancy option: %H%s%N\n"
@@ -139,3 +69,65 @@ #string STR_IPSEC_CONFIG_DISABLE_FAILED #language en-US "Error: Disable IPsec failed !\n"
+#string STR_IPSEC_CONFIG_HELP #language en-US ""
+".TH IpSecConfig 0 "Displays or modifies the current IPsec configuration."\r\n"
+".SH NAME\r\n"
+"Displays or modifies the current IPsec configuration.\r\n"
+".SH SYNOPSIS\r\n"
+" \r\n"
+"%HIpSecConfig [-p {SPD|SAD|PAD}] [command] [options[parameters]]\r\n"
+".SH OPTIONS\r\n"
+" \r\n"
+"%H-p (SPD|SAD|PAD)%N required.point to certain policy database.\r\n"
+" \r\n"
+"%Hcommand%N:\r\n"
+" -a [options[parameters]] Add new policy entry.\r\n"
+" -i entryid [options[parameters]] Insert new policy entry before the one\r\n"
+" matched by the entryid.\r\n"
+" It's only supported on SPD policy database.\r\n"
+" -d entryid Delete the policy entry matched by the \r\n"
+" entryid.\r\n"
+" -e entryid [options[parameters]] Edit the policy entry matched by the\r\n"
+" entryid.\r\n"
+" -f Flush the entire policy database.\r\n"
+" -l List all entries for specified database.\r\n"
+" -enable Enable IPsec.\r\n"
+" -disable Disable IPsec.\r\n"
+" -status Show IPsec current status.\r\n"
+" \r\n"
+"%H[options[parameters]]%N for %HSPD%N:\r\n"
+" --local localaddress optional local address\r\n"
+" --remote remoteaddress required remote address\r\n"
+" --proto (TCP|UDP|ICMP|...) required IP protocol\r\n"
+" --local-port port optional local port for tcp/udp protocol\r\n"
+" --remote-port port optional remote port for tcp/udp protocol\r\n"
+" --name name optional SPD name\r\n"
+" --action (Bypass|Discard|Protect) required \r\n"
+" required IPsec action\r\n"
+" --mode (Transport|Tunnel) optional IPsec mode, transport by default\r\n"
+" --ipsec-proto (AH|ESP) optional IPsec protocol, ESP by default\r\n"
+" --auth-algo (NONE|SHA1HMAC) optional authentication algorithm\r\n"
+" --encrypt-algo(NONE|DESCBC|3DESCBC)optional encryption algorithm\r\n"
+" --tunnel-local tunnellocaladdr optional tunnel local address(only for tunnel mode)\r\n"
+" --tunnel-remote tunnelremoteaddr optional tunnel remote address(only for tunnel mode)\r\n"
+" \r\n"
+"%H[options[parameters]]%N for %HSAD%N:\r\n"
+" --spi spi required SPI value\r\n"
+" --ipsec-proto (AH|ESP) required IPsec protocol\r\n"
+" --local localaddress optional local address\r\n"
+" --remote remoteaddress required destination address\r\n"
+" --auth-algo (NONE|SHA1HMAC) required for AH. authentication algorithm\n"
+" --auth-key key required for AH. key for authentication\r\n"
+" --encrypt-algo (NONE|DESCBC|3DESCBC) required for ESP. encryption algorithm\r\n"
+" --encrypt-key key required for ESP. key for encryption\r\n"
+" --mode (Transport|Tunnel) optional IPsec mode, transport by default\r\n"
+" --tunnel-dest tunneldestaddr optional tunnel destination address(only for tunnel mode)\r\n"
+" --tunnel-source tunnelsourceaddr optional tunnel source address(only for tunnel mode)\r\n"
+" \r\n"
+"%H[options[parameters]]%N for %HPAD%N:\r\n"
+" --peer-address address required peer address\r\n"
+" --auth-proto (IKEv1|IKEv2) optional IKE protocol, IKEv1 by\r\n"
+" default\r\n"
+" --auth-method (PreSharedSecret|Certificates) required authentication method\r\n"
+" --auth-data authdata required data for authentication\r\n"
+" \r\n"
|