]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/EfiSocketLib/Udp4.c
StdLib: Remove EfiSocketLib and Ip4Config Protocol dependency.
[mirror_edk2.git] / StdLib / EfiSocketLib / Udp4.c
index 7fece750958e0048075a2179b1f639c2a9a08d6c..ef2f9e321b2d50f856009233e21ffcd733b6a1e6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implement the UDP4 driver support for the socket layer.\r
 \r
-  Copyright (c) 2011, Intel Corporation\r
+  Copyright (c) 2011 - 2015, Intel Corporation\r
   All rights reserved. This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -1049,8 +1049,8 @@ EslUdp4VerifyLocalIpAddress (
   )\r
 {\r
   UINTN DataSize;\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
@@ -1059,7 +1059,7 @@ EslUdp4VerifyLocalIpAddress (
   //\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
@@ -1087,12 +1087,14 @@ EslUdp4VerifyLocalIpAddress (
     //  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
@@ -1101,39 +1103,45 @@ EslUdp4VerifyLocalIpAddress (
     }\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
@@ -1143,19 +1151,19 @@ EslUdp4VerifyLocalIpAddress (
     //\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 (( pConfigData->StationAddress.Addr [ 0 ] == pIpConfigData->StationAddress.Addr [ 0 ])\r
-      && ( pConfigData->StationAddress.Addr [ 1 ] == pIpConfigData->StationAddress.Addr [ 1 ])\r
-      && ( pConfigData->StationAddress.Addr [ 2 ] == pIpConfigData->StationAddress.Addr [ 2 ])\r
-      && ( pConfigData->StationAddress.Addr [ 3 ] == pIpConfigData->StationAddress.Addr [ 3 ])) {\r
+    if (( pConfigData->StationAddress.Addr [ 0 ] == pIfInfo->StationAddress.Addr [ 0 ])\r
+      && ( pConfigData->StationAddress.Addr [ 1 ] == pIfInfo->StationAddress.Addr [ 1 ])\r
+      && ( pConfigData->StationAddress.Addr [ 2 ] == pIfInfo->StationAddress.Addr [ 2 ])\r
+      && ( pConfigData->StationAddress.Addr [ 3 ] == pIfInfo->StationAddress.Addr [ 3 ])) {\r
       break;\r
     }\r
 \r
@@ -1169,8 +1177,8 @@ EslUdp4VerifyLocalIpAddress (
   //\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