]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IpSecDxe/IkeService.c
BaseTools: StructurePcd array Value support flexible format
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IkeService.c
index 12ee030e70561c591f26b686b0b45a5a92cc2b0f..4c0f6f5eb108de2eeff210fa77eed45beeea0c0e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provide IPsec Key Exchange (IKE) service general interfaces.\r
 \r
 /** @file\r
   Provide IPsec Key Exchange (IKE) service general interfaces.\r
 \r
-  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 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
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -15,7 +15,6 @@
 \r
 #include "IkeService.h"\r
 #include "IpSecConfigImpl.h"\r
 \r
 #include "IkeService.h"\r
 #include "IpSecConfigImpl.h"\r
-#include "Ikev2/Utility.h"\r
 \r
 IKE_EXCHANGE_INTERFACE  *mIkeExchange[] = {\r
   &mIkev1Exchange,\r
 \r
 IKE_EXCHANGE_INTERFACE  *mIkeExchange[] = {\r
   &mIkev1Exchange,\r
@@ -36,10 +35,10 @@ EFI_UDP4_CONFIG_DATA    mUdp4Conf = {
   0,\r
   1000000,\r
   FALSE,\r
   0,\r
   1000000,\r
   FALSE,\r
-  {0,0,0,0},\r
-  {0,0,0,0},\r
+  {{0,0,0,0}},\r
+  {{0,0,0,0}},\r
   IKE_DEFAULT_PORT,\r
   IKE_DEFAULT_PORT,\r
-  {0,0,0,0},\r
+  {{0,0,0,0}},\r
   0\r
 };\r
 \r
   0\r
 };\r
 \r
@@ -55,9 +54,9 @@ EFI_UDP6_CONFIG_DATA    mUdp6Conf = {
   0,\r
   1000000,\r
   //Access Point\r
   0,\r
   1000000,\r
   //Access Point\r
-  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\r
+  {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},\r
   IKE_DEFAULT_PORT,\r
   IKE_DEFAULT_PORT,\r
-  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\r
+  {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},\r
   0\r
 };\r
 \r
   0\r
 };\r
 \r
@@ -212,15 +211,15 @@ IkeOpenOutputUdp (
   IN EFI_IP_ADDRESS            *RemoteIp\r
   )\r
 {\r
   IN EFI_IP_ADDRESS            *RemoteIp\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
-  EFI_IP4_CONFIG_PROTOCOL *Ip4Cfg;\r
-  EFI_IP4_IPCONFIG_DATA   *Ip4CfgData;\r
-  UINTN                   BufSize;\r
-  EFI_IP6_MODE_DATA       Ip6ModeData;\r
-  EFI_UDP6_PROTOCOL       *Udp6;\r
+  EFI_STATUS                       Status;\r
+  EFI_IP4_CONFIG2_PROTOCOL         *Ip4Cfg2;\r
+  EFI_IP4_CONFIG2_INTERFACE_INFO   *IfInfo;\r
+  UINTN                            BufSize;\r
+  EFI_IP6_MODE_DATA                Ip6ModeData;\r
+  EFI_UDP6_PROTOCOL                *Udp6;\r
 \r
   Status      = EFI_SUCCESS;\r
 \r
   Status      = EFI_SUCCESS;\r
-  Ip4CfgData  = NULL;\r
+  IfInfo      = NULL;\r
   BufSize     = 0;\r
 \r
   //\r
   BufSize     = 0;\r
 \r
   //\r
@@ -236,35 +235,52 @@ IkeOpenOutputUdp (
     //\r
     Status = gBS->HandleProtocol (\r
                     UdpService->NicHandle,\r
     //\r
     Status = gBS->HandleProtocol (\r
                     UdpService->NicHandle,\r
-                    &gEfiIp4ConfigProtocolGuid,\r
-                    (VOID **) &Ip4Cfg\r
+                    &gEfiIp4Config2ProtocolGuid,\r
+                    (VOID **) &Ip4Cfg2\r
                     );\r
 \r
     if (EFI_ERROR (Status)) {\r
       goto ON_EXIT;\r
     }\r
 \r
                     );\r
 \r
     if (EFI_ERROR (Status)) {\r
       goto ON_EXIT;\r
     }\r
 \r
-    Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, NULL);\r
+    //\r
+    // Get the interface information size.\r
+    //\r
+    Status = Ip4Cfg2->GetData (\r
+                       Ip4Cfg2,\r
+                       Ip4Config2DataTypeInterfaceInfo,\r
+                       &BufSize,\r
+                       NULL\r
+                       );\r
 \r
     if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {\r
       goto ON_EXIT;\r
     }\r
 \r
 \r
     if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {\r
       goto ON_EXIT;\r
     }\r
 \r
-    Ip4CfgData = AllocateZeroPool (BufSize);\r
+    IfInfo = AllocateZeroPool (BufSize);\r
 \r
 \r
-    if (Ip4CfgData == NULL) {\r
+    if (IfInfo == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto ON_EXIT;\r
     }\r
 \r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto ON_EXIT;\r
     }\r
 \r
-    Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, Ip4CfgData);\r
+    //\r
+    // Get the interface info.\r
+    //\r
+    Status = Ip4Cfg2->GetData (\r
+                       Ip4Cfg2,\r
+                       Ip4Config2DataTypeInterfaceInfo,\r
+                       &BufSize,\r
+                       IfInfo\r
+                       );\r
+    \r
     if (EFI_ERROR (Status)) {\r
       goto ON_EXIT;\r
     }\r
 \r
     CopyMem (\r
       &UdpService->DefaultAddress.v4,\r
     if (EFI_ERROR (Status)) {\r
       goto ON_EXIT;\r
     }\r
 \r
     CopyMem (\r
       &UdpService->DefaultAddress.v4,\r
-      &Ip4CfgData->StationAddress,\r
+      &IfInfo->StationAddress,\r
       sizeof (EFI_IPv4_ADDRESS)\r
       );\r
 \r
       sizeof (EFI_IPv4_ADDRESS)\r
       );\r
 \r
@@ -312,6 +328,31 @@ IkeOpenOutputUdp (
       UdpIoFreeIo (UdpService->Output);\r
       goto ON_EXIT;\r
     }\r
       UdpIoFreeIo (UdpService->Output);\r
       goto ON_EXIT;\r
     }\r
+\r
+    if (Ip6ModeData.AddressList != NULL) {\r
+      FreePool (Ip6ModeData.AddressList);\r
+    }\r
+\r
+    if (Ip6ModeData.GroupTable != NULL) {\r
+      FreePool (Ip6ModeData.GroupTable);\r
+    }\r
+\r
+    if (Ip6ModeData.RouteTable != NULL) {\r
+      FreePool (Ip6ModeData.RouteTable);\r
+    }\r
+\r
+    if (Ip6ModeData.NeighborCache != NULL) {\r
+      FreePool (Ip6ModeData.NeighborCache);\r
+    }\r
+\r
+    if (Ip6ModeData.PrefixTable != NULL) {\r
+      FreePool (Ip6ModeData.PrefixTable);\r
+    }\r
+\r
+    if (Ip6ModeData.IcmpTypeList != NULL) {\r
+      FreePool (Ip6ModeData.IcmpTypeList);\r
+    }\r
+\r
     //\r
     // Reconfigure udp6 io without remote address.\r
     //\r
     //\r
     // Reconfigure udp6 io without remote address.\r
     //\r
@@ -331,8 +372,8 @@ IkeOpenOutputUdp (
   UdpService->IsConfigured = TRUE;\r
 \r
 ON_EXIT:\r
   UdpService->IsConfigured = TRUE;\r
 \r
 ON_EXIT:\r
-  if (Ip4CfgData != NULL) {\r
-    FreePool (Ip4CfgData);\r
+  if (IfInfo != NULL) {\r
+    FreePool (IfInfo);\r
   }\r
 \r
   return Status;\r
   }\r
 \r
   return Status;\r
@@ -346,6 +387,7 @@ ON_EXIT:
 \r
   @param[in] Private        Point to IPSEC_PRIVATE_DATA\r
   @param[in] Controller     Handler for NIC card.\r
 \r
   @param[in] Private        Point to IPSEC_PRIVATE_DATA\r
   @param[in] Controller     Handler for NIC card.\r
+  @param[in] ImageHandle    The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.\r
 \r
   @retval EFI_SUCCESS             The Operation is successful.\r
   @retval EFI_OUT_OF_RESOURCE     The required system resource can't be allocated.\r
 \r
   @retval EFI_SUCCESS             The Operation is successful.\r
   @retval EFI_OUT_OF_RESOURCE     The required system resource can't be allocated.\r
@@ -354,7 +396,8 @@ ON_EXIT:
 EFI_STATUS\r
 IkeOpenInputUdp4 (\r
   IN IPSEC_PRIVATE_DATA           *Private,\r
 EFI_STATUS\r
 IkeOpenInputUdp4 (\r
   IN IPSEC_PRIVATE_DATA           *Private,\r
-  IN EFI_HANDLE                   Controller\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_HANDLE                   ImageHandle\r
   )\r
 {\r
   IKE_UDP_SERVICE *Udp4Srv;\r
   )\r
 {\r
   IKE_UDP_SERVICE *Udp4Srv;\r
@@ -378,7 +421,7 @@ IkeOpenInputUdp4 (
   //\r
   Udp4Srv->Input = UdpIoCreateIo (\r
                      Controller,\r
   //\r
   Udp4Srv->Input = UdpIoCreateIo (\r
                      Controller,\r
-                     Private->ImageHandle,\r
+                     ImageHandle,\r
                      IkeConfigUdp4,\r
                      UDP_IO_UDP4_VERSION,\r
                      NULL\r
                      IkeConfigUdp4,\r
                      UDP_IO_UDP4_VERSION,\r
                      NULL\r
@@ -390,7 +433,7 @@ IkeOpenInputUdp4 (
   }\r
 \r
   Udp4Srv->NicHandle    = Controller;\r
   }\r
 \r
   Udp4Srv->NicHandle    = Controller;\r
-  Udp4Srv->ImageHandle  = Private->ImageHandle;\r
+  Udp4Srv->ImageHandle  = ImageHandle;\r
   Udp4Srv->ListHead     = &(Private->Udp4List);\r
   Udp4Srv->IpVersion    = UDP_IO_UDP4_VERSION;\r
   Udp4Srv->IsConfigured = FALSE;\r
   Udp4Srv->ListHead     = &(Private->Udp4List);\r
   Udp4Srv->IpVersion    = UDP_IO_UDP4_VERSION;\r
   Udp4Srv->IsConfigured = FALSE;\r
@@ -417,6 +460,7 @@ IkeOpenInputUdp4 (
 \r
   @param[in] Private        Point to IPSEC_PRIVATE_DATA\r
   @param[in] Controller     Handler for NIC card.\r
 \r
   @param[in] Private        Point to IPSEC_PRIVATE_DATA\r
   @param[in] Controller     Handler for NIC card.\r
+  @param[in] ImageHandle    The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.\r
 \r
   @retval EFI_SUCCESS             The Operation is successful.\r
   @retval EFI_OUT_OF_RESOURCE     The required system resource can't be allocated.\r
 \r
   @retval EFI_SUCCESS             The Operation is successful.\r
   @retval EFI_OUT_OF_RESOURCE     The required system resource can't be allocated.\r
@@ -425,7 +469,8 @@ IkeOpenInputUdp4 (
 EFI_STATUS\r
 IkeOpenInputUdp6 (\r
   IN IPSEC_PRIVATE_DATA           *Private,\r
 EFI_STATUS\r
 IkeOpenInputUdp6 (\r
   IN IPSEC_PRIVATE_DATA           *Private,\r
-  IN EFI_HANDLE                   Controller\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_HANDLE                   ImageHandle\r
   )\r
 {\r
   IKE_UDP_SERVICE *Udp6Srv;\r
   )\r
 {\r
   IKE_UDP_SERVICE *Udp6Srv;\r
@@ -446,7 +491,7 @@ IkeOpenInputUdp6 (
   //\r
   Udp6Srv->Input = UdpIoCreateIo (\r
                      Controller,\r
   //\r
   Udp6Srv->Input = UdpIoCreateIo (\r
                      Controller,\r
-                     Private->ImageHandle,\r
+                     ImageHandle,\r
                      IkeConfigUdp6,\r
                      UDP_IO_UDP6_VERSION,\r
                      NULL\r
                      IkeConfigUdp6,\r
                      UDP_IO_UDP6_VERSION,\r
                      NULL\r
@@ -458,7 +503,7 @@ IkeOpenInputUdp6 (
   }\r
 \r
   Udp6Srv->NicHandle    = Controller;\r
   }\r
 \r
   Udp6Srv->NicHandle    = Controller;\r
-  Udp6Srv->ImageHandle  = Private->ImageHandle;\r
+  Udp6Srv->ImageHandle  = ImageHandle;\r
   Udp6Srv->ListHead     = &(Private->Udp6List);\r
   Udp6Srv->IpVersion    = UDP_IO_UDP6_VERSION;\r
   Udp6Srv->IsConfigured = FALSE;\r
   Udp6Srv->ListHead     = &(Private->Udp6List);\r
   Udp6Srv->IpVersion    = UDP_IO_UDP6_VERSION;\r
   Udp6Srv->IsConfigured = FALSE;\r