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