/** @file\r
+ Misc support routines for tcp.\r
\r
-Copyright (c) 2005 - 2006, Intel Corporation\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
- Tcp4Misc.c\r
-\r
-Abstract:\r
-\r
- Misc support routines for tcp.\r
-\r
-\r
**/\r
\r
\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
\r
- @return None\r
-\r
**/\r
VOID\r
TcpInitTcbLocal (\r
Tcb->RcvWnd = GET_RCV_BUFFSIZE (Tcb->Sk);\r
\r
//\r
- // Fisrt window size is never scaled\r
+ // First window size is never scaled\r
//\r
Tcb->RcvWndScale = 0;\r
}\r
intial info.\r
@param Opt Pointer to the options announced by the peer.\r
\r
- @return None\r
-\r
**/\r
VOID\r
TcpInitTcbPeer (\r
@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, if NULL no match is found.\r
+ @return Pointer to the TCP_CB with the least number of wildcard, \r
+ if NULL no match is found.\r
\r
**/\r
TCP_CB *\r
\r
if ((Local->Port != Node->LocalEnd.Port) ||\r
!TCP_PEER_MATCH (Remote, &Node->RemoteEnd) ||\r
- !TCP_PEER_MATCH (Local, &Node->LocalEnd)\r
- ) {\r
+ !TCP_PEER_MATCH (Local, &Node->LocalEnd)) {\r
\r
continue;\r
}\r
@param Addr Pointer to the IP address needs to match.\r
@param Port The port number needs to match.\r
\r
- @return The Tcb which matches the <Addr Port> paire exists or not.\r
+ @return The Tcb which matches the <Addr Port> paire exists or not.\r
\r
**/\r
BOOLEAN\r
@param Syn Whether to search the listen sockets, if TRUE, the\r
listen sockets are searched.\r
\r
- @return Pointer to the related TCP_CB, if NULL no match is found.\r
+ @return Pointer to the related TCP_CB, if NULL no match is found.\r
\r
**/\r
TCP_CB *\r
TCP4_PROTO_DATA *TcpProto;\r
\r
ASSERT (\r
- Tcb &&\r
- (\r
- (Tcb->State == TCP_LISTEN) ||\r
- (Tcb->State == TCP_SYN_SENT) ||\r
- (Tcb->State == TCP_SYN_RCVD) ||\r
- (Tcb->State == TCP_CLOSED)\r
- )\r
+ (Tcb != NULL) &&\r
+ ((Tcb->State == TCP_LISTEN) ||\r
+ (Tcb->State == TCP_SYN_SENT) ||\r
+ (Tcb->State == TCP_SYN_RCVD) ||\r
+ (Tcb->State == TCP_CLOSED))\r
);\r
\r
if (Tcb->LocalEnd.Port == 0) {\r
\r
\r
/**\r
- Clone a TCP_CB from Tcb.\r
+ Clone a TCB_CB from Tcb.\r
\r
@param Tcb Pointer to the TCP_CB to be cloned.\r
\r
- @return Pointer to the new cloned TCP_CB, if NULL error condition occurred.\r
+ @return Pointer to the new cloned TCP_CB, if NULL error condition occurred.\r
\r
**/\r
TCP_CB *\r
/**\r
Compute an ISS to be used by a new connection.\r
\r
- None\r
-\r
- @return The result ISS.\r
+ @return The result ISS.\r
\r
**/\r
TCP_SEQNO\r
/**\r
Get the local mss.\r
\r
- None\r
+ @param Sock Pointer to the socket to get mss\r
\r
- @return The mss size.\r
+ @return The mss size.\r
\r
**/\r
UINT16\r
TCP4_PROTO_DATA *TcpProto;\r
EFI_IP4_PROTOCOL *Ip;\r
\r
- ASSERT (Sock);\r
+ ASSERT (Sock != NULL);\r
\r
TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;\r
Ip = TcpProto->TcpService->IpIo->Ip;\r
- ASSERT (Ip);\r
+ ASSERT (Ip != NULL);\r
\r
Ip->GetModeData (Ip, NULL, NULL, &SnpMode);\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
@param State The state to be set.\r
\r
- @return None\r
-\r
**/\r
VOID\r
TcpSetState (\r
- IN TCP_CB *Tcb,\r
- IN UINT8 State\r
+ IN TCP_CB *Tcb,\r
+ IN TCP_STATES State\r
)\r
{\r
DEBUG (\r
mTcpStateName[State])\r
);\r
\r
- Tcb->State = State;\r
+ Tcb->State = (TCP_STATES)State;\r
\r
switch (State) {\r
case TCP_ESTABLISHED:\r
\r
SockConnClosed (Tcb->Sk);\r
\r
+ break;\r
+ case default:\r
break;\r
}\r
}\r
@param HeadSum The checksum value of the fixed part of pseudo\r
header.\r
\r
- @return The checksum value.\r
+ @return The checksum value.\r
\r
**/\r
UINT16\r
Checksum = NetbufChecksum (Nbuf);\r
Checksum = NetAddChecksum (Checksum, HeadSum);\r
\r
- Checksum = NetAddChecksum (\r
- Checksum,\r
- HTONS ((UINT16) Nbuf->TotalSize)\r
- );\r
+ Checksum = NetAddChecksum (\r
+ Checksum,\r
+ HTONS ((UINT16) Nbuf->TotalSize)\r
+ );\r
\r
return (UINT16) ~Checksum;\r
}\r
\r
-\r
/**\r
Translate the information from the head of the received TCP\r
segment Nbuf contains and fill it into a TCP_SEG structure.\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
@param Nbuf Pointer to the buffer contains the TCP segment.\r
\r
- @return Pointer to the TCP_SEG that contains the translated TCP head information.\r
+ @return Pointer to the TCP_SEG that contains the translated TCP head information.\r
\r
**/\r
TCP_SEG *\r
@param Tcb Pointer to the TCP_CB of the connection to be\r
reset.\r
\r
- @return None\r
-\r
**/\r
VOID\r
TcpResetConnection (\r
\r
\r
/**\r
- Initialize an active connection,\r
+ Initialize an active connection.\r
\r
@param Tcb Pointer to the TCP_CB that wants to initiate a\r
connection.\r
\r
- @return None\r
-\r
**/\r
VOID\r
TcpOnAppConnect (\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TcpOnAppClose (\r
IN TCP_CB *Tcb\r
)\r
{\r
- ASSERT (Tcb);\r
+ ASSERT (Tcb != NULL);\r
\r
- if (!IsListEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk)) {\r
+ if (!IsListEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk) != 0) {\r
\r
DEBUG ((EFI_D_WARN, "TcpOnAppClose: connection reset "\r
"because data is lost for TCB %p\n", Tcb));\r
case TCP_CLOSE_WAIT:\r
TcpSetState (Tcb, TCP_LAST_ACK);\r
break;\r
+ case default:\r
+ break;\r
}\r
\r
TcpToSendData (Tcb, 1);\r
\r
\r
/**\r
- Check whether the application's newly delivered data\r
- can be sent out.\r
+ Check whether the application's newly delivered data can be sent out.\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
\r
case TCP_TIME_WAIT:\r
return -1;\r
break;\r
+ case default:\r
+ break;\r
}\r
\r
return 0;\r
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
\r
-\r
**/\r
INTN\r
TcpOnAppConsume (\r
if (TcpOld < Tcb->RcvMss) {\r
\r
DEBUG ((EFI_D_INFO, "TcpOnAppConsume: send a window"\r
- " update for a window closed Tcb(%p)\n", Tcb));\r
+ " update for a window closed Tcb %p\n", Tcb));\r
\r
TcpSendAck (Tcb);\r
} else if (Tcb->DelayedAck == 0) {\r
\r
DEBUG ((EFI_D_INFO, "TcpOnAppConsume: scheduled a delayed"\r
- " ACK to update window for Tcb(%p)\n", Tcb));\r
+ " ACK to update window for Tcb %p\n", Tcb));\r
\r
Tcb->DelayedAck = 1;\r
}\r
\r
@param Tcb Pointer to the TCP_CB of the TCP instance.\r
\r
- @return None.\r
-\r
**/\r
VOID\r
TcpOnAppAbort (\r
/**\r
Set the Tdp4 variable data.\r
\r
- @param Tcp4Service Tcp4 service data.\r
+ @param Tcp4Service Pointer to Tcp4 service data.\r
\r
@retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.\r
@retval other Set variable failed.\r
/**\r
Clear the variable and free the resource.\r
\r
- @param Tcp4Service Tcp4 service data.\r
-\r
- @return None.\r
+ @param Tcp4Service Pointer to Tcp4 service data.\r
\r
**/\r
VOID\r
Tcp4Service->MacString = NULL;\r
}\r
\r
-EFI_STATUS\r
-TcpInstallDevicePath (\r
- IN SOCKET *Sock\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
Install the device path protocol on the TCP instance.\r
\r
-Arguments:\r
-\r
- Sock - Pointer to the socket representing the TCP instance.\r
+ @param Sock Pointer to the socket representing the TCP instance.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS The device path protocol is installed.\r
+ @retval other Failed to install the device path protocol.\r
\r
- EFI_SUCCESS - The device path protocol is installed.\r
- other - Failed to install the device path protocol.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+TcpInstallDevicePath (\r
+ IN SOCKET *Sock\r
+ )\r
{\r
TCP4_PROTO_DATA *TcpProto;\r
TCP4_SERVICE_DATA *TcpService;\r
);\r
\r
Sock->DevicePath = AppendDevicePathNode (\r
- Sock->ParentDevicePath,\r
- (EFI_DEVICE_PATH_PROTOCOL *) &Ip4DPathNode\r
- );\r
+ Sock->ParentDevicePath,\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &Ip4DPathNode\r
+ );\r
if (Sock->DevicePath == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r