]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Output.c
index f1bc83e20bd89eb6518e99623809f17485231bf0..760b09a1eda1fe58fe4aebb0d29c58a04066790e 100644 (file)
@@ -1,28 +1,20 @@
 /** @file\r
 /** @file\r
+  TCP output process routines.\r
 \r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2018, 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
 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
 \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
 \r
 **/\r
 \r
 #include "Tcp4Main.h"\r
 \r
-STATIC UINT8  mTcpOutFlag[] = {\r
+UINT8  mTcpOutFlag[] = {\r
   0,                          // TCP_CLOSED\r
   0,                          // TCP_LISTEN\r
   TCP_FLG_SYN,                // TCP_SYN_SENT\r
   0,                          // TCP_CLOSED\r
   0,                          // TCP_LISTEN\r
   TCP_FLG_SYN,                // TCP_SYN_SENT\r
@@ -85,7 +77,7 @@ TcpRcvWinNow (
   UINT32  OldWin;\r
 \r
   Sk = Tcb->Sk;\r
   UINT32  OldWin;\r
 \r
   Sk = Tcb->Sk;\r
-  ASSERT (Sk);\r
+  ASSERT (Sk != NULL);\r
 \r
   OldWin    = TcpRcvWinOld (Tcb);\r
 \r
 \r
   OldWin    = TcpRcvWinOld (Tcb);\r
 \r
@@ -112,8 +104,7 @@ TcpRcvWinNow (
 \r
 \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
 \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
@@ -122,11 +113,10 @@ TcpRcvWinNow (
   @return The value of the local receive window size used to fill the outing segment.\r
 \r
 **/\r
   @return The value of the local receive window size used to fill the outing segment.\r
 \r
 **/\r
-STATIC\r
 UINT16\r
 TcpComputeWnd (\r
 UINT16\r
 TcpComputeWnd (\r
-  IN TCP_CB  *Tcb,\r
-  IN BOOLEAN Syn\r
+  IN OUT TCP_CB  *Tcb,\r
+  IN     BOOLEAN Syn\r
   )\r
 {\r
   UINT32  Wnd;\r
   )\r
 {\r
   UINT32  Wnd;\r
@@ -200,7 +190,7 @@ TcpDataToSend (
   UINT32  Limit;\r
 \r
   Sk = Tcb->Sk;\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
 \r
   //\r
   // TCP should NOT send data beyond the send window\r
@@ -236,7 +226,7 @@ TcpDataToSend (
     Len = Tcb->SndMss;\r
   }\r
 \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
     return Len;\r
   }\r
 \r
@@ -277,7 +267,9 @@ SetPersistTimer:
       Tcb)\r
       );\r
 \r
       Tcb)\r
       );\r
 \r
-    TcpSetProbeTimer (Tcb);\r
+    if (!Tcb->ProbeTimerOn) {\r
+      TcpSetProbeTimer (Tcb);\r
+    }\r
   }\r
 \r
   return 0;\r
   }\r
 \r
   return 0;\r
@@ -285,8 +277,7 @@ SetPersistTimer:
 \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
 \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
@@ -295,11 +286,10 @@ SetPersistTimer:
   @retval other   Error condition occurred.\r
 \r
 **/\r
   @retval other   Error condition occurred.\r
 \r
 **/\r
-STATIC\r
 INTN\r
 TcpTransmitSegment (\r
 INTN\r
 TcpTransmitSegment (\r
-  IN TCP_CB  *Tcb,\r
-  IN NET_BUF *Nbuf\r
+  IN OUT TCP_CB  *Tcb,\r
+  IN     NET_BUF *Nbuf\r
   )\r
 {\r
   UINT16    Len;\r
   )\r
 {\r
   UINT16    Len;\r
@@ -308,7 +298,7 @@ TcpTransmitSegment (
   BOOLEAN   Syn;\r
   UINT32    DataLen;\r
 \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
 \r
   DataLen = Nbuf->TotalSize;\r
 \r
@@ -437,7 +427,7 @@ TcpGetSegmentSndQue (
   INT32           Offset;\r
   INT32           CopyLen;\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
   //\r
   // Find the segment that contains the Seq.\r
@@ -457,7 +447,9 @@ TcpGetSegmentSndQue (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
-  ASSERT (Cur != Head);\r
+  ASSERT (Cur  != Head);\r
+  ASSERT (Node != NULL);\r
+  ASSERT (Seg  != NULL);\r
 \r
   //\r
   // Return the buffer if it can be returned without\r
 \r
   //\r
   // Return the buffer if it can be returned without\r
@@ -494,7 +486,7 @@ TcpGetSegmentSndQue (
 \r
   //\r
   // If SYN is set and out of the range, clear the flag.\r
 \r
   //\r
   // If SYN is set and out of the range, clear the flag.\r
-  // Becuase the sequence of the first byte is SEG.SEQ+1,\r
+  // Because the sequence of the first byte is SEG.SEQ+1,\r
   // adjust Offset by -1. If SYN is in the range, copy\r
   // one byte less.\r
   //\r
   // adjust Offset by -1. If SYN is in the range, copy\r
   // one byte less.\r
   //\r
@@ -530,9 +522,9 @@ TcpGetSegmentSndQue (
   //\r
   // copy data to the segment\r
   //\r
   //\r
   // copy data to the segment\r
   //\r
-  if (CopyLen) {\r
+  if (CopyLen != 0) {\r
     Data = NetbufAllocSpace (Nbuf, CopyLen, NET_BUF_TAIL);\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
 \r
     if ((INT32) NetbufCopy (Node, Offset, CopyLen, Data) != CopyLen) {\r
       goto OnError;\r
@@ -574,7 +566,7 @@ TcpGetSegmentSock (
   UINT8   *Data;\r
   UINT32  DataGet;\r
 \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
   Nbuf = NetbufAlloc (Len + TCP_MAX_HEAD);\r
 \r
@@ -589,12 +581,12 @@ TcpGetSegmentSock (
 \r
   DataGet = 0;\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
     //\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
     DataGet = SockGetDataToSend (Tcb->Sk, 0, Len, Data);\r
   }\r
@@ -635,7 +627,7 @@ TcpGetSegment (
 {\r
   NET_BUF *Nbuf;\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
 \r
   //\r
   // Compare the SndNxt with the max sequence number sent.\r
@@ -648,7 +640,7 @@ TcpGetSegment (
     Nbuf = TcpGetSegmentSock (Tcb, Seq, Len);\r
   }\r
 \r
     Nbuf = TcpGetSegmentSock (Tcb, Seq, Len);\r
   }\r
 \r
-  ASSERT (TcpVerifySegment (Nbuf));\r
+  ASSERT (TcpVerifySegment (Nbuf) != 0);\r
   return Nbuf;\r
 }\r
 \r
   return Nbuf;\r
 }\r
 \r
@@ -679,33 +671,59 @@ TcpRetransmit (
   // 2. must in the current send window\r
   // 3. will not change the boundaries of queued segments.\r
   //\r
   // 2. must in the current send window\r
   // 3. will not change the boundaries of queued segments.\r
   //\r
-  if (TCP_SEQ_LT (Tcb->SndWl2 + Tcb->SndWnd, Seq)) {\r
-    DEBUG ((EFI_D_WARN, "TcpRetransmit: retransmission cancelled "\r
-      "because send window too small for TCB %p\n", Tcb));\r
+\r
+  //\r
+  // Handle the Window Retraction if TCP window scale is enabled according to RFC7323:\r
+  //   On first retransmission, or if the sequence number is out of\r
+  //   window by less than 2^Rcv.Wind.Shift, then do normal\r
+  //   retransmission(s) without regard to the receiver window as long\r
+  //   as the original segment was in window when it was sent.\r
+  //\r
+  if ((Tcb->SndWndScale != 0) &&\r
+      (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax) || TCP_SEQ_BETWEEN (Tcb->SndWl2 + Tcb->SndWnd, Seq, Tcb->SndWl2 + Tcb->SndWnd + (1 << Tcb->SndWndScale)))) {\r
+    Len = TCP_SUB_SEQ (Tcb->SndNxt, Seq);\r
+    DEBUG (\r
+      (EFI_D_WARN,\r
+      "TcpRetransmit: retransmission without regard to the receiver window for TCB %p\n",\r
+      Tcb)\r
+      );\r
+\r
+  } else if (TCP_SEQ_GEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq)) {\r
+    Len = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq);\r
+\r
+  } else {\r
+    DEBUG (\r
+      (EFI_D_WARN,\r
+      "TcpRetransmit: retransmission cancelled because send window too small for TCB %p\n",\r
+      Tcb)\r
+      );\r
 \r
     return 0;\r
   }\r
 \r
 \r
     return 0;\r
   }\r
 \r
-  Len   = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq);\r
-  Len   = MIN (Len, Tcb->SndMss);\r
+  Len = MIN (Len, Tcb->SndMss);\r
 \r
 \r
-  Nbuf  = TcpGetSegmentSndQue (Tcb, Seq, Len);\r
+  Nbuf = TcpGetSegmentSndQue (Tcb, Seq, Len);\r
   if (Nbuf == NULL) {\r
     return -1;\r
   }\r
 \r
   if (Nbuf == NULL) {\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
   }\r
 \r
 \r
   if (TcpTransmitSegment (Tcb, Nbuf) != 0) {\r
     goto OnError;\r
   }\r
 \r
+  if (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax)) {\r
+    Tcb->RetxmitSeqMax = Seq;\r
+  }\r
+\r
   //\r
   // The retransmitted buffer may be on the SndQue,\r
   // trim TCP head because all the buffer on SndQue\r
   // are headless.\r
   //\r
   //\r
   // The retransmitted buffer may be on the SndQue,\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
   NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);\r
   Nbuf->Tcp = NULL;\r
 \r
@@ -733,8 +751,8 @@ OnError:
 **/\r
 INTN\r
 TcpToSendData (\r
 **/\r
 INTN\r
 TcpToSendData (\r
-  IN TCP_CB *Tcb,\r
-  IN INTN Force\r
+  IN OUT TCP_CB *Tcb,\r
+  IN     INTN Force\r
   )\r
 {\r
   UINT32    Len;\r
   )\r
 {\r
   UINT32    Len;\r
@@ -745,7 +763,7 @@ TcpToSendData (
   TCP_SEQNO Seq;\r
   TCP_SEQNO End;\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
   Sent = 0;\r
 \r
@@ -762,9 +780,10 @@ SEND_AGAIN:
   Len   = TcpDataToSend (Tcb, Force);\r
   Seq   = Tcb->SndNxt;\r
 \r
   Len   = TcpDataToSend (Tcb, Force);\r
   Seq   = Tcb->SndNxt;\r
 \r
+  ASSERT ((Tcb->State) < (ARRAY_SIZE (mTcpOutFlag)));\r
   Flag  = mTcpOutFlag[Tcb->State];\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
 \r
     Seq = Tcb->Iss;\r
     Len = 0;\r
@@ -774,7 +793,8 @@ SEND_AGAIN:
   // only send a segment without data if SYN or\r
   // FIN is set.\r
   //\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
     return Sent;\r
   }\r
 \r
@@ -801,18 +821,22 @@ SEND_AGAIN:
     End++;\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
     //\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_NET,\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
 \r
       End++;\r
     } else {\r
@@ -824,8 +848,8 @@ SEND_AGAIN:
   Seg->End  = End;\r
   Seg->Flag = Flag;\r
 \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
   // don't send an empty segment here.\r
@@ -839,13 +863,10 @@ SEND_AGAIN:
   }\r
 \r
   if (TcpTransmitSegment (Tcb, Nbuf) != 0) {\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
     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
       TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT);\r
     }\r
 \r
@@ -857,7 +878,7 @@ SEND_AGAIN:
   //\r
   // All the buffer in the SndQue is headless\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
   NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);\r
   Nbuf->Tcp = NULL;\r
@@ -869,7 +890,7 @@ SEND_AGAIN:
   //\r
   Tcb->DelayedAck = 0;\r
 \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
     TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT);\r
   }\r
 \r
@@ -888,7 +909,7 @@ SEND_AGAIN:
   if ((Tcb->CongestState == TCP_CONGEST_OPEN) &&\r
       !TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RTT_ON)) {\r
 \r
   if ((Tcb->CongestState == TCP_CONGEST_OPEN) &&\r
       !TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RTT_ON)) {\r
 \r
-    DEBUG ((EFI_D_INFO, "TcpToSendData: set RTT measure "\r
+    DEBUG ((EFI_D_NET, "TcpToSendData: set RTT measure "\r
       "sequence %d for TCB %p\n", Seq, Tcb));\r
 \r
     TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_RTT_ON);\r
       "sequence %d for TCB %p\n", Seq, Tcb));\r
 \r
     TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_RTT_ON);\r
@@ -916,12 +937,10 @@ OnError:
 \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
 TcpSendAck (\r
 **/\r
 VOID\r
 TcpSendAck (\r
-  IN TCP_CB *Tcb\r
+  IN OUT TCP_CB *Tcb\r
   )\r
 {\r
   NET_BUF *Nbuf;\r
   )\r
 {\r
   NET_BUF *Nbuf;\r
@@ -950,8 +969,7 @@ TcpSendAck (
 \r
 \r
 /**\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
@@ -961,7 +979,7 @@ TcpSendAck (
 **/\r
 INTN\r
 TcpSendZeroProbe (\r
 **/\r
 INTN\r
 TcpSendZeroProbe (\r
-  IN TCP_CB *Tcb\r
+  IN OUT TCP_CB *Tcb\r
   )\r
 {\r
   NET_BUF *Nbuf;\r
   )\r
 {\r
   NET_BUF *Nbuf;\r
@@ -997,12 +1015,10 @@ TcpSendZeroProbe (
 \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
 VOID\r
 TcpToSendAck (\r
-  IN TCP_CB *Tcb\r
+  IN OUT TCP_CB *Tcb\r
   )\r
 {\r
   UINT32 TcpNow;\r
   )\r
 {\r
   UINT32 TcpNow;\r
@@ -1016,13 +1032,12 @@ TcpToSendAck (
   //\r
   if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) ||\r
       (Tcb->DelayedAck >= 1) ||\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
     TcpSendAck (Tcb);\r
     return;\r
   }\r
 \r
-  DEBUG ((EFI_D_INFO, "TcpToSendAck: scheduled a delayed"\r
+  DEBUG ((EFI_D_NET, "TcpToSendAck: scheduled a delayed"\r
     " ACK for TCB %p\n", Tcb));\r
 \r
   //\r
     " ACK for TCB %p\n", Tcb));\r
 \r
   //\r
@@ -1061,7 +1076,7 @@ TcpSendReset (
   //\r
   // Don't respond to a Reset with reset\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
     return 0;\r
   }\r
 \r
@@ -1105,7 +1120,7 @@ TcpSendReset (
 \r
   Nhead->SrcPort  = Head->DstPort;\r
   Nhead->DstPort  = Head->SrcPort;\r
 \r
   Nhead->SrcPort  = Head->DstPort;\r
   Nhead->DstPort  = Head->SrcPort;\r
-  Nhead->HeadLen  = (sizeof (TCP_HEAD) >> 2);\r
+  Nhead->HeadLen  = (UINT8) (sizeof (TCP_HEAD) >> 2);\r
   Nhead->Res      = 0;\r
   Nhead->Wnd      = HTONS (0xFFFF);\r
   Nhead->Checksum = 0;\r
   Nhead->Res      = 0;\r
   Nhead->Wnd      = HTONS (0xFFFF);\r
   Nhead->Checksum = 0;\r