TianoCore EDK2 master
|
#include "Mtftp6Impl.h"
Go to the source code of this file.
Mtftp6 support functions implementation.
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Mtftp6Support.c.
MTFTP6_BLOCK_RANGE * Mtftp6AllocateRange | ( | IN UINT16 | Start, |
IN UINT16 | End | ||
) |
Allocate a MTFTP block range, then init it to the range of [Start, End].
[in] | Start | The start block number. |
[in] | End | The last block number in the range. |
Definition at line 22 of file Mtftp6Support.c.
EFI_STATUS EFIAPI Mtftp6CheckPacket | ( | IN EFI_MTFTP6_PROTOCOL * | This, |
IN EFI_MTFTP6_TOKEN * | Token, | ||
IN UINT16 | PacketLen, | ||
IN EFI_MTFTP6_PACKET * | Packet | ||
) |
Check packet for GetInfo callback routine.
GetInfo is implemented with EfiMtftp6ReadFile. It's used to inspect the first packet from server, then abort the session.
[in] | This | The pointer to the Mtftp6 protocol. |
[in] | Token | The pointer to the Mtftp6 token. |
[in] | PacketLen | The length of the packet. |
[in] | Packet | The pointer to the received packet. |
EFI_ABORTED | Abort the Mtftp6 operation. |
Definition at line 839 of file Mtftp6Support.c.
EFI_STATUS EFIAPI Mtftp6ConfigDummyUdpIo | ( | IN UDP_IO * | UdpIo, |
IN VOID * | Context | ||
) |
The dummy configure routine for create a new Udp6 Io.
[in] | UdpIo | The pointer to the Udp6 Io. |
[in] | Context | The pointer to the context. |
EFI_SUCCESS | This value is always returned. |
Definition at line 362 of file Mtftp6Support.c.
EFI_STATUS Mtftp6ConfigUdpIo | ( | IN UDP_IO * | UdpIo, |
IN EFI_IPv6_ADDRESS * | ServerIp, | ||
IN UINT16 | ServerPort, | ||
IN EFI_IPv6_ADDRESS * | LocalIp, | ||
IN UINT16 | LocalPort | ||
) |
The configure routine for Mtftp6 instance to transmit/receive.
[in] | UdpIo | The pointer to the Udp6 Io. |
[in] | ServerIp | The pointer to the server address. |
[in] | ServerPort | The pointer to the server port. |
[in] | LocalIp | The pointer to the local address. |
[in] | LocalPort | The pointer to the local port. |
EFI_SUCCESS | Configured the Udp6 Io for Mtftp6 successfully. |
EFI_NO_MAPPING | The corresponding Ip6 instance has not been configured yet. |
Definition at line 385 of file Mtftp6Support.c.
EFI_STATUS Mtftp6GetMapping | ( | IN UDP_IO * | UdpIo, |
IN EFI_UDP6_CONFIG_DATA * | UdpCfgData | ||
) |
Configure the opened Udp6 instance until the corresponding Ip6 instance has been configured.
[in] | UdpIo | The pointer to the Udp6 Io. |
[in] | UdpCfgData | The pointer to the Udp6 configure data. |
EFI_SUCCESS | Configure the Udp6 instance successfully. |
EFI_NO_MAPPING | The corresponding Ip6 instance has not been configured yet. |
Definition at line 262 of file Mtftp6Support.c.
INTN Mtftp6GetNextBlockNum | ( | IN LIST_ENTRY * | Head | ) |
Get the first valid block number on the range list.
[in] | Head | The block range head. |
==-1 | If the block range is empty. |
>-1 | The first valid block number. |
Definition at line 92 of file Mtftp6Support.c.
EFI_STATUS Mtftp6InitBlockRange | ( | 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 startup, WRQ initializes its whole valid block range to [0, 0xffff]. This is because the server will send an ACK0 to inform the user to start the upload. When the client receives an 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 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.
[in] | Head | The block range head to initialize. |
[in] | Start | The Start block number. |
[in] | End | The last block number. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory for initial block range. |
EFI_SUCCESS | The initial block range is created. |
Definition at line 64 of file Mtftp6Support.c.
VOID EFIAPI Mtftp6OnPacketSent | ( | IN NET_BUF * | Packet, |
IN UDP_END_POINT * | UdpEpt, | ||
IN EFI_STATUS | IoStatus, | ||
IN VOID * | Context | ||
) |
The callback function called when the packet is transmitted.
[in] | Packet | The pointer to the packet. |
[in] | UdpEpt | The pointer to the Udp6 access point. |
[in] | IoStatus | The result of the transmission. |
[in] | Context | The pointer to the context. |
Definition at line 633 of file Mtftp6Support.c.
The timer ticking routine for the Mtftp6 instance.
[in] | Event | The pointer to the ticking event. |
[in] | Context | The pointer to the context. |
Definition at line 1163 of file Mtftp6Support.c.
VOID Mtftp6OperationClean | ( | IN MTFTP6_INSTANCE * | Instance, |
IN EFI_STATUS | Result | ||
) |
Clean up the current Mtftp6 operation.
[in] | Instance | The pointer to the Mtftp6 instance. |
[in] | Result | The result to be returned to the user. |
Definition at line 893 of file Mtftp6Support.c.
EFI_STATUS Mtftp6OperationStart | ( | IN EFI_MTFTP6_PROTOCOL * | This, |
IN EFI_MTFTP6_TOKEN * | Token, | ||
IN UINT16 | OpCode | ||
) |
Start the Mtftp6 instance to perform the operation, such as read file, write file, and read directory.
[in] | This | The MTFTP session. |
[in] | Token | The token than encapsules the user's request. |
[in] | OpCode | The operation to perform. |
EFI_INVALID_PARAMETER | Some of the parameters are invalid. |
EFI_NOT_STARTED | The MTFTP session hasn't been configured. |
EFI_ALREADY_STARTED | There is pending operation for the session. |
EFI_SUCCESS | The operation is successfully started. |
Definition at line 984 of file Mtftp6Support.c.
EFI_STATUS Mtftp6RemoveBlockNum | ( | IN LIST_ENTRY * | Head, |
IN UINT16 | Num, | ||
IN BOOLEAN | Completed, | ||
OUT UINT64 * | BlockCounter | ||
) |
Remove the block number from the block range list.
[in] | Head | The block range list to remove from. |
[in] | Num | The block number to remove. |
[in] | Completed | Whether Num is the last block number. |
[out] | BlockCounter | The continuous block counter instead of the value after roll-over. |
EFI_NOT_FOUND | The block number isn't in the block range list. |
EFI_SUCCESS | The block number has been removed from the list. |
EFI_OUT_OF_RESOURCES | Failed to allocate resources. |
Definition at line 160 of file Mtftp6Support.c.
EFI_STATUS Mtftp6SendError | ( | IN MTFTP6_INSTANCE * | Instance, |
IN UINT16 | ErrCode, | ||
IN UINT8 * | ErrInfo | ||
) |
Build and send an error packet.
[in] | Instance | The pointer to the Mtftp6 instance. |
[in] | ErrCode | The error code in the packet. |
[in] | ErrInfo | The error message in the packet. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory for the error packet. |
EFI_SUCCESS | The error packet is transmitted. |
Others | Failed to transmit the packet. |
Definition at line 577 of file Mtftp6Support.c.
EFI_STATUS Mtftp6SendRequest | ( | IN MTFTP6_INSTANCE * | Instance, |
IN UINT16 | Operation | ||
) |
Build and transmit the request packet for the Mtftp6 instance.
[in] | Instance | The pointer to the Mtftp6 instance. |
[in] | Operation | The operation code of this packet. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory for the request. |
EFI_SUCCESS | The request is built and sent. |
Others | Failed to transmit the packet. |
Definition at line 451 of file Mtftp6Support.c.
VOID Mtftp6SetLastBlockNum | ( | IN LIST_ENTRY * | Head, |
IN UINT16 | Last | ||
) |
Set the last block number of the block range list. It removes 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 calls this function to set the last block number.
[in] | Head | The block range list. |
[in] | Last | The last block number. |
Definition at line 118 of file Mtftp6Support.c.
EFI_STATUS Mtftp6TransmitPacket | ( | IN MTFTP6_INSTANCE * | Instance, |
IN NET_BUF * | Packet | ||
) |
Send the packet for the Mtftp6 instance.
[in] | Instance | The pointer to the Mtftp6 instance. |
[in] | Packet | The pointer to the packet to be sent. |
EFI_SUCCESS | The packet was sent out |
Others | Failed to transmit the packet. |
Definition at line 655 of file Mtftp6Support.c.