]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/EfiSocketLib/Socket.c
StdLib: Remove EfiSocketLib and Ip4Config Protocol dependency.
[mirror_edk2.git] / StdLib / EfiSocketLib / Socket.c
index a74dcd07f60021f5a2f74a841438038079c504a2..d782b435e658a8251cd02447eb00d538ee0e1fd7 100644 (file)
@@ -5,10 +5,10 @@
   * Bound - pSocket->PortList is not NULL\r
   * Listen - AcceptWait event is not NULL\r
 \r
-  Copyright (c) 2011, Intel Corporation\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
+  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials are licensed and made available under\r
+  the terms and conditions of the BSD License that accompanies this distribution.\r
+  The full text of the license may be found at\r
   http://opensource.org/licenses/bsd-license.php\r
 \r
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 \r
   <code><pre>\r
 \r
-                +-------------+   +-------------+   +-------------+   \r
+                +---------------+   +-------------+   +-------------+\r
   Service Lists | ::ESL_SERVICE |-->| ESL_SERVICE |-->| ESL_SERVICE |--> NULL (pNext)\r
-                +-------------+   +-------------+   +-------------+   \r
+                +---------------+   +-------------+   +-------------+\r
                   ^                       | (pPortList)    |\r
     pUdp4List ^   | pTcp4List             |                |\r
               |   |                       |                |\r
           ^   |   |                       |                |\r
  pIp4List |   |   |                       |                |\r
         +---------------+                 |                |\r
-        |   ::ESL_LAYER   |   ::mEslLayer     |                |\r
+        | ::ESL_LAYER   | ::mEslLayer     |                |\r
         +---------------+                 |                |\r
                   | (pSocketList)         |                |\r
     Socket List   V                       V                V\r
-                +-------------+   +-------------+   +-------------+   \r
-                | ::ESL_SOCKET  |-->|   ::ESL_PORT  |-->|   ESL_PORT  |--> NULL (pLinkSocket)\r
-                +-------------+   +-------------+   +-------------+   \r
+                +---------------+   +-------------+   +-------------+\r
+                | ::ESL_SOCKET  |-->| ::ESL_PORT  |-->|   ESL_PORT  |--> NULL (pLinkSocket)\r
+                +---------------+   +-------------+   +-------------+\r
                   |                       |                |\r
                   |                       |                V\r
                   V                       V               NULL\r
-                +-------------+   +-------------+         \r
+                +-------------+   +-------------+\r
                 | ESL_SOCKET  |-->|   ESL_PORT  |--> NULL\r
                 +-------------+   +-------------+\r
                   |    | | | |            |\r
@@ -53,9 +53,9 @@
                        | `---------------.                  |                |\r
   pTxOobPacketListHead |                 |                  |                |\r
                        V                 V                  V                V\r
-                  +------------+    +------------+    +------------+    +------------+\r
+                  +--------------+    +------------+    +------------+    +------------+\r
                   | ::ESL_PACKET |    | ESL_PACKET |    | ESL_PACKET |    | ESL_PACKET |\r
-                  +------------+    +------------+    +------------+    +------------+\r
+                  +--------------+    +------------+    +------------+    +------------+\r
                          |                 |                |                |\r
                          V                 V                V                V\r
                   +------------+    +------------+    +------------+    +------------+\r
       ::EslTcp4PortCloseOp.\r
     </li>\r
     <li>State: PORT_STATE_CLOSE_TX_DONE</li>\r
-    <li>Arc: ::EslSocketPortCloseComplete - Called when the close operation is \r
+    <li>Arc: ::EslSocketPortCloseComplete - Called when the close operation is\r
       complete.  After the transition to PORT_STATE_CLOSE_DONE,\r
       this routine calls ::EslSocketRxCancel to abort the pending receive operations.\r
     </li>\r
          pPort->pRxActive\r
                 |\r
                 V\r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
   Active  | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
 \r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
   Free    | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
                 ^\r
                 |\r
           pPort->pRxFree\r
 \r
 <code><pre>\r
 \r
-                    +------------+   +------------+   \r
+                    +------------+   +------------+\r
     High     .----->| ESL_PACKET |-->| ESL_PACKET |--> NULL (pNext)\r
   Priority   |      +------------+   +------------+\r
              |\r
        +------------+\r
              | pRxPacketListHead\r
     Low      |\r
-  Priority   |      +------------+   +------------+   +------------+   \r
+  Priority   |      +------------+   +------------+   +------------+\r
              `----->| ::ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL\r
-                    +------------+   +------------+   +------------+   \r
+                    +------------+   +------------+   +------------+\r
 \r
 </pre></code>\r
 \r
   ::EslSocketRxStart connects an ::ESL_PACKET structure to the ::ESL_IO_MGMT structure\r
-  and then calls the network layer to start the receive operation.  Upon \r
+  and then calls the network layer to start the receive operation.  Upon\r
   receive completion, ::EslSocketRxComplete breaks the connection between these\r
   structrues and places the ESL_IO_MGMT structure onto the ESL_PORT::pRxFree list to\r
   make token and event available for another receive operation.  EslSocketRxComplete\r
      *ppQueueHead: pSocket->pRxPacketListHead or pSocket->pRxOobPacketListHead\r
           |\r
           V\r
-        +------------+   +------------+   +------------+   \r
+        +------------+   +------------+   +------------+\r
   Data  | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL\r
-        +------------+   +------------+   +------------+   \r
+        +------------+   +------------+   +------------+\r
                                                      ^\r
                                                      |\r
      *ppQueueTail: pSocket->pRxPacketListTail or pSocket->pRxOobPacketListTail\r
          pPort->pTxActive or pTxOobActive\r
                 |\r
                 V\r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
   Active  | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
 \r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
   Free    | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-          +-------------+   +-------------+   +-------------+   \r
+          +-------------+   +-------------+   +-------------+\r
                 ^\r
                 |\r
           pPort->pTxFree or pTxOobFree\r
 #include "Socket.h"\r
 \r
 \r
-/**\r
-  Socket driver connection points\r
+/** Socket driver connection points\r
 \r
   List the network stack connection points for the socket driver.\r
 **/\r
