Insert comments for functions/macros and add the file headers.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7293 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
niry 2009-01-16 06:56:18 +00:00
parent bd59b46eb4
commit dab714aa11
23 changed files with 1220 additions and 605 deletions

View File

@ -1,21 +1,15 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
UEFI Component Name(2) protocol implementation for Mtftp4Dxe driver.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
**/
#include "Mtftp4Driver.h"
@ -33,10 +27,10 @@ Abstract:
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language[in] A pointer to a Null-terminated ASCII string
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@ -45,7 +39,7 @@ Abstract:
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] A pointer to the Unicode string to return.
@param[out] DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@ -65,9 +59,9 @@ Abstract:
EFI_STATUS
EFIAPI
Mtftp4ComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
@ -84,15 +78,15 @@ Mtftp4ComponentNameGetDriverName (
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle[in] The handle of a controller that the driver
@param[in] ControllerHandle The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle[in] The handle of the child controller to retrieve
@param[in] ChildHandle The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
@ -101,7 +95,7 @@ Mtftp4ComponentNameGetDriverName (
driver that wishes to retrieve the name of a
child controller.
@param Language[in] A pointer to a Null-terminated ASCII string
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@ -110,7 +104,7 @@ Mtftp4ComponentNameGetDriverName (
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName[out] A pointer to the Unicode string to return.
@param[out] ControllerName A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
@ -142,26 +136,26 @@ Mtftp4ComponentNameGetDriverName (
EFI_STATUS
EFIAPI
Mtftp4ComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
///
/// EFI Component Name Protocol
///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMtftp4ComponentName = {
Mtftp4ComponentNameGetDriverName,
Mtftp4ComponentNameGetControllerName,
"eng"
};
//
// EFI Component Name 2 Protocol
//
///
/// EFI Component Name 2 Protocol
///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Mtftp4ComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Mtftp4ComponentNameGetControllerName,
@ -190,10 +184,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[]
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language[in] A pointer to a Null-terminated ASCII string
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@ -202,7 +196,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[]
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] A pointer to the Unicode string to return.
@param[out] DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@ -222,9 +216,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[]
EFI_STATUS
EFIAPI
Mtftp4ComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@ -249,15 +243,15 @@ Mtftp4ComponentNameGetDriverName (
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle[in] The handle of a controller that the driver
@param[in] ControllerHandle The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle[in] The handle of the child controller to retrieve
@param[in] ChildHandle The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
@ -266,7 +260,7 @@ Mtftp4ComponentNameGetDriverName (
driver that wishes to retrieve the name of a
child controller.
@param Language[in] A pointer to a Null-terminated ASCII string
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@ -275,7 +269,7 @@ Mtftp4ComponentNameGetDriverName (
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName[out] A pointer to the Unicode string to return.
@param[out] ControllerName A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
@ -307,11 +301,11 @@ Mtftp4ComponentNameGetDriverName (
EFI_STATUS
EFIAPI
Mtftp4ComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;

View File

@ -1,21 +1,15 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
Implementation of Mtftp drivers.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Driver.c
Abstract:
**/
#include "Mtftp4Impl.h"
@ -34,29 +28,23 @@ EFI_SERVICE_BINDING_PROTOCOL gMtftp4ServiceBindingTemplete = {
Mtftp4ServiceBindingDestroyChild
};
/**
The driver entry point which installs multiple protocols to the ImageHandle.
@param ImageHandle The MTFTP's image handle.
@param SystemTable The system table.
@retval EFI_SUCCESS The handles are successfully installed on the image.
@retval others some EFI_ERROR occured.
**/
EFI_STATUS
EFIAPI
Mtftp4DriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
The driver entry point which installs multiple protocols to the ImageHandle.
Arguments:
ImageHandle - The MTFTP's image handle
SystemTable - The system table
Returns:
EFI_SUCCESS - The handles are successfully installed on the image. Otherwise
some EFI_ERROR.
--*/
{
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@ -82,6 +70,7 @@ Returns:
**/
EFI_STATUS
EFIAPI
Mtftp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
@ -104,9 +93,10 @@ Mtftp4DriverBindingSupported (
/**
Config a NULL UDP that is used to keep the connection between UDP
and MTFTP. Just leave the Udp child unconfigured. When UDP is
unloaded, MTFTP will be informed with DriverBinding Stop.
Config a NULL UDP that is used to keep the connection between UDP and MTFTP.
Just leave the Udp child unconfigured. When UDP is unloaded,
MTFTP will be informed with DriverBinding Stop.
@param UdpIo The UDP port to configure
@param Context The opaque parameter to the callback
@ -142,9 +132,9 @@ Mtftp4ConfigNullUdp (
**/
EFI_STATUS
Mtftp4CreateService (
IN EFI_HANDLE Controller,
IN EFI_HANDLE Image,
OUT MTFTP4_SERVICE **Service
IN EFI_HANDLE Controller,
IN EFI_HANDLE Image,
OUT MTFTP4_SERVICE **Service
)
{
MTFTP4_SERVICE *MtftpSb;
@ -221,8 +211,6 @@ Mtftp4CreateService (
@param MtftpSb The MTFTP service binding instance.
@return None
**/
VOID
Mtftp4CleanService (
@ -236,8 +224,9 @@ Mtftp4CleanService (
/**
Start the MTFTP driver on this controller. MTFTP driver will
install a MTFTP SERVICE BINDING protocol on the supported
Start the MTFTP driver on this controller.
MTFTP driver will install a MTFTP SERVICE BINDING protocol on the supported
controller, which can be used to create/destroy MTFTP children.
@param This The MTFTP driver binding protocol.
@ -251,6 +240,7 @@ Mtftp4CleanService (
**/
EFI_STATUS
EFIAPI
Mtftp4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
@ -326,11 +316,12 @@ ON_ERROR:
**/
EFI_STATUS
EFIAPI
Mtftp4DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
{
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
@ -408,13 +399,11 @@ Mtftp4DriverBindingStop (
@param MtftpSb The MTFTP service binding protocol.
@param Instance The MTFTP instance to initialize.
@return None
**/
VOID
Mtftp4InitProtocol (
IN MTFTP4_SERVICE *MtftpSb,
IN MTFTP4_PROTOCOL *Instance
IN MTFTP4_SERVICE *MtftpSb,
OUT MTFTP4_PROTOCOL *Instance
)
{
ZeroMem (Instance, sizeof (MTFTP4_PROTOCOL));
@ -423,7 +412,7 @@ Mtftp4InitProtocol (
InitializeListHead (&Instance->Link);
CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4));
Instance->State = MTFTP4_STATE_UNCONFIGED;
Instance->Indestory = FALSE;
Instance->InDestory = FALSE;
Instance->Service = MtftpSb;
InitializeListHead (&Instance->Blocks);
@ -443,9 +432,10 @@ Mtftp4InitProtocol (
**/
EFI_STATUS
EFIAPI
Mtftp4ServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN OUT EFI_HANDLE *ChildHandle
IN EFI_HANDLE *ChildHandle
)
{
MTFTP4_SERVICE *MtftpSb;
@ -552,6 +542,7 @@ ON_ERROR:
**/
EFI_STATUS
EFIAPI
Mtftp4ServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
@ -590,11 +581,11 @@ Mtftp4ServiceBindingDestroyChild (
return EFI_INVALID_PARAMETER;
}
if (Instance->Indestory) {
if (Instance->InDestory) {
return EFI_SUCCESS;
}
Instance->Indestory = TRUE;
Instance->InDestory = TRUE;
//
// Close the Udp4 protocol.
@ -616,7 +607,7 @@ Mtftp4ServiceBindingDestroyChild (
);
if (EFI_ERROR (Status)) {
Instance->Indestory = FALSE;
Instance->InDestory = FALSE;
return Status;
}

View File

@ -1,70 +1,136 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
Mtftp drivers function header.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Driver.h
Abstract:
**/
#ifndef __EFI_MTFTP4_DRIVER_H__
#define __EFI_MTFTP4_DRIVER_H__
#include <PiDxe.h>
#include <Uefi.h>
#include <Protocol/ServiceBinding.h>
#include <Library/NetLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
extern EFI_COMPONENT_NAME_PROTOCOL gMtftp4ComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2;
extern EFI_DRIVER_BINDING_PROTOCOL gMtftp4DriverBinding;
/**
Test whether MTFTP driver support this controller.
@param This The MTFTP driver binding instance
@param Controller The controller to test
@param RemainingDevicePath The remaining device path
@retval EFI_SUCCESS The controller has UDP service binding protocol
installed, MTFTP can support it.
@retval Others MTFTP can't support the controller.
**/
EFI_STATUS
EFIAPI
Mtftp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
Start the MTFTP driver on this controller.
MTFTP driver will install a MTFTP SERVICE BINDING protocol on the supported
controller, which can be used to create/destroy MTFTP children.
@param This The MTFTP driver binding protocol.
@param Controller The controller to manage.
@param RemainingDevicePath Remaining device path.
@retval EFI_ALREADY_STARTED The MTFTP service binding protocol has been
started on the controller.
@retval EFI_SUCCESS The MTFTP service binding is installed on the
controller.
**/
EFI_STATUS
EFIAPI
Mtftp4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
Stop the MTFTP driver on controller. The controller is a UDP
child handle.
@param This The MTFTP driver binding protocol
@param Controller The controller to stop
@param NumberOfChildren The number of children
@param ChildHandleBuffer The array of the child handle.
@retval EFI_SUCCESS The driver is stopped on the controller.
@retval EFI_DEVICE_ERROR Failed to stop the driver on the controller.
**/
EFI_STATUS
EFIAPI
Mtftp4DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
/**
Create a MTFTP child for the service binding instance, then
install the MTFTP protocol to the ChildHandle.
@param This The MTFTP service binding instance.
@param ChildHandle The Child handle to install the MTFTP protocol.
@retval EFI_INVALID_PARAMETER The parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the new child.
@retval EFI_SUCCESS The child is successfully create.
**/
EFI_STATUS
EFIAPI
Mtftp4ServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN OUT EFI_HANDLE *ChildHandle
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE *ChildHandle
);
/**
Destory one of the service binding's child.
@param This The service binding instance
@param ChildHandle The child handle to destory
@retval EFI_INVALID_PARAMETER The parameter is invaid.
@retval EFI_UNSUPPORTED The child may have already been destoried.
@retval EFI_SUCCESS The child is destoried and removed from the
parent's child list.
**/
EFI_STATUS
EFIAPI
Mtftp4ServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
);
extern EFI_COMPONENT_NAME_PROTOCOL gMtftp4ComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2;
extern EFI_DRIVER_BINDING_PROTOCOL gMtftp4DriverBinding;
#endif

View File

@ -1,50 +1,41 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
Interface routine for Mtftp4.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Impl.c
Abstract:
Interface routine for Mtftp4
**/
#include "Mtftp4Impl.h"
EFI_STATUS
EFIAPI
EfiMtftp4ReadFile (
IN EFI_MTFTP4_PROTOCOL *This,
IN EFI_MTFTP4_TOKEN *Token
);
/**
Get the current operation parameter for the MTFTP session
Reads the current operational settings.
@param This The MTFTP protocol instance
@param ModeData The MTFTP mode data
The GetModeData()function reads the current operational settings of this
EFI MTFTPv4 Protocol driver instance.
@retval EFI_INVALID_PARAMETER This or ModeData is NULL
@retval EFI_SUCCESS The operation parameter is saved in ModeData
@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
IN EFI_MTFTP4_PROTOCOL *This,
OUT EFI_MTFTP4_MODE_DATA *ModeData
)
{
MTFTP4_PROTOCOL *Instance;
@ -75,14 +66,11 @@ EfiMtftp4GetModeData (
@param Instance The MTFTP session to clean up
@param Result The result to return to the caller who initiated
the operation.
@return None
**/
VOID
Mtftp4CleanOperation (
IN MTFTP4_PROTOCOL *Instance,
IN EFI_STATUS Result
IN OUT MTFTP4_PROTOCOL *Instance,
IN EFI_STATUS Result
)
{
LIST_ENTRY *Entry;
@ -145,15 +133,50 @@ Mtftp4CleanOperation (
/**
Configure the MTFTP session for new operation or reset the current
operation if ConfigData is NULL.
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
@param This The MTFTP session to configure
@param ConfigData The configure parameters
@retval EFI_INVALID_PARAMETER Some of the parameter is invalid.
@retval EFI_ACCESS_DENIED There is pending operation
@retval EFI_SUCCESS The instance is configured for operation.
@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
@ -213,7 +236,7 @@ EfiMtftp4Configure (
}
if ((Gateway != 0) &&
(!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) {
(!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) {
return EFI_INVALID_PARAMETER;
}
@ -236,9 +259,10 @@ EfiMtftp4Configure (
/**
Check packet for GetInfo. GetInfo is implemented with EfiMtftp4ReadFile.
It use Mtftp4GetInfoCheckPacket to inspect the first packet from server,
then abort the session.
Check packet for GetInfo.
GetInfo is implemented with EfiMtftp4ReadFile. It use Mtftp4GetInfoCheckPacket
to inspect the first packet from server, then abort the session.
@param This The MTFTP4 protocol instance
@param Token The user's token
@ -300,108 +324,43 @@ Mtftp4GetInfoCheckPacket (
/**
Get the information of the download from the server. It is implemented
with EfiMtftp4ReadFile: build a token, then pass it to EfiMtftp4ReadFile.
In its check packet callback abort the opertions.
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 The MTFTP protocol instance
@param OverrideData The MTFTP override data
@param Filename The file to get information
@param ModeStr The mode to use
@param OptionCount The number of options to append
@param OptionList The options to append
@param PacketLength The variable to receive the packet length
@param Packet The variable to receive the packet.
@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_INVALID_PARAMETER The parameter is invaid
@retval EFI_SUCCESS The information is got
@retval Others Failed to get the information.
**/
EFI_STATUS
EFIAPI
EfiMtftp4GetInfo (
IN EFI_MTFTP4_PROTOCOL *This,
IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData, OPTIONAL
IN UINT8 *Filename,
IN UINT8 *ModeStr, OPTIONAL
IN UINT8 OptionCount,
IN EFI_MTFTP4_OPTION *OptionList,
OUT UINT32 *PacketLength,
OUT EFI_MTFTP4_PACKET **Packet OPTIONAL
)
{
EFI_MTFTP4_TOKEN Token;
MTFTP4_PROTOCOL *Instance;
MTFTP4_GETINFO_STATE *State;
EFI_STATUS Status;
if ((This == NULL) || (Filename == NULL) || (PacketLength == NULL) ||
(OptionCount && (OptionList == NULL))) {
return EFI_INVALID_PARAMETER;
}
if (Packet != NULL) {
*Packet = NULL;
}
*PacketLength = 0;
Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
State = &Instance->GetInfoState;
State->Packet = Packet;
State->PacketLen = PacketLength;
State->Status = EFI_SUCCESS;
//
// Fill in the Token to issue an synchronous ReadFile operation
//
Token.Status = EFI_SUCCESS;
Token.Event = NULL;
Token.OverrideData = OverrideData;
Token.Filename = Filename;
Token.ModeStr = ModeStr;
Token.OptionCount = OptionCount;
Token.OptionList = OptionList;
Token.BufferSize = 0;
Token.Buffer = NULL;
Token.CheckPacket = Mtftp4GetInfoCheckPacket;
Token.TimeoutCallback = NULL;
Token.PacketNeeded = NULL;
Status = EfiMtftp4ReadFile (This, &Token);
if (EFI_ABORTED == Status) {
return State->Status;
}
return Status;
}
/**
Parse the packet into an array of options. The OptionList is allocated
by this function, and caller should free it when used.
@param This The MTFTP protocol instance
@param PacketLen The length of the packet
@param Packet The packet to parse
@param OptionCount The size of the OptionList array allocated.
@param OptionList The allocated option array to save the option
addresses.
@retval EFI_INVALID_PARAMETER The parameters are invalid.
@retval EFI_NOT_FOUND There is no valid option in the packet
@retval EFI_SUCCESS The packet is parsed.
@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,
IN OUT UINT32 *OptionCount,
OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
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;
@ -427,16 +386,18 @@ EfiMtftp4ParseOptions (
/**
Check whether the override data is valid. It will first
validate whether the server is a valid unicast. If a gateway
is provided in the Override, it also check that it is a
unicast on the connected network.
Check whether the override data is valid.
It will first validate whether the server is a valid unicast. If a gateway
is provided in the Override, it also check that it is a unicast on the
connected network.
@param Instance The MTFTP instance
@param Override The override data to validate.
@return TRUE if the override data is valid, otherwise FALSE.
@retval TRUE The override data is valid
@retval FALSE The override data is invalid
**/
BOOLEAN
Mtftp4OverrideValid (
@ -477,16 +438,18 @@ Mtftp4OverrideValid (
/**
Poll the UDP to get the IP4 default address, which may be retrieved
by DHCP. The default time out value is 5 seconds. If IP has retrieved
the default address, the UDP is reconfigured.
by DHCP.
The default time out value is 5 seconds. If IP has retrieved the default address,
the UDP is reconfigured.
@param Instance The Mtftp instance
@param UdpPort The UDP port to poll
@param UdpCfgData The UDP configure data to reconfigure the UDP
port.
@return TRUE if the default address is retrieved and UDP is reconfigured.
@return Otherwise FALSE.
@retval TRUE The default address is retrieved and UDP is reconfigured.
@retval FALSE Some error occured.
**/
BOOLEAN
@ -781,15 +744,32 @@ ON_ERROR:
/**
Read a file from the server.
Downloads a file from an MTFTPv4 server.
The ReadFile() function is used to initialize and start an MTFTPv4 download
process and optionally wait for completion. When the download operation completes,
whether successfully or not, the Token.Status field is updated by the EFI MTFTPv4
Protocol driver and then Token.Event is signaled (if it is not NULL).
Data can be downloaded from the MTFTPv4 server into either of the following locations:
1.A fixed buffer that is pointed to by Token.Buffer
2.A download service function that is pointed to by Token.CheckPacket
If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
will be called first. If the call is successful, the packet will be stored in
Token.Buffer.
@param This The Mtftp protocol instance.
@param Token The user's request wrap token.
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance
@param Token Pointer to the token structure to provide the
parameters that are used in this operation.
@retval EFI_SUCCESS The ReadFile has finished, the file has been
downloaded if it is synchronous operation,
otherwise it has been initated.
@retval Others Some error happened.
@retval EFI_SUCCESS The data file has been transferred successfully.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval EFI_BUFFER_TOO_SMALL BufferSize is not large enough to hold the downloaded
data in downloading process.
@retval EFI_ABORTED Current operation is aborted by user.
@retval EFI_ICMP_ERROR An ICMP ERROR packet was received.
@retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
@retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received.
@retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
**/
EFI_STATUS
@ -804,15 +784,53 @@ EfiMtftp4ReadFile (
/**
Upload a file to the server.
Sends a data file to an MTFTPv4 server. May be unsupported in some EFI implementations
@param This The MTFTP protocol session
@param Token The user's request wrap token.
The WriteFile() function is used to initialize an uploading operation with the
given option list and optionally wait for completion. If one or more of the
options is not supported by the server, the unsupported options are ignored and
a standard TFTP process starts instead. When the upload process completes,
whether successfully or not, Token.Event is signaled, and the EFI MTFTPv4 Protocol
driver updates Token.Status.
The caller can supply the data to be uploaded in the following two modes:
1.Through the user-provided buffer
2.Through a callback function
With the user-provided buffer, the Token.BufferSize field indicates the length
of the buffer, and the driver will upload the data in the buffer. With an
EFI_MTFTP4_PACKET_NEEDED callback function, the driver will call this callback
function to get more data from the user to upload. See the definition of
EFI_MTFTP4_PACKET_NEEDED for more information. These two modes cannot be used at
the same time. The callback function will be ignored if the user provides the buffer.
@retval EFI_SUCCESS The WriteFile has finished, the file has been
uploaded if it is synchronous operation, otherwise
it has been initated.
@retval Others Some error happened.
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
@param Token Pointer to the token structure to provide the
parameters that are used in this function
@retval EFI_SUCCESS The upload session has started.
@retval EFI_UNSUPPORTED The operation is not supported by this implementation.
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1. This is NULL.
2. Token is NULL.
3. Token.Filename is NULL.
4. Token.OptionCount is not zero and
Token.OptionList is NULL.
5. One or more options in Token.OptionList have wrong
format.
6. Token.Buffer and Token.PacketNeeded are both
NULL.
7. One or more IPv4 addresses in Token.OverrideData
are not valid unicast IPv4 addresses if
Token.OverrideData is not NULL.
@retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in the
unsupported list of structure EFI_MTFTP4_MODE_DATA.
@retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
@retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
BOOTP, RARP, etc.) is not finished yet.
@retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4
session.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval EFI_ACCESS_DENIED The previous operation has not completed yet.
@retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
**/
EFI_STATUS
@ -827,16 +845,62 @@ EfiMtftp4WriteFile (
/**
Read a directory from the server. The only difference
between ReadFile and ReadDirectory is the opcode used.
Downloads a data file "directory" from an MTFTPv4 server.
May be unsupported in some EFI implementations
The ReadDirectory() function is used to return a list of files on the MTFTPv4
server that are logically (or operationally) related to Token.Filename. The
directory request packet that is sent to the server is built with the option
list that was provided by caller, if present.
The file information that the server returns is put into either of the following
locations:
1.A fixed buffer that is pointed to by Token.Buffer
2.A download service function that is pointed to by Token.CheckPacket
If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket will
be called first. If the call is successful, the packet will be stored in Token.Buffer.
The returned directory listing in the Token.Buffer or EFI_MTFTP4_PACKET consists
of a list of two or three variable-length ASCII strings, each terminated by a
null character, for each file in the directory. If the multicast option is involved,
the first field of each directory entry is the static multicast IP address and
UDP port number that is associated with the file name. The format of the field
is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its
terminating null character are not present.
The next field of each directory entry is the file name and the last field is
the file information string. The information string contains the file size and
the create/modify timestamp. The format of the information string is filesize
yyyy-mm-dd hh:mm:ss:ffff. The timestamp is Coordinated Universal Time
(UTC; also known as Greenwich Mean Time [GMT]).
The only difference between ReadFile and ReadDirectory is the opcode used.
@param This The MTFTP protocol session
@param Token The user's request wrap token.
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance
@param Token Pointer to the token structure to provide the
parameters that are used in this function
@retval EFI_SUCCESS The ReadDirectory has finished, the directory has
been downloaded as a file if it is synchronous
operation, otherwise it has been initated.
@retval Others Some error happened.
@retval EFI_SUCCESS The MTFTPv4 related file "directory" has been downloaded.
@retval EFI_UNSUPPORTED The operation is not supported by this implementation.
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1. This is NULL.
2. Token is NULL.
3. Token.Filename is NULL.
4. Token.OptionCount is not zero and
Token.OptionList is NULL.
5. One or more options in Token.OptionList have wrong
format.
6. Token.Buffer and Token.PacketNeeded are both
NULL.
7. One or more IPv4 addresses in Token.OverrideData
are not valid unicast IPv4 addresses if
Token.OverrideData is not NULL.
@retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in the
unsupported list of structure EFI_MTFTP4_MODE_DATA.
@retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
@retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
BOOTP, RARP, etc.) is not finished yet.
@retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4
session.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval EFI_ACCESS_DENIED The previous operation has not completed yet.
@retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
**/
EFI_STATUS
@ -851,13 +915,139 @@ EfiMtftp4ReadDirectory (
/**
Poll the network stack to accelerate the packet process.
Gets information about a file from an MTFTPv4 server.
The GetInfo() function assembles an MTFTPv4 request packet with options;
sends it to the MTFTPv4 server; and may return an MTFTPv4 OACK, MTFTPv4 ERROR,
or ICMP ERROR packet. Retries occur only if no response packets are received
from the MTFTPv4 server before the timeout expires.
It is implemented with EfiMtftp4ReadFile: build a token, then pass it to
EfiMtftp4ReadFile. In its check packet callback abort the opertions.
@param This The MTFTP protocol instance.
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance
@param OverrideData Data that is used to override the existing
parameters. If NULL, the default parameters that
were set in the EFI_MTFTP4_PROTOCOL.Configure()
function are used
@param Filename Pointer to ASCIIZ file name string
@param ModeStr Pointer to ASCIIZ mode string. If NULL, "octet"
will be used
@param OptionCount Number of option/value string pairs in OptionList
@param OptionList Pointer to array of option/value string pairs.
Ignored if OptionCount is zero
@param PacketLength The number of bytes in the returned packet
@param Packet PacketThe pointer to the received packet. This
buffer must be freed by the caller.
@retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in
the Buffer.
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1.This is NULL.
2.Filename is NULL.
3.OptionCount is not zero and OptionList is NULL.
4.One or more options in OptionList have wrong format.
5.PacketLength is NULL.
6.One or more IPv4 addresses in OverrideData are
not valid unicast IPv4 addresses if OverrideData
is not NULL.
@retval EFI_UNSUPPORTED One or more options in the OptionList are in the
unsupported list of structure EFI_MTFTP4_MODE_DATA
@retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
@retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
BOOTP, RARP, etc.) has not finished yet.
@retval EFI_ACCESS_DENIED The previous operation has not completed yet.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in
the Buffer.
@retval EFI_ICMP_ERROR An ICMP ERROR packet was received and the Packet
is set to NULL.
@retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is
in the Buffer.
@retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
@retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
**/
EFI_STATUS
EFIAPI
EfiMtftp4GetInfo (
IN EFI_MTFTP4_PROTOCOL *This,
IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData OPTIONAL,
IN UINT8 *Filename,
IN UINT8 *ModeStr OPTIONAL,
IN UINT8 OptionCount,
IN EFI_MTFTP4_OPTION *OptionList OPTIONAL,
OUT UINT32 *PacketLength,
OUT EFI_MTFTP4_PACKET **Packet OPTIONAL
)
{
EFI_MTFTP4_TOKEN Token;
MTFTP4_PROTOCOL *Instance;
MTFTP4_GETINFO_STATE *State;
EFI_STATUS Status;
if ((This == NULL) || (Filename == NULL) || (PacketLength == NULL) ||
((OptionCount != 0) && (OptionList == NULL))) {
return EFI_INVALID_PARAMETER;
}
if (Packet != NULL) {
*Packet = NULL;
}
*PacketLength = 0;
Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
State = &Instance->GetInfoState;
State->Packet = Packet;
State->PacketLen = PacketLength;
State->Status = EFI_SUCCESS;
//
// Fill in the Token to issue an synchronous ReadFile operation
//
Token.Status = EFI_SUCCESS;
Token.Event = NULL;
Token.OverrideData = OverrideData;
Token.Filename = Filename;
Token.ModeStr = ModeStr;
Token.OptionCount = OptionCount;
Token.OptionList = OptionList;
Token.BufferSize = 0;
Token.Buffer = NULL;
Token.CheckPacket = Mtftp4GetInfoCheckPacket;
Token.TimeoutCallback = NULL;
Token.PacketNeeded = NULL;
Status = EfiMtftp4ReadFile (This, &Token);
if (EFI_ABORTED == Status) {
return State->Status;
}
return Status;
}
/**
Polls for incoming data packets and processes outgoing data packets.
The Poll() function can be used by network drivers and applications to increase
the rate that data packets are moved between the communications device and the
transmit and receive queues.
In some systems, the periodic timer event in the managed network driver may not
poll the underlying communications device fast enough to transmit and/or receive
all data packets without missing incoming packets or dropping outgoing packets.
Drivers and applications that are experiencing packet loss should try calling
the Poll() function more often.
@param This Pointer to the EFI_MTFTP4_PROTOCOL instance
@retval EFI_SUCCESS Incoming or outgoing data was processed.
@retval EFI_NOT_STARTED This EFI MTFTPv4 Protocol instance has not been started.
@retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
BOOTP, RARP, etc.) is not finished yet.
@retval EFI_INVALID_PARAMETER This is NULL.
@retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
@retval EFI_DEVICE_ERROR The MTFTP session has been destoried.
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
@retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
queue. Consider increasing the polling rate.
**/
EFI_STATUS

View File

@ -1,46 +1,39 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
Mtftp4 Implementation.
Mtftp4 Implementation, it supports the following RFCs:
RFC1350 - THE TFTP PROTOCOL (REVISION 2)
RFC2090 - TFTP Multicast Option
RFC2347 - TFTP Option Extension
RFC2348 - TFTP Blocksize Option
RFC2349 - TFTP Timeout Interval and Transfer Size Options
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Impl.h
Abstract:
Mtftp4 Implementation, it supports the following RFCs:
RFC1350 - THE TFTP PROTOCOL (REVISION 2)
RFC2090 - TFTP Multicast Option
RFC2347 - TFTP Option Extension
RFC2348 - TFTP Blocksize Option
RFC2349 - TFTP Timeout Interval and Transfer Size Options
**/
#ifndef __EFI_MTFTP4_IMPL_H__
#define __EFI_MTFTP4_IMPL_H__
#include <PiDxe.h>
#include <Uefi.h>
#include <Protocol/Udp4.h>
#include <Protocol/Mtftp4.h>
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/UdpIoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;
typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;
typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
@ -49,7 +42,11 @@ typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
#include "Mtftp4Option.h"
#include "Mtftp4Support.h"
enum {
///
/// Some constant value of Mtftp service.
///
typedef enum {
MTFTP4_SERVICE_SIGNATURE = SIGNATURE_32 ('T', 'F', 'T', 'P'),
MTFTP4_PROTOCOL_SIGNATURE = SIGNATURE_32 ('t', 'f', 't', 'p'),
@ -62,8 +59,11 @@ enum {
MTFTP4_STATE_UNCONFIGED = 0,
MTFTP4_STATE_CONFIGED,
MTFTP4_STATE_DESTORY
};
} MTFTP4_SERVICE_CONST_VALUE;
///
/// Mtftp service block
///
struct _MTFTP4_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
@ -86,6 +86,7 @@ struct _MTFTP4_SERVICE {
UDP_IO_PORT *ConnectUdp;
};
typedef struct {
EFI_MTFTP4_PACKET **Packet;
UINT32 *PacketLen;
@ -98,7 +99,7 @@ struct _MTFTP4_PROTOCOL {
EFI_MTFTP4_PROTOCOL Mtftp4;
INTN State;
BOOLEAN Indestory;
BOOLEAN InDestory;
MTFTP4_SERVICE *Service;
EFI_HANDLE Handle;
@ -150,22 +151,57 @@ struct _MTFTP4_PROTOCOL {
MTFTP4_GETINFO_STATE GetInfoState;
};
/**
Clean up the MTFTP session to get ready for new operation.
@param Instance The MTFTP session to clean up
@param Result The result to return to the caller who initiated
the operation.
**/
VOID
Mtftp4CleanOperation (
IN MTFTP4_PROTOCOL *Instance,
IN EFI_STATUS Result
IN OUT MTFTP4_PROTOCOL *Instance,
IN EFI_STATUS Result
);
/**
Start the MTFTP session for upload.
It will first init some states, then send the WRQ request packet,
and start receiving the packet.
@param Instance The MTFTP session
@param Operation Redundant parameter, which is always
EFI_MTFTP4_OPCODE_WRQ here.
@retval EFI_SUCCESS The upload process has been started.
@retval Others Failed to start the upload.
**/
EFI_STATUS
Mtftp4WrqStart (
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 Operation
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 Operation
);
/**
Start the MTFTP session to download.
It will first initialize some of the internal states then build and send a RRQ
reqeuest packet, at last, it will start receive for the downloading.
@param Instance The Mtftp session
@param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ
or EFI_MTFTP4_OPCODE_DIR.
@retval EFI_SUCCESS The mtftp download session is started.
@retval Others Failed to start downloading.
**/
EFI_STATUS
Mtftp4RrqStart (
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 Operation
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 Operation
);
#define MTFTP4_SERVICE_FROM_THIS(a) \
@ -174,5 +210,4 @@ Mtftp4RrqStart (
#define MTFTP4_PROTOCOL_FROM_THIS(a) \
CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)
extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;
#endif

View File

@ -1,22 +1,15 @@
/** @file
Copyright (c) 2006, Intel Corporation
Routines to process MTFTP4 options.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Option.c
Abstract:
routines to process MTFTP4 options
**/
#include "Mtftp4Impl.h"
@ -46,10 +39,10 @@ CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = {
**/
EFI_STATUS
Mtftp4FillOptions (
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
IN OUT UINT32 *Count,
OUT EFI_MTFTP4_OPTION *Options OPTIONAL
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
IN OUT UINT32 *Count,
OUT EFI_MTFTP4_OPTION *Options OPTIONAL
)
{
UINT8 *Cur;
@ -103,8 +96,9 @@ Mtftp4FillOptions (
/**
Allocate and fill in a array of Mtftp options from the Packet. It
first calls Mtftp4FillOption to get the option number, then allocate
Allocate and fill in a array of Mtftp options from the Packet.
It first calls Mtftp4FillOption to get the option number, then allocate
the array, at last, call Mtftp4FillOption again to save the options.
@param Packet The packet to parse
@ -120,10 +114,10 @@ Mtftp4FillOptions (
**/
EFI_STATUS
Mtftp4ExtractOptions (
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
IN OUT UINT32 *OptionCount,
OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
OUT UINT32 *OptionCount,
OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
)
{
EFI_STATUS Status;
@ -189,8 +183,8 @@ Mtftp4ExtractOptions (
**/
BOOLEAN
NetStringEqualNoCase (
IN UINT8 *Str1,
IN UINT8 *Str2
IN UINT8 *Str1,
IN UINT8 *Str2
)
{
UINT8 Ch1;
@ -232,7 +226,7 @@ NetStringEqualNoCase (
**/
UINT32
NetStringToU32 (
IN UINT8 *Str
IN UINT8 *Str
)
{
UINT32 Num;
@ -261,8 +255,8 @@ NetStringToU32 (
**/
EFI_STATUS
NetStringToIp (
IN UINT8 *Str,
OUT IP4_ADDR *Ip
IN UINT8 *Str,
OUT IP4_ADDR *Ip
)
{
UINT32 Byte;
@ -317,8 +311,8 @@ NetStringToIp (
**/
EFI_STATUS
Mtftp4ExtractMcast (
IN UINT8 *Value,
IN MTFTP4_OPTION *Option
IN UINT8 *Value,
IN OUT MTFTP4_OPTION *Option
)
{
EFI_STATUS Status;
@ -337,7 +331,7 @@ Mtftp4ExtractMcast (
return Status;
}
while (*Value && (*Value != ',')) {
while ((*Value != 0) && (*Value != ',')) {
Value++;
}
}
@ -361,7 +355,7 @@ Mtftp4ExtractMcast (
return EFI_INVALID_PARAMETER;
}
Option->McastPort = (UINT16)Num;
Option->McastPort = (UINT16) Num;
while (NET_IS_DIGIT (*Value)) {
Value++;
@ -383,7 +377,7 @@ Mtftp4ExtractMcast (
return EFI_INVALID_PARAMETER;
}
Option->Master = (BOOLEAN)(Num == 1);
Option->Master = (BOOLEAN) (Num == 1);
while (NET_IS_DIGIT (*Value)) {
Value++;
@ -402,7 +396,7 @@ Mtftp4ExtractMcast (
can access directly.
@param Options The option array, which contains addresses of each
option's name/value string.
option's name/value string.
@param Count The number of options in the Options
@param Request Whether this is a request or OACK. The format of
multicast is different according to this setting.
@ -415,10 +409,10 @@ Mtftp4ExtractMcast (
**/
EFI_STATUS
Mtftp4ParseOption (
IN EFI_MTFTP4_OPTION *Options,
IN UINT32 Count,
IN BOOLEAN Request,
OUT MTFTP4_OPTION *MtftpOption
IN EFI_MTFTP4_OPTION *Options,
IN UINT32 Count,
IN BOOLEAN Request,
OUT MTFTP4_OPTION *MtftpOption
)
{
EFI_STATUS Status;
@ -515,9 +509,9 @@ Mtftp4ParseOption (
**/
EFI_STATUS
Mtftp4ParseOptionOack (
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
OUT MTFTP4_OPTION *MtftpOption
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
OUT MTFTP4_OPTION *MtftpOption
)
{
EFI_MTFTP4_OPTION *OptionList;

View File

@ -1,29 +1,24 @@
/** @file
Copyright (c) 2006, Intel Corporation
Routines to process MTFTP4 options.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Option.h
Abstract:
Mtftp4 option process routines.
**/
#ifndef __EFI_MTFTP4_OPTION_H__
#define __EFI_MTFTP4_OPTION_H__
enum {
typedef enum {
MTFTP4_SUPPORTED_OPTIONS = 4,
MTFTP4_OPCODE_LEN = 2,
MTFTP4_ERRCODE_LEN = 2,
@ -34,7 +29,7 @@ enum {
MTFTP4_TIMEOUT_EXIST = 0x02,
MTFTP4_TSIZE_EXIST = 0x04,
MTFTP4_MCAST_EXIST = 0x08
};
} MTFTP4_OPTION_CONST_VALUE;
typedef struct {
UINT16 BlkSize;
@ -46,28 +41,75 @@ typedef struct {
UINT32 Exist;
} MTFTP4_OPTION;
/**
Allocate and fill in a array of Mtftp options from the Packet.
It first calls Mtftp4FillOption to get the option number, then allocate
the array, at last, call Mtftp4FillOption again to save the options.
@param Packet The packet to parse
@param PacketLen The length of the packet
@param OptionCount The number of options in the packet
@param OptionList The point to get the option array.
@retval EFI_INVALID_PARAMETER The parametera are invalid or packet isn't a
well-formated OACK packet.
@retval EFI_SUCCESS The option array is build
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array
**/
EFI_STATUS
Mtftp4ExtractOptions (
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
IN OUT UINT32 *OptionCount,
OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
OUT UINT32 *OptionCount,
OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
);
/**
Parse the option in Options array to MTFTP4_OPTION which program
can access directly.
@param Options The option array, which contains addresses of each
option's name/value string.
@param Count The number of options in the Options
@param Request Whether this is a request or OACK. The format of
multicast is different according to this setting.
@param MtftpOption The MTFTP4_OPTION for easy access.
@retval EFI_INVALID_PARAMETER The option is mal-formated
@retval EFI_UNSUPPORTED Some option isn't supported
@retval EFI_SUCCESS The option are OK and has been parsed.
**/
EFI_STATUS
Mtftp4ParseOption (
IN EFI_MTFTP4_OPTION *OptionList,
IN UINT32 Count,
IN BOOLEAN Request,
OUT MTFTP4_OPTION *Option
IN EFI_MTFTP4_OPTION *Options,
IN UINT32 Count,
IN BOOLEAN Request,
OUT MTFTP4_OPTION *MtftpOption
);
/**
Parse the options in the OACK packet to MTFTP4_OPTION which program
can access directly.
@param Packet The OACK packet to parse
@param PacketLen The length of the packet
@param MtftpOption The MTFTP_OPTION for easy access.
@retval EFI_INVALID_PARAMETER The packet option is mal-formated
@retval EFI_UNSUPPORTED Some option isn't supported
@retval EFI_SUCCESS The option are OK and has been parsed.
**/
EFI_STATUS
Mtftp4ParseOptionOack (
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
OUT MTFTP4_OPTION *Option
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 PacketLen,
OUT MTFTP4_OPTION *MtftpOption
);
extern CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];
#endif

View File

@ -1,27 +1,30 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
Routines to process Rrq (download).
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Rrq.c
Abstract:
Routines to process Rrq (download)
**/
#include "Mtftp4Impl.h"
/**
The packet process callback for MTFTP download.
@param UdpPacket The packet received
@param Points The local/remote access point of the packet
@param IoStatus The status of the receiving
@param Context Opaque parameter, which is the MTFTP session
**/
VOID
Mtftp4RrqInput (
IN NET_BUF *UdpPacket,
@ -32,9 +35,10 @@ Mtftp4RrqInput (
/**
Start the MTFTP session to download. It will first initialize some
of the internal states then build and send a RRQ reqeuest packet, at
last, it will start receive for the downloading.
Start the MTFTP session to download.
It will first initialize some of the internal states then build and send a RRQ
reqeuest packet, at last, it will start receive for the downloading.
@param Instance The Mtftp session
@param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ
@ -130,9 +134,9 @@ Mtftp4RrqSendAck (
**/
EFI_STATUS
Mtftp4RrqSaveBlock (
IN MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len
IN OUT MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len
)
{
EFI_MTFTP4_TOKEN *Token;
@ -215,8 +219,9 @@ Mtftp4RrqSaveBlock (
/**
Function to process the received data packets. It will save the block
then send back an ACK if it is active.
Function to process the received data packets.
It will save the block then send back an ACK if it is active.
@param Instance The downloading MTFTP session
@param Packet The packet received
@ -231,11 +236,11 @@ Mtftp4RrqSaveBlock (
**/
EFI_STATUS
Mtftp4RrqHandleData (
IN MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
IN BOOLEAN Multicast,
OUT BOOLEAN *Completed
IN MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
IN BOOLEAN Multicast,
OUT BOOLEAN *Completed
)
{
EFI_STATUS Status;
@ -304,6 +309,7 @@ Mtftp4RrqHandleData (
/**
Validate whether the options received in the server's OACK packet is valid.
The options are valid only if:
1. The server doesn't include options not requested by us
2. The server can only use smaller blksize than that is requested
@ -314,7 +320,8 @@ Mtftp4RrqHandleData (
@param Reply The options in the OACK packet
@param Request The requested options
@return TRUE if the options in the OACK is OK, otherwise FALSE.
@retval TRUE The options in the OACK is OK.
@retval FALSE The options in the OACK is invalid.
**/
BOOLEAN
@ -336,8 +343,8 @@ Mtftp4RrqOackValid (
// Server can only specify a smaller block size to be used and
// return the timeout matches that requested.
//
if (((Reply->Exist & MTFTP4_BLKSIZE_EXIST) && (Reply->BlkSize > Request->BlkSize)) ||
((Reply->Exist & MTFTP4_TIMEOUT_EXIST) && (Reply->Timeout != Request->Timeout))) {
if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) != 0)&& (Reply->BlkSize > Request->BlkSize)) ||
(((Reply->Exist & MTFTP4_TIMEOUT_EXIST) != 0) && (Reply->Timeout != Request->Timeout))) {
return FALSE;
}
@ -346,7 +353,7 @@ Mtftp4RrqOackValid (
// setting. But if it use the specific multicast channel, it can't
// change the setting.
//
if ((Reply->Exist & MTFTP4_MCAST_EXIST) && (This->McastIp != 0)) {
if (((Reply->Exist & MTFTP4_MCAST_EXIST) != 0) && (This->McastIp != 0)) {
if ((Reply->McastIp != 0) && (Reply->McastIp != This->McastIp)) {
return FALSE;
}
@ -367,7 +374,7 @@ Mtftp4RrqOackValid (
@param Context The opaque parameter to the function which is the
MTFTP session.
@retval EFI_SUCCESS The udp child is successfully configured.
@retval EFI_SUCCESS The UDP child is successfully configured.
@retval Others Failed to configure the UDP child.
**/
@ -411,12 +418,20 @@ Mtftp4RrqConfigMcastPort (
return Status;
}
if (!Config->UseDefaultSetting && !EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp)) {
if (!Config->UseDefaultSetting &&
!EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp)) {
//
// The station IP address is manually configured and the Gateway IP is not 0.
// Add the default route for this UDP instance.
//
Status = McastIo->Udp->Routes (McastIo->Udp, FALSE, &mZeroIp4Addr, &mZeroIp4Addr, &Config->GatewayIp);
Status = McastIo->Udp->Routes (
McastIo->Udp,
FALSE,
&mZeroIp4Addr,
&mZeroIp4Addr,
&Config->GatewayIp
);
if (EFI_ERROR (Status)) {
McastIo->Udp->Configure (McastIo->Udp, NULL);
return Status;
@ -434,8 +449,9 @@ Mtftp4RrqConfigMcastPort (
/**
Function to process the OACK. It will first validate the OACK
packet, then update the various negotiated parameters.
Function to process the OACK.
It will first validate the OACK packet, then update the various negotiated parameters.
@param Instance The download MTFTP session
@param Packet The packet received
@ -451,11 +467,11 @@ Mtftp4RrqConfigMcastPort (
**/
EFI_STATUS
Mtftp4RrqHandleOack (
IN MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
IN BOOLEAN Multicast,
OUT BOOLEAN *Completed
IN OUT MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
IN BOOLEAN Multicast,
OUT BOOLEAN *Completed
)
{
MTFTP4_OPTION Reply;
@ -498,7 +514,7 @@ Mtftp4RrqHandleOack (
return EFI_TFTP_ERROR;
}
if (Reply.Exist & MTFTP4_MCAST_EXIST) {
if ((Reply.Exist & MTFTP4_MCAST_EXIST) != 0) {
//
// Save the multicast info. Always update the Master, only update the
@ -586,8 +602,6 @@ Mtftp4RrqHandleOack (
@param IoStatus The status of the receiving
@param Context Opaque parameter, which is the MTFTP session
@return None
**/
VOID
Mtftp4RrqInput (
@ -716,6 +730,9 @@ Mtftp4RrqInput (
case EFI_MTFTP4_OPCODE_ERROR:
Status = EFI_TFTP_ERROR;
break;
default:
break;
}
ON_EXIT:

View File

@ -1,36 +1,27 @@
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
Support routines for Mtftp.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Support.c
Abstract:
Support routines for Mtftp
**/
#include "Mtftp4Impl.h"
/**
Allocate a MTFTP4 block range, then init it to the
range of [Start, End]
Allocate a MTFTP4 block range, then init it to the range of [Start, End]
@param Start The start block number
@param End The last block number in the range
@return NULL if failed to allocate memory, otherwise the created block range.
@return Pointer to the created block range, NULL if failed to allocate memory.
**/
MTFTP4_BLOCK_RANGE *
@ -56,16 +47,17 @@ Mtftp4AllocateRange (
/**
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 bacause 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.
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 bacause 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.
@param Head The block range head to initialize
@param Start The Start block number.
@ -100,7 +92,7 @@ Mtftp4InitBlockRange (
@param Head The block range head
@return -1: if the block range is empty. Otherwise the first valid block number.
@return The first valid block number, -1 if the block range is empty.
**/
INTN
@ -120,17 +112,15 @@ Mtftp4GetNextBlockNum (
/**
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.
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.
@param Head The block range list
@param Last The last block number
@return None
**/
VOID
Mtftp4SetLastBlockNum (
@ -321,10 +311,11 @@ Mtftp4SendRequest (
/**
Build then send an error message
Build then send an error message.
@param Instance The MTFTP session
@param ErrInfo The error code and message
@param ErrCode The error code
@param ErrInfo The error message
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the error packet
@retval EFI_SUCCESS The error packet is transmitted.
@ -335,7 +326,7 @@ EFI_STATUS
Mtftp4SendError (
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 ErrCode,
IN UINT8* ErrInfo
IN UINT8 *ErrInfo
)
{
NET_BUF *Packet;
@ -361,6 +352,7 @@ Mtftp4SendError (
/**
The callback function called when the packet is transmitted.
It simply frees the packet.
@param Packet The transmitted (or failed to) packet
@ -368,8 +360,6 @@ Mtftp4SendError (
@param IoStatus The result of the transmission
@param Context Opaque parameter to the callback
@return None
**/
VOID
Mtftp4OnPacketSent (
@ -384,17 +374,14 @@ Mtftp4OnPacketSent (
/**
Set the timeout for the instance. User a longer time for
passive instances.
Set the timeout for the instance. User a longer time for passive instances.
@param Instance The Mtftp session to set time out
@return None
**/
VOID
Mtftp4SetTimeout (
IN MTFTP4_PROTOCOL *Instance
IN OUT MTFTP4_PROTOCOL *Instance
)
{
if (Instance->Master) {
@ -406,10 +393,11 @@ Mtftp4SetTimeout (
/**
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.
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.
@param Instance The Mtftp instance
@param Packet The packet to send
@ -420,8 +408,8 @@ Mtftp4SetTimeout (
**/
EFI_STATUS
Mtftp4SendPacket (
IN MTFTP4_PROTOCOL *Instance,
IN NET_BUF *Packet
IN OUT MTFTP4_PROTOCOL *Instance,
IN OUT NET_BUF *Packet
)
{
UDP_POINTS UdpPoint;
@ -452,7 +440,8 @@ Mtftp4SendPacket (
Value = *((UINT16 *) NetbufGetByte (Packet, 0, NULL));
OpCode = NTOHS (Value);
if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || (OpCode == EFI_MTFTP4_OPCODE_DIR) ||
if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) ||
(OpCode == EFI_MTFTP4_OPCODE_DIR) ||
(OpCode == EFI_MTFTP4_OPCODE_WRQ)) {
UdpPoint.RemotePort = Instance->ListeningPort;
} else {
@ -479,7 +468,7 @@ Mtftp4SendPacket (
/**
Retransmit the last packet for the instance
Retransmit the last packet for the instance.
@param Instance The Mtftp instance
@ -541,8 +530,6 @@ Mtftp4Retransmit (
@param Event The ticking event
@param Context The Mtftp service instance
@return None
**/
VOID
EFIAPI

View File

@ -1,23 +1,15 @@
/** @file
Copyright (c) 2006, Intel Corporation
Support routines for MTFTP.
Copyright (c) 2006, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Support.h
Abstract:
Support routines for MTFTP
**/
#ifndef __EFI_MTFTP4_SUPPORT_H__
@ -35,6 +27,27 @@ typedef struct {
} MTFTP4_BLOCK_RANGE;
/**
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 bacause 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.
@param Head The block range head to initialize
@param Start The Start block number.
@param End The last block number.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for initial block range
@retval EFI_SUCCESS The initial block range is created.
**/
EFI_STATUS
Mtftp4InitBlockRange (
IN LIST_ENTRY *Head,
@ -42,51 +55,139 @@ Mtftp4InitBlockRange (
IN UINT16 End
);
/**
Get the first valid block number on the range list.
@param Head The block range head
@return The first valid block number, -1 if the block range is empty.
**/
INTN
Mtftp4GetNextBlockNum (
IN LIST_ENTRY *Head
);
/**
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.
@param Head The block range list
@param Last The last block number
**/
VOID
Mtftp4SetLastBlockNum (
IN LIST_ENTRY *Head,
IN UINT16 Last
);
/**
Remove the block number from the block range list.
@param Head The block range list to remove from
@param Num The block number to remove
@retval EFI_NOT_FOUND The block number isn't in the block range list
@retval EFI_SUCCESS The block number has been removed from the list
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource
**/
EFI_STATUS
Mtftp4RemoveBlockNum (
IN LIST_ENTRY *Head,
IN UINT16 Num
);
/**
Set the timeout for the instance. User a longer time for passive instances.
@param Instance The Mtftp session to set time out
**/
VOID
Mtftp4SetTimeout (
IN MTFTP4_PROTOCOL *Instance
IN OUT MTFTP4_PROTOCOL *Instance
);
/**
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.
@param Instance The Mtftp instance
@param Packet The packet to send
@retval EFI_SUCCESS The packet is sent out
@retval Others Failed to transmit the packet.
**/
EFI_STATUS
Mtftp4SendPacket (
IN MTFTP4_PROTOCOL *Instance,
IN NET_BUF *Packet
IN OUT MTFTP4_PROTOCOL *Instance,
IN OUT NET_BUF *Packet
);
/**
Build then transmit the request packet for the MTFTP session.
@param Instance The Mtftp session
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the request
@retval EFI_SUCCESS The request is built and sent
@retval Others Failed to transmit the packet.
**/
EFI_STATUS
Mtftp4SendRequest (
IN MTFTP4_PROTOCOL *Instance
);
/**
Build then send an error message.
@param Instance The MTFTP session
@param ErrCode The error code
@param ErrInfo The error message
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the error packet
@retval EFI_SUCCESS The error packet is transmitted.
@retval Others Failed to transmit the packet.
**/
EFI_STATUS
Mtftp4SendError (
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 ErrCode,
IN UINT8* ErrInfo
IN UINT8 *ErrInfo
);
/**
Retransmit the last packet for the instance.
@param Instance The Mtftp instance
@retval EFI_SUCCESS The last packet is retransmitted.
@retval Others Failed to retransmit.
**/
EFI_STATUS
Mtftp4Retransmit (
IN MTFTP4_PROTOCOL *Instance
);
/**
The timer ticking function for the Mtftp service instance.
@param Event The ticking event
@param Context The Mtftp service instance
**/
VOID
EFIAPI
Mtftp4OnTimerTick (

View File

@ -1,95 +1,37 @@
/** @file
Copyright (c) 2006, Intel Corporation
Routines to process Wrq (upload).
Copyright (c) 2006, Intel Corporation<BR>
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Mtftp4Wrq.c
Abstract:
Routines to process Wrq (upload)
**/
#include "Mtftp4Impl.h"
VOID
Mtftp4WrqInput (
IN NET_BUF *UdpPacket,
IN UDP_POINTS *Points,
IN EFI_STATUS IoStatus,
IN VOID *Context
);
/**
Start the MTFTP session for pload. It will first init some states,
then send the WRQ request packet, and start receiving the packet.
@param Instance The MTFTP session
@param Operation Redundant parameter, which is always
EFI_MTFTP4_OPCODE_WRQ here.
@retval EFI_SUCCESS The upload process has been started.
@retval Others Failed to start the upload.
**/
EFI_STATUS
Mtftp4WrqStart (
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 Operation
)
{
EFI_STATUS Status;
//
// The valid block number range are [0, 0xffff]. For example:
// the client sends an WRQ request to the server, the server
// ACK with an ACK0 to let client start transfer the first
// packet.
//
Status = Mtftp4InitBlockRange (&Instance->Blocks, 0, 0xffff);
if (EFI_ERROR (Status)) {
return Status;
}
Status = Mtftp4SendRequest (Instance);
if (EFI_ERROR (Status)) {
return Status;
}
return UdpIoRecvDatagram (Instance->UnicastPort, Mtftp4WrqInput, Instance, 0);
}
/**
Build then send a MTFTP data packet for the MTFTP upload session.
@param Instance The MTFTP upload session
@param BlockNum The block number to send
@param Instance The MTFTP upload session.
@param BlockNum The block number to send.
@retval EFI_OUT_OF_RESOURCES Failed to build the packet
@retval EFI_OUT_OF_RESOURCES Failed to build the packet.
@retval EFI_ABORTED The consumer of this child directs to abort the
transmission by return an error through
PacketNeeded
transmission by return an error through PacketNeeded.
@retval EFI_SUCCESS The data is sent.
**/
EFI_STATUS
Mtftp4WrqSendBlock (
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 BlockNum
IN OUT MTFTP4_PROTOCOL *Instance,
IN UINT16 BlockNum
)
{
EFI_MTFTP4_PACKET *Packet;
@ -109,7 +51,7 @@ Mtftp4WrqSendBlock (
return EFI_OUT_OF_RESOURCES;
}
Packet = (EFI_MTFTP4_PACKET *)NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);
Packet = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);
Packet->Data.OpCode = HTONS (EFI_MTFTP4_OPCODE_DATA);
Packet->Data.Block = HTONS (BlockNum);
@ -139,7 +81,12 @@ Mtftp4WrqSendBlock (
// Get data from PacketNeeded
//
DataBuf = NULL;
Status = Token->PacketNeeded (&Instance->Mtftp4, Token, &DataLen, (VOID **) &DataBuf);
Status = Token->PacketNeeded (
&Instance->Mtftp4,
Token,
&DataLen,
(VOID **) &DataBuf
);
if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) {
if (DataBuf != NULL) {
@ -172,9 +119,10 @@ Mtftp4WrqSendBlock (
/**
Function to handle received ACK packet. If the ACK number matches the
expected block number, and there are more data pending, send the next
block. Otherwise tell the caller that we are done.
Function to handle received ACK packet.
If the ACK number matches the expected block number, and there are more
data pending, send the next block. Otherwise tell the caller that we are done.
@param Instance The MTFTP upload session
@param Packet The MTFTP packet received
@ -188,10 +136,10 @@ Mtftp4WrqSendBlock (
**/
EFI_STATUS
Mtftp4WrqHandleAck (
IN MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
OUT BOOLEAN *Completed
IN MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
OUT BOOLEAN *Completed
)
{
UINT16 AckNum;
@ -221,6 +169,7 @@ Mtftp4WrqHandleAck (
Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);
if (Expected < 0) {
//
// The block range is empty. It may either because the the last
// block has been ACKed, or the sequence number just looped back,
@ -247,17 +196,19 @@ Mtftp4WrqHandleAck (
/**
Check whether the received OACK is valid. The OACK is valid
only if:
Check whether the received OACK is valid.
The OACK is valid only if:
1. It only include options requested by us
2. It can only include a smaller block size
3. It can't change the proposed time out value.
4. Other requirements of the individal MTFTP options as required.s
4. Other requirements of the individal MTFTP options as required.
@param Reply The options included in the OACK
@param Request The options we requested
@return TRUE if the options included in OACK is valid, otherwise FALSE.
@retval TRUE The options included in OACK is valid.
@retval FALSE The options included in OACK is invalid.
**/
BOOLEAN
@ -269,7 +220,7 @@ Mtftp4WrqOackValid (
//
// It is invalid for server to return options we don't request
//
if ((Reply->Exist &~Request->Exist) != 0) {
if ((Reply->Exist & ~Request->Exist) != 0) {
return FALSE;
}
@ -277,8 +228,8 @@ Mtftp4WrqOackValid (
// Server can only specify a smaller block size to be used and
// return the timeout matches that requested.
//
if (((Reply->Exist & MTFTP4_BLKSIZE_EXIST) && (Reply->BlkSize > Request->BlkSize)) ||
((Reply->Exist & MTFTP4_TIMEOUT_EXIST) && (Reply->Timeout != Request->Timeout))) {
if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) != 0) && (Reply->BlkSize > Request->BlkSize)) ||
(((Reply->Exist & MTFTP4_TIMEOUT_EXIST) != 0) && (Reply->Timeout != Request->Timeout))) {
return FALSE;
}
@ -287,8 +238,9 @@ Mtftp4WrqOackValid (
/**
Function to handle the MTFTP OACK packet. It parses the packet's
options, and update the internal states of the session
Function to handle the MTFTP OACK packet.
It parses the packet's options, and update the internal states of the session.
@param Instance The MTFTP session
@param Packet The received OACK packet
@ -302,10 +254,10 @@ Mtftp4WrqOackValid (
**/
EFI_STATUS
Mtftp4WrqHandleOack (
IN MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
OUT BOOLEAN *Completed
IN OUT MTFTP4_PROTOCOL *Instance,
IN EFI_MTFTP4_PACKET *Packet,
IN UINT32 Len,
OUT BOOLEAN *Completed
)
{
MTFTP4_OPTION Reply;
@ -361,7 +313,14 @@ Mtftp4WrqHandleOack (
Bogus.Ack.OpCode = HTONS (EFI_MTFTP4_OPCODE_ACK);
Bogus.Ack.Block[0] = 0;
return Mtftp4WrqHandleAck (Instance, &Bogus, sizeof (EFI_MTFTP4_ACK_HEADER), Completed);
Status = Mtftp4WrqHandleAck (
Instance,
&Bogus,
sizeof (EFI_MTFTP4_ACK_HEADER),
Completed
);
return Status;
}
@ -373,9 +332,6 @@ Mtftp4WrqHandleOack (
@param IoStatus The result of the packet receiving
@param Context Opaque parameter for the callback, which is the
MTFTP session.
@return None
**/
VOID
Mtftp4WrqInput (
@ -494,6 +450,9 @@ Mtftp4WrqInput (
case EFI_MTFTP4_OPCODE_ERROR:
Status = EFI_TFTP_ERROR;
break;
default:
break;
}
ON_EXIT:
@ -520,3 +479,49 @@ ON_EXIT:
Mtftp4CleanOperation (Instance, Status);
}
}
/**
Start the MTFTP session for upload.
It will first init some states, then send the WRQ request packet,
and start receiving the packet.
@param Instance The MTFTP session
@param Operation Redundant parameter, which is always
EFI_MTFTP4_OPCODE_WRQ here.
@retval EFI_SUCCESS The upload process has been started.
@retval Others Failed to start the upload.
**/
EFI_STATUS
Mtftp4WrqStart (
IN MTFTP4_PROTOCOL *Instance,
IN UINT16 Operation
)
{
EFI_STATUS Status;
//
// The valid block number range are [0, 0xffff]. For example:
// the client sends an WRQ request to the server, the server
// ACK with an ACK0 to let client start transfer the first
// packet.
//
Status = Mtftp4InitBlockRange (&Instance->Blocks, 0, 0xffff);
if (EFI_ERROR (Status)) {
return Status;
}
Status = Mtftp4SendRequest (Instance);
if (EFI_ERROR (Status)) {
return Status;
}
return UdpIoRecvDatagram (Instance->UnicastPort, Mtftp4WrqInput, Instance, 0);
}

View File

@ -1,4 +1,5 @@
/** @file
UEFI Component Name(2) protocol implementation for Tcp4Dxe driver.
Copyright (c) 2005 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
Implementation of the Socket.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
Socket implementation header file.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
Interface function of the Socket.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
Socket header file.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
@ -24,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DebugLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#define SOCK_SND_BUF 0
@ -81,55 +83,224 @@ typedef enum {
SO_NO_MAPPING
} SOCK_CONFIGURE_STATE;
/**
Set socket SO_NO_MORE_DATA flag.
@param Sock Pointer to the socket
**/
#define SOCK_NO_MORE_DATA(Sock) ((Sock)->Flag |= SO_NO_MORE_DATA)
/**
Check whether the socket is unconfigured.
@param Sock Pointer to the socket
@retval True The socket is unconfigued
@retval False The socket is not unconfigued
**/
#define SOCK_IS_UNCONFIGURED(Sock) ((Sock)->ConfigureState == SO_UNCONFIGURED)
/**
Check whether the socket is configured.
@param Sock Pointer to the socket
@retval True The socket is configued
@retval False The socket is not configued
**/
#define SOCK_IS_CONFIGURED(Sock) \
(((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE) || \
((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE))
/**
Check whether the socket is configured to active mode.
@param Sock Pointer to the socket
@retval True The socket is configued to active mode
@retval False The socket is not configued to active mode
**/
#define SOCK_IS_CONFIGURED_ACTIVE(Sock) \
((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE)
/**
Check whether the socket is configured to passive mode.
@param Sock Pointer to the socket
@retval True The socket is configued to passive mode
@retval False The socket is not configued to passive mode
**/
#define SOCK_IS_CONNECTED_PASSIVE(Sock) \
((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE)
/**
Check whether the socket is mapped.
@param Sock Pointer to the socket
@retval True The socket is no mapping
@retval False The socket is mapped
**/
#define SOCK_IS_NO_MAPPING(Sock) \
((Sock)->ConfigureState == SO_NO_MAPPING)
/**
Check whether the socket is closed.
@param Sock Pointer to the socket
@retval True The socket is closed
@retval False The socket is not closed
**/
#define SOCK_IS_CLOSED(Sock) ((Sock)->State == SO_CLOSED)
/**
Check whether the socket is listening.
@param Sock Pointer to the socket
@retval True The socket is listening
@retval False The socket is not listening
**/
#define SOCK_IS_LISTENING(Sock) ((Sock)->State == SO_LISTENING)
/**
Check whether the socket is connecting.
@param Sock Pointer to the socket
@retval True The socket is connecting
@retval False The socket is not connecting
**/
#define SOCK_IS_CONNECTING(Sock) ((Sock)->State == SO_CONNECTING)
/**
Check whether the socket has connected.
@param Sock Pointer to the socket
@retval True The socket has connected
@retval False The socket has not connected
**/
#define SOCK_IS_CONNECTED(Sock) ((Sock)->State == SO_CONNECTED)
/**
Check whether the socket is disconnecting.
@param Sock Pointer to the socket
@retval True The socket is disconnecting
@retval False The socket is not disconnecting
**/
#define SOCK_IS_DISCONNECTING(Sock) ((Sock)->State == SO_DISCONNECTING)
/**
Check whether the socket is no more data.
@param Sock Pointer to the socket
@retval True The socket is no more data
@retval False The socket still has data
**/
#define SOCK_IS_NO_MORE_DATA(Sock) (0 != ((Sock)->Flag & SO_NO_MORE_DATA))
#define SOCK_SIGNATURE SIGNATURE_32 ('S', 'O', 'C', 'K')
#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)
/**
Set the size of the receive buffer.
@param Sock Pointer to the socket
@param Size The size to set
**/
#define SET_RCV_BUFFSIZE(Sock, Size) ((Sock)->RcvBuffer.HighWater = (Size))
/**
Get the size of the receive buffer.
@param Sock Pointer to the socket
@return The receive buffer size
**/
#define GET_RCV_BUFFSIZE(Sock) ((Sock)->RcvBuffer.HighWater)
/**
Get the size of the receive data.
@param Sock Pointer to the socket
@return The received data size
**/
#define GET_RCV_DATASIZE(Sock) (((Sock)->RcvBuffer.DataQueue)->BufSize)
/**
Set the size of the send buffer.
@param Sock Pointer to the socket
@param Size The size to set
**/
#define SET_SND_BUFFSIZE(Sock, Size) ((Sock)->SndBuffer.HighWater = (Size))
/**
Get the size of the send buffer.
@param Sock Pointer to the socket
@return The send buffer size
**/
#define GET_SND_BUFFSIZE(Sock) ((Sock)->SndBuffer.HighWater)
/**
Get the size of the send data.
@param Sock Pointer to the socket
@return The send data size
**/
#define GET_SND_DATASIZE(Sock) (((Sock)->SndBuffer.DataQueue)->BufSize)
/**
Set the backlog value of the socket.
@param Sock Pointer to the socket
@param Value The value to set
**/
#define SET_BACKLOG(Sock, Value) ((Sock)->BackLog = (Value))
/**
Get the backlog value of the socket.
@param Sock Pointer to the socket
@return The backlog value
**/
#define GET_BACKLOG(Sock) ((Sock)->BackLog)
/**
Set the socket with error state.
@param Sock Pointer to the socket
@param Error The error state
**/
#define SOCK_ERROR(Sock, Error) ((Sock)->SockError = (Error))
#define SND_BUF_HDR_LEN(Sock) \
@ -138,6 +309,10 @@ typedef enum {
#define RCV_BUF_HDR_LEN(Sock) \
((SockBufFirst (&((Sock)->RcvBuffer)))->TotalSize)
#define SOCK_SIGNATURE SIGNATURE_32 ('S', 'O', 'C', 'K')
#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)
#define SOCK_FROM_TOKEN(Token) (((SOCK_TOKEN *) (Token))->Sock)
#define PROTO_TOKEN_FORM_SOCK(SockToken, Type) \

View File

@ -1,4 +1,5 @@
/** @file
Tcp request dispatcher implementation.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
Tcp driver function.
Copyright (c) 2005 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
Tcp driver function header.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
Tcp function header file.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,4 +1,5 @@
/** @file
TCP4 protocol services header file.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
@ -17,6 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Socket.h"
#include "Tcp4Proto.h"
#include "Tcp4Func.h"
#include "Tcp4Driver.h"

View File

@ -1,4 +1,5 @@
/** @file
Tcp option's routine header file.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials

View File

@ -1,5 +1,6 @@
/** @file
Tcp Protocol header file.
Copyright (c) 2005 - 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -311,18 +312,25 @@ extern UINT32 mTcpTick;
//
#define TCP_SUB_SEQ(Seq1, Seq2) ((UINT32) ((Seq1) - (Seq2)))
//
// Check whether Flag is on
//
#define TCP_FLG_ON(Value, Flag) ((BOOLEAN) (((Value) & (Flag)) != 0))
//
// Set and Clear operation on a Flag
//
#define TCP_SET_FLG(Value, Flag) ((Value) |= (Flag))
#define TCP_CLEAR_FLG(Value, Flag) ((Value) &= ~(Flag))
//
// test whether two peers are equal
// Test whether two peers are equal
//
#define TCP_PEER_EQUAL(Pa, Pb) \
(((Pa)->Ip == (Pb)->Ip) && ((Pa)->Port == (Pb)->Port))
//
// test whether Pa matches Pb, or Pa is more specific
// Test whether Pa matches Pb, or Pa is more specific
// than pb. Zero means wildcard.
//
#define TCP_PEER_MATCH(Pa, Pb) \
@ -342,8 +350,7 @@ extern UINT32 mTcpTick;
typedef
VOID
(*TCP_TIMER_HANDLER) (
IN TCP_CB *Tcb
IN OUT TCP_CB *Tcb
);
#include "Tcp4Func.h"
#endif