TianoCore EDK2 master
|
#include <Uefi.h>
#include <Protocol/Tcp4.h>
#include <Protocol/Tcp6.h>
#include <Library/NetLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/DpcLib.h>
Go to the source code of this file.
Data Structures | |
struct | _SOCK_COMPLETION_TOKEN |
union | SOCK_IO_DATA |
struct | _SOCK_IO_TOKEN |
struct | _SOCK_BUFFER |
struct | _SOCK_INIT_DATA |
union | _NET_PROTOCOL |
struct | _TCP_SOCKET |
struct | _SOCK_TOKEN |
struct | _TCP_RSV_DATA |
Macros | |
#define | SOCK_SND_BUF 0 |
#define | SOCK_RCV_BUF 1 |
#define | SOCK_BUFF_LOW_WATER (2 * 1024) |
#define | SOCK_RCV_BUFF_SIZE (8 * 1024) |
#define | SOCK_SND_BUFF_SIZE (8 * 1024) |
#define | SOCK_BACKLOG 5 |
#define | PROTO_RESERVED_LEN 20 |
#define | SO_NO_MORE_DATA 0x0001 |
#define | SO_CLOSED 0 |
#define | SO_LISTENING 1 |
#define | SO_CONNECTING 2 |
#define | SO_CONNECTED 3 |
#define | SO_DISCONNECTING 4 |
#define | SO_UNCONFIGURED 0 |
#define | SO_CONFIGURED_ACTIVE 1 |
#define | SO_CONFIGURED_PASSIVE 2 |
#define | SO_NO_MAPPING 3 |
#define | SOCK_ATTACH 0 |
Attach current socket to a new PCB. | |
#define | SOCK_DETACH 1 |
Detach current socket from the PCB. | |
#define | SOCK_CONFIGURE 2 |
Configure attached PCB. | |
#define | SOCK_FLUSH 3 |
Flush attached PCB. | |
#define | SOCK_SND 4 |
Need protocol to send something. | |
#define | SOCK_SNDPUSH 5 |
Need protocol to send pushed data. | |
#define | SOCK_SNDURG 6 |
Need protocol to send urgent data. | |
#define | SOCK_CONSUMED 7 |
Application has retrieved data from socket. | |
#define | SOCK_CONNECT 8 |
Need to connect to a peer. | |
#define | SOCK_CLOSE 9 |
Need to close the protocol process. | |
#define | SOCK_ABORT 10 |
Need to reset the protocol process. | |
#define | SOCK_POLL 11 |
Need to poll to the protocol layer. | |
#define | SOCK_ROUTE 12 |
Need to add a route information. | |
#define | SOCK_MODE 13 |
Need to get the mode data of the protocol. | |
#define | SOCK_GROUP 14 |
Need to join a mcast group. | |
#define | SOCK_NO_MORE_DATA(Sock) ((Sock)->Flag |= SO_NO_MORE_DATA) |
#define | SOCK_IS_UNCONFIGURED(Sock) ((Sock)->ConfigureState == SO_UNCONFIGURED) |
#define | SOCK_IS_CONFIGURED(Sock) |
#define | SOCK_IS_CONFIGURED_ACTIVE(Sock) ((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE) |
#define | SOCK_IS_CONNECTED_PASSIVE(Sock) ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE) |
#define | SOCK_IS_NO_MAPPING(Sock) ((Sock)->ConfigureState == SO_NO_MAPPING) |
#define | SOCK_IS_CLOSED(Sock) ((Sock)->State == SO_CLOSED) |
#define | SOCK_IS_LISTENING(Sock) ((Sock)->State == SO_LISTENING) |
#define | SOCK_IS_CONNECTING(Sock) ((Sock)->State == SO_CONNECTING) |
#define | SOCK_IS_CONNECTED(Sock) ((Sock)->State == SO_CONNECTED) |
#define | SOCK_IS_DISCONNECTING(Sock) ((Sock)->State == SO_DISCONNECTING) |
#define | SOCK_IS_NO_MORE_DATA(Sock) (0 != ((Sock)->Flag & SO_NO_MORE_DATA)) |
#define | SET_RCV_BUFFSIZE(Sock, Size) ((Sock)->RcvBuffer.HighWater = (Size)) |
#define | GET_RCV_BUFFSIZE(Sock) ((Sock)->RcvBuffer.HighWater) |
#define | GET_RCV_DATASIZE(Sock) (((Sock)->RcvBuffer.DataQueue)->BufSize) |
#define | SET_SND_BUFFSIZE(Sock, Size) ((Sock)->SndBuffer.HighWater = (Size)) |
#define | GET_SND_BUFFSIZE(Sock) ((Sock)->SndBuffer.HighWater) |
#define | GET_SND_DATASIZE(Sock) (((Sock)->SndBuffer.DataQueue)->BufSize) |
#define | SET_BACKLOG(Sock, Value) ((Sock)->BackLog = (Value)) |
#define | GET_BACKLOG(Sock) ((Sock)->BackLog) |
#define | SOCK_ERROR(Sock, Error) ((Sock)->SockError = (Error)) |
#define | SOCK_SIGNATURE SIGNATURE_32 ('S', 'O', 'C', 'K') |
#define | SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE) |
#define | SOCK_FROM_TOKEN(Token) (((SOCK_TOKEN *) (Token))->Sock) |
#define | PROTO_TOKEN_FORM_SOCK(SockToken, Type) ((Type *) (((SOCK_TOKEN *) (SockToken))->Token)) |
Typedefs | |
typedef struct _TCP_SOCKET | SOCKET |
typedef struct _SOCK_COMPLETION_TOKEN | SOCK_COMPLETION_TOKEN |
typedef struct _SOCK_IO_TOKEN | SOCK_IO_TOKEN |
typedef struct _SOCK_BUFFER | SOCK_BUFFER |
typedef EFI_STATUS(* | SOCK_PROTO_HANDLER) (IN SOCKET *Socket, IN UINT8 Request, IN VOID *RequestData) |
typedef EFI_STATUS(* | SOCK_CREATE_CALLBACK) (IN SOCKET *This, IN VOID *Context) |
typedef VOID(* | SOCK_DESTROY_CALLBACK) (IN SOCKET *This, IN VOID *Context) |
typedef struct _SOCK_INIT_DATA | SOCK_INIT_DATA |
typedef union _NET_PROTOCOL | NET_PROTOCOL |
typedef struct _SOCK_TOKEN | SOCK_TOKEN |
typedef struct _TCP_RSV_DATA | TCP_RSV_DATA |
Enumerations | |
enum | SOCK_TYPE { SockDgram , SockStream } |
Common head file for TCP socket.
Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Socket.h.
#define GET_BACKLOG | ( | Sock | ) | ((Sock)->BackLog) |
#define GET_RCV_BUFFSIZE | ( | Sock | ) | ((Sock)->RcvBuffer.HighWater) |
#define GET_RCV_DATASIZE | ( | Sock | ) | (((Sock)->RcvBuffer.DataQueue)->BufSize) |
#define GET_SND_BUFFSIZE | ( | Sock | ) | ((Sock)->SndBuffer.HighWater) |
#define GET_SND_DATASIZE | ( | Sock | ) | (((Sock)->SndBuffer.DataQueue)->BufSize) |
#define PROTO_TOKEN_FORM_SOCK | ( | SockToken, | |
Type | |||
) | ((Type *) (((SOCK_TOKEN *) (SockToken))->Token)) |
#define SET_BACKLOG | ( | Sock, | |
Value | |||
) | ((Sock)->BackLog = (Value)) |
#define SET_RCV_BUFFSIZE | ( | Sock, | |
Size | |||
) | ((Sock)->RcvBuffer.HighWater = (Size)) |
#define SET_SND_BUFFSIZE | ( | Sock, | |
Size | |||
) | ((Sock)->SndBuffer.HighWater = (Size)) |
#define SOCK_ATTACH 0 |
#define SOCK_CONSUMED 7 |
#define SOCK_ERROR | ( | Sock, | |
Error | |||
) | ((Sock)->SockError = (Error)) |
#define SOCK_FROM_TOKEN | ( | Token | ) | (((SOCK_TOKEN *) (Token))->Sock) |
#define SOCK_IS_CLOSED | ( | Sock | ) | ((Sock)->State == SO_CLOSED) |
#define SOCK_IS_CONFIGURED | ( | Sock | ) |
Check whether the socket is configured.
[in] | Sock | Pointer to the socket |
TRUE | The socket is configured |
FALSE | The socket is not configured |
#define SOCK_IS_CONFIGURED_ACTIVE | ( | Sock | ) | ((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE) |
#define SOCK_IS_CONNECTED | ( | Sock | ) | ((Sock)->State == SO_CONNECTED) |
#define SOCK_IS_CONNECTED_PASSIVE | ( | Sock | ) | ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE) |
#define SOCK_IS_CONNECTING | ( | Sock | ) | ((Sock)->State == SO_CONNECTING) |
#define SOCK_IS_DISCONNECTING | ( | Sock | ) | ((Sock)->State == SO_DISCONNECTING) |
#define SOCK_IS_LISTENING | ( | Sock | ) | ((Sock)->State == SO_LISTENING) |
#define SOCK_IS_NO_MAPPING | ( | Sock | ) | ((Sock)->ConfigureState == SO_NO_MAPPING) |
#define SOCK_IS_NO_MORE_DATA | ( | Sock | ) | (0 != ((Sock)->Flag & SO_NO_MORE_DATA)) |
#define SOCK_IS_UNCONFIGURED | ( | Sock | ) | ((Sock)->ConfigureState == SO_UNCONFIGURED) |
#define SOCK_MODE 13 |
#define SOCK_NO_MORE_DATA | ( | Sock | ) | ((Sock)->Flag |= SO_NO_MORE_DATA) |
#define SOCK_SIGNATURE SIGNATURE_32 ('S', 'O', 'C', 'K') |
typedef union _NET_PROTOCOL NET_PROTOCOL |
The union type of TCP4 and TCP6 protocol.
typedef struct _SOCK_BUFFER SOCK_BUFFER |
The buffer structure of rcvd data and send data used by socket.
typedef struct _SOCK_COMPLETION_TOKEN SOCK_COMPLETION_TOKEN |
Socket completion token
typedef EFI_STATUS(* SOCK_CREATE_CALLBACK) (IN SOCKET *This, IN VOID *Context) |
typedef struct _SOCK_INIT_DATA SOCK_INIT_DATA |
The initialize data for create a new socket.
typedef struct _SOCK_IO_TOKEN SOCK_IO_TOKEN |
The application token with data packet
typedef EFI_STATUS(* SOCK_PROTO_HANDLER) (IN SOCKET *Socket, IN UINT8 Request, IN VOID *RequestData) |
The handler of protocol for request from socket.
[in] | Socket | The socket issuing the request to protocol. |
[in] | Request | The request issued by socket. |
[in] | RequestData | The request related data. |
EFI_SUCCESS | The socket request is completed successfully. |
other | The error status returned by the corresponding TCP layer function. |
typedef struct _SOCK_TOKEN SOCK_TOKEN |
The token structure buffered in socket layer.
typedef struct _TCP_SOCKET SOCKET |
typedef struct _TCP_RSV_DATA TCP_RSV_DATA |
Reserved data to access the NET_BUF delivered by TCP driver.
enum SOCK_TYPE |
EFI_STATUS SockAccept | ( | IN SOCKET * | Sock, |
IN VOID * | Token | ||
) |
Issue a listen token to get an existed connected network instance, or wait for a connection if there is none.
[in] | Sock | Pointer to the socket to accept connections. |
[in] | Token | The token to accept a connection. |
EFI_SUCCESS | Either a connection is accepted or the Token is buffered for further acceptance. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not configured to be a passive one, or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
EFI_OUT_OF_RESOURCE | Failed to buffer the Token due to memory limit. |
Issue a listen token to get an existed connected network instance or wait for a connection if there is none.
[in] | Sock | Pointer to the socket to accept connections. |
[in] | Token | The token to accept a connection. |
EFI_SUCCESS | Either a connection is accepted or the Token is buffered for further acception. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not configured to be a passive one, or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
EFI_OUT_OF_RESOURCE | Failed to buffer the Token due to memory limits. |
Definition at line 476 of file SockInterface.c.
EFI_STATUS SockCancel | ( | IN OUT SOCKET * | Sock, |
IN VOID * | Token | ||
) |
Abort the socket associated connection, listen, transmission or receive request.
[in,out] | Sock | Pointer to the socket to abort. |
[in] | Token | Pointer to a token that has been issued by Connect(), Accept(), Transmit() or Receive(). If NULL, all pending tokens issued by the four functions listed above will be aborted. |
EFI_UNSUPPORTED | The operation is not supported in the current implementation. |
Definition at line 937 of file SockInterface.c.
Clone a new socket including its associated protocol control block.
[in] | Sock | Pointer to the socket to be cloned. |
Clone a new socket, including its associated protocol control block.
[in] | Sock | Pointer to the socket to be cloned. |
Definition at line 937 of file SockImpl.c.
Close or abort the socket associated connection.
[in,out] | Sock | Pointer to the socket of the connection to close or abort. |
[in] | Token | The token for close operation. |
[in] | OnAbort | TRUE for aborting the connection, FALSE to close it. |
EFI_SUCCESS | The close or abort operation initialized successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not in a synchronized state , or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
Close or abort the socket associated connection.
[in,out] | Sock | Pointer to the socket of the connection to close or abort. |
[in] | Token | The token for a close operation. |
[in] | OnAbort | TRUE for aborting the connection; FALSE to close it. |
EFI_SUCCESS | The close or abort operation initialized successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not in a synchronized state , or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
Definition at line 866 of file SockInterface.c.
EFI_STATUS SockConfigure | ( | IN SOCKET * | Sock, |
IN VOID * | ConfigData | ||
) |
Configure the specific socket Sock using configuration data ConfigData.
[in] | Sock | Pointer to the socket to be configured. |
[in] | ConfigData | Pointer to the configuration data. |
EFI_SUCCESS | The socket configured successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is already configured. |
Definition at line 354 of file SockInterface.c.
Called by the low layer protocol to indicate that the connection is closed.
This function flushes the socket, sets the state to SO_CLOSED, and signals the close token.
[in,out] | Sock | Pointer to the socket associated with the closed connection. |
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.
[in,out] | Sock | Pointer to the socket associated with the closed connection. |
Definition at line 1011 of file SockImpl.c.
EFI_STATUS SockConnect | ( | IN SOCKET * | Sock, |
IN VOID * | Token | ||
) |
Initiate a connection establishment process.
[in] | Sock | Pointer to the socket to initiate the connection. |
[in] | Token | Pointer to the token used for the connection operation. |
EFI_SUCCESS | The connection initialized successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not configured to be an active one, or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
Definition at line 406 of file SockInterface.c.
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.
[in,out] | Sock | Pointer to the socket associated with the established connection. |
Definition at line 985 of file SockImpl.c.
SOCKET * SockCreateChild | ( | IN SOCK_INIT_DATA * | SockInitData | ) |
Create a socket and its associated protocol control block with the initial data SockInitData and protocol specific data ProtoData.
[in] | SockInitData | Initial data to setting the socket. |
Definition at line 260 of file SockInterface.c.
Called by the low layer protocol to deliver received data to socket layer.
This function appends the data to the socket receive buffer, set the urgent data length, then checks if any receive token can be signaled.
[in,out] | Sock | Pointer to the socket. |
[in,out] | NetBuffer | Pointer to the buffer that contains the received data. |
[in] | UrgLen | The length of the urgent data in the received data. |
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.
[in,out] | Sock | Pointer to the socket. |
[in,out] | NetBuffer | Pointer to the buffer that contains the received data. |
[in] | UrgLen | The length of the urgent data in the received data. |
Definition at line 1125 of file SockImpl.c.
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 and signals the data token, if proper.
[in,out] | Sock | Pointer to the socket. |
[in] | Count | The length of the data processed or sent, in bytes. |
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.
[in,out] | Sock | Pointer to the socket. |
[in] | Count | The length of the data processed or sent, in bytes. |
Definition at line 1039 of file SockImpl.c.
EFI_STATUS SockDestroyChild | ( | IN OUT SOCKET * | Sock | ) |
Destroy the socket Sock and its associated protocol control block.
[in,out] | Sock | The socket to be destroyed. |
EFI_SUCCESS | The socket Sock was destroyed successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket. |
Definition at line 132 of file SockInterface.c.
EFI_STATUS SockFlush | ( | IN OUT SOCKET * | Sock | ) |
Reset the socket and its associated protocol control block.
[in,out] | Sock | Pointer to the socket to be flushed. |
EFI_SUCCESS | The socket flushed successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket. |
Reset the socket and its associated protocol control block.
[in,out] | Sock | Pointer to the socket to be flushed. |
EFI_SUCCESS | The socket is flushed successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket. |
Definition at line 800 of file SockInterface.c.
Called by the low layer protocol to copy some data in socket send buffer starting from the specific offset to a buffer provided by the caller.
[in] | Sock | Pointer to the socket. |
[in] | Offset | The start point of the data to be copied. |
[in] | Len | The length of the data to be copied. |
[out] | Dest | Pointer to the destination to copy the data. |
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.
[in] | Sock | Pointer to the socket. |
[in] | Offset | The start point of the data to be copied. |
[in] | Len | The length of the data to be copied. |
[out] | Dest | Pointer to the destination to copy the data. |
Definition at line 1096 of file SockImpl.c.
Get the length of the free space of the specific socket buffer.
[in] | Sock | Pointer to the socket. |
[in] | Which | Flag to indicate which socket buffer to check: either send buffer or receive buffer. |
Definition at line 1156 of file SockImpl.c.
EFI_STATUS SockGetMode | ( | IN SOCKET * | Sock, |
IN OUT VOID * | Mode | ||
) |
Get the mode data of the low layer protocol.
[in] | Sock | Pointer to the socket to get mode data from. |
[in,out] | Mode | Pointer to the data to store the low layer mode information. |
EFI_SUCCESS | The mode data was obtained successfully. |
EFI_NOT_STARTED | The socket is not configured. |
Definition at line 1025 of file SockInterface.c.
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.
[in,out] | Sock | Pointer to the socket. |
Definition at line 1192 of file SockImpl.c.
EFI_STATUS SockRcv | ( | IN SOCKET * | Sock, |
IN VOID * | Token | ||
) |
Issue a token to get data from the socket.
[in] | Sock | Pointer to the socket to get data from. |
[in] | Token | The token to store the received data from the socket. |
EFI_SUCCESS | The token processed successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not in a synchronized state , or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
EFI_CONNECTION_FIN | The connection is closed and there is no more data. |
EFI_OUT_OF_RESOURCE | Failed to buffer the token due to a memory limit. |
Issue a token to get data from the socket.
[in] | Sock | Pointer to the socket to get data from. |
[in] | Token | The token to store the received data from the socket. |
EFI_SUCCESS | The token processed successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not in a synchronized state , or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
EFI_CONNECTION_FIN | The connection is closed and there is no more data. |
EFI_OUT_OF_RESOURCE | Failed to buffer the token due to memory limit. |
Definition at line 705 of file SockInterface.c.
EFI_STATUS SockRoute | ( | IN SOCKET * | Sock, |
IN VOID * | RouteInfo | ||
) |
Add or remove route information in IP route table associated with this socket.
[in] | Sock | Pointer to the socket associated with the IP route table to operate on. |
[in] | RouteInfo | Pointer to the route information to be processed. |
EFI_SUCCESS | The route table updated successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
Definition at line 1049 of file SockInterface.c.
EFI_STATUS SockSend | ( | IN SOCKET * | Sock, |
IN VOID * | Token | ||
) |
Issue a token with data to the socket to send out.
[in] | Sock | Pointer to the socket to process the token with data. |
[in] | Token | The token with data that needs to send out. |
EFI_SUCCESS | The token processed successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not in a synchronized state , or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
EFI_OUT_OF_RESOURCE | Failed to buffer the token due to a memory limit. |
Issue a token with data to the socket to send out.
[in] | Sock | Pointer to the socket to process the token with data. |
[in] | Token | The token with data that needs to send out. |
EFI_SUCCESS | The token processed successfully. |
EFI_ACCESS_DENIED | Failed to get the lock to access the socket, or the socket is closed, or the socket is not in a synchronized state , or the token is already in one of this socket's lists. |
EFI_NO_MAPPING | The IP address configuration operation is not finished. |
EFI_NOT_STARTED | The socket is not configured. |
EFI_OUT_OF_RESOURCE | Failed to buffer the token due to memory limits. |
Definition at line 583 of file SockInterface.c.