]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Mtftp6Dxe/Mtftp6Option.h
NetworkPkg: Apply uncrustify changes
[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 5\r
ecf98fbc 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a3bcde70
HT
7\r
8**/\r
9\r
10#ifndef __EFI_MTFTP6_OPTION_H__\r
11#define __EFI_MTFTP6_OPTION_H__\r
12\r
13#include <Uefi.h>\r
14\r
15#include <Protocol/ServiceBinding.h>\r
16\r
17#include <Library/NetLib.h>\r
18#include <Library/UdpIoLib.h>\r
19#include <Library/BaseMemoryLib.h>\r
20#include <Library/MemoryAllocationLib.h>\r
21#include <Library/UefiRuntimeServicesTableLib.h>\r
22\r
f3427f12 23#define MTFTP6_SUPPORTED_OPTIONS_NUM 5\r
a3bcde70
HT
24#define MTFTP6_OPCODE_LEN 2\r
25#define MTFTP6_ERRCODE_LEN 2\r
26#define MTFTP6_BLKNO_LEN 2\r
27#define MTFTP6_DATA_HEAD_LEN 4\r
28\r
29//\r
30// The bit map definition for Mtftp6 extension options.\r
31//\r
d1050b9d
MK
32#define MTFTP6_OPT_BLKSIZE_BIT 0x01\r
33#define MTFTP6_OPT_TIMEOUT_BIT 0x02\r
34#define MTFTP6_OPT_TSIZE_BIT 0x04\r
35#define MTFTP6_OPT_MCAST_BIT 0x08\r
36#define MTFTP6_OPT_WINDOWSIZE_BIT 0X10\r
a3bcde70 37\r
d1050b9d 38extern CHAR8 *mMtftp6SupportedOptions[MTFTP6_SUPPORTED_OPTIONS_NUM];\r
a3bcde70
HT
39\r
40typedef struct {\r
d1050b9d
MK
41 UINT16 BlkSize;\r
42 UINT16 WindowSize;\r
43 UINT8 Timeout;\r
44 UINT32 Tsize;\r
45 EFI_IPv6_ADDRESS McastIp;\r
46 UINT16 McastPort;\r
47 BOOLEAN IsMaster;\r
48 UINT32 BitMap;\r
a3bcde70
HT
49} MTFTP6_EXT_OPTION_INFO;\r
50\r
51/**\r
52 Parse the Ascii string of multi-cast option.\r
53\r
54 @param[in] Str The pointer to the Ascii string of multi-cast option.\r
55 @param[in] ExtInfo The pointer to the option information to be filled.\r
56\r
57 @retval EFI_SUCCESS Parse the multicast option successfully.\r
58 @retval EFI_INVALID_PARAMETER The string is malformatted.\r
59\r
60**/\r
61EFI_STATUS\r
62Mtftp6ParseMcastOption (\r
d1050b9d
MK
63 IN UINT8 *Str,\r
64 IN MTFTP6_EXT_OPTION_INFO *ExtInfo\r
a3bcde70
HT
65 );\r
66\r
a3bcde70 67/**\r
f6c8bbbe 68 Parse the MTFTP6 extension options.\r
a3bcde70
HT
69\r
70 @param[in] Options The pointer to the extension options list.\r
71 @param[in] Count The num of the extension options.\r
72 @param[in] IsRequest If FALSE, the extension options is included\r
73 by a request packet.\r
f3427f12 74 @param[in] Operation The current performed operation.\r
a3bcde70
HT
75 @param[in] ExtInfo The pointer to the option information to be filled.\r
76\r
f3427f12
JW
77 @retval EFI_SUCCESS Parse the multicast option successfully.\r
78 @retval EFI_INVALID_PARAMETER There is one option is malformatted at least.\r
79 @retval EFI_UNSUPPORTED There is one option is not supported at least.\r
a3bcde70
HT
80\r
81**/\r
82EFI_STATUS\r
83Mtftp6ParseExtensionOption (\r
d1050b9d
MK
84 IN EFI_MTFTP6_OPTION *Options,\r
85 IN UINT32 Count,\r
86 IN BOOLEAN IsRequest,\r
87 IN UINT16 Operation,\r
88 IN MTFTP6_EXT_OPTION_INFO *ExtInfo\r
a3bcde70
HT
89 );\r
90\r
a3bcde70
HT
91/**\r
92 Go through the packet to fill the options array with the start\r
93 addresses of each MTFTP option name/value pair.\r
94\r
95 @param[in] Packet The packet to be checked.\r
96 @param[in] PacketLen The length of the packet.\r
97 @param[in, out] Count The num of the Options on input.\r
98 The actual one on output.\r
99 @param[in] Options The option array to be filled\r
100 it's optional.\r
101\r
102 @retval EFI_SUCCESS The packet has been parsed successfully.\r
103 @retval EFI_INVALID_PARAMETER The packet is malformatted\r
104 @retval EFI_BUFFER_TOO_SMALL The Options array is too small\r
105 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received.\r
106\r
107**/\r
108EFI_STATUS\r
109Mtftp6ParsePacketOption (\r
d1050b9d
MK
110 IN EFI_MTFTP6_PACKET *Packet,\r
111 IN UINT32 PacketLen,\r
112 IN OUT UINT32 *Count,\r
113 IN EFI_MTFTP6_OPTION *Options OPTIONAL\r
a3bcde70
HT
114 );\r
115\r
a3bcde70
HT
116/**\r
117 Go through the packet, generate option list array and fill it\r
118 by the result of parse options.\r
119\r
120 @param[in] Packet The packet to be checked.\r
121 @param[in] PacketLen The length of the packet.\r
122 @param[in, out] OptionCount The num of the Options on input.\r
123 The actual one on output.\r
124 @param[out] OptionList The option list array to be generated\r
125 and filled. It is optional.\r
126\r
127 @retval EFI_SUCCESS The packet has been parsed successfully.\r
128 @retval EFI_INVALID_PARAMETER The packet is malformatted.\r
129 @retval EFI_PROTOCOL_ERROR An option is malformatted.\r
130 @retval EFI_NOT_FOUND The packet has no options.\r
131 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array.\r
132 @retval EFI_BUFFER_TOO_SMALL The size of option list array is too small.\r
133\r
134**/\r
135EFI_STATUS\r
136Mtftp6ParseStart (\r
d1050b9d
MK
137 IN EFI_MTFTP6_PACKET *Packet,\r
138 IN UINT32 PacketLen,\r
139 IN OUT UINT32 *OptionCount,\r
140 OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL\r
a3bcde70
HT
141 );\r
142\r
143#endif\r