/** @file\r
+ Tcp request dispatcher implementation.\r
\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2010, 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\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
- Tcp4Dispatcher.c\r
-\r
-Abstract:\r
-\r
-\r
**/\r
\r
#include "Tcp4Main.h"\r
#define TCP_COMP_VAL(Min, Max, Default, Val) \\r
((((Val) <= (Max)) && ((Val) >= (Min))) ? (Val) : (Default))\r
\r
+/**\r
+ Add or remove a route entry in the IP route table associated with this TCP instance.\r
+\r
+ @param Tcb Pointer to the TCP_CB of this TCP instance.\r
+ @param RouteInfo Pointer to the route info to be processed.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_NOT_STARTED The driver instance has not been started.\r
+ @retval EFI_NO_MAPPING When using the default address, configuration(DHCP,\r
+ BOOTP, RARP, etc.) is not finished yet.\r
+ @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.\r
+ @retval EFI_NOT_FOUND This route is not in the routing table\r
+ (when RouteInfo->DeleteRoute is TRUE).\r
+ @retval EFI_ACCESS_DENIED The route is already defined in the routing table\r
+ (when RouteInfo->DeleteRoute is FALSE).\r
+**/\r
EFI_STATUS\r
Tcp4Route (\r
IN TCP_CB *Tcb,\r
IN TCP4_ROUTE_INFO *RouteInfo\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Add or remove a route entry in the IP route table associated\r
- with this TCP instance.\r
-\r
-Arguments:\r
-\r
- Tcb - Pointer to the TCP_CB of this TCP instance.\r
- RouteInfo - Pointer to the route info to be processed.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - The operation completed successfully.\r
- EFI_NOT_STARTED - The driver instance has not been started.\r
- EFI_NO_MAPPING - When using the default address, configuration(DHCP,\r
- BOOTP, RARP, etc.) is not finished yet.\r
- EFI_OUT_OF_RESOURCES - Could not add the entry to the routing table.\r
- EFI_NOT_FOUND - This route is not in the routing table\r
- (when RouteInfo->DeleteRoute is TRUE).\r
- EFI_ACCESS_DENIED - The route is already defined in the routing table\r
- (when RouteInfo->DeleteRoute is FALSE).\r
-\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);\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
**/\r
EFI_STATUS\r
Tcp4GetMode (\r
- IN TCP_CB *Tcb,\r
- IN TCP4_MODE_DATA *Mode\r
+ IN TCP_CB *Tcb,\r
+ IN OUT TCP4_MODE_DATA *Mode\r
)\r
{\r
SOCKET *Sock;\r
return EFI_NOT_STARTED;\r
}\r
\r
- if (Mode->Tcp4State) {\r
+ if (Mode->Tcp4State != NULL) {\r
*(Mode->Tcp4State) = (EFI_TCP4_CONNECTION_STATE) Tcb->State;\r
}\r
\r
- if (Mode->Tcp4ConfigData) {\r
+ if (Mode->Tcp4ConfigData != NULL) {\r
\r
ConfigData = Mode->Tcp4ConfigData;\r
AccessPoint = &(ConfigData->AccessPoint);\r
Option = ConfigData->ControlOption;\r
\r
- ConfigData->TypeOfService = Tcb->TOS;\r
- ConfigData->TimeToLive = Tcb->TTL;\r
+ ConfigData->TypeOfService = Tcb->Tos;\r
+ ConfigData->TimeToLive = Tcb->Ttl;\r
\r
AccessPoint->UseDefaultAddress = Tcb->UseDefaultAddr;\r
\r
}\r
}\r
\r
- Ip = Tcb->IpInfo->Ip;\r
- ASSERT (Ip);\r
+ Ip = Tcb->IpInfo->Ip.Ip4;\r
+ ASSERT (Ip != NULL);\r
\r
return Ip->GetModeData (Ip, Mode->Ip4ModeData, Mode->MnpConfigData, Mode->SnpModeData);\r
}\r
\r
\r
/**\r
- Flush the Tcb add its associated protocols..\r
+ Flush the Tcb add its associated protocols.\r
\r
@param Tcb Pointer to the TCP_CB to be flushed.\r
\r
- @retval EFI_SUCCESS The operation is completed successfully.\r
-\r
**/\r
VOID\r
Tcp4FlushPcb (\r
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
NetbufFreeList (&Tcb->RcvQue);\r
}\r
\r
+/**\r
+ Attach a Pcb to the socket.\r
+\r
+ @param Sk Pointer to the socket of this TCP instance.\r
+\r
+ @retval EFI_SUCCESS The operation is completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Failed due to resource limit.\r
+\r
+**/\r
EFI_STATUS\r
Tcp4AttachPcb (\r
IN SOCKET *Sk\r
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
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Detach the Pcb of the socket.\r
+\r
+ @param Sk Pointer to the socket of this TCP instance.\r
+\r
+**/\r
VOID\r
Tcp4DetachPcb (\r
IN SOCKET *Sk\r
\r
IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo);\r
\r
- gBS->FreePool (Tcb);\r
+ FreePool (Tcb);\r
\r
ProtoData->TcpPcb = NULL;\r
}\r
\r
\r
/**\r
- Configure the Tcb using CfgData.\r
+ Configure the Pcb using CfgData.\r
\r
@param Sk Pointer to the socket of this TCP instance.\r
- @param SkTcb Pointer to the TCP_CB of this TCP instance.\r
@param CfgData Pointer to the TCP configuration data.\r
\r
@retval EFI_SUCCESS The operation is completed successfully.\r
TCP4_PROTO_DATA *TcpProto;\r
TCP_CB *Tcb;\r
\r
- ASSERT (CfgData && Sk && Sk->SockHandle);\r
+ ASSERT ((CfgData != NULL) && (Sk != NULL) && (Sk->SockHandle != NULL));\r
\r
TcpProto = (TCP4_PROTO_DATA *) Sk->ProtoReserved;\r
Tcb = TcpProto->TcpPcb;\r
//\r
// Add Ip for send pkt to the peer\r
//\r
- CopyMem (&IpCfgData, &mIpIoDefaultIpConfigData, sizeof (IpCfgData));\r
+ CopyMem (&IpCfgData, &mIp4IoDefaultIpConfigData, sizeof (IpCfgData));\r
IpCfgData.DefaultProtocol = EFI_IP_PROTO_TCP;\r
IpCfgData.UseDefaultAddress = CfgData->AccessPoint.UseDefaultAddress;\r
IpCfgData.StationAddress = CfgData->AccessPoint.StationAddress;\r
//\r
// initialize Tcb in the light of CfgData\r
//\r
- Tcb->TTL = CfgData->TimeToLive;\r
- Tcb->TOS = CfgData->TypeOfService;\r
+ Tcb->Ttl = CfgData->TimeToLive;\r
+ Tcb->Tos = CfgData->TypeOfService;\r
\r
Tcb->UseDefaultAddr = CfgData->AccessPoint.UseDefaultAddress;\r
\r
(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
//\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
EFI_STATUS\r
Tcp4Dispatcher (\r
IN SOCKET *Sock,\r
- IN SOCK_REQUEST Request,\r
+ IN UINT8 Request,\r
IN VOID *Data OPTIONAL\r
)\r
{\r
\r
switch (Request) {\r
case SOCK_POLL:\r
- Ip = ProtoData->TcpService->IpIo->Ip;\r
+ Ip = ProtoData->TcpService->IpIo->Ip.Ip4;\r
Ip->Poll (Ip);\r
break;\r
\r
// notify TCP using this message to give it a chance to send out\r
// window update information\r
//\r
- ASSERT (Tcb);\r
+ ASSERT (Tcb != NULL);\r
TcpOnAppConsume (Tcb);\r
break;\r
\r
case SOCK_SND:\r
\r
- ASSERT (Tcb);\r
+ ASSERT (Tcb != NULL);\r
TcpOnAppSend (Tcb);\r
break;\r
\r
\r
case SOCK_MODE:\r
\r
- ASSERT (Data && Tcb);\r
+ ASSERT ((Data != NULL) && (Tcb != NULL));\r
\r
return Tcp4GetMode (Tcb, (TCP4_MODE_DATA *) Data);\r
\r
\r
case SOCK_ROUTE:\r
\r
- ASSERT (Data && Tcb);\r
+ ASSERT ((Data != NULL) && (Tcb != NULL));\r
\r
return Tcp4Route (Tcb, (TCP4_ROUTE_INFO *) Data);\r
\r