TcpFunc.h revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Declaration of external functions shared in TCP driver.
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.
**/
#ifndef _TCP_FUNC_H_
#define _TCP_FUNC_H_
#include "TcpOption.h"
/**
Timeout handler prototype.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
typedef
(*TCP_TIMER_HANDLER) (
);
//
// Functions in TcpMisc.c
//
/**
Initialize the Tcb locally related members.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
/**
Initialize the peer related members.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Seg Pointer to the segment that contains the peer's intial information.
@param[in] Opt Pointer to the options announced by the peer.
**/
);
/**
Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.
@param[in] Addr Pointer to the IP address needs to match.
@param[in] Port The port number needs to match.
@param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack.
IP_VERSION_6 indicates TCP is running on IP6 stack.
@retval TRUE The Tcb which matches the <Addr Port> pairs exists.
@retval FALSE Otherwise
**/
);
/**
Locate the TCP_CB related to the socket pair.
@param[in] LocalPort The local port number.
@param[in] LocalIp The local IP address.
@param[in] RemotePort The remote port number.
@param[in] RemoteIp The remote IP address.
@param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
IP_VERSION_6 indicates TCP is running on IP6 stack.
@param[in] Syn If TRUE, the listen sockets are searched.
@return Pointer to the related TCP_CB. If NULL, no match is found.
**/
TCP_CB *
);
/**
Insert a Tcb into the proper queue.
@param[in] Tcb Pointer to the TCP_CB to be inserted.
@retval 0 The Tcb was inserted successfully.
@retval -1 An error condition occurred.
**/
);
/**
Clone a TCP_CB from Tcb.
@param[in] Tcb Pointer to the TCP_CB to be cloned.
@return Pointer to the new cloned TCP_CB. If NULL, an error condition occurred.
**/
TCP_CB *
);
/**
Compute an ISS to be used by a new connection.
@return The result ISS.
**/
);
/**
Get the local mss.
@param[in] Sock Pointer to the socket to get mss.
@return The mss size.
**/
);
/**
Set the Tcb's state.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] State The state to be set.
**/
);
/**
Compute the TCP segment's checksum.
@param[in] Nbuf Pointer to the buffer that contains the TCP segment.
@param[in] HeadSum The checksum value of the fixed part of pseudo header.
@return The checksum value.
**/
);
/**
Translate the information from the head of the received TCP
segment Nbuf contains, and fill it into a TCP_SEG structure.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in, out] Nbuf Pointer to the buffer contains the TCP segment.
@return Pointer to the TCP_SEG that contains the translated TCP head information.
**/
TCP_SEG *
);
/**
Initialize an active connection,
@param[in, out] Tcb Pointer to the TCP_CB that wants to initiate a
connection.
**/
);
/**
Application has consumed some data, check whether
to send a window update ack or a delayed ack.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
/**
Initiate the connection close procedure, called when
applications want to close the connection.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
/**
Check whether the application's newly delivered data can be sent out.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
@retval 0 The data has been sent out successfully.
@retval -1 The Tcb is not in a state that data is permitted to
be sent out.
**/
);
/**
Abort the connection by sending a reset segment: called
when the application wants to abort the connection.
@param[in] Tcb Pointer to the TCP_CB of the TCP instance.
**/
);
/**
Reset the connection related with Tcb.
@param[in] Tcb Pointer to the TCP_CB of the connection to be reset.
**/
);
/**
Set the Tcp variable data.
@param[in] TcpService Tcp service data.
@retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.
@retval other Set variable failed.
**/
);
/**
Clear the variable and free the resource.
@param[in] TcpService Tcp service data.
**/
);
/**
Install the device path protocol on the TCP instance.
@param[in] Sock Pointer to the socket representing the TCP instance.
@retval EFI_SUCCESS The device path protocol installed.
@retval other Failed to install the device path protocol.
**/
);
//
// Functions in TcpOutput.c
//
/**
Compute the sequence space left in the old receive window.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@return The sequence space left in the old receive window.
**/
);
/**
Compute the current receive window.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@return The size of the current receive window, in bytes.
**/
);
/**
Get the maximum SndNxt.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@return The sequence number of the maximum SndNxt.
**/
);
/**
Compute how much data to send.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
and send out data by force.
@return The length of the data that can be sent. If 0, no data can be sent.
**/
);
/**
Retransmit the segment from sequence Seq.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Seq The sequence number of the segment to be retransmitted.
@retval 0 The retransmission succeeded.
@retval -1 An error condition occurred.
**/
);
/**
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
and send out data by force.
@return The number of bytes sent.
**/
);
/**
Check whether to send an ACK or delayed ACK.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
/**
Send an ACK immediately.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
/**
Send a zero probe segment. It can be used by keepalive and zero window probe.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
@retval 0 The zero probe segment was sent out successfully.
@retval other An error condition occurred.
**/
);
/**
Send a RESET segment in response to the segment received.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance, may be NULL.
@param[in] Head TCP header of the segment that triggers the reset.
@param[in] Len Length of the segment that triggers the reset.
@param[in] Local Local IP address.
@param[in] Remote Remote peer's IP address.
@param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
IP_VERSION_6 indicates TCP is running on IP6 stack.
@retval 0 A reset is sent or no need to send it.
@retval -1 No reset is sent.
**/
);
/**
Verify that the segment is in good shape.
@param[in] Nbuf Buffer that contains the segment to be checked.
@retval 0 The segment is broken.
@retval 1 The segment is in good shape.
**/
);
//
// Functions from TcpInput.c
//
/**
Process the received ICMP error messages for TCP.
@param[in] Nbuf Buffer that contains part of the TCP segment without IP header
truncated from the ICMP error packet.
@param[in] IcmpErr The ICMP error code interpreted from an ICMP error packet.
@param[in] Src Source address of the ICMP error message.
@param[in] Dst Destination address of the ICMP error message.
@param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
IP6 stack.
**/
);
/**
Process the received TCP segments.
@param[in] Nbuf Buffer that contains received TCP segment without an IP header.
@param[in] Src Source address of the segment, or the peer's IP address.
@param[in] Dst Destination address of the segment, or the local end's IP
address.
@param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
IP6 stack.
@retval 0 The segment processed successfully. It is either accepted or
discarded. But no connection is reset by the segment.
@retval -1 A connection is reset by the segment.
**/
TcpInput (
);
//
// Functions in TcpTimer.c
//
/**
Close the TCP connection.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
TcpClose (
);
/**
Heart beat timer handler, queues the DPC at TPL_CALLBACK.
@param[in] Event Timer event signaled, ignored.
@param[in] Context Context of the timer event, ignored.
**/
);
/**
Enable a TCP timer.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Timer The index of the timer to be enabled.
@param[in] TimeOut The timeout value of this timer.
**/
);
/**
Clear one TCP timer.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Timer The index of the timer to be cleared.
**/
);
/**
Clear all TCP timers.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
/**
Enable the window prober timer and set the timeout value.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
/**
Enable the keepalive timer and set the timeout value.
@param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
**/
);
//
// Functions in TcpIo.c
//
/**
Packet receive callback function provided to IP_IO. Used to call
the proper function to handle the packet received by IP.
@param[in] Status Result of the receive request.
@param[in] IcmpErr Valid when Status is EFI_ICMP_ERROR.
@param[in] NetSession The IP session for the received packet.
@param[in] Pkt Packet received.
@param[in] Context The data provided by the user for the received packet when
the callback is registered in IP_IO_OPEN_DATA::RcvdContext.
This is an optional parameter that may be NULL.
**/
);
/**
Send the segment to IP via IpIo function.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Nbuf Pointer to the TCP segment to be sent.
@param[in] Src Source address of the TCP segment.
@param[in] Dest Destination address of the TCP segment.
@param[in] Version IP_VERSION_4 or IP_VERSION_6
@retval 0 The segment was sent out successfully.
@retval -1 The segment failed to be sent.
**/
);
/**
Refresh the remote peer's Neighbor Cache State if already exists.
@param[in] Tcb Pointer to the TCP_CB of this TCP instance.
@param[in] Neighbor Source address of the TCP segment.
@param[in] Timeout Time in 100-ns units that this entry will remain
in the neighbor cache. A value of zero means that
the entry is permanent. A value of non-zero means
that the entry is dynamic and will be deleted
after Timeout.
@retval EFI_SUCCESS Successfully updated the neighbor relationship.
@retval EFI_NOT_STARTED The IpIo is not configured.
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
@retval EFI_NOT_FOUND This entry is not in the neighbor table.
**/
);
//
// Functions in TcpDispatcher.c
//
/**
The procotol handler provided to the socket layer, 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.
**/
);
#endif