]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h
MdeModulePke/Mtftp4Dxe: Support windowsize in read request operation.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Option.h
1 /** @file
2 Routines to process MTFTP4 options.
3
4 Copyright (c) 2006 - 2018, 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 5
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 #define MTFTP4_WINDOWSIZE_EXIST 0x10
30
31 typedef struct {
32 UINT16 BlkSize;
33 UINT16 WindowSize;
34 UINT8 Timeout;
35 UINT32 Tsize;
36 IP4_ADDR McastIp;
37 UINT16 McastPort;
38 BOOLEAN Master;
39 UINT32 Exist;
40 } MTFTP4_OPTION;
41
42 /**
43 Allocate and fill in a array of Mtftp options from the Packet.
44
45 It first calls Mtftp4FillOption to get the option number, then allocate
46 the array, at last, call Mtftp4FillOption again to save the options.
47
48 @param Packet The packet to parse
49 @param PacketLen The length of the packet
50 @param OptionCount The number of options in the packet
51 @param OptionList The point to get the option array.
52
53 @retval EFI_INVALID_PARAMETER The parametera are invalid or packet isn't a
54 well-formated OACK packet.
55 @retval EFI_SUCCESS The option array is build
56 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array
57
58 **/
59 EFI_STATUS
60 Mtftp4ExtractOptions (
61 IN EFI_MTFTP4_PACKET *Packet,
62 IN UINT32 PacketLen,
63 OUT UINT32 *OptionCount,
64 OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
65 );
66
67 /**
68 Parse the option in Options array to MTFTP4_OPTION which program
69 can access directly.
70
71 @param Options The option array, which contains addresses of each
72 option's name/value string.
73 @param Count The number of options in the Options
74 @param Request Whether this is a request or OACK. The format of
75 multicast is different according to this setting.
76 @param Operation The current performed operation.
77 @param MtftpOption The MTFTP4_OPTION for easy access.
78
79 @retval EFI_INVALID_PARAMETER The option is mal-formated
80 @retval EFI_UNSUPPORTED Some option isn't supported
81 @retval EFI_SUCCESS The option are OK and has been parsed.
82
83 **/
84 EFI_STATUS
85 Mtftp4ParseOption (
86 IN EFI_MTFTP4_OPTION *Options,
87 IN UINT32 Count,
88 IN BOOLEAN Request,
89 IN UINT16 Operation,
90 OUT MTFTP4_OPTION *MtftpOption
91 );
92
93 /**
94 Parse the options in the OACK packet to MTFTP4_OPTION which program
95 can access directly.
96
97 @param Packet The OACK packet to parse
98 @param PacketLen The length of the packet
99 @param Operation The current performed operation.
100 @param MtftpOption The MTFTP_OPTION for easy access.
101
102 @retval EFI_INVALID_PARAMETER The packet option is mal-formated
103 @retval EFI_UNSUPPORTED Some option isn't supported
104 @retval EFI_SUCCESS The option are OK and has been parsed.
105
106 **/
107 EFI_STATUS
108 Mtftp4ParseOptionOack (
109 IN EFI_MTFTP4_PACKET *Packet,
110 IN UINT32 PacketLen,
111 IN UINT16 Operation,
112 OUT MTFTP4_OPTION *MtftpOption
113 );
114
115 extern CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];
116
117 #endif