/** Detach the Pcb of the socket. @param Sk Pointer to the socket of this TCP instance. **/ VOID Tcp4DetachPcb ( IN SOCKET *Sk ) { TCP4_PROTO_DATA *ProtoData; TCP_CB *Tcb; ProtoData = (TCP4_PROTO_DATA *) Sk->ProtoReserved; Tcb = ProtoData->TcpPcb; ASSERT (Tcb != NULL); Tcp4FlushPcb (Tcb); // // Close the IP protocol. // gBS->CloseProtocol ( Tcb->IpInfo->ChildHandle, &gEfiIp4ProtocolGuid, ProtoData->TcpService->IpIo->Image, Sk->SockHandle ); IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo); FreePool (Tcb); ProtoData->TcpPcb = NULL; }
/** Attach a Pcb to the socket. @param Sk Pointer to the socket of this TCP instance. @retval EFI_SUCCESS The operation is completed successfully. @retval EFI_OUT_OF_RESOURCES Failed due to resource limit. **/ EFI_STATUS Tcp4AttachPcb ( IN SOCKET *Sk ) { TCP_CB *Tcb; TCP4_PROTO_DATA *ProtoData; IP_IO *IpIo; EFI_STATUS Status; VOID *Ip; Tcb = AllocateZeroPool (sizeof (TCP_CB)); if (Tcb == NULL) { DEBUG ((EFI_D_ERROR, "Tcp4ConfigurePcb: failed to allocate a TCB\n")); return EFI_OUT_OF_RESOURCES; } ProtoData = (TCP4_PROTO_DATA *) Sk->ProtoReserved; IpIo = ProtoData->TcpService->IpIo; // // Create an IpInfo for this Tcb. // Tcb->IpInfo = IpIoAddIp (IpIo); if (Tcb->IpInfo == NULL) { FreePool (Tcb); return EFI_OUT_OF_RESOURCES; } // // Open the new created IP instance BY_CHILD. // Status = gBS->OpenProtocol ( Tcb->IpInfo->ChildHandle, &gEfiIp4ProtocolGuid, &Ip, IpIo->Image, Sk->SockHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); if (EFI_ERROR (Status)) { IpIoRemoveIp (IpIo, Tcb->IpInfo); return Status; } InitializeListHead (&Tcb->List); InitializeListHead (&Tcb->SndQue); InitializeListHead (&Tcb->RcvQue); Tcb->State = TCP_CLOSED; Tcb->Sk = Sk; ProtoData->TcpPcb = Tcb; return EFI_SUCCESS; }
/** Detach the Pcb of the socket. @param Sk Pointer to the socket of this TCP instance. **/ VOID Tcp4DetachPcb ( IN SOCKET *Sk ) { TCP4_PROTO_DATA *ProtoData; TCP_CB *Tcb; ProtoData = (TCP4_PROTO_DATA *) Sk->ProtoReserved; Tcb = ProtoData->TcpPcb; ASSERT (Tcb != NULL); Tcp4FlushPcb (Tcb); IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo); FreePool (Tcb); ProtoData->TcpPcb = NULL; }
/** Detach the Pcb of the socket. @param[in, out] Sk Pointer to the socket of this TCP instance. **/ VOID TcpDetachPcb ( IN OUT SOCKET *Sk ) { TCP_PROTO_DATA *ProtoData; TCP_CB *Tcb; EFI_GUID *IpProtocolGuid; if (Sk->IpVersion == IP_VERSION_4) { IpProtocolGuid = &gEfiIp4ProtocolGuid; } else { IpProtocolGuid = &gEfiIp6ProtocolGuid; } ProtoData = (TCP_PROTO_DATA *) Sk->ProtoReserved; Tcb = ProtoData->TcpPcb; ASSERT (Tcb != NULL); TcpFlushPcb (Tcb); // // Close the IP protocol. // gBS->CloseProtocol ( Tcb->IpInfo->ChildHandle, IpProtocolGuid, ProtoData->TcpService->IpIo->Image, Sk->SockHandle ); IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo); FreePool (Tcb); ProtoData->TcpPcb = NULL; }