]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Mtftp6Dxe/Mtftp6Option.h
NetworkPkg/Mtftp6Dxe: Support windowsize in read request operation.
[mirror_edk2.git] / NetworkPkg / Mtftp6Dxe / Mtftp6Option.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 Mtftp6 option parse functions declaration.\r
3\r
f3427f12 4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_MTFTP6_OPTION_H__\r
17#define __EFI_MTFTP6_OPTION_H__\r
18\r
19#include <Uefi.h>\r
20\r
21#include <Protocol/ServiceBinding.h>\r
22\r
23#include <Library/NetLib.h>\r
24#include <Library/UdpIoLib.h>\r
25#include <Library/BaseMemoryLib.h>\r
26#include <Library/MemoryAllocationLib.h>\r
27#include <Library/UefiRuntimeServicesTableLib.h>\r
28\r
f3427f12 29#define MTFTP6_SUPPORTED_OPTIONS_NUM 5\r
a3bcde70
HT
30#define MTFTP6_OPCODE_LEN 2\r
31#define MTFTP6_ERRCODE_LEN 2\r
32#define MTFTP6_BLKNO_LEN 2\r
33#define MTFTP6_DATA_HEAD_LEN 4\r
34\r
35//\r
36// The bit map definition for Mtftp6 extension options.\r
37//\r
38#define MTFTP6_OPT_BLKSIZE_BIT 0x01\r
39#define MTFTP6_OPT_TIMEOUT_BIT 0x02\r
40#define MTFTP6_OPT_TSIZE_BIT 0x04\r
41#define MTFTP6_OPT_MCAST_BIT 0x08\r
f3427f12 42#define MTFTP6_OPT_WINDOWSIZE_BIT 0X10\r
a3bcde70
HT
43\r
44extern CHAR8 *mMtftp6SupportedOptions[MTFTP6_SUPPORTED_OPTIONS_NUM];\r
45\r
46typedef struct {\r
47 UINT16 BlkSize;\r
f3427f12 48 UINT16 WindowSize;\r
a3bcde70
HT
49 UINT8 Timeout;\r
50 UINT32 Tsize;\r
51 EFI_IPv6_ADDRESS McastIp;\r
52 UINT16 McastPort;\r
53 BOOLEAN IsMaster;\r
54 UINT32 BitMap;\r
55} MTFTP6_EXT_OPTION_INFO;\r
56\r
57/**\r
58 Parse the Ascii string of multi-cast option.\r
59\r
60 @param[in] Str The pointer to the Ascii string of multi-cast option.\r
61 @param[in] ExtInfo The pointer to the option information to be filled.\r
62\r
63 @retval EFI_SUCCESS Parse the multicast option successfully.\r
64 @retval EFI_INVALID_PARAMETER The string is malformatted.\r
65\r
66**/\r
67EFI_STATUS\r
68Mtftp6ParseMcastOption (\r
69 IN UINT8 *Str,\r
70 IN MTFTP6_EXT_OPTION_INFO *ExtInfo\r
71 );\r
72\r
73\r
74/**\r
75 Parse the MTFTP6 extesion options.\r
76\r
77 @param[in] Options The pointer to the extension options list.\r
78 @param[in] Count The num of the extension options.\r
79 @param[in] IsRequest If FALSE, the extension options is included\r
80 by a request packet.\r
f3427f12 81 @param[in] Operation The current performed operation.\r
a3bcde70
HT
82 @param[in] ExtInfo The pointer to the option information to be filled.\r
83\r
f3427f12
JW
84 @retval EFI_SUCCESS Parse the multicast option successfully.\r
85 @retval EFI_INVALID_PARAMETER There is one option is malformatted at least.\r
86 @retval EFI_UNSUPPORTED There is one option is not supported at least.\r
a3bcde70
HT
87\r
88**/\r
89EFI_STATUS\r
90Mtftp6ParseExtensionOption (\r
91 IN EFI_MTFTP6_OPTION *Options,\r
92 IN UINT32 Count,\r
93 IN BOOLEAN IsRequest,\r
f3427f12 94 IN UINT16 Operation,\r
a3bcde70
HT
95 IN MTFTP6_EXT_OPTION_INFO *ExtInfo\r
96 );\r
97\r
98\r
99/**\r
100 Go through the packet to fill the options array with the start\r
101 addresses of each MTFTP option name/value pair.\r
102\r
103 @param[in] Packet The packet to be checked.\r
104 @param[in] PacketLen The length of the packet.\r
105 @param[in, out] Count The num of the Options on input.\r
106 The actual one on output.\r
107 @param[in] Options The option array to be filled\r
108 it's optional.\r
109\r
110 @retval EFI_SUCCESS The packet has been parsed successfully.\r
111 @retval EFI_INVALID_PARAMETER The packet is malformatted\r
112 @retval EFI_BUFFER_TOO_SMALL The Options array is too small\r
113 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received.\r
114\r
115**/\r
116EFI_STATUS\r
117Mtftp6ParsePacketOption (\r
118 IN EFI_MTFTP6_PACKET *Packet,\r
119 IN UINT32 PacketLen,\r
120 IN OUT UINT32 *Count,\r
121 IN EFI_MTFTP6_OPTION *Options OPTIONAL\r
122 );\r
123\r
124\r
125/**\r
126 Go through the packet, generate option list array and fill it\r
127 by the result of parse options.\r
128\r
129 @param[in] Packet The packet to be checked.\r
130 @param[in] PacketLen The length of the packet.\r
131 @param[in, out] OptionCount The num of the Options on input.\r
132 The actual one on output.\r
133 @param[out] OptionList The option list array to be generated\r
134 and filled. It is optional.\r
135\r
136 @retval EFI_SUCCESS The packet has been parsed successfully.\r
137 @retval EFI_INVALID_PARAMETER The packet is malformatted.\r
138 @retval EFI_PROTOCOL_ERROR An option is malformatted.\r
139 @retval EFI_NOT_FOUND The packet has no options.\r
140 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array.\r
141 @retval EFI_BUFFER_TOO_SMALL The size of option list array is too small.\r
142\r
143**/\r
144EFI_STATUS\r
145Mtftp6ParseStart (\r
146 IN EFI_MTFTP6_PACKET *Packet,\r
147 IN UINT32 PacketLen,\r
148 IN OUT UINT32 *OptionCount,\r
149 OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL\r
150 );\r
151\r
152#endif\r