Home | History | Annotate | Download | only in Mtftp4Dxe
      1 /** @file
      2   Routines to process MTFTP4 options.
      3 
      4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
      5 This program and the accompanying materials
      6 are licensed and made available under the terms and conditions of the BSD License
      7 which accompanies this distribution.  The full text of the license may be found at
      8 http://opensource.org/licenses/bsd-license.php<BR>
      9 
     10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 **/
     14 
     15 
     16 #ifndef __EFI_MTFTP4_OPTION_H__
     17 #define __EFI_MTFTP4_OPTION_H__
     18 
     19 #define MTFTP4_SUPPORTED_OPTIONS  4
     20 #define MTFTP4_OPCODE_LEN         2
     21 #define MTFTP4_ERRCODE_LEN        2
     22 #define MTFTP4_BLKNO_LEN          2
     23 #define MTFTP4_DATA_HEAD_LEN      4
     24 
     25 #define MTFTP4_BLKSIZE_EXIST      0x01
     26 #define MTFTP4_TIMEOUT_EXIST      0x02
     27 #define MTFTP4_TSIZE_EXIST        0x04
     28 #define MTFTP4_MCAST_EXIST        0x08
     29 
     30 typedef struct {
     31   UINT16                    BlkSize;
     32   UINT8                     Timeout;
     33   UINT32                    Tsize;
     34   IP4_ADDR                  McastIp;
     35   UINT16                    McastPort;
     36   BOOLEAN                   Master;
     37   UINT32                    Exist;
     38 } MTFTP4_OPTION;
     39 
     40 /**
     41   Allocate and fill in a array of Mtftp options from the Packet.
     42 
     43   It first calls Mtftp4FillOption to get the option number, then allocate
     44   the array, at last, call Mtftp4FillOption again to save the options.
     45 
     46   @param  Packet                 The packet to parse
     47   @param  PacketLen              The length of the packet
     48   @param  OptionCount            The number of options in the packet
     49   @param  OptionList             The point to get the option array.
     50 
     51   @retval EFI_INVALID_PARAMETER  The parametera are invalid or packet isn't a
     52                                  well-formated OACK packet.
     53   @retval EFI_SUCCESS            The option array is build
     54   @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory for the array
     55 
     56 **/
     57 EFI_STATUS
     58 Mtftp4ExtractOptions (
     59   IN     EFI_MTFTP4_PACKET     *Packet,
     60   IN     UINT32                PacketLen,
     61      OUT UINT32                *OptionCount,
     62      OUT EFI_MTFTP4_OPTION     **OptionList        OPTIONAL
     63   );
     64 
     65 /**
     66   Parse the option in Options array to MTFTP4_OPTION which program
     67   can access directly.
     68 
     69   @param  Options                The option array, which contains addresses of each
     70                                  option's name/value string.
     71   @param  Count                  The number of options in the Options
     72   @param  Request                Whether this is a request or OACK. The format of
     73                                  multicast is different according to this setting.
     74   @param  MtftpOption            The MTFTP4_OPTION for easy access.
     75 
     76   @retval EFI_INVALID_PARAMETER  The option is mal-formated
     77   @retval EFI_UNSUPPORTED        Some option isn't supported
     78   @retval EFI_SUCCESS            The option are OK and has been parsed.
     79 
     80 **/
     81 EFI_STATUS
     82 Mtftp4ParseOption (
     83   IN     EFI_MTFTP4_OPTION     *Options,
     84   IN     UINT32                Count,
     85   IN     BOOLEAN               Request,
     86      OUT MTFTP4_OPTION         *MtftpOption
     87   );
     88 
     89 /**
     90   Parse the options in the OACK packet to MTFTP4_OPTION which program
     91   can access directly.
     92 
     93   @param  Packet                 The OACK packet to parse
     94   @param  PacketLen              The length of the packet
     95   @param  MtftpOption            The MTFTP_OPTION for easy access.
     96 
     97   @retval EFI_INVALID_PARAMETER  The packet option is mal-formated
     98   @retval EFI_UNSUPPORTED        Some option isn't supported
     99   @retval EFI_SUCCESS            The option are OK and has been parsed.
    100 
    101 **/
    102 EFI_STATUS
    103 Mtftp4ParseOptionOack (
    104   IN     EFI_MTFTP4_PACKET     *Packet,
    105   IN     UINT32                PacketLen,
    106      OUT MTFTP4_OPTION         *MtftpOption
    107   );
    108 
    109 extern CHAR8  *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];
    110 
    111 #endif
    112