summaryrefslogtreecommitdiff
path: root/StdLib/EfiSocketLib
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2012-06-07 17:38:09 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2012-06-07 17:38:09 +0000
commit3a2fc8780fa881c251e9d91e0ddbb30a7f41ad62 (patch)
tree7451f8e40418a29413ae4a6dc4bfc306f80c0b65 /StdLib/EfiSocketLib
parenta391483e429a170b129774e0efbb0d26f146abbb (diff)
downloadedk2-platforms-3a2fc8780fa881c251e9d91e0ddbb30a7f41ad62.tar.xz
Only use ports with a network connection (media present) when connecting to a remote host.
Fix bug causing early exit with NO_MEDIA. Add fix to TCP6. Signed-off-by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13432 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/EfiSocketLib')
-rw-r--r--StdLib/EfiSocketLib/Tcp4.c14
-rw-r--r--StdLib/EfiSocketLib/Tcp6.c39
2 files changed, 48 insertions, 5 deletions
diff --git a/StdLib/EfiSocketLib/Tcp4.c b/StdLib/EfiSocketLib/Tcp4.c
index 5027ca343d..0643518f0d 100644
--- a/StdLib/EfiSocketLib/Tcp4.c
+++ b/StdLib/EfiSocketLib/Tcp4.c
@@ -512,7 +512,6 @@ EslTcp4ConnectStart (
//
// Verify the port connection
//
- pTcp4Protocol = pPort->pProtocol.TCPv4;
Status = pTcp4Protocol->GetModeData ( pTcp4Protocol,
NULL,
NULL,
@@ -525,7 +524,18 @@ EslTcp4ConnectStart (
//
// Port is not connected to the network
//
- Status = EFI_NO_MEDIA;
+ pTcp4->ConnectToken.CompletionToken.Status = EFI_NO_MEDIA;
+
+ //
+ // Continue with the next port
+ //
+ gBS->CheckEvent ( pTcp4->ConnectToken.CompletionToken.Event );
+ gBS->SignalEvent ( pTcp4->ConnectToken.CompletionToken.Event );
+
+ //
+ // Connection in progress
+ //
+ Status = EFI_SUCCESS;
}
else {
//
diff --git a/StdLib/EfiSocketLib/Tcp6.c b/StdLib/EfiSocketLib/Tcp6.c
index b070aaa724..dd0f086487 100644
--- a/StdLib/EfiSocketLib/Tcp6.c
+++ b/StdLib/EfiSocketLib/Tcp6.c
@@ -471,6 +471,7 @@ EslTcp6ConnectStart (
ESL_PORT * pPort;
ESL_TCP6_CONTEXT * pTcp6;
EFI_TCP6_PROTOCOL * pTcp6Protocol;
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;
EFI_STATUS Status;
DBG_ENTER ( );
@@ -528,10 +529,41 @@ EslTcp6ConnectStart (
pPort->bConfigured = TRUE;
//
- // Attempt the connection to the remote system
+ // Verify the port connection
//
- Status = pTcp6Protocol->Connect ( pTcp6Protocol,
- &pTcp6->ConnectToken );
+ Status = pTcp6Protocol->GetModeData ( pTcp6Protocol,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &SnpModeData );
+ if ( !EFI_ERROR ( Status )) {
+ if ( SnpModeData.MediaPresentSupported
+ && ( !SnpModeData.MediaPresent )) {
+ //
+ // Port is not connected to the network
+ //
+ pTcp6->ConnectToken.CompletionToken.Status = EFI_NO_MEDIA;
+
+ //
+ // Continue with the next port
+ //
+ gBS->CheckEvent ( pTcp6->ConnectToken.CompletionToken.Event );
+ gBS->SignalEvent ( pTcp6->ConnectToken.CompletionToken.Event );
+
+ //
+ // Connection in progress
+ //
+ Status = EFI_SUCCESS;
+ }
+ else {
+ //
+ // Attempt the connection to the remote system
+ //
+ Status = pTcp6Protocol->Connect ( pTcp6Protocol,
+ &pTcp6->ConnectToken );
+ }
+ }
if ( !EFI_ERROR ( Status )) {
//
// Connection in progress
@@ -583,6 +615,7 @@ EslTcp6ConnectStart (
pSocket->errno = ETIMEDOUT;
break;
+ case EFI_NO_MEDIA:
case EFI_NETWORK_UNREACHABLE:
pSocket->errno = ENETDOWN;
break;