]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Driver.c
CommitLineData
8a67d61d 1/** @file\r
2\r
d1102dba 3Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 4SPDX-License-Identifier: BSD-2-Clause-Patent\r
8a67d61d 5\r
8a67d61d 6**/\r
7\r
8\r
9#include "Udp4Impl.h"\r
10\r
11EFI_DRIVER_BINDING_PROTOCOL gUdp4DriverBinding = {\r
12 Udp4DriverBindingSupported,\r
13 Udp4DriverBindingStart,\r
14 Udp4DriverBindingStop,\r
15 0xa,\r
16 NULL,\r
17 NULL\r
18};\r
19\r
20EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = {\r
21 Udp4ServiceBindingCreateChild,\r
22 Udp4ServiceBindingDestroyChild\r
23};\r
24\r
216f7970 25/**\r
26 Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
d1102dba 27\r
216f7970 28 @param[in] Entry The entry to be removed.\r
29 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
30\r
31 @retval EFI_SUCCESS The entry has been removed successfully.\r
32 @retval Others Fail to remove the entry.\r
33\r
34**/\r
35EFI_STATUS\r
1f7eb561 36EFIAPI\r
216f7970 37Udp4DestroyChildEntryInHandleBuffer (\r
38 IN LIST_ENTRY *Entry,\r
39 IN VOID *Context\r
1f7eb561 40 )\r
216f7970 41{\r
42 UDP4_INSTANCE_DATA *Instance;\r
43 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
44 UINTN NumberOfChildren;\r
45 EFI_HANDLE *ChildHandleBuffer;\r
46\r
47 if (Entry == NULL || Context == NULL) {\r
48 return EFI_INVALID_PARAMETER;\r
49 }\r
50\r
51 Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE);\r
52 ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;\r
53 NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;\r
54 ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;\r
55\r
56 if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {\r
57 return EFI_SUCCESS;\r
58 }\r
59\r
60 return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);\r
61}\r
62\r
8a67d61d 63\r
64/**\r
bab52709 65 Test to see if this driver supports ControllerHandle. This service\r
66 is called by the EFI boot service ConnectController(). In\r
67 order to make drivers as small as possible, there are a few calling\r
68 restrictions for this service. ConnectController() must\r
69 follow these calling restrictions. If any other agent wishes to call\r
70 Supported() it must also follow these calling restrictions.\r
71\r
3e8c18da 72 @param[in] This Protocol instance pointer.\r
73 @param[in] ControllerHandle Handle of device to test\r
74 @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
75 device to start.\r
bab52709 76\r
77 @retval EFI_SUCCESS This driver supports this device\r
78 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
79 @retval other This driver does not support this device\r
8a67d61d 80\r
81**/\r
82EFI_STATUS\r
83EFIAPI\r
84Udp4DriverBindingSupported (\r
85 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
86 IN EFI_HANDLE ControllerHandle,\r
87 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
88 )\r
89{\r
90 EFI_STATUS Status;\r
91\r
92 //\r
93 // Test for the Udp4ServiceBinding Protocol\r
94 //\r
95 Status = gBS->OpenProtocol (\r
96 ControllerHandle,\r
97 &gEfiUdp4ServiceBindingProtocolGuid,\r
98 NULL,\r
99 This->DriverBindingHandle,\r
100 ControllerHandle,\r
101 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
102 );\r
103 if (!EFI_ERROR (Status)) {\r
104 return EFI_ALREADY_STARTED;\r
105 }\r
106\r
107 //\r
108 // Test for the Ip4 Protocol\r
109 //\r
110 Status = gBS->OpenProtocol (\r
111 ControllerHandle,\r
112 &gEfiIp4ServiceBindingProtocolGuid,\r
113 NULL,\r
114 This->DriverBindingHandle,\r
115 ControllerHandle,\r
116 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
117 );\r
118\r
119 return Status;\r
120}\r
121\r
122\r
123/**\r
bab52709 124 Start this driver on ControllerHandle. This service is called by the\r
125 EFI boot service ConnectController(). In order to make\r
126 drivers as small as possible, there are a few calling restrictions for\r
127 this service. ConnectController() must follow these\r
128 calling restrictions. If any other agent wishes to call Start() it\r
129 must also follow these calling restrictions.\r
130\r
3e8c18da 131 @param[in] This Protocol instance pointer.\r
132 @param[in] ControllerHandle Handle of device to bind driver to\r
133 @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
134 device to start.\r
bab52709 135\r
136 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
137 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
138 @retval other This driver does not support this device\r
8a67d61d 139\r
140**/\r
141EFI_STATUS\r
142EFIAPI\r
143Udp4DriverBindingStart (\r
144 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
145 IN EFI_HANDLE ControllerHandle,\r
146 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
147 )\r
148{\r
149 EFI_STATUS Status;\r
150 UDP4_SERVICE_DATA *Udp4Service;\r
151\r
152 //\r
153 // Allocate Private Context Data Structure.\r
154 //\r
e48e37fc 155 Udp4Service = AllocatePool (sizeof (UDP4_SERVICE_DATA));\r
8a67d61d 156 if (Udp4Service == NULL) {\r
157 return EFI_OUT_OF_RESOURCES;\r
158 }\r
159\r
160 Status = Udp4CreateService (Udp4Service, This->DriverBindingHandle, ControllerHandle);\r
161 if (EFI_ERROR (Status)) {\r
766c7483 162 FreePool (Udp4Service);\r
c4a62a12 163 return Status;\r
8a67d61d 164 }\r
165\r
166 //\r
167 // Install the Udp4ServiceBindingProtocol on the ControllerHandle.\r
168 //\r
169 Status = gBS->InstallMultipleProtocolInterfaces (\r
170 &ControllerHandle,\r
171 &gEfiUdp4ServiceBindingProtocolGuid,\r
172 &Udp4Service->ServiceBinding,\r
173 NULL\r
174 );\r
175 if (EFI_ERROR (Status)) {\r
c4a62a12 176 Udp4CleanService (Udp4Service);\r
766c7483 177 FreePool (Udp4Service);\r
8a67d61d 178 }\r
179\r
8a67d61d 180 return Status;\r
181}\r
182\r
183\r
184/**\r
bab52709 185 Stop this driver on ControllerHandle. This service is called by the\r
186 EFI boot service DisconnectController(). In order to\r
187 make drivers as small as possible, there are a few calling\r
188 restrictions for this service. DisconnectController()\r
189 must follow these calling restrictions. If any other agent wishes\r
190 to call Stop() it must also follow these calling restrictions.\r
d1102dba 191\r
3e8c18da 192 @param[in] This Protocol instance pointer.\r
193 @param[in] ControllerHandle Handle of device to stop driver on\r
194 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
195 children is zero stop the entire bus driver.\r
196 @param[in] ChildHandleBuffer List of Child Handles to Stop.\r
bab52709 197\r
198 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
199 @retval other This driver was not removed from this device\r
8a67d61d 200\r
201**/\r
202EFI_STATUS\r
203EFIAPI\r
204Udp4DriverBindingStop (\r
205 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
206 IN EFI_HANDLE ControllerHandle,\r
207 IN UINTN NumberOfChildren,\r
208 IN EFI_HANDLE *ChildHandleBuffer\r
209 )\r
210{\r
216f7970 211 EFI_STATUS Status;\r
212 EFI_HANDLE NicHandle;\r
213 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
214 UDP4_SERVICE_DATA *Udp4Service;\r
215 UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;\r
216 LIST_ENTRY *List;\r
8a67d61d 217\r
218 //\r
219 // Find the NicHandle where UDP4 ServiceBinding Protocol is installed.\r
220 //\r
221 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid);\r
222 if (NicHandle == NULL) {\r
216f7970 223 return EFI_SUCCESS;\r
8a67d61d 224 }\r
225\r
226 //\r
227 // Retrieve the UDP4 ServiceBinding Protocol.\r
228 //\r
229 Status = gBS->OpenProtocol (\r
230 NicHandle,\r
231 &gEfiUdp4ServiceBindingProtocolGuid,\r
232 (VOID **) &ServiceBinding,\r
233 This->DriverBindingHandle,\r
234 NicHandle,\r
235 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
236 );\r
237 if (EFI_ERROR (Status)) {\r
238 return EFI_DEVICE_ERROR;\r
239 }\r
240\r
241 Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (ServiceBinding);\r
216f7970 242 if (NumberOfChildren != 0) {\r
243 //\r
244 // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.\r
245 //\r
246 List = &Udp4Service->ChildrenList;\r
247 Context.ServiceBinding = ServiceBinding;\r
248 Context.NumberOfChildren = NumberOfChildren;\r
249 Context.ChildHandleBuffer = ChildHandleBuffer;\r
250 Status = NetDestroyLinkList (\r
251 List,\r
252 Udp4DestroyChildEntryInHandleBuffer,\r
253 &Context,\r
254 NULL\r
255 );\r
256 } else {\r
c4a62a12 257 gBS->UninstallMultipleProtocolInterfaces (\r
258 NicHandle,\r
259 &gEfiUdp4ServiceBindingProtocolGuid,\r
260 &Udp4Service->ServiceBinding,\r
261 NULL\r
262 );\r
d1102dba 263\r
c4a62a12 264 Udp4CleanService (Udp4Service);\r
8a67d61d 265\r
216f7970 266 if (gUdpControllerNameTable != NULL) {\r
267 FreeUnicodeStringTable (gUdpControllerNameTable);\r
268 gUdpControllerNameTable = NULL;\r
c4a62a12 269 }\r
216f7970 270 FreePool (Udp4Service);\r
c4a62a12 271 }\r
272\r
273 return Status;\r
8a67d61d 274}\r
275\r
276\r
277/**\r
3e8c18da 278 Creates a child handle and installs a protocol.\r
d1102dba
LG
279\r
280 The CreateChild() function installs a protocol on ChildHandle.\r
281 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.\r
3e8c18da 282 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.\r
8a67d61d 283\r
47c75f64 284 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
285 @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,\r
d1102dba 286 then a new handle is created. If it is a pointer to an existing UEFI handle,\r
47c75f64 287 then the protocol is added to the existing UEFI handle.\r
8a67d61d 288\r
3e8c18da 289 @retval EFI_SUCCES The protocol was added to ChildHandle.\r
bab52709 290 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
2048c585 291 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create\r
bab52709 292 the child\r
293 @retval other The child handle was not created\r
8a67d61d 294\r
295**/\r
296EFI_STATUS\r
297EFIAPI\r
298Udp4ServiceBindingCreateChild (\r
299 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
300 IN EFI_HANDLE *ChildHandle\r
301 )\r
302{\r
303 EFI_STATUS Status;\r
304 UDP4_SERVICE_DATA *Udp4Service;\r
305 UDP4_INSTANCE_DATA *Instance;\r
306 EFI_TPL OldTpl;\r
307 VOID *Ip4;\r
308\r
309 if ((This == NULL) || (ChildHandle == NULL)) {\r
310 return EFI_INVALID_PARAMETER;\r
311 }\r
312\r
313 Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (This);\r
314\r
315 //\r
316 // Allocate the instance private data structure.\r
317 //\r
e48e37fc 318 Instance = AllocateZeroPool (sizeof (UDP4_INSTANCE_DATA));\r
8a67d61d 319 if (Instance == NULL) {\r
320 return EFI_OUT_OF_RESOURCES;\r
321 }\r
322\r
323 Udp4InitInstance (Udp4Service, Instance);\r
324\r
325 //\r
326 // Add an IpInfo for this instance.\r
327 //\r
328 Instance->IpInfo = IpIoAddIp (Udp4Service->IpIo);\r
329 if (Instance->IpInfo == NULL) {\r
330 Status = EFI_OUT_OF_RESOURCES;\r
c4a62a12 331 goto ON_ERROR;\r
8a67d61d 332 }\r
333\r
334 //\r
335 // Install the Udp4Protocol for this instance.\r
336 //\r
337 Status = gBS->InstallMultipleProtocolInterfaces (\r
338 ChildHandle,\r
339 &gEfiUdp4ProtocolGuid,\r
340 &Instance->Udp4Proto,\r
341 NULL\r
342 );\r
343 if (EFI_ERROR (Status)) {\r
c4a62a12 344 goto ON_ERROR;\r
8a67d61d 345 }\r
346\r
347 Instance->ChildHandle = *ChildHandle;\r
348\r
349 //\r
350 // Open the default Ip4 protocol in the IP_IO BY_CHILD.\r
351 //\r
352 Status = gBS->OpenProtocol (\r
353 Udp4Service->IpIo->ChildHandle,\r
354 &gEfiIp4ProtocolGuid,\r
355 (VOID **) &Ip4,\r
356 gUdp4DriverBinding.DriverBindingHandle,\r
357 Instance->ChildHandle,\r
358 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
359 );\r
360 if (EFI_ERROR (Status)) {\r
c4a62a12 361 goto ON_ERROR;\r
8a67d61d 362 }\r
363\r
216f7970 364 //\r
365 // Open this instance's Ip4 protocol in the IpInfo BY_CHILD.\r
366 //\r
367 Status = gBS->OpenProtocol (\r
368 Instance->IpInfo->ChildHandle,\r
369 &gEfiIp4ProtocolGuid,\r
370 (VOID **) &Ip4,\r
371 gUdp4DriverBinding.DriverBindingHandle,\r
372 Instance->ChildHandle,\r
373 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
374 );\r
375 if (EFI_ERROR (Status)) {\r
376 goto ON_ERROR;\r
377 }\r
378\r
e48e37fc 379 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
8a67d61d 380\r
381 //\r
382 // Link this instance into the service context data and increase the ChildrenNumber.\r
383 //\r
e48e37fc 384 InsertTailList (&Udp4Service->ChildrenList, &Instance->Link);\r
8a67d61d 385 Udp4Service->ChildrenNumber++;\r
386\r
e48e37fc 387 gBS->RestoreTPL (OldTpl);\r
8a67d61d 388\r
c4a62a12 389 return EFI_SUCCESS;\r
8a67d61d 390\r
c4a62a12 391ON_ERROR:\r
8a67d61d 392\r
c4a62a12 393 if (Instance->ChildHandle != NULL) {\r
394 gBS->UninstallMultipleProtocolInterfaces (\r
395 Instance->ChildHandle,\r
396 &gEfiUdp4ProtocolGuid,\r
397 &Instance->Udp4Proto,\r
398 NULL\r
399 );\r
400 }\r
8a67d61d 401\r
c4a62a12 402 if (Instance->IpInfo != NULL) {\r
403 IpIoRemoveIp (Udp4Service->IpIo, Instance->IpInfo);\r
404 }\r
8a67d61d 405\r
406 Udp4CleanInstance (Instance);\r
407\r
766c7483 408 FreePool (Instance);\r
8a67d61d 409\r
410 return Status;\r
411}\r
412\r
413\r
414/**\r
3e8c18da 415 Destroys a child handle with a protocol installed on it.\r
d1102dba
LG
416\r
417 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r
418 that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r
3e8c18da 419 last protocol on ChildHandle, then ChildHandle is destroyed.\r
8a67d61d 420\r
47c75f64 421 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
422 @param[in] ChildHandle Handle of the child to destroy\r
8a67d61d 423\r
3e8c18da 424 @retval EFI_SUCCES The protocol was removed from ChildHandle.\r
425 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.\r
284ee2e8 426 @retval EFI_INVALID_PARAMETER Child handle is NULL.\r
3e8c18da 427 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r
428 because its services are being used.\r
bab52709 429 @retval other The child handle was not destroyed\r
8a67d61d 430\r
431**/\r
432EFI_STATUS\r
433EFIAPI\r
434Udp4ServiceBindingDestroyChild (\r
435 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
436 IN EFI_HANDLE ChildHandle\r
437 )\r
438{\r
439 EFI_STATUS Status;\r
440 UDP4_SERVICE_DATA *Udp4Service;\r
441 EFI_UDP4_PROTOCOL *Udp4Proto;\r
442 UDP4_INSTANCE_DATA *Instance;\r
443 EFI_TPL OldTpl;\r
444\r
445 if ((This == NULL) || (ChildHandle == NULL)) {\r
446 return EFI_INVALID_PARAMETER;\r
447 }\r
448\r
449 Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (This);\r
450\r
451 //\r
452 // Try to get the Udp4 protocol from the ChildHandle.\r
453 //\r
454 Status = gBS->OpenProtocol (\r
455 ChildHandle,\r
456 &gEfiUdp4ProtocolGuid,\r
457 (VOID **) &Udp4Proto,\r
458 gUdp4DriverBinding.DriverBindingHandle,\r
459 ChildHandle,\r
460 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
461 );\r
462 if (EFI_ERROR (Status)) {\r
463 return EFI_UNSUPPORTED;\r
464 }\r
465\r
466 Instance = UDP4_INSTANCE_DATA_FROM_THIS (Udp4Proto);\r
467\r
216f7970 468 if (Instance->InDestroy) {\r
8a67d61d 469 return EFI_SUCCESS;\r
470 }\r
471\r
472 //\r
473 // Use the Destroyed flag to avoid the re-entering of the following code.\r
474 //\r
216f7970 475 Instance->InDestroy = TRUE;\r
8a67d61d 476\r
477 //\r
478 // Close the Ip4 protocol.\r
479 //\r
480 gBS->CloseProtocol (\r
481 Udp4Service->IpIo->ChildHandle,\r
482 &gEfiIp4ProtocolGuid,\r
483 gUdp4DriverBinding.DriverBindingHandle,\r
484 Instance->ChildHandle\r
485 );\r
216f7970 486 //\r
487 // Close the Ip4 protocol on this instance's IpInfo.\r
488 //\r
489 gBS->CloseProtocol (\r
490 Instance->IpInfo->ChildHandle,\r
491 &gEfiIp4ProtocolGuid,\r
492 gUdp4DriverBinding.DriverBindingHandle,\r
493 Instance->ChildHandle\r
d1102dba 494 );\r
8a67d61d 495\r
496 //\r
497 // Uninstall the Udp4Protocol previously installed on the ChildHandle.\r
498 //\r
499 Status = gBS->UninstallMultipleProtocolInterfaces (\r
500 ChildHandle,\r
501 &gEfiUdp4ProtocolGuid,\r
502 (VOID *) &Instance->Udp4Proto,\r
503 NULL\r
504 );\r
505 if (EFI_ERROR (Status)) {\r
216f7970 506 Instance->InDestroy = FALSE;\r
8a67d61d 507 return Status;\r
508 }\r
509\r
510 //\r
511 // Reset the configuration in case the instance's consumer forgets to do this.\r
512 //\r
513 Udp4Proto->Configure (Udp4Proto, NULL);\r
514\r
515 //\r
516 // Remove the IpInfo this instance consumes.\r
517 //\r
518 IpIoRemoveIp (Udp4Service->IpIo, Instance->IpInfo);\r
519\r
e48e37fc 520 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
8a67d61d 521\r
522 //\r
523 // Remove this instance from the service context data's ChildrenList.\r
524 //\r
e48e37fc 525 RemoveEntryList (&Instance->Link);\r
8a67d61d 526 Udp4Service->ChildrenNumber--;\r
527\r
528 //\r
529 // Clean the instance.\r
530 //\r
531 Udp4CleanInstance (Instance);\r
532\r
e48e37fc 533 gBS->RestoreTPL (OldTpl);\r
8a67d61d 534\r
766c7483 535 FreePool (Instance);\r
8a67d61d 536\r
537 return EFI_SUCCESS;\r
538}\r
539\r
bab52709 540/**\r
541 This is the declaration of an EFI image entry point. This entry point is\r
542 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
543 both device drivers and bus drivers.\r
d1102dba 544\r
bab52709 545 The entry point for Udp4 driver which installs the driver binding\r
546 and component name protocol on its ImageHandle.\r
547\r
3e8c18da 548 @param[in] ImageHandle The firmware allocated handle for the UEFI image.\r
549 @param[in] SystemTable A pointer to the EFI System Table.\r
bab52709 550\r
551 @retval EFI_SUCCESS The operation completed successfully.\r
552 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
8a67d61d 553\r
bab52709 554**/\r
8a67d61d 555EFI_STATUS\r
556EFIAPI\r
557Udp4DriverEntryPoint (\r
558 IN EFI_HANDLE ImageHandle,\r
559 IN EFI_SYSTEM_TABLE *SystemTable\r
560 )\r
8a67d61d 561{\r
562 EFI_STATUS Status;\r
563\r
564 //\r
565 // Install the Udp4DriverBinding and Udp4ComponentName protocols.\r
566 //\r
83cbd279 567 Status = EfiLibInstallDriverBindingComponentName2 (\r
8a67d61d 568 ImageHandle,\r
569 SystemTable,\r
570 &gUdp4DriverBinding,\r
571 ImageHandle,\r
572 &gUdp4ComponentName,\r
83cbd279 573 &gUdp4ComponentName2\r
8a67d61d 574 );\r
575 if (!EFI_ERROR (Status)) {\r
576 //\r
577 // Initialize the UDP random port.\r
578 //\r
687a2e5f 579 mUdp4RandomPort = (UINT16) (((UINT16) NetRandomInitSeed ()) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN);\r
8a67d61d 580 }\r
581\r
582 return Status;\r
583}\r
584\r