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