Udp6Driver.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /** @file
  2. Driver Binding functions and Service Binding functions for the Network driver module.
  3. Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "Udp6Impl.h"
  7. EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = {
  8. Udp6DriverBindingSupported,
  9. Udp6DriverBindingStart,
  10. Udp6DriverBindingStop,
  11. 0xa,
  12. NULL,
  13. NULL
  14. };
  15. EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding = {
  16. Udp6ServiceBindingCreateChild,
  17. Udp6ServiceBindingDestroyChild
  18. };
  19. /**
  20. Tests to see if this driver supports a given controller. If a child device is provided,
  21. it further tests to see if this driver supports creating a handle for the specified child device.
  22. This function checks to see if the driver specified by This supports the device specified by
  23. ControllerHandle. Drivers will typically use the device path attached to
  24. ControllerHandle and/or the services from the bus I/O abstraction attached to
  25. ControllerHandle to determine if the driver supports ControllerHandle. This function
  26. may be called many times during platform initialization. In order to reduce boot times, the tests
  27. performed by this function must be very small, and take as little time as possible to execute. This
  28. function must not change the state of any hardware devices, and this function must be aware that the
  29. device specified by ControllerHandle may already be managed by the same driver or a
  30. different driver. This function must match its calls to AllocatePages() with FreePages(),
  31. AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
  32. Because ControllerHandle may have been previously started by the same driver, if a protocol is
  33. already in the opened state, then it must not be closed with CloseProtocol(). This is required
  34. to guarantee the state of ControllerHandle is not modified by this function.
  35. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  36. @param[in] ControllerHandle The handle of the controller to test. This handle
  37. must support a protocol interface that supplies
  38. an I/O abstraction to the driver.
  39. @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
  40. parameter is ignored by device drivers, and is optional for bus
  41. drivers. For bus drivers, if this parameter is not NULL, then
  42. the bus driver must determine if the bus controller specified
  43. by ControllerHandle and the child controller specified
  44. by RemainingDevicePath are both supported by this
  45. bus driver.
  46. @retval EFI_SUCCESS The device specified by ControllerHandle and
  47. RemainingDevicePath is supported by the driver specified by This.
  48. @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
  49. RemainingDevicePath is already being managed by the driver
  50. specified by This.
  51. @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
  52. RemainingDevicePath is already being managed by a different
  53. driver or an application that requires exclusive access.
  54. Currently not implemented.
  55. @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
  56. RemainingDevicePath is not supported by the driver specified by This.
  57. **/
  58. EFI_STATUS
  59. EFIAPI
  60. Udp6DriverBindingSupported (
  61. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  62. IN EFI_HANDLE ControllerHandle,
  63. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  64. )
  65. {
  66. EFI_STATUS Status;
  67. //
  68. // Test for the Udp6ServiceBinding Protocol
  69. //
  70. Status = gBS->OpenProtocol (
  71. ControllerHandle,
  72. &gEfiUdp6ServiceBindingProtocolGuid,
  73. NULL,
  74. This->DriverBindingHandle,
  75. ControllerHandle,
  76. EFI_OPEN_PROTOCOL_TEST_PROTOCOL
  77. );
  78. if (!EFI_ERROR (Status)) {
  79. return EFI_ALREADY_STARTED;
  80. }
  81. //
  82. // Test for the Ip6ServiceBinding Protocol
  83. //
  84. Status = gBS->OpenProtocol (
  85. ControllerHandle,
  86. &gEfiIp6ServiceBindingProtocolGuid,
  87. NULL,
  88. This->DriverBindingHandle,
  89. ControllerHandle,
  90. EFI_OPEN_PROTOCOL_TEST_PROTOCOL
  91. );
  92. return Status;
  93. }
  94. /**
  95. Start this driver on ControllerHandle.
  96. This service is called by the EFI boot service ConnectController(). In order to make
  97. drivers as small as possible, there are a few calling restrictions for
  98. this service. ConnectController() must follow these
  99. calling restrictions. If any other agent wishes to call Start() it
  100. must also follow these calling restrictions.
  101. @param[in] This Protocol instance pointer.
  102. @param[in] ControllerHandle Handle of device to bind the driver to.
  103. @param[in] RemainingDevicePath Optional parameter use to pick a specific child
  104. device to start.
  105. @retval EFI_SUCCESS This driver is added to ControllerHandle.
  106. @retval EFI_OUT_OF_RESOURCES The required system resource can't be allocated.
  107. @retval other This driver does not support this device.
  108. **/
  109. EFI_STATUS
  110. EFIAPI
  111. Udp6DriverBindingStart (
  112. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  113. IN EFI_HANDLE ControllerHandle,
  114. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  115. )
  116. {
  117. EFI_STATUS Status;
  118. UDP6_SERVICE_DATA *Udp6Service;
  119. //
  120. // Allocate Private Context Data Structure.
  121. //
  122. Udp6Service = AllocateZeroPool (sizeof (UDP6_SERVICE_DATA));
  123. if (Udp6Service == NULL) {
  124. Status = EFI_OUT_OF_RESOURCES;
  125. goto EXIT;
  126. }
  127. Status = Udp6CreateService (Udp6Service, This->DriverBindingHandle, ControllerHandle);
  128. if (EFI_ERROR (Status)) {
  129. goto EXIT;
  130. }
  131. //
  132. // Install the Udp6ServiceBindingProtocol on the ControllerHandle.
  133. //
  134. Status = gBS->InstallMultipleProtocolInterfaces (
  135. &ControllerHandle,
  136. &gEfiUdp6ServiceBindingProtocolGuid,
  137. &Udp6Service->ServiceBinding,
  138. NULL
  139. );
  140. if (EFI_ERROR (Status)) {
  141. Udp6CleanService (Udp6Service);
  142. }
  143. EXIT:
  144. if (EFI_ERROR (Status)) {
  145. if (Udp6Service != NULL) {
  146. FreePool (Udp6Service);
  147. }
  148. }
  149. return Status;
  150. }
  151. /**
  152. Callback function which provided by user to remove one node in NetDestroyLinkList process.
  153. @param[in] Entry The entry to be removed.
  154. @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
  155. @retval EFI_INVALID_PARAMETER Entry is NULL or Context is NULL.
  156. @retval EFI_SUCCESS The entry has been removed successfully.
  157. @retval Others Fail to remove the entry.
  158. **/
  159. EFI_STATUS
  160. EFIAPI
  161. Udp6DestroyChildEntryInHandleBuffer (
  162. IN LIST_ENTRY *Entry,
  163. IN VOID *Context
  164. )
  165. {
  166. UDP6_INSTANCE_DATA *Instance;
  167. EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
  168. UINTN NumberOfChildren;
  169. EFI_HANDLE *ChildHandleBuffer;
  170. if ((Entry == NULL) || (Context == NULL)) {
  171. return EFI_INVALID_PARAMETER;
  172. }
  173. Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE);
  174. ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
  175. NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
  176. ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
  177. if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
  178. return EFI_SUCCESS;
  179. }
  180. return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
  181. }
  182. /**
  183. Stop this driver on ControllerHandle.
  184. This service is called by the EFI boot service DisconnectController(). In order to
  185. make drivers as small as possible, there are a few calling
  186. restrictions for this service. DisconnectController()
  187. must follow these calling restrictions. If any other agent wishes
  188. to call Stop(), it must also follow these calling restrictions.
  189. @param[in] This Protocol instance pointer.
  190. @param[in] ControllerHandle Handle of device to stop the driver on.
  191. @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number
  192. of children is zero stop the entire bus driver.
  193. @param[in] ChildHandleBuffer List of Child Handles to Stop. It is optional.
  194. @retval EFI_SUCCESS This driver is removed ControllerHandle.
  195. @retval EFI_DEVICE_ERROR Can't find the NicHandle from the ControllerHandle and specified GUID.
  196. @retval other This driver was not removed from this device.
  197. **/
  198. EFI_STATUS
  199. EFIAPI
  200. Udp6DriverBindingStop (
  201. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  202. IN EFI_HANDLE ControllerHandle,
  203. IN UINTN NumberOfChildren,
  204. IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
  205. )
  206. {
  207. EFI_STATUS Status;
  208. EFI_HANDLE NicHandle;
  209. EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
  210. UDP6_SERVICE_DATA *Udp6Service;
  211. LIST_ENTRY *List;
  212. UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
  213. //
  214. // Find the NicHandle where UDP6 ServiceBinding Protocol is installed.
  215. //
  216. NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);
  217. if (NicHandle == NULL) {
  218. return EFI_SUCCESS;
  219. }
  220. //
  221. // Retrieve the UDP6 ServiceBinding Protocol.
  222. //
  223. Status = gBS->OpenProtocol (
  224. NicHandle,
  225. &gEfiUdp6ServiceBindingProtocolGuid,
  226. (VOID **)&ServiceBinding,
  227. This->DriverBindingHandle,
  228. NicHandle,
  229. EFI_OPEN_PROTOCOL_GET_PROTOCOL
  230. );
  231. if (EFI_ERROR (Status)) {
  232. return EFI_DEVICE_ERROR;
  233. }
  234. Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (ServiceBinding);
  235. if (NumberOfChildren != 0) {
  236. //
  237. // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.
  238. //
  239. List = &Udp6Service->ChildrenList;
  240. Context.ServiceBinding = ServiceBinding;
  241. Context.NumberOfChildren = NumberOfChildren;
  242. Context.ChildHandleBuffer = ChildHandleBuffer;
  243. Status = NetDestroyLinkList (
  244. List,
  245. Udp6DestroyChildEntryInHandleBuffer,
  246. &Context,
  247. NULL
  248. );
  249. } else if (IsListEmpty (&Udp6Service->ChildrenList)) {
  250. Status = gBS->UninstallMultipleProtocolInterfaces (
  251. NicHandle,
  252. &gEfiUdp6ServiceBindingProtocolGuid,
  253. &Udp6Service->ServiceBinding,
  254. NULL
  255. );
  256. Udp6CleanService (Udp6Service);
  257. FreePool (Udp6Service);
  258. }
  259. return Status;
  260. }
  261. /**
  262. Creates a child handle and installs a protocol.
  263. The CreateChild() function installs a protocol on ChildHandle.
  264. If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
  265. If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
  266. @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
  267. @param[in, out] ChildHandle Pointer to the handle of the child to create. If it is NULL,
  268. then a new handle is created. If it is a pointer to an existing UEFI handle,
  269. then the protocol is added to the existing UEFI handle.
  270. @retval EFI_SUCCESS The protocol was added to ChildHandle.
  271. @retval EFI_INVALID_PARAMETER This is NULL or ChildHandle is NULL.
  272. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
  273. the child.
  274. @retval other The child handle was not created.
  275. **/
  276. EFI_STATUS
  277. EFIAPI
  278. Udp6ServiceBindingCreateChild (
  279. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  280. IN OUT EFI_HANDLE *ChildHandle
  281. )
  282. {
  283. EFI_STATUS Status;
  284. UDP6_SERVICE_DATA *Udp6Service;
  285. UDP6_INSTANCE_DATA *Instance;
  286. EFI_TPL OldTpl;
  287. VOID *Ip6;
  288. if ((This == NULL) || (ChildHandle == NULL)) {
  289. return EFI_INVALID_PARAMETER;
  290. }
  291. Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (This);
  292. //
  293. // Allocate the instance private data structure.
  294. //
  295. Instance = AllocateZeroPool (sizeof (UDP6_INSTANCE_DATA));
  296. if (Instance == NULL) {
  297. return EFI_OUT_OF_RESOURCES;
  298. }
  299. Udp6InitInstance (Udp6Service, Instance);
  300. //
  301. // Add an IpInfo for this instance.
  302. //
  303. Instance->IpInfo = IpIoAddIp (Udp6Service->IpIo);
  304. if (Instance->IpInfo == NULL) {
  305. Status = EFI_OUT_OF_RESOURCES;
  306. goto ON_ERROR;
  307. }
  308. //
  309. // Install the Udp6Protocol for this instance.
  310. //
  311. Status = gBS->InstallMultipleProtocolInterfaces (
  312. ChildHandle,
  313. &gEfiUdp6ProtocolGuid,
  314. &Instance->Udp6Proto,
  315. NULL
  316. );
  317. if (EFI_ERROR (Status)) {
  318. goto ON_ERROR;
  319. }
  320. Instance->ChildHandle = *ChildHandle;
  321. //
  322. // Open the default Ip6 protocol in the IP_IO BY_CHILD.
  323. //
  324. Status = gBS->OpenProtocol (
  325. Udp6Service->IpIo->ChildHandle,
  326. &gEfiIp6ProtocolGuid,
  327. (VOID **)&Ip6,
  328. gUdp6DriverBinding.DriverBindingHandle,
  329. Instance->ChildHandle,
  330. EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
  331. );
  332. if (EFI_ERROR (Status)) {
  333. goto ON_ERROR;
  334. }
  335. //
  336. // Open this instance's Ip6 protocol in the IpInfo BY_CHILD.
  337. //
  338. Status = gBS->OpenProtocol (
  339. Instance->IpInfo->ChildHandle,
  340. &gEfiIp6ProtocolGuid,
  341. (VOID **)&Ip6,
  342. gUdp6DriverBinding.DriverBindingHandle,
  343. Instance->ChildHandle,
  344. EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
  345. );
  346. if (EFI_ERROR (Status)) {
  347. goto ON_ERROR;
  348. }
  349. OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  350. //
  351. // Link this instance into the service context data and increase the ChildrenNumber.
  352. //
  353. InsertTailList (&Udp6Service->ChildrenList, &Instance->Link);
  354. Udp6Service->ChildrenNumber++;
  355. gBS->RestoreTPL (OldTpl);
  356. return EFI_SUCCESS;
  357. ON_ERROR:
  358. if (Instance->ChildHandle != NULL) {
  359. gBS->UninstallMultipleProtocolInterfaces (
  360. Instance->ChildHandle,
  361. &gEfiUdp6ProtocolGuid,
  362. &Instance->Udp6Proto,
  363. NULL
  364. );
  365. }
  366. if (Instance->IpInfo != NULL) {
  367. IpIoRemoveIp (Udp6Service->IpIo, Instance->IpInfo);
  368. }
  369. Udp6CleanInstance (Instance);
  370. FreePool (Instance);
  371. return Status;
  372. }
  373. /**
  374. Destroys a child handle with a set of I/O services.
  375. The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
  376. that was installed by CreateChild() from ChildHandle. If the removed protocol is the
  377. last protocol on ChildHandle, then ChildHandle is destroyed.
  378. @param[in] This Protocol instance pointer.
  379. @param[in] ChildHandle Handle of the child to destroy.
  380. @retval EFI_SUCCESS The I/O services were removed from the child
  381. handle.
  382. @retval EFI_UNSUPPORTED The child handle does not support the I/O services
  383. that are being removed.
  384. @retval EFI_INVALID_PARAMETER Child handle is NULL.
  385. @retval EFI_ACCESS_DENIED The child handle could not be destroyed because
  386. its I/O services are being used.
  387. @retval other The child handle was not destroyed.
  388. **/
  389. EFI_STATUS
  390. EFIAPI
  391. Udp6ServiceBindingDestroyChild (
  392. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  393. IN EFI_HANDLE ChildHandle
  394. )
  395. {
  396. EFI_STATUS Status;
  397. UDP6_SERVICE_DATA *Udp6Service;
  398. EFI_UDP6_PROTOCOL *Udp6Proto;
  399. UDP6_INSTANCE_DATA *Instance;
  400. EFI_TPL OldTpl;
  401. if ((This == NULL) || (ChildHandle == NULL)) {
  402. return EFI_INVALID_PARAMETER;
  403. }
  404. Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (This);
  405. //
  406. // Try to get the Udp6 protocol from the ChildHandle.
  407. //
  408. Status = gBS->OpenProtocol (
  409. ChildHandle,
  410. &gEfiUdp6ProtocolGuid,
  411. (VOID **)&Udp6Proto,
  412. gUdp6DriverBinding.DriverBindingHandle,
  413. ChildHandle,
  414. EFI_OPEN_PROTOCOL_GET_PROTOCOL
  415. );
  416. if (EFI_ERROR (Status)) {
  417. return EFI_UNSUPPORTED;
  418. }
  419. Instance = UDP6_INSTANCE_DATA_FROM_THIS (Udp6Proto);
  420. if (Instance->InDestroy) {
  421. return EFI_SUCCESS;
  422. }
  423. //
  424. // Use the Destroyed flag to avoid the re-entering of the following code.
  425. //
  426. Instance->InDestroy = TRUE;
  427. //
  428. // Close the Ip6 protocol on the default IpIo.
  429. //
  430. Status = gBS->CloseProtocol (
  431. Udp6Service->IpIo->ChildHandle,
  432. &gEfiIp6ProtocolGuid,
  433. gUdp6DriverBinding.DriverBindingHandle,
  434. Instance->ChildHandle
  435. );
  436. if (EFI_ERROR (Status)) {
  437. Instance->InDestroy = FALSE;
  438. return Status;
  439. }
  440. //
  441. // Close the Ip6 protocol on this instance's IpInfo.
  442. //
  443. Status = gBS->CloseProtocol (
  444. Instance->IpInfo->ChildHandle,
  445. &gEfiIp6ProtocolGuid,
  446. gUdp6DriverBinding.DriverBindingHandle,
  447. Instance->ChildHandle
  448. );
  449. if (EFI_ERROR (Status)) {
  450. Instance->InDestroy = FALSE;
  451. return Status;
  452. }
  453. //
  454. // Uninstall the Udp6Protocol previously installed on the ChildHandle.
  455. //
  456. Status = gBS->UninstallMultipleProtocolInterfaces (
  457. ChildHandle,
  458. &gEfiUdp6ProtocolGuid,
  459. (VOID *)&Instance->Udp6Proto,
  460. NULL
  461. );
  462. if (EFI_ERROR (Status)) {
  463. Instance->InDestroy = FALSE;
  464. return Status;
  465. }
  466. //
  467. // Reset the configuration in case the instance's consumer forgets to do this.
  468. //
  469. Udp6Proto->Configure (Udp6Proto, NULL);
  470. //
  471. // Remove the IpInfo this instance consumes.
  472. //
  473. IpIoRemoveIp (Udp6Service->IpIo, Instance->IpInfo);
  474. OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  475. //
  476. // Remove this instance from the service context data's ChildrenList.
  477. //
  478. RemoveEntryList (&Instance->Link);
  479. Udp6Service->ChildrenNumber--;
  480. //
  481. // Clean the instance.
  482. //
  483. Udp6CleanInstance (Instance);
  484. gBS->RestoreTPL (OldTpl);
  485. FreePool (Instance);
  486. return EFI_SUCCESS;
  487. }
  488. /**
  489. This is the declaration of an EFI image entry point. This entry point is
  490. the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, including
  491. both device drivers and bus drivers.
  492. The entry point for Udp6 driver that installs the driver binding
  493. and component name protocol on its ImageHandle.
  494. @param[in] ImageHandle The firmware allocated handle for the UEFI image.
  495. @param[in] SystemTable A pointer to the EFI System Table.
  496. @retval EFI_SUCCESS The operation completed successfully.
  497. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
  498. **/
  499. EFI_STATUS
  500. EFIAPI
  501. Udp6DriverEntryPoint (
  502. IN EFI_HANDLE ImageHandle,
  503. IN EFI_SYSTEM_TABLE *SystemTable
  504. )
  505. {
  506. EFI_STATUS Status;
  507. //
  508. // Install the Udp6DriverBinding and Udp6ComponentName protocols.
  509. //
  510. Status = EfiLibInstallDriverBindingComponentName2 (
  511. ImageHandle,
  512. SystemTable,
  513. &gUdp6DriverBinding,
  514. ImageHandle,
  515. &gUdp6ComponentName,
  516. &gUdp6ComponentName2
  517. );
  518. if (!EFI_ERROR (Status)) {
  519. //
  520. // Initialize the UDP random port.
  521. //
  522. mUdp6RandomPort = (UINT16)(
  523. ((UINT16)NetRandomInitSeed ()) %
  524. UDP6_PORT_KNOWN +
  525. UDP6_PORT_KNOWN
  526. );
  527. }
  528. return Status;
  529. }