diff options
author | lpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-16 22:20:22 +0000 |
---|---|---|
committer | lpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-16 22:20:22 +0000 |
commit | 3302a555989ef62e98aa0d726bdd3fd4761767d4 (patch) | |
tree | f6dc2c362e402839464ad170cbcf884adb6234ca | |
parent | 0378a2f497c66dcd85db2a1074aef0946f271c08 (diff) | |
download | edk2-3302a555989ef62e98aa0d726bdd3fd4761767d4.zip edk2-3302a555989ef62e98aa0d726bdd3fd4761767d4.tar.gz edk2-3302a555989ef62e98aa0d726bdd3fd4761767d4.tar.bz2 |
Merge the RxStart routines.
Signed-off by: Lee Leahy
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/EADK@12368 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | StdLib/EfiSocketLib/Ip4.c | 240 | ||||
-rw-r--r-- | StdLib/EfiSocketLib/Socket.c | 216 | ||||
-rw-r--r-- | StdLib/EfiSocketLib/Socket.h | 1353 | ||||
-rw-r--r-- | StdLib/EfiSocketLib/Tcp4.c | 292 | ||||
-rw-r--r-- | StdLib/EfiSocketLib/Udp4.c | 240 |
5 files changed, 563 insertions, 1778 deletions
diff --git a/StdLib/EfiSocketLib/Ip4.c b/StdLib/EfiSocketLib/Ip4.c index 20b5436..e135d3c 100644 --- a/StdLib/EfiSocketLib/Ip4.c +++ b/StdLib/EfiSocketLib/Ip4.c @@ -10,74 +10,32 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- \section Ip4ReceiveEngine IPv4 Receive Engine
-
- The receive engine is started by calling ::EslIp4RxStart when the
- ::ESL_PORT structure is configured and stopped when ::EslSocketPortCloseTxDone
- calls the IPv4 configure operation to reset the port. The receive engine
- consists of a single receive buffer that is posted to the IPv4 driver.
-
- Upon receive completion, ::EslIp4RxComplete posts the IPv4 buffer to the
- ESL_SOCKET::pRxPacketListTail. To minimize the number of buffer copies,
- the ::EslIp4RxComplete routine queues the IP4 driver's buffer to a list
- of datagrams waiting to be received. The socket driver holds on to the
- buffers from the IPv4 driver until the application layer requests
- the data or the socket is closed.
-
- When the application wants to receive data it indirectly calls
- ::EslIp4Receive to remove data from the data queue. This routine
- removes the next available datagram from ESL_SOCKET::pRxPacketListHead
- and copies the data from the IPv4 driver's buffer into the
- application's buffer. The IPv4 driver's buffer is then returned.
-
- During socket layer shutdown, ::EslIp4RxCancel is called by ::EslSocketShutdown
- to cancel the pending receive operations.
-
- Receive flow control is applied when the socket is created, since no receive
- operation is pending to the IPv4 driver. The flow control gets released
- when the port is configured. Flow control remains in the released state,
- ::EslIp4RxComplete calls ::EslIp4RxStart until the maximum buffer space
- is consumed. By not calling EslIp4RxStart, EslIp4RxComplete applies flow
- control. Flow control is eventually released when the buffer space drops
- below the maximum amount and EslIp4Receive calls EslIp4RxStart.
-
**/
#include "Socket.h"
+
/**
- Interface between the socket layer and the network specific
- code that supports SOCK_RAW sockets over IPv4.
+ Process the receive completion
+
+ This routine keeps the IPv4 driver's buffer and queues it in
+ in FIFO order to the data queue. The IP4 driver's buffer will
+ be returned by either ::EslIp4Receive or ::EslSocketPortCloseTxDone.
+ See the \ref Tcp4ReceiveEngine section.
+
+ This routine is called by the IPv4 driver when data is
+ received.
+
+ @param [in] Event The receive completion event
+
+ @param [in] pPort The address of an ::ESL_PORT structure
+
**/
-CONST ESL_PROTOCOL_API cEslIp4Api = {
- IPPROTO_IP,
- OFFSET_OF ( ESL_LAYER, pIp4List ),
- OFFSET_OF ( struct sockaddr_in, sin_zero ),
- sizeof ( struct sockaddr_in ),
- AF_INET,
- NULL, // Accept
- NULL, // ConnectPoll
- NULL, // ConnectStart
- EslIp4SocketIsConfigured,
- EslIp4LocalAddressGet,
- EslIp4LocalAddressSet,
- NULL, // Listen
- EslIp4OptionGet,
- EslIp4OptionSet,
- EslIp4PortAllocate,
- EslIp4PortClose,
- EslIp4PortClosePacketFree,
- EslIp4PortCloseRxStop,
- TRUE,
- EslIp4Receive,
- EslIp4RemoteAddressGet,
- EslIp4RemoteAddressSet,
- EslIp4RxCancel,
- EslIp4TxBuffer,
- EslIp4TxComplete,
- NULL // TxOobComplete
-};
+VOID
+EslIp4RxComplete (
+ IN EFI_EVENT Event,
+ IN ESL_PORT * pPort
+ );
/**
@@ -850,7 +808,7 @@ EslIp4Receive ( //
if (( NULL == pPort->pReceivePending )
&& ( MAX_RX_DATA > pSocket->RxBytes )) {
- EslIp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
}
}
@@ -1160,7 +1118,7 @@ EslIp4RxComplete ( // Attempt to restart this receive operation
//
if ( pSocket->MaxRxBuf > pSocket->RxBytes ) {
- EslIp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
}
else {
DEBUG (( DEBUG_RX,
@@ -1218,25 +1176,22 @@ EslIp4RxComplete ( Start a receive operation
This routine posts a receive buffer to the IPv4 driver.
- See the \ref Ip4ReceiveEngine section.
+ See the \ref ReceiveEngine section.
- This support routine is called by:
- <ul>
- <li>::EslIp4SocketIsConfigured to start the recevie engine for the new socket.</li>
- <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>
- </ul>
+ This support routine is called by EslSocketRxStart.
@param [in] pPort Address of an ::ESL_PORT structure.
+ @param [in] pPacket Address of an ::ESL_PACKET structure.
+
+ @retval EFI_SUCCESS Receive operation started successfully
**/
-VOID
+EFI_STATUS
EslIp4RxStart (
- IN ESL_PORT * pPort
+ IN ESL_PORT * pPort,
+ IN ESL_PACKET * pPacket
)
{
- ESL_PACKET * pPacket;
- ESL_SOCKET * pSocket;
ESL_IP4_CONTEXT * pIp4;
EFI_IP4_PROTOCOL * pIp4Protocol;
EFI_STATUS Status;
@@ -1244,93 +1199,24 @@ EslIp4RxStart ( DBG_ENTER ( );
//
- // Determine if a receive is already pending
+ // Initialize the buffer for receive
//
- Status = EFI_SUCCESS;
- pPacket = NULL;
- pSocket = pPort->pSocket;
+ pPacket->Op.Ip4Rx.pRxData = NULL;
pIp4 = &pPort->Context.Ip4;
- if ( !EFI_ERROR ( pPort->pSocket->RxError )) {
- if (( NULL == pPort->pReceivePending )
- && ( PORT_STATE_CLOSE_STARTED > pPort->State )) {
- //
- // Determine if there are any free packets
- //
- pPacket = pSocket->pRxFree;
- if ( NULL != pPacket ) {
- //
- // Remove this packet from the free list
- //
- pSocket->pRxFree = pPacket->pNext;
- DEBUG (( DEBUG_RX,
- "0x%08x: Port removed packet 0x%08x from free list\r\n",
- pPort,
- pPacket ));
- }
- else {
- //
- // Allocate a packet structure
- //
- Status = EslSocketPacketAllocate ( &pPacket,
- sizeof ( pPacket->Op.Ip4Rx ),
- DEBUG_RX );
- if ( EFI_ERROR ( Status )) {
- pPacket = NULL;
- DEBUG (( DEBUG_ERROR | DEBUG_RX,
- "0x%08x: Port failed to allocate RX packet, Status: %r\r\n",
- pPort,
- Status ));
- }
- }
-
- //
- // Determine if a packet is available
- //
- if ( NULL != pPacket ) {
- //
- // Initialize the buffer for receive
- //
- pPacket->pNext = NULL;
- pPacket->Op.Ip4Rx.pRxData = NULL;
- pIp4->RxToken.Packet.RxData = NULL;
- pPort->pReceivePending = pPacket;
+ pIp4->RxToken.Packet.RxData = NULL;
- //
- // Start the receive on the packet
- //
- pIp4Protocol = pPort->pProtocol.IPv4;
- Status = pIp4Protocol->Receive ( pIp4Protocol,
- &pIp4->RxToken );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_RX | DEBUG_INFO,
- "0x%08x: Packet receive pending on port 0x%08x\r\n",
- pPacket,
- pPort ));
- }
- else {
- DEBUG (( DEBUG_RX | DEBUG_INFO,
- "ERROR - Failed to post a receive on port 0x%08x, Status: %r\r\n",
- pPort,
- Status ));
- if ( !EFI_ERROR ( pSocket->RxError )) {
- //
- // Save the error status
- //
- pSocket->RxError = Status;
- }
-
- //
- // Free the packet
- //
- pPort->pReceivePending = NULL;
- pPacket->pNext = pSocket->pRxFree;
- pSocket->pRxFree = pPacket;
- }
- }
- }
- }
+ //
+ // Start the receive on the packet
+ //
+ pIp4Protocol = pPort->pProtocol.IPv4;
+ Status = pIp4Protocol->Receive ( pIp4Protocol,
+ &pIp4->RxToken );
- DBG_EXIT ( );
+ //
+ // Return the operation status
+ //
+ DBG_EXIT_STATUS ( Status );
+ return Status;
}
@@ -1510,7 +1396,7 @@ EslIp4RxStart ( //
// Start the first read on the port
//
- EslIp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
//
// The socket is connected
@@ -1851,3 +1737,39 @@ EslIp4TxComplete ( &pPort->pTxFree );
DBG_EXIT ( );
}
+
+
+/**
+ Interface between the socket layer and the network specific
+ code that supports SOCK_RAW sockets over IPv4.
+**/
+CONST ESL_PROTOCOL_API cEslIp4Api = {
+ IPPROTO_IP,
+ OFFSET_OF ( ESL_LAYER, pIp4List ),
+ OFFSET_OF ( struct sockaddr_in, sin_zero ),
+ sizeof ( struct sockaddr_in ),
+ AF_INET,
+ sizeof (((ESL_PACKET *)0 )->Op.Ip4Rx ),
+ NULL, // Accept
+ NULL, // ConnectPoll
+ NULL, // ConnectStart
+ EslIp4SocketIsConfigured,
+ EslIp4LocalAddressGet,
+ EslIp4LocalAddressSet,
+ NULL, // Listen
+ EslIp4OptionGet,
+ EslIp4OptionSet,
+ EslIp4PortAllocate,
+ EslIp4PortClose,
+ EslIp4PortClosePacketFree,
+ EslIp4PortCloseRxStop,
+ TRUE,
+ EslIp4Receive,
+ EslIp4RemoteAddressGet,
+ EslIp4RemoteAddressSet,
+ EslIp4RxCancel,
+ EslIp4RxStart,
+ EslIp4TxBuffer,
+ EslIp4TxComplete,
+ NULL // TxOobComplete
+};
diff --git a/StdLib/EfiSocketLib/Socket.c b/StdLib/EfiSocketLib/Socket.c index 67f2e47..7250212 100644 --- a/StdLib/EfiSocketLib/Socket.c +++ b/StdLib/EfiSocketLib/Socket.c @@ -54,7 +54,99 @@ completions may happen in either order.
+ \section ReceiveEngine Receive Engine
+
+ The receive engine is started by calling ::EslSocketRxStart when the
+ ::ESL_PORT structure is allocated and stopped when ::EslSocketPortCloseTxDone
+ calls the network specific close operation. The receive engine consists
+ of a single receive buffer that is posted to the network driver. Upon
+ completion, ::EslSocketRxComplete posts the buffer to either the
+ ESL_SOCKET::pRxOobPacketListTail or ESL_SOCKET::pRxPacketListTail
+ depending on whether urgent or normal data was received.
+
+ When the application wants to receive data it indirectly calls
+ ::EslTcp4Receive to remove data from one of the data queues. If
+ message flag MSG_OOB is specified, data is removed from
+ ESL_SOCKET::pRxOobPacketListHead, otherwise data is removed from
+ ESL_SOCKET::pRxPacketListHead.
+
+ During socket layer shutdown, ::EslTcp4RxCancel is called by ::EslSocketShutdown to cancel the
+ pending receive operations.
+
+ Receive flow control is applied when the socket is created, since no receive
+ operation is pending to the TCPv4 driver. The flow control gets released
+ when the first receive request is made to ::EslTcp4Receive. Flow control
+ remains in the released state, ::EslTcp4RxComplete calls ::EslTcp4RxStart
+ until the maximum buffer space is consumed. By not calling EslTcp4RxStart,
+ EslTcp4RxComplete applies flow control. Flow control is eventually released
+ when the buffer space drops below the maximum amount and EslTcp4Receive
+ calls EslTcp4RxStart.
+
+ \section Ip4ReceiveEngine IPv4 Receive Engine
+
+ The receive engine is started by calling ::EslIp4RxStart when the
+ ::ESL_PORT structure is configured and stopped when ::EslSocketPortCloseTxDone
+ calls the IPv4 configure operation to reset the port. The receive engine
+ consists of a single receive buffer that is posted to the IPv4 driver.
+
+ Upon receive completion, ::EslIp4RxComplete posts the IPv4 buffer to the
+ ESL_SOCKET::pRxPacketListTail. To minimize the number of buffer copies,
+ the ::EslIp4RxComplete routine queues the IP4 driver's buffer to a list
+ of datagrams waiting to be received. The socket driver holds on to the
+ buffers from the IPv4 driver until the application layer requests
+ the data or the socket is closed.
+
+ When the application wants to receive data it indirectly calls
+ ::EslIp4Receive to remove data from the data queue. This routine
+ removes the next available datagram from ESL_SOCKET::pRxPacketListHead
+ and copies the data from the IPv4 driver's buffer into the
+ application's buffer. The IPv4 driver's buffer is then returned.
+
+ During socket layer shutdown, ::EslIp4RxCancel is called by ::EslSocketShutdown
+ to cancel the pending receive operations.
+
+ Receive flow control is applied when the socket is created, since no receive
+ operation is pending to the IPv4 driver. The flow control gets released
+ when the port is configured. Flow control remains in the released state,
+ ::EslIp4RxComplete calls ::EslIp4RxStart until the maximum buffer space
+ is consumed. By not calling EslIp4RxStart, EslIp4RxComplete applies flow
+ control. Flow control is eventually released when the buffer space drops
+ below the maximum amount and EslIp4Receive calls EslIp4RxStart.
+
+ \section Udp4ReceiveEngine UDPv4 Receive Engine
+
+ The receive engine is started by calling ::EslUdp4RxStart when the
+ ::ESL_PORT structure is configured and stopped when ::EslSocketPortCloseTxDone
+ calls the UDPv4 configure operation to reset the port. The receive engine
+ consists of a single receive buffer that is posted to the UDPv4 driver.
+
+ Upon receive completion, ::EslUdp4RxComplete posts the UDPv4 buffer to the
+ ESL_SOCKET::pRxPacketListTail. To minimize the number of buffer copies,
+ the ::EslUdp4RxComplete 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 UDPv4 driver until the application layer requests
+ the data or the socket is closed.
+
+ When the application wants to receive data it indirectly calls
+ ::EslUdp4Receive to remove data from the data queue. This routine
+ removes the next available datagram from ESL_SOCKET::pRxPacketListHead
+ and copies the data from the UDPv4 driver's buffer into the
+ application's buffer. The UDPv4 driver's buffer is then returned.
+
+ During socket layer shutdown, ::EslUdp4RxCancel is called by ::EslSocketShutdown
+ to cancel the pending receive operations.
+
+ Receive flow control is applied when the socket is created, since no receive
+ operation is pending to the UDPv4 driver. The flow control gets released
+ when the port is configured. Flow control remains in the released state,
+ ::EslUdp4RxComplete calls ::EslUdp4RxStart until the maximum buffer space
+ is consumed. By not calling EslUdp4RxStart, EslUdp4RxComplete applies flow
+ control. Flow control is eventually released when the buffer space drops
+ below the maximum amount and EslUdp4Receive calls EslUdp4RxStart.
+
+
\section TransmitEngine Transmit Engine
+
The transmit engine uses the ESL_IO_MGMT structures to manage
multiple transmit buffers. ::EslSocketPortAllocate allocates the
::ESL_IO_MGMT structures and place them on the free list by calling
@@ -2410,8 +2502,9 @@ EslSocketOptionSet ( /**
Allocate a packet for a receive or transmit operation
- This support routine is called by the network specific RxStart
- and TxBuffer routines to get buffer space for the next operation.
+ This support routine is called by ::EslSocketRxStart and the
+ network specific TxBuffer routines to get buffer space for the
+ next operation.
@param [in] ppPacket Address to receive the ::ESL_PACKET structure
@param [in] LengthInBytes Length of the packet structure
@@ -3706,6 +3799,125 @@ EslSocketReceive ( /**
+ Start a receive operation
+
+ This routine posts a receive buffer to the network adapter.
+ See the \ref ReceiveEngine section.
+
+ 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] pPort Address of an ::ESL_PORT structure.
+
+ **/
+VOID
+EslSocketRxStart (
+ IN ESL_PORT * pPort
+ )
+{
+ ESL_PACKET * pPacket;
+ ESL_SOCKET * pSocket;
+ EFI_STATUS Status;
+
+ DBG_ENTER ( );
+
+ //
+ // Determine if a receive is already pending
+ //
+ Status = EFI_SUCCESS;
+ pPacket = NULL;
+ pSocket = pPort->pSocket;
+ if ( !EFI_ERROR ( pPort->pSocket->RxError )) {
+ if (( NULL == pPort->pReceivePending )
+ && ( PORT_STATE_CLOSE_STARTED > pPort->State )) {
+ //
+ // Determine if there are any free packets
+ //
+ pPacket = pSocket->pRxFree;
+ if ( NULL != pPacket ) {
+ //
+ // Remove this packet from the free list
+ //
+ pSocket->pRxFree = pPacket->pNext;
+ DEBUG (( DEBUG_RX,
+ "0x%08x: Port removed packet 0x%08x from free list\r\n",
+ pPort,
+ pPacket ));
+ }
+ else {
+ //
+ // Allocate a packet structure
+ //
+ Status = EslSocketPacketAllocate ( &pPacket,
+ pSocket->pApi->RxPacketBytes,
+ DEBUG_RX );
+ if ( EFI_ERROR ( Status )) {
+ pPacket = NULL;
+ DEBUG (( DEBUG_ERROR | DEBUG_RX,
+ "0x%08x: Port failed to allocate RX packet, Status: %r\r\n",
+ pPort,
+ Status ));
+ }
+ }
+
+ //
+ // Determine if a packet is available
+ //
+ if ( NULL != pPacket ) {
+ //
+ // Mark this receive as pending
+ //
+ pPort->pReceivePending = pPacket;
+ pPacket->pNext = NULL;
+
+ //
+ // Start the receive on the packet
+ //
+ Status = pSocket->pApi->pfnRxStart ( pPort, pPacket );
+ if ( !EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_RX | DEBUG_INFO,
+ "0x%08x: Packet receive pending on port 0x%08x\r\n",
+ pPacket,
+ pPort ));
+ }
+ else {
+ DEBUG (( DEBUG_RX | DEBUG_INFO,
+ "ERROR - Failed to post a receive on port 0x%08x, Status: %r\r\n",
+ pPort,
+ Status ));
+ if ( !EFI_ERROR ( pSocket->RxError )) {
+ //
+ // Save the error status
+ //
+ pSocket->RxError = Status;
+ }
+
+ //
+ // Free the packet
+ //
+ pPort->pReceivePending = NULL;
+ pPacket->pNext = pSocket->pRxFree;
+ pSocket->pRxFree = pPacket;
+ }
+ }
+ }
+ }
+
+ DBG_EXIT ( );
+}
+
+
+/**
Shutdown the socket receive and transmit operations
This routine sets a flag to stop future transmissions and calls
diff --git a/StdLib/EfiSocketLib/Socket.h b/StdLib/EfiSocketLib/Socket.h index 50e09c0..c6ba771 100644 --- a/StdLib/EfiSocketLib/Socket.h +++ b/StdLib/EfiSocketLib/Socket.h @@ -716,6 +716,27 @@ EFI_STATUS );
/**
+ Start a receive operation
+
+ This routine posts a receive buffer to the network adapter.
+ See the \ref ReceiveEngine section.
+
+ This support routine is called by EslSocketRxStart.
+
+ @param [in] pPort Address of an ::ESL_PORT structure.
+ @param [in] pPacket Address of an ::ESL_PACKET structure.
+
+ @retval EFI_SUCCESS Receive operation started successfully
+
+ **/
+typedef
+EFI_STATUS
+(* PFN_API_RX_START) (
+ IN ESL_PORT * pPort,
+ IN ESL_PACKET * pPacket
+ );
+
+/**
Buffer data for transmission over a network connection.
@param [in] pSocket Address of a ESL_SOCKET structure
@@ -779,6 +800,7 @@ typedef struct { 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
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
@@ -797,6 +819,7 @@ typedef struct { PFN_API_REMOTE_ADDR_GET pfnRemoteAddrGet; ///< Get remote address
PFN_API_REMOTE_ADDR_SET pfnRemoteAddrSet; ///< Set the remote system address
PFN_API_RX_CANCEL pfnRxCancel; ///< Cancel a receive operation
+ 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
@@ -1271,6 +1294,33 @@ EslSocketPortCloseTxDone ( );
/**
+ Start a receive operation
+
+ This routine posts a receive buffer to the network adapter.
+ See the \ref ReceiveEngine section.
+
+ 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] pPort Address of an ::ESL_PORT structure.
+
+ **/
+VOID
+EslSocketRxStart (
+ IN ESL_PORT * pPort
+ );
+
+/**
Complete the transmit operation
This support routine handles the transmit completion processing for
@@ -1335,1308 +1385,5 @@ EslSocketTxStart ( );
//------------------------------------------------------------------------------
-// Ip4 Routines
-//------------------------------------------------------------------------------
-
-/**
- Get the local socket address
-
- This routine returns the IPv4 address associated with the local
- socket.
-
- This routine is called by ::EslSocketGetLocalAddress to determine the
- network address for the SOCK_RAW socket.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [out] pAddress Network address to receive the local system address
-
-**/
-VOID
-EslIp4LocalAddressGet (
- IN ESL_PORT * pPort,
- OUT struct sockaddr * pAddress
- );
-
-/**
- Set the local port address.
-
- This routine sets the local port address.
-
- This support routine is called by ::EslSocketPortAllocate.
-
- @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.
-
- **/
-VOID
-EslIp4LocalAddressSet (
- IN ESL_PORT * pPort,
- IN CONST struct sockaddr * pSockAddr
- );
-
-/**
- Get the option value
-
- This routine handles the IPv4 level options.
-
- The ::EslSocketOptionGet routine calls this routine to retrieve
- the IPv4 options one at a time by name.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure
- @param [in] level Option protocol level
- @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
-
- @retval EFI_SUCCESS - Socket data successfully received
-
- **/
-EFI_STATUS
-EslIp4OptionGet (
- IN ESL_SOCKET * pSocket,
- IN int level,
- IN int OptionName,
- OUT CONST void ** __restrict ppOptionData,
- OUT socklen_t * __restrict pOptionLength
- );
-
-/**
- Set the option value
-
- This routine handles the IPv4 level options.
-
- The ::EslSocketOptionSet routine calls this routine to adjust
- the IPv4 options one at a time by name.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure
- @param [in] level Option protocol level
- @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
-
- **/
-EFI_STATUS
-EslIp4OptionSet (
- IN ESL_SOCKET * pSocket,
- IN int level,
- IN int OptionName,
- IN CONST void * pOptionValue,
- IN socklen_t OptionLength
- );
-
-/**
- Initialize the network specific portions of an ::ESL_PORT structure.
-
- This routine initializes the network specific portions of an
- ::ESL_PORT structure for use by the socket.
-
- This support routine is called by ::EslSocketPortAllocate
- to connect the socket with the underlying network adapter
- running the IPv4 protocol.
-
- @param [in] ppPort Address of an ESL_PORT structure
- @param [in] DebugFlags Flags for debug messages
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslIp4PortAllocate (
- IN ESL_PORT * pPort,
- IN UINTN DebugFlags
- );
-
-/**
- Close an IP4 port.
-
- This routine releases the resources allocated by
- ::EslIp4PortAllocate.
-
- This routine is called by:
- <ul>
- <li>::EslIp4PortAllocate - Port initialization failure</li>
- <li>::EslIp4PortCloseRxDone - Last step of close processing</li>
- </ul>
- See the \ref Ip4PortCloseStateMachine section.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @retval EFI_SUCCESS The port is closed
- @retval other Port close error
-
-**/
-EFI_STATUS
-EslIp4PortClose (
- IN ESL_PORT * pPort
- );
-
-/**
- Free a receive packet
-
- This routine performs the network specific operations necessary
- to free a receive packet.
-
- This routine is called by ::EslSocketPortCloseTxDone to free a
- receive packet.
-
- @param [in] pPacket Address of an ::ESL_PACKET structure.
- @param [in, out] pRxBytes Address of the count of RX bytes
-
-**/
-VOID
-EslIp4PortClosePacketFree (
- IN ESL_PACKET * pPacket,
- IN OUT size_t * pRxBytes
- );
-
-/**
- Perform the network specific close operation on the port.
-
- This routine performs a cancel operations on the IPv4 port to
- shutdown the receive operations on the port.
-
- 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.
-
-**/
-EFI_STATUS
-EslIp4PortCloseRxStop (
- IN ESL_PORT * pPort
- );
-
-/**
- Receive data from a network connection.
-
- This routine attempts to return buffered data to the caller. The
- data is only removed from the normal queue, the message flag
- MSG_OOB is ignored. See the \ref Ip4ReceiveEngine section.
-
- This routine is called by ::EslSocketReceive to handle the network
- specific receive operation to support SOCK_RAW sockets.
-
- @param [in] pSocket Address of an ::ESL_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 [out] pAddress Network address to receive the remote system address
-
- @param [in,out] pAddressLength Length of the remote network address structure
-
- @retval EFI_SUCCESS - Socket data successfully received
-
-**/
-EFI_STATUS
-EslIp4Receive (
- IN ESL_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
- );
-
-/**
- Get the remote socket address
-
- This routine returns the address of the remote connection point
- associated with the SOCK_RAW socket.
-
- This routine is called by ::EslSocketGetPeerAddress to detemine
- the IPv4 address associated with the network adapter.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [out] pAddress Network address to receive the remote system address
-
-**/
-VOID
-EslIp4RemoteAddressGet (
- IN ESL_PORT * pPort,
- OUT struct sockaddr * pAddress
- );
-
-/**
- Set the remote address
-
- This routine sets the remote address in the port.
-
- This routine is called by ::EslSocketConnect to specify the
- remote network address.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [in] pSockAddr Network address of the remote system.
-
- @param [in] SockAddrLength Length in bytes of the network address.
-
- **/
-VOID
-EslIp4RemoteAddressSet (
- IN ESL_PORT * pPort,
- IN CONST struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
- Cancel the receive operations
-
- This routine cancels the pending receive operations.
- See the \ref Ip4ReceiveEngine section.
-
- This routine is called by ::EslSocketShutdown when the socket
- layer is being shutdown.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure
-
- @retval EFI_SUCCESS - The cancel was successful
-
- **/
-EFI_STATUS
-EslIp4RxCancel (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Process the receive completion
-
- This routine keeps the IPv4 driver's buffer and queues it in
- in FIFO order to the data queue. The IP4 driver's buffer will
- be returned by either ::EslIp4Receive or ::EslSocketPortCloseTxDone.
- See the \ref Tcp4ReceiveEngine section.
-
- This routine is called by the IPv4 driver when data is
- received.
-
- @param [in] Event The receive completion event
-
- @param [in] pPort The address of an ::ESL_PORT structure
-
-**/
-VOID
-EslIp4RxComplete (
- IN EFI_EVENT Event,
- IN ESL_PORT * pPort
- );
-
-/**
- Start a receive operation
-
- This routine posts a receive buffer to the IPv4 driver.
- See the \ref Ip4ReceiveEngine section.
-
- This support routine is called by:
- <ul>
- <li>::EslIp4SocketIsConfigured to start the recevie engine for the new socket.</li>
- <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>
- </ul>
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- **/
-VOID
-EslIp4RxStart (
- IN ESL_PORT * pPort
- );
-
-/**
- Determine if the socket is configured.
-
- This routine uses the flag ESL_SOCKET::bConfigured to determine
- if the network layer's configuration routine has been called.
- This routine calls the bind and configuration routines if they
- were not already called. After the port is configured, the
- \ref Ip4ReceiveEngine is started.
-
- This routine is called by EslSocketIsConfigured to verify
- that the socket is configured.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure
-
- @retval EFI_SUCCESS - The port is connected
- @retval EFI_NOT_STARTED - The port is not connected
-
- **/
- EFI_STATUS
- EslIp4SocketIsConfigured (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Buffer data for transmission over a network connection.
-
- This routine buffers data for the transmit engine in the normal
- data queue. When the \ref TransmitEngine has resources, this
- routine will start the transmission of the next buffer on the
- network connection.
-
- This routine is called by ::EslSocketTransmit 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 starts 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.
-
- Transmission errors are returned during the next transmission or
- during the close operation. Only buffering errors are returned
- during the current transmission attempt.
-
- @param [in] pSocket Address of an ::ESL_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
-
-**/
-EFI_STATUS
-EslIp4TxBuffer (
- IN ESL_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
- );
-
-/**
- Process the transmit completion
-
- This routine use ::EslSocketTxComplete to perform the transmit
- completion processing for data packets.
-
- This routine is called by the IPv4 network layer when a data
- transmit request completes.
-
- @param [in] Event The normal transmit completion event
-
- @param [in] pIo The address of an ::ESL_IO_MGMT structure
-
-**/
-VOID
-EslIp4TxComplete (
- IN EFI_EVENT Event,
- IN ESL_IO_MGMT * pIo
- );
-
-//------------------------------------------------------------------------------
-// Tcp4 Routines
-//------------------------------------------------------------------------------
-
-/**
- Accept a network connection.
-
- This routine waits for a network connection to the socket and
- returns the remote network address to the caller if requested.
-
- This routine is called by ::EslSocketAccept to handle the TCPv4 protocol
- specific accept operations for SOCK_STREAM and SOCK_SEQPACKET sockets.
- See the \ref ConnectionManagement section.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @param [in] pSockAddr Address of a buffer to receive the remote
- network address.
-
- @param [in, out] pSockAddrLength Length in bytes of the address buffer.
- On output specifies the length of the
- remote network address.
-
- @retval EFI_SUCCESS Remote address is available
- @retval Others Remote address not available
-
- **/
-EFI_STATUS
-EslTcp4Accept (
- IN ESL_SOCKET * pSocket,
- IN struct sockaddr * pSockAddr,
- IN OUT socklen_t * pSockAddrLength
- );
-
-/**
- Poll for completion of the connection attempt.
-
- This routine polls the ESL_SOCKET::bConnected flag to determine
- when the connection attempt is complete.
-
- This routine is called from ::EslSocketConnect to determine when
- the connection is complete. The ESL_SOCKET::bConnected flag is
- set by ::EslTcp4ConnectComplete when the TCPv4 layer establishes
- a connection or runs out of local network adapters. This routine
- gets the connection status from ESL_SOCKET::ConnectStatus.
-
- @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.
-
- **/
-EFI_STATUS
-EslTcp4ConnectPoll (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Attempt to connect to a remote TCP port
-
- This routine starts the connection processing for a SOCK_STREAM
- or SOCK_SEQPAKCET socket using the TCPv4 network layer. It
- configures the local TCPv4 connection point and then attempts to
- connect to a remote system. Upon completion, the
- ::EslTcp4ConnectComplete routine gets called with the connection
- status.
-
- This routine is called by ::EslSocketConnect to initiate the TCPv4
- network specific connect operations. The connection processing is
- initiated by this routine and finished by ::EslTcp4ConnectComplete.
- This pair of routines walks through the list of local TCPv4
- connection points until a connection to the remote system is
- made.
-
- @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.
-
- **/
-EFI_STATUS
-EslTcp4ConnectStart (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Establish the known port to listen for network connections.
-
- This routine places the port into a state that enables connection
- attempts.
-
- This routine is called by ::EslSocketListen to handle the network
- specifics of the listen operation for SOCK_STREAM and SOCK_SEQPACKET
- sockets. See the \ref ConnectionManagement section.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @retval EFI_SUCCESS - Socket successfully created
- @retval Other - Failed to enable the socket for listen
-
-**/
-EFI_STATUS
-EslTcp4Listen (
- 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.
-
- The TCPv4 layer calls this routine when a connection is made to
- the socket in the listen state. See the
- \ref ConnectionManagement">Connection Management</a> section.
-
- @param [in] Event The listen completion event
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
-**/
-VOID
-EslTcp4ListenComplete (
- IN EFI_EVENT Event,
- IN ESL_PORT * pPort
- );
-
-/**
- Get the local socket address.
-
- This routine returns the IPv4 address and TCP port number associated
- with the local socket.
-
- This routine is called by ::EslSocketGetLocalAddress to determine the
- network address for the SOCK_STREAM or SOCK_SEQPACKET socket.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [out] pAddress Network address to receive the local system address
-
-**/
-VOID
-EslTcp4LocalAddressGet (
- IN ESL_PORT * pPort,
- OUT struct sockaddr * pAddress
- );
-
-/**
- Set the local port address.
-
- This routine sets the local port address.
-
- This support routine is called by ::EslSocketPortAllocate.
-
- @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.
-
- **/
-VOID
-EslTcp4LocalAddressSet (
- IN ESL_PORT * pPort,
- IN CONST struct sockaddr * pSockAddr
- );
-
-/**
- Initialize the network specific portions of an ::ESL_PORT structure.
-
- This routine initializes the network specific portions of an
- ::ESL_PORT structure for use by the socket.
-
- This support routine is called by ::EslSocketPortAllocate
- to connect the socket with the underlying network adapter
- running the TCPv4 protocol.
-
- @param [in] ppPort Address of an ESL_PORT structure
- @param [in] DebugFlags Flags for debug messages
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslTcp4PortAllocate (
- IN ESL_PORT * pPort,
- IN UINTN DebugFlags
- );
-
-/**
- Close a TCP4 port.
-
- This routine releases the resources allocated by
- ::EslTcp4PortAllocate.
-
- This routine is called by:
- <ul>
- <li>::EslTcp4ConnectComplete - Connection failure and reducint the port list to a single port</li>
- <li>::EslTcp4PortAllocate - Port initialization failure</li>
- <li>::EslTcp4PortCloseRxDone - Last step of close processing</li>
- </ul>
- See the \ref Tcp4PortCloseStateMachine section.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @retval EFI_SUCCESS The port is closed
- @retval other Port close error
-
-**/
-EFI_STATUS
-EslTcp4PortClose (
- IN ESL_PORT * pPort
- );
-
-/**
- Free a receive packet
-
- This routine performs the network specific operations necessary
- to free a receive packet.
-
- This routine is called by ::EslSocketPortCloseTxDone to free a
- receive packet.
-
- @param [in] pPacket Address of an ::ESL_PACKET structure.
- @param [in, out] pRxBytes Address of the count of RX bytes
-
-**/
-VOID
-EslTcp4PortClosePacketFree (
- IN ESL_PACKET * pPacket,
- IN OUT size_t * pRxBytes
- );
-
-/**
- Perform the network specific close operation on the port.
-
- This routine performs a cancel operations on the UDPv4 port to
- shutdown the receive operations on the port.
-
- 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.
-
-**/
-EFI_STATUS
-EslTcp4PortCloseRxStop (
- 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 Tcp4ReceiveEngine section.
-
- This routine is called by ::EslSocketReceive to handle the network
- specific receive operation to support SOCK_STREAM and SOCK_SEQPACKET
- sockets.
-
- @param [in] pSocket Address of an ::ESL_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 [out] pAddress Network address to receive the remote system address
-
- @param [in,out] pAddressLength Length of the remote network address structure
-
- @retval EFI_SUCCESS - Socket data successfully received
-
- **/
-EFI_STATUS
-EslTcp4Receive (
- IN ESL_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
- );
-
-/**
- Get the remote socket address.
-
- This routine returns the address of the remote connection point
- associated with the SOCK_STREAM or SOCK_SEQPACKET socket.
-
- This routine is called by ::EslSocketGetPeerAddress to detemine
- the TCPv4 address and por number associated with the network adapter.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [out] pAddress Network address to receive the remote system address
-
-**/
-VOID
-EslTcp4RemoteAddressGet (
- IN ESL_PORT * pPort,
- OUT struct sockaddr * pAddress
- );
-
-/**
- Set the remote address
-
- This routine sets the remote address in the port.
-
- This routine is called by ::EslSocketConnect to specify the
- remote network address.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [in] pSockAddr Network address of the remote system.
-
- @param [in] SockAddrLength Length in bytes of the network address.
-
- **/
-VOID
-EslTcp4RemoteAddressSet (
- IN ESL_PORT * pPort,
- IN CONST struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
- Cancel the receive operations
-
- This routine cancels the pending receive operations.
- See the \ref Tcp4ReceiveEngine section.
-
- This routine is called by ::EslSocketShutdown when the socket
- layer is being shutdown.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @retval EFI_SUCCESS - The cancel was successful
-
- **/
-EFI_STATUS
-EslTcp4RxCancel (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Process the receive completion
-
- 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 Tcp4ReceiveEngine section.
-
- This routine is called by the TCPv4 driver when some data is
- received.
-
- Buffer the data that was just received.
-
- @param [in] Event The receive completion event
-
- @param [in] pPort Address of an ::ESL_PORT structure
-
-**/
-VOID
-EslTcp4RxComplete (
- IN EFI_EVENT Event,
- IN ESL_PORT * pPort
- );
-
-/**
- Start a receive operation
-
- This routine posts a receive buffer to the TCPv4 driver.
- See the \ref Tcp4ReceiveEngine section.
-
- This support routine is called by:
- <ul>
- <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>
- </ul>
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- **/
-VOID
-EslTcp4RxStart (
- IN ESL_PORT * pPort
- );
-
-/**
- Determine if the socket is configured.
-
- This routine uses the flag ESL_SOCKET::bConfigured to determine
- if the network layer's configuration routine has been called.
-
- This routine is called by EslSocketIsConfigured to verify
- that the socket has been configured.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @retval EFI_SUCCESS - The port is connected
- @retval EFI_NOT_STARTED - The port is not connected
-
- **/
- EFI_STATUS
- EslTcp4SocketIsConfigured (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Buffer data for transmission over a network connection.
-
- This routine buffers data for the transmit engine in one of two
- queues, one for urgent (out-of-band) data and the other for normal
- data. The urgent data is provided to TCP as soon as it is available,
- allowing the TCP layer to schedule transmission of the urgent data
- between packets of normal data.
-
- This routine is called by ::EslSocketTransmit to buffer
- data for transmission. When the transmit engine has resources,
- this routine will start the transmission of the next buffer on
- the network connection.
-
- Transmission errors are returned during the next transmission or
- during the close operation. Only buffering errors are returned
- during the current transmission attempt.
-
- @param [in] pSocket Address of an ::ESL_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
-
- **/
-EFI_STATUS
-EslTcp4TxBuffer (
- IN ESL_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
- );
-
-/**
- Process the normal data transmit completion
-
- This routine use ::EslSocketTxComplete to perform the transmit
- completion processing for normal data.
-
- This routine is called by the TCPv4 network layer when a
- normal data transmit request completes.
-
- @param [in] Event The normal transmit completion event
-
- @param [in] pIo The ESL_IO_MGMT structure address
-
-**/
-VOID
-EslTcp4TxComplete (
- IN EFI_EVENT Event,
- IN ESL_IO_MGMT * pIo
- );
-
-/**
- Process the urgent data transmit completion
-
- This routine use ::EslSocketTxComplete to perform the transmit
- completion processing for urgent data.
-
- This routine is called by the TCPv4 network layer when a
- urgent data transmit request completes.
-
- @param [in] Event The urgent transmit completion event
-
- @param [in] pIo The ESL_IO_MGMT structure address
-
-**/
-VOID
-EslTcp4TxOobComplete (
- IN EFI_EVENT Event,
- IN ESL_IO_MGMT * pIo
- );
-
-//------------------------------------------------------------------------------
-// Udp4 Routines
-//------------------------------------------------------------------------------
-
-/**
- Get the local socket address
-
- This routine returns the IPv4 address and UDP port number associated
- with the local socket.
-
- This routine is called by ::EslSocketGetLocalAddress to determine the
- network address for the SOCK_DGRAM socket.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [out] pAddress Network address to receive the local system address
-
-**/
-VOID
-EslUdp4LocalAddressGet (
- IN ESL_PORT * pPort,
- OUT struct sockaddr * pAddress
- );
-
-/**
- Set the local port address.
-
- This routine sets the local port address.
-
- This support routine is called by ::EslSocketPortAllocate.
-
- @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.
-
- **/
-VOID
-EslUdp4LocalAddressSet (
- IN ESL_PORT * pPort,
- IN CONST struct sockaddr * pSockAddr
- );
-
-/**
- Initialize the network specific portions of an ::ESL_PORT structure.
-
- This routine initializes the network specific portions of an
- ::ESL_PORT structure for use by the socket.
-
- This support routine is called by ::EslSocketPortAllocate
- to connect the socket with the underlying network adapter
- running the UDPv4 protocol.
-
- @param [in] ppPort Address of an ESL_PORT structure
- @param [in] DebugFlags Flags for debug messages
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslUdp4PortAllocate (
- IN ESL_PORT * pPort,
- IN UINTN DebugFlags
- );
-
-/**
- Close a UDP4 port.
-
- This routine releases the resources allocated by
- ::EslUdp4PortAllocate.
-
- This routine is called by:
- <ul>
- <li>::EslUdp4PortAllocate - Port initialization failure</li>
- <li>::EslUdp4PortCloseRxDone - Last step of close processing</li>
- </ul>
- See the \ref Udp4PortCloseStateMachine section.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @retval EFI_SUCCESS The port is closed
- @retval other Port close error
-
-**/
-EFI_STATUS
-EslUdp4PortClose (
- IN ESL_PORT * pPort
- );
-
-/**
- Free a receive packet
-
- This routine performs the network specific operations necessary
- to free a receive packet.
-
- This routine is called by ::EslSocketPortCloseTxDone to free a
- receive packet.
-
- @param [in] pPacket Address of an ::ESL_PACKET structure.
- @param [in, out] pRxBytes Address of the count of RX bytes
-
-**/
-VOID
-EslUdp4PortClosePacketFree (
- IN ESL_PACKET * pPacket,
- IN OUT size_t * pRxBytes
- );
-
-/**
- Perform the network specific close operation on the port.
-
- This routine performs a cancel operations on the UDPv4 port to
- shutdown the receive operations on the port.
-
- 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.
-
-**/
-EFI_STATUS
-EslUdp4PortCloseRxStop (
- IN ESL_PORT * pPort
- );
-
-/**
- Receive data from a network connection.
-
- This routine attempts to return buffered data to the caller. The
- data is only removed from the normal queue, the message flag
- MSG_OOB is ignored. See the \ref Udp4ReceiveEngine section.
-
- This routine is called by ::EslSocketReceive to handle the network
- specific receive operation to support SOCK_DGRAM sockets.
-
- @param [in] pSocket Address of an ::ESL_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 [out] pAddress Network address to receive the remote system address
-
- @param [in,out] pAddressLength Length of the remote network address structure
-
- @retval EFI_SUCCESS - Socket data successfully received
-
-**/
-EFI_STATUS
-EslUdp4Receive (
- IN ESL_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
- );
-
-/**
- Get the remote socket address
-
- This routine returns the address of the remote connection point
- associated with the SOCK_DGRAM socket.
-
- This routine is called by ::EslSocketGetPeerAddress to detemine
- the UDPv4 address and port number associated with the network adapter.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [out] pAddress Network address to receive the remote system address
-
-**/
-VOID
-EslUdp4RemoteAddressGet (
- IN ESL_PORT * pPort,
- OUT struct sockaddr * pAddress
- );
-
-/**
- Set the remote address
-
- This routine sets the remote address in the port.
-
- This routine is called by ::EslSocketConnect to specify the
- remote network address.
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- @param [in] pSockAddr Network address of the remote system.
-
- @param [in] SockAddrLength Length in bytes of the network address.
-
- **/
-VOID
-EslUdp4RemoteAddressSet (
- IN ESL_PORT * pPort,
- IN CONST struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
- Cancel the receive operations
-
- This routine cancels the pending receive operations.
- See the \ref Udp4ReceiveEngine section.
-
- This routine is called by ::EslSocketShutdown when the socket
- layer is being shutdown.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure
-
- @retval EFI_SUCCESS - The cancel was successful
-
- **/
-EFI_STATUS
-EslUdp4RxCancel (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Process the receive completion
-
- This routine keeps the UDPv4 driver's buffer and queues it in
- in FIFO order to the data queue. The UDP4 driver's buffer will
- be returned by either ::EslUdp4Receive or ::EslSocketPortCloseTxDone.
- See the \ref Tcp4ReceiveEngine section.
-
- This routine is called by the UDPv4 driver when data is
- received.
-
- @param [in] Event The receive completion event
-
- @param [in] pPort Address of an ::ESL_PORT structure
-
-**/
-VOID
-EslUdp4RxComplete (
- IN EFI_EVENT Event,
- IN ESL_PORT * pPort
- );
-
-/**
- Start a receive operation
-
- This routine posts a receive buffer to the UDPv4 driver.
- See the \ref Udp4ReceiveEngine section.
-
- This support routine is called by:
- <ul>
- <li>::EslUdp4SocketIsConfigured to start the recevie engine for the new socket.</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>
- </ul>
-
- @param [in] pPort Address of an ::ESL_PORT structure.
-
- **/
-VOID
-EslUdp4RxStart (
- IN ESL_PORT * pPort
- );
-
-/**
- Determine if the socket is configured.
-
- This routine uses the flag ESL_SOCKET::bConfigured to determine
- if the network layer's configuration routine has been called.
- This routine calls the bind and configuration routines if they
- were not already called. After the port is configured, the
- \ref Udp4ReceiveEngine is started.
-
- This routine is called by EslSocketIsConfigured to verify
- that the socket is configured.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure
-
- @retval EFI_SUCCESS - The port is connected
- @retval EFI_NOT_STARTED - The port is not connected
-
- **/
- EFI_STATUS
- EslUdp4SocketIsConfigured (
- IN ESL_SOCKET * pSocket
- );
-
-/**
- Buffer data for transmission over a network connection.
-
- This routine buffers data for the transmit engine in the normal
- data queue. When the \ref TransmitEngine has resources, this
- routine will start the transmission of the next buffer on the
- network connection.
-
- This routine is called by ::EslSocketTransmit 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 starts 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.
-
- Transmission errors are returned during the next transmission or
- during the close operation. Only buffering errors are returned
- during the current transmission attempt.
-
- @param [in] pSocket Address of an ::ESL_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
-
-**/
-EFI_STATUS
-EslUdp4TxBuffer (
- IN ESL_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
- );
-
-/**
- Process the transmit completion
-
- This routine use ::EslSocketTxComplete to perform the transmit
- completion processing for data packets.
-
- This routine is called by the UDPv4 network layer when a data
- transmit request completes.
-
- @param [in] Event The normal transmit completion event
-
- @param [in] pIo Address of an ::ESL_IO_MGMT structure
-
-**/
-VOID
-EslUdp4TxComplete (
- IN EFI_EVENT Event,
- IN ESL_IO_MGMT * pIo
- );
-
-//------------------------------------------------------------------------------
#endif // _SOCKET_H_
diff --git a/StdLib/EfiSocketLib/Tcp4.c b/StdLib/EfiSocketLib/Tcp4.c index 8c3a45c..0e58711 100644 --- a/StdLib/EfiSocketLib/Tcp4.c +++ b/StdLib/EfiSocketLib/Tcp4.c @@ -24,72 +24,85 @@ calls ::EslTcp4Accept to remove the next connection from the queue
and get the associated socket.
+**/
+
+#include "Socket.h"
+
+
+/**
+ Attempt to connect to a remote TCP port
- \section Tcp4ReceiveEngine TCPv4 Receive Engine
-
- The receive engine is started by calling ::EslTcp4RxStart when the
- ::ESL_PORT structure is allocated and stopped when ::EslSocketPortCloseTxDone
- calls the TCPv4 close operation. The receive engine consists of a
- single receive buffer that is posted to the TCPv4 driver. Upon
- completion, ::EslTcp4RxComplete posts the buffer to either the
- ESL_SOCKET::pRxOobPacketListTail or ESL_SOCKET::pRxPacketListTail
- depending on whether urgent or normal data was received.
-
- When the application wants to receive data it indirectly calls
- ::EslTcp4Receive to remove data from one of the data queues. If
- message flag MSG_OOB is specified, data is removed from
- ESL_SOCKET::pRxOobPacketListHead, otherwise data is removed from
- ESL_SOCKET::pRxPacketListHead.
-
- During socket layer shutdown, ::EslTcp4RxCancel is called by ::EslSocketShutdown to cancel the
- pending receive operations.
-
- Receive flow control is applied when the socket is created, since no receive
- operation is pending to the TCPv4 driver. The flow control gets released
- when the first receive request is made to ::EslTcp4Receive. Flow control
- remains in the released state, ::EslTcp4RxComplete calls ::EslTcp4RxStart
- until the maximum buffer space is consumed. By not calling EslTcp4RxStart,
- EslTcp4RxComplete applies flow control. Flow control is eventually released
- when the buffer space drops below the maximum amount and EslTcp4Receive
- calls EslTcp4RxStart.
+ This routine starts the connection processing for a SOCK_STREAM
+ or SOCK_SEQPAKCET socket using the TCPv4 network layer. It
+ configures the local TCPv4 connection point and then attempts to
+ connect to a remote system. Upon completion, the
+ ::EslTcp4ConnectComplete routine gets called with the connection
+ status.
+
+ This routine is called by ::EslSocketConnect to initiate the TCPv4
+ network specific connect operations. The connection processing is
+ initiated by this routine and finished by ::EslTcp4ConnectComplete.
+ This pair of routines walks through the list of local TCPv4
+ connection points until a connection to the remote system is
+ made.
+
+ @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.
+
+ **/
+EFI_STATUS
+EslTcp4ConnectStart (
+ 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.
+
+ The TCPv4 layer calls this routine when a connection is made to
+ the socket in the listen state. See the
+ \ref ConnectionManagement section.
+
+ @param [in] Event The listen completion event
+
+ @param [in] pPort Address of an ::ESL_PORT structure.
**/
+VOID
+EslTcp4ListenComplete (
+ IN EFI_EVENT Event,
+ IN ESL_PORT * pPort
+ );
-#include "Socket.h"
/**
- Interface between the socket layer and the network specific
- code that supports SOCK_STREAM and SOCK_SEQPACKET sockets
- over TCPv4.
+ Process the receive completion
+
+ 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 Tcp4ReceiveEngine section.
+
+ This routine is called by the TCPv4 driver when some data is
+ received.
+
+ Buffer the data that was just received.
+
+ @param [in] Event The receive completion event
+
+ @param [in] pPort Address of an ::ESL_PORT structure
+
**/
-CONST ESL_PROTOCOL_API cEslTcp4Api = {
- IPPROTO_TCP,
- OFFSET_OF ( ESL_LAYER, pTcp4List ),
- OFFSET_OF ( struct sockaddr_in, sin_zero ),
- sizeof ( struct sockaddr_in ),
- AF_INET,
- EslTcp4Accept,
- EslTcp4ConnectPoll,
- EslTcp4ConnectStart,
- EslTcp4SocketIsConfigured,
- EslTcp4LocalAddressGet,
- EslTcp4LocalAddressSet,
- EslTcp4Listen,
- NULL, // OptionGet
- NULL, // OptionSet
- EslTcp4PortAllocate,
- EslTcp4PortClose,
- EslTcp4PortClosePacketFree,
- EslTcp4PortCloseRxStop,
- FALSE,
- EslTcp4Receive,
- EslTcp4RemoteAddressGet,
- EslTcp4RemoteAddressSet,
- EslTcp4RxCancel,
- EslTcp4TxBuffer,
- EslTcp4TxComplete,
- EslTcp4TxOobComplete
-};
+VOID
+EslTcp4RxComplete (
+ IN EFI_EVENT Event,
+ IN ESL_PORT * pPort
+ );
/**
@@ -949,7 +962,7 @@ EslTcp4ListenComplete ( //
// Start the receive operation
//
- EslTcp4RxStart ( pNewPort );
+ EslSocketRxStart ( pNewPort );
}
else {
DEBUG (( DEBUG_ERROR | DEBUG_CONNECTION | DEBUG_INFO,
@@ -1661,7 +1674,7 @@ EslTcp4Receive ( //
if (( NULL == pPort->pReceivePending )
&& ( MAX_RX_DATA > pSocket->RxBytes )) {
- EslTcp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
}
}
}
@@ -2018,7 +2031,7 @@ EslTcp4RxComplete ( // Attempt to restart this receive operation
//
if ( pSocket->MaxRxBuf > pSocket->RxBytes ) {
- EslTcp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
}
else {
DEBUG (( DEBUG_RX,
@@ -2063,26 +2076,22 @@ EslTcp4RxComplete ( Start a receive operation
This routine posts a receive buffer to the TCPv4 driver.
- See the \ref Tcp4ReceiveEngine section.
+ See the \ref ReceiveEngine section.
- This support routine is called by:
- <ul>
- <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>
- </ul>
+ This support routine is called by EslSocketRxStart.
@param [in] pPort Address of an ::ESL_PORT structure.
+ @param [in] pPacket Address of an ::ESL_PACKET structure.
+
+ @retval EFI_SUCCESS Receive operation started successfully
**/
-VOID
+EFI_STATUS
EslTcp4RxStart (
- IN ESL_PORT * pPort
+ IN ESL_PORT * pPort,
+ IN ESL_PACKET * pPacket
)
{
- size_t LengthInBytes;
- ESL_PACKET * pPacket;
- ESL_SOCKET * pSocket;
ESL_TCP4_CONTEXT * pTcp4;
EFI_TCP4_PROTOCOL * pTcp4Protocol;
EFI_STATUS Status;
@@ -2090,91 +2099,27 @@ EslTcp4RxStart ( DBG_ENTER ( );
//
- // Determine if a receive is already pending
+ // Initialize the buffer for receive
//
- Status = EFI_SUCCESS;
- pPacket = NULL;
- pSocket = pPort->pSocket;
pTcp4 = &pPort->Context.Tcp4;
- if ( !EFI_ERROR ( pPort->pSocket->RxError )) {
- if (( NULL == pPort->pReceivePending )
- && ( PORT_STATE_CLOSE_STARTED > pPort->State )) {
- //
- // Determine if there are any free packets
- //
- pPacket = pSocket->pRxFree;
- LengthInBytes = sizeof ( pPacket->Op.Tcp4Rx.Buffer );
- if ( NULL != pPacket ) {
- //
- // Remove this packet from the free list
- //
- pSocket->pRxFree = pPacket->pNext;
- DEBUG (( DEBUG_RX,
- "0x%08x: Port removed packet 0x%08x from free list\r\n",
- pPort,
- pPacket ));
- }
- else {
- //
- // Allocate a packet structure
- //
- Status = EslSocketPacketAllocate ( &pPacket,
- sizeof ( pPacket->Op.Tcp4Rx ),
- DEBUG_RX );
- if ( EFI_ERROR ( Status )) {
- pPacket = NULL;
- DEBUG (( DEBUG_ERROR | DEBUG_RX,
- "0x%08x: Port failed to allocate RX packet, Status: %r\r\n",
- pPort,
- Status ));
- }
- }
-
- //
- // Determine if a packet is available
- //
- if ( NULL != pPacket ) {
- //
- // Initialize the buffer for receive
- //
- pTcp4->RxToken.Packet.RxData = &pPacket->Op.Tcp4Rx.RxData;
- pPacket->Op.Tcp4Rx.RxData.DataLength = (UINT32) LengthInBytes;
- pPacket->Op.Tcp4Rx.RxData.FragmentCount = 1;
- pPacket->Op.Tcp4Rx.RxData.FragmentTable[0].FragmentLength = (UINT32) LengthInBytes;
- pPacket->Op.Tcp4Rx.RxData.FragmentTable[0].FragmentBuffer = &pPacket->Op.Tcp4Rx.Buffer[0];
- pPort->pReceivePending = pPacket;
+ pTcp4->RxToken.Packet.RxData = &pPacket->Op.Tcp4Rx.RxData;
+ pPacket->Op.Tcp4Rx.RxData.DataLength = sizeof ( pPacket->Op.Tcp4Rx.Buffer );
+ pPacket->Op.Tcp4Rx.RxData.FragmentCount = 1;
+ pPacket->Op.Tcp4Rx.RxData.FragmentTable[0].FragmentLength = pPacket->Op.Tcp4Rx.RxData.DataLength;
+ pPacket->Op.Tcp4Rx.RxData.FragmentTable[0].FragmentBuffer = &pPacket->Op.Tcp4Rx.Buffer[0];
- //
- // Start the receive on the packet
- //
- pTcp4Protocol = pPort->pProtocol.TCPv4;
- Status = pTcp4Protocol->Receive ( pTcp4Protocol,
- &pTcp4->RxToken );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_RX | DEBUG_INFO,
- "0x%08x: Packet receive pending on port 0x%08x\r\n",
- pPacket,
- pPort ));
- }
- else {
- DEBUG (( DEBUG_RX | DEBUG_INFO,
- "ERROR - Failed to post a receive on port 0x%08x, Status: %r\r\n",
- pPort,
- Status ));
- pPort->pReceivePending = NULL;
- EslSocketPacketFree ( pPacket, DEBUG_RX | DEBUG_INFO );
- if ( !EFI_ERROR ( pSocket->RxError )) {
- //
- // Save the error status
- //
- pSocket->RxError = Status;
- }
- }
- }
- }
- }
+ //
+ // Start the receive on the packet
+ //
+ pTcp4Protocol = pPort->pProtocol.TCPv4;
+ Status = pTcp4Protocol->Receive ( pTcp4Protocol,
+ &pTcp4->RxToken );
- DBG_EXIT ( );
+ //
+ // Return the operation status
+ //
+ DBG_EXIT_STATUS ( Status );
+ return Status;
}
@@ -2555,3 +2500,40 @@ EslTcp4TxOobComplete ( &pPort->pTxOobFree );
DBG_EXIT ( );
}
+
+
+/**
+ Interface between the socket layer and the network specific
+ code that supports SOCK_STREAM and SOCK_SEQPACKET sockets
+ over TCPv4.
+**/
+CONST ESL_PROTOCOL_API cEslTcp4Api = {
+ IPPROTO_TCP,
+ OFFSET_OF ( ESL_LAYER, pTcp4List ),
+ OFFSET_OF ( struct sockaddr_in, sin_zero ),
+ sizeof ( struct sockaddr_in ),
+ AF_INET,
+ sizeof (((ESL_PACKET *)0 )->Op.Tcp4Rx ),
+ EslTcp4Accept,
+ EslTcp4ConnectPoll,
+ EslTcp4ConnectStart,
+ EslTcp4SocketIsConfigured,
+ EslTcp4LocalAddressGet,
+ EslTcp4LocalAddressSet,
+ EslTcp4Listen,
+ NULL, // OptionGet
+ NULL, // OptionSet
+ EslTcp4PortAllocate,
+ EslTcp4PortClose,
+ EslTcp4PortClosePacketFree,
+ EslTcp4PortCloseRxStop,
+ FALSE,
+ EslTcp4Receive,
+ EslTcp4RemoteAddressGet,
+ EslTcp4RemoteAddressSet,
+ EslTcp4RxCancel,
+ EslTcp4RxStart,
+ EslTcp4TxBuffer,
+ EslTcp4TxComplete,
+ EslTcp4TxOobComplete
+};
diff --git a/StdLib/EfiSocketLib/Udp4.c b/StdLib/EfiSocketLib/Udp4.c index cd26765..954e920 100644 --- a/StdLib/EfiSocketLib/Udp4.c +++ b/StdLib/EfiSocketLib/Udp4.c @@ -10,74 +10,32 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- \section Udp4ReceiveEngine UDPv4 Receive Engine
-
- The receive engine is started by calling ::EslUdp4RxStart when the
- ::ESL_PORT structure is configured and stopped when ::EslSocketPortCloseTxDone
- calls the UDPv4 configure operation to reset the port. The receive engine
- consists of a single receive buffer that is posted to the UDPv4 driver.
-
- Upon receive completion, ::EslUdp4RxComplete posts the UDPv4 buffer to the
- ESL_SOCKET::pRxPacketListTail. To minimize the number of buffer copies,
- the ::EslUdp4RxComplete 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 UDPv4 driver until the application layer requests
- the data or the socket is closed.
-
- When the application wants to receive data it indirectly calls
- ::EslUdp4Receive to remove data from the data queue. This routine
- removes the next available datagram from ESL_SOCKET::pRxPacketListHead
- and copies the data from the UDPv4 driver's buffer into the
- application's buffer. The UDPv4 driver's buffer is then returned.
-
- During socket layer shutdown, ::EslUdp4RxCancel is called by ::EslSocketShutdown
- to cancel the pending receive operations.
-
- Receive flow control is applied when the socket is created, since no receive
- operation is pending to the UDPv4 driver. The flow control gets released
- when the port is configured. Flow control remains in the released state,
- ::EslUdp4RxComplete calls ::EslUdp4RxStart until the maximum buffer space
- is consumed. By not calling EslUdp4RxStart, EslUdp4RxComplete applies flow
- control. Flow control is eventually released when the buffer space drops
- below the maximum amount and EslUdp4Receive calls EslUdp4RxStart.
-
**/
#include "Socket.h"
+
/**
- Interface between the socket layer and the network specific
- code that supports SOCK_DGRAM sockets over UDPv4.
+ Process the receive completion
+
+ This routine keeps the UDPv4 driver's buffer and queues it in
+ in FIFO order to the data queue. The UDP4 driver's buffer will
+ be returned by either ::EslUdp4Receive or ::EslSocketPortCloseTxDone.
+ See the \ref Tcp4ReceiveEngine section.
+
+ This routine is called by the UDPv4 driver when data is
+ received.
+
+ @param [in] Event The receive completion event
+
+ @param [in] pPort Address of an ::ESL_PORT structure
+
**/
-CONST ESL_PROTOCOL_API cEslUdp4Api = {
- IPPROTO_UDP,
- OFFSET_OF ( ESL_LAYER, pUdp4List ),
- OFFSET_OF ( struct sockaddr_in, sin_zero ),
- sizeof ( struct sockaddr_in ),
- AF_INET,
- NULL, // Accept
- NULL, // ConnectPoll
- NULL, // ConnectStart
- EslUdp4SocketIsConfigured,
- EslUdp4LocalAddressGet,
- EslUdp4LocalAddressSet,
- NULL, // Listen
- NULL, // OptionGet
- NULL, // OptionSet
- EslUdp4PortAllocate,
- EslUdp4PortClose,
- EslUdp4PortClosePacketFree,
- EslUdp4PortCloseRxStop,
- TRUE,
- EslUdp4Receive,
- EslUdp4RemoteAddressGet,
- EslUdp4RemoteAddressSet,
- EslUdp4RxCancel,
- EslUdp4TxBuffer,
- EslUdp4TxComplete,
- NULL // TxOobComplete
-};
+VOID
+EslUdp4RxComplete (
+ IN EFI_EVENT Event,
+ IN ESL_PORT * pPort
+ );
/**
@@ -643,7 +601,7 @@ EslUdp4Receive ( //
if (( NULL == pPort->pReceivePending )
&& ( MAX_RX_DATA > pSocket->RxBytes )) {
- EslUdp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
}
}
@@ -957,7 +915,7 @@ EslUdp4RxComplete ( // Attempt to restart this receive operation
//
if ( pSocket->MaxRxBuf > pSocket->RxBytes ) {
- EslUdp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
}
else {
DEBUG (( DEBUG_RX,
@@ -1015,25 +973,22 @@ EslUdp4RxComplete ( Start a receive operation
This routine posts a receive buffer to the UDPv4 driver.
- See the \ref Udp4ReceiveEngine section.
+ See the \ref ReceiveEngine section.
- This support routine is called by:
- <ul>
- <li>::EslUdp4SocketIsConfigured to start the recevie engine for the new socket.</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>
- </ul>
+ This support routine is called by EslSocketRxStart.
@param [in] pPort Address of an ::ESL_PORT structure.
+ @param [in] pPacket Address of an ::ESL_PACKET structure.
+
+ @retval EFI_SUCCESS Receive operation started successfully
**/
-VOID
+EFI_STATUS
EslUdp4RxStart (
- IN ESL_PORT * pPort
+ IN ESL_PORT * pPort,
+ IN ESL_PACKET * pPacket
)
{
- ESL_PACKET * pPacket;
- ESL_SOCKET * pSocket;
ESL_UDP4_CONTEXT * pUdp4;
EFI_UDP4_PROTOCOL * pUdp4Protocol;
EFI_STATUS Status;
@@ -1041,93 +996,24 @@ EslUdp4RxStart ( DBG_ENTER ( );
//
- // Determine if a receive is already pending
+ // Initialize the buffer for receive
//
- Status = EFI_SUCCESS;
- pPacket = NULL;
- pSocket = pPort->pSocket;
+ pPacket->Op.Udp4Rx.pRxData = NULL;
pUdp4 = &pPort->Context.Udp4;
- if ( !EFI_ERROR ( pPort->pSocket->RxError )) {
- if (( NULL == pPort->pReceivePending )
- && ( PORT_STATE_CLOSE_STARTED > pPort->State )) {
- //
- // Determine if there are any free packets
- //
- pPacket = pSocket->pRxFree;
- if ( NULL != pPacket ) {
- //
- // Remove this packet from the free list
- //
- pSocket->pRxFree = pPacket->pNext;
- DEBUG (( DEBUG_RX,
- "0x%08x: Port removed packet 0x%08x from free list\r\n",
- pPort,
- pPacket ));
- }
- else {
- //
- // Allocate a packet structure
- //
- Status = EslSocketPacketAllocate ( &pPacket,
- sizeof ( pPacket->Op.Udp4Rx ),
- DEBUG_RX );
- if ( EFI_ERROR ( Status )) {
- pPacket = NULL;
- DEBUG (( DEBUG_ERROR | DEBUG_RX,
- "0x%08x: Port failed to allocate RX packet, Status: %r\r\n",
- pPort,
- Status ));
- }
- }
-
- //
- // Determine if a packet is available
- //
- if ( NULL != pPacket ) {
- //
- // Initialize the buffer for receive
- //
- pPacket->pNext = NULL;
- pPacket->Op.Udp4Rx.pRxData = NULL;
- pUdp4->RxToken.Packet.RxData = NULL;
- pPort->pReceivePending = pPacket;
+ pUdp4->RxToken.Packet.RxData = NULL;
- //
- // Start the receive on the packet
- //
- pUdp4Protocol = pPort->pProtocol.UDPv4;
- Status = pUdp4Protocol->Receive ( pUdp4Protocol,
- &pUdp4->RxToken );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_RX | DEBUG_INFO,
- "0x%08x: Packet receive pending on port 0x%08x\r\n",
- pPacket,
- pPort ));
- }
- else {
- DEBUG (( DEBUG_RX | DEBUG_INFO,
- "ERROR - Failed to post a receive on port 0x%08x, Status: %r\r\n",
- pPort,
- Status ));
- if ( !EFI_ERROR ( pSocket->RxError )) {
- //
- // Save the error status
- //
- pSocket->RxError = Status;
- }
-
- //
- // Free the packet
- //
- pPort->pReceivePending = NULL;
- pPacket->pNext = pSocket->pRxFree;
- pSocket->pRxFree = pPacket;
- }
- }
- }
- }
+ //
+ // Start the receive on the packet
+ //
+ pUdp4Protocol = pPort->pProtocol.UDPv4;
+ Status = pUdp4Protocol->Receive ( pUdp4Protocol,
+ &pUdp4->RxToken );
- DBG_EXIT ( );
+ //
+ // Return the operation status
+ //
+ DBG_EXIT_STATUS ( Status );
+ return Status;
}
@@ -1274,7 +1160,7 @@ EslUdp4RxStart ( //
// Start the first read on the port
//
- EslUdp4RxStart ( pPort );
+ EslSocketRxStart ( pPort );
//
// The socket is connected
@@ -1598,3 +1484,39 @@ EslUdp4TxComplete ( &pPort->pTxFree );
DBG_EXIT ( );
}
+
+
+/**
+ Interface between the socket layer and the network specific
+ code that supports SOCK_DGRAM sockets over UDPv4.
+**/
+CONST ESL_PROTOCOL_API cEslUdp4Api = {
+ IPPROTO_UDP,
+ OFFSET_OF ( ESL_LAYER, pUdp4List ),
+ OFFSET_OF ( struct sockaddr_in, sin_zero ),
+ sizeof ( struct sockaddr_in ),
+ AF_INET,
+ sizeof (((ESL_PACKET *)0 )->Op.Udp4Rx ),
+ NULL, // Accept
+ NULL, // ConnectPoll
+ NULL, // ConnectStart
+ EslUdp4SocketIsConfigured,
+ EslUdp4LocalAddressGet,
+ EslUdp4LocalAddressSet,
+ NULL, // Listen
+ NULL, // OptionGet
+ NULL, // OptionSet
+ EslUdp4PortAllocate,
+ EslUdp4PortClose,
+ EslUdp4PortClosePacketFree,
+ EslUdp4PortCloseRxStop,
+ TRUE,
+ EslUdp4Receive,
+ EslUdp4RemoteAddressGet,
+ EslUdp4RemoteAddressSet,
+ EslUdp4RxCancel,
+ EslUdp4RxStart,
+ EslUdp4TxBuffer,
+ EslUdp4TxComplete,
+ NULL // TxOobComplete
+};
|