75 return EFI_OUT_OF_RESOURCES;
131 if (Range->Start > Last) {
137 if (Range->End > Last) {
162 IN BOOLEAN Completed,
163 OUT UINT64 *BlockCounter
170 NET_LIST_FOR_EACH (Entry, Head) {
177 if (Range->End < Num) {
197 if (Range->Start > Num) {
198 return EFI_NOT_FOUND;
199 }
else if (Range->Start == Num) {
212 if (Range->Round > 0) {
213 *BlockCounter += Range->Bound +
MultU64x32 ((
UINTN)(Range->Round -1), (UINT32)(Range->Bound + 1)) + 1;
216 if (Range->Start > Range->Bound) {
221 if ((Range->Start > Range->End) || Completed) {
228 if (Range->End == Num) {
233 if (NewRange ==
NULL) {
234 return EFI_OUT_OF_RESOURCES;
237 Range->End = Num - 1;
245 return EFI_NOT_FOUND;
266 RETURN_STATUS Status;
272 UINTN FileNameLength;
274 UINTN OptionStrLength;
275 UINTN ValueStrLength;
277 Token = Instance->Token;
279 Mode = Instance->Token->ModeStr;
282 Mode = (UINT8 *)
"octet";
290 BufferLength = (UINT32)FileNameLength + (UINT32)ModeLength + 4;
292 for (Index = 0; Index < Token->
OptionCount; Index++) {
293 OptionStrLength =
AsciiStrLen ((CHAR8 *)Options[Index].OptionStr);
294 ValueStrLength =
AsciiStrLen ((CHAR8 *)Options[Index].ValueStr);
295 BufferLength += (UINT32)OptionStrLength + (UINT32)ValueStrLength + 2;
302 return EFI_OUT_OF_RESOURCES;
306 ASSERT (Packet !=
NULL);
308 Packet->
OpCode = HTONS (Instance->Operation);
309 BufferLength -=
sizeof (Packet->
OpCode);
311 Cur = Packet->
Rrq.Filename;
314 BufferLength -= (UINT32)(FileNameLength + 1);
315 Cur += FileNameLength + 1;
316 Status =
AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Mode);
318 BufferLength -= (UINT32)(ModeLength + 1);
319 Cur += ModeLength + 1;
321 for (Index = 0; Index < Token->
OptionCount; ++Index) {
322 OptionStrLength =
AsciiStrLen ((CHAR8 *)Options[Index].OptionStr);
323 ValueStrLength =
AsciiStrLen ((CHAR8 *)Options[Index].ValueStr);
325 Status =
AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Options[Index].OptionStr);
327 BufferLength -= (UINT32)(OptionStrLength + 1);
328 Cur += OptionStrLength + 1;
330 Status =
AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Options[Index].ValueStr);
332 BufferLength -= (UINT32)(ValueStrLength + 1);
333 Cur += ValueStrLength + 1;
364 if (Packet ==
NULL) {
365 return EFI_OUT_OF_RESOURCES;
369 ASSERT (TftpError !=
NULL);
371 TftpError->
OpCode = HTONS (EFI_MTFTP4_OPCODE_ERROR);
372 TftpError->
Error.ErrorCode = HTONS (ErrCode);
413 if (Instance->Master) {
414 Instance->PacketToLive = Instance->Timeout;
416 Instance->PacketToLive = Instance->Timeout * 2;
448 if (Instance->LastPacket !=
NULL) {
452 Instance->LastPacket = Packet;
454 Instance->CurRetry = 0;
457 ZeroMem (&UdpPoint,
sizeof (UdpPoint));
458 UdpPoint.RemoteAddr.Addr[0] = Instance->ServerIp;
465 ASSERT (Buffer !=
NULL);
466 OpCode = NTOHS (*(UINT16 *)Buffer);
468 if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) ||
469 (OpCode == EFI_MTFTP4_OPCODE_DIR) ||
470 (OpCode == EFI_MTFTP4_OPCODE_WRQ))
472 UdpPoint.RemotePort = Instance->ListeningPort;
474 UdpPoint.RemotePort = Instance->ConnectedPort;
477 NET_GET_REF (Packet);
480 Instance->UnicastPort,
488 if (EFI_ERROR (Status)) {
489 NET_PUT_REF (Packet);
514 ASSERT (Instance->LastPacket !=
NULL);
516 ZeroMem (&UdpPoint,
sizeof (UdpPoint));
517 UdpPoint.RemoteAddr.Addr[0] = Instance->ServerIp;
523 ASSERT (Buffer !=
NULL);
524 OpCode = NTOHS (*(UINT16 *)Buffer);
526 if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || (OpCode == EFI_MTFTP4_OPCODE_DIR) ||
527 (OpCode == EFI_MTFTP4_OPCODE_WRQ))
529 UdpPoint.RemotePort = Instance->ListeningPort;
531 UdpPoint.RemotePort = Instance->ConnectedPort;
534 NET_GET_REF (Instance->LastPacket);
537 Instance->UnicastPort,
538 Instance->LastPacket,
545 if (EFI_ERROR (Status)) {
546 NET_PUT_REF (Instance->LastPacket);
577 NET_LIST_FOR_EACH_SAFE (Entry, Next, &MtftpSb->Children) {
579 if ((Instance->PacketToLive == 0) || (--Instance->PacketToLive > 0)) {
580 Instance->HasTimeout =
FALSE;
582 Instance->HasTimeout =
TRUE;
612 NET_LIST_FOR_EACH_SAFE (Entry, Next, &MtftpSb->Children) {
614 if (!Instance->HasTimeout) {
618 Instance->HasTimeout =
FALSE;
623 Token = Instance->Token;
630 EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
631 (UINT8 *)
"User aborted the transfer in time out"
642 if (++Instance->CurRetry < Instance->MaxRetry) {
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
VOID Mtftp4CleanOperation(IN OUT MTFTP4_PROTOCOL *Instance, IN EFI_STATUS Result)
EFI_STATUS Mtftp4Retransmit(IN MTFTP4_PROTOCOL *Instance)
VOID EFIAPI Mtftp4OnPacketSent(IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint, IN EFI_STATUS IoStatus, IN VOID *Context)
MTFTP4_BLOCK_RANGE * Mtftp4AllocateRange(IN UINT16 Start, IN UINT16 End)
EFI_STATUS Mtftp4InitBlockRange(IN LIST_ENTRY *Head, IN UINT16 Start, IN UINT16 End)
VOID Mtftp4SetLastBlockNum(IN LIST_ENTRY *Head, IN UINT16 Last)
EFI_STATUS Mtftp4SendRequest(IN MTFTP4_PROTOCOL *Instance)
VOID Mtftp4SetTimeout(IN OUT MTFTP4_PROTOCOL *Instance)
VOID EFIAPI Mtftp4OnTimerTickNotifyLevel(IN EFI_EVENT Event, IN VOID *Context)
INTN Mtftp4GetNextBlockNum(IN LIST_ENTRY *Head)
EFI_STATUS Mtftp4SendError(IN MTFTP4_PROTOCOL *Instance, IN UINT16 ErrCode, IN UINT8 *ErrInfo)
EFI_STATUS Mtftp4RemoveBlockNum(IN LIST_ENTRY *Head, IN UINT16 Num, IN BOOLEAN Completed, OUT UINT64 *BlockCounter)
VOID EFIAPI Mtftp4OnTimerTick(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS Mtftp4SendPacket(IN OUT MTFTP4_PROTOCOL *Instance, IN OUT NET_BUF *Packet)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
VOID EFIAPI NetListInsertAfter(IN OUT LIST_ENTRY *PrevEntry, IN OUT LIST_ENTRY *NewEntry)
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 UdpIoSendDatagram(IN UDP_IO *UdpIo, IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint OPTIONAL, IN EFI_IP_ADDRESS *Gateway OPTIONAL, IN UDP_IO_CALLBACK CallBack, IN VOID *Context)
EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback
EFI_MTFTP4_OPTION * OptionList
EFI_MTFTP4_REQ_HEADER Rrq
EFI_MTFTP4_ERROR_HEADER Error