/** @file
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.<BR>
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<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Library/TcpIoLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
/**
The common notify function associated with various TcpIo events.
@param[in] Event The event signaled.
@param[in] Context The context.
**/
)
{
return ;
}
}
/**
The internal function for delay configuring TCP6 when IP6 driver is still in DAD.
@param[in] Tcp6 The EFI_TCP6_PROTOCOL protocol instance.
@param[in] Tcp6ConfigData The Tcp6 configuration data.
@retval EFI_SUCCESS The operational settings successfully
completed.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval Others Failed to finish the operation.
**/
)
{
return EFI_INVALID_PARAMETER;
}
NULL,
NULL,
);
goto ON_EXIT;
}
);
goto ON_EXIT;
}
break;
}
}
}
return Status;
}
/**
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
supported in the implementation.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
@retval Others Failed to create the TCP socket or configure it.
**/
)
{
return EFI_INVALID_PARAMETER;
}
if (TcpVersion == TCP_VERSION_4) {
} else if (TcpVersion == TCP_VERSION_6) {
} else {
return EFI_UNSUPPORTED;
}
//
// Create the TCP child instance and get the TCP protocol.
//
);
return Status;
}
);
goto ON_ERROR;
}
if (TcpVersion == TCP_VERSION_4) {
} else {
}
//
// Set the configuration parameters.
//
ControlOption.FinTimeout = 0;
if (TcpVersion == TCP_VERSION_4) {
CopyMem (
sizeof (EFI_IPv4_ADDRESS)
);
CopyMem (
sizeof (EFI_IPv4_ADDRESS)
);
CopyMem (
sizeof (EFI_IPv4_ADDRESS)
);
//
// Configure the TCP4 protocol.
//
goto ON_ERROR;
}
//
// The gateway is not zero. Add the default route manually.
//
Tcp4,
);
goto ON_ERROR;
}
}
} else {
//
// Configure the TCP6 protocol.
//
if (Status == EFI_NO_MAPPING) {
}
goto ON_ERROR;
}
}
//
// Create events for variuos asynchronous operations.
//
&TcpIo->IsConnDone,
);
goto ON_ERROR;
}
);
goto ON_ERROR;
}
);
goto ON_ERROR;
}
);
goto ON_ERROR;
}
goto ON_ERROR;
}
&TcpIo->IsCloseDone,
);
goto ON_ERROR;
}
return EFI_SUCCESS;
return Status;
}
/**
Destroy the socket.
@param[in] TcpIo The TcpIo which wraps the socket to be destroyed.
**/
)
{
return ;
}
return ;
}
}
}
}
}
}
}
if (TcpVersion == TCP_VERSION_4) {
}
} else {
}
}
gBS->CloseProtocol (
);
}
ChildHandle = NULL;
if (TcpIo->IsListenDone) {
if (TcpVersion == TCP_VERSION_4) {
}
} else {
}
}
if (ChildHandle != NULL) {
gBS->CloseProtocol (
);
}
}
);
}
/**
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.
@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
TCP socket in the specified time period.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_UNSUPPORTED One or more of the control options are not
supported in the implementation.
@retval Others Other errors as indicated.
**/
)
{
return EFI_INVALID_PARAMETER;
}
} else {
return EFI_UNSUPPORTED;
}
return Status;
}
} else {
}
}
if (!TcpIo->IsConnDone) {
} else {
}
return Status;
}
/**
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.
@retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
successfully.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_UNSUPPORTED One or more of the control options are not
supported in the implementation.
@retval EFI_TIMEOUT Failed to connect to the other endpoint of the
TCP socket in the specified time period.
@retval Others Other errors as indicated.
**/
)
{
return EFI_INVALID_PARAMETER;
}
} else {
return EFI_UNSUPPORTED;
}
return Status;
}
} else {
}
}
if (!TcpIo->IsListenDone) {
} else {
}
//
// The new TCP instance handle created for the established connection is
// in ListenToken.
//
} else {
}
);
}
return Status;
}
/**
Reset the socket.
@param[in, out] TcpIo The TcpIo wrapping the TCP socket.
**/
)
{
return ;
}
} else {
return ;
}
return ;
}
while (!TcpIo->IsCloseDone) {
} else {
}
}
}
/**
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
supported in the implementation.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
@retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
@retval Others Other errors as indicated.
**/
)
{
return EFI_INVALID_PARAMETER;
}
Size = sizeof (EFI_TCP4_TRANSMIT_DATA) +
Size = sizeof (EFI_TCP6_TRANSMIT_DATA) +
} else {
return EFI_UNSUPPORTED;
}
return EFI_OUT_OF_RESOURCES;
}
//
// Build the fragment table.
//
);
//
// Trasnmit the packet.
//
if (TcpIo->IsListenDone) {
}
goto ON_EXIT;
}
} else {
if (TcpIo->IsListenDone) {
}
goto ON_EXIT;
}
}
goto ON_EXIT;
}
} else {
}
}
return Status;
}
/**
Receive data from the socket.
@param[in, out] TcpIo The TcpIo which wraps the socket to be destroyed.
@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.
@retval EFI_SUCCESS The required amount of data is received from the socket.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
@retval EFI_OUT_OF_RESOURCES Failed to allocate momery.
@retval EFI_TIMEOUT Failed to receive the required amount of data in the
specified time period.
@retval Others Other errors as indicated.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
if (TcpIo->IsListenDone) {
}
return EFI_DEVICE_ERROR;
}
if (TcpIo->IsListenDone) {
}
return EFI_DEVICE_ERROR;
}
} else {
return EFI_UNSUPPORTED;
}
goto ON_EXIT;
}
//
// Build the fragment table.
//
CurrentFragment = 0;
while (CurrentFragment < FragmentCount) {
} else {
}
goto ON_EXIT;
}
//
// Poll until some data is received or an error occurs.
//
} else {
}
}
//
// Timeout occurs, cancel the receive request.
//
} else {
}
goto ON_EXIT;
} else {
}
goto ON_EXIT;
}
} else {
}
}
}
return Status;
}