summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c')
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c155
1 files changed, 70 insertions, 85 deletions
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
index 602765b252..14342dfff0 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
@@ -20,18 +20,41 @@ 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,
OUT BOOLEAN *IsOOB,
IN UINT32 BufLen
);
+
+/**
+ Process the send token.
+ @param Sock Pointer to the socket.
+
+**/
VOID
SockProcessSndToken (
IN SOCKET *Sock
);
+/**
+
+
+**/
VOID
SockFreeFoo (
IN EFI_EVENT Event
@@ -56,9 +79,9 @@ SockFreeFoo (
**/
UINT32
SockTcpDataToRcv (
- IN SOCK_BUFFER *SockBuffer,
- OUT BOOLEAN *IsUrg,
- IN UINT32 BufLen
+ IN SOCK_BUFFER *SockBuffer,
+ OUT BOOLEAN *IsUrg,
+ IN UINT32 BufLen
)
{
NET_BUF *RcvBufEntry;
@@ -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);
@@ -305,9 +326,7 @@ 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 *
@@ -905,22 +907,22 @@ SockClone (
SOCKET *ClonedSock;
SOCK_INIT_DATA InitData;
- InitData.BackLog = Sock->BackLog;
- InitData.Parent = Sock;
- InitData.State = Sock->State;
- InitData.ProtoHandler = Sock->ProtoHandler;
- InitData.Type = Sock->Type;
- InitData.RcvBufferSize = Sock->RcvBuffer.HighWater;
- InitData.SndBufferSize = Sock->SndBuffer.HighWater;
- InitData.DriverBinding = Sock->DriverBinding;
- InitData.Protocol = &(Sock->NetProtocol);
+ InitData.BackLog = Sock->BackLog;
+ InitData.Parent = Sock;
+ InitData.State = Sock->State;
+ InitData.ProtoHandler = Sock->ProtoHandler;
+ InitData.Type = Sock->Type;
+ InitData.RcvBufferSize = Sock->RcvBuffer.HighWater;
+ InitData.SndBufferSize = Sock->SndBuffer.HighWater;
+ InitData.DriverBinding = Sock->DriverBinding;
+ InitData.Protocol = &(Sock->NetProtocol);
InitData.CreateCallback = Sock->CreateCallback;
InitData.DestroyCallback = Sock->DestroyCallback;
InitData.Context = Sock->Context;
InitData.ProtoData = Sock->ProtoReserved;
InitData.DataSize = sizeof (Sock->ProtoReserved);
- ClonedSock = SockCreate (&InitData);
+ ClonedSock = SockCreate (&InitData);
if (NULL == ClonedSock) {
DEBUG ((EFI_D_ERROR, "SockClone: no resource to create a cloned sock\n"));
@@ -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;
}