/** @file
Functions implementation related with Mtftp for UefiPxeBc Driver.
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "PxeBcImpl.h"
"blksize",
"timeout",
"tsize",
"multicast"
};
/**
This is a callback function when packets are received or transmitted in Mtftp driver.
A callback function that is provided by the caller to intercept
the EFI_MTFTP6_OPCODE_DATA or EFI_MTFTP6_OPCODE_DATA8 packets processed in the
EFI_MTFTP6_PROTOCOL.ReadFile() function, and alternatively to intercept
EFI_MTFTP6_OPCODE_OACK or EFI_MTFTP6_OPCODE_ERROR packets during a call to
EFI_MTFTP6_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory().
@param[in] This Pointer to EFI_MTFTP6_PROTOCOL.
@param[in] Token Pointer to EFI_MTFTP6_TOKEN.
@param[in] PacketLen Length of EFI_MTFTP6_PACKET.
@param[in] Packet Pointer to EFI_MTFTP6_PACKET to be checked.
@retval EFI_SUCCESS The current operation succeeded.
@retval EFI_ABORTED Abort the current transfer process.
**/
)
{
//
// Store the tftp error message into mode data and set the received flag.
//
);
}
//
// Callback to user if has when received any tftp packet.
//
TRUE,
);
//
// User wants to abort current process if not EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE.
//
} else {
//
// User wants to continue current process if EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE.
//
}
}
return Status;
}
/**
This function is to get the size of a file using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP6_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Sucessfully obtained the size of file.
@retval EFI_NOT_FOUND Parse the tftp ptions failed.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Has not obtained the size of the file.
**/
)
{
*BufferSize = 0;
PktLen = 0;
OptCnt = 1;
return Status;
}
//
// Build the required options for get info.
//
PxeBcUintnToAscDec (0, OptBuf);
ReqOpt[1].ValueStr = (UINT8 *) (ReqOpt[0].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 1);
OptCnt++;
}
NULL,
&PktLen,
);
if (Status == EFI_TFTP_ERROR) {
//
// Store the tftp error message into mode data and set the received flag.
//
);
}
goto ON_ERROR;
}
//
// Parse the options in the reply packet.
//
OptCnt = 0;
);
goto ON_ERROR;
}
//
// Parse out the value of "tsize" option.
//
while (OptCnt != 0) {
}
OptCnt--;
}
}
return Status;
}
/**
This function is to get data of a file using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP6_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicates whether with a receive buffer.
@retval EFI_SUCCESS Successfully read the data from the special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Read data from file failed.
**/
)
{
OptCnt = 0;
return Status;
}
OptCnt++;
}
if (DontUseBuffer) {
Token.BufferSize = 0;
} else {
}
//
// Get the real size of received buffer.
//
return Status;
}
/**
This function is used to write the data of a file using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP6_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] Overwrite Indicate whether with overwrite attribute.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Successfully wrote the data into a special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval other Write data into file failed.
**/
)
{
OptCnt = 0;
return Status;
}
OptCnt++;
}
//
// Get the real size of transmitted buffer.
//
return Status;
}
/**
This function is to read the data (file) from a directory using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP6_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicates whether to use a receive buffer.
@retval EFI_SUCCESS Successfully obtained the data from the file included in directory.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Operation failed.
**/
)
{
OptCnt = 0;
return Status;
}
OptCnt++;
}
if (DontUseBuffer) {
Token.BufferSize = 0;
} else {
}
//
// Get the real size of received buffer.
//
return Status;
}
/**
This is a callback function when packets are received or transmitted in Mtftp driver.
A callback function that is provided by the caller to intercept
the EFI_MTFTP6_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets processed in the
EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept
EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during a call to
EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory().
@param[in] This Pointer to EFI_MTFTP4_PROTOCOL.
@param[in] Token Pointer to EFI_MTFTP4_TOKEN.
@param[in] PacketLen Length of EFI_MTFTP4_PACKET.
@param[in] Packet Pointer to EFI_MTFTP4_PACKET to be checked.
@retval EFI_SUCCESS The current operation succeeeded.
@retval EFI_ABORTED Abort the current transfer process.
**/
)
{
//
// Store the tftp error message into mode data and set the received flag.
//
);
}
//
// Callback to user if has when received any tftp packet.
//
TRUE,
);
//
// User wants to abort current process if not EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE.
//
} else {
//
// User wants to continue current process if EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE.
//
}
}
return Status;
}
/**
This function is to get size of a file using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP4_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Successfully obtained the size of file.
@retval EFI_NOT_FOUND Parse the tftp options failed.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Did not obtain the size of the file.
**/
)
{
*BufferSize = 0;
PktLen = 0;
OptCnt = 1;
return Status;
}
//
// Build the required options for get info.
//
PxeBcUintnToAscDec (0, OptBuf);
ReqOpt[1].ValueStr = (UINT8 *) (ReqOpt[0].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 1);
OptCnt++;
}
NULL,
&PktLen,
);
if (Status == EFI_TFTP_ERROR) {
//
// Store the tftp error message into mode data and set the received flag.
//
);
}
goto ON_ERROR;
}
//
// Parse the options in the reply packet.
//
OptCnt = 0;
);
goto ON_ERROR;
}
//
// Parse out the value of "tsize" option.
//
while (OptCnt != 0) {
}
OptCnt--;
}
}
return Status;
}
/**
This function is to read the data of a file using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP4_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicates whether to use a receive buffer.
@retval EFI_SUCCESS Successfully read the data from the special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Read data from file failed.
**/
)
{
OptCnt = 0;
return Status;
}
OptCnt++;
}
if (DontUseBuffer) {
Token.BufferSize = 0;
} else {
}
//
// Get the real size of received buffer.
//
return Status;
}
/**
This function is to write the data of a file using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP4_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] Overwrite Indicates whether to use the overwrite attribute.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Successfully write the data into the special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval other Write data into file failed.
**/
)
{
OptCnt = 0;
return Status;
}
OptCnt++;
}
//
// Get the real size of transmitted buffer.
//
return Status;
}
/**
This function is to get data (file) from a directory using Tftp.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to EFI_MTFTP4_CONFIG_DATA.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicates whether to use a receive buffer.
@retval EFI_SUCCES Successfully obtained the data from the file included in the directory.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Operation failed.
**/
)
{
OptCnt = 0;
return Status;
}
OptCnt++;
}
if (DontUseBuffer) {
Token.BufferSize = 0;
} else {
}
//
// Get the real size of received buffer.
//
return Status;
}
/**
This function is wrapper to get the file size using TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to configure data.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Successfully obtained the size of file.
@retval EFI_NOT_FOUND Parse the tftp options failed.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Did not obtain the size of the file.
**/
)
{
return PxeBcMtftp6GetFileSize (
);
} else {
return PxeBcMtftp4GetFileSize (
);
}
}
/**
This function is a wrapper to get file using TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to config data.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicates whether to use a receive buffer.
@retval EFI_SUCCESS Sucessfully read the data from the special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Read data from file failed.
**/
)
{
return PxeBcMtftp6ReadFile (
);
} else {
return PxeBcMtftp4ReadFile (
);
}
}
/**
This function is a wrapper to write file using TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to config data.
@param[in] Filename Pointer to boot file name.
@param[in] Overwrite Indicate whether with overwrite attribute.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Successfully wrote the data into a special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval other Write data into file failed.
**/
)
{
return PxeBcMtftp6WriteFile (
);
} else {
return PxeBcMtftp4WriteFile (
);
}
}
/**
This function is a wrapper to get the data (file) from a directory using TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to config data.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicatse whether to use a receive buffer.
@retval EFI_SUCCES Successfully obtained the data from the file included in the directory.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Operation failed.
**/
)
{
return PxeBcMtftp6ReadDirectory (
);
} else {
return PxeBcMtftp4ReadDirectory (
);
}
}