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:
niry 2008-12-05 23:47:55 +00:00
parent 4e2dd553a6
commit 120db52c6d
12 changed files with 329 additions and 367 deletions

View File

@ -20,6 +20,19 @@ Abstract:
#include "SockImpl.h" #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 UINT32
SockTcpDataToRcv ( SockTcpDataToRcv (
IN SOCK_BUFFER *SockBuffer, IN SOCK_BUFFER *SockBuffer,
@ -27,11 +40,21 @@ SockTcpDataToRcv (
IN UINT32 BufLen IN UINT32 BufLen
); );
/**
Process the send token.
@param Sock Pointer to the socket.
**/
VOID VOID
SockProcessSndToken ( SockProcessSndToken (
IN SOCKET *Sock IN SOCKET *Sock
); );
/**
**/
VOID VOID
SockFreeFoo ( SockFreeFoo (
IN EFI_EVENT Event IN EFI_EVENT Event
@ -66,10 +89,10 @@ SockTcpDataToRcv (
TCP_RSV_DATA *TcpRsvData; TCP_RSV_DATA *TcpRsvData;
BOOLEAN Urg; BOOLEAN Urg;
ASSERT (SockBuffer && IsUrg && (BufLen > 0)); ASSERT ((SockBuffer != NULL) && (IsUrg != NULL) && (BufLen > 0));
RcvBufEntry = SockBufFirst (SockBuffer); RcvBufEntry = SockBufFirst (SockBuffer);
ASSERT (RcvBufEntry); ASSERT (RcvBufEntry != NULL);
TcpRsvData = (TCP_RSV_DATA *) RcvBufEntry->ProtoData; TcpRsvData = (TCP_RSV_DATA *) RcvBufEntry->ProtoData;
@ -133,8 +156,6 @@ SockTcpDataToRcv (
@param RcvdBytes The maximum length of the data can be copied. @param RcvdBytes The maximum length of the data can be copied.
@param IsOOB If TURE the data is OOB, else the data is normal. @param IsOOB If TURE the data is OOB, else the data is normal.
@return None.
**/ **/
VOID VOID
SockSetTcpRxData ( SockSetTcpRxData (
@ -197,7 +218,7 @@ SockProcessRcvToken (
EFI_TCP4_RECEIVE_DATA *RxData; EFI_TCP4_RECEIVE_DATA *RxData;
BOOLEAN IsUrg; BOOLEAN IsUrg;
ASSERT (Sock); ASSERT (Sock != NULL);
ASSERT (SOCK_STREAM == Sock->Type); ASSERT (SOCK_STREAM == Sock->Type);
@ -306,8 +327,6 @@ SockProcessTcpSndData (
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@param PendingTokenList Pointer to the token list to be flushed. @param PendingTokenList Pointer to the token list to be flushed.
@return None.
**/ **/
VOID VOID
SockFlushPendingToken ( SockFlushPendingToken (
@ -318,7 +337,7 @@ SockFlushPendingToken (
SOCK_TOKEN *SockToken; SOCK_TOKEN *SockToken;
SOCK_COMPLETION_TOKEN *Token; SOCK_COMPLETION_TOKEN *Token;
ASSERT (Sock && PendingTokenList); ASSERT ((Sock != NULL) && (PendingTokenList != NULL));
while (!IsListEmpty (PendingTokenList)) { while (!IsListEmpty (PendingTokenList)) {
SockToken = NET_LIST_HEAD ( SockToken = NET_LIST_HEAD (
@ -337,14 +356,11 @@ SockFlushPendingToken (
/** /**
Wake up the connection token while the connection is Wake up the connection token while the connection is successfully established,
successfully established, then try to process any then try to process any pending send token.
pending send token.
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@return None.
**/ **/
VOID VOID
SockWakeConnToken ( SockWakeConnToken (
@ -365,13 +381,10 @@ SockWakeConnToken (
/** /**
Wake up the listen token while the connection is Wake up the listen token while the connection is established successfully.
established successfully.
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@return None.
**/ **/
VOID VOID
SockWakeListenToken ( SockWakeListenToken (
@ -384,7 +397,7 @@ SockWakeListenToken (
Parent = Sock->Parent; 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)) { if (!IsListEmpty (&Parent->ListenTokenList)) {
SockToken = NET_LIST_HEAD ( SockToken = NET_LIST_HEAD (
@ -416,8 +429,6 @@ SockWakeListenToken (
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@return None.
**/ **/
VOID VOID
SockWakeRcvToken ( SockWakeRcvToken (
@ -429,7 +440,7 @@ SockWakeRcvToken (
SOCK_TOKEN *SockToken; SOCK_TOKEN *SockToken;
SOCK_IO_TOKEN *RcvToken; SOCK_IO_TOKEN *RcvToken;
ASSERT (Sock->RcvBuffer.DataQueue); ASSERT (Sock->RcvBuffer.DataQueue != NULL);
RcvdBytes = (Sock->RcvBuffer.DataQueue)->BufSize; RcvdBytes = (Sock->RcvBuffer.DataQueue)->BufSize;
@ -462,8 +473,6 @@ SockWakeRcvToken (
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@return None.
**/ **/
VOID VOID
SockProcessSndToken ( SockProcessSndToken (
@ -477,7 +486,7 @@ SockProcessSndToken (
EFI_TCP4_TRANSMIT_DATA *TxData; EFI_TCP4_TRANSMIT_DATA *TxData;
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (Sock && (SOCK_STREAM == Sock->Type)); ASSERT ((Sock != NULL) && (SOCK_STREAM == Sock->Type));
FreeSpace = SockGetFreeSpace (Sock, SOCK_SND_BUF); FreeSpace = SockGetFreeSpace (Sock, SOCK_SND_BUF);
@ -552,9 +561,9 @@ SockCreate (
SOCKET *Parent; SOCKET *Parent;
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (SockInitData && SockInitData->ProtoHandler); ASSERT ((SockInitData != NULL) && (SockInitData->ProtoHandler != NULL));
ASSERT (SockInitData->Type == SOCK_STREAM); 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; Parent = SockInitData->Parent;
@ -706,8 +715,6 @@ OnError:
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@return None.
**/ **/
VOID VOID
SockDestroy ( SockDestroy (
@ -807,8 +814,6 @@ FreeSock:
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@return None.
**/ **/
VOID VOID
SockConnFlush ( SockConnFlush (
@ -817,7 +822,7 @@ SockConnFlush (
{ {
SOCKET *Child; SOCKET *Child;
ASSERT (Sock); ASSERT (Sock != NULL);
// //
// Clear the flag in this socket // Clear the flag in this socket
@ -875,8 +880,6 @@ SockConnFlush (
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@param State The new state to be set. @param State The new state to be set.
@return None.
**/ **/
VOID VOID
SockSetState ( SockSetState (
@ -893,8 +896,7 @@ SockSetState (
@param Sock Pointer to the socket to be cloned. @param Sock Pointer to the socket to be cloned.
@retval * Pointer to the newly cloned socket. If NULL, error @return Pointer to the newly cloned socket. If NULL, error condition occurred.
condition occurred.
**/ **/
SOCKET * SOCKET *
@ -935,16 +937,12 @@ SockClone (
/** /**
Called by the low layer protocol to indicate the socket Called by the low layer protocol to indicate the socket a connection is
a connection is established. This function just changes established. This function just changes the socket's state to SO_CONNECTED
the socket's state to SO_CONNECTED and signals the token and signals the token used for connection establishment.
used for connection establishment.
@param Sock Pointer to the socket associated with the @param Sock Pointer to the socket associated with the
established connection. established connection.
@return None.
**/ **/
VOID VOID
SockConnEstablished ( SockConnEstablished (
@ -967,15 +965,12 @@ SockConnEstablished (
/** /**
Called by the low layer protocol to indicate the connection Called by the low layer protocol to indicate the connection is closed; This
is closed. This function flushes the socket, sets the state function flushes the socket, sets the state to SO_CLOSED and signals the close
to SO_CLOSED and signals the close token. token.
@param Sock Pointer to the socket associated with the closed @param Sock Pointer to the socket associated with the closed
connection. connection.
@return None.
**/ **/
VOID VOID
SockConnClosed ( SockConnClosed (
@ -998,16 +993,13 @@ SockConnClosed (
/** /**
Called by low layer protocol to indicate that some Called by low layer protocol to indicate that some data is sent or processed;
data is sent or processed. This function trims the This function trims the sent data in the socket send buffer, signals the data
sent data in the socket send buffer, signals the token if proper.
data token if proper
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@param Count The length of the data processed or sent, in bytes. @param Count The length of the data processed or sent, in bytes.
@return None.
**/ **/
VOID VOID
SockDataSent ( SockDataSent (
@ -1078,7 +1070,7 @@ SockGetDataToSend (
IN UINT8 *Dest IN UINT8 *Dest
) )
{ {
ASSERT (Sock && SOCK_STREAM == Sock->Type); ASSERT ((Sock != NULL) && SOCK_STREAM == Sock->Type);
return NetbufQueCopy ( return NetbufQueCopy (
Sock->SndBuffer.DataQueue, Sock->SndBuffer.DataQueue,
@ -1090,18 +1082,15 @@ SockGetDataToSend (
/** /**
Called by the low layer protocol to deliver received data Called by the low layer protocol to deliver received data to socket layer;
to socket layer. This function will append the data to the This function will append the data to the socket receive buffer, set ther
socket receive buffer, set ther urgent data length and then urgent data length and then check if any receive token can be signaled.
check if any receive token can be signaled.
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@param NetBuffer Pointer to the buffer that contains the received @param NetBuffer Pointer to the buffer that contains the received
data. data.
@param UrgLen The length of the urgent data in the received data. @param UrgLen The length of the urgent data in the received data.
@return None.
**/ **/
VOID VOID
SockDataRcvd ( SockDataRcvd (
@ -1110,7 +1099,7 @@ SockDataRcvd (
IN UINT32 UrgLen IN UINT32 UrgLen
) )
{ {
ASSERT (Sock && Sock->RcvBuffer.DataQueue && ASSERT ((Sock != NULL) && (Sock->RcvBuffer.DataQueue != NULL) &&
UrgLen <= NetBuffer->TotalSize); UrgLen <= NetBuffer->TotalSize);
NET_GET_REF (NetBuffer); NET_GET_REF (NetBuffer);
@ -1143,7 +1132,7 @@ SockGetFreeSpace (
UINT32 BufferCC; UINT32 BufferCC;
SOCK_BUFFER *SockBuffer; 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) { if (SOCK_SND_BUF == Which) {
SockBuffer = &(Sock->SndBuffer); SockBuffer = &(Sock->SndBuffer);
@ -1169,8 +1158,6 @@ SockGetFreeSpace (
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@param Error The error code received. @param Error The error code received.
@return None.
**/ **/
VOID VOID
SockRcvdErr ( SockRcvdErr (
@ -1202,15 +1189,13 @@ SockRcvdErr (
/** /**
Called by the low layer protocol to indicate that there 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 function set the socket's state to SO_NO_MORE_DATA and
signal all queued IO tokens with the error status signal all queued IO tokens with the error status
EFI_CONNECTION_FIN. EFI_CONNECTION_FIN.
@param Sock Pointer to the socket. @param Sock Pointer to the socket.
@return None.
**/ **/
VOID VOID
SockNoMoreData ( SockNoMoreData (
@ -1270,7 +1255,8 @@ SockBufFirst (
@param SockEntry Pointer to the buffer block prior to the required @param SockEntry Pointer to the buffer block prior to the required
one. 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 * NET_BUF *
@ -1285,8 +1271,7 @@ SockBufNext (
if ((SockEntry->List.ForwardLink == NetbufList) || if ((SockEntry->List.ForwardLink == NetbufList) ||
(SockEntry->List.BackLink == &SockEntry->List) || (SockEntry->List.BackLink == &SockEntry->List) ||
(SockEntry->List.ForwardLink == &SockEntry->List) (SockEntry->List.ForwardLink == &SockEntry->List)) {
) {
return NULL; return NULL;
} }

View File

@ -28,8 +28,8 @@ Abstract:
@param List Pointer to the token list to be searched. @param List Pointer to the token list to be searched.
@param Event The event to be checked. @param Event The event to be checked.
@retval BOOLEAN If TRUE, the specific Event exists in the List. If @retval TRUE The specific Event exists in the List.
FALSE, the specific Event is not in the List. @retval False The specific Event is not in the List.
**/ **/
BOOLEAN BOOLEAN
@ -77,8 +77,7 @@ SockTokenExisted (
if (SockTokenExistedInList (&Sock->SndTokenList, Event) || if (SockTokenExistedInList (&Sock->SndTokenList, Event) ||
SockTokenExistedInList (&Sock->ProcessingSndTokenList, Event) || SockTokenExistedInList (&Sock->ProcessingSndTokenList, Event) ||
SockTokenExistedInList (&Sock->RcvTokenList, Event) || SockTokenExistedInList (&Sock->RcvTokenList, Event) ||
SockTokenExistedInList (&Sock->ListenTokenList, Event) SockTokenExistedInList (&Sock->ListenTokenList, Event)) {
) {
return TRUE; return TRUE;
} }
@ -152,7 +151,7 @@ SockDestroyChild (
{ {
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (Sock && Sock->ProtoHandler); ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL));
if (Sock->IsDestroyed) { if (Sock->IsDestroyed) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -258,8 +257,7 @@ SockCreateChild (
/** /**
Configure the specific socket Sock using configuration data Configure the specific socket Sock using configuration data ConfigData.
ConfigData.
@param Sock Pointer to the socket to be configured. @param Sock Pointer to the socket to be configured.
@param ConfigData Pointer to the configuration data. @param ConfigData Pointer to the configuration data.
@ -455,7 +453,7 @@ SockAccept (
RemoveEntryList (ListEntry); RemoveEntryList (ListEntry);
ASSERT (Socket->Parent); ASSERT (Socket->Parent != NULL);
Socket->Parent->ConnCnt--; Socket->Parent->ConnCnt--;

View File

@ -23,42 +23,33 @@ Abstract:
#define TCP_COMP_VAL(Min, Max, Default, Val) \ #define TCP_COMP_VAL(Min, Max, Default, Val) \
((((Val) <= (Max)) && ((Val) >= (Min))) ? (Val) : (Default)) ((((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 EFI_STATUS
Tcp4Route ( Tcp4Route (
IN TCP_CB *Tcb, IN TCP_CB *Tcb,
IN TCP4_ROUTE_INFO *RouteInfo 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; EFI_IP4_PROTOCOL *Ip;
Ip = Tcb->IpInfo->Ip; Ip = Tcb->IpInfo->Ip;
ASSERT (Ip); ASSERT (Ip != NULL);
return Ip->Routes ( return Ip->Routes (
Ip, Ip,
@ -147,7 +138,7 @@ Tcp4GetMode (
} }
Ip = Tcb->IpInfo->Ip; Ip = Tcb->IpInfo->Ip;
ASSERT (Ip); ASSERT (Ip != NULL);
return Ip->GetModeData (Ip, Mode->Ip4ModeData, Mode->MnpConfigData, Mode->SnpModeData); 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. @param Tcb Pointer to the TCP_CB to be flushed.
None
**/ **/
VOID VOID
Tcp4FlushPcb ( Tcp4FlushPcb (
@ -260,6 +249,15 @@ Tcp4FlushPcb (
NetbufFreeList (&Tcb->RcvQue); 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 EFI_STATUS
Tcp4AttachPcb ( Tcp4AttachPcb (
IN SOCKET *Sk IN SOCKET *Sk
@ -302,6 +300,12 @@ Tcp4AttachPcb (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/**
Detach the Tcb of the socket.
@param Sk Pointer to the socket of this TCP instance.
**/
VOID VOID
Tcp4DetachPcb ( Tcp4DetachPcb (
IN SOCKET *Sk IN SOCKET *Sk
@ -349,7 +353,7 @@ Tcp4ConfigurePcb (
TCP4_PROTO_DATA *TcpProto; TCP4_PROTO_DATA *TcpProto;
TCP_CB *Tcb; TCP_CB *Tcb;
ASSERT (CfgData && Sk && Sk->SockHandle); ASSERT ((CfgData != NULL) && (Sk != NULL) && (Sk->SockHandle != NULL));
TcpProto = (TCP4_PROTO_DATA *) Sk->ProtoReserved; TcpProto = (TCP4_PROTO_DATA *) Sk->ProtoReserved;
Tcb = TcpProto->TcpPcb; Tcb = TcpProto->TcpPcb;
@ -617,13 +621,13 @@ Tcp4Dispatcher (
// notify TCP using this message to give it a chance to send out // notify TCP using this message to give it a chance to send out
// window update information // window update information
// //
ASSERT (Tcb); ASSERT (Tcb != NULL);
TcpOnAppConsume (Tcb); TcpOnAppConsume (Tcb);
break; break;
case SOCK_SND: case SOCK_SND:
ASSERT (Tcb); ASSERT (Tcb != NULL);
TcpOnAppSend (Tcb); TcpOnAppSend (Tcb);
break; break;
@ -686,7 +690,7 @@ Tcp4Dispatcher (
case SOCK_MODE: case SOCK_MODE:
ASSERT (Data && Tcb); ASSERT ((Data != NULL) && (Tcb != NULL));
return Tcp4GetMode (Tcb, (TCP4_MODE_DATA *) Data); return Tcp4GetMode (Tcb, (TCP4_MODE_DATA *) Data);
@ -694,7 +698,7 @@ Tcp4Dispatcher (
case SOCK_ROUTE: case SOCK_ROUTE:
ASSERT (Data && Tcb); ASSERT ((Data != NULL) && (Tcb != NULL));
return Tcp4Route (Tcb, (TCP4_ROUTE_INFO *) Data); return Tcp4Route (Tcb, (TCP4_ROUTE_INFO *) Data);

View File

@ -78,8 +78,6 @@ EFI_SERVICE_BINDING_PROTOCOL mTcp4ServiceBinding = {
/** /**
Create and start the heartbeat timer for TCP driver. Create and start the heartbeat timer for TCP driver.
None.
@retval EFI_SUCCESS The timer is successfully created and started. @retval EFI_SUCCESS The timer is successfully created and started.
@retval other The timer is not created. @retval other The timer is not created.
@ -124,13 +122,11 @@ Tcp4CreateTimer (
/** /**
Stop and destroy the heartbeat timer for TCP driver. Stop and destroy the heartbeat timer for TCP driver.
None
None
**/ **/
VOID VOID
Tcp4DestroyTimer () Tcp4DestroyTimer (
VOID
)
{ {
ASSERT (mTcp4Timer.RefCnt > 0); ASSERT (mTcp4Timer.RefCnt > 0);
@ -146,8 +142,7 @@ Tcp4DestroyTimer ()
} }
/** /**
The entry point for Tcp4 driver. The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
Used to install Tcp4 driver on the ImageHandle.
@param ImageHandle The firmware allocated handle for this @param ImageHandle The firmware allocated handle for this
driver image. driver image.
@ -464,6 +459,17 @@ Tcp4DriverBindingStop (
return Status; 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 EFI_STATUS
Tcp4CreateSocketCallback ( Tcp4CreateSocketCallback (
IN SOCKET *This, IN SOCKET *This,
@ -519,6 +525,13 @@ Tcp4CreateSocketCallback (
return Status; 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 VOID
Tcp4DestroySocketCallback ( Tcp4DestroySocketCallback (
IN SOCKET *This, IN SOCKET *This,

View File

@ -24,13 +24,13 @@ Abstract:
/** /**
Check whether the sequence number of the incoming segment Check whether the sequence number of the incoming segment is acceptable.
is acceptable.
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Seg Pointer to the incoming segment. @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 INTN
@ -50,8 +50,6 @@ TcpSeqAcceptable (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Seg Segment that triggers the fast recovery. @param Seg Segment that triggers the fast recovery.
@return None.
**/ **/
VOID VOID
TcpFastRecover ( TcpFastRecover (
@ -162,8 +160,6 @@ TcpFastRecover (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Seg Segment that triggers the fast loss recovery. @param Seg Segment that triggers the fast loss recovery.
@return None.
**/ **/
VOID VOID
TcpFastLossRecover ( 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 Tcb Pointer to the TCP_CB of this TCP instance.
@param Measure Currently measured RTT in heart beats. @param Measure Currently measured RTT in heart beats.
@return None.
**/ **/
VOID VOID
TcpComputeRtt ( TcpComputeRtt (
@ -264,14 +258,13 @@ TcpComputeRtt (
/** /**
Trim the data, SYN and FIN to fit into the window defined by Trim the data, SYN and FIN to fit into the window defined by Left and Right.
Left and Right.
@param Nbuf Buffer that contains received TCP segment without IP header. @param Nbuf Buffer that contains received TCP segment without IP header.
@param Left The sequence number of the window's left edge. @param Left The sequence number of the window's left edge.
@param Right The sequence number of the window's right 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 INTN
@ -351,7 +344,7 @@ TcpTrimSegment (
} }
} }
ASSERT (TcpVerifySegment (Nbuf)); ASSERT (TcpVerifySegment (Nbuf) != 0);
return 0; return 0;
} }
@ -362,7 +355,7 @@ TcpTrimSegment (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Nbuf Pointer to the NET_BUF containing the received tcp segment. @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 INTN
@ -397,7 +390,7 @@ TcpDeliverData (
TCP_SEG *Seg; TCP_SEG *Seg;
UINT32 Urgent; UINT32 Urgent;
ASSERT (Tcb && Tcb->Sk); ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
// //
// make sure there is some data queued, // make sure there is some data queued,
@ -418,7 +411,7 @@ TcpDeliverData (
Nbuf = NET_LIST_USER_STRUCT (Entry, NET_BUF, List); Nbuf = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
Seg = TCPSEG_NETBUF (Nbuf); Seg = TCPSEG_NETBUF (Nbuf);
ASSERT (TcpVerifySegment (Nbuf)); ASSERT (TcpVerifySegment (Nbuf) != 0);
ASSERT (Nbuf->Tcp == NULL); ASSERT (Nbuf->Tcp == NULL);
if (TCP_SEQ_GT (Seg->Seq, Seq)) { if (TCP_SEQ_GT (Seg->Seq, Seq)) {
@ -547,8 +540,6 @@ TcpDeliverData (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Nbuf Pointer to the buffer containing the data to be queued. @param Nbuf Pointer to the buffer containing the data to be queued.
@return None.
**/ **/
VOID VOID
TcpQueueData ( TcpQueueData (
@ -562,7 +553,7 @@ TcpQueueData (
LIST_ENTRY *Cur; LIST_ENTRY *Cur;
NET_BUF *Node; NET_BUF *Node;
ASSERT (Tcb && Nbuf && (Nbuf->Tcp == NULL)); ASSERT ((Tcb != NULL) && (Nbuf != NULL) && (Nbuf->Tcp == NULL));
NET_GET_REF (Nbuf); NET_GET_REF (Nbuf);
@ -655,8 +646,6 @@ TcpQueueData (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Ack The acknowledge seuqence number of the received segment. @param Ack The acknowledge seuqence number of the received segment.
@return None.
**/ **/
VOID VOID
TcpAdjustSndQue ( TcpAdjustSndQue (
@ -991,8 +980,7 @@ TcpInput (
} else if ((Tcb->State == TCP_ESTABLISHED) || } else if ((Tcb->State == TCP_ESTABLISHED) ||
(Tcb->State == TCP_FIN_WAIT_1) || (Tcb->State == TCP_FIN_WAIT_1) ||
(Tcb->State == TCP_FIN_WAIT_2) || (Tcb->State == TCP_FIN_WAIT_2) ||
(Tcb->State == TCP_CLOSE_WAIT) (Tcb->State == TCP_CLOSE_WAIT)) {
) {
SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET); SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);
@ -1162,7 +1150,7 @@ TcpInput (
Tcb->SndUna = Seg->Ack; Tcb->SndUna = Seg->Ack;
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_SND_URG) && 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); TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_SND_URG);
} }
@ -1390,7 +1378,7 @@ RESET_THEN_DROP:
TcpSendReset (Tcb, Head, Len, Dst, Src); TcpSendReset (Tcb, Head, Len, Dst, Src);
DROP_CONNECTION: DROP_CONNECTION:
ASSERT (Tcb && Tcb->Sk); ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
NetbufFree (Nbuf); NetbufFree (Nbuf);
TcpClose (Tcb); TcpClose (Tcb);
@ -1411,7 +1399,7 @@ DISCARD:
if ((Parent != NULL) && (Tcb != NULL)) { if ((Parent != NULL) && (Tcb != NULL)) {
ASSERT (Tcb->Sk); ASSERT (Tcb->Sk != NULL);
TcpClose (Tcb); TcpClose (Tcb);
} }
@ -1428,8 +1416,6 @@ DISCARD:
@param Src Source address of the ICMP error message. @param Src Source address of the ICMP error message.
@param Dst Destination address of the ICMP error message. @param Dst Destination address of the ICMP error message.
@return None.
**/ **/
VOID VOID
TcpIcmpInput ( TcpIcmpInput (

View File

@ -221,9 +221,9 @@ Tcp4Configure (
/** /**
Add or delete routing entries. 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 instances routing table.
The most specific route is selected by comparing the SubnetAddress with the The most specific route is selected by comparing the SubnetAddress with the
destination IP address¡¯s arithmetical AND to the SubnetMask. destination IP addresss arithmetical AND to the SubnetMask.
The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0. 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. 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 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 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. 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 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_PROTOCOLs routing table.
The copy will be updated automatically whenever the IP driver reconfigures its 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 instances local copy
will be lost. The priority of checking the route table is specific with IP will be lost. The priority of checking the route table is specific with IP
implementation and every IP implementation must comply with RFC 1122. 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 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 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 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 instances configuration and is
ready for use upon return. The instance is in the Tcp4StateEstablished state. ready for use upon return. The instance is in the Tcp4StateEstablished state.
The ListenToken->CompletionToken.Event will be signaled when a new connection The ListenToken->CompletionToken.Event will be signaled when a new connection
is accepted, user aborts the listen or connection is reset. This function only 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 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 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 @param Token Pointer to the completion token to queue to the
transmit queue 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 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
configured. configured.
@retval EFI_NO_MAPPING When using a default address, configuration @retval EFI_NO_MAPPING When using a default address, configuration
(DHCP, BOOTP, RARP, etc.) is not finished yet. (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: @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
* A transmit completion token with the same * A transmit completion token with the same
Token-> CompletionToken.Event was already in the Token-> CompletionToken.Event was already in the
@ -481,7 +481,7 @@ Tcp4Transmit (
@param Token Pointer to a token that is associated with the @param Token Pointer to a token that is associated with the
receive data descriptor. 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 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
configured. configured.
@retval EFI_NO_MAPPING When using a default address, configuration @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 asynchronous operation is signaled and any buffers used for TCP network traffic
is flushed. 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 @param CloseToken Pointer to the close token to return when
operation finishes. 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 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
configured. configured.
@retval EFI_ACCESS_DENIED One or more of the following are TRUE: @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. set to NULL and this function has not returned.
* Previous Close() call on this instance has not * Previous Close() call on this instance has not
finished. 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 @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 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above
category error. category error.
@ -606,6 +606,7 @@ Tcp4Close (
is not in one of the queues, which usually means that the asynchronous operation 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 has completed, EFI_NOT_FOUND is returned. If Token is NULL all asynchronous token
issued by Connect(), Accept(), Transmit() and Receive()will be aborted. 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 This Pointer to the EFI_TCP4_PROTOCOL instance.
@param Token Pointer to a token that has been issued by @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 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
is signaled. is signaled.
@retval EFI_INVALID_PARAMETER This is NULL. @retval EFI_INVALID_PARAMETER This is NULL.
@retval EFI_NOT_STARTED This instance hasn¡¯t been configured. @retval EFI_NOT_STARTED This instance hasnt been configured.
@retval EFI_NO_MAPPING When using the default address, configuration @retval EFI_NO_MAPPING When using the default address, configuration
(DHCP, BOOTP,RARP, etc.) hasn¡¯t finished yet. (DHCP, BOOTP,RARP, etc.) hasnt finished yet.
@retval EFI_NOT_FOUND The asynchronous I/O request isn¡¯t found in the @retval EFI_NOT_FOUND The asynchronous I/O request isnt found in the
transmission or receive queue. It has either transmission or receive queue. It has either
completed or wasn¡¯t issued by Transmit() and Receive(). completed or wasnt issued by Transmit() and Receive().
@retval EFI_UNSUPPORTED The operation is not supported in current @retval EFI_UNSUPPORTED The operation is not supported in current
implementation. implementation.

View File

@ -57,8 +57,6 @@ CHAR16 *mTcpStateName[] = {
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None
**/ **/
VOID VOID
TcpInitTcbLocal ( TcpInitTcbLocal (
@ -85,7 +83,7 @@ TcpInitTcbLocal (
Tcb->RcvWnd = GET_RCV_BUFFSIZE (Tcb->Sk); Tcb->RcvWnd = GET_RCV_BUFFSIZE (Tcb->Sk);
// //
// Fisrt window size is never scaled // First window size is never scaled
// //
Tcb->RcvWndScale = 0; Tcb->RcvWndScale = 0;
} }
@ -99,8 +97,6 @@ TcpInitTcbLocal (
intial info. intial info.
@param Opt Pointer to the options announced by the peer. @param Opt Pointer to the options announced by the peer.
@return None
**/ **/
VOID VOID
TcpInitTcbPeer ( TcpInitTcbPeer (
@ -183,7 +179,8 @@ TcpInitTcbPeer (
@param Local Pointer to the local (IP, Port). @param Local Pointer to the local (IP, Port).
@param Remote Pointer to the remote (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 * TCP_CB *
@ -206,8 +203,7 @@ TcpLocateListenTcb (
if ((Local->Port != Node->LocalEnd.Port) || if ((Local->Port != Node->LocalEnd.Port) ||
!TCP_PEER_MATCH (Remote, &Node->RemoteEnd) || !TCP_PEER_MATCH (Remote, &Node->RemoteEnd) ||
!TCP_PEER_MATCH (Local, &Node->LocalEnd) !TCP_PEER_MATCH (Local, &Node->LocalEnd)) {
) {
continue; continue;
} }
@ -369,13 +365,11 @@ TcpInsertTcb (
TCP4_PROTO_DATA *TcpProto; TCP4_PROTO_DATA *TcpProto;
ASSERT ( ASSERT (
Tcb && (Tcb != NULL) &&
( ((Tcb->State == TCP_LISTEN) ||
(Tcb->State == TCP_LISTEN) ||
(Tcb->State == TCP_SYN_SENT) || (Tcb->State == TCP_SYN_SENT) ||
(Tcb->State == TCP_SYN_RCVD) || (Tcb->State == TCP_SYN_RCVD) ||
(Tcb->State == TCP_CLOSED) (Tcb->State == TCP_CLOSED))
)
); );
if (Tcb->LocalEnd.Port == 0) { if (Tcb->LocalEnd.Port == 0) {
@ -459,8 +453,6 @@ TcpCloneTcb (
/** /**
Compute an ISS to be used by a new connection. Compute an ISS to be used by a new connection.
None
@return The result ISS. @return The result ISS.
**/ **/
@ -491,11 +483,11 @@ TcpGetRcvMss (
TCP4_PROTO_DATA *TcpProto; TCP4_PROTO_DATA *TcpProto;
EFI_IP4_PROTOCOL *Ip; EFI_IP4_PROTOCOL *Ip;
ASSERT (Sock); ASSERT (Sock != NULL);
TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved; TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
Ip = TcpProto->TcpService->IpIo->Ip; Ip = TcpProto->TcpService->IpIo->Ip;
ASSERT (Ip); ASSERT (Ip != NULL);
Ip->GetModeData (Ip, NULL, NULL, &SnpMode); Ip->GetModeData (Ip, NULL, NULL, &SnpMode);
@ -509,8 +501,6 @@ TcpGetRcvMss (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param State The state to be set. @param State The state to be set.
@return None
**/ **/
VOID VOID
TcpSetState ( TcpSetState (
@ -639,8 +629,6 @@ TcpFormatNetbuf (
@param Tcb Pointer to the TCP_CB of the connection to be @param Tcb Pointer to the TCP_CB of the connection to be
reset. reset.
@return None
**/ **/
VOID VOID
TcpResetConnection ( 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 @param Tcb Pointer to the TCP_CB that wants to initiate a
connection. connection.
@return None
**/ **/
VOID VOID
TcpOnAppConnect ( TcpOnAppConnect (
@ -712,17 +698,15 @@ TcpOnAppConnect (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpOnAppClose ( TcpOnAppClose (
IN TCP_CB *Tcb 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 " DEBUG ((EFI_D_WARN, "TcpOnAppClose: connection reset "
"because data is lost for TCB %p\n", Tcb)); "because data is lost for TCB %p\n", Tcb));
@ -754,8 +738,7 @@ TcpOnAppClose (
/** /**
Check whether the application's newly delivered data Check whether the application's newly delivered data can be sent out.
can be sent out.
@param Tcb Pointer to the TCP_CB of this TCP instance. @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. @param Tcb Pointer to the TCP_CB of this TCP instance.
**/ **/
INTN INTN
TcpOnAppConsume ( TcpOnAppConsume (
@ -877,8 +859,6 @@ TcpOnAppConsume (
@param Tcb Pointer to the TCP_CB of the TCP instance. @param Tcb Pointer to the TCP_CB of the TCP instance.
@return None.
**/ **/
VOID VOID
TcpOnAppAbort ( TcpOnAppAbort (
@ -905,7 +885,7 @@ TcpOnAppAbort (
/** /**
Set the Tdp4 variable data. 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 EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.
@retval other Set variable failed. @retval other Set variable failed.
@ -1078,9 +1058,7 @@ ON_ERROR:
/** /**
Clear the variable and free the resource. Clear the variable and free the resource.
@param Tcp4Service Tcp4 service data. @param Tcp4Service Pointer to Tcp4 service data.
@return None.
**/ **/
VOID VOID
@ -1102,26 +1080,19 @@ TcpClearVariableData (
Tcp4Service->MacString = NULL; 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 EFI_STATUS
TcpInstallDevicePath ( TcpInstallDevicePath (
IN SOCKET *Sock 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_PROTO_DATA *TcpProto;
TCP4_SERVICE_DATA *TcpService; TCP4_SERVICE_DATA *TcpService;

View File

@ -22,6 +22,14 @@ Abstract:
#include "Tcp4Main.h" #include "Tcp4Main.h"
/**
Get a UINT16 value from buffer.
@param Buf Pointer to input buffer.
@return The UINT16 value get from buffer.
**/
UINT16 UINT16
TcpGetUint16 ( TcpGetUint16 (
IN UINT8 *Buf IN UINT8 *Buf
@ -32,17 +40,14 @@ TcpGetUint16 (
return NTOHS (Value); return NTOHS (Value);
} }
// STATIC /**
// VOID Get a UINT32 value from buffer.
// TcpPutUint16 (
// IN UINT8 *Buf,
// IN UINT16 Data
// )
// {
// Data = HTONS (Data);
// CopyMem (Buf, &Data, sizeof (UINT16));
// }
@param Buf Pointer to input buffer.
@return The UINT32 value get from buffer.
**/
UINT32 UINT32
TcpGetUint32 ( TcpGetUint32 (
IN UINT8 *Buf IN UINT8 *Buf
@ -53,6 +58,13 @@ TcpGetUint32 (
return NTOHL (Value); 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 VOID
TcpPutUint32 ( TcpPutUint32 (
IN UINT8 *Buf, IN UINT8 *Buf,
@ -65,12 +77,11 @@ TcpPutUint32 (
/** /**
Compute the window scale value according to the given Compute the window scale value according to the given buffer size.
buffer size.
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@retval UINT8 The scale value. @return The scale value.
**/ **/
UINT8 UINT8
@ -81,7 +92,7 @@ TcpComputeScale (
UINT8 Scale; UINT8 Scale;
UINT32 BufSize; UINT32 BufSize;
ASSERT (Tcb && Tcb->Sk); ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
BufSize = GET_RCV_BUFFSIZE (Tcb->Sk); BufSize = GET_RCV_BUFFSIZE (Tcb->Sk);
@ -114,7 +125,7 @@ TcpSynBuildOption (
UINT8 *Data; UINT8 *Data;
UINT16 Len; UINT16 Len;
ASSERT (Tcb && Nbuf && !Nbuf->Tcp); ASSERT ((Tcb != NULL) && (Nbuf != NULL) && (Nbuf->Tcp == NULL));
Len = 0; Len = 0;
@ -133,7 +144,7 @@ TcpSynBuildOption (
NET_BUF_HEAD NET_BUF_HEAD
); );
ASSERT (Data); ASSERT (Data != NULL);
Len += TCP_OPTION_TS_ALIGNED_LEN; Len += TCP_OPTION_TS_ALIGNED_LEN;
TcpPutUint32 (Data, TCP_OPTION_TS_FAST); TcpPutUint32 (Data, TCP_OPTION_TS_FAST);
@ -156,7 +167,7 @@ TcpSynBuildOption (
NET_BUF_HEAD NET_BUF_HEAD
); );
ASSERT (Data); ASSERT (Data != NULL);
Len += TCP_OPTION_WS_ALIGNED_LEN; Len += TCP_OPTION_WS_ALIGNED_LEN;
TcpPutUint32 (Data, TCP_OPTION_WS_FAST | TcpComputeScale (Tcb)); TcpPutUint32 (Data, TCP_OPTION_WS_FAST | TcpComputeScale (Tcb));
@ -166,7 +177,7 @@ TcpSynBuildOption (
// Build MSS option // Build MSS option
// //
Data = NetbufAllocSpace (Nbuf, TCP_OPTION_MSS_LEN, 1); Data = NetbufAllocSpace (Nbuf, TCP_OPTION_MSS_LEN, 1);
ASSERT (Data); ASSERT (Data != NULL);
Len += TCP_OPTION_MSS_LEN; Len += TCP_OPTION_MSS_LEN;
TcpPutUint32 (Data, TCP_OPTION_MSS_FAST | Tcb->RcvMss); TcpPutUint32 (Data, TCP_OPTION_MSS_FAST | Tcb->RcvMss);
@ -193,7 +204,7 @@ TcpBuildOption (
UINT8 *Data; UINT8 *Data;
UINT16 Len; UINT16 Len;
ASSERT (Tcb && Nbuf && !Nbuf->Tcp); ASSERT ((Tcb != NULL) && (Nbuf != NULL) && (Nbuf->Tcp == NULL));
Len = 0; Len = 0;
// //
@ -208,7 +219,7 @@ TcpBuildOption (
NET_BUF_HEAD NET_BUF_HEAD
); );
ASSERT (Data); ASSERT (Data != NULL);
Len += TCP_OPTION_TS_ALIGNED_LEN; Len += TCP_OPTION_TS_ALIGNED_LEN;
TcpPutUint32 (Data, TCP_OPTION_TS_FAST); TcpPutUint32 (Data, TCP_OPTION_TS_FAST);
@ -243,7 +254,7 @@ TcpParseOption (
UINT8 Type; UINT8 Type;
UINT8 Len; UINT8 Len;
ASSERT (Tcp && Option); ASSERT ((Tcp != NULL) && (Option != NULL));
Option->Flag = 0; Option->Flag = 0;
@ -333,7 +344,7 @@ TcpParseOption (
default: default:
Len = Head[Cur + 1]; Len = Head[Cur + 1];
if (TotalLen - Cur < Len || Len < 2) { if ((TotalLen - Cur) < Len || Len < 2) {
return -1; return -1;
} }

View File

@ -85,7 +85,7 @@ TcpRcvWinNow (
UINT32 OldWin; UINT32 OldWin;
Sk = Tcb->Sk; Sk = Tcb->Sk;
ASSERT (Sk); ASSERT (Sk != NULL);
OldWin = TcpRcvWinOld (Tcb); OldWin = TcpRcvWinOld (Tcb);
@ -199,7 +199,7 @@ TcpDataToSend (
UINT32 Limit; UINT32 Limit;
Sk = Tcb->Sk; Sk = Tcb->Sk;
ASSERT (Sk); ASSERT (Sk != NULL);
// //
// TCP should NOT send data beyond the send window // 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 Build the TCP header of the TCP segment and transmit the segment by IP.
segment by IP.
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Nbuf Pointer to the buffer containing the segment to be sent out. @param Nbuf Pointer to the buffer containing the segment to be sent out.
@ -306,7 +305,7 @@ TcpTransmitSegment (
BOOLEAN Syn; BOOLEAN Syn;
UINT32 DataLen; UINT32 DataLen;
ASSERT (Nbuf && (Nbuf->Tcp == NULL) && TcpVerifySegment (Nbuf)); ASSERT ((Nbuf != NULL) && (Nbuf->Tcp == NULL) && (TcpVerifySegment (Nbuf) != 0));
DataLen = Nbuf->TotalSize; DataLen = Nbuf->TotalSize;
@ -435,7 +434,7 @@ TcpGetSegmentSndQue (
INT32 Offset; INT32 Offset;
INT32 CopyLen; 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. // Find the segment that contains the Seq.
@ -530,7 +529,7 @@ TcpGetSegmentSndQue (
// //
if (CopyLen != 0) { if (CopyLen != 0) {
Data = NetbufAllocSpace (Nbuf, CopyLen, NET_BUF_TAIL); Data = NetbufAllocSpace (Nbuf, CopyLen, NET_BUF_TAIL);
ASSERT (Data); ASSERT (Data != NULL);
if ((INT32) NetbufCopy (Node, Offset, CopyLen, Data) != CopyLen) { if ((INT32) NetbufCopy (Node, Offset, CopyLen, Data) != CopyLen) {
goto OnError; goto OnError;
@ -572,7 +571,7 @@ TcpGetSegmentSock (
UINT8 *Data; UINT8 *Data;
UINT32 DataGet; UINT32 DataGet;
ASSERT (Tcb && Tcb->Sk); ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL));
Nbuf = NetbufAlloc (Len + TCP_MAX_HEAD); Nbuf = NetbufAlloc (Len + TCP_MAX_HEAD);
@ -592,7 +591,7 @@ TcpGetSegmentSock (
// copy data to the segment. // copy data to the segment.
// //
Data = NetbufAllocSpace (Nbuf, Len, NET_BUF_TAIL); Data = NetbufAllocSpace (Nbuf, Len, NET_BUF_TAIL);
ASSERT (Data); ASSERT (Data != NULL);
DataGet = SockGetDataToSend (Tcb->Sk, 0, Len, Data); DataGet = SockGetDataToSend (Tcb->Sk, 0, Len, Data);
} }
@ -633,7 +632,7 @@ TcpGetSegment (
{ {
NET_BUF *Nbuf; NET_BUF *Nbuf;
ASSERT (Tcb); ASSERT (Tcb != NULL);
// //
// Compare the SndNxt with the max sequence number sent. // Compare the SndNxt with the max sequence number sent.
@ -646,7 +645,7 @@ TcpGetSegment (
Nbuf = TcpGetSegmentSock (Tcb, Seq, Len); Nbuf = TcpGetSegmentSock (Tcb, Seq, Len);
} }
ASSERT (TcpVerifySegment (Nbuf)); ASSERT (TcpVerifySegment (Nbuf) != 0);
return Nbuf; return Nbuf;
} }
@ -692,7 +691,7 @@ TcpRetransmit (
return -1; return -1;
} }
ASSERT (TcpVerifySegment (Nbuf)); ASSERT (TcpVerifySegment (Nbuf) != 0);
if (TcpTransmitSegment (Tcb, Nbuf) != 0) { if (TcpTransmitSegment (Tcb, Nbuf) != 0) {
goto OnError; goto OnError;
@ -703,7 +702,7 @@ TcpRetransmit (
// trim TCP head because all the buffer on SndQue // trim TCP head because all the buffer on SndQue
// are headless. // are headless.
// //
ASSERT (Nbuf->Tcp); ASSERT (Nbuf->Tcp != NULL);
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD); NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);
Nbuf->Tcp = NULL; Nbuf->Tcp = NULL;
@ -743,7 +742,7 @@ TcpToSendData (
TCP_SEQNO Seq; TCP_SEQNO Seq;
TCP_SEQNO End; TCP_SEQNO End;
ASSERT (Tcb && Tcb->Sk && (Tcb->State != TCP_LISTEN)); ASSERT ((Tcb != NULL) && (Tcb->Sk != NULL) && (Tcb->State != TCP_LISTEN));
Sent = 0; Sent = 0;
@ -807,8 +806,7 @@ SEND_AGAIN:
// //
if ((TcpGetMaxSndNxt (Tcb) == Tcb->SndNxt) && if ((TcpGetMaxSndNxt (Tcb) == Tcb->SndNxt) &&
(GET_SND_DATASIZE (Tcb->Sk) == 0) && (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 " DEBUG ((EFI_D_INFO, "TcpToSendData: send FIN "
"to peer for TCB %p in state %d\n", Tcb, Tcb->State)); "to peer for TCB %p in state %d\n", Tcb, Tcb->State));
@ -823,8 +821,8 @@ SEND_AGAIN:
Seg->End = End; Seg->End = End;
Seg->Flag = Flag; Seg->Flag = Flag;
ASSERT (TcpVerifySegment (Nbuf)); ASSERT (TcpVerifySegment (Nbuf) != 0);
ASSERT (TcpCheckSndQue (&Tcb->SndQue)); ASSERT (TcpCheckSndQue (&Tcb->SndQue) != 0);
// //
// don't send an empty segment here. // don't send an empty segment here.
@ -856,7 +854,7 @@ SEND_AGAIN:
// //
// All the buffer in the SndQue is headless // All the buffer in the SndQue is headless
// //
ASSERT (Nbuf->Tcp); ASSERT (Nbuf->Tcp != NULL);
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD); NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);
Nbuf->Tcp = NULL; Nbuf->Tcp = NULL;
@ -915,8 +913,6 @@ OnError:
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpSendAck ( TcpSendAck (
@ -949,8 +945,7 @@ TcpSendAck (
/** /**
Send a zero probe segment. It can be used by keepalive Send a zero probe segment. It can be used by keepalive and zero window probe.
and zero window probe.
@param Tcb Pointer to the TCP_CB of this TCP instance. @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. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpToSendAck ( TcpToSendAck (
@ -1015,8 +1008,7 @@ TcpToSendAck (
// //
if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) || if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) ||
(Tcb->DelayedAck >= 1) || (Tcb->DelayedAck >= 1) ||
(TcpNow > TcpRcvWinOld (Tcb)) (TcpNow > TcpRcvWinOld (Tcb))) {
) {
TcpSendAck (Tcb); TcpSendAck (Tcb);
return; return;
} }
@ -1060,7 +1052,7 @@ TcpSendReset (
// //
// Don't respond to a Reset with reset // Don't respond to a Reset with reset
// //
if (Head->Flag & TCP_FLG_RST) { if ((Head->Flag & TCP_FLG_RST) != 0) {
return 0; return 0;
} }

View File

@ -24,31 +24,67 @@ Abstract:
UINT32 mTcpTick = 1000; UINT32 mTcpTick = 1000;
/**
Connect timeout handler.
@param Tcb Pointer to the TCP_CB of this TCP instance.
**/
VOID VOID
TcpConnectTimeout ( TcpConnectTimeout (
IN TCP_CB *Tcb IN TCP_CB *Tcb
); );
/**
Timeout handler for TCP retransmission timer.
@param Tcb Pointer to the TCP_CB of this TCP instance.
**/
VOID VOID
TcpRexmitTimeout ( TcpRexmitTimeout (
IN TCP_CB *Tcb IN TCP_CB *Tcb
); );
/**
Timeout handler for window probe timer.
@param Tcb Pointer to the TCP_CB of this TCP instance.
**/
VOID VOID
TcpProbeTimeout ( TcpProbeTimeout (
IN TCP_CB *Tcb IN TCP_CB *Tcb
); );
/**
Timeout handler for keepalive timer.
@param Tcb Pointer to the TCP_CB of this TCP instance.
**/
VOID VOID
TcpKeepaliveTimeout ( TcpKeepaliveTimeout (
IN TCP_CB *Tcb IN TCP_CB *Tcb
); );
/**
Timeout handler for FIN_WAIT_2 timer.
@param Tcb Pointer to the TCP_CB of this TCP instance.
**/
VOID VOID
TcpFinwait2Timeout ( TcpFinwait2Timeout (
IN TCP_CB *Tcb IN TCP_CB *Tcb
); );
/**
Timeout handler for 2MSL timer.
@param Tcb Pointer to the TCP_CB of this TCP instance.
**/
VOID VOID
Tcp2MSLTimeout ( Tcp2MSLTimeout (
IN TCP_CB *Tcb IN TCP_CB *Tcb
@ -63,14 +99,11 @@ TCP_TIMER_HANDLER mTcpTimerHandler[TCP_TIMER_NUMBER] = {
Tcp2MSLTimeout, Tcp2MSLTimeout,
}; };
/** /**
Close the TCP connection. Close the TCP connection.
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpClose ( TcpClose (
@ -89,8 +122,6 @@ TcpClose (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpConnectTimeout ( TcpConnectTimeout (
@ -123,8 +154,6 @@ TcpConnectTimeout (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpRexmitTimeout ( TcpRexmitTimeout (
@ -148,7 +177,7 @@ TcpRexmitTimeout (
Tcb->LossRecover = Tcb->SndNxt; Tcb->LossRecover = Tcb->SndNxt;
Tcb->LossTimes++; Tcb->LossTimes++;
if (Tcb->LossTimes > Tcb->MaxRexmit && if ((Tcb->LossTimes > Tcb->MaxRexmit) &&
!TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_CONNECT)) { !TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_CONNECT)) {
DEBUG ((EFI_D_ERROR, "TcpRexmitTimeout: connection closed " DEBUG ((EFI_D_ERROR, "TcpRexmitTimeout: connection closed "
@ -167,7 +196,6 @@ TcpRexmitTimeout (
TcpSetTimer (Tcb, TCP_TIMER_REXMIT, Tcb->Rto); TcpSetTimer (Tcb, TCP_TIMER_REXMIT, Tcb->Rto);
Tcb->CongestState = TCP_CONGEST_LOSS; Tcb->CongestState = TCP_CONGEST_LOSS;
TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_RTT_ON); 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. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpProbeTimeout ( TcpProbeTimeout (
@ -207,8 +233,6 @@ TcpProbeTimeout (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpKeepaliveTimeout ( TcpKeepaliveTimeout (
@ -240,8 +264,6 @@ TcpKeepaliveTimeout (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpFinwait2Timeout ( TcpFinwait2Timeout (
@ -260,8 +282,6 @@ TcpFinwait2Timeout (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
Tcp2MSLTimeout ( Tcp2MSLTimeout (
@ -276,14 +296,11 @@ Tcp2MSLTimeout (
/** /**
Update the timer status and the next expire time Update the timer status and the next expire time according to the timers
according to the timers to expire in a specific to expire in a specific future time slot.
future time slot.
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpUpdateTimer ( TcpUpdateTimer (
@ -318,8 +335,6 @@ TcpUpdateTimer (
@param Timer The index of the timer to be enabled. @param Timer The index of the timer to be enabled.
@param TimeOut The timeout value of this timer. @param TimeOut The timeout value of this timer.
@return None.
**/ **/
VOID VOID
TcpSetTimer ( TcpSetTimer (
@ -341,8 +356,6 @@ TcpSetTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Timer The index of the timer to be cleared. @param Timer The index of the timer to be cleared.
@return None.
**/ **/
VOID VOID
TcpClearTimer ( TcpClearTimer (
@ -360,8 +373,6 @@ TcpClearTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpClearAllTimer ( TcpClearAllTimer (
@ -378,8 +389,6 @@ TcpClearAllTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpSetProbeTimer ( TcpSetProbeTimer (
@ -410,8 +419,6 @@ TcpSetProbeTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpSetKeepaliveTimer ( TcpSetKeepaliveTimer (
@ -448,8 +455,6 @@ TcpSetKeepaliveTimer (
@param Tcb Pointer to the TCP_CB of this TCP instance. @param Tcb Pointer to the TCP_CB of this TCP instance.
@return None.
**/ **/
VOID VOID
TcpBackoffRto ( TcpBackoffRto (
@ -483,8 +488,6 @@ TcpBackoffRto (
@param Context Context of the timer event, ignored. @param Context Context of the timer event, ignored.
@return None.
**/ **/
VOID VOID
EFIAPI EFIAPI
@ -572,8 +575,6 @@ NextConnection:
@param Event Timer event signaled, ignored. @param Event Timer event signaled, ignored.
@param Context Context of the timer event, ignored. @param Context Context of the timer event, ignored.
@return None.
**/ **/
VOID VOID
EFIAPI EFIAPI