/** @file
The implementation of a dispatch routine for processing TCP requests.
Copyright (c) 2009 - 2010, 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
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 "TcpMain.h"
/**
Add or remove a route entry in the IP route table associated with this TCP instance.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] RouteInfo Pointer to the route information to be processed.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_NOT_STARTED The driver instance has not been started.
@retval EFI_NO_MAPPING When using the default address, configuration(DHCP,
BOOTP, RARP, etc.) is not finished yet.
@retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
@retval EFI_NOT_FOUND This route is not in the routing table
(when RouteInfo->DeleteRoute is TRUE).
@retval EFI_ACCESS_DENIED The route is already defined in the routing table
(when RouteInfo->DeleteRoute is FALSE).
**/
)
{
);
}
/**
Get the operational settings of this TCPv4 instance.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in, out] Mode Pointer to the buffer to store the operational
settings.
@retval EFI_SUCCESS The mode data was read.
@retval EFI_NOT_STARTED No configuration data is available because this
instance hasn't been started.
**/
)
{
return EFI_NOT_STARTED;
}
}
}
}
}
/**
Get the operational settings of this TCPv6 instance.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in, out] Mode Pointer to the buffer to store the operational
settings.
@retval EFI_SUCCESS The mode data was read.
@retval EFI_NOT_STARTED No configuration data is available because this
instance hasn't been started.
**/
)
{
return EFI_NOT_STARTED;
}
}
}
}
}
/**
If TcpAp->StationPort isn't zero, check whether the access point
is registered, else generate a random station port for this
access point.
@param[in] TcpAp Pointer to the access point.
@param[in] IpVersion IP_VERSION_4 or IP_VERSION_6
@retval EFI_SUCCESS The check passed or the port is assigned.
@retval EFI_INVALID_PARAMETER The non-zero station port is already used.
@retval EFI_OUT_OF_RESOURCES No port can be allocated.
**/
TcpBind (
)
{
if (IpVersion == IP_VERSION_4) {
} else {
}
if (0 != *Port) {
//
// Check if a same endpoing is bound.
//
return EFI_INVALID_PARAMETER;
}
} else {
//
// generate a random port
//
if (TCP_PORT_USER_RESERVED == *RandomPort) {
}
(*RandomPort)++;
(*RandomPort)++;
if (*RandomPort <= TCP_PORT_KNOWN) {
if (Cycle) {
DEBUG (
"TcpBind: no port can be allocated for this pcb\n")
);
return EFI_OUT_OF_RESOURCES;
}
}
}
*Port = *RandomPort;
}
return EFI_SUCCESS;
}
/**
Flush the Tcb add its associated protocols.
@param[in, out] Tcb Pointer to the TCP_CB to be flushed.
**/
)
{
if (SOCK_IS_CONFIGURED (Sock)) {
//
// Uninstall the device path protocl.
//
);
}
}
}
/**
Attach a Pcb to the socket.
@param[in] Sk Pointer to the socket of this TCP instance.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_OUT_OF_RESOURCES Failed due to resource limits.
**/
)
{
return EFI_OUT_OF_RESOURCES;
}
//
// Create an IpInfo for this Tcb.
//
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
/**
Detach the Pcb of the socket.
@param[in, out] Sk Pointer to the socket of this TCP instance.
**/
)
{
TcpFlushPcb (Tcb);
}
/**
Configure the Pcb using CfgData.
@param[in] Sk Pointer to the socket of this TCP instance.
@param[in] CfgData Pointer to the TCP configuration data.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_INVALID_PARAMETER A same access point has been configured in
another TCP instance.
@retval EFI_OUT_OF_RESOURCES Failed due to resource limits.
**/
)
{
//
// Add Ip for send pkt to the peer
//
CopyMem (
sizeof (EFI_IPv4_ADDRESS)
);
} else {
);
);
}
//
// Configure the IP instance this Tcb consumes.
//
goto OnExit;
}
//
// Get the default address information if the instance is configured to use default address.
//
} else {
);
}
//
// check if we can bind this endpoint in CfgData
//
DEBUG (
"TcpConfigurePcb: Bind endpoint failed with %r\n",
);
goto OnExit;
}
//
// Initalize the operating information in this Tcb
//
//
// initialize Tcb in the light of CfgData
//
} else {
//
// Type EFI_TCP4_OPTION and EFI_TCP6_OPTION are the same.
//
}
Sk,
(UINT32) (TCP_COMP_VAL (
)
)
);
Sk,
(UINT32) (TCP_COMP_VAL (
)
)
);
Sk,
(UINT32) (TCP_COMP_VAL (
)
)
);
);
);
if (Option->TimeWaitTimeout != 0) {
);
} else {
Tcb->TimeWaitTimeout = 0;
}
if (Option->KeepAliveProbes != 0) {
);
);
);
}
);
if (!Option->EnableNagle) {
}
if (!Option->EnableTimeStamp) {
}
if (!Option->EnableWindowScaling) {
}
}
//
// The socket is bound, the <SrcIp, SrcPort, DstIp, DstPort> is
// determined, construct the IP device path and install it.
//
goto OnExit;
}
//
// update state of Tcb and socket
//
) {
} else {
}
}
TcpInsertTcb (Tcb);
return Status;
}
/**
The procotol handler provided to the socket layer, which is used to
dispatch the socket level requests by calling the corresponding
TCP layer functions.
@param[in] Sock Pointer to the socket of this TCP instance.
@param[in] Request The code of this operation request.
@param[in] Data Pointer to the operation specific data passed in
together with the operation request. This is an
optional parameter that may be NULL.
@retval EFI_SUCCESS The socket request completed successfully.
@retval other The error status returned by the corresponding TCP
layer function.
**/
)
{
switch (Request) {
case SOCK_POLL:
} else {
}
break;
case SOCK_CONSUMED:
//
// After user received data from socket buffer, socket will
// notify TCP using this message to give it a chance to send out
// window update information
//
break;
case SOCK_SND:
TcpOnAppSend (Tcb);
break;
case SOCK_CLOSE:
TcpOnAppClose (Tcb);
break;
case SOCK_ABORT:
TcpOnAppAbort (Tcb);
break;
case SOCK_SNDPUSH:
break;
case SOCK_SNDURG:
break;
case SOCK_CONNECT:
break;
case SOCK_ATTACH:
return TcpAttachPcb (Sock);
break;
case SOCK_FLUSH:
TcpFlushPcb (Tcb);
break;
case SOCK_DETACH:
TcpDetachPcb (Sock);
break;
case SOCK_CONFIGURE:
return TcpConfigurePcb (
Sock,
(TCP_CONFIG_DATA *) Data
);
break;
case SOCK_MODE:
} else {
}
break;
case SOCK_ROUTE:
default:
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}