/** @file\r
+ Routines to process MTFTP4 options.\r
\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
- Mtftp4Option.h\r
-\r
-Abstract:\r
-\r
- Mtftp4 option process routines.\r
-\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
+\r
#ifndef __EFI_MTFTP4_OPTION_H__\r
#define __EFI_MTFTP4_OPTION_H__\r
\r
-enum {\r
- MTFTP4_SUPPORTED_OPTIONS = 4,\r
- MTFTP4_OPCODE_LEN = 2,\r
- MTFTP4_ERRCODE_LEN = 2,\r
- MTFTP4_BLKNO_LEN = 2,\r
- MTFTP4_DATA_HEAD_LEN = 4,\r
+#define MTFTP4_SUPPORTED_OPTIONS 5\r
+#define MTFTP4_OPCODE_LEN 2\r
+#define MTFTP4_ERRCODE_LEN 2\r
+#define MTFTP4_BLKNO_LEN 2\r
+#define MTFTP4_DATA_HEAD_LEN 4\r
\r
- MTFTP4_BLKSIZE_EXIST = 0x01,\r
- MTFTP4_TIMEOUT_EXIST = 0x02,\r
- MTFTP4_TSIZE_EXIST = 0x04,\r
- MTFTP4_MCAST_EXIST = 0x08\r
-};\r
+#define MTFTP4_BLKSIZE_EXIST 0x01\r
+#define MTFTP4_TIMEOUT_EXIST 0x02\r
+#define MTFTP4_TSIZE_EXIST 0x04\r
+#define MTFTP4_MCAST_EXIST 0x08\r
+#define MTFTP4_WINDOWSIZE_EXIST 0x10\r
\r
typedef struct {\r
UINT16 BlkSize;\r
+ UINT16 WindowSize;\r
UINT8 Timeout;\r
UINT32 Tsize;\r
IP4_ADDR McastIp;\r
UINT32 Exist;\r
} MTFTP4_OPTION;\r
\r
+/**\r
+ Allocate and fill in a array of Mtftp options from the Packet.\r
+\r
+ It first calls Mtftp4FillOption to get the option number, then allocate\r
+ the array, at last, call Mtftp4FillOption again to save the options.\r
+\r
+ @param Packet The packet to parse\r
+ @param PacketLen The length of the packet\r
+ @param OptionCount The number of options in the packet\r
+ @param OptionList The point to get the option array.\r
+\r
+ @retval EFI_INVALID_PARAMETER The parametera are invalid or packet isn't a\r
+ well-formated OACK packet.\r
+ @retval EFI_SUCCESS The option array is build\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array\r
+\r
+**/\r
EFI_STATUS\r
Mtftp4ExtractOptions (\r
- IN EFI_MTFTP4_PACKET *Packet,\r
- IN UINT32 PacketLen,\r
- IN OUT UINT32 *OptionCount,\r
- OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL\r
+ IN EFI_MTFTP4_PACKET *Packet,\r
+ IN UINT32 PacketLen,\r
+ OUT UINT32 *OptionCount,\r
+ OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL\r
);\r
\r
+/**\r
+ Parse the option in Options array to MTFTP4_OPTION which program\r
+ can access directly.\r
+\r
+ @param Options The option array, which contains addresses of each\r
+ option's name/value string.\r
+ @param Count The number of options in the Options\r
+ @param Request Whether this is a request or OACK. The format of\r
+ multicast is different according to this setting.\r
+ @param Operation The current performed operation.\r
+ @param MtftpOption The MTFTP4_OPTION for easy access.\r
+\r
+ @retval EFI_INVALID_PARAMETER The option is mal-formated\r
+ @retval EFI_UNSUPPORTED Some option isn't supported\r
+ @retval EFI_SUCCESS The option are OK and has been parsed.\r
+\r
+**/\r
EFI_STATUS\r
Mtftp4ParseOption (\r
- IN EFI_MTFTP4_OPTION *OptionList,\r
- IN UINT32 Count,\r
- IN BOOLEAN Request,\r
- OUT MTFTP4_OPTION *Option\r
+ IN EFI_MTFTP4_OPTION *Options,\r
+ IN UINT32 Count,\r
+ IN BOOLEAN Request,\r
+ IN UINT16 Operation,\r
+ OUT MTFTP4_OPTION *MtftpOption\r
);\r
\r
+/**\r
+ Parse the options in the OACK packet to MTFTP4_OPTION which program\r
+ can access directly.\r
+\r
+ @param Packet The OACK packet to parse\r
+ @param PacketLen The length of the packet\r
+ @param Operation The current performed operation.\r
+ @param MtftpOption The MTFTP_OPTION for easy access.\r
+\r
+ @retval EFI_INVALID_PARAMETER The packet option is mal-formated\r
+ @retval EFI_UNSUPPORTED Some option isn't supported\r
+ @retval EFI_SUCCESS The option are OK and has been parsed.\r
+\r
+**/\r
EFI_STATUS\r
Mtftp4ParseOptionOack (\r
- IN EFI_MTFTP4_PACKET *Packet,\r
- IN UINT32 PacketLen,\r
- OUT MTFTP4_OPTION *Option\r
+ IN EFI_MTFTP4_PACKET *Packet,\r
+ IN UINT32 PacketLen,\r
+ IN UINT16 Operation,\r
+ OUT MTFTP4_OPTION *MtftpOption\r
);\r
\r
extern CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];\r
+\r
#endif\r