diff options
author | lpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-06-04 20:38:03 +0000 |
---|---|---|
committer | lpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-06-04 20:38:03 +0000 |
commit | d6f19057f048bdb1afb84fb8dddcb6373c0b684f (patch) | |
tree | e6da23037cee81fad6f5cf3f52ac4af85e03033f /StdLib/EfiSocketLib | |
parent | 441f48f5b0847d35937534d6052f704f19019d2d (diff) | |
download | edk2-d6f19057f048bdb1afb84fb8dddcb6373c0b684f.zip edk2-d6f19057f048bdb1afb84fb8dddcb6373c0b684f.tar.gz edk2-d6f19057f048bdb1afb84fb8dddcb6373c0b684f.tar.bz2 |
Only use ports with a network connection (media present) when connecting to a remote host.
Signed-off-by: lpleahy
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13427 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/EfiSocketLib')
-rw-r--r-- | StdLib/EfiSocketLib/Tcp4.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/StdLib/EfiSocketLib/Tcp4.c b/StdLib/EfiSocketLib/Tcp4.c index 8044d80..5027ca3 100644 --- a/StdLib/EfiSocketLib/Tcp4.c +++ b/StdLib/EfiSocketLib/Tcp4.c @@ -453,6 +453,7 @@ EslTcp4ConnectStart ( ESL_PORT * pPort;
ESL_TCP4_CONTEXT * pTcp4;
EFI_TCP4_PROTOCOL * pTcp4Protocol;
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;
EFI_STATUS Status;
DBG_ENTER ( );
@@ -509,10 +510,31 @@ EslTcp4ConnectStart ( pPort->bConfigured = TRUE;
//
- // Attempt the connection to the remote system
+ // Verify the port connection
//
- Status = pTcp4Protocol->Connect ( pTcp4Protocol,
- &pTcp4->ConnectToken );
+ pTcp4Protocol = pPort->pProtocol.TCPv4;
+ Status = pTcp4Protocol->GetModeData ( pTcp4Protocol,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &SnpModeData );
+ if ( !EFI_ERROR ( Status )) {
+ if ( SnpModeData.MediaPresentSupported
+ && ( !SnpModeData.MediaPresent )) {
+ //
+ // Port is not connected to the network
+ //
+ Status = EFI_NO_MEDIA;
+ }
+ else {
+ //
+ // Attempt the connection to the remote system
+ //
+ Status = pTcp4Protocol->Connect ( pTcp4Protocol,
+ &pTcp4->ConnectToken );
+ }
+ }
if ( !EFI_ERROR ( Status )) {
//
// Connection in progress
@@ -552,6 +574,7 @@ EslTcp4ConnectStart ( pSocket->errno = ETIMEDOUT;
break;
+ case EFI_NO_MEDIA:
case EFI_NETWORK_UNREACHABLE:
pSocket->errno = ENETDOWN;
break;
|