2007-09-30 05:08:02 +02:00
|
|
|
/** @file
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
2007-09-30 05:08:02 +02:00
|
|
|
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
|
2008-12-16 03:57:53 +01:00
|
|
|
http://opensource.org/licenses/bsd-license.php<BR>
|
2007-09-30 05:08:02 +02:00
|
|
|
|
|
|
|
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 _TCP4_FUNC_H_
|
|
|
|
#define _TCP4_FUNC_H_
|
|
|
|
|
|
|
|
//
|
|
|
|
// Declaration of all the functions in TCP
|
|
|
|
// protocol. It is intended to keep tcp.h
|
|
|
|
// clear.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions in tcp.c
|
|
|
|
//
|
2008-12-16 03:57:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.
|
|
|
|
|
|
|
|
@param Addr Pointer to the IP address needs to match.
|
|
|
|
@param Port The port number needs to match.
|
|
|
|
|
|
|
|
@return The Tcb which matches the <Addr Port> paire exists or not.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
BOOLEAN
|
|
|
|
TcpFindTcbByPeer (
|
|
|
|
IN EFI_IPv4_ADDRESS *Addr,
|
|
|
|
IN TCP_PORTNO Port
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Locate the TCP_CB related to the socket pair.
|
|
|
|
|
|
|
|
@param LocalPort The local port number.
|
|
|
|
@param LocalIp The local IP address.
|
|
|
|
@param RemotePort The remote port number.
|
|
|
|
@param RemoteIp The remote IP address.
|
|
|
|
@param Syn Whether to search the listen sockets, if TRUE, the
|
|
|
|
listen sockets are searched.
|
|
|
|
|
|
|
|
@return Pointer to the related TCP_CB, if NULL no match is found.
|
|
|
|
|
|
|
|
**/
|
|
|
|
TCP_CB *
|
2007-09-30 05:08:02 +02:00
|
|
|
TcpLocateTcb (
|
|
|
|
IN TCP_PORTNO LocalPort,
|
|
|
|
IN UINT32 LocalIp,
|
|
|
|
IN TCP_PORTNO RemotePort,
|
|
|
|
IN UINT32 RemoteIp,
|
|
|
|
IN BOOLEAN Syn
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Insert a Tcb into the proper queue.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB to be inserted.
|
|
|
|
|
|
|
|
@retval 0 The Tcb is inserted successfully.
|
|
|
|
@retval -1 Error condition occurred.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpInsertTcb (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Clone a TCP_CB from Tcb.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB to be cloned.
|
|
|
|
|
|
|
|
@return Pointer to the new cloned TCP_CB, if NULL error condition occurred.
|
|
|
|
|
|
|
|
**/
|
|
|
|
TCP_CB *
|
2007-09-30 05:08:02 +02:00
|
|
|
TcpCloneTcb (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Compute an ISS to be used by a new connection.
|
|
|
|
|
|
|
|
@return The result ISS.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
TCP_SEQNO
|
|
|
|
TcpGetIss (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Initialize the Tcb local related members.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpInitTcbLocal (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Initialize the peer related members.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seg Pointer to the segment that contains the peer's
|
|
|
|
intial info.
|
|
|
|
@param Opt Pointer to the options announced by the peer.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpInitTcbPeer (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN TCP_SEG *Seg,
|
|
|
|
IN TCP_OPTION *Opt
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Get the local mss.
|
|
|
|
|
|
|
|
@param Sock Pointer to the socket to get mss
|
|
|
|
|
|
|
|
@return The mss size.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
UINT16
|
|
|
|
TcpGetRcvMss (
|
2008-12-16 03:57:53 +01:00
|
|
|
IN SOCKET *Sock
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Set the Tcb's state.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param State The state to be set.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpSetState (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN UINT8 State
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions in Tcp4Output.c
|
|
|
|
//
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Send the segment to IP via IpIo function.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Nbuf Pointer to the TCP segment to be sent.
|
|
|
|
@param Src Source address of the TCP segment.
|
|
|
|
@param Dest Destination address of the TCP segment.
|
|
|
|
|
|
|
|
@retval 0 The segment was sent out successfully.
|
|
|
|
@retval -1 The segment was failed to send.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpSendIpPacket (
|
2008-12-16 03:57:53 +01:00
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN NET_BUF *Nbuf,
|
|
|
|
IN UINT32 Src,
|
|
|
|
IN UINT32 Dest
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Check whether to send data/SYN/FIN and piggy back an ACK.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Force Whether to ignore the sender's SWS avoidance algorithm and send
|
|
|
|
out data by force.
|
|
|
|
|
|
|
|
@return The number of bytes sent.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpToSendData (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN INTN Force
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Check whether to send an ACK or delayed ACK.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpToSendAck (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Send an ACK immediately.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpSendAck (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Send a zero probe segment. It can be used by keepalive and zero window probe.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
@retval 0 The zero probe segment was sent out successfully.
|
|
|
|
@retval other Error condition occurred.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpSendZeroProbe (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Process the data and FIN flag, check whether to deliver
|
|
|
|
data to the socket layer.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
@retval 0 No error occurred to deliver data.
|
|
|
|
@retval -1 Error condition occurred. Proper response is to reset the
|
|
|
|
connection.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpDeliverData (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Send a RESET segment in response to the segment received.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance, may be NULL.
|
|
|
|
@param Head TCP header of the segment that triggers the reset.
|
|
|
|
@param Len Length of the segment that triggers the reset.
|
|
|
|
@param Local Local IP address.
|
|
|
|
@param Remote Remote peer's IP address.
|
|
|
|
|
|
|
|
@retval 0 A reset is sent or no need to send it.
|
|
|
|
@retval -1 No reset is sent.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpSendReset (
|
2008-12-16 03:57:53 +01:00
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN TCP_HEAD *Head,
|
|
|
|
IN INT32 Len,
|
|
|
|
IN UINT32 Local,
|
|
|
|
IN UINT32 Remote
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Compute the sequence space left in the old receive window.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
@return The sequence space left in the old receive window.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
UINT32
|
|
|
|
TcpRcvWinOld (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Compute the current receive window.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
@return The size of the current receive window, in bytes.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
UINT32
|
|
|
|
TcpRcvWinNow (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Retransmit the segment from sequence Seq.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seq The sequence number of the segment to be retransmitted.
|
|
|
|
|
|
|
|
@retval 0 Retransmission succeeded.
|
|
|
|
@retval -1 Error condition occurred.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpRetransmit (
|
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN TCP_SEQNO Seq
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Compute how much data to send.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Force Whether to ignore the sender's SWS avoidance algorithm and send
|
|
|
|
out data by force.
|
|
|
|
|
|
|
|
@return The length of the data can be sent, if 0, no data can be sent.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
UINT32
|
|
|
|
TcpDataToSend (
|
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN INTN Force
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Verify that the segment is in good shape.
|
|
|
|
|
|
|
|
@param Nbuf Buffer that contains the segment to be checked.
|
|
|
|
|
|
|
|
@retval 0 The segment is broken.
|
|
|
|
@retval 1 The segment is in good shape.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpVerifySegment (
|
|
|
|
IN NET_BUF *Nbuf
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Verify that all the segments in SndQue are in good shape.
|
|
|
|
|
|
|
|
@param Head Pointer to the head node of the SndQue.
|
|
|
|
|
|
|
|
@retval 0 At least one segment is broken.
|
|
|
|
@retval 1 All segments in the specific queue are in good shape.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpCheckSndQue (
|
2008-02-14 10:40:22 +01:00
|
|
|
IN LIST_ENTRY *Head
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Get a segment from the Tcb's SndQue.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seq The sequence number of the segment.
|
|
|
|
@param Len The maximum length of the segment.
|
|
|
|
|
|
|
|
@return Pointer to the segment, if NULL some error occurred.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
NET_BUF *
|
|
|
|
TcpGetSegmentSndQue (
|
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN TCP_SEQNO Seq,
|
|
|
|
IN UINT32 Len
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Get a segment from the Tcb's socket buffer.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seq The sequence number of the segment.
|
|
|
|
@param Len The maximum length of the segment.
|
|
|
|
|
|
|
|
@return Pointer to the segment, if NULL some error occurred.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
NET_BUF *
|
|
|
|
TcpGetSegmentSock (
|
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN TCP_SEQNO Seq,
|
|
|
|
IN UINT32 Len
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Get a segment starting from sequence Seq of a maximum
|
|
|
|
length of Len.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seq The sequence number of the segment.
|
|
|
|
@param Len The maximum length of the segment.
|
|
|
|
|
|
|
|
@return Pointer to the segment, if NULL some error occurred.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
NET_BUF *
|
|
|
|
TcpGetSegment (
|
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN TCP_SEQNO Seq,
|
|
|
|
IN UINT32 Len
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Get the maximum SndNxt.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
@return The sequence number of the maximum SndNxt.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
TCP_SEQNO
|
|
|
|
TcpGetMaxSndNxt (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions from Tcp4Input.c
|
|
|
|
//
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Process the received ICMP error messages for TCP.
|
|
|
|
|
|
|
|
@param Nbuf Buffer that contains part of the TCP segment without IP header
|
|
|
|
truncated from the ICMP error packet.
|
|
|
|
@param IcmpErr The ICMP error code interpreted from ICMP error packet.
|
|
|
|
@param Src Source address of the ICMP error message.
|
|
|
|
@param Dst Destination address of the ICMP error message.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpIcmpInput (
|
|
|
|
IN NET_BUF *Nbuf,
|
|
|
|
IN ICMP_ERROR IcmpErr,
|
|
|
|
IN UINT32 Src,
|
|
|
|
IN UINT32 Dst
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Process the received TCP segments.
|
|
|
|
|
|
|
|
@param Nbuf Buffer that contains received TCP segment without IP header.
|
|
|
|
@param Src Source address of the segment, or the peer's IP address.
|
|
|
|
@param Dst Destination address of the segment, or the local end's IP
|
|
|
|
address.
|
|
|
|
|
|
|
|
@retval 0 Segment is 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.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpInput (
|
|
|
|
IN NET_BUF *Nbuf,
|
|
|
|
IN UINT32 Src,
|
|
|
|
IN UINT32 Dst
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Check whether the sequence number of the incoming segment is acceptable.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seg Pointer to the incoming segment.
|
|
|
|
|
|
|
|
@retval 1 The sequence number is acceptable.
|
|
|
|
@retval 0 The sequence number is not acceptable.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpSeqAcceptable (
|
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN TCP_SEG *Seg
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
NewReno fast recovery, RFC3782.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seg Segment that triggers the fast recovery.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpFastRecover (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN TCP_SEG *Seg
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
NewReno fast loss recovery, RFC3792.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Seg Segment that triggers the fast loss recovery.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpFastLossRecover (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN TCP_SEG *Seg
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Compute the RTT as specified in RFC2988.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Measure Currently measured RTT in heart beats.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpComputeRtt (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN UINT32 Measure
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Trim off the data outside the tcb's receive window.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Nbuf Pointer to the NET_BUF containing the received tcp segment.
|
|
|
|
|
|
|
|
**/
|
2008-12-24 09:14:19 +01:00
|
|
|
VOID
|
2007-09-30 05:08:02 +02:00
|
|
|
TcpTrimInWnd (
|
|
|
|
IN TCP_CB *Tcb,
|
2008-12-16 03:57:53 +01:00
|
|
|
IN NET_BUF *Nbuf
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Store the data into the reassemble queue.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Nbuf Pointer to the buffer containing the data to be queued.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpQueueData (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN NET_BUF *Nbuf
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Ajust the send queue or the retransmit queue.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Ack The acknowledge seuqence number of the received segment.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpAdjustSndQue (
|
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN TCP_SEQNO Ack
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions from Tcp4Misc.c
|
|
|
|
//
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Compute the TCP segment's checksum.
|
|
|
|
|
|
|
|
@param Nbuf Pointer to the buffer that contains the TCP
|
|
|
|
segment.
|
|
|
|
@param HeadSum The checksum value of the fixed part of pseudo
|
|
|
|
header.
|
|
|
|
|
|
|
|
@return The checksum value.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
UINT16
|
|
|
|
TcpChecksum (
|
2008-12-16 03:57:53 +01:00
|
|
|
IN NET_BUF *Nbuf,
|
|
|
|
IN UINT16 HeadSum
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Translate the information from the head of the received TCP
|
|
|
|
segment Nbuf contains and fill it into a TCP_SEG structure.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Nbuf Pointer to the buffer contains the TCP segment.
|
|
|
|
|
|
|
|
@return Pointer to the TCP_SEG that contains the translated TCP head information.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
TCP_SEG *
|
|
|
|
TcpFormatNetbuf (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN TCP_CB *Tcb,
|
|
|
|
IN OUT NET_BUF *Nbuf
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Initialize an active connection.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB that wants to initiate a
|
|
|
|
connection.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpOnAppConnect (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Application has consumed some data, check whether
|
|
|
|
to send a window updata ack or a delayed ack.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2008-12-24 09:14:19 +01:00
|
|
|
VOID
|
2007-09-30 05:08:02 +02:00
|
|
|
TcpOnAppConsume (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Initiate the connection close procedure, called when
|
|
|
|
applications want to close the connection.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpOnAppClose (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Check whether the application's newly delivered data can be sent out.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
@retval 0 Whether the data is sent out or is buffered for
|
|
|
|
further sending.
|
|
|
|
@retval -1 The Tcb is not in a state that data is permitted to
|
|
|
|
be sent out.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
TcpOnAppSend (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Abort the connection by sending a reset segment, called
|
|
|
|
when the application wants to abort the connection.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of the TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpOnAppAbort (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Reset the connection related with Tcb.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of the connection to be
|
|
|
|
reset.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpResetConnection (
|
|
|
|
IN TCP_CB *Tcb
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions in Tcp4Timer.c
|
|
|
|
//
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Close the TCP connection.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpClose (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Heart beat timer handler, queues the DPC at TPL_CALLBACK.
|
|
|
|
|
|
|
|
@param Event Timer event signaled, ignored.
|
|
|
|
@param Context Context of the timer event, ignored.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
TcpTicking (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Enable a TCP timer.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Timer The index of the timer to be enabled.
|
|
|
|
@param TimeOut The timeout value of this timer.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpSetTimer (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN UINT16 Timer,
|
|
|
|
IN UINT32 TimeOut
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Clear one TCP timer.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
@param Timer The index of the timer to be cleared.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpClearTimer (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb,
|
|
|
|
IN UINT16 Timer
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Clear all TCP timers.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpClearAllTimer (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Enable the window prober timer and set the timeout value.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpSetProbeTimer (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Enable the keepalive timer and set the timeout value.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpSetKeepaliveTimer (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Backoff the RTO.
|
|
|
|
|
|
|
|
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpBackoffRto (
|
2008-12-29 13:58:38 +01:00
|
|
|
IN OUT TCP_CB *Tcb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Set the Tdp4 variable data.
|
|
|
|
|
|
|
|
@param Tcp4Service Pointer to Tcp4 service data.
|
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.
|
|
|
|
@retval other Set variable failed.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
TcpSetVariableData (
|
|
|
|
IN TCP4_SERVICE_DATA *Tcp4Service
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Clear the variable and free the resource.
|
|
|
|
|
|
|
|
@param Tcp4Service Pointer to Tcp4 service data.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
TcpClearVariableData (
|
|
|
|
IN TCP4_SERVICE_DATA *Tcp4Service
|
|
|
|
);
|
|
|
|
|
2008-12-16 03:57:53 +01:00
|
|
|
/**
|
|
|
|
Install the device path protocol on the TCP instance.
|
|
|
|
|
|
|
|
@param Sock Pointer to the socket representing the TCP instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The device path protocol is installed.
|
|
|
|
@retval other Failed to install the device path protocol.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
TcpInstallDevicePath (
|
2008-12-16 03:57:53 +01:00
|
|
|
IN SOCKET *Sock
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|