2 Implementation of EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL protocol.
4 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 // EFI Component Name Functions
16 Retrieves a Unicode string that is the user-readable name of the EFI Driver.
18 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
19 @param Language A pointer to a three-character ISO 639-2 language identifier.
20 This is the language of the driver name that that the caller
21 is requesting, and it must match one of the languages specified
22 in SupportedLanguages. The number of languages supported by a
23 driver is up to the driver writer.
24 @param DriverName A pointer to the Unicode string to return. This Unicode string
25 is the name of the driver specified by This in the language
26 specified by Language.
28 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
29 and the language specified by Language was returned
31 @retval EFI_INVALID_PARAMETER Language is NULL.
32 @retval EFI_INVALID_PARAMETER DriverName is NULL.
33 @retval EFI_UNSUPPORTED The driver specified by This does not support the
34 language specified by Language.
39 DnsComponentNameGetDriverName (
40 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
42 OUT CHAR16
**DriverName
46 Retrieves a Unicode string that is the user readable name of the controller
47 that is being managed by an EFI Driver.
49 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
50 @param ControllerHandle The handle of a controller that the driver specified by
51 This is managing. This handle specifies the controller
52 whose name is to be returned.
53 @param ChildHandle The handle of the child controller to retrieve the name
54 of. This is an optional parameter that may be NULL. It
55 will be NULL for device drivers. It will also be NULL
56 for a bus drivers that wish to retrieve the name of the
57 bus controller. It will not be NULL for a bus driver
58 that wishes to retrieve the name of a child controller.
59 @param Language A pointer to a three character ISO 639-2 language
60 identifier. This is the language of the controller name
61 that the caller is requesting, and it must match one
62 of the languages specified in SupportedLanguages. The
63 number of languages supported by a driver is up to the
65 @param ControllerName A pointer to the Unicode string to return. This Unicode
66 string is the name of the controller specified by
67 ControllerHandle and ChildHandle in the language specified
68 by Language, from the point of view of the driver specified
71 @retval EFI_SUCCESS The Unicode string for the user-readable name in the
72 language specified by Language for the driver
73 specified by This was returned in DriverName.
74 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
75 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
76 @retval EFI_INVALID_PARAMETER Language is NULL.
77 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
78 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
79 the controller specified by ControllerHandle and
81 @retval EFI_UNSUPPORTED The driver specified by This does not support the
82 language specified by Language.
87 DnsComponentNameGetControllerName (
88 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
89 IN EFI_HANDLE ControllerHandle
,
90 IN EFI_HANDLE ChildHandle OPTIONAL
,
92 OUT CHAR16
**ControllerName
96 /// Component Name Protocol instance
98 GLOBAL_REMOVE_IF_UNREFERENCED
99 EFI_COMPONENT_NAME_PROTOCOL gDnsComponentName
= {
100 DnsComponentNameGetDriverName
,
101 DnsComponentNameGetControllerName
,
106 /// Component Name 2 Protocol instance
108 GLOBAL_REMOVE_IF_UNREFERENCED
109 EFI_COMPONENT_NAME2_PROTOCOL gDnsComponentName2
= {
110 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)DnsComponentNameGetDriverName
,
111 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)DnsComponentNameGetControllerName
,
116 /// Table of driver names
118 GLOBAL_REMOVE_IF_UNREFERENCED
119 EFI_UNICODE_STRING_TABLE mDnsDriverNameTable
[] = {
120 { "eng;en", (CHAR16
*)L
"DNS Network Service Driver" },
124 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gDnsControllerNameTable
= NULL
;
127 Retrieves a Unicode string that is the user-readable name of the EFI Driver.
129 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
130 @param Language A pointer to a three-character ISO 639-2 language identifier.
131 This is the language of the driver name that that the caller
132 is requesting, and it must match one of the languages specified
133 in SupportedLanguages. The number of languages supported by a
134 driver is up to the driver writer.
135 @param DriverName A pointer to the Unicode string to return. This Unicode string
136 is the name of the driver specified by This in the language
137 specified by Language.
139 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
140 and the language specified by Language was returned
142 @retval EFI_INVALID_PARAMETER Language is NULL.
143 @retval EFI_INVALID_PARAMETER DriverName is NULL.
144 @retval EFI_UNSUPPORTED The driver specified by This does not support the
145 language specified by Language.
150 DnsComponentNameGetDriverName (
151 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
153 OUT CHAR16
**DriverName
156 return LookupUnicodeString2 (
158 This
->SupportedLanguages
,
161 (BOOLEAN
)(This
== &gDnsComponentName
)
166 Update the component name for the Dns4 child handle.
168 @param Dns4 A pointer to the EFI_DNS4_PROTOCOL.
171 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
172 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
177 EFI_DNS4_PROTOCOL
*Dns4
181 CHAR16 HandleName
[80];
182 EFI_DNS4_MODE_DATA ModeData
;
185 return EFI_INVALID_PARAMETER
;
189 // Format the child name into the string buffer as:
190 // DNSv4 (StationIp=?, LocalPort=?)
192 Status
= Dns4
->GetModeData (Dns4
, &ModeData
);
193 if (EFI_ERROR (Status
)) {
200 L
"DNSv4 (StationIp=%d.%d.%d.%d, LocalPort=%d)",
201 ModeData
.DnsConfigData
.StationIp
.Addr
[0],
202 ModeData
.DnsConfigData
.StationIp
.Addr
[1],
203 ModeData
.DnsConfigData
.StationIp
.Addr
[2],
204 ModeData
.DnsConfigData
.StationIp
.Addr
[3],
205 ModeData
.DnsConfigData
.LocalPort
208 if (ModeData
.DnsCacheList
!= NULL
) {
209 FreePool (ModeData
.DnsCacheList
);
212 if (ModeData
.DnsServerList
!= NULL
) {
213 FreePool (ModeData
.DnsServerList
);
216 if (gDnsControllerNameTable
!= NULL
) {
217 FreeUnicodeStringTable (gDnsControllerNameTable
);
218 gDnsControllerNameTable
= NULL
;
221 Status
= AddUnicodeString2 (
223 gDnsComponentName
.SupportedLanguages
,
224 &gDnsControllerNameTable
,
228 if (EFI_ERROR (Status
)) {
232 return AddUnicodeString2 (
234 gDnsComponentName2
.SupportedLanguages
,
235 &gDnsControllerNameTable
,
242 Update the component name for the Dns6 child handle.
244 @param Dns6 A pointer to the EFI_DNS6_PROTOCOL.
247 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
248 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
253 EFI_DNS6_PROTOCOL
*Dns6
257 CHAR16 HandleName
[128];
258 EFI_DNS6_MODE_DATA ModeData
;
259 CHAR16 Address
[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
262 return EFI_INVALID_PARAMETER
;
266 // Format the child name into the string buffer as:
267 // DNSv6 (StationIp=?, LocalPort=?)
269 Status
= Dns6
->GetModeData (Dns6
, &ModeData
);
270 if (EFI_ERROR (Status
)) {
274 Status
= NetLibIp6ToStr (&ModeData
.DnsConfigData
.StationIp
, Address
, sizeof (Address
));
275 if (EFI_ERROR (Status
)) {
282 L
"DNSv6 (StationIp=%s, LocalPort=%d)",
284 ModeData
.DnsConfigData
.LocalPort
287 if (ModeData
.DnsCacheList
!= NULL
) {
288 FreePool (ModeData
.DnsCacheList
);
291 if (ModeData
.DnsServerList
!= NULL
) {
292 FreePool (ModeData
.DnsServerList
);
295 if (gDnsControllerNameTable
!= NULL
) {
296 FreeUnicodeStringTable (gDnsControllerNameTable
);
297 gDnsControllerNameTable
= NULL
;
300 Status
= AddUnicodeString2 (
302 gDnsComponentName
.SupportedLanguages
,
303 &gDnsControllerNameTable
,
307 if (EFI_ERROR (Status
)) {
311 return AddUnicodeString2 (
313 gDnsComponentName2
.SupportedLanguages
,
314 &gDnsControllerNameTable
,
321 Retrieves a Unicode string that is the user readable name of the controller
322 that is being managed by an EFI Driver.
324 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
325 @param ControllerHandle The handle of a controller that the driver specified by
326 This is managing. This handle specifies the controller
327 whose name is to be returned.
328 @param ChildHandle The handle of the child controller to retrieve the name
329 of. This is an optional parameter that may be NULL. It
330 will be NULL for device drivers. It will also be NULL
331 for a bus drivers that wish to retrieve the name of the
332 bus controller. It will not be NULL for a bus driver
333 that wishes to retrieve the name of a child controller.
334 @param Language A pointer to a three character ISO 639-2 language
335 identifier. This is the language of the controller name
336 that the caller is requesting, and it must match one
337 of the languages specified in SupportedLanguages. The
338 number of languages supported by a driver is up to the
340 @param ControllerName A pointer to the Unicode string to return. This Unicode
341 string is the name of the controller specified by
342 ControllerHandle and ChildHandle in the language specified
343 by Language, from the point of view of the driver specified
346 @retval EFI_SUCCESS The Unicode string for the user-readable name in the
347 language specified by Language for the driver
348 specified by This was returned in DriverName.
349 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
350 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
351 @retval EFI_INVALID_PARAMETER Language is NULL.
352 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
353 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
354 the controller specified by ControllerHandle and
356 @retval EFI_UNSUPPORTED The driver specified by This does not support the
357 language specified by Language.
362 DnsComponentNameGetControllerName (
363 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
364 IN EFI_HANDLE ControllerHandle
,
365 IN EFI_HANDLE ChildHandle OPTIONAL
,
367 OUT CHAR16
**ControllerName
371 EFI_DNS4_PROTOCOL
*Dns4
;
372 EFI_DNS6_PROTOCOL
*Dns6
;
375 // ChildHandle must be NULL for a Device Driver
377 if (ChildHandle
== NULL
) {
378 return EFI_UNSUPPORTED
;
382 // Make sure this driver produced ChildHandle
384 Status
= EfiTestChildHandle (
387 &gEfiUdp6ProtocolGuid
389 if (!EFI_ERROR (Status
)) {
391 // Retrieve an instance of a produced protocol from ChildHandle
393 Status
= gBS
->OpenProtocol (
395 &gEfiDns6ProtocolGuid
,
399 EFI_OPEN_PROTOCOL_GET_PROTOCOL
401 if (EFI_ERROR (Status
)) {
406 // Update the component name for this child handle.
408 Status
= UpdateDns6Name (Dns6
);
409 if (EFI_ERROR (Status
)) {
415 // Make sure this driver produced ChildHandle
417 Status
= EfiTestChildHandle (
420 &gEfiUdp4ProtocolGuid
422 if (!EFI_ERROR (Status
)) {
424 // Retrieve an instance of a produced protocol from ChildHandle
426 Status
= gBS
->OpenProtocol (
428 &gEfiDns4ProtocolGuid
,
432 EFI_OPEN_PROTOCOL_GET_PROTOCOL
434 if (EFI_ERROR (Status
)) {
439 // Update the component name for this child handle.
441 Status
= UpdateDns4Name (Dns4
);
442 if (EFI_ERROR (Status
)) {
447 return LookupUnicodeString2 (
449 This
->SupportedLanguages
,
450 gDnsControllerNameTable
,
452 (BOOLEAN
)(This
== &gDnsComponentName
)