TianoCore EDK2 master
Loading...
Searching...
No Matches
SockImpl.c File Reference
#include "SockImpl.h"

Go to the source code of this file.

Functions

NET_BUFSockBufFirst (IN SOCK_BUFFER *Sockbuf)
 
NET_BUFSockBufNext (IN SOCK_BUFFER *Sockbuf, IN NET_BUF *SockEntry)
 
VOID EFIAPI SockFreeFoo (IN VOID *Arg)
 
UINT32 SockTcpDataToRcv (IN SOCK_BUFFER *SockBuffer, OUT BOOLEAN *IsUrg, IN UINT32 BufLen)
 
VOID SockSetTcpRxData (IN SOCKET *Sock, IN VOID *TcpRxData, IN UINT32 RcvdBytes, IN BOOLEAN IsUrg)
 
VOID SockProcessSndToken (IN OUT SOCKET *Sock)
 
UINT32 SockProcessRcvToken (IN OUT SOCKET *Sock, IN OUT SOCK_IO_TOKEN *RcvToken)
 
EFI_STATUS SockProcessTcpSndData (IN SOCKET *Sock, IN VOID *TcpTxData)
 
VOID SockFlushPendingToken (IN SOCKET *Sock, IN OUT LIST_ENTRY *PendingTokenList)
 
VOID SockWakeConnToken (IN OUT SOCKET *Sock)
 
VOID SockWakeListenToken (IN OUT SOCKET *Sock)
 
VOID SockWakeRcvToken (IN OUT SOCKET *Sock)
 
EFI_STATUS SockCancelToken (IN SOCK_COMPLETION_TOKEN *Token, IN OUT LIST_ENTRY *SpecifiedTokenList)
 
SOCKETSockCreate (IN SOCK_INIT_DATA *SockInitData)
 
VOID SockDestroy (IN OUT SOCKET *Sock)
 
VOID SockConnFlush (IN OUT SOCKET *Sock)
 
VOID SockSetState (IN OUT SOCKET *Sock, IN UINT8 State)
 
SOCKETSockClone (IN SOCKET *Sock)
 
VOID SockConnEstablished (IN OUT SOCKET *Sock)
 
VOID SockConnClosed (IN OUT SOCKET *Sock)
 
VOID SockDataSent (IN OUT SOCKET *Sock, IN UINT32 Count)
 
UINT32 SockGetDataToSend (IN SOCKET *Sock, IN UINT32 Offset, IN UINT32 Len, OUT UINT8 *Dest)
 
VOID SockDataRcvd (IN OUT SOCKET *Sock, IN OUT NET_BUF *NetBuffer, IN UINT32 UrgLen)
 
UINT32 SockGetFreeSpace (IN SOCKET *Sock, IN UINT32 Which)
 
VOID SockNoMoreData (IN OUT SOCKET *Sock)
 

Detailed Description

Implementation of the Socket.

Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SockImpl.c.

Function Documentation

◆ SockBufFirst()

NET_BUF * SockBufFirst ( IN SOCK_BUFFER Sockbuf)

Get the first buffer block in the specific socket buffer.

Parameters
[in]SockbufPointer to the socket buffer.
Returns
Pointer to the first buffer in the queue. NULL if the queue is empty.

Definition at line 21 of file SockImpl.c.

◆ SockBufNext()

NET_BUF * SockBufNext ( IN SOCK_BUFFER Sockbuf,
IN NET_BUF SockEntry 
)

Get the next buffer block in the specific socket buffer.

Parameters
[in]SockbufPointer to the socket buffer.
[in]SockEntryPointer to the buffer block prior to the required one.
Returns
Pointer to the buffer block next to SockEntry. NULL if SockEntry is the tail or head entry.

Definition at line 47 of file SockImpl.c.

◆ SockCancelToken()

EFI_STATUS SockCancelToken ( IN SOCK_COMPLETION_TOKEN Token,
IN OUT LIST_ENTRY SpecifiedTokenList 
)

Cancel the tokens in the specific token list.

