TianoCore EDK2 master
Loading...
Searching...
No Matches
Mtftp4Support.c File Reference
#include "Mtftp4Impl.h"

Go to the source code of this file.

Functions

MTFTP4_BLOCK_RANGEMtftp4AllocateRange (IN UINT16 Start, IN UINT16 End)
 
EFI_STATUS Mtftp4InitBlockRange (IN LIST_ENTRY *Head, IN UINT16 Start, IN UINT16 End)
 
INTN Mtftp4GetNextBlockNum (IN LIST_ENTRY *Head)
 
VOID Mtftp4SetLastBlockNum (IN LIST_ENTRY *Head, IN UINT16 Last)
 
EFI_STATUS Mtftp4RemoveBlockNum (IN LIST_ENTRY *Head, IN UINT16 Num, IN BOOLEAN Completed, OUT UINT64 *BlockCounter)
 
EFI_STATUS Mtftp4SendRequest (IN MTFTP4_PROTOCOL *Instance)
 
EFI_STATUS Mtftp4SendError (IN MTFTP4_PROTOCOL *Instance, IN UINT16 ErrCode, IN UINT8 *ErrInfo)
 
VOID EFIAPI Mtftp4OnPacketSent (IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint, IN EFI_STATUS IoStatus, IN VOID *Context)
 
VOID Mtftp4SetTimeout (IN OUT MTFTP4_PROTOCOL *Instance)
 
EFI_STATUS Mtftp4SendPacket (IN OUT MTFTP4_PROTOCOL *Instance, IN OUT NET_BUF *Packet)
 
EFI_STATUS Mtftp4Retransmit (IN MTFTP4_PROTOCOL *Instance)
 
