mirror of https://github.com/acidanthera/audk.git
re order the function definition to avoid unnecessary declaration.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7381 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
712ef76bdc
commit
3dc3861a4e
|
@ -16,50 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include "Mtftp4Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Reads the current operational settings.
|
||||
|
||||
The GetModeData()function reads the current operational settings of this
|
||||
EFI MTFTPv4 Protocol driver instance.
|
||||
|
||||
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
|
||||
@param ModeData Pointer to storage for the EFI MTFTPv4 Protocol
|
||||
driver mode data.
|
||||
|
||||
@retval EFI_SUCCESS The configuration data was successfully returned.
|
||||
@retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiMtftp4GetModeData (
|
||||
IN EFI_MTFTP4_PROTOCOL *This,
|
||||
OUT EFI_MTFTP4_MODE_DATA *ModeData
|
||||
)
|
||||
{
|
||||
MTFTP4_PROTOCOL *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (ModeData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
|
||||
CopyMem(&ModeData->ConfigData, &Instance->Config, sizeof (Instance->Config));
|
||||
ModeData->SupportedOptionCount = MTFTP4_SUPPORTED_OPTIONS;
|
||||
ModeData->SupportedOptoins = (UINT8 **) mMtftp4SupportedOptions;
|
||||
ModeData->UnsupportedOptionCount = 0;
|
||||
ModeData->UnsupportedOptoins = NULL;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up the MTFTP session to get ready for new operation.
|
||||
|
||||
|
@ -132,132 +88,6 @@ Mtftp4CleanOperation (
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Initializes, changes, or resets the default operational setting for this
|
||||
EFI MTFTPv4 Protocol driver instance.
|
||||
|
||||
The Configure() function is used to set and change the configuration data for
|
||||
this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset
|
||||
to startup defaults by calling Configure() with MtftpConfigData set to NULL.
|
||||
Whenever the instance is reset, any pending operation is aborted. By changing
|
||||
the EFI MTFTPv4 Protocol driver instance configuration data, the client can
|
||||
connect to different MTFTPv4 servers. The configuration parameters in
|
||||
MtftpConfigData are used as the default parameters in later MTFTPv4 operations
|
||||
and can be overridden in later operations.
|
||||
|
||||
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance
|
||||
@param ConfigData MtftpConfigDataPointer to the configuration data
|
||||
structure
|
||||
|
||||
@retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured
|
||||
successfully.
|
||||
@retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
|
||||
1.This is NULL.
|
||||
2.MtftpConfigData.UseDefaultSetting is FALSE and
|
||||
MtftpConfigData.StationIp is not a valid IPv4
|
||||
unicast address.
|
||||
3.MtftpCofigData.UseDefaultSetting is FALSE and
|
||||
MtftpConfigData.SubnetMask is invalid.
|
||||
4.MtftpCofigData.ServerIp is not a valid IPv4
|
||||
unicast address.
|
||||
5.MtftpConfigData.UseDefaultSetting is FALSE and
|
||||
MtftpConfigData.GatewayIp is not a valid IPv4
|
||||
unicast address or is not in the same subnet
|
||||
with station address.
|
||||
@retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this
|
||||
time because there is one MTFTP background operation
|
||||
in progress.
|
||||
@retval EFI_NO_MAPPING When using a default address, configuration
|
||||
(DHCP, BOOTP, RARP, etc.) has not finished yet.
|
||||
@retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.)
|
||||
could not be located when clients choose to use
|
||||
the default address settings.
|
||||
@retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could
|
||||
not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
The EFI MTFTPv4 Protocol driver instance is not
|
||||
configured.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiMtftp4Configure (
|
||||
IN EFI_MTFTP4_PROTOCOL *This,
|
||||
IN EFI_MTFTP4_CONFIG_DATA *ConfigData
|
||||
)
|
||||
{
|
||||
MTFTP4_PROTOCOL *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
IP4_ADDR Ip;
|
||||
IP4_ADDR Netmask;
|
||||
IP4_ADDR Gateway;
|
||||
IP4_ADDR ServerIp;
|
||||
|
||||
if (This == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
|
||||
|
||||
if (ConfigData == NULL) {
|
||||
//
|
||||
// Reset the operation if ConfigData is NULL
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
Mtftp4CleanOperation (Instance, EFI_ABORTED);
|
||||
ZeroMem (&Instance->Config, sizeof (EFI_MTFTP4_CONFIG_DATA));
|
||||
Instance->State = MTFTP4_STATE_UNCONFIGED;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
} else {
|
||||
//
|
||||
// Configure the parameters for new operation.
|
||||
//
|
||||
CopyMem (&Ip, &ConfigData->StationIp, sizeof (IP4_ADDR));
|
||||
CopyMem (&Netmask, &ConfigData->SubnetMask, sizeof (IP4_ADDR));
|
||||
CopyMem (&Gateway, &ConfigData->GatewayIp, sizeof (IP4_ADDR));
|
||||
CopyMem (&ServerIp, &ConfigData->ServerIp, sizeof (IP4_ADDR));
|
||||
|
||||
Ip = NTOHL (Ip);
|
||||
Netmask = NTOHL (Netmask);
|
||||
Gateway = NTOHL (Gateway);
|
||||
ServerIp = NTOHL (ServerIp);
|
||||
|
||||
if (!Ip4IsUnicast (ServerIp, 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!ConfigData->UseDefaultSetting &&
|
||||
((!IP4_IS_VALID_NETMASK (Netmask) || !Ip4IsUnicast (Ip, Netmask)))) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((Gateway != 0) &&
|
||||
(!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
if ((Instance->State == MTFTP4_STATE_CONFIGED) && (Instance->Operation != 0)) {
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
CopyMem(&Instance->Config, ConfigData, sizeof (*ConfigData));;
|
||||
Instance->State = MTFTP4_STATE_CONFIGED;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check packet for GetInfo.
|
||||
|
||||
|
@ -323,68 +153,6 @@ Mtftp4GetInfoCheckPacket (
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Parses the options in an MTFTPv4 OACK packet.
|
||||
|
||||
The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet
|
||||
and returns the number of options that were found and optionally a list of
|
||||
pointers to the options in the packet.
|
||||
If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is
|
||||
returned and *OptionCount and *OptionList stop at the last valid option.
|
||||
The OptionList is allocated by this function, and caller should free it when used.
|
||||
|
||||
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
|
||||
@param PacketLen Length of the OACK packet to be parsed.
|
||||
@param Packet Pointer to the OACK packet to be parsed.
|
||||
@param OptionCount Pointer to the number of options in following OptionList.
|
||||
@param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the
|
||||
EFI Boot Service FreePool() to release theOptionList
|
||||
if the options in this OptionList are not needed
|
||||
any more
|
||||
|
||||
@retval EFI_SUCCESS The OACK packet was valid and the OptionCount and
|
||||
OptionList parameters have been updated.
|
||||
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
||||
1.PacketLen is 0.
|
||||
2.Packet is NULL or Packet is not a valid MTFTPv4 packet.
|
||||
3.OptionCount is NULL.
|
||||
@retval EFI_NOT_FOUND No options were found in the OACK packet.
|
||||
@retval EFI_OUT_OF_RESOURCES Storage for the OptionList array cannot be allocated.
|
||||
@retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiMtftp4ParseOptions (
|
||||
IN EFI_MTFTP4_PROTOCOL *This,
|
||||
IN UINT32 PacketLen,
|
||||
IN EFI_MTFTP4_PACKET *Packet,
|
||||
OUT UINT32 *OptionCount,
|
||||
OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((This == NULL) || (PacketLen < MTFTP4_OPCODE_LEN) ||
|
||||
(Packet == NULL) || (OptionCount == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = Mtftp4ExtractOptions (Packet, PacketLen, OptionCount, OptionList);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (*OptionCount == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether the override data is valid.
|
||||
|
||||
|
@ -743,6 +511,240 @@ ON_ERROR:
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Reads the current operational settings.
|
||||
|
||||
The GetModeData()function reads the current operational settings of this
|
||||
EFI MTFTPv4 Protocol driver instance.
|
||||
|
||||
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
|
||||
@param ModeData Pointer to storage for the EFI MTFTPv4 Protocol
|
||||
driver mode data.
|
||||
|
||||
@retval EFI_SUCCESS The configuration data was successfully returned.
|
||||
@retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiMtftp4GetModeData (
|
||||
IN EFI_MTFTP4_PROTOCOL *This,
|
||||
OUT EFI_MTFTP4_MODE_DATA *ModeData
|
||||
)
|
||||
{
|
||||
MTFTP4_PROTOCOL *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (ModeData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
|
||||
CopyMem(&ModeData->ConfigData, &Instance->Config, sizeof (Instance->Config));
|
||||
ModeData->SupportedOptionCount = MTFTP4_SUPPORTED_OPTIONS;
|
||||
ModeData->SupportedOptoins = (UINT8 **) mMtftp4SupportedOptions;
|
||||
ModeData->UnsupportedOptionCount = 0;
|
||||
ModeData->UnsupportedOptoins = NULL;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initializes, changes, or resets the default operational setting for this
|
||||
EFI MTFTPv4 Protocol driver instance.
|
||||
|
||||
The Configure() function is used to set and change the configuration data for
|
||||
this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset
|
||||
to startup defaults by calling Configure() with MtftpConfigData set to NULL.
|
||||
Whenever the instance is reset, any pending operation is aborted. By changing
|
||||
the EFI MTFTPv4 Protocol driver instance configuration data, the client can
|
||||
connect to different MTFTPv4 servers. The configuration parameters in
|
||||
MtftpConfigData are used as the default parameters in later MTFTPv4 operations
|
||||
and can be overridden in later operations.
|
||||
|
||||
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance
|
||||
@param ConfigData MtftpConfigDataPointer to the configuration data
|
||||
structure
|
||||
|
||||
@retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured
|
||||
successfully.
|
||||
@retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
|
||||
1.This is NULL.
|
||||
2.MtftpConfigData.UseDefaultSetting is FALSE and
|
||||
MtftpConfigData.StationIp is not a valid IPv4
|
||||
unicast address.
|
||||
3.MtftpCofigData.UseDefaultSetting is FALSE and
|
||||
MtftpConfigData.SubnetMask is invalid.
|
||||
4.MtftpCofigData.ServerIp is not a valid IPv4
|
||||
unicast address.
|
||||
5.MtftpConfigData.UseDefaultSetting is FALSE and
|
||||
MtftpConfigData.GatewayIp is not a valid IPv4
|
||||
unicast address or is not in the same subnet
|
||||
with station address.
|
||||
@retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this
|
||||
time because there is one MTFTP background operation
|
||||
in progress.
|
||||
@retval EFI_NO_MAPPING When using a default address, configuration
|
||||
(DHCP, BOOTP, RARP, etc.) has not finished yet.
|
||||
@retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.)
|
||||
could not be located when clients choose to use
|
||||
the default address settings.
|
||||
@retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could
|
||||
not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
The EFI MTFTPv4 Protocol driver instance is not
|
||||
configured.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiMtftp4Configure (
|
||||
IN EFI_MTFTP4_PROTOCOL *This,
|
||||
IN EFI_MTFTP4_CONFIG_DATA *ConfigData
|
||||
)
|
||||
{
|
||||
MTFTP4_PROTOCOL *Instance;
|
||||
EFI_TPL OldTpl;
|
||||
IP4_ADDR Ip;
|
||||
IP4_ADDR Netmask;
|
||||
IP4_ADDR Gateway;
|
||||
IP4_ADDR ServerIp;
|
||||
|
||||
if (This == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
|
||||
|
||||
if (ConfigData == NULL) {
|
||||
//
|
||||
// Reset the operation if ConfigData is NULL
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
Mtftp4CleanOperation (Instance, EFI_ABORTED);
|
||||
ZeroMem (&Instance->Config, sizeof (EFI_MTFTP4_CONFIG_DATA));
|
||||
Instance->State = MTFTP4_STATE_UNCONFIGED;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
} else {
|
||||
//
|
||||
// Configure the parameters for new operation.
|
||||
//
|
||||
CopyMem (&Ip, &ConfigData->StationIp, sizeof (IP4_ADDR));
|
||||
CopyMem (&Netmask, &ConfigData->SubnetMask, sizeof (IP4_ADDR));
|
||||
CopyMem (&Gateway, &ConfigData->GatewayIp, sizeof (IP4_ADDR));
|
||||
CopyMem (&ServerIp, &ConfigData->ServerIp, sizeof (IP4_ADDR));
|
||||
|
||||
Ip = NTOHL (Ip);
|
||||
Netmask = NTOHL (Netmask);
|
||||
Gateway = NTOHL (Gateway);
|
||||
ServerIp = NTOHL (ServerIp);
|
||||
|
||||
if (!Ip4IsUnicast (ServerIp, 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!ConfigData->UseDefaultSetting &&
|
||||
((!IP4_IS_VALID_NETMASK (Netmask) || !Ip4IsUnicast (Ip, Netmask)))) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((Gateway != 0) &&
|
||||
(!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
if ((Instance->State == MTFTP4_STATE_CONFIGED) && (Instance->Operation != 0)) {
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
CopyMem(&Instance->Config, ConfigData, sizeof (*ConfigData));;
|
||||
Instance->State = MTFTP4_STATE_CONFIGED;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Parses the options in an MTFTPv4 OACK packet.
|
||||
|
||||
The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet
|
||||
and returns the number of options that were found and optionally a list of
|
||||
pointers to the options in the packet.
|
||||
If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is
|
||||
returned and *OptionCount and *OptionList stop at the last valid option.
|
||||
The OptionList is allocated by this function, and caller should free it when used.
|
||||
|
||||
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
|
||||
@param PacketLen Length of the OACK packet to be parsed.
|
||||
@param Packet Pointer to the OACK packet to be parsed.
|
||||
@param OptionCount Pointer to the number of options in following OptionList.
|
||||
@param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the
|
||||
EFI Boot Service FreePool() to release theOptionList
|
||||
if the options in this OptionList are not needed
|
||||
any more
|
||||
|
||||
@retval EFI_SUCCESS The OACK packet was valid and the OptionCount and
|
||||
OptionList parameters have been updated.
|
||||
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
||||
1.PacketLen is 0.
|
||||
2.Packet is NULL or Packet is not a valid MTFTPv4 packet.
|
||||
3.OptionCount is NULL.
|
||||
@retval EFI_NOT_FOUND No options were found in the OACK packet.
|
||||
@retval EFI_OUT_OF_RESOURCES Storage for the OptionList array cannot be allocated.
|
||||
@retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiMtftp4ParseOptions (
|
||||
IN EFI_MTFTP4_PROTOCOL *This,
|
||||
IN UINT32 PacketLen,
|
||||
IN EFI_MTFTP4_PACKET *Packet,
|
||||
OUT UINT32 *OptionCount,
|
||||
OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((This == NULL) || (PacketLen < MTFTP4_OPCODE_LEN) ||
|
||||
(Packet == NULL) || (OptionCount == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = Mtftp4ExtractOptions (Packet, PacketLen, OptionCount, OptionList);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (*OptionCount == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Downloads a file from an MTFTPv4 server.
|
||||
|
||||
|
|
|
@ -22,6 +22,134 @@ CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
Check whether two ascii strings are equel, ignore the case.
|
||||
|
||||
@param Str1 The first ascii string
|
||||
@param Str2 The second ascii string
|
||||
|
||||
@retval TRUE Two strings are equal when case is ignored.
|
||||
@retval FALSE Two string are not equal.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
NetStringEqualNoCase (
|
||||
IN UINT8 *Str1,
|
||||
IN UINT8 *Str2
|
||||
)
|
||||
{
|
||||
UINT8 Ch1;
|
||||
UINT8 Ch2;
|
||||
|
||||
ASSERT ((Str1 != NULL) && (Str2 != NULL));
|
||||
|
||||
for (; (*Str1 != '\0') && (*Str2 != '\0'); Str1++, Str2++) {
|
||||
Ch1 = *Str1;
|
||||
Ch2 = *Str2;
|
||||
|
||||
//
|
||||
// Convert them to lower case then compare two
|
||||
//
|
||||
if (('A' <= Ch1) && (Ch1 <= 'Z')) {
|
||||
Ch1 += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (('A' <= Ch2) && (Ch2 <= 'Z')) {
|
||||
Ch2 += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (Ch1 != Ch2) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return (BOOLEAN) (*Str1 == *Str2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert a string to a UINT32 number.
|
||||
|
||||
@param Str The string to convert from
|
||||
|
||||
@return The number get from the string
|
||||
|
||||
**/
|
||||
UINT32
|
||||
NetStringToU32 (
|
||||
IN UINT8 *Str
|
||||
)
|
||||
{
|
||||
UINT32 Num;
|
||||
|
||||
ASSERT (Str != NULL);
|
||||
|
||||
Num = 0;
|
||||
|
||||
for (; NET_IS_DIGIT (*Str); Str++) {
|
||||
Num = Num * 10 + (*Str - '0');
|
||||
}
|
||||
|
||||
return Num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert a string of the format "192.168.0.1" to an IP address.
|
||||
|
||||
@param Str The string representation of IP
|
||||
@param Ip The varible to get IP.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER The IP string is invalid.
|
||||
@retval EFI_SUCCESS The IP is parsed into the Ip
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NetStringToIp (
|
||||
IN UINT8 *Str,
|
||||
OUT IP4_ADDR *Ip
|
||||
)
|
||||
{
|
||||
UINT32 Byte;
|
||||
UINT32 Addr;
|
||||
UINTN Index;
|
||||
|
||||
*Ip = 0;
|
||||
Addr = 0;
|
||||
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
if (!NET_IS_DIGIT (*Str)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Byte = NetStringToU32 (Str);
|
||||
|
||||
if (Byte > 255) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Addr = (Addr << 8) | Byte;
|
||||
|
||||
//
|
||||
// Skip all the digitals and check whether the sepeator is the dot
|
||||
//
|
||||
while (NET_IS_DIGIT (*Str)) {
|
||||
Str++;
|
||||
}
|
||||
|
||||
if ((Index < 3) && (*Str != '.')) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Str++;
|
||||
}
|
||||
|
||||
*Ip = Addr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Go through the packet to fill the Options array with the start
|
||||
addresses of each MTFTP option name/value pair.
|
||||
|
@ -171,134 +299,6 @@ Mtftp4ExtractOptions (
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether two ascii strings are equel, ignore the case.
|
||||
|
||||
@param Str1 The first ascii string
|
||||
@param Str2 The second ascii string
|
||||
|
||||
@retval TRUE Two strings are equal when case is ignored.
|
||||
@retval FALSE Two string are not equal.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
NetStringEqualNoCase (
|
||||
IN UINT8 *Str1,
|
||||
IN UINT8 *Str2
|
||||
)
|
||||
{
|
||||
UINT8 Ch1;
|
||||
UINT8 Ch2;
|
||||
|
||||
ASSERT ((Str1 != NULL) && (Str2 != NULL));
|
||||
|
||||
for (; (*Str1 != '\0') && (*Str2 != '\0'); Str1++, Str2++) {
|
||||
Ch1 = *Str1;
|
||||
Ch2 = *Str2;
|
||||
|
||||
//
|
||||
// Convert them to lower case then compare two
|
||||
//
|
||||
if (('A' <= Ch1) && (Ch1 <= 'Z')) {
|
||||
Ch1 += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (('A' <= Ch2) && (Ch2 <= 'Z')) {
|
||||
Ch2 += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (Ch1 != Ch2) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return (BOOLEAN) (*Str1 == *Str2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert a string to a UINT32 number.
|
||||
|
||||
@param Str The string to convert from
|
||||
|
||||
@return The number get from the string
|
||||
|
||||
**/
|
||||
UINT32
|
||||
NetStringToU32 (
|
||||
IN UINT8 *Str
|
||||
)
|
||||
{
|
||||
UINT32 Num;
|
||||
|
||||
ASSERT (Str != NULL);
|
||||
|
||||
Num = 0;
|
||||
|
||||
for (; NET_IS_DIGIT (*Str); Str++) {
|
||||
Num = Num * 10 + (*Str - '0');
|
||||
}
|
||||
|
||||
return Num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert a string of the format "192.168.0.1" to an IP address.
|
||||
|
||||
@param Str The string representation of IP
|
||||
@param Ip The varible to get IP.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER The IP string is invalid.
|
||||
@retval EFI_SUCCESS The IP is parsed into the Ip
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NetStringToIp (
|
||||
IN UINT8 *Str,
|
||||
OUT IP4_ADDR *Ip
|
||||
)
|
||||
{
|
||||
UINT32 Byte;
|
||||
UINT32 Addr;
|
||||
UINTN Index;
|
||||
|
||||
*Ip = 0;
|
||||
Addr = 0;
|
||||
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
if (!NET_IS_DIGIT (*Str)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Byte = NetStringToU32 (Str);
|
||||
|
||||
if (Byte > 255) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Addr = (Addr << 8) | Byte;
|
||||
|
||||
//
|
||||
// Skip all the digitals and check whether the sepeator is the dot
|
||||
//
|
||||
while (NET_IS_DIGIT (*Str)) {
|
||||
Str++;
|
||||
}
|
||||
|
||||
if ((Index < 3) && (*Str != '.')) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Str++;
|
||||
}
|
||||
|
||||
*Ip = Addr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse the MTFTP multicast option.
|
||||
|
||||
|
|
|
@ -363,10 +363,10 @@ Mtftp4SendError (
|
|||
**/
|
||||
VOID
|
||||
Mtftp4OnPacketSent (
|
||||
NET_BUF *Packet,
|
||||
UDP_POINTS *Points,
|
||||
EFI_STATUS IoStatus,
|
||||
VOID *Context
|
||||
IN NET_BUF *Packet,
|
||||
IN UDP_POINTS *Points,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
NetbufFree (Packet);
|
||||
|
|
Loading…
Reference in New Issue