/** @file\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+ TCP output process routines.\r
+ \r
+Copyright (c) 2005 - 2006, 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
- Tcp4Output.c\r
-\r
-Abstract:\r
-\r
- TCP output process routines.\r
-\r
-\r
**/\r
\r
#include "Tcp4Main.h"\r
UINT32 OldWin;\r
\r
Sk = Tcb->Sk;\r
- ASSERT (Sk);\r
+ ASSERT (Sk != NULL);\r
\r
OldWin = TcpRcvWinOld (Tcb);\r
\r
\r
\r
/**\r
- Compute the value to fill in the window size field\r
- of the outgoing segment.\r
+ Compute the value to fill in the window size field of the outgoing segment.\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
@param Syn The flag to indicate whether the outgoing segment is a SYN\r
UINT32 Limit;\r
\r
Sk = Tcb->Sk;\r
- ASSERT (Sk);\r
+ ASSERT (Sk != NULL);\r
\r
//\r
// TCP should NOT send data beyond the send window\r
Len = Tcb->SndMss;\r
}\r
\r
- if (Force || (Len == 0 && Left == 0)) {\r
+ if ((Force != 0)|| (Len == 0 && Left == 0)) {\r
return Len;\r
}\r
\r
\r
\r
/**\r
- Build the TCP header of the TCP segment and transmit the\r
- segment by IP.\r
+ Build the TCP header of the TCP segment and transmit the segment by IP.\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
@param Nbuf Pointer to the buffer containing the segment to be sent out.\r
BOOLEAN Syn;\r
UINT32 DataLen;\r
\r
- ASSERT (Nbuf && (Nbuf->Tcp == NULL) && TcpVerifySegment (Nbuf));\r
+ ASSERT ((Nbuf != NULL) && (Nbuf->Tcp == NULL) && (TcpVerifySegment (Nbuf) != 0));\r
\r
DataLen = Nbuf->TotalSize;\r
\r
INT32 Offset;\r
INT32 CopyLen;\r
\r
- ASSERT (Tcb && TCP_SEQ_LEQ (Seq, Tcb->SndNxt) && (Len > 0));\r
+ ASSERT ((Tcb != NULL) && TCP_SEQ_LEQ (Seq, Tcb->SndNxt) && (Len > 0));\r
\r
//\r
// Find the segment that contains the Seq.\r
//\r
// copy data to the segment\r
//\r
- if (CopyLen) {\r
+ if (CopyLen != 0) {\r
Data = NetbufAllocSpace (Nbuf, CopyLen, NET_BUF_TAIL);\r
- ASSERT (Data);\r
+ ASSERT (Data != NULL);\r
\r
if ((INT32) NetbufCopy (Node, Offset, CopyLen, Data) != CopyLen) {\r
goto OnError;\r
UINT8 *Data;\r
UINT32 DataGet;\r
\r
- ASSERT (Tcb && Tcb->Sk);\r
+ ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));\r
\r
Nbuf = NetbufAlloc (Len + TCP_MAX_HEAD);\r
\r
\r
DataGet = 0;\r
\r
- if (Len) {\r
+ if (Len != 0) {\r
//\r
// copy data to the segment.\r
//\r
Data = NetbufAllocSpace (Nbuf, Len, NET_BUF_TAIL);\r
- ASSERT (Data);\r
+ ASSERT (Data != NULL);\r
\r
DataGet = SockGetDataToSend (Tcb->Sk, 0, Len, Data);\r
}\r
{\r
NET_BUF *Nbuf;\r
\r
- ASSERT (Tcb);\r
+ ASSERT (Tcb != NULL);\r
\r
//\r
// Compare the SndNxt with the max sequence number sent.\r
Nbuf = TcpGetSegmentSock (Tcb, Seq, Len);\r
}\r
\r
- ASSERT (TcpVerifySegment (Nbuf));\r
+ ASSERT (TcpVerifySegment (Nbuf) != 0);\r
return Nbuf;\r
}\r
\r
return -1;\r
}\r
\r
- ASSERT (TcpVerifySegment (Nbuf));\r
+ ASSERT (TcpVerifySegment (Nbuf) != 0);\r
\r
if (TcpTransmitSegment (Tcb, Nbuf) != 0) {\r
goto OnError;\r
// trim TCP head because all the buffer on SndQue\r
// are headless.\r
//\r
- ASSERT (Nbuf->Tcp);\r
+ ASSERT (Nbuf->Tcp != NULL);\r
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);\r
Nbuf->Tcp = NULL;\r
\r
TCP_SEQNO Seq;\r
TCP_SEQNO End;\r
\r
- ASSERT (Tcb && Tcb->Sk && (Tcb->State != TCP_LISTEN));\r
+ ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL) && (Tcb->State != TCP_LISTEN));\r
\r
Sent = 0;\r
\r
\r
Flag = mTcpOutFlag[Tcb->State];\r
\r
- if (Flag & TCP_FLG_SYN) {\r
+ if ((Flag & TCP_FLG_SYN) != 0) {\r
\r
Seq = Tcb->Iss;\r
Len = 0;\r
// only send a segment without data if SYN or\r
// FIN is set.\r
//\r
- if ((Len == 0) && !(Flag & (TCP_FLG_SYN | TCP_FLG_FIN))) {\r
+ if ((Len == 0) && \r
+ ((Flag & (TCP_FLG_SYN | TCP_FLG_FIN)) == 0)) {\r
return Sent;\r
}\r
\r
End++;\r
}\r
\r
- if (Flag & TCP_FLG_FIN) {\r
+ if ((Flag & TCP_FLG_FIN) != 0) {\r
//\r
// Send FIN if all data is sent, and FIN is\r
// in the window\r
//\r
if ((TcpGetMaxSndNxt (Tcb) == Tcb->SndNxt) &&\r
(GET_SND_DATASIZE (Tcb->Sk) == 0) &&\r
- TCP_SEQ_LT (End + 1, Tcb->SndWnd + Tcb->SndWl2)\r
- ) {\r
-\r
- DEBUG ((EFI_D_INFO, "TcpToSendData: send FIN "\r
- "to peer for TCB %p in state %d\n", Tcb, Tcb->State));\r
+ TCP_SEQ_LT (End + 1, Tcb->SndWnd + Tcb->SndWl2)) {\r
+\r
+ DEBUG (\r
+ (EFI_D_INFO, \r
+ "TcpToSendData: send FIN "\r
+ "to peer for TCB %p in state %s\n", \r
+ Tcb, \r
+ mTcpStateName[Tcb->State])\r
+ );\r
\r
End++;\r
} else {\r
Seg->End = End;\r
Seg->Flag = Flag;\r
\r
- ASSERT (TcpVerifySegment (Nbuf));\r
- ASSERT (TcpCheckSndQue (&Tcb->SndQue));\r
+ ASSERT (TcpVerifySegment (Nbuf) != 0);\r
+ ASSERT (TcpCheckSndQue (&Tcb->SndQue) != 0);\r
\r
//\r
// don't send an empty segment here.\r
}\r
\r
if (TcpTransmitSegment (Tcb, Nbuf) != 0) {\r
- //\r
- // TODO: double check this\r
- //\r
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);\r
Nbuf->Tcp = NULL;\r
\r
- if (Flag & TCP_FLG_FIN) {\r
+ if ((Flag & TCP_FLG_FIN) != 0) {\r
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT);\r
}\r
\r
//\r
// All the buffer in the SndQue is headless\r
//\r
- ASSERT (Nbuf->Tcp);\r
+ ASSERT (Nbuf->Tcp != NULL);\r
\r
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);\r
Nbuf->Tcp = NULL;\r
//\r
Tcb->DelayedAck = 0;\r
\r
- if (Flag & TCP_FLG_FIN) {\r
+ if ((Flag & TCP_FLG_FIN) != 0) {\r
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT);\r
}\r
\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TcpSendAck (\r
\r
\r
/**\r
- Send a zero probe segment. It can be used by keepalive\r
- and zero window probe.\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
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TcpToSendAck (\r
//\r
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) ||\r
(Tcb->DelayedAck >= 1) ||\r
- (TcpNow > TcpRcvWinOld (Tcb))\r
- ) {\r
+ (TcpNow > TcpRcvWinOld (Tcb))) {\r
TcpSendAck (Tcb);\r
return;\r
}\r
//\r
// Don't respond to a Reset with reset\r
//\r
- if (Head->Flag & TCP_FLG_RST) {\r
+ if ((Head->Flag & TCP_FLG_RST) != 0) {\r
return 0;\r
}\r
\r