]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
fixed potential NULL pointer reference issue.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / ComponentName.c
CommitLineData
8a67d61d 1/** @file\r
2\r
dfc1f033 3Copyright (c) 2005 - 2007, Intel Corporation<BR>\r
8a67d61d 4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
dfc1f033 7http://opensource.org/licenses/bsd-license.php<BR>\r
8a67d61d 8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
8a67d61d 12**/\r
13\r
14#include "Tcp4Main.h"\r
15\r
83cbd279 16/**\r
17 Retrieves a Unicode string that is the user readable name of the driver.\r
18\r
19 This function retrieves the user readable name of a driver in the form of a\r
20 Unicode string. If the driver specified by This has a user readable name in\r
21 the language specified by Language, then a pointer to the driver name is\r
22 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
23 by This does not support the language specified by Language,\r
24 then EFI_UNSUPPORTED is returned.\r
25\r
dfc1f033 26 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
83cbd279 27 EFI_COMPONENT_NAME_PROTOCOL instance.\r
28\r
dfc1f033 29 @param[in] Language A pointer to a Null-terminated ASCII string\r
83cbd279 30 array indicating the language. This is the\r
31 language of the driver name that the caller is\r
32 requesting, and it must match one of the\r
33 languages specified in SupportedLanguages. The\r
34 number of languages supported by a driver is up\r
35 to the driver writer. Language is specified\r
36 in RFC 3066 or ISO 639-2 language code format.\r
37\r
dfc1f033 38 @param[out] DriverName A pointer to the Unicode string to return.\r
83cbd279 39 This Unicode string is the name of the\r
40 driver specified by This in the language\r
41 specified by Language.\r
42\r
43 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
44 This and the language specified by Language was\r
45 returned in DriverName.\r
46\r
47 @retval EFI_INVALID_PARAMETER Language is NULL.\r
48\r
49 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
50\r
51 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
52 the language specified by Language.\r
53\r
54**/\r
8a67d61d 55EFI_STATUS\r
56EFIAPI\r
57TcpComponentNameGetDriverName (\r
dfc1f033 58 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
59 IN CHAR8 *Language,\r
60 OUT CHAR16 **DriverName\r
8a67d61d 61 );\r
62\r
83cbd279 63\r
64/**\r
65 Retrieves a Unicode string that is the user readable name of the controller\r
66 that is being managed by a driver.\r
67\r
68 This function retrieves the user readable name of the controller specified by\r
69 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
70 driver specified by This has a user readable name in the language specified by\r
71 Language, then a pointer to the controller name is returned in ControllerName,\r
72 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
73 managing the controller specified by ControllerHandle and ChildHandle,\r
74 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
75 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
76\r
dfc1f033 77 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
83cbd279 78 EFI_COMPONENT_NAME_PROTOCOL instance.\r
79\r
dfc1f033 80 @param[in] ControllerHandle The handle of a controller that the driver\r
83cbd279 81 specified by This is managing. This handle\r
82 specifies the controller whose name is to be\r
83 returned.\r
84\r
dfc1f033 85 @param[in] ChildHandle The handle of the child controller to retrieve\r
83cbd279 86 the name of. This is an optional parameter that\r
87 may be NULL. It will be NULL for device\r
88 drivers. It will also be NULL for a bus drivers\r
89 that wish to retrieve the name of the bus\r
90 controller. It will not be NULL for a bus\r
91 driver that wishes to retrieve the name of a\r
92 child controller.\r
93\r
dfc1f033 94 @param[in] Language A pointer to a Null-terminated ASCII string\r
83cbd279 95 array indicating the language. This is the\r
96 language of the driver name that the caller is\r
97 requesting, and it must match one of the\r
98 languages specified in SupportedLanguages. The\r
99 number of languages supported by a driver is up\r
100 to the driver writer. Language is specified in\r
101 RFC 3066 or ISO 639-2 language code format.\r
102\r
dfc1f033 103 @param[out] ControllerName A pointer to the Unicode string to return.\r
83cbd279 104 This Unicode string is the name of the\r
105 controller specified by ControllerHandle and\r
106 ChildHandle in the language specified by\r
107 Language from the point of view of the driver\r
108 specified by This.\r
109\r
110 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
111 the language specified by Language for the\r
112 driver specified by This was returned in\r
113 DriverName.\r
114\r
115 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
116\r
117 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
118 EFI_HANDLE.\r
119\r
120 @retval EFI_INVALID_PARAMETER Language is NULL.\r
121\r
122 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
123\r
124 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
125 managing the controller specified by\r
126 ControllerHandle and ChildHandle.\r
127\r
128 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
129 the language specified by Language.\r
130\r
131**/\r
8a67d61d 132EFI_STATUS\r
133EFIAPI\r
134TcpComponentNameGetControllerName (\r
dfc1f033 135 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
136 IN EFI_HANDLE ControllerHandle,\r
137 IN EFI_HANDLE ChildHandle OPTIONAL,\r
138 IN CHAR8 *Language,\r
139 OUT CHAR16 **ControllerName\r
8a67d61d 140 );\r
141\r
83cbd279 142\r
dfc1f033 143///\r
144/// EFI Component Name Protocol\r
145///\r
1307dcd7 146GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gTcp4ComponentName = {\r
8a67d61d 147 TcpComponentNameGetDriverName,\r
148 TcpComponentNameGetControllerName,\r
149 "eng"\r
1307dcd7 150};\r
83cbd279 151\r
dfc1f033 152///\r
153/// EFI Component Name 2 Protocol\r
154///\r
1307dcd7 155GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTcp4ComponentName2 = {\r
83cbd279 156 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) TcpComponentNameGetDriverName,\r
157 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) TcpComponentNameGetControllerName,\r
158 "en"\r
1307dcd7 159};\r
83cbd279 160\r
8a67d61d 161\r
d1aeb0bd 162GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {\r
8a67d61d 163 {\r
83cbd279 164 "eng;en",\r
8a67d61d 165 L"Tcp Network Service Driver"\r
166 },\r
167 {\r
168 NULL,\r
169 NULL\r
170 }\r
171};\r
172\r
83cbd279 173/**\r
174 Retrieves a Unicode string that is the user readable name of the driver.\r
175\r
176 This function retrieves the user readable name of a driver in the form of a\r
177 Unicode string. If the driver specified by This has a user readable name in\r
178 the language specified by Language, then a pointer to the driver name is\r
179 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
180 by This does not support the language specified by Language,\r
181 then EFI_UNSUPPORTED is returned.\r
182\r
dfc1f033 183 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
83cbd279 184 EFI_COMPONENT_NAME_PROTOCOL instance.\r
185\r
dfc1f033 186 @param[in] Language A pointer to a Null-terminated ASCII string\r
83cbd279 187 array indicating the language. This is the\r
188 language of the driver name that the caller is\r
189 requesting, and it must match one of the\r
190 languages specified in SupportedLanguages. The\r
191 number of languages supported by a driver is up\r
192 to the driver writer. Language is specified\r
193 in RFC 3066 or ISO 639-2 language code format.\r
194\r
dfc1f033 195 @param[out] DriverName A pointer to the Unicode string to return.\r
83cbd279 196 This Unicode string is the name of the\r
197 driver specified by This in the language\r
198 specified by Language.\r
199\r
200 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
201 This and the language specified by Language was\r
202 returned in DriverName.\r
203\r
204 @retval EFI_INVALID_PARAMETER Language is NULL.\r
205\r
206 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
207\r
208 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
209 the language specified by Language.\r
210\r
211**/\r
8a67d61d 212EFI_STATUS\r
213EFIAPI\r
214TcpComponentNameGetDriverName (\r
dfc1f033 215 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
216 IN CHAR8 *Language,\r
217 OUT CHAR16 **DriverName\r
8a67d61d 218 )\r
83cbd279 219{\r
220 return LookupUnicodeString2 (\r
221 Language,\r
222 This->SupportedLanguages,\r
223 mTcpDriverNameTable,\r
224 DriverName,\r
225 (BOOLEAN)(This == &gTcp4ComponentName)\r
226 );\r
227}\r
8a67d61d 228\r
83cbd279 229/**\r
230 Retrieves a Unicode string that is the user readable name of the controller\r
231 that is being managed by a driver.\r
8a67d61d 232\r
83cbd279 233 This function retrieves the user readable name of the controller specified by\r
234 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
235 driver specified by This has a user readable name in the language specified by\r
236 Language, then a pointer to the controller name is returned in ControllerName,\r
237 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
238 managing the controller specified by ControllerHandle and ChildHandle,\r
239 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
240 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
8a67d61d 241\r
dfc1f033 242 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
83cbd279 243 EFI_COMPONENT_NAME_PROTOCOL instance.\r
8a67d61d 244\r
dfc1f033 245 @param[in] ControllerHandle The handle of a controller that the driver\r
83cbd279 246 specified by This is managing. This handle\r
247 specifies the controller whose name is to be\r
248 returned.\r
8a67d61d 249\r
dfc1f033 250 @param[in] ChildHandle The handle of the child controller to retrieve\r
83cbd279 251 the name of. This is an optional parameter that\r
252 may be NULL. It will be NULL for device\r
253 drivers. It will also be NULL for a bus drivers\r
254 that wish to retrieve the name of the bus\r
255 controller. It will not be NULL for a bus\r
256 driver that wishes to retrieve the name of a\r
257 child controller.\r
8a67d61d 258\r
dfc1f033 259 @param[in] Language A pointer to a Null-terminated ASCII string\r
83cbd279 260 array indicating the language. This is the\r
261 language of the driver name that the caller is\r
262 requesting, and it must match one of the\r
263 languages specified in SupportedLanguages. The\r
264 number of languages supported by a driver is up\r
265 to the driver writer. Language is specified in\r
266 RFC 3066 or ISO 639-2 language code format.\r
8a67d61d 267\r
dfc1f033 268 @param[out] ControllerName A pointer to the Unicode string to return.\r
83cbd279 269 This Unicode string is the name of the\r
270 controller specified by ControllerHandle and\r
271 ChildHandle in the language specified by\r
272 Language from the point of view of the driver\r
273 specified by This.\r
274\r
275 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
276 the language specified by Language for the\r
277 driver specified by This was returned in\r
278 DriverName.\r
279\r
280 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
281\r
282 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
283 EFI_HANDLE.\r
284\r
285 @retval EFI_INVALID_PARAMETER Language is NULL.\r
286\r
287 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
288\r
289 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
290 managing the controller specified by\r
291 ControllerHandle and ChildHandle.\r
8a67d61d 292\r
83cbd279 293 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
294 the language specified by Language.\r
295\r
296**/\r
8a67d61d 297EFI_STATUS\r
298EFIAPI\r
299TcpComponentNameGetControllerName (\r
dfc1f033 300 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
301 IN EFI_HANDLE ControllerHandle,\r
302 IN EFI_HANDLE ChildHandle OPTIONAL,\r
303 IN CHAR8 *Language,\r
304 OUT CHAR16 **ControllerName\r
8a67d61d 305 )\r
8a67d61d 306{\r
307 return EFI_UNSUPPORTED;\r
308}\r