/** @file\r
UEFI Component Name(2) protocol implementation for Dhcp6 driver.\r
\r
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2018, 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
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php.\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
}\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
);\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
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