]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
OvmfPkg: Removed magic values for the Virtio Sub-System ID in the PCI device drivers
[mirror_edk2.git] / ShellPkg / Library / UefiShellNetwork1CommandsLib / Ifconfig.c
index 94c9c021acf351122e558019faf014a0cb585d1b..32a4f7fb43ff61666893bf079f2669a71b17b013 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation for ifcommand shell command.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -20,7 +20,7 @@
 BOOLEAN                                 mIp4ConfigExist    = FALSE;\r
 STATIC EFI_HII_CONFIG_ROUTING_PROTOCOL  *mHiiConfigRouting = NULL;\r
 \r
-STATIC CONST UINTN SEC_TO_NS            = 10000000;\r
+STATIC CONST UINTN SecondsToNanoSeconds = 10000000;\r
 STATIC CONST CHAR16 DhcpString[5]       = L"DHCP";\r
 STATIC CONST CHAR16 StaticString[7]     = L"STATIC";\r
 STATIC CONST CHAR16 PermanentString[10] = L"PERMANENT";\r
@@ -173,7 +173,7 @@ TestChildHandle (
   Get the child handle of the NIC handle.\r
 \r
   @param[in] Controller     Routing information: GUID.\r
-  @param[in] ChildHandle    Returned child handle.\r
+  @param[out] ChildHandle   Returned child handle.\r
 \r
   @retval EFI_SUCCESS         Successfully to get child handle.\r
 **/\r
@@ -249,10 +249,10 @@ GetChildHandle (
 /**\r
   Append OFFSET/WIDTH/VALUE items at the beginning of string.\r
 \r
-  @param[in,out]  String      The pointer to the string to append onto.\r
-  @param[in]      Offset      Offset value.\r
-  @param[in]      Width       Width value.\r
-  @param[in]      Block       Point to data buffer.\r
+  @param[in, out]  String      The pointer to the string to append onto.\r
+  @param[in]       Offset      Offset value.\r
+  @param[in]       Width       Width value.\r
+  @param[in]       Block       Point to data buffer.\r
 \r
   @return The count of unicode character that were appended.\r
 **/\r
@@ -606,13 +606,19 @@ IfconfigGetAllNicInfoByHii (
     // Construct configuration request string header\r
     //\r
     ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);\r
-    Length = StrLen (ConfigHdr);\r
+    if (ConfigHdr != NULL) {\r
+      Length = StrLen (ConfigHdr);\r
+    } else {\r
+      Length = 0;\r
+    }\r
     ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
     if (ConfigResp == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto ON_ERROR;\r
     }\r
-    StrCpy (ConfigResp, ConfigHdr);\r
+    if (ConfigHdr != NULL) {\r
+      StrCpy (ConfigResp, ConfigHdr);\r
+    }\r
  \r
     //\r
     // Append OFFSET/WIDTH pair\r
@@ -772,10 +778,20 @@ IfconfigSetNicAddrByHii (
   // Construct config request string header\r
   //\r
   ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);\r
-\r
-  Length = StrLen (ConfigHdr);\r
+  if (ConfigHdr != NULL) {\r
+    Length = StrLen (ConfigHdr);\r
+  } else {\r
+    ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
   ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
-  StrCpy (ConfigResp, ConfigHdr);\r
+  if (ConfigResp == NULL) {\r
+    ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
+  if (ConfigHdr != NULL) {\r
+    StrCpy (ConfigResp, ConfigHdr);\r
+  }\r
 \r
   NicConfig = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
   if (NicConfig == NULL) {\r
@@ -1026,7 +1042,7 @@ TimeoutToGetMap (
 }\r
 \r
 /**\r
-  Create an IP child, use it to start the auto configuration, then destory it.\r
+  Create an IP child, use it to start the auto configuration, then destroy it.\r
 \r
   @param[in] NicInfo    The pointer to the NIC_INFO of the Nic to be configured.\r
 \r
@@ -1099,7 +1115,7 @@ IfconfigStartIp4(
     mTimeout = FALSE;\r
     Status  = gBS->CreateEvent (\r
                     EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
-                    TPL_CALLBACK - 1,\r
+                    TPL_CALLBACK,\r
                     TimeoutToGetMap,\r
                     NULL,\r
                     &TimerToGetMap\r
@@ -1112,7 +1128,7 @@ IfconfigStartIp4(
     Status = gBS->SetTimer (\r
                    TimerToGetMap,\r
                    TimerRelative,\r
-                   MultU64x32 (SEC_TO_NS, 5)\r
+                   MultU64x32 (SecondsToNanoSeconds, 5)\r
                    );\r
     \r
     if (EFI_ERROR (Status)) {\r