]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
Adopt new IPv4/IPv6 device path for network modules.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Misc.c
index 1f478290bb4774ae7f696185663d36bc9fabda93..b3591aa7df09943beddba4d8b8e1035744b85e0c 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Misc support routines for tcp.\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2011, 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
@@ -77,7 +77,9 @@ TcpInitTcbLocal (
   //\r
   // First window size is never scaled\r
   //\r
-  Tcb->RcvWndScale = 0;\r
+  Tcb->RcvWndScale  = 0;\r
+\r
+  Tcb->ProbeTimerOn = FALSE;\r
 }\r
 \r
 \r
@@ -171,7 +173,7 @@ TcpInitTcbPeer (
   @param  Local                 Pointer to the local (IP, Port).\r
   @param  Remote                Pointer to the remote (IP, Port).\r
 \r
-  @return  Pointer to the TCP_CB with the least number of wildcard, \r
+  @return  Pointer to the TCP_CB with the least number of wildcard,\r
            if NULL no match is found.\r
 \r
 **/\r
@@ -432,7 +434,7 @@ TcpCloneTcb (
   Clone->Sk = SockClone (Tcb->Sk);\r
   if (Clone->Sk == NULL) {\r
     DEBUG ((EFI_D_ERROR, "TcpCloneTcb: failed to clone a sock\n"));\r
-    gBS->FreePool (Clone);\r
+    FreePool (Clone);\r
     return NULL;\r
   }\r
 \r
@@ -471,19 +473,19 @@ TcpGetRcvMss (
   IN SOCKET  *Sock\r
   )\r
 {\r
-  EFI_SIMPLE_NETWORK_MODE SnpMode;\r
+  EFI_IP4_MODE_DATA       Ip4Mode;\r
   TCP4_PROTO_DATA         *TcpProto;\r
   EFI_IP4_PROTOCOL        *Ip;\r
 \r
   ASSERT (Sock != NULL);\r
 \r
   TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;\r
-  Ip       = TcpProto->TcpService->IpIo->Ip;\r
+  Ip       = TcpProto->TcpService->IpIo->Ip.Ip4;\r
   ASSERT (Ip != NULL);\r
 \r
-  Ip->GetModeData (Ip, NULL, NULL, &SnpMode);\r
+  Ip->GetModeData (Ip, &Ip4Mode, NULL, NULL);\r
 \r
-  return (UINT16) (SnpMode.MaxPacketSize - 40);\r
+  return (UINT16) (Ip4Mode.MaxPacketSize - sizeof (TCP_HEAD));\r
 }\r
 \r
 \r
@@ -500,6 +502,9 @@ TcpSetState (
   IN     UINT8   State\r
   )\r
 {\r
+  ASSERT (Tcb->State < (sizeof (mTcpStateName) / sizeof (CHAR16 *)));\r
+  ASSERT (State < (sizeof (mTcpStateName) / sizeof (CHAR16 *)));\r
+\r
   DEBUG (\r
     (EFI_D_INFO,\r
     "Tcb (%p) state %s --> %s\n",\r
@@ -652,7 +657,7 @@ TcpResetConnection (
   Nhead->Ack      = HTONL (Tcb->RcvNxt);\r
   Nhead->SrcPort  = Tcb->LocalEnd.Port;\r
   Nhead->DstPort  = Tcb->RemoteEnd.Port;\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
@@ -1025,7 +1030,7 @@ TcpSetVariableData (
              );\r
     }\r
 \r
-    gBS->FreePool (Tcp4Service->MacString);\r
+    FreePool (Tcp4Service->MacString);\r
   }\r
 \r
   Tcp4Service->MacString = NewMacString;\r
@@ -1040,7 +1045,7 @@ TcpSetVariableData (
 \r
 ON_ERROR:\r
 \r
-  gBS->FreePool (Tcp4VariableData);\r
+  FreePool (Tcp4VariableData);\r
 \r
   return Status;\r
 }\r
@@ -1067,7 +1072,7 @@ TcpClearVariableData (
          NULL\r
          );\r
 \r
-  gBS->FreePool (Tcp4Service->MacString);\r
+  FreePool (Tcp4Service->MacString);\r
   Tcp4Service->MacString = NULL;\r
 }\r
 \r
@@ -1090,22 +1095,28 @@ TcpInstallDevicePath (
   TCP_CB             *Tcb;\r
   IPv4_DEVICE_PATH   Ip4DPathNode;\r
   EFI_STATUS         Status;\r
+  TCP_PORTNO         LocalPort;\r
+  TCP_PORTNO         RemotePort;\r
 \r
   TcpProto   = (TCP4_PROTO_DATA *) Sock->ProtoReserved;\r
   TcpService = TcpProto->TcpService;\r
   Tcb        = TcpProto->TcpPcb;\r
 \r
+  LocalPort = NTOHS (Tcb->LocalEnd.Port);\r
+  RemotePort = NTOHS (Tcb->RemoteEnd.Port);\r
   NetLibCreateIPv4DPathNode (\r
     &Ip4DPathNode,\r
     TcpService->ControllerHandle,\r
     Tcb->LocalEnd.Ip,\r
-    NTOHS (Tcb->LocalEnd.Port),\r
+    LocalPort,\r
     Tcb->RemoteEnd.Ip,\r
-    NTOHS (Tcb->RemoteEnd.Port),\r
+    RemotePort,\r
     EFI_IP_PROTO_TCP,\r
     Tcb->UseDefaultAddr\r
     );\r
 \r
+  IP4_COPY_ADDRESS (&Ip4DPathNode.SubnetMask, &Tcb->SubnetMask);\r
+\r
   Sock->DevicePath = AppendDevicePathNode (\r
                        Sock->ParentDevicePath,\r
                        (EFI_DEVICE_PATH_PROTOCOL *) &Ip4DPathNode\r
@@ -1121,7 +1132,7 @@ TcpInstallDevicePath (
                   Sock->DevicePath\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (Sock->DevicePath);\r
+    FreePool (Sock->DevicePath);\r
   }\r
 \r
   return Status;\r