]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Mtftp6Dxe/Mtftp6Option.h
NetworkPkg: Replace BSD License with BSD+Patent License
[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
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
f3427f12 36#define MTFTP6_OPT_WINDOWSIZE_BIT 0X10\r
a3bcde70
HT
37\r
38extern CHAR8 *mMtftp6SupportedOptions[MTFTP6_SUPPORTED_OPTIONS_NUM];\r
39\r
40typedef struct {\r
41 UINT16 BlkSize;\r
f3427f12 42 UINT16 WindowSize;\r
a3bcde70
HT
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
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
63 IN UINT8 *Str,\r
64 IN MTFTP6_EXT_OPTION_INFO *ExtInfo\r
65 );\r
66\r
67\r
68/**\r
69 Parse the MTFTP6 extesion options.\r
70\r
71 @param[in] Options The pointer to the extension options list.\r
72 @param[in] Count The num of the extension options.\r
73 @param[in] IsRequest If FALSE, the extension options is included\r
74 by a request packet.\r
f3427f12 75 @param[in] Operation The current performed operation.\r
a3bcde70
HT
76 @param[in] ExtInfo The pointer to the option information to be filled.\r
77\r
f3427f12
JW
78 @retval EFI_SUCCESS Parse the multicast option successfully.\r
79 @retval EFI_INVALID_PARAMETER There is one option is malformatted at least.\r
80 @retval EFI_UNSUPPORTED There is one option is not supported at least.\r
a3bcde70
HT
81\r
82**/\r
83EFI_STATUS\r
84Mtftp6ParseExtensionOption (\r
85 IN EFI_MTFTP6_OPTION *Options,\r
86 IN UINT32 Count,\r
87 IN BOOLEAN IsRequest,\r
f3427f12 88 IN UINT16 Operation,\r
a3bcde70
HT
89 IN MTFTP6_EXT_OPTION_INFO *ExtInfo\r
90 );\r
91\r
92\r
93/**\r
94 Go through the packet to fill the options array with the start\r
95 addresses of each MTFTP option name/value pair.\r
96\r
97 @param[in] Packet The packet to be checked.\r
98 @param[in] PacketLen The length of the packet.\r
99 @param[in, out] Count The num of the Options on input.\r
100 The actual one on output.\r
101 @param[in] Options The option array to be filled\r
102 it's optional.\r
103\r
104 @retval EFI_SUCCESS The packet has been parsed successfully.\r
105 @retval EFI_INVALID_PARAMETER The packet is malformatted\r
106 @retval EFI_BUFFER_TOO_SMALL The Options array is too small\r
107 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received.\r
108\r
109**/\r
110EFI_STATUS\r
111Mtftp6ParsePacketOption (\r
112 IN EFI_MTFTP6_PACKET *Packet,\r
113 IN UINT32 PacketLen,\r
114 IN OUT UINT32 *Count,\r
115 IN EFI_MTFTP6_OPTION *Options OPTIONAL\r
116 );\r
117\r
118\r
119/**\r
120 Go through the packet, generate option list array and fill it\r
121 by the result of parse options.\r
122\r
123 @param[in] Packet The packet to be checked.\r
124 @param[in] PacketLen The length of the packet.\r
125 @param[in, out] OptionCount The num of the Options on input.\r
126 The actual one on output.\r
127 @param[out] OptionList The option list array to be generated\r
128 and filled. It is optional.\r
129\r
130 @retval EFI_SUCCESS The packet has been parsed successfully.\r
131 @retval EFI_INVALID_PARAMETER The packet is malformatted.\r
132 @retval EFI_PROTOCOL_ERROR An option is malformatted.\r
133 @retval EFI_NOT_FOUND The packet has no options.\r
134 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array.\r
135 @retval EFI_BUFFER_TOO_SMALL The size of option list array is too small.\r
136\r
137**/\r
138EFI_STATUS\r
139Mtftp6ParseStart (\r
140 IN EFI_MTFTP6_PACKET *Packet,\r
141 IN UINT32 PacketLen,\r
142 IN OUT UINT32 *OptionCount,\r
143 OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL\r
144 );\r
145\r
146#endif\r