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"
13 Retrieves a Unicode string that is the user-readable name of the driver.
15 This function retrieves the user-readable name of a driver in the form of a
16 Unicode string. If the driver specified by This has a user-readable name in
17 the language specified by Language, then a pointer to the driver name is
18 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
19 by This does not support the language specified by Language,
20 then EFI_UNSUPPORTED is returned.
22 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
23 EFI_COMPONENT_NAME_PROTOCOL instance.
25 @param[in] Language A pointer to a Null-terminated ASCII string
26 array indicating the language. This is the
27 language of the driver name that the caller is
28 requesting, and it must match one of the
29 languages specified in SupportedLanguages. The
30 number of languages supported by a driver is up
31 to the driver writer. Language is specified
32 in RFC 4646 or ISO 639-2 language code format.
34 @param[out] DriverName A pointer to the Unicode string to return.
35 This Unicode string is the name of the
36 driver specified by This in the language
37 specified by Language.
39 @retval EFI_SUCCESS The Unicode string for the Driver specified by
40 This and the language specified by Language was
41 returned in DriverName.
43 @retval EFI_INVALID_PARAMETER Language is NULL.
45 @retval EFI_INVALID_PARAMETER DriverName is NULL.
47 @retval EFI_UNSUPPORTED The driver specified by This does not support
48 the language specified by Language.
53 Dhcp6ComponentNameGetDriverName (
54 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
56 OUT CHAR16
**DriverName
60 Retrieves a Unicode string that is the user-readable name of the controller
61 that is being managed by a driver.
63 This function retrieves the user-readable name of the controller specified by
64 ControllerHandle and ChildHandle in the form of a Unicode string. If the
65 driver specified by This has a user-readable name in the language specified by
66 Language, then a pointer to the controller name is returned in ControllerName,
67 and EFI_SUCCESS is returned. If the driver specified by This is not currently
68 managing the controller specified by ControllerHandle and ChildHandle,
69 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
70 support the language specified by Language, then EFI_UNSUPPORTED is returned.
72 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
73 EFI_COMPONENT_NAME_PROTOCOL instance.
75 @param[in] ControllerHandle The handle of a controller that the driver
76 specified by This is managing. This handle
77 specifies the controller whose name is to be
80 @param[in] ChildHandle The handle of the child controller to retrieve
81 the name of. This is an optional parameter that
82 may be NULL. It will be NULL for device
83 drivers. It will also be NULL for a bus drivers
84 that attempt to retrieve the name of the bus
85 controller. It will not be NULL for a bus
86 driver that attempts to retrieve the name of a
89 @param[in] Language A pointer to a Null-terminated ASCII string
90 array indicating the language. This is the
91 language of the driver name that the caller is
92 requesting, and it must match one of the
93 languages specified in SupportedLanguages. The
94 number of languages supported by a driver is up
95 to the driver writer. Language is specified in
96 RFC 4646 or ISO 639-2 language code format.
98 @param[out] ControllerName A pointer to the Unicode string to return.
99 This Unicode string is the name of the
100 controller specified by ControllerHandle and
101 ChildHandle in the language specified by
102 Language, from the point of view of the driver
105 @retval EFI_SUCCESS The Unicode string for the user-readable name in
106 the language specified by Language for the
107 driver specified by This was returned in
110 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
112 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
115 @retval EFI_INVALID_PARAMETER Language is NULL.
117 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
119 @retval EFI_UNSUPPORTED The driver specified by This is not currently
120 managing the controller specified by
121 ControllerHandle and ChildHandle.
123 @retval EFI_UNSUPPORTED The driver specified by This does not support
124 the language specified by Language.
129 Dhcp6ComponentNameGetControllerName (
130 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
131 IN EFI_HANDLE ControllerHandle
,
132 IN EFI_HANDLE ChildHandle OPTIONAL
,
134 OUT CHAR16
**ControllerName
138 // EFI Component Name Protocol
140 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName
= {
141 Dhcp6ComponentNameGetDriverName
,
142 Dhcp6ComponentNameGetControllerName
,
147 // EFI Component Name 2 Protocol
149 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2
= {
150 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)Dhcp6ComponentNameGetDriverName
,
151 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)Dhcp6ComponentNameGetControllerName
,
155 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcp6DriverNameTable
[] = {
158 L
"DHCP6 Protocol Driver"
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gDhcp6ControllerNameTable
= NULL
;
168 CHAR16
*mDhcp6ControllerName
[] = {
169 L
"DHCPv6 (State=0, Init)",
170 L
"DHCPv6 (State=1, Selecting)",
171 L
"DHCPv6 (State=2, Requesting)",
172 L
"DHCPv6 (State=3, Declining)",
173 L
"DHCPv6 (State=4, Confirming)",
174 L
"DHCPv6 (State=5, Releasing)",
175 L
"DHCPv6 (State=6, Bound)",
176 L
"DHCPv6 (State=7, Renewing)",
177 L
"DHCPv6 (State=8, Rebinding)"
181 Retrieves a Unicode string that is the user-readable name of the driver.
183 This function retrieves the user-readable name of a driver in the form of a
184 Unicode string. If the driver specified by This has a user-readable name in
185 the language specified by Language, then a pointer to the driver name is
186 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
187 by This does not support the language specified by Language,
188 then EFI_UNSUPPORTED is returned.
190 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
191 EFI_COMPONENT_NAME_PROTOCOL instance.
193 @param[in] Language A pointer to a Null-terminated ASCII string
194 array indicating the language. This is the
195 language of the driver name that the caller is
196 requesting, and it must match one of the
197 languages specified in SupportedLanguages. The
198 number of languages supported by a driver is up
199 to the driver writer. Language is specified
200 in RFC 4646 or ISO 639-2 language code format.
202 @param[out] DriverName A pointer to the Unicode string to return.
203 This Unicode string is the name of the
204 driver specified by This in the language
205 specified by Language.
207 @retval EFI_SUCCESS The Unicode string for the Driver specified by
208 This and the language specified by Language was
209 returned in DriverName.
211 @retval EFI_INVALID_PARAMETER Language is NULL.
213 @retval EFI_INVALID_PARAMETER DriverName is NULL.
215 @retval EFI_UNSUPPORTED The driver specified by This does not support
216 the language specified by Language.
221 Dhcp6ComponentNameGetDriverName (
222 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
224 OUT CHAR16
**DriverName
227 return LookupUnicodeString2 (
229 This
->SupportedLanguages
,
230 mDhcp6DriverNameTable
,
232 (BOOLEAN
)(This
== &gDhcp6ComponentName
)
237 Update the component name for the Dhcp6 child handle.
239 @param Dhcp6[in] A pointer to the EFI_DHCP6_PROTOCOL.
242 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
243 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
248 IN EFI_DHCP6_PROTOCOL
*Dhcp6
252 EFI_DHCP6_MODE_DATA Dhcp6ModeData
;
256 return EFI_INVALID_PARAMETER
;
260 // Format the child name into the string buffer.
262 Status
= Dhcp6
->GetModeData (Dhcp6
, &Dhcp6ModeData
, NULL
);
263 if (EFI_ERROR (Status
)) {
267 if (gDhcp6ControllerNameTable
!= NULL
) {
268 FreeUnicodeStringTable (gDhcp6ControllerNameTable
);
269 gDhcp6ControllerNameTable
= NULL
;
272 if (Dhcp6ModeData
.Ia
== NULL
) {
273 HandleName
= L
"DHCPv6 (No configured IA)";
275 if (Dhcp6ModeData
.Ia
->State
> Dhcp6Rebinding
) {
276 return EFI_DEVICE_ERROR
;
279 HandleName
= mDhcp6ControllerName
[Dhcp6ModeData
.Ia
->State
];
282 if (Dhcp6ModeData
.Ia
!= NULL
) {
283 FreePool (Dhcp6ModeData
.Ia
);
286 if (Dhcp6ModeData
.ClientId
!= NULL
) {
287 FreePool (Dhcp6ModeData
.ClientId
);
290 Status
= AddUnicodeString2 (
292 gDhcp6ComponentName
.SupportedLanguages
,
293 &gDhcp6ControllerNameTable
,
297 if (EFI_ERROR (Status
)) {
301 return AddUnicodeString2 (
303 gDhcp6ComponentName2
.SupportedLanguages
,
304 &gDhcp6ControllerNameTable
,
311 Retrieves a Unicode string that is the user-readable name of the controller
312 that is being managed by a driver.
314 This function retrieves the user-readable name of the controller specified by
315 ControllerHandle and ChildHandle in the form of a Unicode string. If the
316 driver specified by This has a user-readable name in the language specified by
317 Language, then a pointer to the controller name is returned in ControllerName,
318 and EFI_SUCCESS is returned. If the driver specified by This is not currently
319 managing the controller specified by ControllerHandle and ChildHandle,
320 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
321 support the language specified by Language, then EFI_UNSUPPORTED is returned.
323 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
324 EFI_COMPONENT_NAME_PROTOCOL instance.
326 @param[in] ControllerHandle The handle of a controller that the driver
327 specified by This is managing. This handle
328 specifies the controller whose name is to be
331 @param[in] ChildHandle The handle of the child controller to retrieve
332 the name of. This is an optional parameter that
333 may be NULL. It will be NULL for device
334 drivers. It will also be NULL for a bus drivers
335 that wish to retrieve the name of the bus
336 controller. It will not be NULL for a bus
337 driver that wishes to retrieve the name of a
340 @param[in] Language A pointer to a Null-terminated ASCII string
341 array indicating the language. This is the
342 language of the driver name that the caller is
343 requesting, and it must match one of the
344 languages specified in SupportedLanguages. The
345 number of languages supported by a driver is up
346 to the driver writer. Language is specified in the
347 RFC 4646 or ISO 639-2 language code format.
349 @param[out] ControllerName A pointer to the Unicode string to return.
350 This Unicode string is the name of the
351 controller specified by ControllerHandle and
352 ChildHandle in the language specified by
353 Language, from the point of view of the driver
356 @retval EFI_SUCCESS The Unicode string for the user-readable name in
357 the language specified by Language for the
358 driver specified by This was returned in
361 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
363 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
366 @retval EFI_INVALID_PARAMETER Language is NULL.
368 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
370 @retval EFI_UNSUPPORTED The driver specified by This is not currently
371 managing the controller specified by
372 ControllerHandle and ChildHandle.
374 @retval EFI_UNSUPPORTED The driver specified by This does not support
375 the language specified by Language.
380 Dhcp6ComponentNameGetControllerName (
381 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
382 IN EFI_HANDLE ControllerHandle
,
383 IN EFI_HANDLE ChildHandle OPTIONAL
,
385 OUT CHAR16
**ControllerName
389 EFI_DHCP6_PROTOCOL
*Dhcp6
;
392 // Only provide names for child handles.
394 if (ChildHandle
== NULL
) {
395 return EFI_UNSUPPORTED
;
399 // Make sure this driver produced ChildHandle
401 Status
= EfiTestChildHandle (
404 &gEfiUdp6ProtocolGuid
406 if (EFI_ERROR (Status
)) {
411 // Retrieve an instance of a produced protocol from ChildHandle
413 Status
= gBS
->OpenProtocol (
415 &gEfiDhcp6ProtocolGuid
,
419 EFI_OPEN_PROTOCOL_GET_PROTOCOL
421 if (EFI_ERROR (Status
)) {
426 // Update the component name for this child handle.
428 Status
= UpdateName (Dhcp6
);
429 if (EFI_ERROR (Status
)) {
433 return LookupUnicodeString2 (
435 This
->SupportedLanguages
,
436 gDhcp6ControllerNameTable
,
438 (BOOLEAN
)(This
== &gDhcp6ComponentName
)