summaryrefslogtreecommitdiff
path: root/StdLib/EfiSocketLib/Socket.h
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 23:02:35 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 23:02:35 +0000
commita88c31639bb24c73383a4528a5b77066e805148b (patch)
tree058801cd8687b0a0c6f82459b56b2ad3beb43bf4 /StdLib/EfiSocketLib/Socket.h
parentdf7499fcc1fbd6c825cabf19bbed379688416125 (diff)
downloadedk2-platforms-a88c31639bb24c73383a4528a5b77066e805148b.tar.xz
Update the sockets library code
* Passes conformance and functional tests. * Builds with GCC 4.4 compiler. Signed-off by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12497 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/EfiSocketLib/Socket.h')
-rw-r--r--StdLib/EfiSocketLib/Socket.h1762
1 files changed, 972 insertions, 790 deletions
diff --git a/StdLib/EfiSocketLib/Socket.h b/StdLib/EfiSocketLib/Socket.h
index 42377eb29c..25133e6f89 100644
--- a/StdLib/EfiSocketLib/Socket.h
+++ b/StdLib/EfiSocketLib/Socket.h
@@ -30,27 +30,26 @@
#define DEBUG_TX 0x00400000 ///< Display transmit messages
#define DEBUG_CLOSE 0x00200000 ///< Display close messages
#define DEBUG_CONNECT 0x00100000 ///< Display connect messages
+#define DEBUG_OPTION 0x00080000 ///< Display option messages
#define MAX_PENDING_CONNECTIONS 1 ///< Maximum connection FIFO depth
#define MAX_RX_DATA 65536 ///< Maximum receive data size
-#define MAX_TX_DATA ( MAX_RX_DATA * 2 )
+#define MAX_TX_DATA ( MAX_RX_DATA * 2 ) ///< Maximum buffered transmit data in bytes
#define RX_PACKET_DATA 16384 ///< Maximum number of bytes in a RX packet
+#define MAX_UDP_RETRANSMIT 16 ///< UDP retransmit attempts to handle address not mapped
-#define LAYER_SIGNATURE SIGNATURE_32('S','k','t','L') ///< DT_LAYER memory signature
-#define SERVICE_SIGNATURE SIGNATURE_32('S','k','t','S') ///< DT_SERVICE memory signature
-#define SOCKET_SIGNATURE SIGNATURE_32('S','c','k','t') ///< DT_SOCKET memory signature
-#define PORT_SIGNATURE SIGNATURE_32('P','o','r','t') ///< DT_PORT memory signature
+#define ESL_STRUCTURE_ALIGNMENT_BYTES 15 ///< Number of bytes for structure alignment
+#define ESL_STRUCTURE_ALIGNMENT_MASK ( ~ESL_STRUCTURE_ALIGNMENT_BYTES ) ///< Mask to align structures
+
+#define LAYER_SIGNATURE SIGNATURE_32 ('S','k','t','L') ///< ESL_LAYER memory signature
+#define SERVICE_SIGNATURE SIGNATURE_32 ('S','k','t','S') ///< ESL_SERVICE memory signature
+#define SOCKET_SIGNATURE SIGNATURE_32 ('S','c','k','t') ///< ESL_SOCKET memory signature
+#define PORT_SIGNATURE SIGNATURE_32 ('P','o','r','t') ///< ESL_PORT memory signature
-typedef enum
-{
- NETWORK_TYPE_UNKNOWN = 0,
- NETWORK_TYPE_RAW,
- NETWORK_TYPE_TCP4,
- NETWORK_TYPE_TCP6,
- NETWORK_TYPE_UDP4,
- NETWORK_TYPE_UDP6
-} NETWORK_TYPE;
+/**
+ Socket states
+**/
typedef enum
{
SOCKET_STATE_NOT_CONFIGURED = 0, ///< socket call was successful
@@ -67,6 +66,10 @@ typedef enum
SOCKET_STATE_CLOSED ///< Close call was successful
} SOCKET_STATE;
+
+/**
+ Port states
+**/
typedef enum
{
PORT_STATE_ALLOCATED = 0, ///< Port allocated
@@ -74,102 +77,164 @@ typedef enum
PORT_STATE_RX_ERROR, ///< Receive error detected
//
- // Close state must be last in the list
+ // Close state must be last in the list!
+ //
+ // Using < <= > >= in tests code to detect port close state
+ // machine has started
//
PORT_STATE_CLOSE_STARTED, ///< Close started on port
PORT_STATE_CLOSE_TX_DONE, ///< Transmits shutdown
- PORT_STATE_CLOSE_RX_DONE, ///< Receives shutdown
- PORT_STATE_CLOSE_DONE ///< Port close operation complete
+ PORT_STATE_CLOSE_DONE, ///< Port close operation complete
+ PORT_STATE_CLOSE_RX_DONE ///< Receives shutdown
} PORT_STATE;
//------------------------------------------------------------------------------
// Data Types
//------------------------------------------------------------------------------
-typedef struct _DT_PACKET DT_PACKET; ///< Forward declaration
-typedef struct _DT_PORT DT_PORT; ///< Forward declaration
-typedef struct _DT_SOCKET DT_SOCKET; ///< Forward declaration
+typedef struct _ESL_IO_MGMT ESL_IO_MGMT;///< Forward declaration
+typedef struct _ESL_PACKET ESL_PACKET; ///< Forward declaration
+typedef struct _ESL_PORT ESL_PORT; ///< Forward declaration
+typedef struct _ESL_SOCKET ESL_SOCKET; ///< Forward declaration
+/**
+ Receive context for SOCK_RAW sockets using IPv4.
+**/
+typedef struct
+{
+ EFI_IP4_RECEIVE_DATA * pRxData; ///< Receive operation description
+} ESL_IP4_RX_DATA;
+
+
+/**
+ Transmit context for SOCK_RAW sockets using IPv4.
+**/
+typedef struct
+{
+ EFI_IP4_OVERRIDE_DATA Override; ///< Override data
+ EFI_IP4_TRANSMIT_DATA TxData; ///< Transmit operation description
+ UINT8 Buffer[ 1 ]; ///< Data buffer
+} ESL_IP4_TX_DATA;
+
+
+/**
+ Receive context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv4.
+**/
typedef struct
{
EFI_TCP4_RECEIVE_DATA RxData; ///< Receive operation description
- size_t ValidBytes; ///< Length of valid data in bytes
- UINT8 * pBuffer; ///< Current data pointer
- UINT8 Buffer [ RX_PACKET_DATA ]; ///< Data buffer
-} DT_TCP4_RX_DATA;
+ UINT8 Buffer[ RX_PACKET_DATA ]; ///< Data buffer
+} ESL_TCP4_RX_DATA;
+
+/**
+ Transmit context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv4.
+**/
typedef struct
{
EFI_TCP4_TRANSMIT_DATA TxData; ///< Transmit operation description
- UINT8 Buffer [ 1 ]; ///< Data buffer
-} DT_TCP4_TX_DATA;
+ UINT8 Buffer[ 1 ]; ///< Data buffer
+} ESL_TCP4_TX_DATA;
+
+/**
+ Receive context for SOCK_DGRAM sockets using UDPv4.
+**/
typedef struct
{
- EFI_UDP4_SESSION_DATA Session; ///< * Remote network address
- EFI_UDP4_RECEIVE_DATA * pRxData; ///< * Receive operation description
-} DT_UDP4_RX_DATA;
+ EFI_UDP4_SESSION_DATA Session; ///< Remote network address
+ EFI_UDP4_RECEIVE_DATA * pRxData; ///< Receive operation description
+} ESL_UDP4_RX_DATA;
+
+/**
+ Transmit context for SOCK_DGRAM sockets using UDPv4.
+**/
typedef struct
{
EFI_UDP4_SESSION_DATA Session; ///< Remote network address
EFI_UDP4_TRANSMIT_DATA TxData; ///< Transmit operation description
- UINT8 Buffer [ 1 ]; ///< Data buffer
-} DT_UDP4_TX_DATA;
+ UINTN RetransmitCount; ///< Retransmit to handle ARP negotiation
+ UINT8 Buffer[ 1 ]; ///< Data buffer
+} ESL_UDP4_TX_DATA;
+
-typedef struct _DT_PACKET {
- DT_PACKET * pNext; ///< Next packet in the receive list
+/**
+ Network specific context for transmit and receive packets.
+**/
+typedef struct _ESL_PACKET {
+ ESL_PACKET * pNext; ///< Next packet in the receive list
size_t PacketSize; ///< Size of this data structure
+ size_t ValidBytes; ///< Length of valid data in bytes
+ UINT8 * pBuffer; ///< Current data pointer
union {
- DT_TCP4_RX_DATA Tcp4Rx; ///< Receive operation description
- DT_TCP4_TX_DATA Tcp4Tx; ///< Transmit operation description
- DT_UDP4_RX_DATA Udp4Rx; ///< Receive operation description
- DT_UDP4_TX_DATA Udp4Tx; ///< Transmit operation description
- } Op;
-} GCC_DT_PACKET;
+ ESL_IP4_RX_DATA Ip4Rx; ///< Receive operation description
+ ESL_IP4_TX_DATA Ip4Tx; ///< Transmit operation description
+ ESL_TCP4_RX_DATA Tcp4Rx; ///< Receive operation description
+ ESL_TCP4_TX_DATA Tcp4Tx; ///< Transmit operation description
+ ESL_UDP4_RX_DATA Udp4Rx; ///< Receive operation description
+ ESL_UDP4_TX_DATA Udp4Tx; ///< Transmit operation description
+ } Op; ///< Network specific context
+} GCC_ESL_PACKET;
/**
Service control structure
The driver uses this structure to manage the network devices.
**/
-typedef struct _DT_SERVICE {
+typedef struct _ESL_SERVICE {
UINTN Signature; ///< Structure identification
//
// Links
//
- DT_SERVICE * pNext; ///< Next service in the service list
+ ESL_SERVICE * pNext; ///< Next service in the service list
//
// Service data
//
- CONST DT_SOCKET_BINDING * pSocketBinding; ///< Name and shutdown routine
- EFI_HANDLE Controller; ///< Controller for the service
- VOID * pInterface; ///< Network layer service binding interface
+ CONST ESL_SOCKET_BINDING * pSocketBinding; ///< Name and shutdown routine
+ EFI_HANDLE Controller; ///< Controller for the service
+ EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Network layer service binding interface
//
// Network data
//
- NETWORK_TYPE NetworkType; ///< Type of network service
- DT_PORT * pPortList; ///< List of ports using this service
-}GCC_DT_SERVICE;
+ ESL_PORT * pPortList; ///< List of ports using this service
+}GCC_ESL_SERVICE;
/**
- Start the close operation on a TCP4 port.
+ IO management structure
- @param [in] pPort Address of the port structure.
- @param [in] bAbort Set TRUE to abort active transfers
- @param [in] DebugFlags Flags for debug messages
+ This structure manages a single operation with the network.
+**/
+typedef struct _ESL_IO_MGMT {
+ ESL_IO_MGMT * pNext; ///< Next TX management structure
+ ESL_PORT * pPort; ///< Port structure address
+ ESL_PACKET * pPacket; ///< Packet structure address
+ union {
+ EFI_IP4_COMPLETION_TOKEN Ip4Rx; ///< IP4 receive token
+ EFI_IP4_COMPLETION_TOKEN Ip4Tx; ///< IP4 transmit token
+ EFI_TCP4_IO_TOKEN Tcp4Rx; ///< TCP4 receive token
+ EFI_TCP4_IO_TOKEN Tcp4Tx; ///< TCP4 transmit token
+ EFI_UDP4_COMPLETION_TOKEN Udp4Rx; ///< UDP4 receive token
+ EFI_UDP4_COMPLETION_TOKEN Udp4Tx; ///< UDP4 transmit token
+ } Token; ///< Completion token for the network operation
+};
+
+/**
+ IP4 context structure
+ The driver uses this structure to manage the IP4 connections.
**/
-typedef
-EFI_STATUS
-PFN_PORT_CLOSE_START (
- IN DT_PORT * pPort,
- IN BOOLEAN bAbort,
- IN UINTN DebugFlags
- );
+typedef struct {
+ //
+ // IP4 context
+ //
+ EFI_IP4_MODE_DATA ModeData; ///< IP4 mode data, includes configuration data
+ EFI_IPv4_ADDRESS DestinationAddress; ///< Default destination address
+} ESL_IP4_CONTEXT;
+
/**
TCP4 context structure
@@ -180,34 +245,16 @@ typedef struct {
//
// TCP4 context
//
- EFI_HANDLE Handle; ///< TCP4 port handle
- EFI_TCP4_PROTOCOL * pProtocol; ///< TCP4 protocol pointer
- EFI_TCP4_CONFIG_DATA ConfigData; ///< TCP4 configuration data
- EFI_TCP4_OPTION Option; ///< TCP4 port options
- BOOLEAN bConfigured; ///< TRUE if configuration was successful
+ EFI_TCP4_CONFIG_DATA ConfigData; ///< TCP4 configuration data
+ EFI_TCP4_OPTION Option; ///< TCP4 port options
//
// Tokens
//
- EFI_TCP4_LISTEN_TOKEN ListenToken; ///< Listen control
+ EFI_TCP4_LISTEN_TOKEN ListenToken; ///< Listen control
EFI_TCP4_CONNECTION_TOKEN ConnectToken; ///< Connection control
- EFI_TCP4_CLOSE_TOKEN CloseToken; ///< Close control
-
- //
- // Receive data management
- //
- EFI_TCP4_IO_TOKEN RxToken; ///< Receive token
- DT_PACKET * pReceivePending; ///< Receive operation in progress
-
- //
- // Transmit data management
- //
- EFI_TCP4_IO_TOKEN TxOobToken; ///< Urgent data token
- DT_PACKET * pTxOobPacket; ///< Urgent data in progress
-
- EFI_TCP4_IO_TOKEN TxToken; ///< Normal data token
- DT_PACKET * pTxPacket; ///< Normal transmit in progress
-} DT_TCP4_CONTEXT;
+ EFI_TCP4_CLOSE_TOKEN CloseToken; ///< Close control
+} ESL_TCP4_CONTEXT;
/**
UDP4 context structure
@@ -218,24 +265,41 @@ typedef struct {
//
// UDP4 context
//
- EFI_HANDLE Handle; ///< UDP4 port handle
- EFI_UDP4_PROTOCOL * pProtocol; ///< UDP4 protocol pointer
EFI_UDP4_CONFIG_DATA ConfigData; ///< UDP4 configuration data
- BOOLEAN bConfigured; ///< TRUE if configuration was successful
+} ESL_UDP4_CONTEXT;
- //
- // Receive data management
- //
- EFI_UDP4_COMPLETION_TOKEN RxToken;///< Receive token
- DT_PACKET * pReceivePending; ///< Receive operation in progress
- //
- // Transmit data management
- //
- EFI_UDP4_COMPLETION_TOKEN TxToken;///< Transmit token
- DT_PACKET * pTxPacket; ///< Transmit in progress
-} DT_UDP4_CONTEXT;
+/**
+ Configure the network layer.
+
+ @param [in] pProtocol Protocol structure address
+ @param [in] pConfigData Address of the confiuration data
+
+ @return Returns EFI_SUCCESS if the operation is successfully
+ started.
+**/
+typedef
+EFI_STATUS
+(* PFN_NET_CONFIGURE) (
+ IN VOID * pProtocol,
+ IN VOID * pConfigData
+ );
+
+/**
+ Hand an I/O operation to the network layer.
+
+ @param [in] pProtocol Protocol structure address
+ @param [in] pToken Completion token address
+ @return Returns EFI_SUCCESS if the operation is successfully
+ started.
+**/
+typedef
+EFI_STATUS
+(* PFN_NET_IO_START) (
+ IN VOID * pProtocol,
+ IN VOID * pToken
+ );
/**
Port control structure
@@ -243,240 +307,75 @@ typedef struct {
The driver uses this structure to manager the socket's connection
with the network driver.
**/
-typedef struct _DT_PORT {
+typedef struct _ESL_PORT {
UINTN Signature; ///< Structure identification
//
// List links
//
- DT_PORT * pLinkService; ///< Link in service port list
- DT_PORT * pLinkSocket; ///< Link in socket port list
+ ESL_PORT * pLinkService; ///< Link in service port list
+ ESL_PORT * pLinkSocket; ///< Link in socket port list
//
// Structures
//
- DT_SERVICE * pService; ///< Service for this port
- DT_SOCKET * pSocket; ///< Socket for this port
-// PFN_CLOSE_PORT pfnClosePort; ///< Routine to immediately close the port
- PFN_PORT_CLOSE_START * pfnCloseStart; ///< Routine to start closing the port
-
- //
- // Protocol specific management data
- //
- PORT_STATE State; ///< State of the port
- UINTN DebugFlags; ///< Debug flags used to close the port
- BOOLEAN bCloseNow; ///< TRUE = Close the port immediately
-
- union {
- DT_TCP4_CONTEXT Tcp4; ///< TCPv4 management data
- DT_UDP4_CONTEXT Udp4; ///< UDPv4 management data
- } Context;
-}GCC_DT_PORT;
-
-/**
- Socket control structure
-
- The driver uses this structure to manage the socket.
-**/
-typedef struct _DT_SOCKET {
- UINTN Signature; ///< Structure identification
-
- //
- // Protocol binding
- //
- EFI_SOCKET_PROTOCOL SocketProtocol; ///< Socket protocol declaration
+ ESL_SERVICE * pService; ///< Service for this port
+ ESL_SOCKET * pSocket; ///< Socket for this port
//
- // Socket management
+ // Eliminate the pService references during port close
//
- DT_SOCKET * pNext; ///< Next socket in the list of sockets
- int errno; ///< Error information for this socket
- EFI_STATUS Status; ///< Asyncronous error information for this socket
- SOCKET_STATE State; ///< Socket state
+ EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Service binding for network layer
+ CONST ESL_SOCKET_BINDING * pSocketBinding; ///< Socket binding for network layer
//
- // Socket data
+ // Port management
//
- int Domain; ///< Specifies family of protocols
- int Type; ///< Specifies how to make network connection
- int Protocol; ///< Specifies lower layer protocol to use
- BOOLEAN bConfigured; ///< Set after the socket is configured
-
- BOOLEAN bRxDisable; ///< Receive disabled via shutdown
- size_t RxBytes; ///< Total Rx bytes
- size_t RxOobBytes; ///< Urgent Rx bytes
- EFI_STATUS RxError; ///< Error during receive
-
- BOOLEAN bTxDisable; ///< Transmit disabled via shutdown
- size_t TxBytes; ///< Normal Tx bytes
- size_t TxOobBytes; ///< Urgent Tx bytes
- EFI_STATUS TxError; ///< Error during transmit
-
- //
- // Pending connection data
- //
- BOOLEAN bConnected; ///< Set when connected, cleared by poll
- EFI_STATUS ConnectStatus; ///< Connection status
- UINTN MaxFifoDepth; ///< Maximum FIFO depth
- UINTN FifoDepth; ///< Number of sockets in the FIFO
- DT_SOCKET * pFifoHead; ///< Head of the FIFO
- DT_SOCKET * pFifoTail; ///< Tail of the FIFO
- DT_SOCKET * pNextConnection; ///< Link in the FIFO
-
- //
- // Network use
- //
- DT_PORT * pPortList; ///< List of ports managed by this socket
- EFI_EVENT WaitAccept; ///< Wait for accept completion
-
- //
- // Receive data management
- //
- UINT32 MaxRxBuf; ///< Maximum size of the receive buffer
- struct timeval RxTimeout; ///< Receive timeout
- DT_PACKET * pRxFree; ///< Free packet list
- DT_PACKET * pRxOobPacketListHead; ///< Urgent data list head
- DT_PACKET * pRxOobPacketListTail; ///< Urgent data list tail
- DT_PACKET * pRxPacketListHead; ///< Normal data list head
- DT_PACKET * pRxPacketListTail; ///< Normal data list tail
+ EFI_HANDLE Handle; ///< Network port handle
+ PORT_STATE State; ///< State of the port
+ UINTN DebugFlags; ///< Debug flags used to close the port
+ BOOLEAN bCloseNow; ///< TRUE = Close the port immediately
+ BOOLEAN bConfigured; ///< TRUE = Configure call made to network layer
+ PFN_NET_CONFIGURE pfnConfigure; ///< Configure the network layer
//
// Transmit data management
//
- UINT32 MaxTxBuf; ///< Maximum size of the transmit buffer
- DT_PACKET * pTxOobPacketListHead; ///< Urgent data list head
- DT_PACKET * pTxOobPacketListTail; ///< Urgent data list tail
- DT_PACKET * pTxPacketListHead; ///< Normal data list head
- DT_PACKET * pTxPacketListTail; ///< Normal data list tail
-}GCC_DT_SOCKET;
-
-#define SOCKET_FROM_PROTOCOL(a) CR(a, DT_SOCKET, SocketProtocol, SOCKET_SIGNATURE) ///< Locate DT_SOCKET from protocol
-
-/**
- Socket layer control structure
-
- The driver uses this structure to manage the driver.
-**/
-typedef struct {
- UINTN Signature; ///< Structure identification
-
- //
- // Service binding interface
- //
- EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;///< Driver's binding
+ BOOLEAN bTxFlowControl; ///< TX flow control applied
+ PFN_NET_IO_START pfnTxStart; ///< Start a transmit on the network
+ ESL_IO_MGMT * pTxActive; ///< Normal data queue
+ ESL_IO_MGMT * pTxFree; ///< Normal free queue
- //
- // Image data
- //
- EFI_HANDLE ImageHandle; ///< Image handle
+ ESL_IO_MGMT * pTxOobActive; ///< Urgent data queue
+ ESL_IO_MGMT * pTxOobFree; ///< Urgent free queue
//
- // Network services
+ // Receive data management
//
- DT_SERVICE * pTcp4List; ///< List of Tcp4 services
- DT_SERVICE * pUdp4List; ///< List of Udp4 services
+ PFN_NET_IO_START pfnRxCancel; ///< Cancel a receive on the network
+ PFN_NET_IO_START pfnRxStart; ///< Start a receive on the network
+ ESL_IO_MGMT * pRxActive; ///< Active receive operation queue
+ ESL_IO_MGMT * pRxFree; ///< Free structure queue
//
- // Socket management
- //
- DT_SOCKET * pSocketList; ///< List of sockets
-
- //
- // TCP4 service
+ // Protocol specific management data
//
- UINTN TcpCloseMax4; ///< Number of entries in the ring buffer
- UINTN TcpCloseIn4; ///< Offset into TcpClose4 ring buffer - Close request
- UINTN TcpCloseOut4; ///< Offset into TcpClose4 ring buffer - Close operation
- EFI_TCP4_PROTOCOL ** ppTcpClose4; ///< Ring buffer to close TCP4 ports
-} DT_LAYER;
-
-#define LAYER_FROM_SERVICE(a) CR(a, DT_LAYER, ServiceBinding, LAYER_SIGNATURE) ///< Locate DT_LAYER from service binding
-
-//------------------------------------------------------------------------------
-// Data
-//------------------------------------------------------------------------------
-
-extern DT_LAYER mEslLayer;
-
-//------------------------------------------------------------------------------
-// Socket Support Routines
-//------------------------------------------------------------------------------
-
-/**
- Allocate and initialize a DT_SOCKET structure.
-
- The ::SocketAllocate() function allocates a DT_SOCKET structure
- and installs a protocol on ChildHandle. If pChildHandle is a
- pointer to NULL, then a new handle is created and returned in
- pChildHandle. If pChildHandle is not a pointer to NULL, then
- the protocol installs on the existing pChildHandle.
-
- @param [in, out] pChildHandle Pointer to the handle of the child to create.
- If it is NULL, then a new handle is created.
- If it is a pointer to an existing UEFI handle,
- then the protocol is added to the existing UEFI
- handle.
- @param [in] DebugFlags Flags for debug messages
- @param [in, out] ppSocket The buffer to receive the DT_SOCKET structure address.
-
- @retval EFI_SUCCESS The protocol was added to ChildHandle.
- @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
- the child
- @retval other The child handle was not created
-
-**/
-EFI_STATUS
-EFIAPI
-EslSocketAllocate (
- IN OUT EFI_HANDLE * pChildHandle,
- IN UINTN DebugFlags,
- IN OUT DT_SOCKET ** ppSocket
- );
-
-/**
- Allocate a packet for a receive or transmit operation
-
- @param [in] ppPacket Address to receive the DT_PACKET structure
- @param [in] LengthInBytes Length of the packet structure
- @param [in] DebugFlags Flags for debug messages
-
- @retval EFI_SUCCESS - The packet was allocated successfully
-
- **/
-EFI_STATUS
-EslSocketPacketAllocate (
- IN DT_PACKET ** ppPacket,
- IN size_t LengthInBytes,
- IN UINTN DebugFlags
- );
-
-/**
- Free a packet used for receive or transmit operation
-
- @param [in] pPacket Address of the DT_PACKET structure
- @param [in] DebugFlags Flags for debug messages
-
- @retval EFI_SUCCESS - The packet was allocated successfully
-
- **/
-EFI_STATUS
-EslSocketPacketFree (
- IN DT_PACKET * pPacket,
- IN UINTN DebugFlags
- );
-
-//------------------------------------------------------------------------------
-// Tcp4 Routines
-//------------------------------------------------------------------------------
+ union {
+ VOID * v; ///< VOID pointer
+ EFI_IP4_PROTOCOL * IPv4; ///< IP4 protocol pointer
+ EFI_TCP4_PROTOCOL * TCPv4; ///< TCP4 protocol pointer
+ EFI_UDP4_PROTOCOL * UDPv4; ///< UDP4 protocol pointer
+ } pProtocol; ///< Protocol structure address
+ union {
+ ESL_IP4_CONTEXT Ip4; ///< IPv4 management data
+ ESL_TCP4_CONTEXT Tcp4; ///< TCPv4 management data
+ ESL_UDP4_CONTEXT Udp4; ///< UDPv4 management data
+ } Context; ///< Network specific context
+}GCC_ESL_PORT;
/**
Accept a network connection.
- The SocketAccept routine waits for a network connection to the socket.
- It is able to return the remote network address to the caller if
- requested.
-
@param [in] pSocket Address of the socket structure.
@param [in] pSockAddr Address of a buffer to receive the remote
@@ -490,293 +389,276 @@ EslSocketPacketFree (
@retval Others Remote address not available
**/
+typedef
EFI_STATUS
-EslTcpAccept4 (
- IN DT_SOCKET * pSocket,
+(* PFN_API_ACCEPT) (
+ IN ESL_SOCKET * pSocket,
IN struct sockaddr * pSockAddr,
IN OUT socklen_t * pSockAddrLength
);
/**
- Bind a name to a socket.
-
- The ::TcpBind4 routine connects a name to A TCP4 stack on the local machine.
-
- @param [in] pSocket Address of the socket structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address. Specifying zero
- for the port causes the network layer to assign a port
- number from the dynamic range. Specifying a specific
- port number causes the network layer to use that port.
-
- @param [in] SockAddrLen Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslTcpBind4 (
- IN DT_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
Poll for completion of the connection attempt.
- The ::TcpConnectPoll4 routine determines when the connection
- attempt transitions from being in process to being complete.
-
- @param [in] pSocket Address of the socket structure.
+ @param [in] pSocket Address of an ::ESL_SOCKET structure.
@retval EFI_SUCCESS The connection was successfully established.
@retval EFI_NOT_READY The connection is in progress, call this routine again.
@retval Others The connection attempt failed.
**/
+typedef
EFI_STATUS
-EslTcpConnectPoll4 (
- IN DT_SOCKET * pSocket
+(* PFN_API_CONNECT_POLL) (
+ IN ESL_SOCKET * pSocket
);
/**
- Connect to a remote system via the network.
+ Attempt to connect to a remote TCP port
- The ::TcpConnectStart4= routine starts the connection processing
- for a TCP4 port.
+ This routine starts the connection processing for a SOCK_STREAM
+ or SOCK_SEQPAKCET socket using the TCP network layer.
- @param [in] pSocket Address of the socket structure.
+ This routine is called by ::EslSocketConnect to initiate the TCP
+ network specific connect operations.
+
+ @param [in] pSocket Address of an ::ESL_SOCKET structure.
- @param [in] pSockAddr Network address of the remote system.
-
- @param [in] SockAddrLength Length in bytes of the network address.
-
@retval EFI_SUCCESS The connection was successfully established.
@retval EFI_NOT_READY The connection is in progress, call this routine again.
@retval Others The connection attempt failed.
**/
+typedef
EFI_STATUS
-EslTcpConnectStart4 (
- IN DT_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
+(* PFN_API_CONNECT_START) (
+ IN ESL_SOCKET * pSocket
);
/**
- Initialize the TCP4 service.
-
- This routine initializes the TCP4 service after its service binding
- protocol was located on a controller.
+ Get the local socket address
- @param [in] pService DT_SERVICE structure address
+ @param [in] pPort Address of an ::ESL_PORT structure.
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
+ @param [out] pAddress Network address to receive the local system address
**/
-EFI_STATUS
-EFIAPI
-EslTcpInitialize4 (
- IN DT_SERVICE * pService
+typedef
+VOID
+(* PFN_API_LOCAL_ADDR_GET) (
+ IN ESL_PORT * pPort,
+ OUT struct sockaddr * pAddress
);
/**
- Get the local socket address
+ Set the local port address.
- @param [in] pSocket Address of the socket structure.
+ This routine sets the local port address.
- @param [out] pAddress Network address to receive the local system address
+ This support routine is called by ::EslSocketPortAllocate.
- @param [in,out] pAddressLength Length of the local network address structure
+ @param [in] ppPort Address of an ESL_PORT structure
+ @param [in] pSockAddr Address of a sockaddr structure that contains the
+ connection point on the local machine. An IPv4 address
+ of INADDR_ANY specifies that the connection is made to
+ all of the network stacks on the platform. Specifying a
+ specific IPv4 address restricts the connection to the
+ network stack supporting that address. Specifying zero
+ for the port causes the network layer to assign a port
+ number from the dynamic range. Specifying a specific
+ port number causes the network layer to use that port.
+ @param [in] bBindTest TRUE = run bind testing
- @retval EFI_SUCCESS - Address available
- @retval Other - Failed to get the address
+ @retval EFI_SUCCESS The operation was successful
-**/
+ **/
+typedef
EFI_STATUS
-EslTcpGetLocalAddress4 (
- IN DT_SOCKET * pSocket,
- OUT struct sockaddr * pAddress,
- IN OUT socklen_t * pAddressLength
+(* PFN_API_LOCAL_ADDR_SET) (
+ IN ESL_PORT * pPort,
+ IN CONST struct sockaddr * pSockAddr,
+ IN BOOLEAN bBindTest
);
/**
- Get the remote socket address
-
- @param [in] pSocket Address of the socket structure.
-
- @param [out] pAddress Network address to receive the remote system address
+ Determine if the socket is configured.
- @param [in,out] pAddressLength Length of the remote network address structure
- @retval EFI_SUCCESS - Address available
- @retval Other - Failed to get the address
+ @param [in] pSocket Address of a ESL_SOCKET structure
+
+ @retval EFI_SUCCESS - The port is connected
+ @retval EFI_NOT_STARTED - The port is not connected
-**/
-EFI_STATUS
-EslTcpGetRemoteAddress4 (
- IN DT_SOCKET * pSocket,
- OUT struct sockaddr * pAddress,
- IN OUT socklen_t * pAddressLength
+ **/
+ typedef
+ EFI_STATUS
+ (* PFN_API_IS_CONFIGURED) (
+ IN ESL_SOCKET * pSocket
);
/**
Establish the known port to listen for network connections.
- The ::Tcp4Listen routine places the port into a state that enables connection
- attempts. Connections are placed into FIFO order in a queue to be serviced
- by the application. The application calls the ::Tcp4Accept routine to remove
- the next connection from the queue and get the associated socket. The
- <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html">POSIX</a>
- documentation for the listen routine is available online for reference.
-
@param [in] pSocket Address of the socket structure.
-
+
@retval EFI_SUCCESS - Socket successfully created
@retval Other - Failed to enable the socket for listen
**/
+typedef
EFI_STATUS
-EslTcpListen4 (
- IN DT_SOCKET * pSocket
+(* PFN_API_LISTEN) (
+ IN ESL_SOCKET * pSocket
);
/**
- Process the connection attempt
-
- A system has initiated a connection attempt with a socket in the
- listen state. Attempt to complete the connection.
+ Get the option value
- @param Event The listeen completion event
+ Retrieve the protocol options one at a time by name.
- @param pPort The DT_PORT structure address
-
-**/
-VOID
-EslTcpListenComplete4 (
- IN EFI_EVENT Event,
- IN DT_PORT * pPort
- );
+ @param [in] pSocket Address of a ESL_SOCKET structure
+ @param [in] OptionName Name of the option
+ @param [out] ppOptionData Buffer to receive address of option value
+ @param [out] pOptionLength Buffer to receive the option length
-/**
- Allocate and initialize a DT_PORT structure.
-
- @param [in] pSocket Address of the socket structure.
- @param [in] pService Address of the DT_SERVICE structure.
- @param [in] ChildHandle TCP4 child handle
- @param [in] pIpAddress Buffer containing IP4 network address of the local host
- @param [in] PortNumber Tcp4 port number
- @param [in] DebugFlags Flags for debug messages
- @param [out] ppPort Buffer to receive new DT_PORT structure address
-
- @retval EFI_SUCCESS - Socket successfully created
+ @retval EFI_SUCCESS - Socket data successfully received
**/
+typedef
EFI_STATUS
-EslTcpPortAllocate4 (
- IN DT_SOCKET * pSocket,
- IN DT_SERVICE * pService,
- IN EFI_HANDLE ChildHandle,
- IN CONST UINT8 *pIpAddress,
- IN UINT16 PortNumber,
- IN UINTN DebugFlags,
- OUT DT_PORT ** ppPort
+(* PFN_API_OPTION_GET) (
+ IN ESL_SOCKET * pSocket,
+ IN int OptionName,
+ OUT CONST void ** __restrict ppOptionData,
+ OUT socklen_t * __restrict pOptionLength
);
/**
- Close a TCP4 port.
+ Set the option value
- This routine releases the resources allocated by
- ::TcpPortAllocate4().
-
- @param [in] pPort Address of the port structure.
+ Adjust the protocol options one at a time by name.
- @retval EFI_SUCCESS The port is closed
- @retval other Port close error
+ @param [in] pSocket Address of a ESL_SOCKET structure
+ @param [in] OptionName Name of the option
+ @param [in] pOptionValue Buffer containing the option value
+ @param [in] OptionLength Length of the buffer in bytes
-**/
+ @retval EFI_SUCCESS - Option successfully set
+
+ **/
+typedef
EFI_STATUS
-EslTcpPortClose4 (
- IN DT_PORT * pPort
+(* PFN_API_OPTION_SET) (
+ IN ESL_SOCKET * pSocket,
+ IN int OptionName,
+ IN CONST void * pOptionValue,
+ IN socklen_t OptionLength
);
/**
- Process the port close completion
+ Free a receive packet
+
+ This routine performs the network specific operations necessary
+ to free a receive packet.
- @param Event The close completion event
+ This routine is called by ::EslSocketPortCloseTxDone to free a
+ receive packet.
- @param pPort The DT_PORT structure address
+ @param [in] pPacket Address of an ::ESL_PACKET structure.
+ @param [in, out] pRxBytes Address of the count of RX bytes
**/
+typedef
VOID
-EslTcpPortCloseComplete4 (
- IN EFI_EVENT Event,
- IN DT_PORT * pPort
+(* PFN_API_PACKET_FREE) (
+ IN ESL_PACKET * pPacket,
+ IN OUT size_t * pRxBytes
);
/**
- Port close state 3
+ Initialize the network specific portions of an ::ESL_PORT structure.
- Continue the close operation after the receive is complete.
+ This routine initializes the network specific portions of an
+ ::ESL_PORT structure for use by the socket.
- @param [in] pPort Address of the port structure.
+ This support routine is called by ::EslSocketPortAllocate
+ to connect the socket with the underlying network adapter
+ running the IPv4 protocol.
- @retval EFI_SUCCESS The port is closed
- @retval EFI_NOT_READY The port is still closing
- @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,
- most likely the routine was called already.
+ @param [in] ppPort Address of an ESL_PORT structure
+ @param [in] DebugFlags Flags for debug messages
-**/
+ @retval EFI_SUCCESS - Socket successfully created
+
+ **/
+typedef
EFI_STATUS
-EslTcpPortCloseRxDone4 (
- IN DT_PORT * pPort
+(* PFN_API_PORT_ALLOC) (
+ IN ESL_PORT * pPort,
+ IN UINTN DebugFlags
);
/**
- Start the close operation on a TCP4 port.
+ Close a network specific port.
- @param [in] pPort Address of the port structure.
- @param [in] bAbort Set TRUE to abort active transfers
- @param [in] DebugFlags Flags for debug messages
+ This routine releases the resources allocated by the
+ network specific PortAllocate routine.
+
+ This routine is called by ::EslSocketPortCloseRxDone as
+ the last step of closing processing.
+ See the \ref PortCloseStateMachine section.
+
+ @param [in] pPort Address of an ::ESL_PORT structure.
+
+ @retval EFI_SUCCESS The port is closed
+ @retval other Port close error
**/
+typedef
EFI_STATUS
-EslTcpPortCloseStart4 (
- IN DT_PORT * pPort,
- IN BOOLEAN bAbort,
- IN UINTN DebugFlags
+(* PFN_API_PORT_CLOSE) (
+ IN ESL_PORT * pPort
);
/**
- Port close state 2
+ Perform the network specific close operation on the port.
- Continue the close operation after the transmission is complete.
+ This routine performs the network specific operation to
+ shutdown receive operations on the port.
- @param [in] pPort Address of the port structure.
+ This routine is called by the ::EslSocketPortCloseTxDone
+ routine after the port completes all of the transmission.
+ @param [in] pPort Address of an ::ESL_PORT structure.
+
+ @retval EFI_SUCCESS The port is closed, not normally returned
@retval EFI_NOT_READY The port is still closing
@retval EFI_ALREADY_STARTED Error, the port is in the wrong state,
most likely the routine was called already.
**/
+typedef
EFI_STATUS
-EslTcpPortCloseTxDone4 (
- IN DT_PORT * pPort
+(* PFN_API_PORT_CLOSE_OP) (
+ IN ESL_PORT * pPort
);
/**
Receive data from a network connection.
+ This routine attempts to return buffered data to the caller. The
+ data is removed from the urgent queue if the message flag MSG_OOB
+ is specified, otherwise data is removed from the normal queue.
+ See the \ref ReceiveEngine section.
+
+ This routine is called by ::EslSocketReceive to handle the network
+ specific receive operation.
+
+ @param [in] pPort Address of an ::ESL_PORT structure.
- @param [in] pSocket Address of a DT_SOCKET structure
+ @param [in] pPacket Address of an ::ESL_PACKET structure.
- @param [in] Flags Message control flags
+ @param [in] pbConsumePacket Address of a BOOLEAN indicating if the packet is to be consumed
@param [in] BufferLength Length of the the buffer
@@ -786,550 +668,850 @@ EslTcpPortCloseTxDone4 (
@param [out] pAddress Network address to receive the remote system address
- @param [in,out] pAddressLength Length of the remote network address structure
+ @param [out] pSkipBytes Address to receive the number of bytes skipped
- @retval EFI_SUCCESS - Socket data successfully received
+ @return Returns the address of the next free byte in the buffer.
**/
-EFI_STATUS
-EslTcpReceive4 (
- IN DT_SOCKET * pSocket,
- IN INT32 Flags,
+typedef
+UINT8 *
+(* PFN_API_RECEIVE) (
+ IN ESL_PORT * pPort,
+ IN ESL_PACKET * pPacket,
+ IN BOOLEAN * pbConsumePacket,
IN size_t BufferLength,
IN UINT8 * pBuffer,
OUT size_t * pDataLength,
OUT struct sockaddr * pAddress,
- IN OUT socklen_t * pAddressLength
+ OUT size_t * pSkipBytes
);
/**
- Cancel the receive operations
+ Get the remote socket address
- @param [in] pSocket Address of a DT_SOCKET structure
-
- @retval EFI_SUCCESS - The cancel was successful
+ @param [in] pPort Address of an ::ESL_PORT structure.
- **/
-EFI_STATUS
-EslTcpRxCancel4 (
- IN DT_SOCKET * pSocket
+ @param [out] pAddress Network address to receive the remote system address
+
+**/
+typedef
+VOID
+(* PFN_API_REMOTE_ADDR_GET) (
+ IN ESL_PORT * pPort,
+ OUT struct sockaddr * pAddress
);
/**
- Process the receive completion
+ Set the remote address
- Buffer the data that was just received.
+ This routine sets the remote address in the port.
- @param Event The receive completion event
+ This routine is called by ::EslSocketConnect to specify the
+ remote network address.
- @param pPort The DT_PORT structure address
+ @param [in] pPort Address of an ::ESL_PORT structure.
-**/
-VOID
-EslTcpRxComplete4 (
- IN EFI_EVENT Event,
- IN DT_PORT * pPort
- );
+ @param [in] pSockAddr Network address of the remote system.
-/**
- Start a receive operation
+ @param [in] SockAddrLength Length in bytes of the network address.
- @param [in] pPort Address of the DT_PORT structure.
+ @retval EFI_SUCCESS The operation was successful
**/
-VOID
-EslTcpRxStart4 (
- IN DT_PORT * pPort
+typedef
+EFI_STATUS
+(* PFN_API_REMOTE_ADDR_SET) (
+ IN ESL_PORT * pPort,
+ IN CONST struct sockaddr * pSockAddr,
+ IN socklen_t SockAddrLength
);
/**
- Shutdown the TCP4 service.
+ Process the receive completion
+
+ This routine handles the receive completion event.
- This routine undoes the work performed by ::TcpInitialize4.
+ This routine is called by the low level network driver when
+ data is received.
- @param [in] pService DT_SERVICE structure address
+ @param [in] Event The receive completion event
+
+ @param [in] pIo The address of an ::ESL_IO_MGMT structure
**/
+typedef
VOID
-EFIAPI
-EslTcpShutdown4 (
- IN DT_SERVICE * pService
+(* PFN_API_RX_COMPLETE) (
+ IN EFI_EVENT Event,
+ IN ESL_IO_MGMT * pIo
);
/**
- Determine if the socket is configured.
+ Start a receive operation
+ This routine prepares a packet for the receive operation.
+ See the \ref ReceiveEngine section.
- @param [in] pSocket Address of a DT_SOCKET structure
-
- @retval EFI_SUCCESS - The port is connected
- @retval EFI_NOT_STARTED - The port is not connected
+ This support routine is called by EslSocketRxStart.
+
+ @param [in] pPort Address of an ::ESL_PORT structure.
+ @param [in] pIo Address of an ::ESL_IO_MGMT structure.
**/
- EFI_STATUS
- EslTcpSocketIsConfigured4 (
- IN DT_SOCKET * pSocket
+typedef
+VOID
+(* PFN_API_RX_START) (
+ IN ESL_PORT * pPort,
+ IN ESL_IO_MGMT * pIo
);
/**
Buffer data for transmission over a network connection.
- This routine is called by the socket layer API to buffer
- data for transmission. When necessary, this routine will
- start the transmit engine that performs the data transmission
- on the network connection.
+ @param [in] pSocket Address of a ESL_SOCKET structure
- @param [in] pSocket Address of a DT_SOCKET structure
-
@param [in] Flags Message control flags
-
+
@param [in] BufferLength Length of the the buffer
-
+
@param [in] pBuffer Address of a buffer to receive the data.
-
+
@param [in] pDataLength Number of received data bytes in the buffer.
+ @param [in] pAddress Network address of the remote system address
+
+ @param [in] AddressLength Length of the remote network address structure
+
@retval EFI_SUCCESS - Socket data successfully buffered
- **/
+**/
+typedef
EFI_STATUS
-EslTcpTxBuffer4 (
- IN DT_SOCKET * pSocket,
+(* PFN_API_TRANSMIT) (
+ IN ESL_SOCKET * pSocket,
IN int Flags,
IN size_t BufferLength,
IN CONST UINT8 * pBuffer,
- OUT size_t * pDataLength
+ OUT size_t * pDataLength,
+ IN const struct sockaddr * pAddress,
+ IN socklen_t AddressLength
);
/**
- Process the normal data transmit completion
+ Process the transmit completion
+
+ This routine calls ::EslSocketTxComplete to handle the
+ transmit completion.
+
+ This routine is called by the network layers upon the completion
+ of a transmit operation.
- @param Event The normal transmit completion event
+ @param [in] Event The urgent transmit completion event
- @param pPort The DT_PORT structure address
+ @param [in] pIo The ESL_IO_MGMT structure address
**/
+typedef
VOID
-EslTcpTxComplete4 (
+(* PFN_API_TX_COMPLETE) (
IN EFI_EVENT Event,
- IN DT_PORT * pPort
+ IN ESL_IO_MGMT * pIo
);
/**
- Process the urgent data transmit completion
+ Socket type control structure
+
+ This driver uses this structure to define the API for the socket type.
+**/
+typedef struct {
+ CONST CHAR8 * pName; ///< Protocol name
+ int DefaultProtocol; ///< Default protocol
+ UINTN ConfigDataOffset; ///< Offset in ::ESL_PORT to the configuration data
+ UINTN ServiceListOffset; ///< Offset in ::ESL_LAYER for the list of services
+ socklen_t MinimumAddressLength; ///< Minimum address length in bytes
+ socklen_t AddressLength; ///< Address length in bytes
+ sa_family_t AddressFamily; ///< Address family
+ UINTN RxPacketBytes; ///< Length of the RX packet allocation
+ UINTN RxZeroBytes; ///< Number of bytes to zero in RX packet
+ UINTN RxBufferOffset; ///< Offset of buffer address in ESL_IO_MGMT structure
+ BOOLEAN bOobSupported; ///< TRUE if out-of-band messages are supported
+ int BindTestErrno; ///< errno value if EslSocketBindTest fails
+ PFN_API_ACCEPT pfnAccept; ///< Accept a network connection
+ PFN_API_CONNECT_POLL pfnConnectPoll; ///< Poll for connection complete
+ PFN_API_CONNECT_START pfnConnectStart; ///< Start the connection to a remote system
+ PFN_API_IS_CONFIGURED pfnIsConfigured; ///< Determine if the socket is configured
+ PFN_API_LOCAL_ADDR_GET pfnLocalAddrGet; ///< Get the local address
+ PFN_API_LOCAL_ADDR_SET pfnLocalAddrSet; ///< Set the local address
+ PFN_API_LISTEN pfnListen; ///< Listen for connections on known server port
+ PFN_API_OPTION_GET pfnOptionGet; ///< Get the option value
+ PFN_API_OPTION_SET pfnOptionSet; ///< Set the option value
+ PFN_API_PACKET_FREE pfnPacketFree; ///< Free the receive packet
+ PFN_API_PORT_ALLOC pfnPortAllocate; ///< Allocate the network specific resources for the port
+ PFN_API_PORT_CLOSE pfnPortClose; ///< Close the network specific resources for the port
+ PFN_API_PORT_CLOSE_OP pfnPortCloseOp; ///< Perform the close operation on the port
+ BOOLEAN bPortCloseComplete; ///< TRUE = Close is complete after close operation
+ PFN_API_RECEIVE pfnReceive; ///< Attempt to receive some data
+ PFN_API_REMOTE_ADDR_GET pfnRemoteAddrGet; ///< Get remote address
+ PFN_API_REMOTE_ADDR_SET pfnRemoteAddrSet; ///< Set the remote system address
+ PFN_API_RX_COMPLETE pfnRxComplete; ///< RX completion
+ PFN_API_RX_START pfnRxStart; ///< Start a network specific receive operation
+ PFN_API_TRANSMIT pfnTransmit; ///< Attempt to buffer a packet for transmit
+ PFN_API_TX_COMPLETE pfnTxComplete; ///< TX completion for normal data
+ PFN_API_TX_COMPLETE pfnTxOobComplete; ///< TX completion for urgent data
+} ESL_PROTOCOL_API;
- @param Event The urgent transmit completion event
- @param pPort The DT_PORT structure address
+/**
+ Socket control structure
+ The driver uses this structure to manage the socket.
**/
-VOID
-EslTcpTxOobComplete4 (
- IN EFI_EVENT Event,
- IN DT_PORT * pPort
- );
+typedef struct _ESL_SOCKET {
+ UINTN Signature; ///< Structure identification
-/**
- Transmit data using a network connection.
+ //
+ // Protocol binding
+ //
+ EFI_SOCKET_PROTOCOL SocketProtocol; ///< Socket protocol declaration
+ CONST ESL_PROTOCOL_API * pApi; ///< API for the protocol
+ //
+ // Socket management
+ //
+ ESL_SOCKET * pNext; ///< Next socket in the list of sockets
+ int errno; ///< Error information for this socket
+ EFI_STATUS Status; ///< Asyncronous error information for this socket
+ SOCKET_STATE State; ///< Socket state
+ UINT32 DebugFlags; ///< Debug flags
- @param [in] pPort Address of a DT_PORT structure
- @param [in] pToken Address of either the OOB or normal transmit token
- @param [in] ppQueueHead Transmit queue head address
- @param [in] ppQueueTail Transmit queue tail address
- @param [in] ppPacket Active transmit packet address
+ //
+ // Socket options
+ //
+ BOOLEAN bListenCalled; ///< TRUE if listen was successfully called
+ BOOLEAN bOobInLine; ///< TRUE if out-of-band messages are to be received inline with normal data
+ BOOLEAN bIncludeHeader; ///< TRUE if including the IP header
- **/
-VOID
-EslTcpTxStart4 (
- IN DT_PORT * pPort,
- IN EFI_TCP4_IO_TOKEN * pToken,
- IN DT_PACKET ** ppQueueHead,
- IN DT_PACKET ** ppQueueTail,
- IN DT_PACKET ** ppPacket
- );
+ //
+ // Socket data
+ //
+ int Domain; ///< Specifies family of protocols
+ int Type; ///< Specifies how to make network connection
+ int Protocol; ///< Specifies lower layer protocol to use
+ BOOLEAN bConfigured; ///< Set after the socket is configured
-//------------------------------------------------------------------------------
-// Udp4 Routines
-//------------------------------------------------------------------------------
+ BOOLEAN bRxDisable; ///< Receive disabled via shutdown
+ size_t RxBytes; ///< Total Rx bytes
+ size_t RxOobBytes; ///< Urgent Rx bytes
+ EFI_STATUS RxError; ///< Error during receive
+
+ BOOLEAN bTxDisable; ///< Transmit disabled via shutdown
+ size_t TxBytes; ///< Normal Tx bytes
+ size_t TxOobBytes; ///< Urgent Tx bytes
+ EFI_STATUS TxError; ///< Error during transmit
+
+ //
+ // Pending connection data
+ //
+ BOOLEAN bConnected; ///< Set when connected, cleared by poll
+ EFI_STATUS ConnectStatus; ///< Connection status
+ UINTN MaxFifoDepth; ///< Maximum FIFO depth
+ UINTN FifoDepth; ///< Number of sockets in the FIFO
+ ESL_SOCKET * pFifoHead; ///< Head of the FIFO
+ ESL_SOCKET * pFifoTail; ///< Tail of the FIFO
+ ESL_SOCKET * pNextConnection; ///< Link in the FIFO
+
+ //
+ // Network use
+ //
+ ESL_PORT * pPortList; ///< List of ports managed by this socket
+ EFI_EVENT WaitAccept; ///< Wait for accept completion
+
+ //
+ // Receive data management
+ //
+ UINT32 MaxRxBuf; ///< Maximum size of the receive buffer
+ struct timeval RxTimeout; ///< Receive timeout
+ ESL_PACKET * pRxFree; ///< Free packet list
+ ESL_PACKET * pRxOobPacketListHead;///< Urgent data list head
+ ESL_PACKET * pRxOobPacketListTail;///< Urgent data list tail
+ ESL_PACKET * pRxPacketListHead; ///< Normal data list head
+ ESL_PACKET * pRxPacketListTail; ///< Normal data list tail
+
+ //
+ // Transmit data management
+ //
+ UINTN TxPacketOffset; ///< Offset for data pointer in ::ESL_PACKET
+ UINTN TxTokenEventOffset; ///< Offset to the Event in the TX token
+ UINTN TxTokenOffset; ///< Offset for data pointer in TX token
+ UINT32 MaxTxBuf; ///< Maximum size of the transmit buffer
+ ESL_PACKET * pTxOobPacketListHead;///< Urgent data list head
+ ESL_PACKET * pTxOobPacketListTail;///< Urgent data list tail
+ ESL_PACKET * pTxPacketListHead; ///< Normal data list head
+ ESL_PACKET * pTxPacketListTail; ///< Normal data list tail
+}GCC_ESL_SOCKET;
+
+#define SOCKET_FROM_PROTOCOL(a) CR (a, ESL_SOCKET, SocketProtocol, SOCKET_SIGNATURE) ///< Locate ESL_SOCKET from protocol
/**
- Bind a name to a socket.
+ Socket layer control structure
- The ::UdpBind4 routine connects a name to a UDP4 stack on the local machine.
+ The driver uses this structure to manage the driver.
+**/
+typedef struct {
+ UINTN Signature; ///< Structure identification
- @param [in] pSocket Address of the socket structure.
+ //
+ // Service binding interface
+ //
+ CONST EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Driver's binding
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address. Specifying zero
- for the port causes the network layer to assign a port
- number from the dynamic range. Specifying a specific
- port number causes the network layer to use that port.
+ //
+ // Image data
+ //
+ EFI_HANDLE ImageHandle; ///< Image handle
- @param [in] SockAddrLen Specifies the length in bytes of the sockaddr structure.
+ //
+ // Network services
+ //
+ ESL_SERVICE * pIp4List; ///< List of Ip4 services
+ ESL_SERVICE * pTcp4List; ///< List of Tcp4 services
+ ESL_SERVICE * pUdp4List; ///< List of Udp4 services
- @retval EFI_SUCCESS - Socket successfully created
+ //
+ // Socket management
+ //
+ ESL_SOCKET * pSocketList; ///< List of sockets
+} ESL_LAYER;
- **/
-EFI_STATUS
-EslUdpBind4 (
- IN DT_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
+#define LAYER_FROM_SERVICE(a) CR (a, ESL_LAYER, ServiceBinding, LAYER_SIGNATURE) ///< Locate ESL_LAYER from service binding
-/**
- Initialize the UDP4 service.
+//------------------------------------------------------------------------------
+// Data
+//------------------------------------------------------------------------------
+
+extern ESL_LAYER mEslLayer;
- This routine initializes the UDP4 service after its service binding
- protocol was located on a controller.
+extern CONST ESL_PROTOCOL_API cEslIp4Api;
+extern CONST ESL_PROTOCOL_API cEslTcp4Api;
+extern CONST ESL_PROTOCOL_API cEslUdp4Api;
- @param [in] pService DT_SERVICE structure address
+extern CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding;
+
+//------------------------------------------------------------------------------
+// Socket Support Routines
+//------------------------------------------------------------------------------
+
+/**
+ Allocate and initialize a ESL_SOCKET structure.
+
+ This support function allocates an ::ESL_SOCKET structure
+ and installs a protocol on ChildHandle. If pChildHandle is a
+ pointer to NULL, then a new handle is created and returned in
+ pChildHandle. If pChildHandle is not a pointer to NULL, then
+ the protocol installs on the existing pChildHandle.
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
+ @param [in, out] pChildHandle Pointer to the handle of the child to create.
+ If it is NULL, then a new handle is created.
+ If it is a pointer to an existing UEFI handle,
+ then the protocol is added to the existing UEFI
+ handle.
+ @param [in] DebugFlags Flags for debug messages
+ @param [in, out] ppSocket The buffer to receive an ::ESL_SOCKET structure address.
+ @retval EFI_SUCCESS The protocol was added to ChildHandle.
+ @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
+ the child
+ @retval other The child handle was not created
+
**/
EFI_STATUS
EFIAPI
-EslUdpInitialize4 (
- IN DT_SERVICE * pService
+EslSocketAllocate (
+ IN OUT EFI_HANDLE * pChildHandle,
+ IN UINTN DebugFlags,
+ IN OUT ESL_SOCKET ** ppSocket
);
/**
- Allocate and initialize a DT_PORT structure.
+ Test the bind configuration.
- @param [in] pSocket Address of the socket structure.
- @param [in] pService Address of the DT_SERVICE structure.
- @param [in] ChildHandle Udp4 child handle
- @param [in] pIpAddress Buffer containing IP4 network address of the local host
- @param [in] PortNumber Udp4 port number
- @param [in] DebugFlags Flags for debug messages
- @param [out] ppPort Buffer to receive new DT_PORT structure address
+ @param [in] pPort Address of the ::ESL_PORT structure.
+ @param [in] ErrnoValue errno value if test fails
- @retval EFI_SUCCESS - Socket successfully created
+ @retval EFI_SUCCESS The connection was successfully established.
+ @retval Others The connection attempt failed.
**/
EFI_STATUS
-EslUdpPortAllocate4 (
- IN DT_SOCKET * pSocket,
- IN DT_SERVICE * pService,
- IN EFI_HANDLE ChildHandle,
- IN CONST UINT8 * pIpAddress,
- IN UINT16 PortNumber,
- IN UINTN DebugFlags,
- OUT DT_PORT ** ppPort
+EslSocketBindTest (
+ IN ESL_PORT * pPort,
+ IN int ErrnoValue
);
/**
- Close a UDP4 port.
+ Copy a fragmented buffer into a destination buffer.
- This routine releases the resources allocated by
- ::UdpPortAllocate4().
-
- @param [in] pPort Address of the port structure.
+ This support routine copies a fragmented buffer to the caller specified buffer.
- @retval EFI_SUCCESS The port is closed
- @retval other Port close error
+ This routine is called by ::EslIp4Receive and ::EslUdp4Receive.
-**/
-EFI_STATUS
-EslUdpPortClose4 (
- IN DT_PORT * pPort
- );
+ @param [in] FragmentCount Number of fragments in the table
-/**
- Start the close operation on a UDP4 port, state 1.
+ @param [in] pFragmentTable Address of an EFI_IP4_FRAGMENT_DATA structure
- Closing a port goes through the following states:
- 1. Port close starting - Mark the port as closing and wait for transmission to complete
- 2. Port TX close done - Transmissions complete, close the port and abort the receives
- 3. Port RX close done - Receive operations complete, close the port
- 4. Port closed - Release the port resources
-
- @param [in] pPort Address of the port structure.
- @param [in] bCloseNow Set TRUE to abort active transfers
- @param [in] DebugFlags Flags for debug messages
+ @param [in] BufferLength Length of the the buffer
- @retval EFI_SUCCESS The port is closed, not normally returned
- @retval EFI_NOT_READY The port has started the closing process
- @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,
- most likely the routine was called already.
+ @param [in] pBuffer Address of a buffer to receive the data.
+
+ @param [in] pDataLength Number of received data bytes in the buffer.
+
+ @return Returns the address of the next free byte in the buffer.
**/
-EFI_STATUS
-EslUdpPortCloseStart4 (
- IN DT_PORT * pPort,
- IN BOOLEAN bCloseNow,
- IN UINTN DebugFlags
+UINT8 *
+EslSocketCopyFragmentedBuffer (
+ IN UINT32 FragmentCount,
+ IN EFI_IP4_FRAGMENT_DATA * pFragmentTable,
+ IN size_t BufferLength,
+ IN UINT8 * pBuffer,
+ OUT size_t * pDataLength
);
/**
- Port close state 2
+ Free the ESL_IO_MGMT event and structure
- Continue the close operation after the transmission is complete.
+ This support routine walks the free list to close the event in
+ the ESL_IO_MGMT structure and remove the structure from the free
+ list.
- @param [in] pPort Address of the port structure.
+ See the \ref TransmitEngine section.
- @retval EFI_SUCCESS The port is closed, not normally returned
- @retval EFI_NOT_READY The port is still closing
- @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,
- most likely the routine was called already.
+ @param [in] pPort Address of an ::ESL_PORT structure
+ @param [in] ppFreeQueue Address of the free queue head
+ @param [in] DebugFlags Flags for debug messages
+ @param [in] pEventName Zero terminated string containing the event name
+
+ @retval EFI_SUCCESS - The structures were properly initialized
**/
EFI_STATUS
-EslUdpPortCloseTxDone4 (
- IN DT_PORT * pPort
+EslSocketIoFree (
+ IN ESL_PORT * pPort,
+ IN ESL_IO_MGMT ** ppFreeQueue,
+ IN UINTN DebugFlags,
+ IN CHAR8 * pEventName
);
/**
- Connect to a remote system via the network.
+ Initialize the ESL_IO_MGMT structures
- The ::UdpConnectStart4= routine sets the remote address for the connection.
+ This support routine initializes the ESL_IO_MGMT structure and
+ places them on to a free list.
- @param [in] pSocket Address of the socket structure.
+ This routine is called by the PortAllocate routines to prepare
+ the transmit engines. See the \ref TransmitEngine section.
- @param [in] pSockAddr Network address of the remote system.
-
- @param [in] SockAddrLength Length in bytes of the network address.
-
- @retval EFI_SUCCESS The connection was successfully established.
- @retval EFI_NOT_READY The connection is in progress, call this routine again.
- @retval Others The connection attempt failed.
+ @param [in] pPort Address of an ::ESL_PORT structure
+ @param [in, out] ppIo Address containing the first structure address. Upon
+ return this buffer contains the next structure address.
+ @param [in] TokenCount Number of structures to initialize
+ @param [in] ppFreeQueue Address of the free queue head
+ @param [in] DebugFlags Flags for debug messages
+ @param [in] pEventName Zero terminated string containing the event name
+ @param [in] pfnCompletion Completion routine address
- **/
+ @retval EFI_SUCCESS - The structures were properly initialized
+
+**/
EFI_STATUS
-EslUdpConnect4 (
- IN DT_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
+EslSocketIoInit (
+ IN ESL_PORT * pPort,
+ IN ESL_IO_MGMT ** ppIo,
+ IN UINTN TokenCount,
+ IN ESL_IO_MGMT ** ppFreeQueue,
+ IN UINTN DebugFlags,
+ IN CHAR8 * pEventName,
+ IN EFI_EVENT_NOTIFY pfnCompletion
);
/**
- Get the local socket address
+ Determine if the socket is configured
- @param [in] pSocket Address of the socket structure.
+ This support routine is called to determine if the socket if the
+ configuration call was made to the network layer. The following
+ routines call this routine to verify that they may be successful
+ in their operations:
+ <ul>
+ <li>::EslSocketGetLocalAddress</li>
+ <li>::EslSocketGetPeerAddress</li>
+ <li>::EslSocketPoll</li>
+ <li>::EslSocketReceive</li>
+ <li>::EslSocketTransmit</li>
+ </ul>
- @param [out] pAddress Network address to receive the local system address
+ @param [in] pSocket Address of an ::ESL_SOCKET structure
- @param [in,out] pAddressLength Length of the local network address structure
-
- @retval EFI_SUCCESS - Address available
- @retval Other - Failed to get the address
+ @retval EFI_SUCCESS - The socket is configured
**/
EFI_STATUS
-EslUdpGetLocalAddress4 (
- IN DT_SOCKET * pSocket,
- OUT struct sockaddr * pAddress,
- IN OUT socklen_t * pAddressLength
+EslSocketIsConfigured (
+ IN ESL_SOCKET * pSocket
);
/**
- Get the remote socket address
-
- @param [in] pSocket Address of the socket structure.
+ Allocate a packet for a receive or transmit operation
- @param [out] pAddress Network address to receive the remote system address
+ This support routine is called by ::EslSocketRxStart and the
+ network specific TxBuffer routines to get buffer space for the
+ next operation.
- @param [in,out] pAddressLength Length of the remote network address structure
+ @param [in] ppPacket Address to receive the ::ESL_PACKET structure
+ @param [in] LengthInBytes Length of the packet structure
+ @param [in] ZeroBytes Length of packet to zero
+ @param [in] DebugFlags Flags for debug messages
- @retval EFI_SUCCESS - Address available
- @retval Other - Failed to get the address
+ @retval EFI_SUCCESS - The packet was allocated successfully
-**/
+ **/
EFI_STATUS
-EslUdpGetRemoteAddress4 (
- IN DT_SOCKET * pSocket,
- OUT struct sockaddr * pAddress,
- IN OUT socklen_t * pAddressLength
+EslSocketPacketAllocate (
+ IN ESL_PACKET ** ppPacket,
+ IN size_t LengthInBytes,
+ IN size_t ZeroBytes,
+ IN UINTN DebugFlags
);
/**
- Receive data from a network connection.
-
- To minimize the number of buffer copies, the ::UdpRxComplete4
- routine queues the UDP4 driver's buffer to a list of datagrams
- waiting to be received. The socket driver holds on to the
- buffers from the UDP4 driver until the application layer requests
- the data or the socket is closed.
+ Free a packet used for receive or transmit operation
- The application calls this routine in the socket layer to
- receive datagrams from one or more remote systems. This routine
- removes the next available datagram from the list of datagrams
- and copies the data from the UDP4 driver's buffer into the
- application's buffer. The UDP4 driver's buffer is then returned.
+ This support routine is called by the network specific Close
+ and TxComplete routines and during error cases in RxComplete
+ and TxBuffer. Note that the network layers typically place
+ receive packets on the ESL_SOCKET::pRxFree list for reuse.
- @param [in] pSocket Address of a DT_SOCKET structure
+ @param [in] pPacket Address of an ::ESL_PACKET structure
+ @param [in] DebugFlags Flags for debug messages
- @param [in] Flags Message control flags
+ @retval EFI_SUCCESS - The packet was allocated successfully
- @param [in] BufferLength Length of the the buffer
+ **/
+EFI_STATUS
+EslSocketPacketFree (
+ IN ESL_PACKET * pPacket,
+ IN UINTN DebugFlags
+ );
- @param [in] pBuffer Address of a buffer to receive the data.
+/**
+ Allocate and initialize a ESL_PORT structure.
- @param [in] pDataLength Number of received data bytes in the buffer.
+ This routine initializes an ::ESL_PORT structure for use by
+ the socket. This routine calls a routine via
+ ESL_PROTOCOL_API::pfnPortAllocate to initialize the network
+ specific resources. The resources are released later by the
+ \ref PortCloseStateMachine.
- @param [out] pAddress Network address to receive the remote system address
+ This support routine is called by ::EslSocketBind and
+ ::EslTcp4ListenComplete to connect the socket with the
+ underlying network adapter to the socket.
- @param [in,out] pAddressLength Length of the remote network address structure
+ @param [in] pSocket Address of an ::ESL_SOCKET structure.
+ @param [in] pService Address of an ::ESL_SERVICE structure.
+ @param [in] ChildHandle TCP4 child handle
+ @param [in] pSockAddr Address of a sockaddr structure that contains the
+ connection point on the local machine. An IPv4 address
+ of INADDR_ANY specifies that the connection is made to
+ all of the network stacks on the platform. Specifying a
+ specific IPv4 address restricts the connection to the
+ network stack supporting that address. Specifying zero
+ for the port causes the network layer to assign a port
+ number from the dynamic range. Specifying a specific
+ port number causes the network layer to use that port.
+ @param [in] bBindTest TRUE if EslSocketBindTest should be called
+ @param [in] DebugFlags Flags for debug messages
+ @param [out] ppPort Buffer to receive new ::ESL_PORT structure address
- @retval EFI_SUCCESS - Socket data successfully received
+ @retval EFI_SUCCESS - Socket successfully created
-**/
+ **/
EFI_STATUS
-EslUdpReceive4 (
- IN DT_SOCKET * pSocket,
- IN INT32 Flags,
- IN size_t BufferLength,
- IN UINT8 * pBuffer,
- OUT size_t * pDataLength,
- OUT struct sockaddr * pAddress,
- IN OUT socklen_t * pAddressLength
+EslSocketPortAllocate (
+ IN ESL_SOCKET * pSocket,
+ IN ESL_SERVICE * pService,
+ IN EFI_HANDLE ChildHandle,
+ IN CONST struct sockaddr * pSockAddr,
+ IN BOOLEAN bBindTest,
+ IN UINTN DebugFlags,
+ OUT ESL_PORT ** ppPort
);
/**
- Cancel the receive operations
-
- @param [in] pSocket Address of a DT_SOCKET structure
+ Close a port.
+
+ This routine releases the resources allocated by ::EslSocketPortAllocate.
+ This routine calls ESL_PROTOCOL_API::pfnPortClose to release the network
+ specific resources.
+
+ This routine is called by:
+ <ul>
+ <li>::EslIp4PortAllocate - Port initialization failure</li>
+ <li>::EslSocketPortCloseRxDone - Last step of close processing</li>
+ <li>::EslTcp4ConnectComplete - Connection failure and reducint the port list to a single port</li>
+ <li>::EslTcp4PortAllocate - Port initialization failure</li>
+ <li>::EslUdp4PortAllocate - Port initialization failure</li>
+ </ul>
+ See the \ref PortCloseStateMachine section.
- @retval EFI_SUCCESS - The cancel was successful
+ @param [in] pPort Address of an ::ESL_PORT structure.
- **/
+ @retval EFI_SUCCESS The port is closed
+ @retval other Port close error
+
+**/
EFI_STATUS
-EslUdpRxCancel4 (
- IN DT_SOCKET * pSocket
+EslSocketPortClose (
+ IN ESL_PORT * pPort
);
/**
- Process the receive completion
+ Process the port close completion event
- Keep the UDP4 driver's buffer and append it to the list of
- datagrams for the application to receive. The UDP4 driver's
- buffer will be returned by either ::UdpReceive4 or
- ::UdpPortCloseTxDone4.
+ This routine attempts to complete the port close operation.
- @param Event The receive completion event
+ This routine is called by the TCP layer upon completion of
+ the close operation.
+ See the \ref PortCloseStateMachine section.
- @param pPort The DT_PORT structure address
+ @param [in] Event The close completion event
+
+ @param [in] pPort Address of an ::ESL_PORT structure.
**/
VOID
-EslUdpRxComplete4 (
+EslSocketPortCloseComplete (
IN EFI_EVENT Event,
- IN DT_PORT * pPort
+ IN ESL_PORT * pPort
);
/**
- Start a receive operation
+ Port close state 3
- @param [in] pPort Address of the DT_PORT structure.
+ This routine determines the state of the receive operations and
+ continues the close operation after the pending receive operations
+ are cancelled.
- **/
-VOID
-EslUdpRxStart4 (
- IN DT_PORT * pPort
+ This routine is called by
+ <ul>
+ <li>::EslIp4RxComplete</li>
+ <li>::EslSocketPortCloseComplete</li>
+ <li>::EslSocketPortCloseTxDone</li>
+ <li>::EslUdp4RxComplete</li>
+ </ul>
+ to determine the state of the receive operations.
+ See the \ref PortCloseStateMachine section.
+
+ @param [in] pPort Address of an ::ESL_PORT structure.
+
+ @retval EFI_SUCCESS The port is closed
+ @retval EFI_NOT_READY The port is still closing
+ @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,
+ most likely the routine was called already.
+
+**/
+EFI_STATUS
+EslSocketPortCloseRxDone (
+ IN ESL_PORT * pPort
);
/**
- Determine if the socket is configured.
+ Start the close operation on a port, state 1.
+ This routine marks the port as closed and initiates the \ref
+ PortCloseStateMachine. The first step is to allow the \ref
+ TransmitEngine to run down.
- @param [in] pSocket Address of a DT_SOCKET structure
-
- @retval EFI_SUCCESS - The port is connected
- @retval EFI_NOT_STARTED - The port is not connected
+ This routine is called by ::EslSocketCloseStart to initiate the socket
+ network specific close operation on the socket.
- **/
- EFI_STATUS
- EslUdpSocketIsConfigured4 (
- IN DT_SOCKET * pSocket
+ @param [in] pPort Address of an ::ESL_PORT structure.
+ @param [in] bCloseNow Set TRUE to abort active transfers
+ @param [in] DebugFlags Flags for debug messages
+
+ @retval EFI_SUCCESS The port is closed, not normally returned
+ @retval EFI_NOT_READY The port has started the closing process
+ @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,
+ most likely the routine was called already.
+
+**/
+EFI_STATUS
+EslSocketPortCloseStart (
+ IN ESL_PORT * pPort,
+ IN BOOLEAN bCloseNow,
+ IN UINTN DebugFlags
);
/**
- Process the transmit completion
+ Port close state 2
+
+ This routine determines the state of the transmit engine and
+ continue the close operation after the transmission is complete.
+ The next step is to stop the \ref ReceiveEngine.
+ See the \ref PortCloseStateMachine section.
+
+ This routine is called by ::EslSocketPortCloseStart to determine
+ if the transmission is complete.
- @param Event The normal transmit completion event
+ @param [in] pPort Address of an ::ESL_PORT structure.
- @param pPort The DT_PORT structure address
+ @retval EFI_SUCCESS The port is closed, not normally returned
+ @retval EFI_NOT_READY The port is still closing
+ @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,
+ most likely the routine was called already.
**/
-VOID
-EslUdpTxComplete4 (
- IN EFI_EVENT Event,
- IN DT_PORT * pPort
+EFI_STATUS
+EslSocketPortCloseTxDone (
+ IN ESL_PORT * pPort
);
/**
- Shutdown the UDP4 service.
+ Cancel the receive operations
- This routine undoes the work performed by ::UdpInitialize4.
+ This routine cancels a pending receive operation.
+ See the \ref ReceiveEngine section.
- @param [in] pService DT_SERVICE structure address
+ This routine is called by ::EslSocketShutdown when the socket
+ layer is being shutdown.
-**/
+ @param [in] pPort Address of an ::ESL_PORT structure
+ @param [in] pIo Address of an ::ESL_IO_MGMT structure
+
+ **/
VOID
-EFIAPI
-EslUdpShutdown4 (
- IN DT_SERVICE * pService
+EslSocketRxCancel (
+ IN ESL_PORT * pPort,
+ IN ESL_IO_MGMT * pIo
);
/**
- Buffer data for transmission over a network connection.
+ Process the receive completion
- This routine is called by the socket layer API to buffer
- data for transmission. The data is copied into a local buffer
- freeing the application buffer for reuse upon return. When
- necessary, this routine will start the transmit engine that
- performs the data transmission on the network connection. The
- transmit engine transmits the data a packet at a time over the
- network connection.
+ This routine queues the data in FIFO order in either the urgent
+ or normal data queues depending upon the type of data received.
+ See the \ref ReceiveEngine section.
- Transmission errors are returned during the next transmission or
- during the close operation. Only buffering errors are returned
- during the current transmission attempt.
+ This routine is called when some data is received by:
+ <ul>
+ <li>::EslIp4RxComplete</li>
+ <li>::EslTcp4RxComplete</li>
+ <li>::EslUdp4RxComplete</li>
+ </ul>
- @param [in] pSocket Address of a DT_SOCKET structure
+ @param [in] pIo Address of an ::ESL_IO_MGMT structure
+ @param [in] Status Receive status
+ @param [in] LengthInBytes Length of the receive data
+ @param [in] bUrgent TRUE if urgent data is received and FALSE
+ for normal data.
- @param [in] Flags Message control flags
+**/
+VOID
+EslSocketRxComplete (
+ IN ESL_IO_MGMT * pIo,
+ IN EFI_STATUS Status,
+ IN UINTN LengthInBytes,
+ IN BOOLEAN bUrgent
+ );
- @param [in] BufferLength Length of the the buffer
+/**
+ Start a receive operation
- @param [in] pBuffer Address of a buffer to receive the data.
+ This routine posts a receive buffer to the network adapter.
+ See the \ref ReceiveEngine section.
- @param [in] pDataLength Number of received data bytes in the buffer.
+ This support routine is called by:
+ <ul>
+ <li>::EslIp4Receive to restart the receive engine to release flow control.</li>
+ <li>::EslIp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>
+ <li>::EslIp4SocketIsConfigured to start the recevie engine for the new socket.</li>
+ <li>::EslTcp4ListenComplete to start the recevie engine for the new socket.</li>
+ <li>::EslTcp4Receive to restart the receive engine to release flow control.</li>
+ <li>::EslTcp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>
+ <li>::EslUdp4Receive to restart the receive engine to release flow control.</li>
+ <li>::EslUdp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>
+ <li>::EslUdp4SocketIsConfigured to start the recevie engine for the new socket.</li>
+ </ul>
- @param [in] pAddress Network address of the remote system address
+ @param [in] pPort Address of an ::ESL_PORT structure.
- @param [in] AddressLength Length of the remote network address structure
+ **/
+VOID
+EslSocketRxStart (
+ IN ESL_PORT * pPort
+ );
- @retval EFI_SUCCESS - Socket data successfully buffered
+/**
+ Complete the transmit operation
+
+ This support routine handles the transmit completion processing for
+ the various network layers. It frees the ::ESL_IO_MGMT structure
+ and and frees packet resources by calling ::EslSocketPacketFree.
+ Transmit errors are logged in ESL_SOCKET::TxError.
+ See the \ref TransmitEngine section.
+
+ This routine is called by:
+ <ul>
+ <li>::EslIp4TxComplete</li>
+ <li>::EslTcp4TxComplete</li>
+ <li>::EslTcp4TxOobComplete</li>
+ <li>::EslUdp4TxComplete</li>
+ </ul>
+
+ @param [in] pIo Address of an ::ESL_IO_MGMT structure
+ @param [in] LengthInBytes Length of the data in bytes
+ @param [in] Status Transmit operation status
+ @param [in] pQueueType Zero terminated string describing queue type
+ @param [in] ppQueueHead Transmit queue head address
+ @param [in] ppQueueTail Transmit queue tail address
+ @param [in] ppActive Active transmit queue address
+ @param [in] ppFree Free transmit queue address
-**/
-EFI_STATUS
-EslUdpTxBuffer4 (
- IN DT_SOCKET * pSocket,
- IN int Flags,
- IN size_t BufferLength,
- IN CONST UINT8 * pBuffer,
- OUT size_t * pDataLength,
- IN const struct sockaddr * pAddress,
- IN socklen_t AddressLength
+ **/
+VOID
+EslSocketTxComplete (
+ IN ESL_IO_MGMT * pIo,
+ IN UINT32 LengthInBytes,
+ IN EFI_STATUS Status,
+ IN CONST CHAR8 * pQueueType,
+ IN ESL_PACKET ** ppQueueHead,
+ IN ESL_PACKET ** ppQueueTail,
+ IN ESL_IO_MGMT ** ppActive,
+ IN ESL_IO_MGMT ** ppFree
);
/**
Transmit data using a network connection.
- @param [in] pPort Address of a DT_PORT structure
+ This support routine starts a transmit operation on the
+ underlying network layer.
+
+ The network specific code calls this routine to start a
+ transmit operation. See the \ref TransmitEngine section.
+
+ @param [in] pPort Address of an ::ESL_PORT structure
+ @param [in] ppQueueHead Transmit queue head address
+ @param [in] ppQueueTail Transmit queue tail address
+ @param [in] ppActive Active transmit queue address
+ @param [in] ppFree Free transmit queue address
**/
VOID
-EslUdpTxStart4 (
- IN DT_PORT * pPort
+EslSocketTxStart (
+ IN ESL_PORT * pPort,
+ IN ESL_PACKET ** ppQueueHead,
+ IN ESL_PACKET ** ppQueueTail,
+ IN ESL_IO_MGMT ** ppActive,
+ IN ESL_IO_MGMT ** ppFree
);
//------------------------------------------------------------------------------