]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/EfiSocketLib/Ip4.c
Return the proper status after one of the ports is configured for UDP or IP communica...
[mirror_edk2.git] / StdLib / EfiSocketLib / Ip4.c
index 9f885e96bf4bd5d17838a4e378bf63ce6ed87d8a..a245e6847e25a0fba58445f7b99f2b278bde2c19 100644 (file)
@@ -143,9 +143,9 @@ EslIp4LocalAddressSet (
     }\r
     else {\r
       pConfig->SubnetMask.Addr[0] = 0xff;\r
-      pConfig->SubnetMask.Addr[1] = 0xff;\r
-      pConfig->SubnetMask.Addr[2] = 0xff;\r
-      pConfig->SubnetMask.Addr[3] = 0xff;\r
+      pConfig->SubnetMask.Addr[1] = ( 128 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;\r
+      pConfig->SubnetMask.Addr[2] = ( 192 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;\r
+      pConfig->SubnetMask.Addr[3] = ( 224 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;\r
     }\r
   }\r
 \r
@@ -383,6 +383,7 @@ EslIp4PortAllocate (
   //\r
   pPort->pfnConfigure = (PFN_NET_CONFIGURE)pPort->pProtocol.IPv4->Configure;\r
   pPort->pfnRxCancel = (PFN_NET_IO_START)pPort->pProtocol.IPv4->Cancel;\r
+  pPort->pfnRxPoll = (PFN_NET_POLL)pPort->pProtocol.IPv4->Poll;\r
   pPort->pfnRxStart = (PFN_NET_IO_START)pPort->pProtocol.IPv4->Receive;\r
   pPort->pfnTxStart = (PFN_NET_IO_START)pPort->pProtocol.IPv4->Transmit;\r
 \r
@@ -618,6 +619,7 @@ EslIp4RemoteAddressSet (
   pIp4->DestinationAddress.Addr[1] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 8 );\r
   pIp4->DestinationAddress.Addr[2] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 16 );\r
   pIp4->DestinationAddress.Addr[3] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 24 );\r
+  pPort->pSocket->bAddressSet = TRUE;\r
   Status = EFI_SUCCESS;\r
 \r
   //\r
@@ -747,6 +749,7 @@ EslIp4RxComplete (
     //\r
     //  Fill in the port list if necessary\r
     //\r
+    pSocket->errno = ENETDOWN;\r
     if ( NULL == pSocket->pPortList ) {\r
       LocalAddress.sin_len = sizeof ( LocalAddress );\r
       LocalAddress.sin_family = AF_INET;\r
@@ -802,34 +805,36 @@ EslIp4RxComplete (
                                              NULL );\r
       }\r
       if ( EFI_ERROR ( Status )) {\r
-        DEBUG (( DEBUG_LISTEN,\r
-                  "ERROR - Failed to configure the Ip4 port, Status: %r\r\n",\r
-                  Status ));\r
-        switch ( Status ) {\r
-        case EFI_ACCESS_DENIED:\r
-          pSocket->errno = EACCES;\r
-          break;\r
-\r
-        default:\r
-        case EFI_DEVICE_ERROR:\r
-          pSocket->errno = EIO;\r
-          break;\r
-\r
-        case EFI_INVALID_PARAMETER:\r
-          pSocket->errno = EADDRNOTAVAIL;\r
-          break;\r
-\r
-        case EFI_NO_MAPPING:\r
-          pSocket->errno = EAFNOSUPPORT;\r
-          break;\r
-\r
-        case EFI_OUT_OF_RESOURCES:\r
-          pSocket->errno = ENOBUFS;\r
-          break;\r
-\r
-        case EFI_UNSUPPORTED:\r
-          pSocket->errno = EOPNOTSUPP;\r
-          break;\r
+        if ( !pSocket->bConfigured ) {\r
+          DEBUG (( DEBUG_LISTEN,\r
+                    "ERROR - Failed to configure the Ip4 port, Status: %r\r\n",\r
+                    Status ));\r
+          switch ( Status ) {\r
+          case EFI_ACCESS_DENIED:\r
+            pSocket->errno = EACCES;\r
+            break;\r
+\r
+          default:\r
+          case EFI_DEVICE_ERROR:\r
+            pSocket->errno = EIO;\r
+            break;\r
+\r
+          case EFI_INVALID_PARAMETER:\r
+            pSocket->errno = EADDRNOTAVAIL;\r
+            break;\r
+\r
+          case EFI_NO_MAPPING:\r
+            pSocket->errno = EAFNOSUPPORT;\r
+            break;\r
+\r
+          case EFI_OUT_OF_RESOURCES:\r
+            pSocket->errno = ENOBUFS;\r
+            break;\r
+\r
+          case EFI_UNSUPPORTED:\r
+            pSocket->errno = EOPNOTSUPP;\r
+            break;\r
+          }\r
         }\r
       }\r
       else {\r
@@ -874,6 +879,7 @@ EslIp4RxComplete (
                     pIp4->ModeData.RouteTable[Index].GatewayAddress.Addr[3]));\r
         }\r
         pPort->bConfigured = TRUE;\r
+        pSocket->bConfigured = TRUE;\r
 \r
         //\r
         //  Start the first read on the port\r
@@ -884,6 +890,7 @@ EslIp4RxComplete (
         //  The socket is connected\r
         //\r
         pSocket->State = SOCKET_STATE_CONNECTED;\r
+        pSocket->errno = 0;\r
       }\r
 \r
       //\r
@@ -891,21 +898,12 @@ EslIp4RxComplete (
       //\r
       pPort = pNextPort;\r
     }\r
-\r
-    //\r
-    //  Determine the configuration status\r
-    //\r
-    if ( NULL != pSocket->pPortList ) {\r
-      pSocket->bConfigured = TRUE;\r
-    }\r
   }\r
 \r
   //\r
   //  Determine the socket configuration status\r
   //\r
-  if ( !EFI_ERROR ( Status )) {\r
-    Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;\r
-  }\r
+  Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;\r
   \r
   //\r
   //  Return the port connected state.\r