X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FDxeTcpIoLib%2FDxeTcpIoLib.c;h=341295d0b7afd49874c5ee3a2aa01579820fca90;hp=17183e1a6c818df61f2e1715b02f4d0259de140b;hb=c0fd7f734e2d33e22215899b40a47b843129541d;hpb=4b738c76f56f8eda171f14b8f9b20e34b66be476
diff --git a/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c b/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c
index 17183e1a6c..341295d0b7 100644
--- a/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c
+++ b/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c
@@ -2,14 +2,8 @@
This library is used to share code between UEFI network stack modules.
It provides the helper routines to access TCP service.
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -23,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
/**
- The common notify function associated with various TcpIo events.
+ The common notify function associated with various TcpIo events.
@param[in] Event The event signaled.
@param[in] Context The context.
@@ -111,14 +105,14 @@ ON_EXIT:
}
/**
- Create a TCP socket with the specified configuration data.
+ Create a TCP socket with the specified configuration data.
@param[in] Image The handle of the driver image.
@param[in] Controller The handle of the controller.
@param[in] TcpVersion The version of Tcp, TCP_VERSION_4 or TCP_VERSION_6.
@param[in] ConfigData The Tcp configuration data.
@param[out] TcpIo The TcpIo.
-
+
@retval EFI_SUCCESS The TCP socket is created and configured.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_UNSUPPORTED One or more of the control options are not
@@ -176,7 +170,7 @@ TcpIoCreateSocket (
//
// Create the TCP child instance and get the TCP protocol.
- //
+ //
Status = NetLibCreateServiceChild (
Controller,
Image,
@@ -395,9 +389,9 @@ ON_ERROR:
return Status;
}
-
+
/**
- Destroy the socket.
+ Destroy the socket.
@param[in] TcpIo The TcpIo which wraps the socket to be destroyed.
@@ -530,8 +524,8 @@ TcpIoDestroySocket (
Connect to the other endpoint of the TCP socket.
@param[in, out] TcpIo The TcpIo wrapping the TCP socket.
- @param[in] Timeout The time to wait for connection done.
-
+ @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.
+
@retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
successfully.
@retval EFI_TIMEOUT Failed to connect to the other endpoint of the
@@ -546,7 +540,7 @@ EFI_STATUS
EFIAPI
TcpIoConnect (
IN OUT TCP_IO *TcpIo,
- IN EFI_EVENT Timeout
+ IN EFI_EVENT Timeout OPTIONAL
)
{
EFI_TCP4_PROTOCOL *Tcp4;
@@ -576,7 +570,7 @@ TcpIoConnect (
return Status;
}
- while (!TcpIo->IsConnDone && EFI_ERROR (gBS->CheckEvent (Timeout))) {
+ while (!TcpIo->IsConnDone && ((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout)))) {
if (TcpIo->TcpVersion == TCP_VERSION_4) {
Tcp4->Poll (Tcp4);
} else {
@@ -585,6 +579,11 @@ TcpIoConnect (
}
if (!TcpIo->IsConnDone) {
+ if (TcpIo->TcpVersion == TCP_VERSION_4) {
+ Tcp4->Cancel (Tcp4, &TcpIo->ConnToken.Tcp4Token.CompletionToken);
+ } else {
+ Tcp6->Cancel (Tcp6, &TcpIo->ConnToken.Tcp6Token.CompletionToken);
+ }
Status = EFI_TIMEOUT;
} else {
Status = TcpIo->ConnToken.Tcp4Token.CompletionToken.Status;
@@ -597,9 +596,9 @@ TcpIoConnect (
Accept the incomding request from the other endpoint of the TCP socket.
@param[in, out] TcpIo The TcpIo wrapping the TCP socket.
- @param[in] Timeout The time to wait for connection done.
+ @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.
+
-
@retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
successfully.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@@ -607,7 +606,7 @@ TcpIoConnect (
supported in the implementation.
@retval EFI_TIMEOUT Failed to connect to the other endpoint of the
- TCP socket in the specified time period.
+ TCP socket in the specified time period.
@retval Others Other errors as indicated.
**/
@@ -615,7 +614,7 @@ EFI_STATUS
EFIAPI
TcpIoAccept (
IN OUT TCP_IO *TcpIo,
- IN EFI_EVENT Timeout
+ IN EFI_EVENT Timeout OPTIONAL
)
{
EFI_STATUS Status;
@@ -646,7 +645,7 @@ TcpIoAccept (
return Status;
}
- while (!TcpIo->IsListenDone && EFI_ERROR (gBS->CheckEvent (Timeout))) {
+ while (!TcpIo->IsListenDone && ((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout)))) {
if (TcpIo->TcpVersion == TCP_VERSION_4) {
Tcp4->Poll (Tcp4);
} else {
@@ -655,13 +654,18 @@ TcpIoAccept (
}
if (!TcpIo->IsListenDone) {
+ if (TcpIo->TcpVersion == TCP_VERSION_4) {
+ Tcp4->Cancel (Tcp4, &TcpIo->ListenToken.Tcp4Token.CompletionToken);
+ } else {
+ Tcp6->Cancel (Tcp6, &TcpIo->ListenToken.Tcp6Token.CompletionToken);
+ }
Status = EFI_TIMEOUT;
} else {
Status = TcpIo->ListenToken.Tcp4Token.CompletionToken.Status;
}
//
- // The new TCP instance handle created for the established connection is
+ // The new TCP instance handle created for the established connection is
// in ListenToken.
//
if (!EFI_ERROR (Status)) {
@@ -670,7 +674,7 @@ TcpIoAccept (
} else {
ProtocolGuid = &gEfiTcp6ProtocolGuid;
}
-
+
Status = gBS->OpenProtocol (
TcpIo->ListenToken.Tcp4Token.NewChildHandle,
ProtocolGuid,
@@ -709,7 +713,7 @@ TcpIoReset (
Tcp4 = NULL;
Tcp6 = NULL;
- if (TcpIo->TcpVersion == TCP_VERSION_4) {
+ if (TcpIo->TcpVersion == TCP_VERSION_4) {
TcpIo->CloseToken.Tcp4Token.AbortOnClose = TRUE;
Tcp4 = TcpIo->Tcp.Tcp4;
Status = Tcp4->Close (Tcp4, &TcpIo->CloseToken.Tcp4Token);
@@ -734,13 +738,13 @@ TcpIoReset (
}
}
-
+
/**
Transmit the Packet to the other endpoint of the socket.
@param[in] TcpIo The TcpIo wrapping the TCP socket.
@param[in] Packet The packet to transmit.
-
+
@retval EFI_SUCCESS The packet is trasmitted.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_UNSUPPORTED One or more of the control options are not
@@ -769,7 +773,7 @@ TcpIoTransmit (
if (TcpIo->TcpVersion == TCP_VERSION_4) {
- Size = sizeof (EFI_TCP4_TRANSMIT_DATA) +
+ Size = sizeof (EFI_TCP4_TRANSMIT_DATA) +
(Packet->BlockOpNum - 1) * sizeof (EFI_TCP4_FRAGMENT_DATA);
} else if (TcpIo->TcpVersion == TCP_VERSION_6) {
Size = sizeof (EFI_TCP6_TRANSMIT_DATA) +
@@ -815,7 +819,7 @@ TcpIoTransmit (
if (Tcp4 == NULL) {
goto ON_EXIT;
}
-
+
Status = Tcp4->Transmit (Tcp4, &TcpIo->TxToken.Tcp4Token);
} else {
TcpIo->TxToken.Tcp6Token.Packet.TxData = (EFI_TCP6_TRANSMIT_DATA *) Data;
@@ -860,7 +864,7 @@ ON_EXIT:
@param[in] Packet The buffer to hold the data copy from the socket rx buffer.
@param[in] AsyncMode Is this receive asyncronous or not.
@param[in] Timeout The time to wait for receiving the amount of data the Packet
- can hold.
+ can hold. Set to NULL for infinite wait.
@retval EFI_SUCCESS The required amount of data is received from the socket.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@@ -877,7 +881,7 @@ TcpIoReceive (
IN OUT TCP_IO *TcpIo,
IN NET_BUF *Packet,
IN BOOLEAN AsyncMode,
- IN EFI_EVENT Timeout
+ IN EFI_EVENT Timeout OPTIONAL
)
{
EFI_TCP4_PROTOCOL *Tcp4;
@@ -919,7 +923,7 @@ TcpIoReceive (
}
if (Tcp6 == NULL) {
- return EFI_DEVICE_ERROR;
+ return EFI_DEVICE_ERROR;
}
} else {
@@ -951,11 +955,11 @@ TcpIoReceive (
} else {
Status = Tcp6->Receive (Tcp6, &TcpIo->RxToken.Tcp6Token);
}
-
+
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
-
+
while (!TcpIo->IsRxDone && ((Timeout == NULL) || EFI_ERROR (gBS->CheckEvent (Timeout)))) {
//
// Poll until some data is received or an error occurs.