]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Dhcp6Dxe/ComponentName.c
BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / NetworkPkg / Dhcp6Dxe / ComponentName.c
CommitLineData
a3bcde70
HT
1/** @file\r
2 UEFI Component Name(2) protocol implementation for Dhcp6 driver.\r
3\r
f75a7f56 4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "Dhcp6Impl.h"\r
17\r
18\r
19/**\r
20 Retrieves a Unicode string that is the user-readable name of the driver.\r
21\r
22 This function retrieves the user-readable name of a driver in the form of a\r
23 Unicode string. If the driver specified by This has a user-readable name in\r
24 the language specified by Language, then a pointer to the driver name is\r
25 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
26 by This does not support the language specified by Language,\r
27 then EFI_UNSUPPORTED is returned.\r
28\r
29 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
30 EFI_COMPONENT_NAME_PROTOCOL instance.\r
31\r
32 @param[in] Language A pointer to a Null-terminated ASCII string\r
33 array indicating the language. This is the\r
34 language of the driver name that the caller is\r
35 requesting, and it must match one of the\r
36 languages specified in SupportedLanguages. The\r
37 number of languages supported by a driver is up\r
38 to the driver writer. Language is specified\r
39 in RFC 4646 or ISO 639-2 language code format.\r
40\r
41 @param[out] DriverName A pointer to the Unicode string to return.\r
42 This Unicode string is the name of the\r
43 driver specified by This in the language\r
44 specified by Language.\r
45\r
46 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
47 This and the language specified by Language was\r
48 returned in DriverName.\r
49\r
50 @retval EFI_INVALID_PARAMETER Language is NULL.\r
51\r
52 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
53\r
54 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
55 the language specified by Language.\r
56\r
57**/\r
58EFI_STATUS\r
59EFIAPI\r
60Dhcp6ComponentNameGetDriverName (\r
61 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
62 IN CHAR8 *Language,\r
63 OUT CHAR16 **DriverName\r
64 );\r
65\r
66\r
67/**\r
68 Retrieves a Unicode string that is the user-readable name of the controller\r
69 that is being managed by a driver.\r
70\r
71 This function retrieves the user-readable name of the controller specified by\r
72 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
73 driver specified by This has a user-readable name in the language specified by\r
74 Language, then a pointer to the controller name is returned in ControllerName,\r
75 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
76 managing the controller specified by ControllerHandle and ChildHandle,\r
77 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
78 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
79\r
80 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
81 EFI_COMPONENT_NAME_PROTOCOL instance.\r
82\r
83 @param[in] ControllerHandle The handle of a controller that the driver\r
84 specified by This is managing. This handle\r
85 specifies the controller whose name is to be\r
86 returned.\r
87\r
88 @param[in] ChildHandle The handle of the child controller to retrieve\r
89 the name of. This is an optional parameter that\r
90 may be NULL. It will be NULL for device\r
91 drivers. It will also be NULL for a bus drivers\r
92 that attempt to retrieve the name of the bus\r
93 controller. It will not be NULL for a bus\r
94 driver that attempts to retrieve the name of a\r
95 child controller.\r
96\r
97 @param[in] Language A pointer to a Null-terminated ASCII string\r
98 array indicating the language. This is the\r
99 language of the driver name that the caller is\r
100 requesting, and it must match one of the\r
101 languages specified in SupportedLanguages. The\r
102 number of languages supported by a driver is up\r
103 to the driver writer. Language is specified in\r
104 RFC 4646 or ISO 639-2 language code format.\r
105\r
106 @param[out] ControllerName A pointer to the Unicode string to return.\r
107 This Unicode string is the name of the\r
108 controller specified by ControllerHandle and\r
109 ChildHandle in the language specified by\r
110 Language, from the point of view of the driver\r
111 specified by This.\r
112\r
113 @retval EFI_SUCCESS The Unicode string for the user-readable name in\r
114 the language specified by Language for the\r
115 driver specified by This was returned in\r
116 DriverName.\r
117\r
15ee13fc 118 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
a3bcde70
HT
119\r
120 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid\r
121 EFI_HANDLE.\r
122\r
123 @retval EFI_INVALID_PARAMETER Language is NULL.\r
124\r
125 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
126\r
127 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
128 managing the controller specified by\r
129 ControllerHandle and ChildHandle.\r
130\r
131 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
132 the language specified by Language.\r
133\r
134**/\r
135EFI_STATUS\r
136EFIAPI\r
137Dhcp6ComponentNameGetControllerName (\r
138 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
139 IN EFI_HANDLE ControllerHandle,\r
140 IN EFI_HANDLE ChildHandle OPTIONAL,\r
141 IN CHAR8 *Language,\r
142 OUT CHAR16 **ControllerName\r
143 );\r
144\r
145\r
146//\r
147// EFI Component Name Protocol\r
148//\r
149GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName = {\r
150 Dhcp6ComponentNameGetDriverName,\r
151 Dhcp6ComponentNameGetControllerName,\r
152 "eng"\r
153};\r
154\r
155//\r
156// EFI Component Name 2 Protocol\r
157//\r
158GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2 = {\r
159 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Dhcp6ComponentNameGetDriverName,\r
160 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Dhcp6ComponentNameGetControllerName,\r
161 "en"\r
162};\r
163\r
164GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcp6DriverNameTable[] = {\r
165 {\r
166 "eng;en",\r
167 L"DHCP6 Protocol Driver"\r
168 },\r
169 {\r
170 NULL,\r
171 NULL\r
172 }\r
173};\r
174\r
216f7970 175GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gDhcp6ControllerNameTable = NULL;\r
176\r
177CHAR16 *mDhcp6ControllerName[] = {\r
178 L"DHCPv6 (State=0, Init)",\r
179 L"DHCPv6 (State=1, Selecting)",\r
180 L"DHCPv6 (State=2, Requesting)",\r
181 L"DHCPv6 (State=3, Declining)",\r
182 L"DHCPv6 (State=4, Confirming)",\r
183 L"DHCPv6 (State=5, Releasing)",\r
184 L"DHCPv6 (State=6, Bound)",\r
185 L"DHCPv6 (State=7, Renewing)",\r
186 L"DHCPv6 (State=8, Rebinding)"\r
187};\r
a3bcde70
HT
188\r
189/**\r
190 Retrieves a Unicode string that is the user-readable name of the driver.\r
191\r
192 This function retrieves the user-readable name of a driver in the form of a\r
193 Unicode string. If the driver specified by This has a user-readable name in\r
194 the language specified by Language, then a pointer to the driver name is\r
195 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
196 by This does not support the language specified by Language,\r
197 then EFI_UNSUPPORTED is returned.\r
198\r
199 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
200 EFI_COMPONENT_NAME_PROTOCOL instance.\r
201\r
202 @param[in] Language A pointer to a Null-terminated ASCII string\r
203 array indicating the language. This is the\r
204 language of the driver name that the caller is\r
205 requesting, and it must match one of the\r
206 languages specified in SupportedLanguages. The\r
207 number of languages supported by a driver is up\r
208 to the driver writer. Language is specified\r
209 in RFC 4646 or ISO 639-2 language code format.\r
210\r
211 @param[out] DriverName A pointer to the Unicode string to return.\r
212 This Unicode string is the name of the\r
213 driver specified by This in the language\r
214 specified by Language.\r
215\r
216 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
217 This and the language specified by Language was\r
218 returned in DriverName.\r
219\r
220 @retval EFI_INVALID_PARAMETER Language is NULL.\r
221\r
222 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
223\r
224 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
225 the language specified by Language.\r
226\r
227**/\r
228EFI_STATUS\r
229EFIAPI\r
230Dhcp6ComponentNameGetDriverName (\r
231 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
232 IN CHAR8 *Language,\r
233 OUT CHAR16 **DriverName\r
234 )\r
235{\r
236 return LookupUnicodeString2 (\r
237 Language,\r
238 This->SupportedLanguages,\r
239 mDhcp6DriverNameTable,\r
240 DriverName,\r
241 (BOOLEAN)(This == &gDhcp6ComponentName)\r
242 );\r
243}\r
244\r
216f7970 245/**\r
246 Update the component name for the Dhcp6 child handle.\r
247\r
248 @param Dhcp6[in] A pointer to the EFI_DHCP6_PROTOCOL.\r
249\r
f75a7f56 250\r
216f7970 251 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.\r
252 @retval EFI_INVALID_PARAMETER The input parameter is invalid.\r
f75a7f56 253\r
216f7970 254**/\r
255EFI_STATUS\r
256UpdateName (\r
257 IN EFI_DHCP6_PROTOCOL *Dhcp6\r
258 )\r
259{\r
260 EFI_STATUS Status;\r
261 EFI_DHCP6_MODE_DATA Dhcp6ModeData;\r
a4faf336 262 CHAR16 *HandleName;\r
216f7970 263\r
264 if (Dhcp6 == NULL) {\r
265 return EFI_INVALID_PARAMETER;\r
266 }\r
267\r
268 //\r
269 // Format the child name into the string buffer.\r
270 //\r
271 Status = Dhcp6->GetModeData (Dhcp6, &Dhcp6ModeData, NULL);\r
272 if (EFI_ERROR (Status)) {\r
273 return Status;\r
274 }\r
f75a7f56 275\r
216f7970 276 if (gDhcp6ControllerNameTable != NULL) {\r
277 FreeUnicodeStringTable (gDhcp6ControllerNameTable);\r
278 gDhcp6ControllerNameTable = NULL;\r
279 }\r
f75a7f56 280\r
216f7970 281 if (Dhcp6ModeData.Ia == NULL) {\r
a4faf336 282 HandleName = L"DHCPv6 (No configured IA)";\r
216f7970 283 } else {\r
a4faf336
FS
284 if (Dhcp6ModeData.Ia->State > Dhcp6Rebinding) {\r
285 return EFI_DEVICE_ERROR;\r
286 }\r
287 HandleName = mDhcp6ControllerName[Dhcp6ModeData.Ia->State];\r
216f7970 288 }\r
ce22514e
ZL
289\r
290 if (Dhcp6ModeData.Ia != NULL) {\r
291 FreePool (Dhcp6ModeData.Ia);\r
292 }\r
293 if (Dhcp6ModeData.ClientId != NULL) {\r
294 FreePool (Dhcp6ModeData.ClientId);\r
295 }\r
296\r
216f7970 297 Status = AddUnicodeString2 (\r
298 "eng",\r
299 gDhcp6ComponentName.SupportedLanguages,\r
300 &gDhcp6ControllerNameTable,\r
301 HandleName,\r
302 TRUE\r
303 );\r
304 if (EFI_ERROR (Status)) {\r
305 return Status;\r
306 }\r
f75a7f56 307\r
216f7970 308 return AddUnicodeString2 (\r
309 "en",\r
310 gDhcp6ComponentName2.SupportedLanguages,\r
311 &gDhcp6ControllerNameTable,\r
312 HandleName,\r
313 FALSE\r
314 );\r
315}\r
a3bcde70
HT
316\r
317/**\r
318 Retrieves a Unicode string that is the user-readable name of the controller\r
319 that is being managed by a driver.\r
320\r
321 This function retrieves the user-readable name of the controller specified by\r
322 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
323 driver specified by This has a user-readable name in the language specified by\r
324 Language, then a pointer to the controller name is returned in ControllerName,\r
325 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
326 managing the controller specified by ControllerHandle and ChildHandle,\r
327 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
328 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
329\r
330 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
331 EFI_COMPONENT_NAME_PROTOCOL instance.\r
332\r
333 @param[in] ControllerHandle The handle of a controller that the driver\r
334 specified by This is managing. This handle\r
335 specifies the controller whose name is to be\r
336 returned.\r
337\r
338 @param[in] ChildHandle The handle of the child controller to retrieve\r
339 the name of. This is an optional parameter that\r
340 may be NULL. It will be NULL for device\r
341 drivers. It will also be NULL for a bus drivers\r
342 that wish to retrieve the name of the bus\r
343 controller. It will not be NULL for a bus\r
344 driver that wishes to retrieve the name of a\r
345 child controller.\r
346\r
347 @param[in] Language A pointer to a Null-terminated ASCII string\r
348 array indicating the language. This is the\r
349 language of the driver name that the caller is\r
350 requesting, and it must match one of the\r
351 languages specified in SupportedLanguages. The\r
352 number of languages supported by a driver is up\r
353 to the driver writer. Language is specified in the\r
354 RFC 4646 or ISO 639-2 language code format.\r
355\r
356 @param[out] ControllerName A pointer to the Unicode string to return.\r
357 This Unicode string is the name of the\r
358 controller specified by ControllerHandle and\r
359 ChildHandle in the language specified by\r
360 Language, from the point of view of the driver\r
361 specified by This.\r
362\r
363 @retval EFI_SUCCESS The Unicode string for the user-readable name in\r
364 the language specified by Language for the\r
365 driver specified by This was returned in\r
366 DriverName.\r
367\r
15ee13fc 368 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
a3bcde70
HT
369\r
370 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid\r
371 EFI_HANDLE.\r
372\r
373 @retval EFI_INVALID_PARAMETER Language is NULL.\r
374\r
375 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
376\r
377 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
378 managing the controller specified by\r
379 ControllerHandle and ChildHandle.\r
380\r
381 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
382 the language specified by Language.\r
383\r
384**/\r
385EFI_STATUS\r
386EFIAPI\r
387Dhcp6ComponentNameGetControllerName (\r
388 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
389 IN EFI_HANDLE ControllerHandle,\r
390 IN EFI_HANDLE ChildHandle OPTIONAL,\r
391 IN CHAR8 *Language,\r
392 OUT CHAR16 **ControllerName\r
393 )\r
394{\r
216f7970 395 EFI_STATUS Status;\r
396 EFI_DHCP6_PROTOCOL *Dhcp6;\r
397\r
398 //\r
399 // Only provide names for child handles.\r
400 //\r
401 if (ChildHandle == NULL) {\r
402 return EFI_UNSUPPORTED;\r
403 }\r
f75a7f56
LG
404\r
405 //\r
406 // Make sure this driver produced ChildHandle\r
407 //\r
216f7970 408 Status = EfiTestChildHandle (\r
409 ControllerHandle,\r
f75a7f56 410 ChildHandle,\r
216f7970 411 &gEfiUdp6ProtocolGuid\r
412 );\r
413 if (EFI_ERROR (Status)) {\r
414 return Status;\r
415 }\r
416\r
417 //\r
418 // Retrieve an instance of a produced protocol from ChildHandle\r
419 //\r
420 Status = gBS->OpenProtocol (\r
421 ChildHandle,\r
422 &gEfiDhcp6ProtocolGuid,\r
f75a7f56 423 (VOID **)&Dhcp6,\r
216f7970 424 NULL,\r
425 NULL,\r
426 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
427 );\r
428 if (EFI_ERROR (Status)) {\r
429 return Status;\r
430 }\r
431\r
432 //\r
433 // Update the component name for this child handle.\r
434 //\r
435 Status = UpdateName (Dhcp6);\r
436 if (EFI_ERROR (Status)) {\r
437 return Status;\r
438 }\r
439\r
440 return LookupUnicodeString2 (\r
441 Language,\r
442 This->SupportedLanguages,\r
443 gDhcp6ControllerNameTable,\r
444 ControllerName,\r
445 (BOOLEAN)(This == &gDhcp6ComponentName)\r
446 );\r
a3bcde70 447}\r
216f7970 448\r