Parameters
[in]TokenPointer to the Token. If NULL, all tokens in SpecifiedTokenList will be canceled.
[in,out]SpecifiedTokenListPointer to the token list to be checked.
Return values
EFI_SUCCESSCancel the tokens in the specific token listsuccessfully.
EFI_NOT_FOUNDThe Token is not found in SpecifiedTokenList.

Definition at line 573 of file SockImpl.c.

◆ SockClone()

SOCKET * SockClone ( IN SOCKET Sock)

Clone a new socket, including its associated protocol control block.

Parameters
[in]SockPointer to the socket to be cloned.
Returns
Pointer to the newly cloned socket. If NULL, an error condition occurred.

Definition at line 937 of file SockImpl.c.

◆ SockConnClosed()

VOID SockConnClosed ( IN OUT SOCKET Sock)

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.

Parameters
[in,out]SockPointer to the socket associated with the closed connection.

Definition at line 1011 of file SockImpl.c.

◆ SockConnEstablished()

VOID SockConnEstablished ( IN OUT SOCKET Sock)

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.

Parameters
[in,out]SockPointer to the socket associated with the established connection.

Definition at line 985 of file SockImpl.c.

◆ SockConnFlush()

VOID SockConnFlush ( IN OUT SOCKET Sock)

Flush the sndBuffer and rcvBuffer of socket.

Parameters
[in,out]SockPointer to the socket.

Definition at line 857 of file SockImpl.c.

◆ SockCreate()

SOCKET * SockCreate ( IN SOCK_INIT_DATA SockInitData)

Create a socket with initial data SockInitData.

Parameters
[in]SockInitDataPointer to the initial data of the socket.
Returns
Pointer to the newly created socket, return NULL when an exception occurs.

Definition at line 633 of file SockImpl.c.

◆ SockDataRcvd()

VOID SockDataRcvd ( IN OUT SOCKET Sock,
IN OUT NET_BUF NetBuffer,
IN UINT32  UrgLen 
)

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 the urgent data length, and then check if any receive token can be signaled.

Parameters
[in,out]SockPointer to the socket.
[in,out]NetBufferPointer to the buffer that contains the received data.
[in]UrgLenThe length of the urgent data in the received data.

Definition at line 1125 of file SockImpl.c.

◆ SockDataSent()

VOID SockDataSent ( IN OUT SOCKET Sock,
IN UINT32  Count 
)

Called by low layer protocol to indicate that some data was sent or processed.

This function trims the sent data in the socket send buffer, and signals the data token if proper.

Parameters
[in,out]SockPointer to the socket.
[in]CountThe length of the data processed or sent, in bytes.

Definition at line 1039 of file SockImpl.c.

◆ SockDestroy()

VOID SockDestroy ( IN OUT SOCKET Sock)

Destroy a socket.

Parameters
[in,out]SockPointer to the socket.

Definition at line 809 of file SockImpl.c.

◆ SockFlushPendingToken()

VOID SockFlushPendingToken ( IN SOCKET Sock,
IN OUT LIST_ENTRY PendingTokenList 
)

Flush the tokens in the specific token list.

Parameters
[in]SockPointer to the socket.
[in,out]PendingTokenListPointer to the token list to be flushed.

Definition at line 424 of file SockImpl.c.

◆ SockFreeFoo()

VOID EFIAPI SockFreeFoo ( IN VOID *  Arg)

User provided callback function for NetbufFromExt.

Parameters
[in]ArgThe Arg parameter forwarded by NetbufFromExt(). Ignored.

Definition at line 75 of file SockImpl.c.

◆ SockGetDataToSend()

UINT32 SockGetDataToSend ( IN SOCKET Sock,
IN UINT32  Offset,
IN UINT32  Len,
OUT UINT8 *  Dest 
)

Called by the low layer protocol to copy some data in the socket send buffer starting from the specific offset to a buffer provided by the caller.

Parameters
[in]SockPointer to the socket.
[in]OffsetThe start point of the data to be copied.
[in]LenThe length of the data to be copied.
[out]DestPointer to the destination to copy the data.
Returns
The data size copied.

Definition at line 1096 of file SockImpl.c.

◆ SockGetFreeSpace()

UINT32 SockGetFreeSpace ( IN SOCKET Sock,
IN UINT32  Which 
)

