/** @file
Definitions for the TFTP server.
Copyright (c) 2011, Intel Corporation
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _TFTP_SERVER_H_
#define _TFTP_SERVER_H_
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <Uefi.h>
#include <Guid/EventGroup.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <sys/EfiSysCall.h>
//------------------------------------------------------------------------------
// Macros
//------------------------------------------------------------------------------
#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
#define DBG_ENTER() DEBUG (( DEBUG_INFO, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry
#define DBG_EXIT_DEC(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value
#define DBG_EXIT_HEX(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value
#define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value
#define DBG_EXIT_TF(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value
#else // _MSC_VER
#define DBG_ENTER()
#define DBG_EXIT()
#endif // _MSC_VER
//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------
#define TFTP_PORT_POLL_DELAY ( 2 * 1000 ) ///< Delay in milliseconds for attempts to open the TFTP port
/**
Verify new TPL value
This macro which is enabled when debug is enabled verifies that
the new TPL value is >= the current TPL value.
**/
#ifdef VERIFY_TPL
#endif // VERIFY_TPL
#if !defined(MDEPKG_NDEBUG)
{ \
\
if ( PreviousTpl > tpl ) { \
} \
}
#else // MDEPKG_NDEBUG
#endif // MDEPKG_NDEBUG
//
//
// TFTP Operations
//
//------------------------------------------------------------------------------
// Data Types
//------------------------------------------------------------------------------
/**
Port control structure
**/
typedef struct _TSDT_CONNECTION_CONTEXT {
//
// Remote connection management
//
//
// TFTP management parameters
//
//
// File management parameters
//
//
// Buffer management
//
/**
TFTP server control structure
**/
typedef struct {
//
// Image attributes
//
//
// TFTP port management
//
//
// Request management
//
//
// Client port management
//
//#define SERVER_FROM_SERVICE(a) CR(a, TSDT_TFTP_SERVER, ServiceBinding, TFTP_SERVER_SIGNATURE) ///< Locate DT_LAYER from service binding
extern TSDT_TFTP_SERVER mTftpServer;
//------------------------------------------------------------------------------
// Support routines
//------------------------------------------------------------------------------
/**
Process the TFTP request
@param [in] pOption Address of the first zero terminated option string
@param [in] pValue Address to receive the value
@retval EFI_SUCCESS Option translated into a value
**/
);
/**
Process the TFTP request
@param [in] pTftpServer The TFTP server control structure address.
@param [in] pContext Connection context structure address
**/
);
/**
Build and send an error packet
@param [in] pTftpServer The TFTP server control structure address.
@param [in] pContext The context structure address.
@param [in] Error Error number for the packet
@param [in] pError Zero terminated error string address
@retval EFI_SUCCESS Message processed successfully
**/
);
/**
Send the next block of file system data
@param [in] pTftpServer The TFTP server control structure address.
@param [in] pContext The context structure address.
@retval EFI_SUCCESS Message processed successfully
**/
);
/**
TFTP port creation timer routine
This routine polls the socket layer waiting for the initial network connection
which will enable the creation of the TFTP port. The socket layer will manage
the coming and going of the network connections after that until the last network
connection is broken.
@param [in] pTftpServer The TFTP server control structure address.
**/
);
/**
Start the TFTP server port creation timer
@param [in] pTftpServer The TFTP server control structure address.
@retval EFI_SUCCESS The timer was successfully started.
@retval EFI_ALREADY_STARTED The timer is already running.
@retval Other The timer failed to start.
**/
);
/**
Stop the TFTP server port creation timer
@param [in] pTftpServer The TFTP server control structure address.
@retval EFI_SUCCESS The TFTP port timer is stopped
@retval Other Failed to stop the TFTP port timer
**/
);
/**
Send the next TFTP packet
@param [in] pTftpServer The TFTP server control structure address.
@param [in] pContext The context structure address.
@retval EFI_SUCCESS Message processed successfully
**/
);
//------------------------------------------------------------------------------
#endif // _TFTP_SERVER_H_