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