\r
#include <Library/DevicePathLib.h>\r
\r
-NET_LIST_ENTRY mTcpRunQue = {\r
+LIST_ENTRY mTcpRunQue = {\r
&mTcpRunQue,\r
&mTcpRunQue\r
};\r
\r
-NET_LIST_ENTRY mTcpListenQue = {\r
+LIST_ENTRY mTcpListenQue = {\r
&mTcpListenQue,\r
&mTcpListenQue\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
-STATIC\r
TCP_CB *\r
TcpLocateListenTcb (\r
IN TCP_PEER *Local,\r
IN TCP_PEER *Remote\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
TCP_CB *Node;\r
TCP_CB *Match;\r
INTN Last;\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
)\r
{\r
TCP_PORTNO LocalPort;\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
TCP_CB *Tcb;\r
\r
ASSERT ((Addr != NULL) && (Port != 0));\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
{\r
TCP_PEER Local;\r
TCP_PEER Remote;\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
TCP_CB *Tcb;\r
\r
Local.Port = LocalPort;\r
if (TCP_PEER_EQUAL (&Remote, &Tcb->RemoteEnd) &&\r
TCP_PEER_EQUAL (&Local, &Tcb->LocalEnd)) {\r
\r
- NetListRemoveEntry (&Tcb->List);\r
- NetListInsertHead (&mTcpRunQue, &Tcb->List);\r
+ RemoveEntryList (&Tcb->List);\r
+ InsertHeadList (&mTcpRunQue, &Tcb->List);\r
\r
return Tcb;\r
}\r
IN TCP_CB *Tcb\r
)\r
{\r
- NET_LIST_ENTRY *Entry;\r
- NET_LIST_ENTRY *Head;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Head;\r
TCP_CB *Node;\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
- NetListInsertHead (Head, &Tcb->List);\r
+ InsertHeadList (Head, &Tcb->List);\r
\r
TcpProto = (TCP4_PROTO_DATA *) Tcb->Sk->ProtoReserved;\r
TcpSetVariableData (TcpProto->TcpService);\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
{\r
TCP_CB *Clone;\r
- TCP4_SERVICE_DATA *TcpService;\r
- EFI_IP4_PROTOCOL *Ip4;\r
\r
- Clone = NetAllocatePool (sizeof (TCP_CB));\r
+ Clone = AllocatePool (sizeof (TCP_CB));\r
\r
if (Clone == NULL) {\r
return NULL;\r
\r
}\r
\r
- NetCopyMem (Clone, Tcb, sizeof (TCP_CB));\r
+ CopyMem (Clone, Tcb, sizeof (TCP_CB));\r
\r
//\r
// Increate the reference count of the shared IpInfo.\r
//\r
NET_GET_REF (Tcb->IpInfo);\r
\r
- NetListInit (&Clone->List);\r
- NetListInit (&Clone->SndQue);\r
- NetListInit (&Clone->RcvQue);\r
+ InitializeListHead (&Clone->List);\r
+ InitializeListHead (&Clone->SndQue);\r
+ InitializeListHead (&Clone->RcvQue);\r
\r
Clone->Sk = SockClone (Tcb->Sk);\r
if (Clone->Sk == NULL) {\r
- TCP4_DEBUG_ERROR (("TcpCloneTcb: failed to clone a sock\n"));\r
- NetFreePool (Clone);\r
+ DEBUG ((EFI_D_ERROR, "TcpCloneTcb: failed to clone a sock\n"));\r
+ gBS->FreePool (Clone);\r
return NULL;\r
}\r
\r
((TCP4_PROTO_DATA *) (Clone->Sk->ProtoReserved))->TcpPcb = Clone;\r
\r
- TcpService = ((TCP4_PROTO_DATA *) (Clone->Sk->ProtoReserved))->TcpService;\r
-\r
- NetListInsertTail (&TcpService->SocketList, &Clone->Sk->Link);\r
-\r
- //\r
- // Open the device path on the handle where service binding resides on.\r
- //\r
- gBS->OpenProtocol (\r
- TcpService->ControllerHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **) &Clone->Sk->ParentDevicePath,\r
- TcpService->DriverBindingHandle,\r
- Clone->Sk->SockHandle,\r
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
- );\r
-\r
- //\r
- // Open the ip protocol by child controller.\r
- //\r
- gBS->OpenProtocol (\r
- TcpService->IpIo->ChildHandle,\r
- &gEfiIp4ProtocolGuid,\r
- (VOID **) &Ip4,\r
- TcpService->DriverBindingHandle,\r
- Clone->Sk->SockHandle,\r
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
- );\r
-\r
return Clone;\r
}\r
\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 UINT8 State\r
)\r
{\r
- TCP4_DEBUG_TRACE (\r
- ("Tcb (%x) state %s --> %s\n",\r
+ DEBUG (\r
+ (EFI_D_INFO,\r
+ "Tcb (%p) state %s --> %s\n",\r
Tcb,\r
mTcpStateName[Tcb->State],\r
mTcpStateName[State])\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
@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 (!NetListIsEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk)) {\r
+ if (!IsListEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk) != 0) {\r
\r
- TCP4_DEBUG_WARN (("TcpOnAppClose: connection reset "\r
- "because data is lost for TCB %x\n", Tcb));\r
+ DEBUG ((EFI_D_WARN, "TcpOnAppClose: connection reset "\r
+ "because data is lost for TCB %p\n", Tcb));\r
\r
TcpResetConnection (Tcb);\r
TcpClose (Tcb);\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
\r
@param Tcb Pointer to the TCP_CB of this TCP instance.\r
\r
-\r
**/\r
INTN\r
TcpOnAppConsume (\r
\r
if (TcpOld < Tcb->RcvMss) {\r
\r
- TCP4_DEBUG_TRACE (("TcpOnAppConsume: send a window"\r
- " update for a window closed Tcb(%x)\n", Tcb));\r
+ DEBUG ((EFI_D_INFO, "TcpOnAppConsume: send a window"\r
+ " update for a window closed Tcb(%p)\n", Tcb));\r
\r
TcpSendAck (Tcb);\r
} else if (Tcb->DelayedAck == 0) {\r
\r
- TCP4_DEBUG_TRACE (("TcpOnAppConsume: scheduled a delayed"\r
- " ACK to update window for Tcb(%x)\n", Tcb));\r
+ DEBUG ((EFI_D_INFO, "TcpOnAppConsume: scheduled a delayed"\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
IN TCP_CB *Tcb\r
)\r
{\r
- TCP4_DEBUG_WARN (("TcpOnAppAbort: connection reset "\r
- "issued by application for TCB %x\n", Tcb));\r
+ DEBUG ((EFI_D_WARN, "TcpOnAppAbort: connection reset "\r
+ "issued by application for TCB %p\n", Tcb));\r
\r
switch (Tcb->State) {\r
case TCP_SYN_RCVD:\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
{\r
UINT32 NumConfiguredInstance;\r
- NET_LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Entry;\r
TCP_CB *TcpPcb;\r
TCP4_PROTO_DATA *TcpProto;\r
UINTN VariableDataSize;\r
VariableDataSize += sizeof (EFI_TCP4_SERVICE_POINT) * (NumConfiguredInstance - 1);\r
}\r
\r
- Tcp4VariableData = NetAllocatePool (VariableDataSize);\r
+ Tcp4VariableData = AllocatePool (VariableDataSize);\r
if (Tcp4VariableData == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
// This tcp instance belongs to the Tcp4Service.\r
//\r
Tcp4ServicePoint->InstanceHandle = TcpPcb->Sk->SockHandle;\r
- NetCopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
Tcp4ServicePoint->LocalPort = NTOHS (TcpPcb->LocalEnd.Port);\r
- NetCopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
Tcp4ServicePoint->RemotePort = NTOHS (TcpPcb->RemoteEnd.Port);\r
\r
Tcp4ServicePoint++;\r
// This tcp instance belongs to the Tcp4Service.\r
//\r
Tcp4ServicePoint->InstanceHandle = TcpPcb->Sk->SockHandle;\r
- NetCopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
Tcp4ServicePoint->LocalPort = NTOHS (TcpPcb->LocalEnd.Port);\r
- NetCopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));\r
Tcp4ServicePoint->RemotePort = NTOHS (TcpPcb->RemoteEnd.Port);\r
\r
Tcp4ServicePoint++;\r
);\r
}\r
\r
- NetFreePool (Tcp4Service->MacString);\r
+ gBS->FreePool (Tcp4Service->MacString);\r
}\r
\r
Tcp4Service->MacString = NewMacString;\r
\r
ON_ERROR:\r
\r
- NetFreePool (Tcp4VariableData);\r
+ gBS->FreePool (Tcp4VariableData);\r
\r
return Status;\r
}\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
NULL\r
);\r
\r
- NetFreePool (Tcp4Service->MacString);\r
+ gBS->FreePool (Tcp4Service->MacString);\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
Sock->DevicePath\r
);\r
if (EFI_ERROR (Status)) {\r
- NetFreePool (Sock->DevicePath);\r
+ gBS->FreePool (Sock->DevicePath);\r
}\r
\r
return Status;\r