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