40 UdpPacket =
NetbufAlloc (Instance->BlkSize + MTFTP6_DATA_HEAD_LEN);
42 if (UdpPacket ==
NULL) {
43 return EFI_OUT_OF_RESOURCES;
51 ASSERT (Packet !=
NULL);
59 Token = Instance->Token;
60 DataLen = Instance->BlkSize;
63 Start =
MultU64x32 (BlockNum - 1, Instance->BlkSize);
65 if (Token->
BufferSize < Start + Instance->BlkSize) {
67 Instance->LastBlk = BlockNum;
80 Status = Token->
PacketNeeded (&Instance->Mtftp6, Token, &DataLen, (VOID *)&DataBuf);
82 if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) {
83 if (DataBuf !=
NULL) {
84 gBS->FreePool (DataBuf);
93 (UINT8 *)
"User aborted the transfer"
99 if (DataLen < Instance->BlkSize) {
100 Instance->LastBlk = BlockNum;
107 gBS->FreePool (DataBuf);
114 Instance->CurRetry = 0;
142 OUT BOOLEAN *IsCompleted
149 *IsCompleted =
FALSE;
150 AckNum = NTOHS (Packet->Ack.Block[0]);
153 ASSERT (Expected >= 0);
159 if (Expected != AckNum) {
178 if (Instance->LastBlk == AckNum) {
179 ASSERT (Instance->LastBlk >= 1);
195 (UINT8 *)
"Block number rolls back, not supported, try blksize option"
198 return EFI_TFTP_ERROR;
236 if ((ReplyInfo->BitMap & ~RequestInfo->BitMap) != 0) {
244 if ((((ReplyInfo->BitMap & MTFTP6_OPT_BLKSIZE_BIT) != 0) && (ReplyInfo->BlkSize > RequestInfo->BlkSize)) ||
245 (((ReplyInfo->BitMap & MTFTP6_OPT_TIMEOUT_BIT) != 0) && (ReplyInfo->Timeout != RequestInfo->Timeout))
275 OUT BOOLEAN *IsCompleted
285 *IsCompleted =
FALSE;
304 if (EFI_ERROR (Status)) {
308 ASSERT (Options !=
NULL);
317 if (Status != EFI_OUT_OF_RESOURCES) {
330 (UINT8 *)
"Malformatted OACK packet"
334 return EFI_TFTP_ERROR;
337 if (ExtInfo.BlkSize != 0) {
338 Instance->BlkSize = ExtInfo.BlkSize;
341 if (ExtInfo.Timeout != 0) {
342 Instance->Timeout = ExtInfo.Timeout;
389 NET_CHECK_SIGNATURE (Instance, MTFTP6_INSTANCE_SIGNATURE);
399 if (EFI_ERROR (IoStatus)) {
404 ASSERT (UdpPacket !=
NULL);
406 if (UdpPacket->TotalSize < MTFTP6_OPCODE_LEN) {
414 if (UdpEpt->RemotePort != Instance->ServerDataPort) {
415 if (Instance->ServerDataPort != 0) {
418 Instance->ServerDataPort = UdpEpt->RemotePort;
425 Len = UdpPacket->TotalSize;
426 TotalNum = UdpPacket->BlockOpNum;
431 if (Packet ==
NULL) {
432 Status = EFI_OUT_OF_RESOURCES;
436 NetbufCopy (UdpPacket, 0, Len, (UINT8 *)Packet);
439 ASSERT (Packet !=
NULL);
442 Opcode = NTOHS (Packet->
OpCode);
459 if (EFI_ERROR (Status)) {
476 (UINT8 *)
"User aborted the transfer"
480 Status = EFI_ABORTED;
490 if (Len != MTFTP6_OPCODE_LEN + MTFTP6_BLKNO_LEN) {
501 if (Len <= MTFTP6_OPCODE_LEN) {
515 Status = EFI_TFTP_ERROR;
524 if ((Packet !=
NULL) && (TotalNum > 1)) {
528 if (UdpPacket !=
NULL) {
532 if (!EFI_ERROR (Status) && !IsCompleted) {
544 if (EFI_ERROR (Status) || IsCompleted) {
576 if (EFI_ERROR (Status)) {
582 if (EFI_ERROR (Status)) {
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
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_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 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 Mtftp6WrqInput(IN NET_BUF *UdpPacket, IN UDP_END_POINT *UdpEpt, IN EFI_STATUS IoStatus, IN VOID *Context)
BOOLEAN Mtftp6WrqOackValid(IN MTFTP6_EXT_OPTION_INFO *ReplyInfo, IN MTFTP6_EXT_OPTION_INFO *RequestInfo)
EFI_STATUS Mtftp6WrqHandleAck(IN MTFTP6_INSTANCE *Instance, IN EFI_MTFTP6_PACKET *Packet, IN UINT32 Len, OUT NET_BUF **UdpPacket, OUT BOOLEAN *IsCompleted)
EFI_STATUS Mtftp6WrqHandleOack(IN MTFTP6_INSTANCE *Instance, IN EFI_MTFTP6_PACKET *Packet, IN UINT32 Len, OUT NET_BUF **UdpPacket, OUT BOOLEAN *IsCompleted)
EFI_STATUS Mtftp6WrqSendBlock(IN MTFTP6_INSTANCE *Instance, IN UINT16 BlockNum)
EFI_STATUS Mtftp6WrqStart(IN MTFTP6_INSTANCE *Instance, IN UINT16 Operation)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
NET_BUF *EFIAPI NetbufAlloc(IN UINT32 Len)
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_MTFTP6_PACKET_NEEDED PacketNeeded
EFI_MTFTP6_CHECK_PACKET CheckPacket
EFI_MTFTP6_DATA_HEADER Data
Data packet header.
EFI_MTFTP6_ACK_HEADER Ack
Acknowledgement packet header.
UINT16 OpCode
Type of packets as defined by the MTFTPv6 packet opcodes.