]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Dhcp6Dxe/ComponentName.c
MdePkg/PciExpress: Add macro PCI_ECAM_ADDRESS
[mirror_edk2.git] / NetworkPkg / Dhcp6Dxe / ComponentName.c
index 314ca37d16b54d69512a13f11dfe84f133194025..ba612156a09f1001807eff58127731d258799848 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Component Name(2) protocol implementation for Dhcp6 driver.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, 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
@@ -115,7 +115,7 @@ Dhcp6ComponentNameGetDriverName (
                                 driver specified by This was returned in\r
                                 DriverName.\r
 \r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
 \r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid\r
                                 EFI_HANDLE.\r
@@ -172,6 +172,19 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE       mDhcp6DriverNameTab
   }\r
 };\r
 \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE   *gDhcp6ControllerNameTable = NULL;\r
+\r
+CHAR16 *mDhcp6ControllerName[] = {\r
+  L"DHCPv6 (State=0, Init)",\r
+  L"DHCPv6 (State=1, Selecting)",\r
+  L"DHCPv6 (State=2, Requesting)",\r
+  L"DHCPv6 (State=3, Declining)",\r
+  L"DHCPv6 (State=4, Confirming)",\r
+  L"DHCPv6 (State=5, Releasing)",\r
+  L"DHCPv6 (State=6, Bound)",\r
+  L"DHCPv6 (State=7, Renewing)",\r
+  L"DHCPv6 (State=8, Rebinding)"\r
+};\r
 \r
 /**\r
   Retrieves a Unicode string that is the user-readable name of the driver.\r
@@ -229,6 +242,77 @@ Dhcp6ComponentNameGetDriverName (
            );\r
 }\r
 \r
+/**\r
+  Update the component name for the Dhcp6 child handle.\r
+\r
+  @param  Dhcp6[in]                   A pointer to the EFI_DHCP6_PROTOCOL.\r
+\r
+  \r
+  @retval EFI_SUCCESS                 Update the ControllerNameTable of this instance successfully.\r
+  @retval EFI_INVALID_PARAMETER       The input parameter is invalid.\r
+  \r
+**/\r
+EFI_STATUS\r
+UpdateName (\r
+  IN   EFI_DHCP6_PROTOCOL             *Dhcp6\r
+  )\r
+{\r
+  EFI_STATUS                       Status;\r
+  EFI_DHCP6_MODE_DATA              Dhcp6ModeData;\r
+  CHAR16                           *HandleName;\r
+\r
+  if (Dhcp6 == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Format the child name into the string buffer.\r
+  //\r
+  Status = Dhcp6->GetModeData (Dhcp6, &Dhcp6ModeData, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
+  if (gDhcp6ControllerNameTable != NULL) {\r
+    FreeUnicodeStringTable (gDhcp6ControllerNameTable);\r
+    gDhcp6ControllerNameTable = NULL;\r
+  }\r
+  \r
+  if (Dhcp6ModeData.Ia == NULL) {\r
+    HandleName = L"DHCPv6 (No configured IA)";\r
+  } else {\r
+    if (Dhcp6ModeData.Ia->State > Dhcp6Rebinding) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+    HandleName = mDhcp6ControllerName[Dhcp6ModeData.Ia->State];\r
+  }\r
+\r
+  if (Dhcp6ModeData.Ia != NULL) {\r
+    FreePool (Dhcp6ModeData.Ia);\r
+  }\r
+  if (Dhcp6ModeData.ClientId != NULL) {\r
+    FreePool (Dhcp6ModeData.ClientId);\r
+  }\r
+\r
+  Status = AddUnicodeString2 (\r
+             "eng",\r
+             gDhcp6ComponentName.SupportedLanguages,\r
+             &gDhcp6ControllerNameTable,\r
+             HandleName,\r
+             TRUE\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
+  return AddUnicodeString2 (\r
+           "en",\r
+           gDhcp6ComponentName2.SupportedLanguages,\r
+           &gDhcp6ControllerNameTable,\r
+           HandleName,\r
+           FALSE\r
+           );\r
+}\r
 \r
 /**\r
   Retrieves a Unicode string that is the user-readable name of the controller\r
@@ -281,7 +365,7 @@ Dhcp6ComponentNameGetDriverName (
                                 driver specified by This was returned in\r
                                 DriverName.\r
 \r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
 \r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid\r
                                 EFI_HANDLE.\r
@@ -308,5 +392,57 @@ Dhcp6ComponentNameGetControllerName (
   OUT CHAR16                                          **ControllerName\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  EFI_STATUS                    Status;\r
+  EFI_DHCP6_PROTOCOL            *Dhcp6;\r
+\r
+  //\r
+  // Only provide names for child handles.\r
+  //\r
+  if (ChildHandle == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  // \r
+  // Make sure this driver produced ChildHandle \r
+  // \r
+  Status = EfiTestChildHandle (\r
+             ControllerHandle,\r
+             ChildHandle, \r
+             &gEfiUdp6ProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Retrieve an instance of a produced protocol from ChildHandle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ChildHandle,\r
+                  &gEfiDhcp6ProtocolGuid,\r
+                  (VOID **)&Dhcp6, \r
+                  NULL,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Update the component name for this child handle.\r
+  //\r
+  Status = UpdateName (Dhcp6);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           gDhcp6ControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gDhcp6ComponentName)\r
+           );\r
 }\r
+\r