]> 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 7ece38d52137329e74d800f8830bd32ded86be03..68477fba6e70122d173a2ffc918564a4a6432446 100644 (file)
@@ -1,18 +1,18 @@
 /** @file\r
   Implement the TCP4 driver support for the socket layer.\r
 \r
-  Copyright (c) 2011, 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
-  http://opensource.org/licenses/bsd-license.php\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
+  http://opensource.org/licenses/bsd-license.php.\r
 \r
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 \r
   \section ConnectionManagement Connection Management\r
-  \r
+\r
   The ::EslTcp4Listen routine initially places the SOCK_STREAM or\r
   SOCK_SEQPACKET socket into a listen state.   When a remote machine\r
   makes a connection to the socket, the TCPv4 network layer calls\r
@@ -487,7 +487,7 @@ EslTcp4ConnectStart (
   EFI_STATUS Status;\r
 \r
   DBG_ENTER ( );\r
-  \r
+\r
   //\r
   //  Determine if any more local adapters are available\r
   //\r
@@ -776,7 +776,7 @@ EslTcp4Listen (
       //\r
       pPort = pNextPort;\r
     }\r
-    \r
+\r
     //\r
     //  Determine if any ports are in the listen state\r
     //\r
@@ -840,7 +840,6 @@ EslTcp4ListenComplete (
   EFI_HANDLE ChildHandle;\r
   struct sockaddr_in LocalAddress;\r
   EFI_TCP4_CONFIG_DATA * pConfigData;\r
-  ESL_LAYER * pLayer;\r
   ESL_PORT * pNewPort;\r
   ESL_SOCKET * pNewSocket;\r
   ESL_SOCKET * pSocket;\r
@@ -869,7 +868,6 @@ EslTcp4ListenComplete (
     //  Allocate a socket for this connection\r
     //\r
     ChildHandle = NULL;\r
-    pLayer = &mEslLayer;\r
     Status = EslSocketAllocate ( &ChildHandle,\r
                                  DEBUG_CONNECTION,\r
                                  &pNewSocket );\r
@@ -1041,7 +1039,7 @@ EslTcp4ListenComplete (
     //  Process:\r
     //    Call close\r
     //    Release the resources\r
-    \r
+\r
   }\r
 \r
   DBG_EXIT ( );\r
@@ -1151,7 +1149,7 @@ EslTcp4LocalAddressSet (
     //  Determine if the default address is used\r
     //\r
     pAccessPoint->UseDefaultAddress = (BOOLEAN)( 0 == pIpAddress->sin_addr.s_addr );\r
-    \r
+\r
     //\r
     //  Set the subnet mask\r
     //\r
@@ -1345,7 +1343,7 @@ EslTcp4PortAllocate (
 \r
   This routine is called by ::EslSocketPortClose.\r
   See the \ref PortCloseStateMachine section.\r
-  \r
+\r
   @param [in] pPort       Address of an ::ESL_PORT structure.\r
 \r
   @retval EFI_SUCCESS     The port is closed\r
@@ -1360,7 +1358,7 @@ EslTcp4PortClose (
   UINTN DebugFlags;\r
   ESL_TCP4_CONTEXT * pTcp4;\r
   EFI_STATUS Status;\r
-  \r
+\r
   DBG_ENTER ( );\r
 \r
   //\r
@@ -1504,13 +1502,13 @@ EslTcp4PortCloseOp (
   @param [in] pPort           Address of an ::ESL_PORT structure.\r
 \r
   @param [in] pPacket         Address of an ::ESL_PACKET structure.\r
-  \r
+\r
   @param [in] pbConsumePacket Address of a BOOLEAN indicating if the packet is to be consumed\r
-  \r
+\r
   @param [in] BufferLength    Length of the the buffer\r
-  \r
+\r
   @param [in] pBuffer         Address of a buffer to receive the data.\r
-  \r
+\r
   @param [in] pDataLength     Number of received data bytes in the buffer.\r
 \r
   @param [out] pAddress       Network address to receive the remote system address\r
@@ -1888,13 +1886,13 @@ EslTcp4RxStart (
   during the current transmission attempt.\r
 \r
   @param [in] pSocket         Address of an ::ESL_SOCKET structure\r
-  \r
+\r
   @param [in] Flags           Message control flags\r
-  \r
+\r
   @param [in] BufferLength    Length of the the buffer\r
-  \r
+\r
   @param [in] pBuffer         Address of a buffer to receive the data.\r
-  \r
+\r
   @param [in] pDataLength     Number of received data bytes in the buffer.\r
 \r
   @param [in] pAddress        Network address of the remote system address\r
@@ -1924,7 +1922,6 @@ EslTcp4TxBuffer (
   ESL_PACKET ** ppQueueHead;\r
   ESL_PACKET ** ppQueueTail;\r
   ESL_PACKET * pPreviousPacket;\r
-  ESL_TCP4_CONTEXT * pTcp4;\r
   size_t * pTxBytes;\r
   EFI_TCP4_TRANSMIT_DATA * pTxData;\r
   EFI_STATUS Status;\r
@@ -1951,7 +1948,6 @@ EslTcp4TxBuffer (
       //\r
       //  Determine the queue head\r
       //\r
-      pTcp4 = &pPort->Context.Tcp4;\r
       bUrgent = (BOOLEAN)( 0 != ( Flags & MSG_OOB ));\r
       bUrgentQueue = bUrgent\r
                     && ( !pSocket->bOobInLine )\r
@@ -2142,7 +2138,7 @@ EslTcp4TxComplete (
   ESL_PORT * pPort;\r
   ESL_SOCKET * pSocket;\r
   EFI_STATUS Status;\r
-  \r
+\r
   DBG_ENTER ( );\r
 \r
   //\r
@@ -2251,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
@@ -2261,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
@@ -2290,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
@@ -2304,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
@@ -2346,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
@@ -2372,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