summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-10 01:13:05 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-10 01:13:05 +0000
commitbb3aa953b3c724ae575881283d4b6e18bfad5433 (patch)
tree044078f89a104723d5102678eae3cf714a050d91
parent36384ceb64c64b903495cd7bd462676f394f674a (diff)
downloadedk2-platforms-bb3aa953b3c724ae575881283d4b6e18bfad5433.tar.xz
Return the proper status after one of the ports is configured for UDP or IP communications.
Reviewed by: Ankit Singh of Dell Submitted by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13604 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--StdLib/EfiSocketLib/Ip4.c72
-rw-r--r--StdLib/EfiSocketLib/Udp4.c72
-rw-r--r--StdLib/EfiSocketLib/Udp6.c72
3 files changed, 102 insertions, 114 deletions
diff --git a/StdLib/EfiSocketLib/Ip4.c b/StdLib/EfiSocketLib/Ip4.c
index 80f328a8dd..a245e6847e 100644
--- a/StdLib/EfiSocketLib/Ip4.c
+++ b/StdLib/EfiSocketLib/Ip4.c
@@ -749,6 +749,7 @@ EslIp4RxComplete (
//
// Fill in the port list if necessary
//
+ pSocket->errno = ENETDOWN;
if ( NULL == pSocket->pPortList ) {
LocalAddress.sin_len = sizeof ( LocalAddress );
LocalAddress.sin_family = AF_INET;
@@ -804,34 +805,36 @@ EslIp4RxComplete (
NULL );
}
if ( EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_LISTEN,
- "ERROR - Failed to configure the Ip4 port, Status: %r\r\n",
- Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
-
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
-
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
-
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
-
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
+ if ( !pSocket->bConfigured ) {
+ DEBUG (( DEBUG_LISTEN,
+ "ERROR - Failed to configure the Ip4 port, Status: %r\r\n",
+ Status ));
+ switch ( Status ) {
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ default:
+ case EFI_DEVICE_ERROR:
+ pSocket->errno = EIO;
+ break;
+
+ case EFI_INVALID_PARAMETER:
+ pSocket->errno = EADDRNOTAVAIL;
+ break;
+
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
+
+ case EFI_OUT_OF_RESOURCES:
+ pSocket->errno = ENOBUFS;
+ break;
+
+ case EFI_UNSUPPORTED:
+ pSocket->errno = EOPNOTSUPP;
+ break;
+ }
}
}
else {
@@ -876,6 +879,7 @@ EslIp4RxComplete (
pIp4->ModeData.RouteTable[Index].GatewayAddress.Addr[3]));
}
pPort->bConfigured = TRUE;
+ pSocket->bConfigured = TRUE;
//
// Start the first read on the port
@@ -886,6 +890,7 @@ EslIp4RxComplete (
// The socket is connected
//
pSocket->State = SOCKET_STATE_CONNECTED;
+ pSocket->errno = 0;
}
//
@@ -893,21 +898,12 @@ EslIp4RxComplete (
//
pPort = pNextPort;
}
-
- //
- // Determine the configuration status
- //
- if ( NULL != pSocket->pPortList ) {
- pSocket->bConfigured = TRUE;
- }
}
//
// Determine the socket configuration status
//
- if ( !EFI_ERROR ( Status )) {
- Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
- }
+ Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
//
// Return the port connected state.
diff --git a/StdLib/EfiSocketLib/Udp4.c b/StdLib/EfiSocketLib/Udp4.c
index 026f850377..45c0adad3a 100644
--- a/StdLib/EfiSocketLib/Udp4.c
+++ b/StdLib/EfiSocketLib/Udp4.c
@@ -591,6 +591,7 @@ EslUdp4RxComplete (
//
// Fill in the port list if necessary
//
+ pSocket->errno = ENETDOWN;
if ( NULL == pSocket->pPortList ) {
LocalAddress.sin_len = sizeof ( LocalAddress );
LocalAddress.sin_family = AF_INET;
@@ -640,34 +641,36 @@ EslUdp4RxComplete (
NULL );
}
if ( EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_LISTEN,
- "ERROR - Failed to configure the Udp4 port, Status: %r\r\n",
- Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
-
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
-
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
-
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
-
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
+ if ( !pSocket->bConfigured ) {
+ DEBUG (( DEBUG_LISTEN,
+ "ERROR - Failed to configure the Udp4 port, Status: %r\r\n",
+ Status ));
+ switch ( Status ) {
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ default:
+ case EFI_DEVICE_ERROR:
+ pSocket->errno = EIO;
+ break;
+
+ case EFI_INVALID_PARAMETER:
+ pSocket->errno = EADDRNOTAVAIL;
+ break;
+
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
+
+ case EFI_OUT_OF_RESOURCES:
+ pSocket->errno = ENOBUFS;
+ break;
+
+ case EFI_UNSUPPORTED:
+ pSocket->errno = EOPNOTSUPP;
+ break;
+ }
}
}
else {
@@ -685,6 +688,7 @@ EslUdp4RxComplete (
pConfigData->RemoteAddress.Addr[3],
pConfigData->RemotePort ));
pPort->bConfigured = TRUE;
+ pSocket->bConfigured = TRUE;
//
// Start the first read on the port
@@ -695,6 +699,7 @@ EslUdp4RxComplete (
// The socket is connected
//
pSocket->State = SOCKET_STATE_CONNECTED;
+ pSocket->errno = 0;
}
//
@@ -702,21 +707,12 @@ EslUdp4RxComplete (
//
pPort = pNextPort;
}
-
- //
- // Determine the configuration status
- //
- if ( NULL != pSocket->pPortList ) {
- pSocket->bConfigured = TRUE;
- }
}
//
// Determine the socket configuration status
//
- if ( !EFI_ERROR ( Status )) {
- Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
- }
+ Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
//
// Return the port connected state.
diff --git a/StdLib/EfiSocketLib/Udp6.c b/StdLib/EfiSocketLib/Udp6.c
index 9f47f1c736..899e50681e 100644
--- a/StdLib/EfiSocketLib/Udp6.c
+++ b/StdLib/EfiSocketLib/Udp6.c
@@ -585,6 +585,7 @@ EslUdp6RxComplete (
//
// Fill in the port list if necessary
//
+ pSocket->errno = ENETDOWN;
if ( NULL == pSocket->pPortList ) {
ZeroMem ( &LocalAddress, sizeof ( LocalAddress ));
LocalAddress.sin6_len = sizeof ( LocalAddress );
@@ -657,34 +658,36 @@ EslUdp6RxComplete (
NULL );
}
if ( EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_LISTEN,
- "ERROR - Failed to configure the Udp6 port, Status: %r\r\n",
- Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
-
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
-
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
-
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
-
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
+ if ( !pSocket->bConfigured ) {
+ DEBUG (( DEBUG_LISTEN,
+ "ERROR - Failed to configure the Udp6 port, Status: %r\r\n",
+ Status ));
+ switch ( Status ) {
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ default:
+ case EFI_DEVICE_ERROR:
+ pSocket->errno = EIO;
+ break;
+
+ case EFI_INVALID_PARAMETER:
+ pSocket->errno = EADDRNOTAVAIL;
+ break;
+
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
+
+ case EFI_OUT_OF_RESOURCES:
+ pSocket->errno = ENOBUFS;
+ break;
+
+ case EFI_UNSUPPORTED:
+ pSocket->errno = EOPNOTSUPP;
+ break;
+ }
}
}
else {
@@ -726,6 +729,7 @@ EslUdp6RxComplete (
pConfigData->RemoteAddress.Addr[15],
pConfigData->RemotePort ));
pPort->bConfigured = TRUE;
+ pSocket->bConfigured = TRUE;
//
// Start the first read on the port
@@ -736,6 +740,7 @@ EslUdp6RxComplete (
// The socket is connected
//
pSocket->State = SOCKET_STATE_CONNECTED;
+ pSocket->errno = 0;
}
//
@@ -743,21 +748,12 @@ EslUdp6RxComplete (
//
pPort = pNextPort;
}
-
- //
- // Determine the configuration status
- //
- if ( NULL != pSocket->pPortList ) {
- pSocket->bConfigured = TRUE;
- }
}
//
// Determine the socket configuration status
//
- if ( !EFI_ERROR ( Status )) {
- Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
- }
+ Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
//
// Return the port connected state.