/** 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; }
/** 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; 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; } InitializeListHead (&Tcb->List); InitializeListHead (&Tcb->SndQue); InitializeListHead (&Tcb->RcvQue); Tcb->State = TCP_CLOSED; Tcb->Sk = Sk; ProtoData->TcpPcb = Tcb; return EFI_SUCCESS; }