[edk2] [Patch 3/3 V2] ShellPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.

fanwang2 posted 3 patches 6 years, 10 months ago
[edk2] [Patch 3/3 V2] ShellPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.
Posted by fanwang2 6 years, 10 months ago
From: Wang Fan <fan.wang@intel.com>

V2:
   *Define time period in a macro instead of hard code.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
---
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 8 ++++----
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c     | 8 ++++----
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c    | 8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 082ab72..ab6ab8b 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -548,15 +548,15 @@ IfConfigShowInterfaceInfo (
   )
 {
   LIST_ENTRY                   *Entry;
   LIST_ENTRY                   *Next;
   IFCONFIG_INTERFACE_CB        *IfCb;
-  BOOLEAN                       MediaPresent;
+  EFI_STATUS                    MediaStatus;
   EFI_IPv4_ADDRESS              Gateway;
   UINT32                        Index;
   
-  MediaPresent = TRUE;
+  MediaStatus = EFI_SUCCESS;
 
   if (IsListEmpty (IfList)) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
   }
 
@@ -574,12 +574,12 @@ IfConfigShowInterfaceInfo (
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_IF_NAME), gShellNetwork1HiiHandle, IfCb->IfInfo->Name); 
 
     //
     // Get Media State.
     //
-    if (EFI_SUCCESS == NetLibDetectMedia (IfCb->NicHandle, &MediaPresent)) {
-      if (!MediaPresent) {
+    if (EFI_SUCCESS == NetLibDetectMediaWaitTimeout (IfCb->NicHandle, 0, &MediaStatus)) {
+      if (MediaStatus != EFI_SUCCESS) {
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media disconnected");
       } else {
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
       }
     } else {
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
index 10d291c..bec9535 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
@@ -964,11 +964,11 @@ PingCreateIpInstance (
   EFI_STATUS                       Status;
   UINTN                            HandleIndex;
   UINTN                            HandleNum;
   EFI_HANDLE                       *HandleBuffer;
   BOOLEAN                          UnspecifiedSrc;
-  BOOLEAN                          MediaPresent;
+  EFI_STATUS                       MediaStatus;
   EFI_SERVICE_BINDING_PROTOCOL     *EfiSb;
   VOID                             *IpXCfg;
   EFI_IP6_CONFIG_DATA              Ip6Config;
   EFI_IP4_CONFIG_DATA              Ip4Config;
   VOID                             *IpXInterfaceInfo;
@@ -976,11 +976,11 @@ PingCreateIpInstance (
   EFI_IPv6_ADDRESS                 *Addr;
   UINTN                            AddrIndex;
 
   HandleBuffer      = NULL;
   UnspecifiedSrc    = FALSE;
-  MediaPresent      = TRUE;
+  MediaStatus       = EFI_SUCCESS;
   EfiSb             = NULL;
   IpXInterfaceInfo  = NULL;
   IfInfoSize        = 0;
 
   //
@@ -1033,12 +1033,12 @@ PingCreateIpInstance (
 
     if (UnspecifiedSrc) {
       //
       // Check media.
       //
-      NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
-      if (!MediaPresent) {
+      NetLibDetectMediaWaitTimeout (HandleBuffer[HandleIndex], 0, &MediaStatus);
+      if (MediaStatus != EFI_SUCCESS) {
         //
         // Skip this one.
         //
         continue;
       }
diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
index b784696..fa27c82 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
@@ -753,22 +753,22 @@ Ping6CreateIpInstance (
   EFI_STATUS                       Status;
   UINTN                            HandleIndex;
   UINTN                            HandleNum;
   EFI_HANDLE                       *HandleBuffer;
   BOOLEAN                          UnspecifiedSrc;
-  BOOLEAN                          MediaPresent;
+  EFI_STATUS                       MediaStatus;
   EFI_SERVICE_BINDING_PROTOCOL     *Ip6Sb;
   EFI_IP6_CONFIG_PROTOCOL          *Ip6Cfg;
   EFI_IP6_CONFIG_DATA              Ip6Config;
   EFI_IP6_CONFIG_INTERFACE_INFO    *IfInfo;
   UINTN                            IfInfoSize;
   EFI_IPv6_ADDRESS                 *Addr;
   UINTN                            AddrIndex;
 
   HandleBuffer      = NULL;
   UnspecifiedSrc    = FALSE;
-  MediaPresent      = TRUE;
+  MediaStatus       = EFI_SUCCESS
   Ip6Sb             = NULL;
   IfInfo            = NULL;
   IfInfoSize        = 0;
 
   //
@@ -812,12 +812,12 @@ Ping6CreateIpInstance (
 
     if (UnspecifiedSrc) {
       //
       // Check media.
       //
-      NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
-      if (!MediaPresent) {
+      NetLibDetectMediaWaitTimeout (HandleBuffer[HandleIndex], 0, &MediaStatus);
+      if (MediaStatus != EFI_SUCCESS) {
         //
         // Skip this one.
         //
         continue;
       }
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel