]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/EfiSocketLib/Tcp4.c
StdLib: Remove EfiSocketLib and Ip4Config Protocol dependency.
[mirror_edk2.git] / StdLib / EfiSocketLib / Tcp4.c
index 943af946bce68fe70bdbeaff228be31ffdd5c99f..68477fba6e70122d173a2ffc918564a4a6432446 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implement the TCP4 driver support for the socket layer.\r
 \r
-  Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available\r
   under the terms and conditions of the BSD License which accompanies this\r
   distribution.  The full text of the license may be found at\r
@@ -2247,8 +2247,8 @@ EslTcp4VerifyLocalIpAddress (
 {\r
   UINTN DataSize;\r
   EFI_TCP4_ACCESS_POINT * pAccess;\r
-  EFI_IP4_IPCONFIG_DATA * pIpConfigData;\r
-  EFI_IP4_CONFIG_PROTOCOL * pIpConfigProtocol;\r
+  EFI_IP4_CONFIG2_INTERFACE_INFO * pIfInfo;\r
+  EFI_IP4_CONFIG2_PROTOCOL * pIpConfig2Protocol;\r
   ESL_SERVICE * pService;\r
   EFI_STATUS Status;\r
 \r
@@ -2257,7 +2257,7 @@ EslTcp4VerifyLocalIpAddress (
   //\r
   //  Use break instead of goto\r
   //\r
-  pIpConfigData = NULL;\r
+  pIfInfo = NULL;\r
   for ( ; ; ) {\r
     //\r
     //  Determine if the IP address is specified\r
@@ -2286,12 +2286,14 @@ EslTcp4VerifyLocalIpAddress (
     //  Open the configuration protocol\r
     //\r
     pService = pPort->pService;\r
-    Status = gBS->OpenProtocol ( pService->Controller,\r
-                                 &gEfiIp4ConfigProtocolGuid,\r
-                                 (VOID **)&pIpConfigProtocol,\r
-                                 NULL,\r
-                                 NULL,\r
-                                 EFI_OPEN_PROTOCOL_GET_PROTOCOL );\r
+    Status = gBS->OpenProtocol ( \r
+                    pService->Controller,\r
+                    &gEfiIp4Config2ProtocolGuid,\r
+                    (VOID **)&pIpConfig2Protocol,\r
+                    NULL,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL \r
+                    );\r
     if ( EFI_ERROR ( Status )) {\r
       DEBUG (( DEBUG_ERROR,\r
                 "ERROR - IP Configuration Protocol not available, Status: %r\r\n",\r
@@ -2300,39 +2302,45 @@ EslTcp4VerifyLocalIpAddress (
     }\r
 \r
     //\r
-    //  Get the IP configuration data size\r
+    // Get the interface information size.\r
     //\r
     DataSize = 0;\r
-    Status = pIpConfigProtocol->GetData ( pIpConfigProtocol,\r
-                                          &DataSize,\r
-                                          NULL );\r
+    Status = pIpConfig2Protocol->GetData ( \r
+                                   pIpConfig2Protocol,\r
+                                   Ip4Config2DataTypeInterfaceInfo,\r
+                                   &DataSize,\r
+                                   NULL\r
+                                   );\r
     if ( EFI_BUFFER_TOO_SMALL != Status ) {\r
       DEBUG (( DEBUG_ERROR,\r
-                "ERROR - Failed to get IP Configuration data size, Status: %r\r\n",\r
+                "ERROR - Failed to get the interface information size, Status: %r\r\n",\r
                 Status ));\r
       break;\r
     }\r
 \r
     //\r
-    //  Allocate the configuration data buffer\r
+    //  Allocate the interface information buffer\r
     //\r
-    pIpConfigData = AllocatePool ( DataSize );\r
-    if ( NULL == pIpConfigData ) {\r
+    pIfInfo = AllocatePool ( DataSize );\r
+    if ( NULL == pIfInfo ) {\r
       DEBUG (( DEBUG_ERROR,\r
-                "ERROR - Not enough memory to allocate IP Configuration data!\r\n" ));\r
+                "ERROR - Not enough memory to allocate the interface information buffer!\r\n" ));\r
       Status = EFI_OUT_OF_RESOURCES;\r
       break;\r
     }\r
 \r
     //\r
-    //  Get the IP configuration\r
+    // Get the interface info.\r
     //\r
-    Status = pIpConfigProtocol->GetData ( pIpConfigProtocol,\r
-                                          &DataSize,\r
-                                          pIpConfigData );\r
+    Status = pIpConfig2Protocol->GetData ( \r
+                                  pIpConfig2Protocol,\r
+                                  Ip4Config2DataTypeInterfaceInfo,\r
+                                  &DataSize,\r
+                                  pIfInfo\r
+                                  );\r
     if ( EFI_ERROR ( Status )) {\r
       DEBUG (( DEBUG_ERROR,\r
-                "ERROR - Failed to return IP Configuration data, Status: %r\r\n",\r
+                "ERROR - Failed to return the interface info, Status: %r\r\n",\r
                 Status ));\r
       break;\r
     }\r
@@ -2342,19 +2350,19 @@ EslTcp4VerifyLocalIpAddress (
     //\r
     DEBUG (( DEBUG_BIND,\r
               "Actual adapter IP address: %d.%d.%d.%d\r\n",\r
-              pIpConfigData->StationAddress.Addr [ 0 ],\r
-              pIpConfigData->StationAddress.Addr [ 1 ],\r
-              pIpConfigData->StationAddress.Addr [ 2 ],\r
-              pIpConfigData->StationAddress.Addr [ 3 ]));\r
+              pIfInfo->StationAddress.Addr [ 0 ],\r
+              pIfInfo->StationAddress.Addr [ 1 ],\r
+              pIfInfo->StationAddress.Addr [ 2 ],\r
+              pIfInfo->StationAddress.Addr [ 3 ]));\r
 \r
     //\r
     //  Assume the port is not configured\r
     //\r
     Status = EFI_SUCCESS;\r
-    if (( pAccess->StationAddress.Addr [ 0 ] == pIpConfigData->StationAddress.Addr [ 0 ])\r
-      && ( pAccess->StationAddress.Addr [ 1 ] == pIpConfigData->StationAddress.Addr [ 1 ])\r
-      && ( pAccess->StationAddress.Addr [ 2 ] == pIpConfigData->StationAddress.Addr [ 2 ])\r
-      && ( pAccess->StationAddress.Addr [ 3 ] == pIpConfigData->StationAddress.Addr [ 3 ])) {\r
+    if (( pAccess->StationAddress.Addr [ 0 ] == pIfInfo->StationAddress.Addr [ 0 ])\r
+      && ( pAccess->StationAddress.Addr [ 1 ] == pIfInfo->StationAddress.Addr [ 1 ])\r
+      && ( pAccess->StationAddress.Addr [ 2 ] == pIfInfo->StationAddress.Addr [ 2 ])\r
+      && ( pAccess->StationAddress.Addr [ 3 ] == pIfInfo->StationAddress.Addr [ 3 ])) {\r
       break;\r
     }\r
 \r
@@ -2368,8 +2376,8 @@ EslTcp4VerifyLocalIpAddress (
   //\r
   //  Free the buffer if necessary\r
   //\r
-  if ( NULL != pIpConfigData ) {\r
-    FreePool ( pIpConfigData );\r
+  if ( NULL != pIfInfo ) {\r
+    FreePool ( pIfInfo );\r
   }\r
 \r
   //\r