]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/IpSecDxe/ComponentName.c
NetworkPkg: Clean up source files
[mirror_edk2.git] / NetworkPkg / IpSecDxe / ComponentName.c
CommitLineData
a3bcde70
HT
1/** @file\r
2 UEFI Component Name(2) protocol implementation for IPsec 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 "IpSecImpl.h"\r
17\r
18//\r
19// EFI Component Name Functions\r
20//\r
21/**\r
22 Retrieves a Unicode string that is the user-readable name of the driver.\r
23\r
24 This function retrieves the user-readable name of a driver in the form of a\r
25 Unicode string. If the driver specified by This has a user-readable name in\r
26 the language specified by Language, then a pointer to the driver name is\r
27 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
28 by This does not support the language specified by Language,\r
29 then EFI_UNSUPPORTED is returned.\r
30\r
31 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
32 EFI_COMPONENT_NAME_PROTOCOL instance.\r
33\r
34 @param[in] Language A pointer to a Null-terminated ASCII string\r
35 array indicating the language. This is the\r
36 language of the driver name that the caller is\r
37 requesting, and it must match one of the\r
38 languages specified in SupportedLanguages. The\r
39 number of languages supported by a driver is up\r
40 to the driver writer. Language is specified\r
41 in RFC 4646 or ISO 639-2 language code format.\r
42\r
43 @param[out] DriverName A pointer to the Unicode string to return.\r
44 This Unicode string is the name of the\r
45 driver specified by This in the language\r
46 specified by Language.\r
47\r
48 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
49 This and the language specified by Language was\r
50 returned in DriverName.\r
51\r
52 @retval EFI_INVALID_PARAMETER Language is NULL.\r
53\r
54 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
55\r
56 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
57 the language specified by Language.\r
58\r
59**/\r
60EFI_STATUS\r
61EFIAPI\r
62IpSecComponentNameGetDriverName (\r
63 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
64 IN CHAR8 *Language,\r
65 OUT CHAR16 **DriverName\r
66 );\r
67\r
68/**\r
69 Retrieves a Unicode string that is the user-readable name of the controller\r
70 that is being managed by a driver.\r
71\r
72 This function retrieves the user-readable name of the controller specified by\r
73 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
74 driver specified by This has a user-readable name in the language specified by\r
75 Language, then a pointer to the controller name is returned in ControllerName,\r
76 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
77 managing the controller specified by ControllerHandle and ChildHandle,\r
78 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
79 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
80\r
81 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
82 EFI_COMPONENT_NAME_PROTOCOL instance.\r
83\r
84 @param[in] ControllerHandle The handle of a controller that the driver\r
85 specified by This is managing. This handle\r
86 specifies the controller whose name is to be\r
87 returned.\r
88\r
89 @param[in] ChildHandle The handle of the child controller to retrieve\r
90 the name of. This is an optional parameter that\r
91 may be NULL. It will be NULL for device\r
92 drivers. It will also be NULL for a bus drivers\r
93 that wish to retrieve the name of the bus\r
94 controller. It will not be NULL for a bus\r
95 driver that wishes to retrieve the name of a\r
96 child controller.\r
97\r
98 @param[in] Language A pointer to a Null-terminated ASCII string\r
99 array indicating the language. This is the\r
100 language of the driver name that the caller is\r
101 requesting, and it must match one of the\r
102 languages specified in SupportedLanguages. The\r
103 number of languages supported by a driver is up\r
104 to the driver writer. Language is specified in\r
105 RFC 4646 or ISO 639-2 language code format.\r
106\r
107 @param[out] ControllerName A pointer to the Unicode string to return.\r
108 This Unicode string is the name of the\r
109 controller specified by ControllerHandle and\r
110 ChildHandle in the language specified by\r
111 Language from the point of view of the driver\r
112 specified by This.\r
113\r
114 @retval EFI_SUCCESS The Unicode string for the user-readable name in\r
115 the language specified by Language for the\r
116 driver specified by This was returned in\r
117 DriverName.\r
118\r
15ee13fc 119 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
a3bcde70
HT
120\r
121 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
122 EFI_HANDLE.\r
123\r
124 @retval EFI_INVALID_PARAMETER Language is NULL.\r
125\r
126 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
127\r
128 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
129 managing the controller specified by\r
130 ControllerHandle and ChildHandle.\r
131\r
132 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
133 the language specified by Language.\r
134\r
135**/\r
136EFI_STATUS\r
137EFIAPI\r
138IpSecComponentNameGetControllerName (\r
139 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
140 IN EFI_HANDLE ControllerHandle,\r
141 IN EFI_HANDLE ChildHandle, OPTIONAL\r
142 IN CHAR8 *Language,\r
143 OUT CHAR16 **ControllerName\r
144 );\r
145\r
146//\r
147// EFI Component Name Protocol\r
148//\r
149GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIpSecComponentName = {\r
150 IpSecComponentNameGetDriverName,\r
151 IpSecComponentNameGetControllerName,\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 gIpSecComponentName2 = {\r
159 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IpSecComponentNameGetDriverName,\r
160 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IpSecComponentNameGetControllerName,\r
161 "en"\r
162};\r
163\r
164GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIpSecDriverNameTable[] = {\r
165 {\r
166 "eng;en",\r
167 L"IpSec 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 mIpSecControllerNameTable[] = {\r
176 {\r
177 "eng;en",\r
178 L"IPsec Controller"\r
179 },\r
180 {\r
181 NULL,\r
182 NULL\r
183 }\r
184};\r
185\r
a3bcde70
HT
186/**\r
187 Retrieves a Unicode string that is the user-readable name of the driver.\r
188\r
189 This function retrieves the user-readable name of a driver in the form of a\r
190 Unicode string. If the driver specified by This has a user-readable name in\r
191 the language specified by Language, then a pointer to the driver name is\r
192 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
193 by This does not support the language specified by Language,\r
194 then EFI_UNSUPPORTED is returned.\r
195\r
196 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
197 EFI_COMPONENT_NAME_PROTOCOL instance.\r
198\r
199 @param[in] Language A pointer to a Null-terminated ASCII string\r
200 array indicating the language. This is the\r
201 language of the driver name that the caller is\r
202 requesting, and it must match one of the\r
203 languages specified in SupportedLanguages. The\r
204 number of languages supported by a driver is up\r
205 to the driver writer. Language is specified\r
206 in RFC 4646 or ISO 639-2 language code format.\r
207\r
208 @param[out] DriverName A pointer to the Unicode string to return.\r
209 This Unicode string is the name of the\r
210 driver specified by This in the language\r
211 specified by Language.\r
212\r
213 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
214 This, and the language specified by Language was\r
215 returned in DriverName.\r
216\r
217 @retval EFI_INVALID_PARAMETER Language is NULL.\r
218\r
219 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
220\r
221 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
222 the language specified by Language.\r
223\r
224**/\r
225EFI_STATUS\r
226EFIAPI\r
227IpSecComponentNameGetDriverName (\r
228 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
229 IN CHAR8 *Language,\r
230 OUT CHAR16 **DriverName\r
231 )\r
232{\r
233 return LookupUnicodeString2 (\r
234 Language,\r
235 This->SupportedLanguages,\r
236 mIpSecDriverNameTable,\r
237 DriverName,\r
238 (BOOLEAN) (This == &gIpSecComponentName)\r
239 );\r
240}\r
241\r
242/**\r
243 Retrieves a Unicode string that is the user-readable name of the controller\r
244 that is being managed by a driver.\r
245\r
246 This function retrieves the user-readable name of the controller specified by\r
247 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
248 driver specified by This has a user-readable name in the language specified by\r
249 Language, then a pointer to the controller name is returned in ControllerName,\r
250 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
251 managing the controller specified by ControllerHandle and ChildHandle,\r
252 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
253 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
254\r
255 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
256 EFI_COMPONENT_NAME_PROTOCOL instance.\r
257\r
258 @param[in] ControllerHandle The handle of a controller that the driver\r
259 specified by This is managing. This handle\r
260 specifies the controller whose name is to be\r
261 returned.\r
262\r
263 @param[in] ChildHandle The handle of the child controller to retrieve\r
264 the name of. This is an optional parameter that\r
265 may be NULL. It will be NULL for device\r
266 drivers. It will also be NULL for a bus drivers\r
267 that wish to retrieve the name of the bus\r
268 controller. It will not be NULL for a bus\r
269 driver that wishes to retrieve the name of a\r
270 child controller.\r
271\r
272 @param[in] Language A pointer to a Null-terminated ASCII string\r
273 array indicating the language. This is the\r
274 language of the driver name that the caller is\r
275 requesting, and it must match one of the\r
276 languages specified in SupportedLanguages. The\r
277 number of languages supported by a driver is up\r
278 to the driver writer. Language is specified in\r
279 RFC 4646 or ISO 639-2 language code format.\r
280\r
281 @param[out] ControllerName A pointer to the Unicode string to return.\r
282 This Unicode string is the name of the\r
283 controller specified by ControllerHandle and\r
284 ChildHandle in the language specified by\r
285 Language from the point of view of the driver\r
286 specified by This.\r
287\r
288 @retval EFI_SUCCESS The Unicode string for the user-readable name in\r
289 the language specified by Language for the\r
290 driver specified by This was returned in\r
291 DriverName.\r
292\r
15ee13fc 293 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
a3bcde70
HT
294\r
295 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid\r
296 EFI_HANDLE.\r
297\r
298 @retval EFI_INVALID_PARAMETER Language is NULL.\r
299\r
300 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
301\r
302 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
303 managing the controller specified by\r
304 ControllerHandle and ChildHandle.\r
305\r
306 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
307 the language specified by Language.\r
308\r
309**/\r
310EFI_STATUS\r
311EFIAPI\r
312IpSecComponentNameGetControllerName (\r
313 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
314 IN EFI_HANDLE ControllerHandle,\r
315 IN EFI_HANDLE ChildHandle, OPTIONAL\r
316 IN CHAR8 *Language,\r
317 OUT CHAR16 **ControllerName\r
318 )\r
319{\r
216f7970 320 EFI_STATUS Status;\r
321\r
322 //\r
323 // ChildHandle must be NULL for a Device Driver\r
324 //\r
325 if (ChildHandle != NULL) {\r
326 return EFI_UNSUPPORTED;\r
327 }\r
f75a7f56 328\r
216f7970 329 //\r
330 // Make sure this driver is currently managing ControllerHandle\r
331 //\r
332 Status = gBS->OpenProtocol (\r
333 ControllerHandle,\r
334 &gEfiIpSec2ProtocolGuid,\r
335 NULL,\r
336 NULL,\r
337 NULL,\r
338 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
339 );\r
340 if (EFI_ERROR (Status)) {\r
341 return Status;\r
342 }\r
343\r
344 return LookupUnicodeString2 (\r
345 Language,\r
346 This->SupportedLanguages,\r
347 mIpSecControllerNameTable,\r
348 ControllerName,\r
349 (BOOLEAN) (This == &gIpSecComponentName)\r
350 );\r
a3bcde70 351}\r