@@ -509,9 +508,7 @@ CONST ESL_SOCKET_BINDING cEslSocketBinding[] = {
 \r
 CONST UINTN cEslSocketBindingEntries = DIM ( cEslSocketBinding );\r
 \r
-/**\r
-  APIs to support the various socket types for the v4 network stack.\r
-**/\r
+/// APIs to support the various socket types for the v4 network stack.\r
 CONST ESL_PROTOCOL_API * cEslAfInetApi[] = {\r
   NULL,             //  0\r
   &cEslTcp4Api,     //  SOCK_STREAM\r
@@ -521,15 +518,11 @@ CONST ESL_PROTOCOL_API * cEslAfInetApi[] = {
   &cEslTcp4Api      //  SOCK_SEQPACKET\r
 };\r
 \r
-/**\r
-  Number of entries in the v4 API array ::cEslAfInetApi.\r
-**/\r
+/// Number of entries in the v4 API array ::cEslAfInetApi.\r
 CONST int cEslAfInetApiSize = DIM ( cEslAfInetApi );\r
 \r
 \r
-/**\r
-  APIs to support the various socket types for the v6 network stack.\r
-**/\r
+/// APIs to support the various socket types for the v6 network stack.\r
 CONST ESL_PROTOCOL_API * cEslAfInet6Api[] = {\r
   NULL,             //  0\r
   &cEslTcp6Api,     //  SOCK_STREAM\r
@@ -539,40 +532,34 @@ CONST ESL_PROTOCOL_API * cEslAfInet6Api[] = {
   &cEslTcp6Api      //  SOCK_SEQPACKET\r
 };\r
 \r
-/**\r
-  Number of entries in the v6 API array ::cEslAfInet6Api.\r
-**/\r
+/// Number of entries in the v6 API array ::cEslAfInet6Api.\r
 CONST int cEslAfInet6ApiSize = DIM ( cEslAfInet6Api );\r
 \r
 \r
-/**\r
-  Global management structure for the socket layer.\r
-**/\r
+/// Global management structure for the socket layer.\r
 ESL_LAYER mEslLayer;\r
 \r
 \r
-/**\r
-  Initialize an endpoint for network communication.\r
+/** Initialize an endpoint for network communication.\r
 \r
   This routine initializes the communication endpoint.\r
 \r
   The ::socket routine calls this routine indirectly to create\r
   the communication endpoint.\r
 \r
-  @param [in] pSocketProtocol Address of the socket protocol structure.\r
-  @param [in] domain    Select the family of protocols for the client or server\r
-                        application.  See the ::socket documentation for values.\r
-  @param [in] type      Specifies how to make the network connection.\r
-                        See the ::socket documentation for values.\r
-  @param [in] protocol  Specifies the lower layer protocol to use.\r
-                        See the ::socket documentation for values.\r
-  @param [out] pErrno   Address to receive the errno value upon completion.\r
+  @param[in] pSocketProtocol Address of the socket protocol structure.\r
+  @param[in]  domain   Select the family of protocols for the client or server\r
+                       application.  See the ::socket documentation for values.\r
+  @param[in]  type     Specifies how to make the network connection.\r
+                       See the ::socket documentation for values.\r
+  @param[in]  protocol Specifies the lower layer protocol to use.\r
+                       See the ::socket documentation for values.\r
+  @param[out] pErrno   Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket successfully created\r
   @retval EFI_INVALID_PARAMETER - Invalid domain value, errno = EAFNOSUPPORT\r
   @retval EFI_INVALID_PARAMETER - Invalid type value, errno = EINVAL\r
   @retval EFI_INVALID_PARAMETER - Invalid protocol value, errno = EINVAL\r
-\r
  **/\r
 EFI_STATUS\r
 EslSocket (\r
@@ -593,31 +580,21 @@ EslSocket (
 \r
   DBG_ENTER ( );\r
 \r
-  //\r
   //  Locate the socket\r
-  //\r
   pSocket = SOCKET_FROM_PROTOCOL ( pSocketProtocol );\r
 \r
-  //\r
   //  Set the default domain if necessary\r
-  //\r
   if ( AF_UNSPEC == domain ) {\r
     domain = AF_INET;\r
   }\r
 \r
-  //\r
   //  Assume success\r
-  //\r
   errno = 0;\r
   Status = EFI_SUCCESS;\r
 \r
-  //\r
   //  Use break instead of goto\r
-  //\r
   for ( ; ; ) {\r
-    //\r
     //  Validate the domain value\r
-    //\r
     if (( AF_INET != domain )\r
       && ( AF_INET6 != domain )\r
       && ( AF_LOCAL != domain )) {\r
@@ -628,9 +605,7 @@ EslSocket (
       break;\r
     }\r
 \r
-    //\r
     //  Determine the protocol APIs\r
-    //\r
     ppApiArray = NULL;\r
     ApiArraySize = 0;\r
     if (( AF_INET == domain )\r
@@ -643,47 +618,35 @@ EslSocket (
       ApiArraySize = cEslAfInet6ApiSize;\r
     }\r
 \r
-    //\r
     //  Set the default type if necessary\r
-    //\r
     if ( 0 == type ) {\r
       type = SOCK_STREAM;\r
     }\r
 \r
-    //\r
     //  Validate the type value\r
-    //\r
     if (( type >= ApiArraySize )\r
       || ( NULL == ppApiArray )\r
       || ( NULL == ppApiArray[ type ])) {\r
       DEBUG (( DEBUG_ERROR | DEBUG_SOCKET,\r
                 "ERROR - Invalid type value\r\n" ));\r
-      //\r
       //  The socket type is not supported\r
-      //\r
       Status = EFI_INVALID_PARAMETER;\r
       errno = EPROTOTYPE;\r
       break;\r
     }\r
 \r
-    //\r
     //  Set the default protocol if necessary\r
-    //\r
     pApi = ppApiArray[ type ];\r
     if ( 0 == protocol ) {\r
       protocol = pApi->DefaultProtocol;\r
     }\r
 \r
-    //\r
     //  Validate the protocol value\r
-    //\r
     if (( pApi->DefaultProtocol != protocol )\r
       && ( SOCK_RAW != type )) {\r
       Status = EFI_INVALID_PARAMETER;\r
 \r
-      //\r
       //  Assume that the driver supports this protocol\r
-      //\r
       ppApiArray = &cEslAfInetApi[0];\r
       ppApiArrayEnd = &ppApiArray [ cEslAfInetApiSize ];\r
       while ( ppApiArrayEnd > ppApiArray ) {\r
@@ -694,9 +657,7 @@ EslSocket (
         ppApiArray += 1;\r
       }\r
       if ( ppApiArrayEnd <= ppApiArray ) {\r
-        //\r
         //  Verify against the IPv6 table\r
-        //\r
         ppApiArray = &cEslAfInet6Api[0];\r
         ppApiArrayEnd = &ppApiArray [ cEslAfInet6ApiSize ];\r
         while ( ppApiArrayEnd > ppApiArray ) {\r
@@ -714,33 +675,23 @@ EslSocket (
         break;\r
       }\r
 \r
-      //\r
       //  The driver does not support this protocol\r
-      //\r
       DEBUG (( DEBUG_ERROR | DEBUG_SOCKET,\r
                 "ERROR - The protocol does not support this socket type!\r\n" ));\r
       errno = EPROTONOSUPPORT;\r
       errno = EPROTOTYPE;\r
       break;\r
     }\r
-\r
-    //\r
     //  Save the socket attributes\r
-    //\r
     pSocket->pApi = pApi;\r
     pSocket->Domain = domain;\r
     pSocket->Type = type;\r
     pSocket->Protocol = protocol;\r
 \r
-    //\r
     //  Done\r
-    //\r
     break;\r
   }\r
-\r
-  //\r
   //  Return the operation status\r
-  //\r
   if ( NULL != pErrno ) {\r
     *pErrno = errno;\r
   }\r
@@ -749,8 +700,7 @@ EslSocket (
 }\r
 \r
 \r
-/**\r
-  Accept a network connection.\r
+/** Accept a network connection.\r
 \r
   This routine calls the network specific layer to remove the next\r
   connection from the FIFO.\r
@@ -761,24 +711,19 @@ EslSocket (
   associated with the new socket and the remote network address\r
   if requested.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-\r
-  @param [in] pSockAddr       Address of a buffer to receive the remote\r
-                              network address.\r
-\r
-  @param [in, out] pSockAddrLength  Length in bytes of the address buffer.\r
+  @param[in]      pSocketProtocol   Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]      pSockAddr         Address of a buffer to receive the remote\r
+                                    network address.\r
+  @param[in,out]  pSockAddrLength   Length in bytes of the address buffer.\r
                                     On output specifies the length of the\r
                                     remote network address.\r
-\r
-  @param [out] ppSocketProtocol Address of a buffer to receive the\r
-                                ::EFI_SOCKET_PROTOCOL instance\r
-                                associated with the new socket.\r
-\r
-  @param [out] pErrno   Address to receive the errno value upon completion.\r
+  @param[out]     ppSocketProtocol  Address of a buffer to receive the\r
+                                    ::EFI_SOCKET_PROTOCOL instance\r
+                                    associated with the new socket.\r
+  @param[out]     pErrno            Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS   New connection successfully created\r
   @retval EFI_NOT_READY No connection is available\r
-\r
  **/\r
 EFI_STATUS\r
 EslSocketAccept (\r
@@ -954,29 +899,27 @@ EslSocketAccept (
 }\r
 \r
 \r
-/**\r
-  Allocate and initialize a ESL_SOCKET structure.\r
-  \r
+/** Allocate and initialize a ESL_SOCKET structure.\r
+\r
   This support function allocates an ::ESL_SOCKET structure\r
   and installs a protocol on ChildHandle.  If pChildHandle is a\r
   pointer to NULL, then a new handle is created and returned in\r
   pChildHandle.  If pChildHandle is not a pointer to NULL, then\r
   the protocol installs on the existing pChildHandle.\r
 \r
-  @param [in, out] pChildHandle Pointer to the handle of the child to create.\r
+  @param[in,out]  pChildHandle  Pointer to the handle of the child to create.\r
                                 If it is NULL, then a new handle is created.\r
-                                If it is a pointer to an existing UEFI handle, \r
+                                If it is a pointer to an existing UEFI handle,\r
                                 then the protocol is added to the existing UEFI\r
                                 handle.\r
-  @param [in] DebugFlags        Flags for debug messages\r
-  @param [in, out] ppSocket     The buffer to receive an ::ESL_SOCKET structure address.\r
+  @param[in]      DebugFlags    Flags for debug messages\r
+  @param[in,out]  ppSocket      The buffer to receive an ::ESL_SOCKET structure address.\r
 \r
   @retval EFI_SUCCESS           The protocol was added to ChildHandle.\r
   @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
   @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to create\r
                                 the child\r
   @retval other                 The child handle was not created\r
-  \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1096,8 +1039,7 @@ EslSocketAllocate (
 }\r
 \r
 \r
-/**\r
-  Bind a name to a socket.\r
+/** Bind a name to a socket.\r
 \r
   This routine calls the network specific layer to save the network\r
   address of the local connection point.\r
@@ -1105,25 +1047,21 @@ EslSocketAllocate (
   The ::bind routine calls this routine to connect a name\r
   (network address and port) to a socket on the local machine.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-\r
-  @param [in] pSockAddr Address of a sockaddr structure that contains the\r
-                        connection point on the local machine.  An IPv4 address\r
-                        of INADDR_ANY specifies that the connection is made to\r
-                        all of the network stacks on the platform.  Specifying a\r
-                        specific IPv4 address restricts the connection to the\r
-                        network stack supporting that address.  Specifying zero\r
-                        for the port causes the network layer to assign a port\r
-                        number from the dynamic range.  Specifying a specific\r
-                        port number causes the network layer to use that port.\r
-\r
-  @param [in] SockAddrLength  Specifies the length in bytes of the sockaddr structure.\r
-\r
-  @param [out] pErrno   Address to receive the errno value upon completion.\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]  pSockAddr       Address of a sockaddr structure that contains the\r
+                              connection point on the local machine.  An IPv4 address\r
+                              of INADDR_ANY specifies that the connection is made to\r
+                              all of the network stacks on the platform.  Specifying a\r
+                              specific IPv4 address restricts the connection to the\r
+                              network stack supporting that address.  Specifying zero\r
+                              for the port causes the network layer to assign a port\r
+                              number from the dynamic range.  Specifying a specific\r
+                              port number causes the network layer to use that port.\r
+  @param[in]  SockAddrLength  Specifies the length in bytes of the sockaddr structure.\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket successfully created\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketBind (\r
   IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
@@ -1306,16 +1244,14 @@ EslSocketBind (
 }\r
 \r
 \r
-/**\r
-  Test the bind configuration.\r
+/** Test the bind configuration.\r
 \r
-  @param [in] pPort       Address of the ::ESL_PORT structure.\r
-  @param [in] ErrnoValue  errno value if test fails\r
+  @param[in] pPort        Address of the ::ESL_PORT structure.\r
+  @param[in] ErrnoValue   errno value if test fails\r
 \r
   @retval EFI_SUCCESS   The connection was successfully established.\r
   @retval Others        The connection attempt failed.\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketBindTest (\r
   IN ESL_PORT * pPort,\r
@@ -1336,27 +1272,40 @@ EslSocketBindTest (
   pConfigData = (VOID *)pBuffer;\r
 \r
   //\r
-  //  Attempt to use this configuration\r
+  //  Validate that the port is connected\r
   //\r
-  Status = pPort->pfnConfigure ( pPort->pProtocol.v, pConfigData );\r
+  Status = pPort->pSocket->pApi->pfnVerifyLocalIpAddress ( pPort, pBuffer );\r
   if ( EFI_ERROR ( Status )) {\r
     DEBUG (( DEBUG_WARN | DEBUG_BIND,\r
-              "WARNING - Port 0x%08x failed configuration, Status: %r\r\n",\r
+              "WARNING - Port 0x%08x invalid IP address: %r\r\n",\r
               pPort,\r
               Status ));\r
     pPort->pSocket->errno = ErrnoValue;\r
   }\r
   else {\r
     //\r
-    //  Reset the port\r
+    //  Attempt to use this configuration\r
     //\r
-    Status = pPort->pfnConfigure ( pPort->pProtocol.v, NULL );\r
+    Status = pPort->pfnConfigure ( pPort->pProtocol.v, pConfigData );\r
     if ( EFI_ERROR ( Status )) {\r
-      DEBUG (( DEBUG_ERROR | DEBUG_BIND,\r
-                "ERROR - Port 0x%08x failed configuration reset, Status: %r\r\n",\r
+      DEBUG (( DEBUG_WARN | DEBUG_BIND,\r
+                "WARNING - Port 0x%08x failed configuration, Status: %r\r\n",\r
                 pPort,\r
                 Status ));\r
-      ASSERT ( EFI_SUCCESS == Status );\r
+      pPort->pSocket->errno = ErrnoValue;\r
+    }\r
+    else {\r
+      //\r
+      //  Reset the port\r
+      //\r
+      Status = pPort->pfnConfigure ( pPort->pProtocol.v, NULL );\r
+      if ( EFI_ERROR ( Status )) {\r
+        DEBUG (( DEBUG_ERROR | DEBUG_BIND,\r
+                  "ERROR - Port 0x%08x failed configuration reset, Status: %r\r\n",\r
+                  pPort,\r
+                  Status ));\r
+        ASSERT ( EFI_SUCCESS == Status );\r
+      }\r
     }\r
   }\r
 \r
@@ -1368,8 +1317,7 @@ EslSocketBindTest (
 }\r
 \r
 \r
-/**\r
-  Determine if the socket is closed\r
+/** Determine if the socket is closed.\r
 \r
   This routine checks the state of the socket to determine if\r
   the network specific layer has completed the close operation.\r
@@ -1378,14 +1326,13 @@ EslSocketBindTest (
   close operation is complete.  The close operation needs to\r
   reverse the operations of the ::EslSocketAllocate routine.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS     Socket successfully closed\r
   @retval EFI_NOT_READY   Close still in progress\r
   @retval EFI_ALREADY     Close operation already in progress\r
   @retval Other           Failed to close the socket\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketClosePoll (\r
@@ -1506,8 +1453,7 @@ EslSocketClosePoll (
 }\r
 \r
 \r
-/**\r
-  Start the close operation on the socket\r
+/** Start the close operation on the socket.\r
 \r
   This routine calls the network specific layer to initiate the\r
   close state machine.  This routine then calls the network\r
@@ -1521,15 +1467,14 @@ EslSocketClosePoll (
   the ::EslSocketClosePoll routine to determine when the\r
   socket is closed.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  @param [in] bCloseNow       Boolean to control close behavior\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in] pSocketProtocol  Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in] bCloseNow        Boolean to control close behavior\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS     Socket successfully closed\r
   @retval EFI_NOT_READY   Close still in progress\r
   @retval EFI_ALREADY     Close operation already in progress\r
   @retval Other           Failed to close the socket\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketCloseStart (\r
@@ -1620,8 +1565,7 @@ EslSocketCloseStart (
 }\r
 \r
 \r
-/**\r
-  Connect to a remote system via the network.\r
+/** Connect to a remote system via the network.\r
 \r
   This routine calls the network specific layer to establish\r
   the remote system address and establish the connection to\r
@@ -1631,19 +1575,15 @@ EslSocketCloseStart (
   connection with the specified remote system.  This routine\r
   is designed to be polled by the connect routine for completion\r
   of the network connection.\r
-  \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-\r
-  @param [in] pSockAddr       Network address of the remote system.\r
-    \r
-  @param [in] SockAddrLength  Length in bytes of the network address.\r
-  \r
-  @param [out] pErrno   Address to receive the errno value upon completion.\r
-  \r
-  @retval EFI_SUCCESS   The connection was successfully established.\r
-  @retval EFI_NOT_READY The connection is in progress, call this routine again.\r
-  @retval Others        The connection attempt failed.\r
 \r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]  pSockAddr       Network address of the remote system.\r
+  @param[in]  SockAddrLength  Length in bytes of the network address.\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
+\r
+  @retval EFI_SUCCESS     The connection was successfully established.\r
+  @retval EFI_NOT_READY   The connection is in progress, call this routine again.\r
+  @retval Others          The connection attempt failed.\r
  **/\r
 EFI_STATUS\r
 EslSocketConnect (\r
@@ -1658,7 +1598,7 @@ EslSocketConnect (
   ESL_SOCKET * pSocket;\r
   EFI_STATUS Status;\r
   EFI_TPL TplPrevious;\r
-  \r
+\r
   DEBUG (( DEBUG_CONNECT, "Entering SocketConnect\r\n" ));\r
 \r
   //\r
@@ -1812,15 +1752,7 @@ EslSocketConnect (
           //  Set the next state if connected\r
           //\r
           if ( EFI_NOT_READY != Status ) {\r
-            if ( !EFI_ERROR ( Status )) {\r
-              pSocket->State = SOCKET_STATE_CONNECTED;\r
-\r
-              //\r
-              //  Start the receive operations\r
-              //\r
-              EslSocketRxStart ( pSocket->pPortList );\r
-            }\r
-            else {\r
+            if ( EFI_ERROR ( Status )) {\r
               pSocket->State = SOCKET_STATE_BOUND;\r
             }\r
           }\r
@@ -1829,10 +1761,9 @@ EslSocketConnect (
 \r
       case SOCKET_STATE_CONNECTED:\r
         //\r
-        //  Already connected\r
+        //  Connected\r
         //\r
-        pSocket->errno = EISCONN;\r
-        Status = EFI_ALREADY_STARTED;\r
+        Status = EFI_SUCCESS;\r
         break;\r
       }\r
 \r
@@ -1869,25 +1800,19 @@ EslSocketConnect (
 }\r
 \r
 \r
-/**\r
-  Copy a fragmented buffer into a destination buffer.\r
+/** Copy a fragmented buffer into a destination buffer.\r
 \r
   This support routine copies a fragmented buffer to the caller specified buffer.\r
 \r
   This routine is called by ::EslIp4Receive and ::EslUdp4Receive.\r
 \r
-  @param [in] FragmentCount   Number of fragments in the table\r
-\r
-  @param [in] pFragmentTable  Address of an EFI_IP4_FRAGMENT_DATA structure\r
-\r
-  @param [in] BufferLength    Length of the the buffer\r
-\r
-  @param [in] pBuffer         Address of a buffer to receive the data.\r
-\r
-  @param [in] pDataLength     Number of received data bytes in the buffer.\r
+  @param[in]  FragmentCount   Number of fragments in the table\r
+  @param[in]  pFragmentTable  Address of an EFI_IP4_FRAGMENT_DATA structure\r
+  @param[in]  BufferLength    Length of the the buffer\r
+  @param[in]  pBuffer         Address of a buffer to receive the data.\r
+  @param[in]  pDataLength     Number of received data bytes in the buffer.\r
 \r
   @return   Returns the address of the next free byte in the buffer.\r
-\r
 **/\r
 UINT8 *\r
 EslSocketCopyFragmentedBuffer (\r
@@ -1950,8 +1875,7 @@ EslSocketCopyFragmentedBuffer (
 }\r
 \r
 \r
-/**\r
-  Free the socket.\r
+/** Free the socket.\r
 \r
   This routine frees the socket structure and handle resources.\r
 \r
@@ -1959,13 +1883,11 @@ EslSocketCopyFragmentedBuffer (
   this routine to free the socket context structure and close the\r
   handle.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  \r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS   The socket resources were returned successfully.\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketFree (\r
   IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
@@ -2112,8 +2034,7 @@ EslSocketFree (
 }\r
 \r
 \r
-/**\r
-  Get the local address.\r
+/** Get the local address.\r
 \r
   This routine calls the network specific layer to get the network\r
   address of the local host connection point.\r
@@ -2121,16 +2042,12 @@ EslSocketFree (
   The ::getsockname routine calls this routine to obtain the network\r
   address associated with the local host connection point.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  \r
-  @param [out] pAddress       Network address to receive the local system address\r
-\r
-  @param [in,out] pAddressLength  Length of the local network address structure\r
-\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]      pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[out]     pAddress        Network address to receive the local system address\r
+  @param[in,out]  pAddressLength  Length of the local network address structure\r
+  @param[out]     pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Local address successfully returned\r
-\r
  **/\r
 EFI_STATUS\r
 EslSocketGetLocalAddress (\r
@@ -2145,14 +2062,14 @@ EslSocketGetLocalAddress (
   ESL_SOCKET * pSocket;\r
   EFI_STATUS Status;\r
   EFI_TPL TplPrevious;\r
-  \r
+\r
   DBG_ENTER ( );\r
-  \r
+\r
   //\r
   //  Assume success\r
   //\r
   Status = EFI_SUCCESS;\r
-  \r
+\r
   //\r
   //  Validate the socket\r
   //\r
@@ -2191,7 +2108,7 @@ EslSocketGetLocalAddress (
             //  Verify the address length\r
             //\r
             LengthInBytes = pSocket->pApi->AddressLength;\r
-            if (( LengthInBytes <= *pAddressLength ) \r
+            if (( LengthInBytes <= *pAddressLength )\r
               && ( 255 >= LengthInBytes )) {\r
               //\r
               //  Return the local address and address length\r
@@ -2212,7 +2129,7 @@ EslSocketGetLocalAddress (
             pSocket->errno = ENOTCONN;\r
             Status = EFI_NOT_STARTED;\r
           }\r
-          \r
+\r
           //\r
           //  Release the socket layer synchronization\r
           //\r
@@ -2232,7 +2149,7 @@ EslSocketGetLocalAddress (
       pSocket->errno = EADDRNOTAVAIL;\r
     }\r
   }\r
-  \r
+\r
   //\r
   //  Return the operation status\r
   //\r
@@ -2250,8 +2167,7 @@ EslSocketGetLocalAddress (
 }\r
 \r
 \r
-/**\r
-  Get the peer address.\r
+/** Get the peer address.\r
 \r
   This routine calls the network specific layer to get the remote\r
   system connection point.\r
@@ -2259,16 +2175,12 @@ EslSocketGetLocalAddress (
   The ::getpeername routine calls this routine to obtain the network\r
   address of the remote connection point.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  \r
-  @param [out] pAddress       Network address to receive the remote system address\r
-\r
-  @param [in,out] pAddressLength  Length of the remote network address structure\r
-\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]      pSocketProtocol   Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[out]     pAddress          Network address to receive the remote system address\r
+  @param[in,out]  pAddressLength    Length of the remote network address structure\r
+  @param[out]     pErrno            Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Remote address successfully returned\r
-\r
  **/\r
 EFI_STATUS\r
 EslSocketGetPeerAddress (\r
@@ -2283,14 +2195,14 @@ EslSocketGetPeerAddress (
   ESL_SOCKET * pSocket;\r
   EFI_STATUS Status;\r
   EFI_TPL TplPrevious;\r
-  \r
+\r
   DBG_ENTER ( );\r
-  \r
+\r
   //\r
   //  Assume success\r
   //\r
   Status = EFI_SUCCESS;\r
-  \r
+\r
   //\r
   //  Validate the socket\r
   //\r
@@ -2389,8 +2301,7 @@ EslSocketGetPeerAddress (
 }\r
 \r
 \r
-/**\r
-  Free the ESL_IO_MGMT event and structure\r
+/** Free the ESL_IO_MGMT event and structure.\r
 \r
   This support routine walks the free list to close the event in\r
   the ESL_IO_MGMT structure and remove the structure from the free\r
@@ -2398,13 +2309,12 @@ EslSocketGetPeerAddress (
 \r
   See the \ref TransmitEngine section.\r
 \r
-  @param [in] pPort         Address of an ::ESL_PORT structure\r
-  @param [in] ppFreeQueue   Address of the free queue head\r
-  @param [in] DebugFlags    Flags for debug messages\r
-  @param [in] pEventName    Zero terminated string containing the event name\r
+  @param[in]  pPort         Address of an ::ESL_PORT structure\r
+  @param[in]  ppFreeQueue   Address of the free queue head\r
+  @param[in]  DebugFlags    Flags for debug messages\r
+  @param[in]  pEventName    Zero terminated string containing the event name\r
 \r
   @retval EFI_SUCCESS - The structures were properly initialized\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketIoFree (\r
@@ -2468,8 +2378,7 @@ EslSocketIoFree (
 }\r
 \r
 \r
-/**\r
-  Initialize the ESL_IO_MGMT structures\r
+/** Initialize the ESL_IO_MGMT structures.\r
 \r
   This support routine initializes the ESL_IO_MGMT structure and\r
   places them on to a free list.\r
@@ -2477,17 +2386,16 @@ EslSocketIoFree (
   This routine is called by ::EslSocketPortAllocate routines to prepare\r
   the transmit engines.  See the \ref TransmitEngine section.\r
 \r
-  @param [in] pPort         Address of an ::ESL_PORT structure\r
-  @param [in, out] ppIo     Address containing the first structure address.  Upon\r
-                            return this buffer contains the next structure address.\r
-  @param [in] TokenCount    Number of structures to initialize\r
-  @param [in] ppFreeQueue   Address of the free queue head\r
-  @param [in] DebugFlags    Flags for debug messages\r
-  @param [in] pEventName    Zero terminated string containing the event name\r
-  @param [in] pfnCompletion Completion routine address\r
+  @param[in]        pPort         Address of an ::ESL_PORT structure\r
+  @param[in, out]   ppIo          Address containing the first structure address.  Upon\r
+                                  return this buffer contains the next structure address.\r
+  @param[in]        TokenCount    Number of structures to initialize\r
+  @param[in]        ppFreeQueue   Address of the free queue head\r
+  @param[in]        DebugFlags    Flags for debug messages\r
+  @param[in]        pEventName    Zero terminated string containing the event name\r
+  @param[in]        pfnCompletion Completion routine address\r
 \r
   @retval EFI_SUCCESS - The structures were properly initialized\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketIoInit (\r
@@ -2574,8 +2482,7 @@ EslSocketIoInit (
 }\r
 \r
 \r
-/**\r
-  Determine if the socket is configured\r
+/** Determine if the socket is configured.\r
 \r
   This support routine is called to determine if the socket if the\r
   configuration call was made to the network layer.  The following\r
@@ -2589,10 +2496,9 @@ EslSocketIoInit (
     <li>::EslSocketTransmit</li>\r
   </ul>\r
 \r
-  @param [in] pSocket       Address of an ::ESL_SOCKET structure\r
+  @param[in]  pSocket       Address of an ::ESL_SOCKET structure\r
 \r
   @retval EFI_SUCCESS - The socket is configured\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketIsConfigured (\r
@@ -2654,8 +2560,7 @@ EslSocketIsConfigured (
 }\r
 \r
 \r
-/**\r
-  Establish the known port to listen for network connections.\r
+/** Establish the known port to listen for network connections.\r
 \r
   This routine calls into the network protocol layer to establish\r
   a handler that is called upon connection completion.  The handler\r
@@ -2668,18 +2573,15 @@ EslSocketIsConfigured (
   remove the next connection from the FIFO and get the associated\r
   socket and address.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-\r
-  @param [in] Backlog         Backlog specifies the maximum FIFO depth for\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]  Backlog         Backlog specifies the maximum FIFO depth for\r
                               the connections waiting for the application\r
                               to call accept.  Connection attempts received\r
                               while the queue is full are refused.\r
-\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket successfully created\r
   @retval Other - Failed to enable the socket for listen\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketListen (\r
@@ -2827,8 +2729,7 @@ EslSocketListen (
 }\r
 \r
 \r
-/**\r
-  Get the socket options\r
+/** Get the socket options.\r
 \r
   This routine handles the socket level options and passes the\r
   others to the network specific layer.\r
@@ -2836,16 +2737,15 @@ EslSocketListen (
   The ::getsockopt routine calls this routine to retrieve the\r
   socket options one at a time by name.\r
 \r
-  @param [in] pSocketProtocol   Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  @param [in] level             Option protocol level\r
-  @param [in] OptionName        Name of the option\r
-  @param [out] pOptionValue     Buffer to receive the option value\r
-  @param [in,out] pOptionLength Length of the buffer in bytes,\r
-                                upon return length of the option value in bytes\r
-  @param [out] pErrno           Address to receive the errno value upon completion.\r
+  @param[in]      pSocketProtocol   Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]      level             Option protocol level\r
+  @param[in]      OptionName        Name of the option\r
+  @param[out]     pOptionValue      Buffer to receive the option value\r
+  @param[in,out]  pOptionLength     Length of the buffer in bytes,\r
+                                    upon return length of the option value in bytes\r
+  @param[out]     pErrno            Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket data successfully received\r
-\r
  **/\r
 EFI_STATUS\r
 EslSocketOptionGet (\r
@@ -2966,7 +2866,7 @@ EslSocketOptionGet (
         pOptionData = (CONST UINT8 *)&pSocket->RxTimeout;\r
         LengthInBytes = sizeof ( pSocket->RxTimeout );\r
         break;\r
-        \r
+\r
       case SO_RCVBUF:\r
         //\r
         //  Return the maximum receive buffer size\r
@@ -2982,7 +2882,7 @@ EslSocketOptionGet (
         pOptionData = (UINT8 *)&pSocket->bReUseAddr;\r
         LengthInBytes = sizeof ( pSocket->bReUseAddr );\r
         break;\r
-      \r
+\r
       case SO_SNDBUF:\r
         //\r
         //  Return the maximum transmit buffer size\r
@@ -3049,8 +2949,7 @@ EslSocketOptionGet (
 }\r
 \r
 \r
-/**\r
-  Set the socket options\r
+/** Set the socket options.\r
 \r
   This routine handles the socket level options and passes the\r
   others to the network specific layer.\r
@@ -3058,16 +2957,15 @@ EslSocketOptionGet (
   The ::setsockopt routine calls this routine to adjust the socket\r
   options one at a time by name.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  @param [in] level           Option protocol level\r
-  @param [in] OptionName      Name of the option\r
-  @param [in] pOptionValue    Buffer containing the option value\r
-  @param [in] OptionLength    Length of the buffer in bytes\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]  level           Option protocol level\r
+  @param[in]  OptionName      Name of the option\r
+  @param[in]  pOptionValue    Buffer containing the option value\r
+  @param[in]  OptionLength    Length of the buffer in bytes\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Option successfully set\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketOptionSet (\r
   IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
@@ -3084,9 +2982,9 @@ EslSocketOptionSet (
   UINT8 * pOptionData;\r
   ESL_SOCKET * pSocket;\r
   EFI_STATUS Status;\r
-  \r
+\r
   DBG_ENTER ( );\r
-  \r
+\r
   //\r
   //  Assume failure\r
   //\r
@@ -3145,7 +3043,7 @@ EslSocketOptionSet (
         errno = ENOPROTOOPT;\r
         Status = EFI_INVALID_PARAMETER;\r
         break;\r
-    \r
+\r
       case SOL_SOCKET:\r
         switch ( OptionName ) {\r
         default:\r
@@ -3265,21 +3163,19 @@ EslSocketOptionSet (
 }\r
 \r
 \r
-/**\r
-  Allocate a packet for a receive or transmit operation\r
+/**  Allocate a packet for a receive or transmit operation.\r
 \r
   This support routine is called by ::EslSocketRxStart and the\r
   network specific TxBuffer routines to get buffer space for the\r
   next operation.\r
 \r
-  @param [in] ppPacket      Address to receive the ::ESL_PACKET structure\r
-  @param [in] LengthInBytes Length of the packet structure\r
-  @param [in] ZeroBytes     Length of packet to zero\r
-  @param [in] DebugFlags    Flags for debug messages\r
+  @param[in]  ppPacket      Address to receive the ::ESL_PACKET structure\r
+  @param[in]  LengthInBytes Length of the packet structure\r
+  @param[in]  ZeroBytes     Length of packet to zero\r
+  @param[in]  DebugFlags    Flags for debug messages\r
 \r
   @retval EFI_SUCCESS - The packet was allocated successfully\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketPacketAllocate (\r
   IN ESL_PACKET ** ppPacket,\r
@@ -3332,20 +3228,18 @@ EslSocketPacketAllocate (
 }\r
 \r
 \r
-/**\r
-  Free a packet used for receive or transmit operation\r
+/** Free a packet used for receive or transmit operation.\r
 \r
   This support routine is called by the network specific Close\r
   and TxComplete routines and during error cases in RxComplete\r
   and TxBuffer.  Note that the network layers typically place\r
   receive packets on the ESL_SOCKET::pRxFree list for reuse.\r
 \r
-  @param [in] pPacket     Address of an ::ESL_PACKET structure\r
-  @param [in] DebugFlags  Flags for debug messages\r
+  @param[in]  pPacket     Address of an ::ESL_PACKET structure\r
+  @param[in]  DebugFlags  Flags for debug messages\r
 \r
   @retval EFI_SUCCESS - The packet was allocated successfully\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketPacketFree (\r
   IN ESL_PACKET * pPacket,\r
@@ -3383,8 +3277,7 @@ EslSocketPacketFree (
 }\r
 \r
 \r
-/**\r
-  Poll a socket for pending activity.\r
+/** Poll a socket for pending activity.\r
 \r
   This routine builds a detected event mask which is returned to\r
   the caller in the buffer provided.\r
@@ -3393,18 +3286,14 @@ EslSocketPacketFree (
   needs to be serviced as a result of connection, error, receive or\r
   transmit activity.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-\r
-  @param [in] Events    Events of interest for this socket\r
-\r
-  @param [in] pEvents   Address to receive the detected events\r
-\r
-  @param [out] pErrno   Address to receive the errno value upon completion.\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]  Events          Events of interest for this socket\r
+  @param[in]  pEvents         Address to receive the detected events\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket successfully polled\r
   @retval EFI_INVALID_PARAMETER - When pEvents is NULL\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketPoll (\r
   IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
@@ -3418,6 +3307,7 @@ EslSocketPoll (
   EFI_STATUS Status;\r
   EFI_TPL TplPrevious;\r
   short ValidEvents;\r
+  int   _errno = EINVAL;\r
 \r
   DEBUG (( DEBUG_POLL, "Entering SocketPoll\r\n" ));\r
 \r
@@ -3458,13 +3348,13 @@ EslSocketPoll (
       //  Synchronize with the socket layer\r
       //\r
       RAISE_TPL ( TplPrevious, TPL_SOCKETS );\r
-      \r
+\r
       //\r
       //  Increase the network performance by extending the\r
       //  polling (idle) loop down into the LAN driver\r
       //\r
       EslSocketRxPoll ( pSocket );\r
-      \r
+\r
       //\r
       //  Release the socket layer synchronization\r
       //\r
@@ -3540,6 +3430,7 @@ EslSocketPoll (
       if ( EFI_ERROR ( pSocket->TxError )) {\r
         DetectedEvents |= POLLERR;\r
       }\r
+      _errno = pSocket->errno;\r
     }\r
   }\r
 \r
@@ -3550,7 +3441,9 @@ EslSocketPoll (
                               | POLLERR\r
                               | POLLHUP\r
                               | POLLNVAL );\r
-\r
+  if ( NULL != pErrno ) {\r
+    *pErrno = _errno;\r
+  }\r
   //\r
   //  Return the operation status\r
   //\r
@@ -3559,8 +3452,7 @@ EslSocketPoll (
 }\r
 \r
 \r
-/**\r
-  Allocate and initialize a ESL_PORT structure.\r
+/** Allocate and initialize a ESL_PORT structure.\r
 \r
   This routine initializes an ::ESL_PORT structure for use by\r
   the socket.  This routine calls a routine via\r
@@ -3576,10 +3468,10 @@ EslSocketPoll (
   to connect the socket with the underlying network adapter\r
   to the socket.\r
 \r
-  @param [in] pSocket     Address of an ::ESL_SOCKET structure.\r
-  @param [in] pService    Address of an ::ESL_SERVICE structure.\r
-  @param [in] ChildHandle Network protocol child handle\r
-  @param [in] pSockAddr   Address of a sockaddr structure that contains the\r
+  @param[in]  pSocket     Address of an ::ESL_SOCKET structure.\r
+  @param[in]  pService    Address of an ::ESL_SERVICE structure.\r
+  @param[in]  ChildHandle Network protocol child handle\r
+  @param[in]  pSockAddr   Address of a sockaddr structure that contains the\r
                           connection point on the local machine.  An IPv4 address\r
                           of INADDR_ANY specifies that the connection is made to\r
                           all of the network stacks on the platform.  Specifying a\r
@@ -3588,13 +3480,12 @@ EslSocketPoll (
                           for the port causes the network layer to assign a port\r
                           number from the dynamic range.  Specifying a specific\r
                           port number causes the network layer to use that port.\r
-  @param [in] bBindTest   TRUE if EslSocketBindTest should be called\r
-  @param [in] DebugFlags  Flags for debug messages\r
-  @param [out] ppPort     Buffer to receive new ::ESL_PORT structure address\r
+  @param[in]  bBindTest   TRUE if EslSocketBindTest should be called\r
+  @param[in]  DebugFlags  Flags for debug messages\r
+  @param[out] ppPort      Buffer to receive new ::ESL_PORT structure address\r
 \r
   @retval EFI_SUCCESS - Socket successfully created\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketPortAllocate (\r
   IN ESL_SOCKET * pSocket,\r
@@ -3826,8 +3717,7 @@ EslSocketPortAllocate (
 }\r
 \r
 \r
-/**\r
-  Close a port.\r
+/** Close a port.\r
 \r
   This routine releases the resources allocated by ::EslSocketPortAllocate.\r
   This routine calls ESL_PROTOCOL_API::pfnPortClose to release the network\r
@@ -3840,12 +3730,11 @@ EslSocketPortAllocate (
     <li>::EslTcp4ConnectComplete - Connection failure and reducing the port list to a single port</li>\r
   </ul>\r
   See the \ref PortCloseStateMachine section.\r
-  \r
-  @param [in] pPort       Address of an ::ESL_PORT structure.\r
+\r
+  @param[in]  pPort       Address of an ::ESL_PORT structure.\r
 \r
   @retval EFI_SUCCESS     The port is closed\r
   @retval other           Port close error\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketPortClose (\r
@@ -3861,7 +3750,7 @@ EslSocketPortClose (
   CONST ESL_SOCKET_BINDING * pSocketBinding;\r
   ESL_SOCKET * pSocket;\r
   EFI_STATUS Status;\r
-  \r
+\r
   DBG_ENTER ( );\r
 \r
   //\r
@@ -4076,8 +3965,7 @@ EslSocketPortClose (
 }\r
 \r
 \r
-/**\r
-  Port close state 3\r
+/** Port close state 3.\r
 \r
   This routine attempts to complete the port close operation.\r
 \r
@@ -4085,10 +3973,8 @@ EslSocketPortClose (
   the close operation and by ::EslSocketPortCloseTxDone.\r
   See the \ref PortCloseStateMachine section.\r
 \r
-  @param [in] Event     The close completion event\r
-\r
-  @param [in] pPort     Address of an ::ESL_PORT structure.\r
-\r
+  @param[in]  Event     The close completion event\r
+  @param[in]  pPort     Address of an ::ESL_PORT structure.\r
 **/\r
 VOID\r
 EslSocketPortCloseComplete (\r
@@ -4102,17 +3988,13 @@ EslSocketPortCloseComplete (
   DBG_ENTER ( );\r
   VERIFY_AT_TPL ( TPL_SOCKETS );\r
 \r
-  //\r
   //  Update the port state\r
-  //\r
   pPort->State = PORT_STATE_CLOSE_DONE;\r
   DEBUG (( DEBUG_CLOSE | DEBUG_INFO,\r
             "0x%08x: Port Close State: PORT_STATE_CLOSE_DONE\r\n",\r
             pPort ));\r
 \r
-  //\r
   //  Shutdown the receive operation on the port\r
-  //\r
   if ( NULL != pPort->pfnRxCancel ) {\r
     pIo = pPort->pRxActive;\r
     while ( NULL != pIo ) {\r
@@ -4121,16 +4003,14 @@ EslSocketPortCloseComplete (
     }\r
   }\r
 \r
-  //\r
   //  Determine if the receive operation is pending\r
-  //\r
   Status = EslSocketPortCloseRxDone ( pPort );\r
   DBG_EXIT_STATUS ( Status );\r
+  --Status;\r
 }\r
 \r
 \r
-/**\r
-  Port close state 4\r
+/** Port close state 4.\r
 \r
   This routine determines the state of the receive operations and\r
   continues the close operation after the pending receive operations\r
@@ -4145,13 +4025,12 @@ EslSocketPortCloseComplete (
   to determine the state of the receive operations.\r
   See the \ref PortCloseStateMachine section.\r
 \r
-  @param [in] pPort       Address of an ::ESL_PORT structure.\r
+  @param[in]  pPort       Address of an ::ESL_PORT structure.\r
 \r
   @retval EFI_SUCCESS         The port is closed\r
   @retval EFI_NOT_READY       The port is still closing\r
   @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r
                               most likely the routine was called already.\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketPortCloseRxDone (\r
@@ -4221,8 +4100,7 @@ EslSocketPortCloseRxDone (
 }\r
 \r
 \r
-/**\r
-  Start the close operation on a port, state 1.\r
+/** Start the close operation on a port, state 1.\r
 \r
   This routine marks the port as closed and initiates the \ref\r
   PortCloseStateMachine. The first step is to allow the \ref\r
@@ -4231,15 +4109,14 @@ EslSocketPortCloseRxDone (
   This routine is called by ::EslSocketCloseStart to initiate the socket\r
   network specific close operation on the socket.\r
 \r
-  @param [in] pPort       Address of an ::ESL_PORT structure.\r
-  @param [in] bCloseNow   Set TRUE to abort active transfers\r
-  @param [in] DebugFlags  Flags for debug messages\r
+  @param[in]  pPort       Address of an ::ESL_PORT structure.\r
+  @param[in]  bCloseNow   Set TRUE to abort active transfers\r
+  @param[in]  DebugFlags  Flags for debug messages\r
 \r
   @retval EFI_SUCCESS         The port is closed, not normally returned\r
   @retval EFI_NOT_READY       The port has started the closing process\r
   @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r
                               most likely the routine was called already.\r
-\r
 **/\r
 EFI_STATUS\r
 EslSocketPortCloseStart (\r
@@ -4290,8 +4167,7 @@ EslSocketPortCloseStart (
 }\r
 \r
 \r
-/**\r
-  Port close state 2\r
+/** Port close state 2.\r
 \r
   This routine determines the state of the transmit engine and\r
   continue the close operation after the transmission is complete.\r
@@ -4301,7 +4177,7 @@ EslSocketPortCloseStart (
   This routine is called by ::EslSocketPortCloseStart to determine\r
   if the transmission is complete.\r
 \r
-  @param [in] pPort           Address of an ::ESL_PORT structure.\r
+  @param[in]  pPort           Address of an ::ESL_PORT structure.\r
 \r
   @retval EFI_SUCCESS         The port is closed, not normally returned\r
   @retval EFI_NOT_READY       The port is still closing\r
@@ -4444,8 +4320,7 @@ EslSocketPortCloseTxDone (
 }\r
 \r
 \r
-/**\r
-  Receive data from a network connection.\r
+/** Receive data from a network connection.\r
 \r
   This routine calls the network specific routine to remove the\r
   next portion of data from the receive queue and return it to the\r
@@ -4455,25 +4330,17 @@ EslSocketPortCloseTxDone (
   is received from the remote system.  Note that the other routines\r
   ::recv and ::read are layered on top of ::recvfrom.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  \r
-  @param [in] Flags           Message control flags\r
-  \r
-  @param [in] BufferLength    Length of the the buffer\r
-  \r
-  @param [in] pBuffer         Address of a buffer to receive the data.\r
-  \r
-  @param [in] pDataLength     Number of received data bytes in the buffer.\r
-\r
-  @param [out] pAddress       Network address to receive the remote system address\r
-\r
-  @param [in,out] pAddressLength  Length of the remote network address structure\r
-\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]      pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]      Flags           Message control flags\r
+  @param[in]      BufferLength    Length of the the buffer\r
+  @param[in]      pBuffer         Address of a buffer to receive the data.\r
+  @param[in]      pDataLength     Number of received data bytes in the buffer.\r
+  @param[out]     pAddress        Network address to receive the remote system address\r
+  @param[in,out]  pAddressLength  Length of the remote network address structure\r
+  @param[out]     pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket data successfully received\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketReceive (\r
   IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
@@ -4573,7 +4440,7 @@ EslSocketReceive (
                 pRemoteAddress->sa_family = pSocket->pApi->AddressFamily;\r
                 pRemoteAddress->sa_len = (UINT8)pSocket->pApi->AddressLength;\r
               }\r
-              \r
+\r
               //\r
               //  Synchronize with the socket layer\r
               //\r
@@ -4785,7 +4652,7 @@ EslSocketReceive (
         }\r
       }\r
 \r
-      \r
+\r
     }\r
     else {\r
       //\r
@@ -4813,8 +4680,7 @@ EslSocketReceive (
 }\r
 \r
 \r
-/**\r
-  Cancel the receive operations\r
+/** Cancel the receive operations.\r
 \r
   This routine cancels a pending receive operation.\r
   See the \ref ReceiveEngine section.\r
@@ -4822,10 +4688,9 @@ EslSocketReceive (
   This routine is called by ::EslSocketShutdown when the socket\r
   layer is being shutdown.\r
 \r
-  @param [in] pPort     Address of an ::ESL_PORT structure\r
-  @param [in] pIo       Address of an ::ESL_IO_MGMT structure\r
-\r
- **/\r
+  @param[in]  pPort     Address of an ::ESL_PORT structure\r
+  @param[in]  pIo       Address of an ::ESL_IO_MGMT structure\r
+**/\r
 VOID\r
 EslSocketRxCancel (\r
   IN ESL_PORT * pPort,\r
@@ -4858,8 +4723,7 @@ EslSocketRxCancel (
 }\r
 \r
 \r
-/**\r
-  Process the receive completion\r
+/** Process the receive completion.\r
 \r
   This routine queues the data in FIFO order in either the urgent\r
   or normal data queues depending upon the type of data received.\r
@@ -4872,12 +4736,11 @@ EslSocketRxCancel (
     <li>::EslUdp4RxComplete</li>\r
   </ul>\r
 \r
-  @param [in] pIo           Address of an ::ESL_IO_MGMT structure\r
-  @param [in] Status        Receive status\r
-  @param [in] LengthInBytes Length of the receive data\r
-  @param [in] bUrgent       TRUE if urgent data is received and FALSE\r
+  @param[in]  pIo           Address of an ::ESL_IO_MGMT structure\r
+  @param[in]  Status        Receive status\r
+  @param[in]  LengthInBytes Length of the receive data\r
+  @param[in]  bUrgent       TRUE if urgent data is received and FALSE\r
                             for normal data.\r
-\r
 **/\r
 VOID\r
 EslSocketRxComplete (\r
@@ -4911,13 +4774,13 @@ EslSocketRxComplete (
   //         pPort->pRxActive\r
   //                |\r
   //                V\r
-  //          +-------------+   +-------------+   +-------------+   \r
+  //          +-------------+   +-------------+   +-------------+\r
   //  Active  | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-  //          +-------------+   +-------------+   +-------------+   \r
+  //          +-------------+   +-------------+   +-------------+\r
   //\r
-  //          +-------------+   +-------------+   +-------------+   \r
+  //          +-------------+   +-------------+   +-------------+\r
   //  Free    | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-  //          +-------------+   +-------------+   +-------------+   \r
+  //          +-------------+   +-------------+   +-------------+\r
   //                ^\r
   //                |\r
   //          pPort->pRxFree\r
@@ -4951,13 +4814,13 @@ EslSocketRxComplete (
   //            pRxOobPacketListHead              pRxOobPacketListTail\r
   //                      |                                 |\r
   //                      V                                 V\r
-  //               +------------+   +------------+   +------------+   \r
+  //               +------------+   +------------+   +------------+\r
   //  Urgent Data  | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL\r
-  //               +------------+   +------------+   +------------+   \r
+  //               +------------+   +------------+   +------------+\r
   //\r
-  //               +------------+   +------------+   +------------+   \r
+  //               +------------+   +------------+   +------------+\r
   //  Normal Data  | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL\r
-  //               +------------+   +------------+   +------------+   \r
+  //               +------------+   +------------+   +------------+\r
   //                      ^                                 ^\r
   //                      |                                 |\r
   //              pRxPacketListHead                pRxPacketListTail\r
@@ -5075,8 +4938,7 @@ EslSocketRxComplete (
 }\r
 \r
 \r
-/**\r
-  Poll a socket for pending receive activity.\r
+/** Poll a socket for pending receive activity.\r
 \r
   This routine is called at elivated TPL and extends the idle\r
   loop which polls a socket down into the LAN driver layer to\r
@@ -5085,8 +4947,7 @@ EslSocketRxComplete (
   The ::EslSocketPoll, ::EslSocketReceive and ::EslSocketTransmit\r
   routines call this routine when there is nothing to do.\r
 \r
-  @param [in] pSocket   Address of an ::EFI_SOCKET structure.\r
-\r
+  @param[in]  pSocket   Address of an ::EFI_SOCKET structure.\r
  **/\r
 VOID\r
 EslSocketRxPoll (\r
@@ -5118,8 +4979,7 @@ EslSocketRxPoll (
 }\r
 \r
 \r
-/**\r
-  Start a receive operation\r
+/** Start a receive operation.\r
 \r
   This routine posts a receive buffer to the network adapter.\r
   See the \ref ReceiveEngine section.\r
@@ -5128,7 +4988,7 @@ EslSocketRxPoll (
   <ul>\r
     <li>::EslIp4Receive to restart the receive engine to release flow control.</li>\r
     <li>::EslIp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r
-    <li>::EslIp4SocketIsConfigured to start the recevie engine for the new socket.</li>\r
+    <li>::EslIp4SocketIsConfigured to start the receive engine for the new socket.</li>\r
     <li>::EslTcp4ListenComplete to start the recevie engine for the new socket.</li>\r
     <li>::EslTcp4Receive to restart the receive engine to release flow control.</li>\r
     <li>::EslTcp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r
@@ -5137,9 +4997,8 @@ EslSocketRxPoll (
     <li>::EslUdp4SocketIsConfigured to start the recevie engine for the new socket.</li>\r
   </ul>\r
 \r
-  @param [in] pPort       Address of an ::ESL_PORT structure.\r
-\r
- **/\r
+  @param[in]  pPort       Address of an ::ESL_PORT structure.\r
+**/\r
 VOID\r
 EslSocketRxStart (\r
   IN ESL_PORT * pPort\r
@@ -5243,13 +5102,13 @@ EslSocketRxStart (
           //  Allocate the receive control structure\r
           //\r
           pPort->pRxFree = pIo->pNext;\r
-          \r
+\r
           //\r
           //  Mark this receive as pending\r
           //\r
           pIo->pNext = pPort->pRxActive;\r
           pPort->pRxActive = pIo;\r
-          \r
+\r
         }\r
         else {\r
           DEBUG (( DEBUG_RX | DEBUG_INFO,\r
@@ -5301,8 +5160,7 @@ EslSocketRxStart (
 }\r
 \r
 \r
-/**\r
-  Shutdown the socket receive and transmit operations\r
+/** Shutdown the socket receive and transmit operations.\r
 \r
   This routine sets a flag to stop future transmissions and calls\r
   the network specific layer to cancel the pending receive operation.\r
@@ -5310,15 +5168,12 @@ EslSocketRxStart (
   The ::shutdown routine calls this routine to stop receive and transmit\r
   operations on the socket.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  \r
-  @param [in] How             Which operations to stop\r
-  \r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]  How             Which operations to stop\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket operations successfully shutdown\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketShutdown (\r
   IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
@@ -5331,9 +5186,9 @@ EslSocketShutdown (
   ESL_SOCKET * pSocket;\r
   EFI_STATUS Status;\r
   EFI_TPL TplPrevious;\r
-  \r
+\r
   DBG_ENTER ( );\r
-  \r
+\r
   //\r
   //  Assume success\r
   //\r
@@ -5436,8 +5291,7 @@ EslSocketShutdown (
 }\r
 \r
 \r
-/**\r
-  Send data using a network connection.\r
+/** Send data using a network connection.\r
 \r
   This routine calls the network specific layer to queue the data\r
   for transmission.  Eventually the buffer will reach the head of\r
@@ -5449,25 +5303,17 @@ EslSocketShutdown (
   The ::sendto routine calls this routine to send data to the remote\r
   system.  Note that ::send and ::write are layered on top of ::sendto.\r
 \r
-  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
-  \r
-  @param [in] Flags           Message control flags\r
-  \r
-  @param [in] BufferLength    Length of the the buffer\r
-  \r
-  @param [in] pBuffer         Address of a buffer containing the data to send\r
-  \r
-  @param [in] pDataLength     Address to receive the number of data bytes sent\r
-\r
-  @param [in] pAddress        Network address of the remote system address\r
-\r
-  @param [in] AddressLength   Length of the remote network address structure\r
-\r
-  @param [out] pErrno         Address to receive the errno value upon completion.\r
+  @param[in]  pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  @param[in]  Flags           Message control flags\r
+  @param[in]  BufferLength    Length of the the buffer\r
+  @param[in]  pBuffer         Address of a buffer containing the data to send\r
+  @param[in]  pDataLength     Address to receive the number of data bytes sent\r
+  @param[in]  pAddress        Network address of the remote system address\r
+  @param[in]  AddressLength   Length of the remote network address structure\r
+  @param[out] pErrno          Address to receive the errno value upon completion.\r
 \r
   @retval EFI_SUCCESS - Socket data successfully queued for transmit\r
-\r
- **/\r
+**/\r
 EFI_STATUS\r
 EslSocketTransmit (\r
   IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
@@ -5614,8 +5460,7 @@ EslSocketTransmit (
 }\r
 \r
 \r
-/**\r
-  Complete the transmit operation\r
+/** Complete the transmit operation.\r
 \r
   This support routine handles the transmit completion processing for\r
   the various network layers.  It frees the ::ESL_IO_MGMT structure\r
@@ -5631,16 +5476,15 @@ EslSocketTransmit (
     <li>::EslUdp4TxComplete</li>\r
   </ul>\r
 \r
-  @param [in] pIo             Address of an ::ESL_IO_MGMT structure\r
-  @param [in] LengthInBytes   Length of the data in bytes\r
-  @param [in] Status          Transmit operation status\r
-  @param [in] pQueueType      Zero terminated string describing queue type\r
-  @param [in] ppQueueHead     Transmit queue head address\r
-  @param [in] ppQueueTail     Transmit queue tail address\r
-  @param [in] ppActive        Active transmit queue address\r
-  @param [in] ppFree          Free transmit queue address\r
-\r
- **/\r
+  @param[in]  pIo             Address of an ::ESL_IO_MGMT structure\r
+  @param[in]  LengthInBytes   Length of the data in bytes\r
+  @param[in]  Status          Transmit operation status\r
+  @param[in]  pQueueType      Zero terminated string describing queue type\r
+  @param[in]  ppQueueHead     Transmit queue head address\r
+  @param[in]  ppQueueTail     Transmit queue tail address\r
+  @param[in]  ppActive        Active transmit queue address\r
+  @param[in]  ppFree          Free transmit queue address\r
+**/\r
 VOID\r
 EslSocketTxComplete (\r
   IN ESL_IO_MGMT * pIo,\r
@@ -5772,8 +5616,7 @@ EslSocketTxComplete (
 }\r
 \r
 \r
-/**\r
-  Transmit data using a network connection.\r
+/** Transmit data using a network connection.\r
 \r
   This support routine starts a transmit operation on the\r
   underlying network layer.\r
@@ -5781,13 +5624,12 @@ EslSocketTxComplete (
   The network specific code calls this routine to start a\r
   transmit operation.  See the \ref TransmitEngine section.\r
 \r
-  @param [in] pPort           Address of an ::ESL_PORT structure\r
-  @param [in] ppQueueHead     Transmit queue head address\r
-  @param [in] ppQueueTail     Transmit queue tail address\r
-  @param [in] ppActive        Active transmit queue address\r
-  @param [in] ppFree          Free transmit queue address\r
-\r
- **/\r
+  @param[in]  pPort           Address of an ::ESL_PORT structure\r
+  @param[in]  ppQueueHead     Transmit queue head address\r
+  @param[in]  ppQueueTail     Transmit queue tail address\r
+  @param[in]  ppActive        Active transmit queue address\r
+  @param[in]  ppFree          Free transmit queue address\r
+**/\r
 VOID\r
 EslSocketTxStart (\r
   IN ESL_PORT * pPort,\r
@@ -5823,9 +5665,9 @@ EslSocketTxStart (
     //     *ppQueueHead: pSocket->pRxPacketListHead or pSocket->pRxOobPacketListHead\r
     //          |\r
     //          V\r
-    //        +------------+   +------------+   +------------+   \r
+    //        +------------+   +------------+   +------------+\r
     //  Data  | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL\r
-    //        +------------+   +------------+   +------------+   \r
+    //        +------------+   +------------+   +------------+\r
     //                                                     ^\r
     //                                                     |\r
     //     *ppQueueTail: pSocket->pRxPacketListTail or pSocket->pRxOobPacketListTail\r
@@ -5896,9 +5738,9 @@ EslSocketTxStart (
       pIo->pPacket = pPacket;\r
 \r
       //\r
-      //          +-------------+   +-------------+   +-------------+   \r
+      //          +-------------+   +-------------+   +-------------+\r
       //  Free    | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-      //          +-------------+   +-------------+   +-------------+   \r
+      //          +-------------+   +-------------+   +-------------+\r
       //              ^\r
       //              |\r
       //          *ppFree:  pPort->pTxFree or pTxOobFree\r
@@ -5907,14 +5749,14 @@ EslSocketTxStart (
       //  Remove the IO structure from the queue\r
       //\r
       *ppFree = pIo->pNext;\r
-      \r
+\r
       //\r
       //         *ppActive:  pPort->pTxActive or pTxOobActive\r
       //             |\r
       //             V\r
-      //          +-------------+   +-------------+   +-------------+   \r
+      //          +-------------+   +-------------+   +-------------+\r
       //  Active  | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL\r
-      //          +-------------+   +-------------+   +-------------+   \r
+      //          +-------------+   +-------------+   +-------------+\r
       //\r
       //\r
       //  Mark this packet as active\r
@@ -5924,10 +5766,24 @@ EslSocketTxStart (
       *ppActive = pIo;\r
     }\r
     else {\r
+      //\r
+      //  Display the transmit error\r
+      //\r
+      DEBUG (( DEBUG_TX | DEBUG_INFO,\r
+                "0x%08x, 0x%08x: pIo, pPacket transmit failure: %r\r\n",\r
+                pIo,\r
+                pPacket,\r
+                Status ));\r
       if ( EFI_SUCCESS == pSocket->TxError ) {\r
         pSocket->TxError = Status;\r
       }\r
 \r
+      //\r
+      //  Free the IO structure\r
+      //\r
+      pIo->pNext = *ppFree;\r
+      *ppFree = pIo;\r
+\r
       //\r
       //  Discard the transmit buffer\r
       //\r