/** @file\r
Implementation of the Socket.\r
\r
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
IN OUT SOCKET *Sock\r
)\r
{\r
- VOID *SockProtocol;\r
- EFI_GUID *TcpProtocolGuid;\r
- EFI_STATUS Status;\r
-\r
ASSERT (SockStream == Sock->Type);\r
\r
- if (Sock->DestroyCallback != NULL) {\r
- Sock->DestroyCallback (Sock, Sock->Context);\r
- }\r
-\r
//\r
// Flush the completion token buffered\r
// by sock and rcv, snd buffer\r
Sock->Parent = NULL;\r
}\r
\r
- //\r
- // Set the protocol guid and driver binding handle\r
- // in the light of Sock->SockType\r
- //\r
- if (Sock->IpVersion == IP_VERSION_4) {\r
- TcpProtocolGuid = &gEfiTcp4ProtocolGuid;\r
- } else {\r
- TcpProtocolGuid = &gEfiTcp6ProtocolGuid;\r
- }\r
-\r
- //\r
- // Retrieve the protocol installed on this sock\r
- //\r
- Status = gBS->OpenProtocol (\r
- Sock->SockHandle,\r
- TcpProtocolGuid,\r
- &SockProtocol,\r
- Sock->DriverBinding,\r
- Sock->SockHandle,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
-\r
- DEBUG (\r
- (EFI_D_ERROR,\r
- "SockDestroy: Open protocol installed on socket failed with %r\n",\r
- Status)\r
- );\r
-\r
- goto FreeSock;\r
- }\r
-\r
- //\r
- // Uninstall the protocol installed on this sock\r
- // in the light of Sock->SockType\r
- //\r
- gBS->UninstallMultipleProtocolInterfaces (\r
- Sock->SockHandle,\r
- TcpProtocolGuid,\r
- SockProtocol,\r
- NULL\r
- );\r
-\r
-FreeSock:\r
-\r
FreePool (Sock);\r
}\r
\r
/** @file\r
The function declaration that provided for Socket Interface.\r
\r
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
#define _SOCK_IMPL_H_\r
\r
#include "Socket.h"\r
+#include "TcpMain.h"\r
\r
/**\r
Signal a event with the given status.\r
/** @file\r
Interface function of the Socket.\r
\r
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
IN OUT SOCKET *Sock\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ TCP_PROTO_DATA *ProtoData;\r
+ TCP_CB *Tcb;\r
+ EFI_GUID *IpProtocolGuid;\r
+ EFI_GUID *TcpProtocolGuid;\r
+ VOID *SockProtocol;\r
\r
ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL));\r
\r
\r
Sock->InDestroy = TRUE;\r
\r
+ if (Sock->IpVersion == IP_VERSION_4) {\r
+ IpProtocolGuid = &gEfiIp4ProtocolGuid;\r
+ TcpProtocolGuid = &gEfiTcp4ProtocolGuid;\r
+ } else {\r
+ IpProtocolGuid = &gEfiIp6ProtocolGuid;\r
+ TcpProtocolGuid = &gEfiTcp6ProtocolGuid;\r
+ }\r
+ ProtoData = (TCP_PROTO_DATA *) Sock->ProtoReserved;\r
+ Tcb = ProtoData->TcpPcb;\r
+\r
+ ASSERT (Tcb != NULL);\r
+\r
Status = EfiAcquireLockOrFail (&(Sock->Lock));\r
if (EFI_ERROR (Status)) {\r
\r
return EFI_ACCESS_DENIED;\r
}\r
\r
+ //\r
+ // Close the IP protocol.\r
+ //\r
+ gBS->CloseProtocol (\r
+ Tcb->IpInfo->ChildHandle,\r
+ IpProtocolGuid,\r
+ ProtoData->TcpService->IpIo->Image,\r
+ Sock->SockHandle\r
+ );\r
+\r
+ if (Sock->DestroyCallback != NULL) {\r
+ Sock->DestroyCallback (Sock, Sock->Context);\r
+ }\r
+\r
+ //\r
+ // Retrieve the protocol installed on this sock\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Sock->SockHandle,\r
+ TcpProtocolGuid,\r
+ &SockProtocol,\r
+ Sock->DriverBinding,\r
+ Sock->SockHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+\r
+ DEBUG (\r
+ (EFI_D_ERROR,\r
+ "SockDestroyChild: Open protocol installed on socket failed with %r\n",\r
+ Status)\r
+ );\r
+ }\r
+\r
+ //\r
+ // Uninstall the protocol installed on this sock\r
+ //\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
+ Sock->SockHandle,\r
+ TcpProtocolGuid,\r
+ SockProtocol,\r
+ NULL\r
+ );\r
+\r
//\r
// force protocol layer to detach the PCB\r
//\r
{\r
SOCKET *Sock;\r
EFI_STATUS Status;\r
+ VOID *SockProtocol;\r
+ EFI_GUID *TcpProtocolGuid;\r
\r
//\r
// create a new socket\r
"SockCreateChild: Get the lock to access socket failed with %r\n",\r
Status)\r
);\r
-\r
- SockDestroy (Sock);\r
- return NULL;\r
+ goto ERROR;\r
}\r
//\r
// inform the protocol layer to attach the socket\r
"SockCreateChild: Protocol failed to attach a socket with %r\n",\r
Status)\r
);\r
-\r
- SockDestroy (Sock);\r
- Sock = NULL;\r
+ goto ERROR;\r
}\r
\r
return Sock;\r
+\r
+ERROR:\r
+\r
+ if (Sock->DestroyCallback != NULL) {\r
+ Sock->DestroyCallback (Sock, Sock->Context);\r
+ }\r
+\r
+ if (Sock->IpVersion == IP_VERSION_4) {\r
+ TcpProtocolGuid = &gEfiTcp4ProtocolGuid;\r
+ } else {\r
+ TcpProtocolGuid = &gEfiTcp6ProtocolGuid;\r
+ }\r
+\r
+ gBS->OpenProtocol (\r
+ Sock->SockHandle,\r
+ TcpProtocolGuid,\r
+ &SockProtocol,\r
+ Sock->DriverBinding,\r
+ Sock->SockHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ //\r
+ // Uninstall the protocol installed on this sock\r
+ //\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
+ Sock->SockHandle,\r
+ TcpProtocolGuid,\r
+ SockProtocol,\r
+ NULL\r
+ );\r
+ SockDestroy (Sock);\r
+ return NULL;\r
}\r
\r
/**\r
The implementation of a dispatch routine for processing TCP requests.\r
\r
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
{\r
TCP_PROTO_DATA *ProtoData;\r
TCP_CB *Tcb;\r
- EFI_GUID *IpProtocolGuid;\r
\r
- if (Sk->IpVersion == IP_VERSION_4) {\r
- IpProtocolGuid = &gEfiIp4ProtocolGuid;\r
- } else {\r
- IpProtocolGuid = &gEfiIp6ProtocolGuid;\r
- }\r
- \r
ProtoData = (TCP_PROTO_DATA *) Sk->ProtoReserved;\r
Tcb = ProtoData->TcpPcb;\r
\r
ASSERT (Tcb != NULL);\r
\r
TcpFlushPcb (Tcb);\r
-\r
- //\r
- // Close the IP protocol.\r
- //\r
- gBS->CloseProtocol (\r
- Tcb->IpInfo->ChildHandle,\r
- IpProtocolGuid,\r
- ProtoData->TcpService->IpIo->Image,\r
- Sk->SockHandle\r
- );\r
\r
IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo);\r
\r