Get the length of the free space of the specific socket buffer.

Parameters
[in]SockPointer to the socket.
[in]WhichFlag to indicate which socket buffer to check: either send buffer or receive buffer.
Returns
The length of the free space, in bytes.

Definition at line 1156 of file SockImpl.c.

◆ SockNoMoreData()

VOID SockNoMoreData ( IN OUT SOCKET Sock)

Called by the low layer protocol to indicate that there will be no more data from the communication peer.

This function sets the socket's state to SO_NO_MORE_DATA and signals all queued IO tokens with the error status EFI_CONNECTION_FIN.

Parameters
[in,out]SockPointer to the socket.

Definition at line 1192 of file SockImpl.c.

◆ SockProcessRcvToken()

UINT32 SockProcessRcvToken ( IN OUT SOCKET Sock,
IN OUT SOCK_IO_TOKEN RcvToken 
)

Get received data from the socket layer to the receive token.

Parameters
[in,out]SockPointer to the socket.
[in,out]RcvTokenPointer to the application provided receive token.
Returns
The length of data received in this token.

Definition at line 304 of file SockImpl.c.

◆ SockProcessSndToken()

VOID SockProcessSndToken ( IN OUT SOCKET Sock)

Process the send token.

Parameters
[in,out]SockPointer to the socket.

Definition at line 230 of file SockImpl.c.

◆ SockProcessTcpSndData()

EFI_STATUS SockProcessTcpSndData ( IN SOCKET Sock,
IN VOID *  TcpTxData 
)

Process the TCP send data, buffer the tcp txdata, and append the buffer to socket send buffer, then try to send it.

Parameters
[in]SockPointer to the socket.
[in]TcpTxDataPointer to the application provided send buffer.
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_OUT_OF_RESOURCESFailed due to resource limits.

Definition at line 349 of file SockImpl.c.

◆ SockSetState()

VOID SockSetState ( IN OUT SOCKET Sock,
IN UINT8  State 
)

Set the state of the socket.

Parameters
[in,out]SockPointer to the socket.
[in]StateThe new socket state to be set.

Definition at line 920 of file SockImpl.c.

◆ SockSetTcpRxData()

VOID SockSetTcpRxData ( IN SOCKET Sock,
IN VOID *  TcpRxData,
IN UINT32  RcvdBytes,
IN BOOLEAN  IsUrg 
)

Copy data from socket buffer to an application provided receive buffer.

Parameters
[in]SockPointer to the socket.
[in]TcpRxDataPointer to the application provided receive buffer.
[in]RcvdBytesThe maximum length of the data can be copied.
[in]IsUrgIf TRUE the data is Out of Bound, FALSE the data is normal.

Definition at line 181 of file SockImpl.c.

◆ SockTcpDataToRcv()

UINT32 SockTcpDataToRcv ( IN SOCK_BUFFER SockBuffer,
OUT BOOLEAN *  IsUrg,
IN UINT32  BufLen 
)

Get the length of the data that can be retrieved from the socket receive buffer.

Parameters
[in]SockBufferPointer to the socket receive buffer.
[out]IsUrgPointer to a BOOLEAN variable. If TRUE the data is OOB.
[in]BufLenThe maximum length of the data buffer to store the received data in the socket layer.
Returns
The length of the data can be retrieved.

Definition at line 96 of file SockImpl.c.

◆ SockWakeConnToken()

VOID SockWakeConnToken ( IN OUT SOCKET Sock)

Wake up the connection token while the connection is successfully established, then try to process any pending send token.

Parameters
[in,out]SockPointer to the socket.

Definition at line 457 of file SockImpl.c.

◆ SockWakeListenToken()

VOID SockWakeListenToken ( IN OUT SOCKET Sock)

Wake up the listen token while the connection is established successfully.

Parameters
[in,out]SockPointer to the socket.

Definition at line 479 of file SockImpl.c.

◆ SockWakeRcvToken()

VOID SockWakeRcvToken ( IN OUT SOCKET Sock)

Wake up the receive token while some data is received.

Parameters
[in,out]SockPointer to the socket.

Definition at line 526 of file SockImpl.c.