/** @file\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
-All rights reserved. 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
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified\r
- in RFC 3066 or ISO 639-2 language code format.\r
+ in RFC 4646 or ISO 639-2 language code format.\r
\r
@param[out] DriverName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified in\r
- RFC 3066 or ISO 639-2 language code format.\r
+ RFC 4646 or ISO 639-2 language code format.\r
\r
@param[out] ControllerName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
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
}\r
};\r
\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gDhcpControllerNameTable = NULL;\r
+\r
+CHAR16 *mDhcp4ControllerName[] = {\r
+ L"DHCPv4 (State=0, Stopped)",\r
+ L"DHCPv4 (State=1, Init)",\r
+ L"DHCPv4 (State=2, Selecting)",\r
+ L"DHCPv4 (State=3, Requesting)",\r
+ L"DHCPv4 (State=4, Bound)",\r
+ L"DHCPv4 (State=5, Renewing)",\r
+ L"DHCPv4 (State=6, Rebinding)",\r
+ L"DHCPv4 (State=7, InitReboot)",\r
+ L"DHCPv4 (State=8, Rebooting)"\r
+};\r
+\r
/**\r
Retrieves a Unicode string that is the user readable name of the driver.\r
\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified\r
- in RFC 3066 or ISO 639-2 language code format.\r
+ in RFC 4646 or ISO 639-2 language code format.\r
\r
@param[out] DriverName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
);\r
}\r
\r
+/**\r
+ Update the component name for the Dhcp4 child handle.\r
+\r
+ @param Dhcp4[in] A pointer to the EFI_DHCP4_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
+ @retval EFI_DEVICE_ERROR DHCP is in unknown state.\r
+\r
+**/\r
+EFI_STATUS\r
+UpdateName (\r
+ IN EFI_DHCP4_PROTOCOL *Dhcp4\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DHCP4_MODE_DATA Dhcp4ModeData;\r
+\r
+ if (Dhcp4 == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Format the child name into the string buffer.\r
+ //\r
+ Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4ModeData);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ if (gDhcpControllerNameTable != NULL) {\r
+ FreeUnicodeStringTable (gDhcpControllerNameTable);\r
+ gDhcpControllerNameTable = NULL;\r
+ }\r
+\r
+ if (Dhcp4ModeData.State > Dhcp4Rebooting) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ Status = AddUnicodeString2 (\r
+ "eng",\r
+ gDhcp4ComponentName.SupportedLanguages,\r
+ &gDhcpControllerNameTable,\r
+ mDhcp4ControllerName[Dhcp4ModeData.State],\r
+ TRUE\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return AddUnicodeString2 (\r
+ "en",\r
+ gDhcp4ComponentName2.SupportedLanguages,\r
+ &gDhcpControllerNameTable,\r
+ mDhcp4ControllerName[Dhcp4ModeData.State],\r
+ FALSE\r
+ );\r
+}\r
+\r
/**\r
Retrieves a Unicode string that is the user readable name of the controller\r
that is being managed by a driver.\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified in\r
- RFC 3066 or ISO 639-2 language code format.\r
+ RFC 4646 or ISO 639-2 language code format.\r
\r
@param[out] ControllerName A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
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
OUT CHAR16 **ControllerName\r
)\r
{\r
- return EFI_UNSUPPORTED;\r
+ EFI_STATUS Status;\r
+ EFI_DHCP4_PROTOCOL *Dhcp4;\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
+ &gEfiUdp4ProtocolGuid\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
+ &gEfiDhcp4ProtocolGuid,\r
+ (VOID **)&Dhcp4,\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 (Dhcp4);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return LookupUnicodeString2 (\r
+ Language,\r
+ This->SupportedLanguages,\r
+ gDhcpControllerNameTable,\r
+ ControllerName,\r
+ (BOOLEAN)(This == &gDhcp4ComponentName)\r
+ );\r
}\r