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