mirror of https://github.com/acidanthera/audk.git
Add comments for functions and fix some coding style issue.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6885 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
4e2dd553a6
commit
120db52c6d
|
@ -20,6 +20,19 @@ Abstract:
|
|||
|
||||
#include "SockImpl.h"
|
||||
|
||||
/**
|
||||
Get the length of the data that can be retrieved from the socket
|
||||
receive buffer.
|
||||
|
||||
@param SockBuffer Pointer to the socket receive buffer.
|
||||
@param IsUrg Pointer to a BOOLEAN variable. If TRUE the data is
|
||||
OOB.
|
||||
@param BufLen The maximum length of the data buffer to store the
|
||||
received data in socket layer.
|
||||
|
||||
@return The length of the data can be retreived.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
SockTcpDataToRcv (
|
||||
IN SOCK_BUFFER *SockBuffer,
|
||||
|
@ -27,11 +40,21 @@ SockTcpDataToRcv (
|
|||
IN UINT32 BufLen
|
||||
);
|
||||
|
||||
/**
|
||||
Process the send token.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockProcessSndToken (
|
||||
IN SOCKET *Sock
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockFreeFoo (
|
||||
IN EFI_EVENT Event
|
||||
|
@ -66,10 +89,10 @@ SockTcpDataToRcv (
|
|||
TCP_RSV_DATA *TcpRsvData;
|
||||
BOOLEAN Urg;
|
||||
|
||||
ASSERT (SockBuffer && IsUrg && (BufLen > 0));
|
||||
ASSERT ((SockBuffer != NULL) && (IsUrg != NULL) && (BufLen > 0));
|
||||
|
||||
RcvBufEntry = SockBufFirst (SockBuffer);
|
||||
ASSERT (RcvBufEntry);
|
||||
ASSERT (RcvBufEntry != NULL);
|
||||
|
||||
TcpRsvData = (TCP_RSV_DATA *) RcvBufEntry->ProtoData;
|
||||
|
||||
|
@ -133,8 +156,6 @@ SockTcpDataToRcv (
|
|||
@param RcvdBytes The maximum length of the data can be copied.
|
||||
@param IsOOB If TURE the data is OOB, else the data is normal.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockSetTcpRxData (
|
||||
|
@ -197,7 +218,7 @@ SockProcessRcvToken (
|
|||
EFI_TCP4_RECEIVE_DATA *RxData;
|
||||
BOOLEAN IsUrg;
|
||||
|
||||
ASSERT (Sock);
|
||||
ASSERT (Sock != NULL);
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
|
||||
|
@ -306,8 +327,6 @@ SockProcessTcpSndData (
|
|||
@param Sock Pointer to the socket.
|
||||
@param PendingTokenList Pointer to the token list to be flushed.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockFlushPendingToken (
|
||||
|
@ -318,7 +337,7 @@ SockFlushPendingToken (
|
|||
SOCK_TOKEN *SockToken;
|
||||
SOCK_COMPLETION_TOKEN *Token;
|
||||
|
||||
ASSERT (Sock && PendingTokenList);
|
||||
ASSERT ((Sock != NULL) && (PendingTokenList != NULL));
|
||||
|
||||
while (!IsListEmpty (PendingTokenList)) {
|
||||
SockToken = NET_LIST_HEAD (
|
||||
|
@ -337,14 +356,11 @@ SockFlushPendingToken (
|
|||
|
||||
|
||||
/**
|
||||
Wake up the connection token while the connection is
|
||||
successfully established, then try to process any
|
||||
pending send token.
|
||||
Wake up the connection token while the connection is successfully established,
|
||||
then try to process any pending send token.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockWakeConnToken (
|
||||
|
@ -365,13 +381,10 @@ SockWakeConnToken (
|
|||
|
||||
|
||||
/**
|
||||
Wake up the listen token while the connection is
|
||||
established successfully.
|
||||
Wake up the listen token while the connection is established successfully.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockWakeListenToken (
|
||||
|
@ -384,7 +397,7 @@ SockWakeListenToken (
|
|||
|
||||
Parent = Sock->Parent;
|
||||
|
||||
ASSERT (Parent && SOCK_IS_LISTENING (Parent) && SOCK_IS_CONNECTED (Sock));
|
||||
ASSERT ((Parent != NULL) && SOCK_IS_LISTENING (Parent) && SOCK_IS_CONNECTED (Sock));
|
||||
|
||||
if (!IsListEmpty (&Parent->ListenTokenList)) {
|
||||
SockToken = NET_LIST_HEAD (
|
||||
|
@ -416,8 +429,6 @@ SockWakeListenToken (
|
|||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockWakeRcvToken (
|
||||
|
@ -429,7 +440,7 @@ SockWakeRcvToken (
|
|||
SOCK_TOKEN *SockToken;
|
||||
SOCK_IO_TOKEN *RcvToken;
|
||||
|
||||
ASSERT (Sock->RcvBuffer.DataQueue);
|
||||
ASSERT (Sock->RcvBuffer.DataQueue != NULL);
|
||||
|
||||
RcvdBytes = (Sock->RcvBuffer.DataQueue)->BufSize;
|
||||
|
||||
|
@ -462,8 +473,6 @@ SockWakeRcvToken (
|
|||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockProcessSndToken (
|
||||
|
@ -477,7 +486,7 @@ SockProcessSndToken (
|
|||
EFI_TCP4_TRANSMIT_DATA *TxData;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (Sock && (SOCK_STREAM == Sock->Type));
|
||||
ASSERT ((Sock != NULL) && (SOCK_STREAM == Sock->Type));
|
||||
|
||||
FreeSpace = SockGetFreeSpace (Sock, SOCK_SND_BUF);
|
||||
|
||||
|
@ -552,9 +561,9 @@ SockCreate (
|
|||
SOCKET *Parent;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (SockInitData && SockInitData->ProtoHandler);
|
||||
ASSERT ((SockInitData != NULL) && (SockInitData->ProtoHandler != NULL));
|
||||
ASSERT (SockInitData->Type == SOCK_STREAM);
|
||||
ASSERT (SockInitData->ProtoData && (SockInitData->DataSize <= PROTO_RESERVED_LEN));
|
||||
ASSERT ((SockInitData->ProtoData != NULL) && (SockInitData->DataSize <= PROTO_RESERVED_LEN));
|
||||
|
||||
Parent = SockInitData->Parent;
|
||||
|
||||
|
@ -706,8 +715,6 @@ OnError:
|
|||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockDestroy (
|
||||
|
@ -807,8 +814,6 @@ FreeSock:
|
|||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockConnFlush (
|
||||
|
@ -817,7 +822,7 @@ SockConnFlush (
|
|||
{
|
||||
SOCKET *Child;
|
||||
|
||||
ASSERT (Sock);
|
||||
ASSERT (Sock != NULL);
|
||||
|
||||
//
|
||||
// Clear the flag in this socket
|
||||
|
@ -875,8 +880,6 @@ SockConnFlush (
|
|||
@param Sock Pointer to the socket.
|
||||
@param State The new state to be set.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockSetState (
|
||||
|
@ -893,8 +896,7 @@ SockSetState (
|
|||
|
||||
@param Sock Pointer to the socket to be cloned.
|
||||
|
||||
@retval * Pointer to the newly cloned socket. If NULL, error
|
||||
condition occurred.
|
||||
@return Pointer to the newly cloned socket. If NULL, error condition occurred.
|
||||
|
||||
**/
|
||||
SOCKET *
|
||||
|
@ -935,16 +937,12 @@ SockClone (
|
|||
|
||||
|
||||
/**
|
||||
Called by the low layer protocol to indicate the socket
|
||||
a connection is established. This function just changes
|
||||
the socket's state to SO_CONNECTED and signals the token
|
||||
used for connection establishment.
|
||||
Called by the low layer protocol to indicate the socket a connection is
|
||||
established. This function just changes the socket's state to SO_CONNECTED
|
||||
and signals the token used for connection establishment.
|
||||
|
||||
@param Sock Pointer to the socket associated with the
|
||||
established connection.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockConnEstablished (
|
||||
|
@ -967,15 +965,12 @@ SockConnEstablished (
|
|||
|
||||
|
||||
/**
|
||||
Called by the low layer protocol to indicate the connection
|
||||
is closed. This function flushes the socket, sets the state
|
||||
to SO_CLOSED and signals the close token.
|
||||
Called by the low layer protocol to indicate the connection is closed; This
|
||||
function flushes the socket, sets the state to SO_CLOSED and signals the close
|
||||
token.
|
||||
|
||||
@param Sock Pointer to the socket associated with the closed
|
||||
connection.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockConnClosed (
|
||||
|
@ -998,16 +993,13 @@ SockConnClosed (
|
|||
|
||||
|
||||
/**
|
||||
Called by low layer protocol to indicate that some
|
||||
data is sent or processed. This function trims the
|
||||
sent data in the socket send buffer, signals the
|
||||
data token if proper
|
||||
Called by low layer protocol to indicate that some data is sent or processed;
|
||||
This function trims the sent data in the socket send buffer, signals the data
|
||||
token if proper.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
@param Count The length of the data processed or sent, in bytes.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockDataSent (
|
||||
|
@ -1078,7 +1070,7 @@ SockGetDataToSend (
|
|||
IN UINT8 *Dest
|
||||
)
|
||||
{
|
||||
ASSERT (Sock && SOCK_STREAM == Sock->Type);
|
||||
ASSERT ((Sock != NULL) && SOCK_STREAM == Sock->Type);
|
||||
|
||||
return NetbufQueCopy (
|
||||
Sock->SndBuffer.DataQueue,
|
||||
|
@ -1090,18 +1082,15 @@ SockGetDataToSend (
|
|||
|
||||
|
||||
/**
|
||||
Called by the low layer protocol to deliver received data
|
||||
to socket layer. This function will append the data to the
|
||||
socket receive buffer, set ther urgent data length and then
|
||||
check if any receive token can be signaled.
|
||||
Called by the low layer protocol to deliver received data to socket layer;
|
||||
This function will append the data to the socket receive buffer, set ther
|
||||
urgent data length and then check if any receive token can be signaled.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
@param NetBuffer Pointer to the buffer that contains the received
|
||||
data.
|
||||
@param UrgLen The length of the urgent data in the received data.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockDataRcvd (
|
||||
|
@ -1110,7 +1099,7 @@ SockDataRcvd (
|
|||
IN UINT32 UrgLen
|
||||
)
|
||||
{
|
||||
ASSERT (Sock && Sock->RcvBuffer.DataQueue &&
|
||||
ASSERT ((Sock != NULL) && (Sock->RcvBuffer.DataQueue != NULL) &&
|
||||
UrgLen <= NetBuffer->TotalSize);
|
||||
|
||||
NET_GET_REF (NetBuffer);
|
||||
|
@ -1143,7 +1132,7 @@ SockGetFreeSpace (
|
|||
UINT32 BufferCC;
|
||||
SOCK_BUFFER *SockBuffer;
|
||||
|
||||
ASSERT (Sock && ((SOCK_SND_BUF == Which) || (SOCK_RCV_BUF == Which)));
|
||||
ASSERT ((Sock != NULL) && ((SOCK_SND_BUF == Which) || (SOCK_RCV_BUF == Which)));
|
||||
|
||||
if (SOCK_SND_BUF == Which) {
|
||||
SockBuffer = &(Sock->SndBuffer);
|
||||
|
@ -1169,8 +1158,6 @@ SockGetFreeSpace (
|
|||
@param Sock Pointer to the socket.
|
||||
@param Error The error code received.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockRcvdErr (
|
||||
|
@ -1202,15 +1189,13 @@ SockRcvdErr (
|
|||
|
||||
/**
|
||||
Called by the low layer protocol to indicate that there
|
||||
will be no more data from the communication peer. This
|
||||
will be no more data from the communication peer; This
|
||||
function set the socket's state to SO_NO_MORE_DATA and
|
||||
signal all queued IO tokens with the error status
|
||||
EFI_CONNECTION_FIN.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockNoMoreData (
|
||||
|
@ -1270,7 +1255,8 @@ SockBufFirst (
|
|||
@param SockEntry Pointer to the buffer block prior to the required
|
||||
one.
|
||||
|
||||
@return Pointer to the buffer block next to SockEntry. NULL if SockEntry is the tail or head entry.
|
||||
@return Pointer to the buffer block next to SockEntry. NULL if SockEntry is
|
||||
the tail or head entry.
|
||||
|
||||
**/
|
||||
NET_BUF *
|
||||
|
@ -1285,8 +1271,7 @@ SockBufNext (
|
|||
|
||||
if ((SockEntry->List.ForwardLink == NetbufList) ||
|
||||
(SockEntry->List.BackLink == &SockEntry->List) ||
|
||||
(SockEntry->List.ForwardLink == &SockEntry->List)
|
||||
) {
|
||||
(SockEntry->List.ForwardLink == &SockEntry->List)) {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ Abstract:
|
|||
@param List Pointer to the token list to be searched.
|
||||
@param Event The event to be checked.
|
||||
|
||||
@retval BOOLEAN If TRUE, the specific Event exists in the List. If
|
||||
FALSE, the specific Event is not in the List.
|
||||
@retval TRUE The specific Event exists in the List.
|
||||
@retval False The specific Event is not in the List.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
|
@ -77,8 +77,7 @@ SockTokenExisted (
|
|||
if (SockTokenExistedInList (&Sock->SndTokenList, Event) ||
|
||||
SockTokenExistedInList (&Sock->ProcessingSndTokenList, Event) ||
|
||||
SockTokenExistedInList (&Sock->RcvTokenList, Event) ||
|
||||
SockTokenExistedInList (&Sock->ListenTokenList, Event)
|
||||
) {
|
||||
SockTokenExistedInList (&Sock->ListenTokenList, Event)) {
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -152,7 +151,7 @@ SockDestroyChild (
|
|||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (Sock && Sock->ProtoHandler);
|
||||
ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL));
|
||||
|
||||
if (Sock->IsDestroyed) {
|
||||
return EFI_SUCCESS;
|
||||
|
@ -258,8 +257,7 @@ SockCreateChild (
|
|||
|
||||
|
||||
/**
|
||||
Configure the specific socket Sock using configuration data
|
||||
ConfigData.
|
||||
Configure the specific socket Sock using configuration data ConfigData.
|
||||
|
||||
@param Sock Pointer to the socket to be configured.
|
||||
@param ConfigData Pointer to the configuration data.
|
||||
|
@ -455,7 +453,7 @@ SockAccept (
|
|||
|
||||
RemoveEntryList (ListEntry);
|
||||
|
||||
ASSERT (Socket->Parent);
|
||||
ASSERT (Socket->Parent != NULL);
|
||||
|
||||
Socket->Parent->ConnCnt--;
|
||||
|
||||
|
|
|
@ -23,42 +23,33 @@ Abstract:
|
|||
#define TCP_COMP_VAL(Min, Max, Default, Val) \
|
||||
((((Val) <= (Max)) && ((Val) >= (Min))) ? (Val) : (Default))
|
||||
|
||||
/**
|
||||
Add or remove a route entry in the IP route table associated with this TCP instance.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param RouteInfo Pointer to the route info to be processed.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_NOT_STARTED The driver instance has not been started.
|
||||
@retval EFI_NO_MAPPING When using the default address, configuration(DHCP,
|
||||
BOOTP, RARP, etc.) is not finished yet.
|
||||
@retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
|
||||
@retval EFI_NOT_FOUND This route is not in the routing table
|
||||
(when RouteInfo->DeleteRoute is TRUE).
|
||||
@retval EFI_ACCESS_DENIED The route is already defined in the routing table
|
||||
(when RouteInfo->DeleteRoute is FALSE).
|
||||
**/
|
||||
EFI_STATUS
|
||||
Tcp4Route (
|
||||
IN TCP_CB *Tcb,
|
||||
IN TCP4_ROUTE_INFO *RouteInfo
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Add or remove a route entry in the IP route table associated
|
||||
with this TCP instance.
|
||||
|
||||
Arguments:
|
||||
|
||||
Tcb - Pointer to the TCP_CB of this TCP instance.
|
||||
RouteInfo - Pointer to the route info to be processed.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - The operation completed successfully.
|
||||
EFI_NOT_STARTED - The driver instance has not been started.
|
||||
EFI_NO_MAPPING - When using the default address, configuration(DHCP,
|
||||
BOOTP, RARP, etc.) is not finished yet.
|
||||
EFI_OUT_OF_RESOURCES - Could not add the entry to the routing table.
|
||||
EFI_NOT_FOUND - This route is not in the routing table
|
||||
(when RouteInfo->DeleteRoute is TRUE).
|
||||
EFI_ACCESS_DENIED - The route is already defined in the routing table
|
||||
(when RouteInfo->DeleteRoute is FALSE).
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_IP4_PROTOCOL *Ip;
|
||||
|
||||
Ip = Tcb->IpInfo->Ip;
|
||||
|
||||
ASSERT (Ip);
|
||||
ASSERT (Ip != NULL);
|
||||
|
||||
return Ip->Routes (
|
||||
Ip,
|
||||
|
@ -147,7 +138,7 @@ Tcp4GetMode (
|
|||
}
|
||||
|
||||
Ip = Tcb->IpInfo->Ip;
|
||||
ASSERT (Ip);
|
||||
ASSERT (Ip != NULL);
|
||||
|
||||
return Ip->GetModeData (Ip, Mode->Ip4ModeData, Mode->MnpConfigData, Mode->SnpModeData);
|
||||
}
|
||||
|
@ -224,8 +215,6 @@ Tcp4Bind (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB to be flushed.
|
||||
|
||||
None
|
||||
|
||||
**/
|
||||
VOID
|
||||
Tcp4FlushPcb (
|
||||
|
@ -260,6 +249,15 @@ Tcp4FlushPcb (
|
|||
NetbufFreeList (&Tcb->RcvQue);
|
||||
}
|
||||
|
||||
/**
|
||||
Attach a Tcb to the socket.
|
||||
|
||||
@param Sk Pointer to the socket of this TCP instance.
|
||||
|
||||
@retval EFI_SUCCESS The operation is completed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Failed due to resource limit.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Tcp4AttachPcb (
|
||||
IN SOCKET *Sk
|
||||
|
@ -302,6 +300,12 @@ Tcp4AttachPcb (
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Detach the Tcb of the socket.
|
||||
|
||||
@param Sk Pointer to the socket of this TCP instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Tcp4DetachPcb (
|
||||
IN SOCKET *Sk
|
||||
|
@ -349,7 +353,7 @@ Tcp4ConfigurePcb (
|
|||
TCP4_PROTO_DATA *TcpProto;
|
||||
TCP_CB *Tcb;
|
||||
|
||||
ASSERT (CfgData && Sk && Sk->SockHandle);
|
||||
ASSERT ((CfgData != NULL) && (Sk != NULL) && (Sk->SockHandle != NULL));
|
||||
|
||||
TcpProto = (TCP4_PROTO_DATA *) Sk->ProtoReserved;
|
||||
Tcb = TcpProto->TcpPcb;
|
||||
|
@ -617,13 +621,13 @@ Tcp4Dispatcher (
|
|||
// notify TCP using this message to give it a chance to send out
|
||||
// window update information
|
||||
//
|
||||
ASSERT (Tcb);
|
||||
ASSERT (Tcb != NULL);
|
||||
TcpOnAppConsume (Tcb);
|
||||
break;
|
||||
|
||||
case SOCK_SND:
|
||||
|
||||
ASSERT (Tcb);
|
||||
ASSERT (Tcb != NULL);
|
||||
TcpOnAppSend (Tcb);
|
||||
break;
|
||||
|
||||
|
@ -686,7 +690,7 @@ Tcp4Dispatcher (
|
|||
|
||||
case SOCK_MODE:
|
||||
|
||||
ASSERT (Data && Tcb);
|
||||
ASSERT ((Data != NULL) && (Tcb != NULL));
|
||||
|
||||
return Tcp4GetMode (Tcb, (TCP4_MODE_DATA *) Data);
|
||||
|
||||
|
@ -694,7 +698,7 @@ Tcp4Dispatcher (
|
|||
|
||||
case SOCK_ROUTE:
|
||||
|
||||
ASSERT (Data && Tcb);
|
||||
ASSERT ((Data != NULL) && (Tcb != NULL));
|
||||
|
||||
return Tcp4Route (Tcb, (TCP4_ROUTE_INFO *) Data);
|
||||
|
||||
|
|
|
@ -78,8 +78,6 @@ EFI_SERVICE_BINDING_PROTOCOL mTcp4ServiceBinding = {
|
|||
/**
|
||||
Create and start the heartbeat timer for TCP driver.
|
||||
|
||||
None.
|
||||
|
||||
@retval EFI_SUCCESS The timer is successfully created and started.
|
||||
@retval other The timer is not created.
|
||||
|
||||
|
@ -124,13 +122,11 @@ Tcp4CreateTimer (
|
|||
/**
|
||||
Stop and destroy the heartbeat timer for TCP driver.
|
||||
|
||||
None
|
||||
|
||||
None
|
||||
|
||||
**/
|
||||
VOID
|
||||
Tcp4DestroyTimer ()
|
||||
Tcp4DestroyTimer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ASSERT (mTcp4Timer.RefCnt > 0);
|
||||
|
||||
|
@ -146,8 +142,7 @@ Tcp4DestroyTimer ()
|
|||
}
|
||||
|
||||
/**
|
||||
The entry point for Tcp4 driver.
|
||||
Used to install Tcp4 driver on the ImageHandle.
|
||||
The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
|
||||
|
||||
@param ImageHandle The firmware allocated handle for this
|
||||
driver image.
|
||||
|
@ -464,6 +459,17 @@ Tcp4DriverBindingStop (
|
|||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Open Ip4 and device path protocols for a created socket, and insert it in
|
||||
socket list.
|
||||
|
||||
@param This Pointer to the socket just created
|
||||
@param Context Context of the socket
|
||||
|
||||
@retval EFI_SUCCESS This protocol is installed successfully.
|
||||
@retval other Some error occured.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Tcp4CreateSocketCallback (
|
||||
IN SOCKET *This,
|
||||
|
@ -519,6 +525,13 @@ Tcp4CreateSocketCallback (
|
|||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Close Ip4 and device path protocols for a socket, and remove it from socket list.
|
||||
|
||||
@param This Pointer to the socket to be removed
|
||||
@param Context Context of the socket
|
||||
|
||||
**/
|
||||
VOID
|
||||
Tcp4DestroySocketCallback (
|
||||
IN SOCKET *This,
|
||||
|
|
|
@ -24,13 +24,13 @@ Abstract:
|
|||
|
||||
|
||||
/**
|
||||
Check whether the sequence number of the incoming segment
|
||||
is acceptable.
|
||||
Check whether the sequence number of the incoming segment is acceptable.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Seg Pointer to the incoming segment.
|
||||
|
||||
@return 1 if the sequence number is acceptable, otherwise 0.
|
||||
@retval 1 The sequence number is acceptable.
|
||||
@retval 0 The sequence number is not acceptable.
|
||||
|
||||
**/
|
||||
INTN
|
||||
|
@ -50,8 +50,6 @@ TcpSeqAcceptable (
|
|||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Seg Segment that triggers the fast recovery.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpFastRecover (
|
||||
|
@ -162,8 +160,6 @@ TcpFastRecover (
|
|||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Seg Segment that triggers the fast loss recovery.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpFastLossRecover (
|
||||
|
@ -203,13 +199,11 @@ TcpFastLossRecover (
|
|||
|
||||
|
||||
/**
|
||||
Compute the RTT as specified in RFC2988
|
||||
Compute the RTT as specified in RFC2988.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Measure Currently measured RTT in heart beats.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpComputeRtt (
|
||||
|
@ -264,14 +258,13 @@ TcpComputeRtt (
|
|||
|
||||
|
||||
/**
|
||||
Trim the data, SYN and FIN to fit into the window defined by
|
||||
Left and Right.
|
||||
Trim the data, SYN and FIN to fit into the window defined by Left and Right.
|
||||
|
||||
@param Nbuf Buffer that contains received TCP segment without IP header.
|
||||
@param Left The sequence number of the window's left edge.
|
||||
@param Right The sequence number of the window's right edge.
|
||||
|
||||
@return 0, the data is successfully trimmed.
|
||||
@return 0 The data is successfully trimmed.
|
||||
|
||||
**/
|
||||
INTN
|
||||
|
@ -351,7 +344,7 @@ TcpTrimSegment (
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT (TcpVerifySegment (Nbuf));
|
||||
ASSERT (TcpVerifySegment (Nbuf) != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -362,7 +355,7 @@ TcpTrimSegment (
|
|||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Nbuf Pointer to the NET_BUF containing the received tcp segment.
|
||||
|
||||
@return 0, the data is trimmed.
|
||||
@return 0 The data is trimmed.
|
||||
|
||||
**/
|
||||
INTN
|
||||
|
@ -397,7 +390,7 @@ TcpDeliverData (
|
|||
TCP_SEG *Seg;
|
||||
UINT32 Urgent;
|
||||
|
||||
ASSERT (Tcb && Tcb->Sk);
|
||||
ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
|
||||
|
||||
//
|
||||
// make sure there is some data queued,
|
||||
|
@ -418,7 +411,7 @@ TcpDeliverData (
|
|||
Nbuf = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
|
||||
Seg = TCPSEG_NETBUF (Nbuf);
|
||||
|
||||
ASSERT (TcpVerifySegment (Nbuf));
|
||||
ASSERT (TcpVerifySegment (Nbuf) != 0);
|
||||
ASSERT (Nbuf->Tcp == NULL);
|
||||
|
||||
if (TCP_SEQ_GT (Seg->Seq, Seq)) {
|
||||
|
@ -547,8 +540,6 @@ TcpDeliverData (
|
|||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Nbuf Pointer to the buffer containing the data to be queued.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpQueueData (
|
||||
|
@ -562,7 +553,7 @@ TcpQueueData (
|
|||
LIST_ENTRY *Cur;
|
||||
NET_BUF *Node;
|
||||
|
||||
ASSERT (Tcb && Nbuf && (Nbuf->Tcp == NULL));
|
||||
ASSERT ((Tcb != NULL) && (Nbuf != NULL) && (Nbuf->Tcp == NULL));
|
||||
|
||||
NET_GET_REF (Nbuf);
|
||||
|
||||
|
@ -655,8 +646,6 @@ TcpQueueData (
|
|||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Ack The acknowledge seuqence number of the received segment.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpAdjustSndQue (
|
||||
|
@ -991,8 +980,7 @@ TcpInput (
|
|||
} else if ((Tcb->State == TCP_ESTABLISHED) ||
|
||||
(Tcb->State == TCP_FIN_WAIT_1) ||
|
||||
(Tcb->State == TCP_FIN_WAIT_2) ||
|
||||
(Tcb->State == TCP_CLOSE_WAIT)
|
||||
) {
|
||||
(Tcb->State == TCP_CLOSE_WAIT)) {
|
||||
|
||||
SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);
|
||||
|
||||
|
@ -1162,7 +1150,7 @@ TcpInput (
|
|||
Tcb->SndUna = Seg->Ack;
|
||||
|
||||
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_SND_URG) &&
|
||||
(TCP_SEQ_LT (Tcb->SndUp, Seg->Ack))) {
|
||||
TCP_SEQ_LT (Tcb->SndUp, Seg->Ack)) {
|
||||
|
||||
TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_SND_URG);
|
||||
}
|
||||
|
@ -1390,7 +1378,7 @@ RESET_THEN_DROP:
|
|||
TcpSendReset (Tcb, Head, Len, Dst, Src);
|
||||
|
||||
DROP_CONNECTION:
|
||||
ASSERT (Tcb && Tcb->Sk);
|
||||
ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
|
||||
|
||||
NetbufFree (Nbuf);
|
||||
TcpClose (Tcb);
|
||||
|
@ -1411,7 +1399,7 @@ DISCARD:
|
|||
|
||||
if ((Parent != NULL) && (Tcb != NULL)) {
|
||||
|
||||
ASSERT (Tcb->Sk);
|
||||
ASSERT (Tcb->Sk != NULL);
|
||||
TcpClose (Tcb);
|
||||
}
|
||||
|
||||
|
@ -1428,8 +1416,6 @@ DISCARD:
|
|||
@param Src Source address of the ICMP error message.
|
||||
@param Dst Destination address of the ICMP error message.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpIcmpInput (
|
||||
|
|
|
@ -221,9 +221,9 @@ Tcp4Configure (
|
|||
/**
|
||||
Add or delete routing entries.
|
||||
|
||||
The Routes() function adds or deletes a route from the instance¡¯s routing table.
|
||||
The Routes() function adds or deletes a route from the instance’s routing table.
|
||||
The most specific route is selected by comparing the SubnetAddress with the
|
||||
destination IP address¡¯s arithmetical AND to the SubnetMask.
|
||||
destination IP address’s arithmetical AND to the SubnetMask.
|
||||
The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0.
|
||||
The default route matches all destination IP addresses if there is no more specific route.
|
||||
Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to
|
||||
|
@ -231,9 +231,9 @@ Tcp4Configure (
|
|||
cache or it is on the local subnet. If the instance is configured to use default
|
||||
address, a direct route to the local network will be added automatically.
|
||||
Each TCP instance has its own independent routing table. Instance that uses the
|
||||
default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL¡¯s routing table.
|
||||
default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL’s routing table.
|
||||
The copy will be updated automatically whenever the IP driver reconfigures its
|
||||
instance. As a result, the previous modification to the instance¡¯s local copy
|
||||
instance. As a result, the previous modification to the instance’s local copy
|
||||
will be lost. The priority of checking the route table is specific with IP
|
||||
implementation and every IP implementation must comply with RFC 1122.
|
||||
|
||||
|
@ -348,7 +348,7 @@ Tcp4Connect (
|
|||
incoming connection on the passive TCP instance. If a remote peer successfully
|
||||
establishes a connection with this instance, a new TCP instance will be created
|
||||
and its handle will be returned in ListenToken->NewChildHandle. The newly created
|
||||
instance is configured by inheriting the passive instance¡¯s configuration and is
|
||||
instance is configured by inheriting the passive instance’s configuration and is
|
||||
ready for use upon return. The instance is in the Tcp4StateEstablished state.
|
||||
The ListenToken->CompletionToken.Event will be signaled when a new connection
|
||||
is accepted, user aborts the listen or connection is reset. This function only
|
||||
|
@ -393,7 +393,7 @@ Tcp4Accept (
|
|||
|
||||
|
||||
/**
|
||||
Queues outgoing data into the transmit queue
|
||||
Queues outgoing data into the transmit queue.
|
||||
|
||||
The Transmit() function queues a sending request to this TCPv4 instance along
|
||||
with the user data. The status of the token is updated and the event in the token
|
||||
|
@ -403,12 +403,12 @@ Tcp4Accept (
|
|||
@param Token Pointer to the completion token to queue to the
|
||||
transmit queue
|
||||
|
||||
@retval EFI_SUCCESS The data has been queued for transmission
|
||||
@retval EFI_SUCCESS The data has been queued for transmission.
|
||||
@retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
|
||||
configured.
|
||||
@retval EFI_NO_MAPPING When using a default address, configuration
|
||||
(DHCP, BOOTP, RARP, etc.) is not finished yet.
|
||||
@retval EFI_INVALID_PARAMETER One or more parameters are invalid
|
||||
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
|
||||
@retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
|
||||
* A transmit completion token with the same
|
||||
Token-> CompletionToken.Event was already in the
|
||||
|
@ -481,7 +481,7 @@ Tcp4Transmit (
|
|||
@param Token Pointer to a token that is associated with the
|
||||
receive data descriptor.
|
||||
|
||||
@retval EFI_SUCCESS The receive completion token was cached
|
||||
@retval EFI_SUCCESS The receive completion token was cached.
|
||||
@retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
|
||||
configured.
|
||||
@retval EFI_NO_MAPPING When using a default address, configuration
|
||||
|
@ -556,11 +556,11 @@ Tcp4Receive (
|
|||
asynchronous operation is signaled and any buffers used for TCP network traffic
|
||||
is flushed.
|
||||
|
||||
@param This Pointer to the EFI_TCP4_PROTOCOL instance
|
||||
@param This Pointer to the EFI_TCP4_PROTOCOL instance.
|
||||
@param CloseToken Pointer to the close token to return when
|
||||
operation finishes.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
|
||||
configured.
|
||||
@retval EFI_ACCESS_DENIED One or more of the following are TRUE:
|
||||
|
@ -568,9 +568,9 @@ Tcp4Receive (
|
|||
set to NULL and this function has not returned.
|
||||
* Previous Close() call on this instance has not
|
||||
finished.
|
||||
@retval EFI_INVALID_PARAMETER One ore more parameters are invalid
|
||||
@retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the
|
||||
operation
|
||||
operation.
|
||||
@retval EFI_DEVICE_ERROR Any unexpected and not belonged to above
|
||||
category error.
|
||||
|
||||
|
@ -606,6 +606,7 @@ Tcp4Close (
|
|||
is not in one of the queues, which usually means that the asynchronous operation
|
||||
has completed, EFI_NOT_FOUND is returned. If Token is NULL all asynchronous token
|
||||
issued by Connect(), Accept(), Transmit() and Receive()will be aborted.
|
||||
NOTE: It has not been implemented currently.
|
||||
|
||||
@param This Pointer to the EFI_TCP4_PROTOCOL instance.
|
||||
@param Token Pointer to a token that has been issued by
|
||||
|
@ -616,12 +617,12 @@ Tcp4Close (
|
|||
@retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
|
||||
is signaled.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
@retval EFI_NOT_STARTED This instance hasn¡¯t been configured.
|
||||
@retval EFI_NOT_STARTED This instance hasn’t been configured.
|
||||
@retval EFI_NO_MAPPING When using the default address, configuration
|
||||
(DHCP, BOOTP,RARP, etc.) hasn¡¯t finished yet.
|
||||
@retval EFI_NOT_FOUND The asynchronous I/O request isn¡¯t found in the
|
||||
(DHCP, BOOTP,RARP, etc.) hasn’t finished yet.
|
||||
@retval EFI_NOT_FOUND The asynchronous I/O request isn’t found in the
|
||||
transmission or receive queue. It has either
|
||||
completed or wasn¡¯t issued by Transmit() and Receive().
|
||||
completed or wasn’t issued by Transmit() and Receive().
|
||||
@retval EFI_UNSUPPORTED The operation is not supported in current
|
||||
implementation.
|
||||
|
||||
|
|
|
@ -57,8 +57,6 @@ CHAR16 *mTcpStateName[] = {
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpInitTcbLocal (
|
||||
|
@ -85,7 +83,7 @@ TcpInitTcbLocal (
|
|||
Tcb->RcvWnd = GET_RCV_BUFFSIZE (Tcb->Sk);
|
||||
|
||||
//
|
||||
// Fisrt window size is never scaled
|
||||
// First window size is never scaled
|
||||
//
|
||||
Tcb->RcvWndScale = 0;
|
||||
}
|
||||
|
@ -99,8 +97,6 @@ TcpInitTcbLocal (
|
|||
intial info.
|
||||
@param Opt Pointer to the options announced by the peer.
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpInitTcbPeer (
|
||||
|
@ -183,7 +179,8 @@ TcpInitTcbPeer (
|
|||
@param Local Pointer to the local (IP, Port).
|
||||
@param Remote Pointer to the remote (IP, Port).
|
||||
|
||||
@return Pointer to the TCP_CB with the least number of wildcard, if NULL no match is found.
|
||||
@return Pointer to the TCP_CB with the least number of wildcard,
|
||||
if NULL no match is found.
|
||||
|
||||
**/
|
||||
TCP_CB *
|
||||
|
@ -206,8 +203,7 @@ TcpLocateListenTcb (
|
|||
|
||||
if ((Local->Port != Node->LocalEnd.Port) ||
|
||||
!TCP_PEER_MATCH (Remote, &Node->RemoteEnd) ||
|
||||
!TCP_PEER_MATCH (Local, &Node->LocalEnd)
|
||||
) {
|
||||
!TCP_PEER_MATCH (Local, &Node->LocalEnd)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -369,13 +365,11 @@ TcpInsertTcb (
|
|||
TCP4_PROTO_DATA *TcpProto;
|
||||
|
||||
ASSERT (
|
||||
Tcb &&
|
||||
(
|
||||
(Tcb->State == TCP_LISTEN) ||
|
||||
(Tcb != NULL) &&
|
||||
((Tcb->State == TCP_LISTEN) ||
|
||||
(Tcb->State == TCP_SYN_SENT) ||
|
||||
(Tcb->State == TCP_SYN_RCVD) ||
|
||||
(Tcb->State == TCP_CLOSED)
|
||||
)
|
||||
(Tcb->State == TCP_CLOSED))
|
||||
);
|
||||
|
||||
if (Tcb->LocalEnd.Port == 0) {
|
||||
|
@ -459,8 +453,6 @@ TcpCloneTcb (
|
|||
/**
|
||||
Compute an ISS to be used by a new connection.
|
||||
|
||||
None
|
||||
|
||||
@return The result ISS.
|
||||
|
||||
**/
|
||||
|
@ -491,11 +483,11 @@ TcpGetRcvMss (
|
|||
TCP4_PROTO_DATA *TcpProto;
|
||||
EFI_IP4_PROTOCOL *Ip;
|
||||
|
||||
ASSERT (Sock);
|
||||
ASSERT (Sock != NULL);
|
||||
|
||||
TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
|
||||
Ip = TcpProto->TcpService->IpIo->Ip;
|
||||
ASSERT (Ip);
|
||||
ASSERT (Ip != NULL);
|
||||
|
||||
Ip->GetModeData (Ip, NULL, NULL, &SnpMode);
|
||||
|
||||
|
@ -509,8 +501,6 @@ TcpGetRcvMss (
|
|||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param State The state to be set.
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpSetState (
|
||||
|
@ -639,8 +629,6 @@ TcpFormatNetbuf (
|
|||
@param Tcb Pointer to the TCP_CB of the connection to be
|
||||
reset.
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpResetConnection (
|
||||
|
@ -685,13 +673,11 @@ TcpResetConnection (
|
|||
|
||||
|
||||
/**
|
||||
Initialize an active connection,
|
||||
Initialize an active connection.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB that wants to initiate a
|
||||
connection.
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpOnAppConnect (
|
||||
|
@ -712,17 +698,15 @@ TcpOnAppConnect (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpOnAppClose (
|
||||
IN TCP_CB *Tcb
|
||||
)
|
||||
{
|
||||
ASSERT (Tcb);
|
||||
ASSERT (Tcb != NULL);
|
||||
|
||||
if (!IsListEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk)) {
|
||||
if (!IsListEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk) != 0) {
|
||||
|
||||
DEBUG ((EFI_D_WARN, "TcpOnAppClose: connection reset "
|
||||
"because data is lost for TCB %p\n", Tcb));
|
||||
|
@ -754,8 +738,7 @@ TcpOnAppClose (
|
|||
|
||||
|
||||
/**
|
||||
Check whether the application's newly delivered data
|
||||
can be sent out.
|
||||
Check whether the application's newly delivered data can be sent out.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
|
@ -810,7 +793,6 @@ TcpOnAppSend (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
|
||||
**/
|
||||
INTN
|
||||
TcpOnAppConsume (
|
||||
|
@ -877,8 +859,6 @@ TcpOnAppConsume (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of the TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpOnAppAbort (
|
||||
|
@ -905,7 +885,7 @@ TcpOnAppAbort (
|
|||
/**
|
||||
Set the Tdp4 variable data.
|
||||
|
||||
@param Tcp4Service Tcp4 service data.
|
||||
@param Tcp4Service Pointer to Tcp4 service data.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.
|
||||
@retval other Set variable failed.
|
||||
|
@ -1078,9 +1058,7 @@ ON_ERROR:
|
|||
/**
|
||||
Clear the variable and free the resource.
|
||||
|
||||
@param Tcp4Service Tcp4 service data.
|
||||
|
||||
@return None.
|
||||
@param Tcp4Service Pointer to Tcp4 service data.
|
||||
|
||||
**/
|
||||
VOID
|
||||
|
@ -1102,26 +1080,19 @@ TcpClearVariableData (
|
|||
Tcp4Service->MacString = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Install the device path protocol on the TCP instance.
|
||||
|
||||
@param Sock Pointer to the socket representing the TCP instance.
|
||||
|
||||
@retval EFI_SUCCESS The device path protocol is installed.
|
||||
@retval other Failed to install the device path protocol.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
TcpInstallDevicePath (
|
||||
IN SOCKET *Sock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Install the device path protocol on the TCP instance.
|
||||
|
||||
Arguments:
|
||||
|
||||
Sock - Pointer to the socket representing the TCP instance.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - The device path protocol is installed.
|
||||
other - Failed to install the device path protocol.
|
||||
|
||||
--*/
|
||||
{
|
||||
TCP4_PROTO_DATA *TcpProto;
|
||||
TCP4_SERVICE_DATA *TcpService;
|
||||
|
|
|
@ -22,6 +22,14 @@ Abstract:
|
|||
|
||||
#include "Tcp4Main.h"
|
||||
|
||||
/**
|
||||
Get a UINT16 value from buffer.
|
||||
|
||||
@param Buf Pointer to input buffer.
|
||||
|
||||
@return The UINT16 value get from buffer.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
TcpGetUint16 (
|
||||
IN UINT8 *Buf
|
||||
|
@ -32,17 +40,14 @@ TcpGetUint16 (
|
|||
return NTOHS (Value);
|
||||
}
|
||||
|
||||
// STATIC
|
||||
// VOID
|
||||
// TcpPutUint16 (
|
||||
// IN UINT8 *Buf,
|
||||
// IN UINT16 Data
|
||||
// )
|
||||
// {
|
||||
// Data = HTONS (Data);
|
||||
// CopyMem (Buf, &Data, sizeof (UINT16));
|
||||
// }
|
||||
/**
|
||||
Get a UINT32 value from buffer.
|
||||
|
||||
@param Buf Pointer to input buffer.
|
||||
|
||||
@return The UINT32 value get from buffer.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
TcpGetUint32 (
|
||||
IN UINT8 *Buf
|
||||
|
@ -53,6 +58,13 @@ TcpGetUint32 (
|
|||
return NTOHL (Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Put a UINT32 value in buffer.
|
||||
|
||||
@param Buf Pointer to the buffer.
|
||||
@param Data The UINT32 Date to put in buffer
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpPutUint32 (
|
||||
IN UINT8 *Buf,
|
||||
|
@ -65,12 +77,11 @@ TcpPutUint32 (
|
|||
|
||||
|
||||
/**
|
||||
Compute the window scale value according to the given
|
||||
buffer size.
|
||||
Compute the window scale value according to the given buffer size.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@retval UINT8 The scale value.
|
||||
@return The scale value.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
|
@ -81,7 +92,7 @@ TcpComputeScale (
|
|||
UINT8 Scale;
|
||||
UINT32 BufSize;
|
||||
|
||||
ASSERT (Tcb && Tcb->Sk);
|
||||
ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
|
||||
|
||||
BufSize = GET_RCV_BUFFSIZE (Tcb->Sk);
|
||||
|
||||
|
@ -114,7 +125,7 @@ TcpSynBuildOption (
|
|||
UINT8 *Data;
|
||||
UINT16 Len;
|
||||
|
||||
ASSERT (Tcb && Nbuf && !Nbuf->Tcp);
|
||||
ASSERT ((Tcb != NULL) && (Nbuf != NULL) && (Nbuf->Tcp == NULL));
|
||||
|
||||
Len = 0;
|
||||
|
||||
|
@ -133,7 +144,7 @@ TcpSynBuildOption (
|
|||
NET_BUF_HEAD
|
||||
);
|
||||
|
||||
ASSERT (Data);
|
||||
ASSERT (Data != NULL);
|
||||
Len += TCP_OPTION_TS_ALIGNED_LEN;
|
||||
|
||||
TcpPutUint32 (Data, TCP_OPTION_TS_FAST);
|
||||
|
@ -156,7 +167,7 @@ TcpSynBuildOption (
|
|||
NET_BUF_HEAD
|
||||
);
|
||||
|
||||
ASSERT (Data);
|
||||
ASSERT (Data != NULL);
|
||||
|
||||
Len += TCP_OPTION_WS_ALIGNED_LEN;
|
||||
TcpPutUint32 (Data, TCP_OPTION_WS_FAST | TcpComputeScale (Tcb));
|
||||
|
@ -166,7 +177,7 @@ TcpSynBuildOption (
|
|||
// Build MSS option
|
||||
//
|
||||
Data = NetbufAllocSpace (Nbuf, TCP_OPTION_MSS_LEN, 1);
|
||||
ASSERT (Data);
|
||||
ASSERT (Data != NULL);
|
||||
|
||||
Len += TCP_OPTION_MSS_LEN;
|
||||
TcpPutUint32 (Data, TCP_OPTION_MSS_FAST | Tcb->RcvMss);
|
||||
|
@ -193,7 +204,7 @@ TcpBuildOption (
|
|||
UINT8 *Data;
|
||||
UINT16 Len;
|
||||
|
||||
ASSERT (Tcb && Nbuf && !Nbuf->Tcp);
|
||||
ASSERT ((Tcb != NULL) && (Nbuf != NULL) && (Nbuf->Tcp == NULL));
|
||||
Len = 0;
|
||||
|
||||
//
|
||||
|
@ -208,7 +219,7 @@ TcpBuildOption (
|
|||
NET_BUF_HEAD
|
||||
);
|
||||
|
||||
ASSERT (Data);
|
||||
ASSERT (Data != NULL);
|
||||
Len += TCP_OPTION_TS_ALIGNED_LEN;
|
||||
|
||||
TcpPutUint32 (Data, TCP_OPTION_TS_FAST);
|
||||
|
@ -243,7 +254,7 @@ TcpParseOption (
|
|||
UINT8 Type;
|
||||
UINT8 Len;
|
||||
|
||||
ASSERT (Tcp && Option);
|
||||
ASSERT ((Tcp != NULL) && (Option != NULL));
|
||||
|
||||
Option->Flag = 0;
|
||||
|
||||
|
@ -333,7 +344,7 @@ TcpParseOption (
|
|||
default:
|
||||
Len = Head[Cur + 1];
|
||||
|
||||
if (TotalLen - Cur < Len || Len < 2) {
|
||||
if ((TotalLen - Cur) < Len || Len < 2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ TcpRcvWinNow (
|
|||
UINT32 OldWin;
|
||||
|
||||
Sk = Tcb->Sk;
|
||||
ASSERT (Sk);
|
||||
ASSERT (Sk != NULL);
|
||||
|
||||
OldWin = TcpRcvWinOld (Tcb);
|
||||
|
||||
|
@ -199,7 +199,7 @@ TcpDataToSend (
|
|||
UINT32 Limit;
|
||||
|
||||
Sk = Tcb->Sk;
|
||||
ASSERT (Sk);
|
||||
ASSERT (Sk != NULL);
|
||||
|
||||
//
|
||||
// TCP should NOT send data beyond the send window
|
||||
|
@ -284,8 +284,7 @@ SetPersistTimer:
|
|||
|
||||
|
||||
/**
|
||||
Build the TCP header of the TCP segment and transmit the
|
||||
segment by IP.
|
||||
Build the TCP header of the TCP segment and transmit the segment by IP.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Nbuf Pointer to the buffer containing the segment to be sent out.
|
||||
|
@ -306,7 +305,7 @@ TcpTransmitSegment (
|
|||
BOOLEAN Syn;
|
||||
UINT32 DataLen;
|
||||
|
||||
ASSERT (Nbuf && (Nbuf->Tcp == NULL) && TcpVerifySegment (Nbuf));
|
||||
ASSERT ((Nbuf != NULL) && (Nbuf->Tcp == NULL) && (TcpVerifySegment (Nbuf) != 0));
|
||||
|
||||
DataLen = Nbuf->TotalSize;
|
||||
|
||||
|
@ -435,7 +434,7 @@ TcpGetSegmentSndQue (
|
|||
INT32 Offset;
|
||||
INT32 CopyLen;
|
||||
|
||||
ASSERT (Tcb && TCP_SEQ_LEQ (Seq, Tcb->SndNxt) && (Len > 0));
|
||||
ASSERT ((Tcb != NULL) && TCP_SEQ_LEQ (Seq, Tcb->SndNxt) && (Len > 0));
|
||||
|
||||
//
|
||||
// Find the segment that contains the Seq.
|
||||
|
@ -530,7 +529,7 @@ TcpGetSegmentSndQue (
|
|||
//
|
||||
if (CopyLen != 0) {
|
||||
Data = NetbufAllocSpace (Nbuf, CopyLen, NET_BUF_TAIL);
|
||||
ASSERT (Data);
|
||||
ASSERT (Data != NULL);
|
||||
|
||||
if ((INT32) NetbufCopy (Node, Offset, CopyLen, Data) != CopyLen) {
|
||||
goto OnError;
|
||||
|
@ -572,7 +571,7 @@ TcpGetSegmentSock (
|
|||
UINT8 *Data;
|
||||
UINT32 DataGet;
|
||||
|
||||
ASSERT (Tcb && Tcb->Sk);
|
||||
ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
|
||||
|
||||
Nbuf = NetbufAlloc (Len + TCP_MAX_HEAD);
|
||||
|
||||
|
@ -592,7 +591,7 @@ TcpGetSegmentSock (
|
|||
// copy data to the segment.
|
||||
//
|
||||
Data = NetbufAllocSpace (Nbuf, Len, NET_BUF_TAIL);
|
||||
ASSERT (Data);
|
||||
ASSERT (Data != NULL);
|
||||
|
||||
DataGet = SockGetDataToSend (Tcb->Sk, 0, Len, Data);
|
||||
}
|
||||
|
@ -633,7 +632,7 @@ TcpGetSegment (
|
|||
{
|
||||
NET_BUF *Nbuf;
|
||||
|
||||
ASSERT (Tcb);
|
||||
ASSERT (Tcb != NULL);
|
||||
|
||||
//
|
||||
// Compare the SndNxt with the max sequence number sent.
|
||||
|
@ -646,7 +645,7 @@ TcpGetSegment (
|
|||
Nbuf = TcpGetSegmentSock (Tcb, Seq, Len);
|
||||
}
|
||||
|
||||
ASSERT (TcpVerifySegment (Nbuf));
|
||||
ASSERT (TcpVerifySegment (Nbuf) != 0);
|
||||
return Nbuf;
|
||||
}
|
||||
|
||||
|
@ -692,7 +691,7 @@ TcpRetransmit (
|
|||
return -1;
|
||||
}
|
||||
|
||||
ASSERT (TcpVerifySegment (Nbuf));
|
||||
ASSERT (TcpVerifySegment (Nbuf) != 0);
|
||||
|
||||
if (TcpTransmitSegment (Tcb, Nbuf) != 0) {
|
||||
goto OnError;
|
||||
|
@ -703,7 +702,7 @@ TcpRetransmit (
|
|||
// trim TCP head because all the buffer on SndQue
|
||||
// are headless.
|
||||
//
|
||||
ASSERT (Nbuf->Tcp);
|
||||
ASSERT (Nbuf->Tcp != NULL);
|
||||
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);
|
||||
Nbuf->Tcp = NULL;
|
||||
|
||||
|
@ -743,7 +742,7 @@ TcpToSendData (
|
|||
TCP_SEQNO Seq;
|
||||
TCP_SEQNO End;
|
||||
|
||||
ASSERT (Tcb && Tcb->Sk && (Tcb->State != TCP_LISTEN));
|
||||
ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL) && (Tcb->State != TCP_LISTEN));
|
||||
|
||||
Sent = 0;
|
||||
|
||||
|
@ -807,8 +806,7 @@ SEND_AGAIN:
|
|||
//
|
||||
if ((TcpGetMaxSndNxt (Tcb) == Tcb->SndNxt) &&
|
||||
(GET_SND_DATASIZE (Tcb->Sk) == 0) &&
|
||||
TCP_SEQ_LT (End + 1, Tcb->SndWnd + Tcb->SndWl2)
|
||||
) {
|
||||
TCP_SEQ_LT (End + 1, Tcb->SndWnd + Tcb->SndWl2)) {
|
||||
|
||||
DEBUG ((EFI_D_INFO, "TcpToSendData: send FIN "
|
||||
"to peer for TCB %p in state %d\n", Tcb, Tcb->State));
|
||||
|
@ -823,8 +821,8 @@ SEND_AGAIN:
|
|||
Seg->End = End;
|
||||
Seg->Flag = Flag;
|
||||
|
||||
ASSERT (TcpVerifySegment (Nbuf));
|
||||
ASSERT (TcpCheckSndQue (&Tcb->SndQue));
|
||||
ASSERT (TcpVerifySegment (Nbuf) != 0);
|
||||
ASSERT (TcpCheckSndQue (&Tcb->SndQue) != 0);
|
||||
|
||||
//
|
||||
// don't send an empty segment here.
|
||||
|
@ -856,7 +854,7 @@ SEND_AGAIN:
|
|||
//
|
||||
// All the buffer in the SndQue is headless
|
||||
//
|
||||
ASSERT (Nbuf->Tcp);
|
||||
ASSERT (Nbuf->Tcp != NULL);
|
||||
|
||||
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);
|
||||
Nbuf->Tcp = NULL;
|
||||
|
@ -915,8 +913,6 @@ OnError:
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpSendAck (
|
||||
|
@ -949,8 +945,7 @@ TcpSendAck (
|
|||
|
||||
|
||||
/**
|
||||
Send a zero probe segment. It can be used by keepalive
|
||||
and zero window probe.
|
||||
Send a zero probe segment. It can be used by keepalive and zero window probe.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
|
@ -996,8 +991,6 @@ TcpSendZeroProbe (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpToSendAck (
|
||||
|
@ -1015,8 +1008,7 @@ TcpToSendAck (
|
|||
//
|
||||
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) ||
|
||||
(Tcb->DelayedAck >= 1) ||
|
||||
(TcpNow > TcpRcvWinOld (Tcb))
|
||||
) {
|
||||
(TcpNow > TcpRcvWinOld (Tcb))) {
|
||||
TcpSendAck (Tcb);
|
||||
return;
|
||||
}
|
||||
|
@ -1060,7 +1052,7 @@ TcpSendReset (
|
|||
//
|
||||
// Don't respond to a Reset with reset
|
||||
//
|
||||
if (Head->Flag & TCP_FLG_RST) {
|
||||
if ((Head->Flag & TCP_FLG_RST) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,31 +24,67 @@ Abstract:
|
|||
|
||||
UINT32 mTcpTick = 1000;
|
||||
|
||||
/**
|
||||
Connect timeout handler.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpConnectTimeout (
|
||||
IN TCP_CB *Tcb
|
||||
);
|
||||
|
||||
/**
|
||||
Timeout handler for TCP retransmission timer.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpRexmitTimeout (
|
||||
IN TCP_CB *Tcb
|
||||
);
|
||||
|
||||
/**
|
||||
Timeout handler for window probe timer.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpProbeTimeout (
|
||||
IN TCP_CB *Tcb
|
||||
);
|
||||
|
||||
/**
|
||||
Timeout handler for keepalive timer.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpKeepaliveTimeout (
|
||||
IN TCP_CB *Tcb
|
||||
);
|
||||
|
||||
/**
|
||||
Timeout handler for FIN_WAIT_2 timer.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpFinwait2Timeout (
|
||||
IN TCP_CB *Tcb
|
||||
);
|
||||
|
||||
/**
|
||||
Timeout handler for 2MSL timer.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Tcp2MSLTimeout (
|
||||
IN TCP_CB *Tcb
|
||||
|
@ -63,14 +99,11 @@ TCP_TIMER_HANDLER mTcpTimerHandler[TCP_TIMER_NUMBER] = {
|
|||
Tcp2MSLTimeout,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Close the TCP connection.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpClose (
|
||||
|
@ -89,8 +122,6 @@ TcpClose (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpConnectTimeout (
|
||||
|
@ -123,8 +154,6 @@ TcpConnectTimeout (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpRexmitTimeout (
|
||||
|
@ -148,7 +177,7 @@ TcpRexmitTimeout (
|
|||
Tcb->LossRecover = Tcb->SndNxt;
|
||||
|
||||
Tcb->LossTimes++;
|
||||
if (Tcb->LossTimes > Tcb->MaxRexmit &&
|
||||
if ((Tcb->LossTimes > Tcb->MaxRexmit) &&
|
||||
!TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_CONNECT)) {
|
||||
|
||||
DEBUG ((EFI_D_ERROR, "TcpRexmitTimeout: connection closed "
|
||||
|
@ -167,7 +196,6 @@ TcpRexmitTimeout (
|
|||
TcpSetTimer (Tcb, TCP_TIMER_REXMIT, Tcb->Rto);
|
||||
|
||||
Tcb->CongestState = TCP_CONGEST_LOSS;
|
||||
|
||||
TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_RTT_ON);
|
||||
}
|
||||
|
||||
|
@ -177,8 +205,6 @@ TcpRexmitTimeout (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpProbeTimeout (
|
||||
|
@ -207,8 +233,6 @@ TcpProbeTimeout (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpKeepaliveTimeout (
|
||||
|
@ -240,8 +264,6 @@ TcpKeepaliveTimeout (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpFinwait2Timeout (
|
||||
|
@ -260,8 +282,6 @@ TcpFinwait2Timeout (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Tcp2MSLTimeout (
|
||||
|
@ -276,14 +296,11 @@ Tcp2MSLTimeout (
|
|||
|
||||
|
||||
/**
|
||||
Update the timer status and the next expire time
|
||||
according to the timers to expire in a specific
|
||||
future time slot.
|
||||
Update the timer status and the next expire time according to the timers
|
||||
to expire in a specific future time slot.
|
||||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpUpdateTimer (
|
||||
|
@ -318,8 +335,6 @@ TcpUpdateTimer (
|
|||
@param Timer The index of the timer to be enabled.
|
||||
@param TimeOut The timeout value of this timer.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpSetTimer (
|
||||
|
@ -341,8 +356,6 @@ TcpSetTimer (
|
|||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
@param Timer The index of the timer to be cleared.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpClearTimer (
|
||||
|
@ -360,8 +373,6 @@ TcpClearTimer (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpClearAllTimer (
|
||||
|
@ -378,8 +389,6 @@ TcpClearAllTimer (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpSetProbeTimer (
|
||||
|
@ -410,8 +419,6 @@ TcpSetProbeTimer (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpSetKeepaliveTimer (
|
||||
|
@ -448,8 +455,6 @@ TcpSetKeepaliveTimer (
|
|||
|
||||
@param Tcb Pointer to the TCP_CB of this TCP instance.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
TcpBackoffRto (
|
||||
|
@ -483,8 +488,6 @@ TcpBackoffRto (
|
|||
|
||||
@param Context Context of the timer event, ignored.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
|
@ -572,8 +575,6 @@ NextConnection:
|
|||
@param Event Timer event signaled, ignored.
|
||||
@param Context Context of the timer event, ignored.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
|
|
Loading…
Reference in New Issue