2 UEFI Component Name(2) protocol implementation for Dhcp6 driver.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "Dhcp6Impl.h"
14 Retrieves a Unicode string that is the user-readable name of the driver.
16 This function retrieves the user-readable name of a driver in the form of a
17 Unicode string. If the driver specified by This has a user-readable name in
18 the language specified by Language, then a pointer to the driver name is
19 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
20 by This does not support the language specified by Language,
21 then EFI_UNSUPPORTED is returned.
23 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
24 EFI_COMPONENT_NAME_PROTOCOL instance.
26 @param[in] Language A pointer to a Null-terminated ASCII string
27 array indicating the language. This is the
28 language of the driver name that the caller is
29 requesting, and it must match one of the
30 languages specified in SupportedLanguages. The
31 number of languages supported by a driver is up
32 to the driver writer. Language is specified
33 in RFC 4646 or ISO 639-2 language code format.
35 @param[out] DriverName A pointer to the Unicode string to return.
36 This Unicode string is the name of the
37 driver specified by This in the language
38 specified by Language.
40 @retval EFI_SUCCESS The Unicode string for the Driver specified by
41 This and the language specified by Language was
42 returned in DriverName.
44 @retval EFI_INVALID_PARAMETER Language is NULL.
46 @retval EFI_INVALID_PARAMETER DriverName is NULL.
48 @retval EFI_UNSUPPORTED The driver specified by This does not support
49 the language specified by Language.
54 Dhcp6ComponentNameGetDriverName (
55 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
57 OUT CHAR16
**DriverName
62 Retrieves a Unicode string that is the user-readable name of the controller
63 that is being managed by a driver.
65 This function retrieves the user-readable name of the controller specified by
66 ControllerHandle and ChildHandle in the form of a Unicode string. If the
67 driver specified by This has a user-readable name in the language specified by
68 Language, then a pointer to the controller name is returned in ControllerName,
69 and EFI_SUCCESS is returned. If the driver specified by This is not currently
70 managing the controller specified by ControllerHandle and ChildHandle,
71 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
72 support the language specified by Language, then EFI_UNSUPPORTED is returned.
74 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
75 EFI_COMPONENT_NAME_PROTOCOL instance.
77 @param[in] ControllerHandle The handle of a controller that the driver
78 specified by This is managing. This handle
79 specifies the controller whose name is to be
82 @param[in] ChildHandle The handle of the child controller to retrieve
83 the name of. This is an optional parameter that
84 may be NULL. It will be NULL for device
85 drivers. It will also be NULL for a bus drivers
86 that attempt to retrieve the name of the bus
87 controller. It will not be NULL for a bus
88 driver that attempts to retrieve the name of a
91 @param[in] Language A pointer to a Null-terminated ASCII string
92 array indicating the language. This is the
93 language of the driver name that the caller is
94 requesting, and it must match one of the
95 languages specified in SupportedLanguages. The
96 number of languages supported by a driver is up
97 to the driver writer. Language is specified in
98 RFC 4646 or ISO 639-2 language code format.
100 @param[out] ControllerName A pointer to the Unicode string to return.
101 This Unicode string is the name of the
102 controller specified by ControllerHandle and
103 ChildHandle in the language specified by
104 Language, from the point of view of the driver
107 @retval EFI_SUCCESS The Unicode string for the user-readable name in
108 the language specified by Language for the
109 driver specified by This was returned in
112 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
114 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
117 @retval EFI_INVALID_PARAMETER Language is NULL.
119 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
121 @retval EFI_UNSUPPORTED The driver specified by This is not currently
122 managing the controller specified by
123 ControllerHandle and ChildHandle.
125 @retval EFI_UNSUPPORTED The driver specified by This does not support
126 the language specified by Language.
131 Dhcp6ComponentNameGetControllerName (
132 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
133 IN EFI_HANDLE ControllerHandle
,
134 IN EFI_HANDLE ChildHandle OPTIONAL
,
136 OUT CHAR16
**ControllerName
141 // EFI Component Name Protocol
143 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName
= {
144 Dhcp6ComponentNameGetDriverName
,
145 Dhcp6ComponentNameGetControllerName
,
150 // EFI Component Name 2 Protocol
152 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2
= {
153 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Dhcp6ComponentNameGetDriverName
,
154 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Dhcp6ComponentNameGetControllerName
,
158 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcp6DriverNameTable
[] = {
161 L
"DHCP6 Protocol Driver"
169 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gDhcp6ControllerNameTable
= NULL
;
171 CHAR16
*mDhcp6ControllerName
[] = {
172 L
"DHCPv6 (State=0, Init)",
173 L
"DHCPv6 (State=1, Selecting)",
174 L
"DHCPv6 (State=2, Requesting)",
175 L
"DHCPv6 (State=3, Declining)",
176 L
"DHCPv6 (State=4, Confirming)",
177 L
"DHCPv6 (State=5, Releasing)",
178 L
"DHCPv6 (State=6, Bound)",
179 L
"DHCPv6 (State=7, Renewing)",
180 L
"DHCPv6 (State=8, Rebinding)"
184 Retrieves a Unicode string that is the user-readable name of the driver.
186 This function retrieves the user-readable name of a driver in the form of a
187 Unicode string. If the driver specified by This has a user-readable name in
188 the language specified by Language, then a pointer to the driver name is
189 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
190 by This does not support the language specified by Language,
191 then EFI_UNSUPPORTED is returned.
193 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
194 EFI_COMPONENT_NAME_PROTOCOL instance.
196 @param[in] Language A pointer to a Null-terminated ASCII string
197 array indicating the language. This is the
198 language of the driver name that the caller is
199 requesting, and it must match one of the
200 languages specified in SupportedLanguages. The
201 number of languages supported by a driver is up
202 to the driver writer. Language is specified
203 in RFC 4646 or ISO 639-2 language code format.
205 @param[out] DriverName A pointer to the Unicode string to return.
206 This Unicode string is the name of the
207 driver specified by This in the language
208 specified by Language.
210 @retval EFI_SUCCESS The Unicode string for the Driver specified by
211 This and the language specified by Language was
212 returned in DriverName.
214 @retval EFI_INVALID_PARAMETER Language is NULL.
216 @retval EFI_INVALID_PARAMETER DriverName is NULL.
218 @retval EFI_UNSUPPORTED The driver specified by This does not support
219 the language specified by Language.
224 Dhcp6ComponentNameGetDriverName (
225 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
227 OUT CHAR16
**DriverName
230 return LookupUnicodeString2 (
232 This
->SupportedLanguages
,
233 mDhcp6DriverNameTable
,
235 (BOOLEAN
)(This
== &gDhcp6ComponentName
)
240 Update the component name for the Dhcp6 child handle.
242 @param Dhcp6[in] A pointer to the EFI_DHCP6_PROTOCOL.
245 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
246 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
251 IN EFI_DHCP6_PROTOCOL
*Dhcp6
255 EFI_DHCP6_MODE_DATA Dhcp6ModeData
;
259 return EFI_INVALID_PARAMETER
;
263 // Format the child name into the string buffer.
265 Status
= Dhcp6
->GetModeData (Dhcp6
, &Dhcp6ModeData
, NULL
);
266 if (EFI_ERROR (Status
)) {
270 if (gDhcp6ControllerNameTable
!= NULL
) {
271 FreeUnicodeStringTable (gDhcp6ControllerNameTable
);
272 gDhcp6ControllerNameTable
= NULL
;
275 if (Dhcp6ModeData
.Ia
== NULL
) {
276 HandleName
= L
"DHCPv6 (No configured IA)";
278 if (Dhcp6ModeData
.Ia
->State
> Dhcp6Rebinding
) {
279 return EFI_DEVICE_ERROR
;
281 HandleName
= mDhcp6ControllerName
[Dhcp6ModeData
.Ia
->State
];
284 if (Dhcp6ModeData
.Ia
!= NULL
) {
285 FreePool (Dhcp6ModeData
.Ia
);
287 if (Dhcp6ModeData
.ClientId
!= NULL
) {
288 FreePool (Dhcp6ModeData
.ClientId
);
291 Status
= AddUnicodeString2 (
293 gDhcp6ComponentName
.SupportedLanguages
,
294 &gDhcp6ControllerNameTable
,
298 if (EFI_ERROR (Status
)) {
302 return AddUnicodeString2 (
304 gDhcp6ComponentName2
.SupportedLanguages
,
305 &gDhcp6ControllerNameTable
,
312 Retrieves a Unicode string that is the user-readable name of the controller
313 that is being managed by a driver.
315 This function retrieves the user-readable name of the controller specified by
316 ControllerHandle and ChildHandle in the form of a Unicode string. If the
317 driver specified by This has a user-readable name in the language specified by
318 Language, then a pointer to the controller name is returned in ControllerName,
319 and EFI_SUCCESS is returned. If the driver specified by This is not currently
320 managing the controller specified by ControllerHandle and ChildHandle,
321 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
322 support the language specified by Language, then EFI_UNSUPPORTED is returned.
324 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
325 EFI_COMPONENT_NAME_PROTOCOL instance.
327 @param[in] ControllerHandle The handle of a controller that the driver
328 specified by This is managing. This handle
329 specifies the controller whose name is to be
332 @param[in] ChildHandle The handle of the child controller to retrieve
333 the name of. This is an optional parameter that
334 may be NULL. It will be NULL for device
335 drivers. It will also be NULL for a bus drivers
336 that wish to retrieve the name of the bus
337 controller. It will not be NULL for a bus
338 driver that wishes to retrieve the name of a
341 @param[in] Language A pointer to a Null-terminated ASCII string
342 array indicating the language. This is the
343 language of the driver name that the caller is
344 requesting, and it must match one of the
345 languages specified in SupportedLanguages. The
346 number of languages supported by a driver is up
347 to the driver writer. Language is specified in the
348 RFC 4646 or ISO 639-2 language code format.
350 @param[out] ControllerName A pointer to the Unicode string to return.
351 This Unicode string is the name of the
352 controller specified by ControllerHandle and
353 ChildHandle in the language specified by
354 Language, from the point of view of the driver
357 @retval EFI_SUCCESS The Unicode string for the user-readable name in
358 the language specified by Language for the
359 driver specified by This was returned in
362 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
364 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
367 @retval EFI_INVALID_PARAMETER Language is NULL.
369 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
371 @retval EFI_UNSUPPORTED The driver specified by This is not currently
372 managing the controller specified by
373 ControllerHandle and ChildHandle.
375 @retval EFI_UNSUPPORTED The driver specified by This does not support
376 the language specified by Language.
381 Dhcp6ComponentNameGetControllerName (
382 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
383 IN EFI_HANDLE ControllerHandle
,
384 IN EFI_HANDLE ChildHandle OPTIONAL
,
386 OUT CHAR16
**ControllerName
390 EFI_DHCP6_PROTOCOL
*Dhcp6
;
393 // Only provide names for child handles.
395 if (ChildHandle
== NULL
) {
396 return EFI_UNSUPPORTED
;
400 // Make sure this driver produced ChildHandle
402 Status
= EfiTestChildHandle (
405 &gEfiUdp6ProtocolGuid
407 if (EFI_ERROR (Status
)) {
412 // Retrieve an instance of a produced protocol from ChildHandle
414 Status
= gBS
->OpenProtocol (
416 &gEfiDhcp6ProtocolGuid
,
420 EFI_OPEN_PROTOCOL_GET_PROTOCOL
422 if (EFI_ERROR (Status
)) {
427 // Update the component name for this child handle.
429 Status
= UpdateName (Dhcp6
);
430 if (EFI_ERROR (Status
)) {
434 return LookupUnicodeString2 (
436 This
->SupportedLanguages
,
437 gDhcp6ControllerNameTable
,
439 (BOOLEAN
)(This
== &gDhcp6ComponentName
)