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