This library is used to share code between UEFI network stack modules.\r
It provides the helper routines to access TCP service.\r
\r
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
-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<BR>\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
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include <Library/BaseMemoryLib.h>\r
\r
/**\r
- The common notify function associated with various TcpIo events. \r
+ The common notify function associated with various TcpIo events.\r
\r
@param[in] Event The event signaled.\r
@param[in] Context The context.\r
}\r
\r
/**\r
- Create a TCP socket with the specified configuration data. \r
+ Create a TCP socket with the specified configuration data.\r
\r
@param[in] Image The handle of the driver image.\r
@param[in] Controller The handle of the controller.\r
@param[in] TcpVersion The version of Tcp, TCP_VERSION_4 or TCP_VERSION_6.\r
@param[in] ConfigData The Tcp configuration data.\r
@param[out] TcpIo The TcpIo.\r
- \r
+\r
@retval EFI_SUCCESS The TCP socket is created and configured.\r
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
@retval EFI_UNSUPPORTED One or more of the control options are not\r
\r
//\r
// Create the TCP child instance and get the TCP protocol.\r
- // \r
+ //\r
Status = NetLibCreateServiceChild (\r
Controller,\r
Image,\r
\r
return Status;\r
}\r
- \r
+\r
/**\r
- Destroy the socket. \r
+ Destroy the socket.\r
\r
@param[in] TcpIo The TcpIo which wraps the socket to be destroyed.\r
\r
\r
@param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
@param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.\r
- \r
+\r
@retval EFI_SUCCESS Connect to the other endpoint of the TCP socket\r
successfully.\r
@retval EFI_TIMEOUT Failed to connect to the other endpoint of the\r
}\r
\r
if (!TcpIo->IsConnDone) {\r
+ if (TcpIo->TcpVersion == TCP_VERSION_4) {\r
+ Tcp4->Cancel (Tcp4, &TcpIo->ConnToken.Tcp4Token.CompletionToken);\r
+ } else {\r
+ Tcp6->Cancel (Tcp6, &TcpIo->ConnToken.Tcp6Token.CompletionToken);\r
+ }\r
Status = EFI_TIMEOUT;\r
} else {\r
Status = TcpIo->ConnToken.Tcp4Token.CompletionToken.Status;\r
@param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
@param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.\r
\r
- \r
+\r
@retval EFI_SUCCESS Connect to the other endpoint of the TCP socket\r
successfully.\r
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
}\r
\r
if (!TcpIo->IsListenDone) {\r
+ if (TcpIo->TcpVersion == TCP_VERSION_4) {\r
+ Tcp4->Cancel (Tcp4, &TcpIo->ListenToken.Tcp4Token.CompletionToken);\r
+ } else {\r
+ Tcp6->Cancel (Tcp6, &TcpIo->ListenToken.Tcp6Token.CompletionToken);\r
+ }\r
Status = EFI_TIMEOUT;\r
} else {\r
Status = TcpIo->ListenToken.Tcp4Token.CompletionToken.Status;\r
}\r
\r
//\r
- // The new TCP instance handle created for the established connection is \r
+ // The new TCP instance handle created for the established connection is\r
// in ListenToken.\r
//\r
if (!EFI_ERROR (Status)) {\r
} else {\r
ProtocolGuid = &gEfiTcp6ProtocolGuid;\r
}\r
- \r
+\r
Status = gBS->OpenProtocol (\r
TcpIo->ListenToken.Tcp4Token.NewChildHandle,\r
ProtocolGuid,\r
Tcp4 = NULL;\r
Tcp6 = NULL;\r
\r
- if (TcpIo->TcpVersion == TCP_VERSION_4) { \r
+ if (TcpIo->TcpVersion == TCP_VERSION_4) {\r
TcpIo->CloseToken.Tcp4Token.AbortOnClose = TRUE;\r
Tcp4 = TcpIo->Tcp.Tcp4;\r
Status = Tcp4->Close (Tcp4, &TcpIo->CloseToken.Tcp4Token);\r
}\r
}\r
\r
- \r
+\r
/**\r
Transmit the Packet to the other endpoint of the socket.\r
\r
@param[in] TcpIo The TcpIo wrapping the TCP socket.\r
@param[in] Packet The packet to transmit.\r
- \r
+\r
@retval EFI_SUCCESS The packet is trasmitted.\r
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
@retval EFI_UNSUPPORTED One or more of the control options are not\r
\r
if (TcpIo->TcpVersion == TCP_VERSION_4) {\r
\r
- Size = sizeof (EFI_TCP4_TRANSMIT_DATA) + \r
+ Size = sizeof (EFI_TCP4_TRANSMIT_DATA) +\r
(Packet->BlockOpNum - 1) * sizeof (EFI_TCP4_FRAGMENT_DATA);\r
} else if (TcpIo->TcpVersion == TCP_VERSION_6) {\r
Size = sizeof (EFI_TCP6_TRANSMIT_DATA) +\r
if (Tcp4 == NULL) {\r
goto ON_EXIT;\r
}\r
- \r
+\r
Status = Tcp4->Transmit (Tcp4, &TcpIo->TxToken.Tcp4Token);\r
} else {\r
TcpIo->TxToken.Tcp6Token.Packet.TxData = (EFI_TCP6_TRANSMIT_DATA *) Data;\r
}\r
\r
if (Tcp6 == NULL) {\r
- return EFI_DEVICE_ERROR; \r
+ return EFI_DEVICE_ERROR;\r
}\r
\r
} else {\r
} else {\r
Status = Tcp6->Receive (Tcp6, &TcpIo->RxToken.Tcp6Token);\r
}\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
goto ON_EXIT;\r
}\r
- \r
+\r
while (!TcpIo->IsRxDone && ((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout)))) {\r
//\r
// Poll until some data is received or an error occurs.\r