]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c
MdeModulePkg:removes the unreachable ‘break’ instruction after a ‘return’ instruction...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Dispatcher.c
index fb224f4ad36b7f75d8594e9237703fb511738ac3..688f9a7e99c9a01e97acef292e4456a275c8dcbf 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Tcp request dispatcher implementation.\r
 \r
-Copyright (c) 2005 - 2009, 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
@@ -39,20 +39,20 @@ Tcp4Route (
   IN TCP4_ROUTE_INFO  *RouteInfo\r
   )\r
 {\r
-  EFI_IP4_PROTOCOL  *Ip;\r
+  EFI_IP4_PROTOCOL  *Ip4;\r
 \r
-  Ip = Tcb->IpInfo->Ip;\r
+  Ip4 = Tcb->IpInfo->Ip.Ip4;\r
 \r
-  ASSERT (Ip != NULL);\r
+  ASSERT (Ip4 != NULL);\r
 \r
-  return Ip->Routes (\r
-              Ip,\r
+  return Ip4->Routes (\r
+              Ip4,\r
               RouteInfo->DeleteRoute,\r
               RouteInfo->SubnetAddress,\r
               RouteInfo->SubnetMask,\r
               RouteInfo->GatewayAddress\r
               );\r
-              \r
+\r
 }\r
 \r
 \r
@@ -131,7 +131,7 @@ Tcp4GetMode (
     }\r
   }\r
 \r
-  Ip = Tcb->IpInfo->Ip;\r
+  Ip = Tcb->IpInfo->Ip.Ip4;\r
   ASSERT (Ip != NULL);\r
 \r
   return Ip->GetModeData (Ip, Mode->Ip4ModeData, Mode->MnpConfigData, Mode->SnpModeData);\r
@@ -227,27 +227,30 @@ Tcp4FlushPcb (
     RemoveEntryList (&Tcb->List);\r
 \r
     //\r
-    // Uninstall the device path protocl.\r
+    // Uninstall the device path protocol.\r
     //\r
-    gBS->UninstallProtocolInterface (\r
-           Sock->SockHandle,\r
-           &gEfiDevicePathProtocolGuid,\r
-           Sock->DevicePath\r
-           );\r
-    gBS->FreePool (Sock->DevicePath);\r
+    if (Sock->DevicePath != NULL) {\r
+      gBS->UninstallProtocolInterface (\r
+             Sock->SockHandle,\r
+             &gEfiDevicePathProtocolGuid,\r
+             Sock->DevicePath\r
+             );\r
+      FreePool (Sock->DevicePath);\r
+    }\r
 \r
     TcpSetVariableData (TcpProto->TcpService);\r
   }\r
 \r
   NetbufFreeList (&Tcb->SndQue);\r
   NetbufFreeList (&Tcb->RcvQue);\r
+  Tcb->State = TCP_CLOSED;\r
 }\r
 \r
 /**\r
   Attach a Pcb to the socket.\r
 \r
   @param  Sk                     Pointer to the socket of this TCP instance.\r
-  \r
+\r
   @retval EFI_SUCCESS            The operation is completed successfully.\r
   @retval EFI_OUT_OF_RESOURCES   Failed due to resource limit.\r
 \r
@@ -279,7 +282,7 @@ Tcp4AttachPcb (
   Tcb->IpInfo = IpIoAddIp (IpIo);\r
   if (Tcb->IpInfo == NULL) {\r
 \r
-    gBS->FreePool (Tcb);\r
+    FreePool (Tcb);\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
@@ -298,7 +301,7 @@ Tcp4AttachPcb (
   Detach the Pcb of the socket.\r
 \r
   @param  Sk                     Pointer to the socket of this TCP instance.\r
-  \r
+\r
 **/\r
 VOID\r
 Tcp4DetachPcb (\r
@@ -317,7 +320,7 @@ Tcp4DetachPcb (
 \r
   IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo);\r
 \r
-  gBS->FreePool (Tcb);\r
+  FreePool (Tcb);\r
 \r
   ProtoData->TcpPcb = NULL;\r
 }\r
@@ -530,15 +533,15 @@ Tcp4ConfigurePcb (
                             (UINT32) (Option->ConnectionTimeout * TCP_TICK_HZ)\r
                             );\r
 \r
-    if (Option->EnableNagle == FALSE) {\r
+    if (!Option->EnableNagle) {\r
       TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_NO_NAGLE);\r
     }\r
 \r
-    if (Option->EnableTimeStamp == FALSE) {\r
+    if (!Option->EnableTimeStamp) {\r
       TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_NO_TS);\r
     }\r
 \r
-    if (Option->EnableWindowScaling == FALSE) {\r
+    if (!Option->EnableWindowScaling) {\r
       TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_NO_WS);\r
     }\r
   }\r
@@ -555,7 +558,7 @@ Tcp4ConfigurePcb (
   //\r
   // update state of Tcb and socket\r
   //\r
-  if (CfgData->AccessPoint.ActiveFlag == FALSE) {\r
+  if (!CfgData->AccessPoint.ActiveFlag) {\r
 \r
     TcpSetState (Tcb, TCP_LISTEN);\r
     SockSetState (Sk, SO_LISTENING);\r
@@ -605,7 +608,7 @@ Tcp4Dispatcher (
 \r
   switch (Request) {\r
   case SOCK_POLL:\r
-    Ip = (EFI_IP4_PROTOCOL *) (ProtoData->TcpService->IpIo->Ip);\r
+    Ip = ProtoData->TcpService->IpIo->Ip.Ip4;\r
     Ip->Poll (Ip);\r
     break;\r
 \r
@@ -659,8 +662,6 @@ Tcp4Dispatcher (
 \r
     return Tcp4AttachPcb (Sock);\r
 \r
-    break;\r
-\r
   case SOCK_FLUSH:\r
 \r
     Tcp4FlushPcb (Tcb);\r
@@ -680,16 +681,12 @@ Tcp4Dispatcher (
             (EFI_TCP4_CONFIG_DATA *) Data\r
             );\r
 \r
-    break;\r
-\r
   case SOCK_MODE:\r
 \r
     ASSERT ((Data != NULL) && (Tcb != NULL));\r
 \r
     return Tcp4GetMode (Tcb, (TCP4_MODE_DATA *) Data);\r
 \r
-    break;\r
-\r
   case SOCK_ROUTE:\r
 \r
     ASSERT ((Data != NULL) && (Tcb != NULL));\r