]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Application/IpsecConfig/IpSecConfig.c
NetworkPkg: Fix IpsecConfig GCC build failure issue
[mirror_edk2.git] / NetworkPkg / Application / IpsecConfig / IpSecConfig.c
index 3554355bd7081f516d8fbfd11fbc12cce863d266..274f582b2bfe64dafc51354e83b8c6a221a87d59 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The main process for IpSecConfig application.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 #include "Delete.h"\r
 #include "Helper.h"\r
 \r
+//\r
+// String token ID of IpSecConfig command help message text.\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringIpSecHelpTokenId = STRING_TOKEN (STR_IPSEC_CONFIG_HELP);\r
+\r
 //\r
 // Used for ShellCommandLineParseEx only\r
 // and to ensure user inputs are in valid format\r
@@ -40,7 +45,6 @@ SHELL_PARAM_ITEM    mIpSecConfigParamList[] = {
   { L"-enable",               TypeFlag },\r
   { L"-disable",              TypeFlag },\r
   { L"-status",               TypeFlag },\r
-  { L"-?",                    TypeFlag },\r
 \r
   //\r
   // SPD Selector\r
@@ -82,7 +86,8 @@ SHELL_PARAM_ITEM    mIpSecConfigParamList[] = {
   // --ipsec-proto\r
   //\r
   { L"--spi",                 TypeValue },\r
-  { L"--dest",                TypeValue },\r
+  { L"--tunnel-dest",         TypeValue },\r
+  { L"--tunnel-source",       TypeValue },\r
   { L"--lookup-spi",          TypeValue },\r
   { L"--lookup-ipsec-proto",  TypeValue },\r
   { L"--lookup-dest",         TypeValue },\r
@@ -231,7 +236,6 @@ STR2INT mMapAuthMethod[] = {
 EFI_IPSEC2_PROTOCOL          *mIpSec;\r
 EFI_IPSEC_CONFIG_PROTOCOL    *mIpSecConfig;\r
 EFI_HII_HANDLE               mHiiHandle;\r
-EFI_GUID                     mEfiIpSecConfigGuid = EFI_IPSEC_CONFIG_GUID;\r
 CHAR16                       mAppName[]          = L"IpSecConfig";\r
 \r
 //\r
@@ -292,7 +296,8 @@ VAR_CHECK_ITEM    mIpSecConfigVarCheckList[] = {
   // --ipsec-proto\r
   //\r
   { L"--spi",                0,              0,       BIT(1),               0 },\r
-  { L"--dest",               0,              0,       BIT(1),               0 },\r
+  { L"--tunnel-dest",        0,              0,       BIT(1),               0 },\r
+  { L"--tunnel-source",      0,              0,       BIT(1),               0 },\r
   { L"--lookup-spi",         0,              0,       BIT(1),               0 },\r
   { L"--lookup-ipsec-proto", 0,              0,       BIT(1),               0 },\r
   { L"--lookup-dest",        0,              0,       BIT(1),               0 },\r
@@ -548,7 +553,7 @@ IpSecConfigRetriveCheckListByName (
   for (Node = GetFirstNode (ParamPackage); !IsNull (ParamPackage, Node); Node = GetNextNode (ParamPackage, Node)) {\r
     if (((SHELL_PARAM_PACKAGE *) Node)->Name != NULL) {\r
       //\r
-         // Enumerate the check list that defines the conflicted attributes of each flag.\r
+      // Enumerate the check list that defines the conflicted attributes of each flag.\r
       //\r
       for (; Item->VarName != NULL; Item++) {\r
         if (StrCmp (((SHELL_PARAM_PACKAGE *) Node)->Name, Item->VarName) == 0) {\r
@@ -621,11 +626,36 @@ InitializeIpSecConfig (
   CONST CHAR16                  *ValueStr;\r
   CHAR16                        *ProblemParam;\r
   UINTN                         NonOptionCount;\r
+  EFI_HII_PACKAGE_LIST_HEADER   *PackageList;\r
 \r
   //\r
-  // Register our string package with HII and return the handle to it.\r
+  // Retrieve HII package list from ImageHandle\r
   //\r
-  mHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, IpSecConfigStrings, NULL);\r
+  Status = gBS->OpenProtocol (\r
+                  ImageHandle,\r
+                  &gEfiHiiPackageListProtocolGuid,\r
+                  (VOID **) &PackageList,\r
+                  ImageHandle,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Publish HII package list to HII Database.\r
+  //\r
+  Status = gHiiDatabase->NewPackageList (\r
+                          gHiiDatabase,\r
+                          PackageList,\r
+                          NULL,\r
+                          &mHiiHandle\r
+                          );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   ASSERT (mHiiHandle != NULL);\r
 \r
   Status = ShellCommandLineParseEx (mIpSecConfigParamList, &ParamPackage, &ProblemParam, TRUE, FALSE);\r
@@ -646,7 +676,7 @@ InitializeIpSecConfig (
     goto Done;\r
   }\r
 \r
-  Status = LocateProtocol (&gEfiIpSecProtocolGuid, (VOID **) &mIpSec);\r
+  Status = LocateProtocol (&gEfiIpSec2ProtocolGuid, (VOID **) &mIpSec);\r
   if (EFI_ERROR (Status) || mIpSec == NULL) {\r
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_PROTOCOL_INEXISTENT), mHiiHandle, mAppName);\r
     goto Done;\r
@@ -717,7 +747,7 @@ InitializeIpSecConfig (
   //\r
   // Try to get policy database type.\r
   //\r
-  DataType = (EFI_IPSEC_CONFIG_DATA_TYPE) -1;\r
+  DataType = (EFI_IPSEC_CONFIG_DATA_TYPE) - 1;\r
   ValueStr = ShellCommandLineGetValue (ParamPackage, L"-p");\r
   if (ValueStr != NULL) {\r
     DataType = (EFI_IPSEC_CONFIG_DATA_TYPE) MapStringToInteger (ValueStr, mMapPolicy);\r
@@ -727,32 +757,6 @@ InitializeIpSecConfig (
     }\r
   }\r
 \r
-  if (ShellCommandLineGetFlag (ParamPackage, L"-?")) {\r
-    switch (DataType) {\r
-      case (EFI_IPSEC_CONFIG_DATA_TYPE) -1:\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_HELP), mHiiHandle);\r
-        break;\r
-\r
-      case IPsecConfigDataTypeSpd:\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_SPD_HELP), mHiiHandle);\r
-        break;\r
-\r
-      case IPsecConfigDataTypeSad:\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_SAD_HELP), mHiiHandle);\r
-        break;\r
-\r
-      case IPsecConfigDataTypePad:\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_PAD_HELP), mHiiHandle);\r
-        break;\r
-\r
-      default:\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_INCORRECT_DB), mHiiHandle);\r
-        break;\r
-    }\r
-\r
-    goto Done;\r
-  }\r
-\r
   NonOptionCount = ShellCommandLineGetCount (ParamPackage);\r
   if ((NonOptionCount - 1) > 0) {\r
     ValueStr = ShellCommandLineGetRawValue (ParamPackage, (UINT32) (NonOptionCount - 1));\r