/** @file\r
+ TCP input process routines.\r
\r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+Copyright (c) 2005 - 2009, Intel Corporation<BR>\r
All rights reserved. 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\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
-Module Name:\r
-\r
- Tcp4Input.c\r
-\r
-Abstract:\r
-\r
- TCP input process routines.\r
-\r
-\r
**/\r
\r
+\r
#include "Tcp4Main.h"\r
\r
\r
/**\r
- Check whether the sequence number of the incoming segment\r
- is acceptable.\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
- @return 1 if the sequence number is acceptable, otherwise 0.\r
+ @retval 1 The sequence number is acceptable.\r
+ @retval 0 The sequence number is not acceptable.\r
\r
**/\r
INTN\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
@param Seg Segment that triggers the fast recovery.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TcpFastRecover (\r
- IN TCP_CB *Tcb,\r
- IN TCP_SEG *Seg\r
+ IN OUT TCP_CB *Tcb,\r
+ IN TCP_SEG *Seg\r
)\r
{\r
UINT32 FlightSize;\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
@param Seg Segment that triggers the fast loss recovery.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TcpFastLossRecover (\r
- IN TCP_CB *Tcb,\r
- IN TCP_SEG *Seg\r
+ IN OUT TCP_CB *Tcb,\r
+ IN TCP_SEG *Seg\r
)\r
{\r
if (TCP_SEQ_GT (Seg->Ack, Tcb->SndUna)) {\r
\r
\r
/**\r
- Compute the RTT as specified in RFC2988\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
- @return None.\r
-\r
**/\r
VOID\r
TcpComputeRtt (\r
- IN TCP_CB *Tcb,\r
- IN UINT32 Measure\r
+ IN OUT TCP_CB *Tcb,\r
+ IN UINT32 Measure\r
)\r
{\r
INT32 Var;\r
\r
\r
/**\r
- Trim the data, SYN and FIN to fit into the window defined by\r
- Left and Right.\r
+ Trim the data, SYN and FIN to fit into the window defined by Left and Right.\r
\r
@param Nbuf Buffer that contains received TCP segment without IP header.\r
@param Left The sequence number of the window's left edge.\r
@param Right The sequence number of the window's right edge.\r
\r
- @return 0, the data is successfully trimmed.\r
-\r
**/\r
-INTN\r
+VOID\r
TcpTrimSegment (\r
IN NET_BUF *Nbuf,\r
IN TCP_SEQNO Left,\r
\r
Seg->Seq = Seg->End;\r
NetbufTrim (Nbuf, Nbuf->TotalSize, NET_BUF_HEAD);\r
- return 0;\r
+ return;\r
}\r
\r
//\r
}\r
}\r
\r
- ASSERT (TcpVerifySegment (Nbuf));\r
- return 0;\r
+ ASSERT (TcpVerifySegment (Nbuf) != 0);\r
}\r
\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
- @return 0, the data is trimmed.\r
-\r
**/\r
-INTN\r
+VOID\r
TcpTrimInWnd (\r
IN TCP_CB *Tcb,\r
IN NET_BUF *Nbuf\r
)\r
{\r
- return TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd);\r
+ TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd);\r
}\r
\r
\r
**/\r
INTN\r
TcpDeliverData (\r
- IN TCP_CB *Tcb\r
+ IN OUT TCP_CB *Tcb\r
)\r
{\r
LIST_ENTRY *Entry;\r
TCP_SEG *Seg;\r
UINT32 Urgent;\r
\r
- ASSERT (Tcb && Tcb->Sk);\r
+ ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));\r
\r
//\r
// make sure there is some data queued,\r
Nbuf = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);\r
Seg = TCPSEG_NETBUF (Nbuf);\r
\r
- ASSERT (TcpVerifySegment (Nbuf));\r
+ ASSERT (TcpVerifySegment (Nbuf) != 0);\r
ASSERT (Nbuf->Tcp == NULL);\r
\r
if (TCP_SEQ_GT (Seg->Seq, Seq)) {\r
NetbufFree (Nbuf);\r
return -1;\r
break;\r
+ default:\r
+ break;\r
}\r
\r
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW);\r
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW);\r
}\r
\r
- if (Nbuf->TotalSize) {\r
+ if (Nbuf->TotalSize != 0) {\r
Urgent = 0;\r
\r
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RCVD_URG) &&\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
- @return None.\r
-\r
**/\r
VOID\r
TcpQueueData (\r
- IN TCP_CB *Tcb,\r
- IN NET_BUF *Nbuf\r
+ IN OUT TCP_CB *Tcb,\r
+ IN NET_BUF *Nbuf\r
)\r
{\r
TCP_SEG *Seg;\r
LIST_ENTRY *Cur;\r
NET_BUF *Node;\r
\r
- ASSERT (Tcb && Nbuf && (Nbuf->Tcp == NULL));\r
+ ASSERT ((Tcb != NULL) && (Nbuf != NULL) && (Nbuf->Tcp == NULL));\r
\r
NET_GET_REF (Nbuf);\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
- @return None.\r
-\r
**/\r
VOID\r
TcpAdjustSndQue (\r
NetbufTrim (Nbuf, (Head->HeadLen << 2), NET_BUF_HEAD);\r
Nbuf->Tcp = NULL;\r
\r
- //\r
- // TODO: add fast path process here\r
- //\r
-\r
//\r
// Process the segment in LISTEN state.\r
//\r
Tcb = TcpCloneTcb (Parent);\r
if (Tcb == NULL) {\r
DEBUG ((EFI_D_ERROR, "TcpInput: discard a segment because"\r
- "failed to clone a child for TCB%x\n", Tcb));\r
+ " failed to clone a child for TCB%x\n", Tcb));\r
\r
goto DISCARD;\r
}\r
if (TCP_FLG_ON (Seg->Flag, TCP_FLG_ACK)) {\r
\r
DEBUG ((EFI_D_WARN, "TcpInput: connection reset by"\r
- " peer for TCB%x in SYN_SENT\n", Tcb));\r
+ " peer for TCB %p in SYN_SENT\n", Tcb));\r
\r
SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);\r
goto DROP_CONNECTION;\r
} else {\r
\r
DEBUG ((EFI_D_WARN, "TcpInput: discard a reset segment "\r
- "because of no ACK for TCB%x in SYN_SENT\n", Tcb));\r
+ "because of no ACK for TCB %p in SYN_SENT\n", Tcb));\r
\r
goto DISCARD;\r
}\r
// if it comes from a LISTEN TCB.\r
//\r
} else if ((Tcb->State == TCP_ESTABLISHED) ||\r
- (Tcb->State == TCP_FIN_WAIT_1) ||\r
- (Tcb->State == TCP_FIN_WAIT_2) ||\r
- (Tcb->State == TCP_CLOSE_WAIT)\r
- ) {\r
+ (Tcb->State == TCP_FIN_WAIT_1) ||\r
+ (Tcb->State == TCP_FIN_WAIT_2) ||\r
+ (Tcb->State == TCP_CLOSE_WAIT)) {\r
\r
SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);\r
\r
} else {\r
- //\r
- // TODO: set socket error to CLOSED\r
- //\r
+\r
}\r
\r
goto DROP_CONNECTION;\r
Tcb->SndUna = Seg->Ack;\r
\r
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_SND_URG) &&\r
- (TCP_SEQ_LT (Tcb->SndUp, Seg->Ack))) {\r
+ TCP_SEQ_LT (Tcb->SndUp, Seg->Ack)) {\r
\r
TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_SND_URG);\r
}\r
}\r
\r
DEBUG ((EFI_D_WARN, "TcpInput: peer shrinks the"\r
- " window for connected TCB %p\n", Tcb));\r
+ " window for connected TCB %p\n", Tcb));\r
\r
if ((Tcb->CongestState == TCP_CONGEST_RECOVER) &&\r
(TCP_SEQ_LT (Right, Tcb->Recover))) {\r
TcpClose (Tcb);\r
}\r
break;\r
+\r
+ default:\r
+ break;\r
}\r
\r
//\r
\r
if ((Tcb->State != TCP_CLOSED) &&\r
(TcpToSendData (Tcb, 0) == 0) &&\r
- (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) || Nbuf->TotalSize)) {\r
+ (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) || (Nbuf->TotalSize != 0))) {\r
\r
TcpToSendAck (Tcb);\r
}\r
TcpSendReset (Tcb, Head, Len, Dst, Src);\r
\r
DROP_CONNECTION:\r
- ASSERT (Tcb && Tcb->Sk);\r
+ ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));\r
\r
NetbufFree (Nbuf);\r
TcpClose (Tcb);\r
\r
if ((Parent != NULL) && (Tcb != NULL)) {\r
\r
- ASSERT (Tcb->Sk);\r
+ ASSERT (Tcb->Sk != NULL);\r
TcpClose (Tcb);\r
}\r
\r
@param Src Source address of the ICMP error message.\r
@param Dst Destination address of the ICMP error message.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TcpIcmpInput (\r
IN NET_BUF *Nbuf,\r
- IN ICMP_ERROR IcmpErr,\r
+ IN UINT8 IcmpErr,\r
IN UINT32 Src,\r
IN UINT32 Dst\r
)\r
goto CLEAN_EXIT;\r
}\r
\r
- IcmpErrStatus = IpIoGetIcmpErrStatus (IcmpErr, &IcmpErrIsHard, &IcmpErrNotify);\r
+ IcmpErrStatus = IpIoGetIcmpErrStatus (\r
+ IcmpErr,\r
+ IP_VERSION_4,\r
+ &IcmpErrIsHard,\r
+ &IcmpErrNotify\r
+ );\r
\r
if (IcmpErrNotify) {\r
\r