summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c
diff options
context:
space:
mode:
Diffstat (limited to 'NetworkPkg/Mtftp6Dxe/Mtftp6Support.c')
-rw-r--r--NetworkPkg/Mtftp6Dxe/Mtftp6Support.c386
1 files changed, 185 insertions, 201 deletions
diff --git a/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c b/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c
index 1157a6065c..582634fb2d 100644
--- a/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c
+++ b/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c
@@ -9,7 +9,6 @@
#include "Mtftp6Impl.h"
-
/**
Allocate a MTFTP block range, then init it to the range of [Start, End].
@@ -21,11 +20,11 @@
**/
MTFTP6_BLOCK_RANGE *
Mtftp6AllocateRange (
- IN UINT16 Start,
- IN UINT16 End
+ IN UINT16 Start,
+ IN UINT16 End
)
{
- MTFTP6_BLOCK_RANGE *Range;
+ MTFTP6_BLOCK_RANGE *Range;
Range = AllocateZeroPool (sizeof (MTFTP6_BLOCK_RANGE));
@@ -34,14 +33,13 @@ Mtftp6AllocateRange (
}
InitializeListHead (&Range->Link);
- Range->Start = Start;
- Range->End = End;
- Range->Bound = End;
+ Range->Start = Start;
+ Range->End = End;
+ Range->Bound = End;
return Range;
}
-
/**
Initialize the block range for either RRQ or WRQ. RRQ and WRQ have
different requirements for Start and End. For example, during startup,
@@ -64,12 +62,12 @@ Mtftp6AllocateRange (
**/
EFI_STATUS
Mtftp6InitBlockRange (
- IN LIST_ENTRY *Head,
- IN UINT16 Start,
- IN UINT16 End
+ IN LIST_ENTRY *Head,
+ IN UINT16 Start,
+ IN UINT16 End
)
{
- MTFTP6_BLOCK_RANGE *Range;
+ MTFTP6_BLOCK_RANGE *Range;
Range = Mtftp6AllocateRange (Start, End);
@@ -81,7 +79,6 @@ Mtftp6InitBlockRange (
return EFI_SUCCESS;
}
-
/**
Get the first valid block number on the range list.
@@ -93,7 +90,7 @@ Mtftp6InitBlockRange (
**/
INTN
Mtftp6GetNextBlockNum (
- IN LIST_ENTRY *Head
+ IN LIST_ENTRY *Head
)
{
MTFTP6_BLOCK_RANGE *Range;
@@ -106,7 +103,6 @@ Mtftp6GetNextBlockNum (
return Range->Start;
}
-
/**
Set the last block number of the block range list. It
removes all the blocks after the Last. MTFTP initialize the
@@ -120,11 +116,11 @@ Mtftp6GetNextBlockNum (
**/
VOID
Mtftp6SetLastBlockNum (
- IN LIST_ENTRY *Head,
- IN UINT16 Last
+ IN LIST_ENTRY *Head,
+ IN UINT16 Last
)
{
- MTFTP6_BLOCK_RANGE *Range;
+ MTFTP6_BLOCK_RANGE *Range;
//
// Iterate from the tail to head to remove the block number
@@ -142,11 +138,11 @@ Mtftp6SetLastBlockNum (
if (Range->End > Last) {
Range->End = Last;
}
- return ;
+
+ return;
}
}
-
/**
Remove the block number from the block range list.
@@ -162,18 +158,17 @@ Mtftp6SetLastBlockNum (
**/
EFI_STATUS
Mtftp6RemoveBlockNum (
- IN LIST_ENTRY *Head,
- IN UINT16 Num,
- IN BOOLEAN Completed,
- OUT UINT64 *BlockCounter
+ IN LIST_ENTRY *Head,
+ IN UINT16 Num,
+ IN BOOLEAN Completed,
+ OUT UINT64 *BlockCounter
)
{
- MTFTP6_BLOCK_RANGE *Range;
- MTFTP6_BLOCK_RANGE *NewRange;
- LIST_ENTRY *Entry;
+ MTFTP6_BLOCK_RANGE *Range;
+ MTFTP6_BLOCK_RANGE *NewRange;
+ LIST_ENTRY *Entry;
NET_LIST_FOR_EACH (Entry, Head) {
-
//
// Each block represents a hole [Start, End] in the file,
// skip to the first range with End >= Num
@@ -202,7 +197,6 @@ Mtftp6RemoveBlockNum (
//
if (Range->Start > Num) {
return EFI_NOT_FOUND;
-
} else if (Range->Start == Num) {
Range->Start++;
@@ -214,7 +208,7 @@ Mtftp6RemoveBlockNum (
// wrap to zero, because this is the simplest to implement. Here we choose
// this solution.
//
- *BlockCounter = Num;
+ *BlockCounter = Num;
if (Range->Round > 0) {
*BlockCounter += Range->Bound + MultU64x32 (Range->Round - 1, (UINT32)(Range->Bound + 1)) + 1;
@@ -222,7 +216,7 @@ Mtftp6RemoveBlockNum (
if (Range->Start > Range->Bound) {
Range->Start = 0;
- Range->Round ++;
+ Range->Round++;
}
if ((Range->Start > Range->End) || Completed) {
@@ -231,12 +225,11 @@ Mtftp6RemoveBlockNum (
}
return EFI_SUCCESS;
-
} else {
if (Range->End == Num) {
Range->End--;
} else {
- NewRange = Mtftp6AllocateRange ((UINT16) (Num + 1), (UINT16) Range->End);
+ NewRange = Mtftp6AllocateRange ((UINT16)(Num + 1), (UINT16)Range->End);
if (NewRange == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -253,7 +246,6 @@ Mtftp6RemoveBlockNum (
return EFI_NOT_FOUND;
}
-
/**
Configure the opened Udp6 instance until the corresponding Ip6 instance
has been configured.
@@ -268,17 +260,17 @@ Mtftp6RemoveBlockNum (
**/
EFI_STATUS
Mtftp6GetMapping (
- IN UDP_IO *UdpIo,
- IN EFI_UDP6_CONFIG_DATA *UdpCfgData
+ IN UDP_IO *UdpIo,
+ IN EFI_UDP6_CONFIG_DATA *UdpCfgData
)
{
- EFI_IP6_MODE_DATA Ip6Mode;
- EFI_UDP6_PROTOCOL *Udp6;
- EFI_STATUS Status;
- EFI_EVENT Event;
+ EFI_IP6_MODE_DATA Ip6Mode;
+ EFI_UDP6_PROTOCOL *Udp6;
+ EFI_STATUS Status;
+ EFI_EVENT Event;
- Event = NULL;
- Udp6 = UdpIo->Protocol.Udp6;
+ Event = NULL;
+ Udp6 = UdpIo->Protocol.Udp6;
//
// Create a timer to check whether the Ip6 instance configured or not.
@@ -307,7 +299,6 @@ Mtftp6GetMapping (
// Check the Ip6 mode data till timeout.
//
while (EFI_ERROR (gBS->CheckEvent (Event))) {
-
Udp6->Poll (Udp6);
Status = Udp6->GetModeData (Udp6, NULL, &Ip6Mode, NULL, NULL);
@@ -337,7 +328,7 @@ Mtftp6GetMapping (
FreePool (Ip6Mode.IcmpTypeList);
}
- if (Ip6Mode.IsConfigured) {
+ if (Ip6Mode.IsConfigured) {
//
// Continue to configure the Udp6 instance.
//
@@ -357,7 +348,6 @@ ON_EXIT:
return Status;
}
-
/**
The dummy configure routine for create a new Udp6 Io.
@@ -370,14 +360,13 @@ ON_EXIT:
EFI_STATUS
EFIAPI
Mtftp6ConfigDummyUdpIo (
- IN UDP_IO *UdpIo,
- IN VOID *Context
+ IN UDP_IO *UdpIo,
+ IN VOID *Context
)
{
return EFI_SUCCESS;
}
-
/**
The configure routine for Mtftp6 instance to transmit/receive.
@@ -394,16 +383,16 @@ Mtftp6ConfigDummyUdpIo (
**/
EFI_STATUS
Mtftp6ConfigUdpIo (
- IN UDP_IO *UdpIo,
- IN EFI_IPv6_ADDRESS *ServerIp,
- IN UINT16 ServerPort,
- IN EFI_IPv6_ADDRESS *LocalIp,
- IN UINT16 LocalPort
+ IN UDP_IO *UdpIo,
+ IN EFI_IPv6_ADDRESS *ServerIp,
+ IN UINT16 ServerPort,
+ IN EFI_IPv6_ADDRESS *LocalIp,
+ IN UINT16 LocalPort
)
{
- EFI_STATUS Status;
- EFI_UDP6_PROTOCOL *Udp6;
- EFI_UDP6_CONFIG_DATA *Udp6Cfg;
+ EFI_STATUS Status;
+ EFI_UDP6_PROTOCOL *Udp6;
+ EFI_UDP6_CONFIG_DATA *Udp6Cfg;
Udp6 = UdpIo->Protocol.Udp6;
Udp6Cfg = &(UdpIo->Config.Udp6);
@@ -441,14 +430,12 @@ Mtftp6ConfigUdpIo (
Status = Udp6->Configure (Udp6, Udp6Cfg);
if (Status == EFI_NO_MAPPING) {
-
return Mtftp6GetMapping (UdpIo, Udp6Cfg);
}
return Status;
}
-
/**
Build and transmit the request packet for the Mtftp6 instance.
@@ -462,30 +449,30 @@ Mtftp6ConfigUdpIo (
**/
EFI_STATUS
Mtftp6SendRequest (
- IN MTFTP6_INSTANCE *Instance,
- IN UINT16 Operation
+ IN MTFTP6_INSTANCE *Instance,
+ IN UINT16 Operation
)
{
- EFI_MTFTP6_PACKET *Packet;
- EFI_MTFTP6_OPTION *Options;
- EFI_MTFTP6_TOKEN *Token;
- RETURN_STATUS Status;
- NET_BUF *Nbuf;
- UINT8 *Mode;
- UINT8 *Cur;
- UINTN Index;
- UINT32 BufferLength;
- UINTN FileNameLength;
- UINTN ModeLength;
- UINTN OptionStrLength;
- UINTN ValueStrLength;
+ EFI_MTFTP6_PACKET *Packet;
+ EFI_MTFTP6_OPTION *Options;
+ EFI_MTFTP6_TOKEN *Token;
+ RETURN_STATUS Status;
+ NET_BUF *Nbuf;
+ UINT8 *Mode;
+ UINT8 *Cur;
+ UINTN Index;
+ UINT32 BufferLength;
+ UINTN FileNameLength;
+ UINTN ModeLength;
+ UINTN OptionStrLength;
+ UINTN ValueStrLength;
Token = Instance->Token;
Options = Token->OptionList;
Mode = Token->ModeStr;
if (Mode == NULL) {
- Mode = (UINT8 *) "octet";
+ Mode = (UINT8 *)"octet";
}
//
@@ -507,14 +494,14 @@ Mtftp6SendRequest (
//
// Compute the size of new Mtftp6 packet.
//
- FileNameLength = AsciiStrLen ((CHAR8 *) Token->Filename);
- ModeLength = AsciiStrLen ((CHAR8 *) Mode);
- BufferLength = (UINT32) FileNameLength + (UINT32) ModeLength + 4;
+ FileNameLength = AsciiStrLen ((CHAR8 *)Token->Filename);
+ ModeLength = AsciiStrLen ((CHAR8 *)Mode);
+ BufferLength = (UINT32)FileNameLength + (UINT32)ModeLength + 4;
for (Index = 0; Index < Token->OptionCount; Index++) {
- OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);
- ValueStrLength = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);
- BufferLength += (UINT32) OptionStrLength + (UINT32) ValueStrLength + 2;
+ OptionStrLength = AsciiStrLen ((CHAR8 *)Options[Index].OptionStr);
+ ValueStrLength = AsciiStrLen ((CHAR8 *)Options[Index].ValueStr);
+ BufferLength += (UINT32)OptionStrLength + (UINT32)ValueStrLength + 2;
}
//
@@ -527,39 +514,38 @@ Mtftp6SendRequest (
//
// Copy the opcode, filename and mode into packet.
//
- Packet = (EFI_MTFTP6_PACKET *) NetbufAllocSpace (Nbuf, BufferLength, FALSE);
+ Packet = (EFI_MTFTP6_PACKET *)NetbufAllocSpace (Nbuf, BufferLength, FALSE);
ASSERT (Packet != NULL);
Packet->OpCode = HTONS (Operation);
BufferLength -= sizeof (Packet->OpCode);
- Cur = Packet->Rrq.Filename;
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Token->Filename);
+ Cur = Packet->Rrq.Filename;
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Token->Filename);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (FileNameLength + 1);
- Cur += FileNameLength + 1;
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Mode);
+ BufferLength -= (UINT32)(FileNameLength + 1);
+ Cur += FileNameLength + 1;
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Mode);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (ModeLength + 1);
- Cur += ModeLength + 1;
+ BufferLength -= (UINT32)(ModeLength + 1);
+ Cur += ModeLength + 1;
//
// Copy all the extension options into the packet.
//
for (Index = 0; Index < Token->OptionCount; ++Index) {
- OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);
- ValueStrLength = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);
+ OptionStrLength = AsciiStrLen ((CHAR8 *)Options[Index].OptionStr);
+ ValueStrLength = AsciiStrLen ((CHAR8 *)Options[Index].ValueStr);
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].OptionStr);
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Options[Index].OptionStr);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (OptionStrLength + 1);
- Cur += OptionStrLength + 1;
+ BufferLength -= (UINT32)(OptionStrLength + 1);
+ Cur += OptionStrLength + 1;
- Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].ValueStr);
+ Status = AsciiStrCpyS ((CHAR8 *)Cur, BufferLength, (CHAR8 *)Options[Index].ValueStr);
ASSERT_EFI_ERROR (Status);
- BufferLength -= (UINT32) (ValueStrLength + 1);
- Cur += ValueStrLength + 1;
-
+ BufferLength -= (UINT32)(ValueStrLength + 1);
+ Cur += ValueStrLength + 1;
}
//
@@ -575,7 +561,6 @@ Mtftp6SendRequest (
return Mtftp6TransmitPacket (Instance, Nbuf);
}
-
/**
Build and send an error packet.
@@ -590,26 +575,26 @@ Mtftp6SendRequest (
**/
EFI_STATUS
Mtftp6SendError (
- IN MTFTP6_INSTANCE *Instance,
- IN UINT16 ErrCode,
- IN UINT8* ErrInfo
+ IN MTFTP6_INSTANCE *Instance,
+ IN UINT16 ErrCode,
+ IN UINT8 *ErrInfo
)
{
- NET_BUF *Nbuf;
- EFI_MTFTP6_PACKET *TftpError;
- UINT32 Len;
+ NET_BUF *Nbuf;
+ EFI_MTFTP6_PACKET *TftpError;
+ UINT32 Len;
//
// Allocate a packet then copy the data.
//
- Len = (UINT32) (AsciiStrLen ((CHAR8 *) ErrInfo) + sizeof (EFI_MTFTP6_ERROR_HEADER));
+ Len = (UINT32)(AsciiStrLen ((CHAR8 *)ErrInfo) + sizeof (EFI_MTFTP6_ERROR_HEADER));
Nbuf = NetbufAlloc (Len);
if (Nbuf == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- TftpError = (EFI_MTFTP6_PACKET *) NetbufAllocSpace (Nbuf, Len, FALSE);
+ TftpError = (EFI_MTFTP6_PACKET *)NetbufAllocSpace (Nbuf, Len, FALSE);
if (TftpError == NULL) {
NetbufFree (Nbuf);
@@ -619,7 +604,7 @@ Mtftp6SendError (
TftpError->OpCode = HTONS (EFI_MTFTP6_OPCODE_ERROR);
TftpError->Error.ErrorCode = HTONS (ErrCode);
- AsciiStrCpyS ((CHAR8 *) TftpError->Error.ErrorMessage, AsciiStrLen ((CHAR8 *) ErrInfo) + 1 , (CHAR8 *) ErrInfo);
+ AsciiStrCpyS ((CHAR8 *)TftpError->Error.ErrorMessage, AsciiStrLen ((CHAR8 *)ErrInfo) + 1, (CHAR8 *)ErrInfo);
//
// Save the packet buf for retransmit
@@ -634,7 +619,6 @@ Mtftp6SendError (
return Mtftp6TransmitPacket (Instance, Nbuf);
}
-
/**
The callback function called when the packet is transmitted.
@@ -647,17 +631,16 @@ Mtftp6SendError (
VOID
EFIAPI
Mtftp6OnPacketSent (
- IN NET_BUF *Packet,
- IN UDP_END_POINT *UdpEpt,
- IN EFI_STATUS IoStatus,
- IN VOID *Context
+ IN NET_BUF *Packet,
+ IN UDP_END_POINT *UdpEpt,
+ IN EFI_STATUS IoStatus,
+ IN VOID *Context
)
{
NetbufFree (Packet);
- *(BOOLEAN *) Context = TRUE;
+ *(BOOLEAN *)Context = TRUE;
}
-
/**
Send the packet for the Mtftp6 instance.
@@ -670,18 +653,18 @@ Mtftp6OnPacketSent (
**/
EFI_STATUS
Mtftp6TransmitPacket (
- IN MTFTP6_INSTANCE *Instance,
- IN NET_BUF *Packet
+ IN MTFTP6_INSTANCE *Instance,
+ IN NET_BUF *Packet
)
{
- EFI_UDP6_PROTOCOL *Udp6;
- EFI_UDP6_CONFIG_DATA Udp6CfgData;
- EFI_STATUS Status;
- UINT16 *Temp;
- UINT16 Value;
- UINT16 OpCode;
-
- ZeroMem (&Udp6CfgData, sizeof(EFI_UDP6_CONFIG_DATA));
+ EFI_UDP6_PROTOCOL *Udp6;
+ EFI_UDP6_CONFIG_DATA Udp6CfgData;
+ EFI_STATUS Status;
+ UINT16 *Temp;
+ UINT16 Value;
+ UINT16 OpCode;
+
+ ZeroMem (&Udp6CfgData, sizeof (EFI_UDP6_CONFIG_DATA));
Udp6 = Instance->UdpIo->Protocol.Udp6;
//
@@ -689,13 +672,13 @@ Mtftp6TransmitPacket (
//
Instance->PacketToLive = Instance->IsMaster ? Instance->Timeout : (Instance->Timeout * 2);
- Temp = (UINT16 *) NetbufGetByte (Packet, 0, NULL);
+ Temp = (UINT16 *)NetbufGetByte (Packet, 0, NULL);
ASSERT (Temp != NULL);
Value = *Temp;
OpCode = NTOHS (Value);
- if (OpCode == EFI_MTFTP6_OPCODE_RRQ || OpCode == EFI_MTFTP6_OPCODE_DIR || OpCode == EFI_MTFTP6_OPCODE_WRQ) {
+ if ((OpCode == EFI_MTFTP6_OPCODE_RRQ) || (OpCode == EFI_MTFTP6_OPCODE_DIR) || (OpCode == EFI_MTFTP6_OPCODE_WRQ)) {
//
// For the Rrq, Dir, Wrq requests of the operation, configure the Udp6Io as
// (serverip, 69, localip, localport) to send.
@@ -786,7 +769,6 @@ Mtftp6TransmitPacket (
}
if (Udp6CfgData.RemotePort != Instance->ServerDataPort) {
-
Status = Udp6->Configure (Udp6, NULL);
if (EFI_ERROR (Status)) {
@@ -838,7 +820,6 @@ Mtftp6TransmitPacket (
return Status;
}
-
/**
Check packet for GetInfo callback routine.
@@ -856,32 +837,32 @@ Mtftp6TransmitPacket (
EFI_STATUS
EFIAPI
Mtftp6CheckPacket (
- IN EFI_MTFTP6_PROTOCOL *This,
- IN EFI_MTFTP6_TOKEN *Token,
- IN UINT16 PacketLen,
- IN EFI_MTFTP6_PACKET *Packet
+ IN EFI_MTFTP6_PROTOCOL *This,
+ IN EFI_MTFTP6_TOKEN *Token,
+ IN UINT16 PacketLen,
+ IN EFI_MTFTP6_PACKET *Packet
)
{
- MTFTP6_GETINFO_CONTEXT *Context;
- UINT16 OpCode;
+ MTFTP6_GETINFO_CONTEXT *Context;
+ UINT16 OpCode;
- Context = (MTFTP6_GETINFO_CONTEXT *) Token->Context;
+ Context = (MTFTP6_GETINFO_CONTEXT *)Token->Context;
OpCode = NTOHS (Packet->OpCode);
//
// Set the GetInfo's return status according to the OpCode.
//
switch (OpCode) {
- case EFI_MTFTP6_OPCODE_ERROR:
- Context->Status = EFI_TFTP_ERROR;
- break;
+ case EFI_MTFTP6_OPCODE_ERROR:
+ Context->Status = EFI_TFTP_ERROR;
+ break;
- case EFI_MTFTP6_OPCODE_OACK:
- Context->Status = EFI_SUCCESS;
- break;
+ case EFI_MTFTP6_OPCODE_OACK:
+ Context->Status = EFI_SUCCESS;
+ break;
- default:
- Context->Status = EFI_PROTOCOL_ERROR;
+ default:
+ Context->Status = EFI_PROTOCOL_ERROR;
}
//
@@ -901,7 +882,6 @@ Mtftp6CheckPacket (
return EFI_ABORTED;
}
-
/**
Clean up the current Mtftp6 operation.
@@ -911,13 +891,13 @@ Mtftp6CheckPacket (
**/
VOID
Mtftp6OperationClean (
- IN MTFTP6_INSTANCE *Instance,
- IN EFI_STATUS Result
+ IN MTFTP6_INSTANCE *Instance,
+ IN EFI_STATUS Result
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- MTFTP6_BLOCK_RANGE *Block;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ MTFTP6_BLOCK_RANGE *Block;
//
// Clean up the current token and event.
@@ -927,6 +907,7 @@ Mtftp6OperationClean (
if (Instance->Token->Event != NULL) {
gBS->SignalEvent (Instance->Token->Event);
}
+
Instance->Token = NULL;
}
@@ -985,7 +966,6 @@ Mtftp6OperationClean (
Instance->IsMaster = TRUE;
}
-
/**
Start the Mtftp6 instance to perform the operation, such as read file,
write file, and read directory.
@@ -1002,37 +982,39 @@ Mtftp6OperationClean (
**/
EFI_STATUS
Mtftp6OperationStart (
- IN EFI_MTFTP6_PROTOCOL *This,
- IN EFI_MTFTP6_TOKEN *Token,
- IN UINT16 OpCode
+ IN EFI_MTFTP6_PROTOCOL *This,
+ IN EFI_MTFTP6_TOKEN *Token,
+ IN UINT16 OpCode
)
{
- MTFTP6_INSTANCE *Instance;
- EFI_STATUS Status;
-
- if (This == NULL ||
- Token == NULL ||
- Token->Filename == NULL ||
- (Token->OptionCount != 0 && Token->OptionList == NULL) ||
- (Token->OverrideData != NULL && !NetIp6IsValidUnicast (&Token->OverrideData->ServerIp))
- ) {
+ MTFTP6_INSTANCE *Instance;
+ EFI_STATUS Status;
+
+ if ((This == NULL) ||
+ (Token == NULL) ||
+ (Token->Filename == NULL) ||
+ ((Token->OptionCount != 0) && (Token->OptionList == NULL)) ||
+ ((Token->OverrideData != NULL) && !NetIp6IsValidUnicast (&Token->OverrideData->ServerIp))
+ )
+ {
return EFI_INVALID_PARAMETER;
}
//
// At least define one method to collect the data for download.
//
- if ((OpCode == EFI_MTFTP6_OPCODE_RRQ || OpCode == EFI_MTFTP6_OPCODE_DIR) &&
- Token->Buffer == NULL &&
- Token->CheckPacket == NULL
- ) {
+ if (((OpCode == EFI_MTFTP6_OPCODE_RRQ) || (OpCode == EFI_MTFTP6_OPCODE_DIR)) &&
+ (Token->Buffer == NULL) &&
+ (Token->CheckPacket == NULL)
+ )
+ {
return EFI_INVALID_PARAMETER;
}
//
// At least define one method to provide the data for upload.
//
- if (OpCode == EFI_MTFTP6_OPCODE_WRQ && Token->Buffer == NULL && Token->PacketNeeded == NULL) {
+ if ((OpCode == EFI_MTFTP6_OPCODE_WRQ) && (Token->Buffer == NULL) && (Token->PacketNeeded == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1055,7 +1037,6 @@ Mtftp6OperationStart (
// Parse the extension options in the request packet.
//
if (Token->OptionCount != 0) {
-
Status = Mtftp6ParseExtensionOption (
Token->OptionList,
Token->OptionCount,
@@ -1072,12 +1053,12 @@ Mtftp6OperationStart (
//
// Initialize runtime data from config data or override data.
//
- Instance->Token = Token;
- Instance->ServerCmdPort = Instance->Config->InitialServerPort;
- Instance->ServerDataPort = 0;
- Instance->MaxRetry = Instance->Config->TryCount;
- Instance->Timeout = Instance->Config->TimeoutValue;
- Instance->IsMaster = TRUE;
+ Instance->Token = Token;
+ Instance->ServerCmdPort = Instance->Config->InitialServerPort;
+ Instance->ServerDataPort = 0;
+ Instance->MaxRetry = Instance->Config->TryCount;
+ Instance->Timeout = Instance->Config->TimeoutValue;
+ Instance->IsMaster = TRUE;
CopyMem (
&Instance->ServerIp,
@@ -1103,15 +1084,19 @@ Mtftp6OperationStart (
if (Instance->ServerCmdPort == 0) {
Instance->ServerCmdPort = MTFTP6_DEFAULT_SERVER_CMD_PORT;
}
+
if (Instance->BlkSize == 0) {
Instance->BlkSize = MTFTP6_DEFAULT_BLK_SIZE;
}
+
if (Instance->WindowSize == 0) {
Instance->WindowSize = MTFTP6_DEFAULT_WINDOWSIZE;
}
+
if (Instance->MaxRetry == 0) {
Instance->MaxRetry = MTFTP6_DEFAULT_MAX_RETRY;
}
+
if (Instance->Timeout == 0) {
Instance->Timeout = MTFTP6_DEFAULT_TIMEOUT;
}
@@ -1122,21 +1107,21 @@ Mtftp6OperationStart (
// Switch the routines by the operation code.
//
switch (OpCode) {
- case EFI_MTFTP6_OPCODE_RRQ:
- Status = Mtftp6RrqStart (Instance, OpCode);
- break;
+ case EFI_MTFTP6_OPCODE_RRQ:
+ Status = Mtftp6RrqStart (Instance, OpCode);
+ break;
- case EFI_MTFTP6_OPCODE_DIR:
- Status = Mtftp6RrqStart (Instance, OpCode);
- break;
+ case EFI_MTFTP6_OPCODE_DIR:
+ Status = Mtftp6RrqStart (Instance, OpCode);
+ break;
- case EFI_MTFTP6_OPCODE_WRQ:
- Status = Mtftp6WrqStart (Instance, OpCode);
- break;
+ case EFI_MTFTP6_OPCODE_WRQ:
+ Status = Mtftp6WrqStart (Instance, OpCode);
+ break;
- default:
- Status = EFI_DEVICE_ERROR;
- goto ON_ERROR;
+ default:
+ Status = EFI_DEVICE_ERROR;
+ goto ON_ERROR;
}
if (EFI_ERROR (Status)) {
@@ -1152,6 +1137,7 @@ Mtftp6OperationStart (
while (Token->Status == EFI_NOT_READY) {
This->Poll (This);
}
+
return Token->Status;
}
@@ -1165,7 +1151,6 @@ ON_ERROR:
return Status;
}
-
/**
The timer ticking routine for the Mtftp6 instance.
@@ -1176,25 +1161,24 @@ ON_ERROR:
VOID
EFIAPI
Mtftp6OnTimerTick (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- MTFTP6_SERVICE *Service;
- MTFTP6_INSTANCE *Instance;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- EFI_MTFTP6_TOKEN *Token;
- EFI_STATUS Status;
+ MTFTP6_SERVICE *Service;
+ MTFTP6_INSTANCE *Instance;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ EFI_MTFTP6_TOKEN *Token;
+ EFI_STATUS Status;
- Service = (MTFTP6_SERVICE *) Context;
+ Service = (MTFTP6_SERVICE *)Context;
//
// Iterate through all the children of the Mtftp service instance. Time
// out the packet. If maximum retries reached, clean the session up.
//
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Service->Children) {
-
Instance = NET_LIST_USER_STRUCT (Entry, MTFTP6_INSTANCE, Link);
if (Instance->Token == NULL) {
@@ -1217,10 +1201,10 @@ Mtftp6OnTimerTick (
if (EFI_ERROR (Status)) {
Mtftp6SendError (
- Instance,
- EFI_MTFTP6_ERRORCODE_REQUEST_DENIED,
- (UINT8 *) "User aborted the transfer in time out"
- );
+ Instance,
+ EFI_MTFTP6_ERRORCODE_REQUEST_DENIED,
+ (UINT8 *)"User aborted the transfer in time out"
+ );
Mtftp6OperationClean (Instance, EFI_ABORTED);
continue;
}