VOID EFIAPI Mtftp4OnTimerTickNotifyLevel (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI Mtftp4OnTimerTick (IN EFI_EVENT Event, IN VOID *Context)
 

Detailed Description

Support routines for Mtftp.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Mtftp4Support.c.

Function Documentation

◆ Mtftp4AllocateRange()

MTFTP4_BLOCK_RANGE * Mtftp4AllocateRange ( IN UINT16  Start,
IN UINT16  End 
)

Allocate a MTFTP4 block range, then init it to the range of [Start, End]

Parameters
StartThe start block number
EndThe last block number in the range
Returns
Pointer to the created block range, NULL if failed to allocate memory.

Definition at line 21 of file Mtftp4Support.c.

◆ Mtftp4GetNextBlockNum()

INTN Mtftp4GetNextBlockNum ( IN LIST_ENTRY Head)

Get the first valid block number on the range list.

Parameters
HeadThe block range head
Returns
The first valid block number, -1 if the block range is empty.

Definition at line 91 of file Mtftp4Support.c.

◆ Mtftp4InitBlockRange()

EFI_STATUS Mtftp4InitBlockRange ( IN LIST_ENTRY Head,
IN UINT16  Start,
IN UINT16  End 
)

Initialize the block range for either RRQ or WRQ.

RRQ and WRQ have different requirements for Start and End. For example, during start up, WRQ initializes its whole valid block range to [0, 0xffff]. This is because the server will send us a ACK0 to inform us to start the upload. When the client received ACK0, it will remove 0 from the range, get the next block number, which is 1, then upload the BLOCK1. For RRQ without option negotiation, the server will directly send us the BLOCK1 in response to the client's RRQ. When received BLOCK1, the client will remove it from the block range and send an ACK. It also works if there is option negotiation.

Parameters
HeadThe block range head to initialize
StartThe Start block number.
EndThe last block number.
Return values
EFI_OUT_OF_RESOURCESFailed to allocate memory for initial block range
EFI_SUCCESSThe initial block range is created.

Definition at line 64 of file Mtftp4Support.c.

◆ Mtftp4OnPacketSent()

VOID EFIAPI Mtftp4OnPacketSent ( IN NET_BUF Packet,
IN UDP_END_POINT EndPoint,
IN EFI_STATUS  IoStatus,
IN VOID *  Context 
)

The callback function called when the packet is transmitted.

It simply frees the packet.

Parameters
PacketThe transmitted (or failed to) packet
EndPointThe local and remote UDP access point
IoStatusThe result of the transmission
ContextOpaque parameter to the callback

Definition at line 392 of file Mtftp4Support.c.

◆ Mtftp4OnTimerTick()

VOID EFIAPI Mtftp4OnTimerTick ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

The timer ticking function for the Mtftp service instance.

Parameters
EventThe ticking event
ContextThe Mtftp service instance

Definition at line 596 of file Mtftp4Support.c.

◆ Mtftp4OnTimerTickNotifyLevel()

VOID EFIAPI Mtftp4OnTimerTickNotifyLevel ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

The timer ticking function in TPL_NOTIFY level for the Mtftp service instance.

Parameters
EventThe ticking event
ContextThe Mtftp service instance

Definition at line 561 of file Mtftp4Support.c.

◆ Mtftp4RemoveBlockNum()

EFI_STATUS Mtftp4RemoveBlockNum ( IN LIST_ENTRY Head,
IN UINT16  Num,
IN BOOLEAN  Completed,
OUT UINT64 *  BlockCounter 
)

Remove the block number from the block range list.

Parameters
HeadThe block range list to remove from
NumThe block number to remove
CompletedWhether Num is the last block number.
BlockCounterThe continuous block counter instead of the value after roll-over.
Return values
EFI_NOT_FOUNDThe block number isn't in the block range list
EFI_SUCCESSThe block number has been removed from the list
EFI_OUT_OF_RESOURCESFailed to allocate resource

Definition at line 159 of file Mtftp4Support.c.

◆ Mtftp4Retransmit()

EFI_STATUS Mtftp4Retransmit ( IN MTFTP4_PROTOCOL Instance)

Retransmit the last packet for the instance.

Parameters
InstanceThe Mtftp instance
Return values
EFI_SUCCESSThe last packet is retransmitted.
OthersFailed to retransmit.

Definition at line 505 of file Mtftp4Support.c.

◆ Mtftp4SendError()

EFI_STATUS Mtftp4SendError ( IN MTFTP4_PROTOCOL Instance,
IN UINT16  ErrCode,
IN UINT8 *  ErrInfo 
)

Build then send an error message.

Parameters
InstanceThe MTFTP session
ErrCodeThe error code
ErrInfoThe error message
Return values
EFI_OUT_OF_RESOURCESFailed to allocate memory for the error packet
EFI_SUCCESSThe error packet is transmitted.
OthersFailed to transmit the packet.

Definition at line 352 of file Mtftp4Support.c.

◆ Mtftp4SendPacket()

EFI_STATUS Mtftp4SendPacket ( IN OUT MTFTP4_PROTOCOL Instance,
IN OUT NET_BUF Packet 
)

Send the packet for the instance.

It will first save a reference to the packet for later retransmission. Then determine the destination port, listen port for requests, and connected port for others. At last, send the packet out.

Parameters
InstanceThe Mtftp instance
PacketThe packet to send
Return values
EFI_SUCCESSThe packet is sent out
OthersFailed to transmit the packet.

Definition at line 435 of file Mtftp4Support.c.

◆ Mtftp4SendRequest()

EFI_STATUS Mtftp4SendRequest ( IN MTFTP4_PROTOCOL Instance)

Build then transmit the request packet for the MTFTP session.

Parameters
InstanceThe Mtftp session
Return values
EFI_OUT_OF_RESOURCESFailed to allocate memory for the request
EFI_SUCCESSThe request is built and sent
OthersFailed to transmit the packet.

Definition at line 259 of file Mtftp4Support.c.

◆ Mtftp4SetLastBlockNum()

VOID Mtftp4SetLastBlockNum ( IN LIST_ENTRY Head,
IN UINT16  Last 
)

Set the last block number of the block range list.

It will remove all the blocks after the Last. MTFTP initialize the block range to the maximum possible range, such as [0, 0xffff] for WRQ. When it gets the last block number, it will call this function to set the last block number.

Parameters
HeadThe block range list
LastThe last block number

Definition at line 117 of file Mtftp4Support.c.

◆ Mtftp4SetTimeout()

VOID Mtftp4SetTimeout ( IN OUT MTFTP4_PROTOCOL Instance)

Set the timeout for the instance. User a longer time for passive instances.

Parameters
InstanceThe Mtftp session to set time out

Definition at line 409 of file Mtftp4Support.c.