2 The driver binding and service binding protocol for the TCP driver.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
12 UINT16 mTcp4RandomPort
;
13 UINT16 mTcp6RandomPort
;
15 TCP_HEARTBEAT_TIMER mTcpTimer
= {
20 EFI_TCP4_PROTOCOL gTcp4ProtocolTemplate
= {
33 EFI_TCP6_PROTOCOL gTcp6ProtocolTemplate
= {
45 SOCK_INIT_DATA mTcpDefaultSockData
= {
54 TcpCreateSocketCallback
,
55 TcpDestroySocketCallback
,
63 EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding
= {
64 Tcp4DriverBindingSupported
,
65 Tcp4DriverBindingStart
,
66 Tcp4DriverBindingStop
,
72 EFI_DRIVER_BINDING_PROTOCOL gTcp6DriverBinding
= {
73 Tcp6DriverBindingSupported
,
74 Tcp6DriverBindingStart
,
75 Tcp6DriverBindingStop
,
81 EFI_SERVICE_BINDING_PROTOCOL gTcpServiceBinding
= {
82 TcpServiceBindingCreateChild
,
83 TcpServiceBindingDestroyChild
87 Create and start the heartbeat timer for the TCP driver.
89 @retval EFI_SUCCESS The timer was successfully created and started.
90 @retval other The timer was not created.
100 Status
= EFI_SUCCESS
;
102 if (mTcpTimer
.RefCnt
== 0) {
103 Status
= gBS
->CreateEvent (
104 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
108 &mTcpTimer
.TimerEvent
110 if (!EFI_ERROR (Status
)) {
111 Status
= gBS
->SetTimer (
112 mTcpTimer
.TimerEvent
,
114 (UINT64
)(TICKS_PER_SECOND
/ TCP_TICK_HZ
)
119 if (!EFI_ERROR (Status
)) {
127 Stop and destroy the heartbeat timer for TCP driver.
135 ASSERT (mTcpTimer
.RefCnt
> 0);
139 if (mTcpTimer
.RefCnt
> 0) {
143 gBS
->SetTimer (mTcpTimer
.TimerEvent
, TimerCancel
, 0);
144 gBS
->CloseEvent (mTcpTimer
.TimerEvent
);
145 mTcpTimer
.TimerEvent
= NULL
;
149 The entry point for Tcp driver, which is used to install Tcp driver on the ImageHandle.
151 @param[in] ImageHandle The firmware allocated handle for this driver image.
152 @param[in] SystemTable Pointer to the EFI system table.
154 @retval EFI_SUCCESS The driver loaded.
155 @retval other The driver did not load.
160 TcpDriverEntryPoint (
161 IN EFI_HANDLE ImageHandle
,
162 IN EFI_SYSTEM_TABLE
*SystemTable
169 // Install the TCP Driver Binding Protocol
171 Status
= EfiLibInstallDriverBindingComponentName2 (
179 if (EFI_ERROR (Status
)) {
184 // Install the TCP Driver Binding Protocol
186 Status
= EfiLibInstallDriverBindingComponentName2 (
194 if (EFI_ERROR (Status
)) {
195 EfiLibUninstallDriverBindingComponentName2 (
204 // Initialize ISS and random port.
206 Seed
= NetRandomInitSeed ();
207 mTcpGlobalIss
= NET_RANDOM (Seed
) % mTcpGlobalIss
;
208 mTcp4RandomPort
= (UINT16
)(TCP_PORT_KNOWN
+ (NET_RANDOM (Seed
) % TCP_PORT_KNOWN
));
209 mTcp6RandomPort
= mTcp4RandomPort
;
215 Create a new TCP4 or TCP6 driver service binding protocol
217 @param[in] Controller Controller handle of device to bind driver to.
218 @param[in] Image The TCP driver's image handle.
219 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
221 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
222 @retval EFI_SUCCESS A new IP6 service binding private was created.
227 IN EFI_HANDLE Controller
,
233 EFI_GUID
*IpServiceBindingGuid
;
234 EFI_GUID
*TcpServiceBindingGuid
;
235 TCP_SERVICE_DATA
*TcpServiceData
;
236 IP_IO_OPEN_DATA OpenData
;
238 if (IpVersion
== IP_VERSION_4
) {
239 IpServiceBindingGuid
= &gEfiIp4ServiceBindingProtocolGuid
;
240 TcpServiceBindingGuid
= &gEfiTcp4ServiceBindingProtocolGuid
;
242 IpServiceBindingGuid
= &gEfiIp6ServiceBindingProtocolGuid
;
243 TcpServiceBindingGuid
= &gEfiTcp6ServiceBindingProtocolGuid
;
246 Status
= gBS
->OpenProtocol (
248 TcpServiceBindingGuid
,
252 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
254 if (!EFI_ERROR (Status
)) {
255 return EFI_ALREADY_STARTED
;
258 Status
= gBS
->OpenProtocol (
260 IpServiceBindingGuid
,
264 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
266 if (EFI_ERROR (Status
)) {
267 return EFI_UNSUPPORTED
;
271 // Create the TCP service data.
273 TcpServiceData
= AllocateZeroPool (sizeof (TCP_SERVICE_DATA
));
274 if (TcpServiceData
== NULL
) {
275 return EFI_OUT_OF_RESOURCES
;
278 TcpServiceData
->Signature
= TCP_DRIVER_SIGNATURE
;
279 TcpServiceData
->ControllerHandle
= Controller
;
280 TcpServiceData
->DriverBindingHandle
= Image
;
281 TcpServiceData
->IpVersion
= IpVersion
;
283 &TcpServiceData
->ServiceBinding
,
285 sizeof (EFI_SERVICE_BINDING_PROTOCOL
)
288 TcpServiceData
->IpIo
= IpIoCreate (Image
, Controller
, IpVersion
);
289 if (TcpServiceData
->IpIo
== NULL
) {
290 Status
= EFI_OUT_OF_RESOURCES
;
294 InitializeListHead (&TcpServiceData
->SocketList
);
295 ZeroMem (&OpenData
, sizeof (IP_IO_OPEN_DATA
));
297 if (IpVersion
== IP_VERSION_4
) {
299 &OpenData
.IpConfigData
.Ip4CfgData
,
300 &mIp4IoDefaultIpConfigData
,
301 sizeof (EFI_IP4_CONFIG_DATA
)
303 OpenData
.IpConfigData
.Ip4CfgData
.DefaultProtocol
= EFI_IP_PROTO_TCP
;
306 &OpenData
.IpConfigData
.Ip6CfgData
,
307 &mIp6IoDefaultIpConfigData
,
308 sizeof (EFI_IP6_CONFIG_DATA
)
310 OpenData
.IpConfigData
.Ip6CfgData
.DefaultProtocol
= EFI_IP_PROTO_TCP
;
313 OpenData
.PktRcvdNotify
= TcpRxCallback
;
314 Status
= IpIoOpen (TcpServiceData
->IpIo
, &OpenData
);
315 if (EFI_ERROR (Status
)) {
319 Status
= TcpCreateTimer ();
320 if (EFI_ERROR (Status
)) {
324 Status
= gBS
->InstallMultipleProtocolInterfaces (
326 TcpServiceBindingGuid
,
327 &TcpServiceData
->ServiceBinding
,
330 if (EFI_ERROR (Status
)) {
340 if (TcpServiceData
->IpIo
!= NULL
) {
341 IpIoDestroy (TcpServiceData
->IpIo
);
342 TcpServiceData
->IpIo
= NULL
;
345 FreePool (TcpServiceData
);
351 Callback function which provided by user to remove one node in NetDestroyLinkList process.
353 @param[in] Entry The entry to be removed.
354 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
356 @retval EFI_SUCCESS The entry has been removed successfully.
357 @retval Others Fail to remove the entry.
362 TcpDestroyChildEntryInHandleBuffer (
363 IN LIST_ENTRY
*Entry
,
368 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
369 UINTN NumberOfChildren
;
370 EFI_HANDLE
*ChildHandleBuffer
;
372 if ((Entry
== NULL
) || (Context
== NULL
)) {
373 return EFI_INVALID_PARAMETER
;
376 Sock
= NET_LIST_USER_STRUCT_S (Entry
, SOCKET
, Link
, SOCK_SIGNATURE
);
377 ServiceBinding
= ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*)Context
)->ServiceBinding
;
378 NumberOfChildren
= ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*)Context
)->NumberOfChildren
;
379 ChildHandleBuffer
= ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
*)Context
)->ChildHandleBuffer
;
381 if (!NetIsInHandleBuffer (Sock
->SockHandle
, NumberOfChildren
, ChildHandleBuffer
)) {
385 return ServiceBinding
->DestroyChild (ServiceBinding
, Sock
->SockHandle
);
389 Destroy a TCP6 or TCP4 service binding instance. It will release all
390 the resources allocated by the instance.
392 @param[in] Controller Controller handle of device to bind driver to.
393 @param[in] ImageHandle The TCP driver's image handle.
394 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number
395 of children is zero stop the entire bus driver.
396 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
397 if NumberOfChildren is 0.
398 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6
400 @retval EFI_SUCCESS The resources used by the instance were cleaned up.
401 @retval Others Failed to clean up some of the resources.
406 IN EFI_HANDLE Controller
,
407 IN EFI_HANDLE ImageHandle
,
408 IN UINTN NumberOfChildren
,
409 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
,
413 EFI_HANDLE NicHandle
;
414 EFI_GUID
*IpProtocolGuid
;
415 EFI_GUID
*ServiceBindingGuid
;
416 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
417 TCP_SERVICE_DATA
*TcpServiceData
;
420 TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context
;
422 ASSERT ((IpVersion
== IP_VERSION_4
) || (IpVersion
== IP_VERSION_6
));
424 if (IpVersion
== IP_VERSION_4
) {
425 IpProtocolGuid
= &gEfiIp4ProtocolGuid
;
426 ServiceBindingGuid
= &gEfiTcp4ServiceBindingProtocolGuid
;
428 IpProtocolGuid
= &gEfiIp6ProtocolGuid
;
429 ServiceBindingGuid
= &gEfiTcp6ServiceBindingProtocolGuid
;
432 NicHandle
= NetLibGetNicHandle (Controller
, IpProtocolGuid
);
433 if (NicHandle
== NULL
) {
437 Status
= gBS
->OpenProtocol (
440 (VOID
**)&ServiceBinding
,
443 EFI_OPEN_PROTOCOL_GET_PROTOCOL
445 if (EFI_ERROR (Status
)) {
446 return EFI_DEVICE_ERROR
;
449 TcpServiceData
= TCP_SERVICE_FROM_THIS (ServiceBinding
);
451 if (NumberOfChildren
!= 0) {
452 List
= &TcpServiceData
->SocketList
;
453 Context
.ServiceBinding
= ServiceBinding
;
454 Context
.NumberOfChildren
= NumberOfChildren
;
455 Context
.ChildHandleBuffer
= ChildHandleBuffer
;
456 Status
= NetDestroyLinkList (
458 TcpDestroyChildEntryInHandleBuffer
,
462 } else if (IsListEmpty (&TcpServiceData
->SocketList
)) {
464 // Uninstall TCP servicebinding protocol
466 gBS
->UninstallMultipleProtocolInterfaces (
474 // Destroy the IpIO consumed by TCP driver
476 IpIoDestroy (TcpServiceData
->IpIo
);
477 TcpServiceData
->IpIo
= NULL
;
480 // Destroy the heartbeat timer.
485 // Release the TCP service data
487 FreePool (TcpServiceData
);
489 Status
= EFI_SUCCESS
;
496 Test to see if this driver supports ControllerHandle.
498 @param[in] This Protocol instance pointer.
499 @param[in] ControllerHandle Handle of device to test.
500 @param[in] RemainingDevicePath Optional parameter use to pick a specific
501 child device to start.
503 @retval EFI_SUCCESS This driver supports this device.
504 @retval EFI_ALREADY_STARTED This driver is already running on this device.
505 @retval other This driver does not support this device.
510 Tcp4DriverBindingSupported (
511 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
512 IN EFI_HANDLE ControllerHandle
,
513 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
519 // Test for the Tcp4ServiceBinding Protocol
521 Status
= gBS
->OpenProtocol (
523 &gEfiTcp4ServiceBindingProtocolGuid
,
525 This
->DriverBindingHandle
,
527 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
529 if (!EFI_ERROR (Status
)) {
530 return EFI_ALREADY_STARTED
;
534 // Test for the Ip4ServiceBinding Protocol
536 Status
= gBS
->OpenProtocol (
538 &gEfiIp4ServiceBindingProtocolGuid
,
540 This
->DriverBindingHandle
,
542 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
548 Start this driver on ControllerHandle.
550 @param[in] This Protocol instance pointer.
551 @param[in] ControllerHandle Handle of device to bind driver to.
552 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
555 @retval EFI_SUCCESS The driver is added to ControllerHandle.
556 @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the
558 @retval other The driver cannot be added to ControllerHandle.
563 Tcp4DriverBindingStart (
564 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
565 IN EFI_HANDLE ControllerHandle
,
566 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
571 Status
= TcpCreateService (ControllerHandle
, This
->DriverBindingHandle
, IP_VERSION_4
);
572 if ((Status
== EFI_ALREADY_STARTED
) || (Status
== EFI_UNSUPPORTED
)) {
573 Status
= EFI_SUCCESS
;
580 Stop this driver on ControllerHandle.
582 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
583 @param[in] ControllerHandle A handle to the device being stopped. The handle must
584 support a bus specific I/O protocol for the driver
585 to use to stop the device.
586 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
587 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
588 if NumberOfChildren is 0.
590 @retval EFI_SUCCESS The device was stopped.
591 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
596 Tcp4DriverBindingStop (
597 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
598 IN EFI_HANDLE ControllerHandle
,
599 IN UINTN NumberOfChildren
,
600 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
603 return TcpDestroyService (
605 This
->DriverBindingHandle
,
613 Test to see if this driver supports ControllerHandle.
615 @param[in] This Protocol instance pointer.
616 @param[in] ControllerHandle Handle of device to test.
617 @param[in] RemainingDevicePath Optional parameter use to pick a specific
618 child device to start.
620 @retval EFI_SUCCESS This driver supports this device.
621 @retval EFI_ALREADY_STARTED This driver is already running on this device.
622 @retval other This driver does not support this device.
627 Tcp6DriverBindingSupported (
628 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
629 IN EFI_HANDLE ControllerHandle
,
630 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
636 // Test for the Tcp6ServiceBinding Protocol
638 Status
= gBS
->OpenProtocol (
640 &gEfiTcp6ServiceBindingProtocolGuid
,
642 This
->DriverBindingHandle
,
644 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
646 if (!EFI_ERROR (Status
)) {
647 return EFI_ALREADY_STARTED
;
651 // Test for the Ip6ServiceBinding Protocol
653 Status
= gBS
->OpenProtocol (
655 &gEfiIp6ServiceBindingProtocolGuid
,
657 This
->DriverBindingHandle
,
659 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
665 Start this driver on ControllerHandle.
667 @param[in] This Protocol instance pointer.
668 @param[in] ControllerHandle Handle of device to bind driver to.
669 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
672 @retval EFI_SUCCESS The driver is added to ControllerHandle.
673 @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the
675 @retval other The driver cannot be added to ControllerHandle.
680 Tcp6DriverBindingStart (
681 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
682 IN EFI_HANDLE ControllerHandle
,
683 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
688 Status
= TcpCreateService (ControllerHandle
, This
->DriverBindingHandle
, IP_VERSION_6
);
689 if ((Status
== EFI_ALREADY_STARTED
) || (Status
== EFI_UNSUPPORTED
)) {
690 Status
= EFI_SUCCESS
;
697 Stop this driver on ControllerHandle.
699 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
700 @param[in] ControllerHandle A handle to the device being stopped. The handle must
701 support a bus specific I/O protocol for the driver
702 to use to stop the device.
703 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
704 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
705 if NumberOfChildren is 0.
707 @retval EFI_SUCCESS The device was stopped.
708 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
713 Tcp6DriverBindingStop (
714 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
715 IN EFI_HANDLE ControllerHandle
,
716 IN UINTN NumberOfChildren
,
717 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
720 return TcpDestroyService (
722 This
->DriverBindingHandle
,
730 The Callback function called after the TCP socket was created.
732 @param[in] This Pointer to the socket just created
733 @param[in] Context Context of the socket
735 @retval EFI_SUCCESS This protocol installed successfully.
736 @retval other An error occurred.
740 TcpCreateSocketCallback (
746 TCP_SERVICE_DATA
*TcpServiceData
;
747 EFI_GUID
*IpProtocolGuid
;
750 if (This
->IpVersion
== IP_VERSION_4
) {
751 IpProtocolGuid
= &gEfiIp4ProtocolGuid
;
753 IpProtocolGuid
= &gEfiIp6ProtocolGuid
;
756 TcpServiceData
= ((TCP_PROTO_DATA
*)This
->ProtoReserved
)->TcpService
;
759 // Open the default IP protocol of IP_IO BY_DRIVER.
761 Status
= gBS
->OpenProtocol (
762 TcpServiceData
->IpIo
->ChildHandle
,
765 TcpServiceData
->DriverBindingHandle
,
767 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
769 if (EFI_ERROR (Status
)) {
774 // Open the device path on the handle where service binding resides on.
776 Status
= gBS
->OpenProtocol (
777 TcpServiceData
->ControllerHandle
,
778 &gEfiDevicePathProtocolGuid
,
779 (VOID
**)&This
->ParentDevicePath
,
780 TcpServiceData
->DriverBindingHandle
,
782 EFI_OPEN_PROTOCOL_GET_PROTOCOL
784 if (EFI_ERROR (Status
)) {
786 TcpServiceData
->IpIo
->ChildHandle
,
788 TcpServiceData
->DriverBindingHandle
,
793 // Insert this socket into the SocketList.
795 InsertTailList (&TcpServiceData
->SocketList
, &This
->Link
);
802 The callback function called before the TCP socket was to be destroyed.
804 @param[in] This The TCP socket to be destroyed.
805 @param[in] Context The context of the socket.
809 TcpDestroySocketCallback (
814 TCP_SERVICE_DATA
*TcpServiceData
;
815 EFI_GUID
*IpProtocolGuid
;
817 if (This
->IpVersion
== IP_VERSION_4
) {
818 IpProtocolGuid
= &gEfiIp4ProtocolGuid
;
820 IpProtocolGuid
= &gEfiIp6ProtocolGuid
;
823 TcpServiceData
= ((TCP_PROTO_DATA
*)This
->ProtoReserved
)->TcpService
;
826 // Remove this node from the list.
828 RemoveEntryList (&This
->Link
);
831 // Close the IP protocol.
834 TcpServiceData
->IpIo
->ChildHandle
,
836 TcpServiceData
->DriverBindingHandle
,
842 Creates a child handle with a set of TCP services.
844 The CreateChild() function installs a protocol on ChildHandle.
845 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
846 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
848 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
849 @param[in, out] ChildHandle Pointer to the handle of the child to create.
850 If it is NULL, then a new handle is created.
851 If it is a pointer to an existing UEFI handle,
852 then the protocol is added to the existing UEFI handle.
854 @retval EFI_SUCCESS The protocol was added to ChildHandle.
855 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
856 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
858 @retval other The child handle was not created.
863 TcpServiceBindingCreateChild (
864 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
865 IN OUT EFI_HANDLE
*ChildHandle
869 TCP_SERVICE_DATA
*TcpServiceData
;
870 TCP_PROTO_DATA TcpProto
;
874 if ((NULL
== This
) || (NULL
== ChildHandle
)) {
875 return EFI_INVALID_PARAMETER
;
878 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
880 Status
= EFI_SUCCESS
;
881 TcpServiceData
= TCP_SERVICE_FROM_THIS (This
);
882 TcpProto
.TcpService
= TcpServiceData
;
883 TcpProto
.TcpPcb
= NULL
;
886 // Create a tcp instance with default Tcp default
887 // sock init data and TcpProto
889 mTcpDefaultSockData
.ProtoData
= &TcpProto
;
890 mTcpDefaultSockData
.DataSize
= sizeof (TCP_PROTO_DATA
);
891 mTcpDefaultSockData
.DriverBinding
= TcpServiceData
->DriverBindingHandle
;
892 mTcpDefaultSockData
.IpVersion
= TcpServiceData
->IpVersion
;
894 if (TcpServiceData
->IpVersion
== IP_VERSION_4
) {
895 mTcpDefaultSockData
.Protocol
= &gTcp4ProtocolTemplate
;
897 mTcpDefaultSockData
.Protocol
= &gTcp6ProtocolTemplate
;
900 Sock
= SockCreateChild (&mTcpDefaultSockData
);
904 "TcpDriverBindingCreateChild: No resource to create a Tcp Child\n")
907 Status
= EFI_OUT_OF_RESOURCES
;
909 *ChildHandle
= Sock
->SockHandle
;
912 mTcpDefaultSockData
.ProtoData
= NULL
;
914 gBS
->RestoreTPL (OldTpl
);
919 Destroys a child handle with a set of TCP services.
921 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
922 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
923 last protocol on ChildHandle, then ChildHandle is destroyed.
925 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
926 @param ChildHandle Handle of the child to be destroyed.
928 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
929 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
930 @retval EFI_INVALID_PARAMETER Child handle is NULL.
931 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
932 because its services are being used.
933 @retval other The child handle was not destroyed.
938 TcpServiceBindingDestroyChild (
939 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
940 IN EFI_HANDLE ChildHandle
947 if ((NULL
== This
) || (NULL
== ChildHandle
)) {
948 return EFI_INVALID_PARAMETER
;
952 // retrieve the Tcp4 protocol from ChildHandle
954 Status
= gBS
->OpenProtocol (
956 &gEfiTcp4ProtocolGuid
,
958 gTcp4DriverBinding
.DriverBindingHandle
,
960 EFI_OPEN_PROTOCOL_GET_PROTOCOL
962 if (EFI_ERROR (Status
)) {
964 // No Tcp4, try the Tcp6 protocol
966 Status
= gBS
->OpenProtocol (
968 &gEfiTcp6ProtocolGuid
,
970 gTcp6DriverBinding
.DriverBindingHandle
,
972 EFI_OPEN_PROTOCOL_GET_PROTOCOL
974 if (EFI_ERROR (Status
)) {
975 Status
= EFI_UNSUPPORTED
;
979 if (!EFI_ERROR (Status
)) {
981 // destroy this sock and related Tcp protocol control
984 Sock
= SOCK_FROM_THIS (Tcp
);
986 SockDestroyChild (Sock
);