41 return EFI_OUT_OF_RESOURCES;
52 Ack->
Ack.
Block[0] = HTONS (BlockNum);
57 Instance->CurRetry = 0;
58 Instance->LastPacket = Packet;
61 if (!EFI_ERROR (Status)) {
62 Instance->AckedBlock = Instance->TotalBlock;
101 Token = Instance->Token;
102 Block = NTOHS (Packet->Data.Block);
103 DataLen = Len - MTFTP6_DATA_HEAD_LEN;
108 if (DataLen < Instance->BlkSize) {
110 Instance->LastBlk = Block;
123 if (Status == EFI_NOT_FOUND) {
125 }
else if (EFI_ERROR (Status)) {
133 Status = Token->
CheckPacket (&Instance->Mtftp6, Token, (UINT16)Len, Packet);
135 if (EFI_ERROR (Status)) {
148 (UINT8 *)
"User aborted download"
156 Start =
MultU64x32 (BlockCounter - 1, Instance->BlkSize);
157 if (Start + DataLen <= Token->BufferSize) {
158 CopyMem ((UINT8 *)Token->
Buffer + Start, Packet->Data.Data, DataLen);
162 if ((Instance->LastBlk == Block) && Completed) {
165 }
else if (Instance->LastBlk != 0) {
185 (UINT8 *)
"User provided memory block is too small"
188 return EFI_BUFFER_TOO_SMALL;
217 OUT BOOLEAN *IsCompleted
224 *IsCompleted =
FALSE;
226 BlockNum = NTOHS (Packet->Data.Block);
229 ASSERT (Expected >= 0);
236 if (Instance->IsMaster && (Expected != BlockNum)) {
252 if (EFI_ERROR (Status)) {
259 Instance->TotalBlock++;
264 if (!Instance->IsMaster) {
265 Instance->PacketToLive = Instance->Timeout * 2;
276 if (Instance->IsMaster || (Expected < 0)) {
284 BlockNum = Instance->LastBlk;
287 BlockNum = (UINT16)(Expected - 1);
297 if ((Instance->WindowSize == (Instance->TotalBlock - Instance->AckedBlock)) || (Expected < 0)) {
331 if ((ReplyInfo->BitMap & ~RequestInfo->BitMap) != 0) {
339 if ((((ReplyInfo->BitMap & MTFTP6_OPT_BLKSIZE_BIT) != 0) && (ReplyInfo->BlkSize > RequestInfo->BlkSize)) ||
340 (((ReplyInfo->BitMap & MTFTP6_OPT_WINDOWSIZE_BIT) != 0) && (ReplyInfo->BlkSize > RequestInfo->BlkSize)) ||
341 (((ReplyInfo->BitMap & MTFTP6_OPT_TIMEOUT_BIT) != 0) && (ReplyInfo->Timeout != RequestInfo->Timeout))
362 if ((ReplyInfo->McastPort != 0) && (ReplyInfo->McastPort != Instance->McastPort)) {
393 Udp6 = McastIo->Protocol.Udp6;
394 Udp6Cfg = &(McastIo->Config.Udp6);
421 Status = Udp6->Configure (Udp6, Udp6Cfg);
423 if (EFI_ERROR (Status)) {
432 return Udp6->Groups (Udp6,
TRUE, &Group);
456 OUT BOOLEAN *IsCompleted
466 *IsCompleted =
FALSE;
474 ASSERT (Expected != -1);
476 if (Instance->IsMaster && (Expected != 1)) {
487 if (EFI_ERROR (Status)) {
491 ASSERT (Options !=
NULL);
498 if (EFI_ERROR (Status) || !
Mtftp6RrqOackValid (Instance, &ExtInfo, &Instance->ExtInfo)) {
502 if (Status != EFI_OUT_OF_RESOURCES) {
515 (UINT8 *)
"Malformatted OACK packet"
519 return EFI_TFTP_ERROR;
522 if ((ExtInfo.BitMap & MTFTP6_OPT_MCAST_BIT) != 0) {
528 Instance->IsMaster = ExtInfo.IsMaster;
544 (UINT8 *)
"Illegal multicast setting"
547 return EFI_TFTP_ERROR;
559 Instance->McastPort = ExtInfo.McastPort;
560 if (Instance->McastUdpIo ==
NULL) {
562 Instance->Service->Controller,
563 Instance->Service->Image,
568 if (Instance->McastUdpIo !=
NULL) {
569 Status =
gBS->OpenProtocol (
570 Instance->McastUdpIo->UdpHandle,
571 &gEfiUdp6ProtocolGuid,
573 Instance->Service->Image,
575 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
577 if (EFI_ERROR (Status)) {
579 Instance->McastUdpIo =
NULL;
580 return EFI_DEVICE_ERROR;
585 if (Instance->McastUdpIo ==
NULL) {
586 return EFI_DEVICE_ERROR;
590 Instance->McastUdpIo,
596 if (EFI_ERROR (Status)) {
609 (UINT8 *)
"Failed to create socket to receive multicast packet"
618 if (ExtInfo.BlkSize != 0) {
619 Instance->BlkSize = ExtInfo.BlkSize;
622 if (ExtInfo.WindowSize != 0) {
623 Instance->WindowSize = ExtInfo.WindowSize;
626 if (ExtInfo.Timeout != 0) {
627 Instance->Timeout = ExtInfo.Timeout;
631 Instance->IsMaster =
TRUE;
633 if (ExtInfo.BlkSize != 0) {
634 Instance->BlkSize = ExtInfo.BlkSize;
637 if (ExtInfo.WindowSize != 0) {
638 Instance->WindowSize = ExtInfo.WindowSize;
641 if (ExtInfo.Timeout != 0) {
642 Instance->Timeout = ExtInfo.Timeout;
688 NET_CHECK_SIGNATURE (Instance, MTFTP6_INSTANCE_SIGNATURE);
699 if (EFI_ERROR (IoStatus)) {
704 ASSERT (UdpPacket !=
NULL);
706 if (UdpPacket->TotalSize < MTFTP6_OPCODE_LEN) {
730 if (UdpEpt->RemotePort != Instance->ServerDataPort) {
731 if (Instance->ServerDataPort != 0) {
740 Instance->ServerDataPort = UdpEpt->RemotePort;
747 Len = UdpPacket->TotalSize;
748 TotalNum = UdpPacket->BlockOpNum;
753 if (Packet ==
NULL) {
754 Status = EFI_OUT_OF_RESOURCES;
758 NetbufCopy (UdpPacket, 0, Len, (UINT8 *)Packet);
761 ASSERT (Packet !=
NULL);
764 Opcode = NTOHS (Packet->
OpCode);
781 if (EFI_ERROR (Status)) {
798 (UINT8 *)
"User aborted the transfer"
802 Status = EFI_ABORTED;
812 if ((Len > (UINT32)(MTFTP6_DATA_HEAD_LEN + Instance->BlkSize)) || (Len < (UINT32)MTFTP6_DATA_HEAD_LEN)) {
829 if (IsMcast || (Len <= MTFTP6_OPCODE_LEN)) {
849 Status = EFI_TFTP_ERROR;
858 if ((Packet !=
NULL) && (TotalNum > 1)) {
862 if (UdpPacket !=
NULL) {
866 if (!EFI_ERROR (Status) && !IsCompleted) {
869 Instance->McastUdpIo,
887 if (EFI_ERROR (Status) || IsCompleted) {
920 if (EFI_ERROR (Status)) {
926 if (EFI_ERROR (Status)) {
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define EFI_MTFTP6_OPCODE_ERROR
The MTFTPv6 packet is an error packet.
#define EFI_MTFTP6_OPCODE_OACK
The MTFTPv6 packet is an option acknowledgement packet.
#define EFI_MTFTP6_ERRORCODE_ACCESS_VIOLATION
#define EFI_MTFTP6_ERRORCODE_DISK_FULL
#define EFI_MTFTP6_OPCODE_ACK
The MTFTPv6 packet is an acknowledgement packet.
#define EFI_MTFTP6_ERRORCODE_REQUEST_DENIED
#define EFI_MTFTP6_OPCODE_DATA
The MTFTPv6 packet is a data packet.
#define EFI_MTFTP6_ERRORCODE_ILLEGAL_OPERATION
EFI_STATUS Mtftp6ParseExtensionOption(IN EFI_MTFTP6_OPTION *Options, IN UINT32 Count, IN BOOLEAN IsRequest, IN UINT16 Operation, IN MTFTP6_EXT_OPTION_INFO *ExtInfo)
EFI_STATUS Mtftp6ParseStart(IN EFI_MTFTP6_PACKET *Packet, IN UINT32 PacketLen, IN OUT UINT32 *OptionCount, OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL)
EFI_STATUS Mtftp6RrqStart(IN MTFTP6_INSTANCE *Instance, IN UINT16 Operation)
EFI_STATUS Mtftp6RrqSaveBlock(IN MTFTP6_INSTANCE *Instance, IN EFI_MTFTP6_PACKET *Packet, IN UINT32 Len, OUT NET_BUF **UdpPacket)
BOOLEAN Mtftp6RrqOackValid(IN MTFTP6_INSTANCE *Instance, IN MTFTP6_EXT_OPTION_INFO *ReplyInfo, IN MTFTP6_EXT_OPTION_INFO *RequestInfo)
VOID EFIAPI Mtftp6RrqInput(IN NET_BUF *UdpPacket, IN UDP_END_POINT *UdpEpt, IN EFI_STATUS IoStatus, IN VOID *Context)
EFI_STATUS Mtftp6RrqHandleOack(IN MTFTP6_INSTANCE *Instance, IN EFI_MTFTP6_PACKET *Packet, IN UINT32 Len, OUT NET_BUF **UdpPacket, OUT BOOLEAN *IsCompleted)
EFI_STATUS EFIAPI Mtftp6RrqConfigMcastUdpIo(IN UDP_IO *McastIo, IN VOID *Context)
EFI_STATUS Mtftp6RrqHandleData(IN MTFTP6_INSTANCE *Instance, IN EFI_MTFTP6_PACKET *Packet, IN UINT32 Len, OUT NET_BUF **UdpPacket, OUT BOOLEAN *IsCompleted)
EFI_STATUS Mtftp6RrqSendAck(IN MTFTP6_INSTANCE *Instance, IN UINT16 BlockNum)
EFI_STATUS Mtftp6RemoveBlockNum(IN LIST_ENTRY *Head, IN UINT16 Num, IN BOOLEAN Completed, OUT UINT64 *BlockCounter)
EFI_STATUS Mtftp6SendError(IN MTFTP6_INSTANCE *Instance, IN UINT16 ErrCode, IN UINT8 *ErrInfo)
EFI_STATUS Mtftp6TransmitPacket(IN MTFTP6_INSTANCE *Instance, IN NET_BUF *Packet)
EFI_STATUS Mtftp6SendRequest(IN MTFTP6_INSTANCE *Instance, IN UINT16 Operation)
INTN Mtftp6GetNextBlockNum(IN LIST_ENTRY *Head)
EFI_STATUS Mtftp6InitBlockRange(IN LIST_ENTRY *Head, IN UINT16 Start, IN UINT16 End)
VOID Mtftp6SetLastBlockNum(IN LIST_ENTRY *Head, IN UINT16 Last)
VOID Mtftp6OperationClean(IN MTFTP6_INSTANCE *Instance, IN EFI_STATUS Result)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
EFI_IPv6_ADDRESS *EFIAPI Ip6Swap128(EFI_IPv6_ADDRESS *Ip6)
NET_BUF *EFIAPI NetbufAlloc(IN UINT32 Len)
BOOLEAN EFIAPI NetIp6IsUnspecifiedAddr(IN EFI_IPv6_ADDRESS *Ip6)
UINT8 *EFIAPI NetbufAllocSpace(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
UINT8 *EFIAPI NetbufGetByte(IN NET_BUF *Nbuf, IN UINT32 Offset, OUT UINT32 *Index OPTIONAL)
EFI_STATUS EFIAPI UdpIoRecvDatagram(IN UDP_IO *UdpIo, IN UDP_IO_CALLBACK CallBack, IN VOID *Context, IN UINT32 HeadLen)
EFI_STATUS EFIAPI UdpIoFreeIo(IN UDP_IO *UdpIo)
UDP_IO *EFIAPI UdpIoCreateIo(IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle, IN UDP_IO_CONFIG Configure, IN UINT8 UdpVersion, IN VOID *Context)
EFI_MTFTP6_CHECK_PACKET CheckPacket
BOOLEAN AcceptPromiscuous
BOOLEAN AllowDuplicatePort
EFI_IPv6_ADDRESS RemoteAddress
EFI_MTFTP6_ACK_HEADER Ack
Acknowledgement packet header.
UINT16 OpCode
Type of packets as defined by the MTFTPv6 packet opcodes.