]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
Fix function comments.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Impl.h
CommitLineData
83cbd279 1/** @file\r
dab714aa 2 \r
3 Mtftp4 Implementation.\r
4 \r
5 Mtftp4 Implementation, it supports the following RFCs:\r
6 RFC1350 - THE TFTP PROTOCOL (REVISION 2)\r
7 RFC2090 - TFTP Multicast Option\r
8 RFC2347 - TFTP Option Extension\r
9 RFC2348 - TFTP Blocksize Option\r
10 RFC2349 - TFTP Timeout Interval and Transfer Size Options\r
11 \r
12Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
83cbd279 13All rights reserved. This program and the accompanying materials\r
14are licensed and made available under the terms and conditions of the BSD License\r
15which accompanies this distribution. The full text of the license may be found at\r
dab714aa 16http://opensource.org/licenses/bsd-license.php<BR>\r
83cbd279 17\r
18THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
19WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
20\r
83cbd279 21**/\r
22\r
dab714aa 23\r
83cbd279 24#ifndef __EFI_MTFTP4_IMPL_H__\r
25#define __EFI_MTFTP4_IMPL_H__\r
26\r
dab714aa 27#include <Uefi.h>\r
772db4bb 28\r
29#include <Protocol/Udp4.h>\r
30#include <Protocol/Mtftp4.h>\r
31\r
32#include <Library/DebugLib.h>\r
772db4bb 33#include <Library/UefiBootServicesTableLib.h>\r
83cbd279 34#include <Library/UdpIoLib.h>\r
dab714aa 35\r
36extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;\r
83cbd279 37\r
38typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;\r
39typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;\r
40\r
41#include "Mtftp4Driver.h"\r
42#include "Mtftp4Option.h"\r
43#include "Mtftp4Support.h"\r
44\r
dab714aa 45\r
46///\r
47/// Some constant value of Mtftp service.\r
48///\r
49typedef enum {\r
f3f2e05d 50 MTFTP4_SERVICE_SIGNATURE = SIGNATURE_32 ('T', 'F', 'T', 'P'),\r
51 MTFTP4_PROTOCOL_SIGNATURE = SIGNATURE_32 ('t', 'f', 't', 'p'),\r
83cbd279 52\r
53 MTFTP4_DEFAULT_SERVER_PORT = 69,\r
54 MTFTP4_DEFAULT_TIMEOUT = 3,\r
55 MTFTP4_DEFAULT_RETRY = 5,\r
56 MTFTP4_DEFAULT_BLKSIZE = 512,\r
57 MTFTP4_TIME_TO_GETMAP = 5,\r
58\r
59 MTFTP4_STATE_UNCONFIGED = 0,\r
60 MTFTP4_STATE_CONFIGED,\r
61 MTFTP4_STATE_DESTORY\r
dab714aa 62} MTFTP4_SERVICE_CONST_VALUE;\r
83cbd279 63\r
dab714aa 64///\r
65/// Mtftp service block\r
66///\r
83cbd279 67struct _MTFTP4_SERVICE {\r
68 UINT32 Signature;\r
69 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
70\r
71 BOOLEAN InDestory;\r
72\r
73 UINT16 ChildrenNum;\r
e48e37fc 74 LIST_ENTRY Children;\r
83cbd279 75\r
5be56d99 76 EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients\r
83cbd279 77 EFI_EVENT TimerToGetMap;\r
78\r
79 EFI_HANDLE Controller;\r
80 EFI_HANDLE Image;\r
81\r
82 //\r
83 // This UDP child is used to keep the connection between the UDP\r
84 // and MTFTP, so MTFTP will be notified when UDP is uninstalled.\r
85 //\r
86 UDP_IO_PORT *ConnectUdp;\r
87};\r
88\r
dab714aa 89\r
61066b8d 90typedef struct {\r
91 EFI_MTFTP4_PACKET **Packet;\r
92 UINT32 *PacketLen;\r
93 EFI_STATUS Status;\r
94} MTFTP4_GETINFO_STATE;\r
95\r
83cbd279 96struct _MTFTP4_PROTOCOL {\r
97 UINT32 Signature;\r
e48e37fc 98 LIST_ENTRY Link;\r
83cbd279 99 EFI_MTFTP4_PROTOCOL Mtftp4;\r
100\r
101 INTN State;\r
dab714aa 102 BOOLEAN InDestory;\r
83cbd279 103\r
104 MTFTP4_SERVICE *Service;\r
105 EFI_HANDLE Handle;\r
106\r
107 EFI_MTFTP4_CONFIG_DATA Config;\r
108\r
109 //\r
110 // Operation parameters: token and requested options.\r
111 //\r
112 EFI_MTFTP4_TOKEN *Token;\r
113 MTFTP4_OPTION RequestOption;\r
114 UINT16 Operation;\r
115\r
116 //\r
117 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains\r
118 // holes in the file\r
119 //\r
120 UINT16 BlkSize;\r
121 UINT16 LastBlock;\r
e48e37fc 122 LIST_ENTRY Blocks;\r
83cbd279 123\r
124 //\r
125 // The server's communication end point: IP and two ports. one for\r
126 // initial request, one for its selected port.\r
127 //\r
128 IP4_ADDR ServerIp;\r
129 UINT16 ListeningPort;\r
130 UINT16 ConnectedPort;\r
131 IP4_ADDR Gateway;\r
132 UDP_IO_PORT *UnicastPort;\r
133\r
134 //\r
135 // Timeout and retransmit status\r
136 //\r
137 NET_BUF *LastPacket;\r
138 UINT32 PacketToLive;\r
139 UINT32 CurRetry;\r
140 UINT32 MaxRetry;\r
141 UINT32 Timeout;\r
142\r
143 //\r
144 // Parameter used by RRQ's multicast download.\r
145 //\r
146 IP4_ADDR McastIp;\r
147 UINT16 McastPort;\r
148 BOOLEAN Master;\r
149 UDP_IO_PORT *McastUdpPort;\r
83cbd279 150\r
61066b8d 151 MTFTP4_GETINFO_STATE GetInfoState;\r
152};\r
36ee91ca 153\r
dab714aa 154/**\r
155 Clean up the MTFTP session to get ready for new operation.\r
156\r
157 @param Instance The MTFTP session to clean up\r
158 @param Result The result to return to the caller who initiated\r
159 the operation.\r
160**/\r
83cbd279 161VOID\r
162Mtftp4CleanOperation (\r
dab714aa 163 IN OUT MTFTP4_PROTOCOL *Instance,\r
164 IN EFI_STATUS Result\r
83cbd279 165 );\r
166\r
dab714aa 167/**\r
168 Start the MTFTP session for upload.\r
169 \r
170 It will first init some states, then send the WRQ request packet, \r
171 and start receiving the packet.\r
172\r
173 @param Instance The MTFTP session\r
174 @param Operation Redundant parameter, which is always\r
175 EFI_MTFTP4_OPCODE_WRQ here.\r
176\r
177 @retval EFI_SUCCESS The upload process has been started.\r
178 @retval Others Failed to start the upload.\r
179\r
180**/\r
83cbd279 181EFI_STATUS\r
182Mtftp4WrqStart (\r
dab714aa 183 IN MTFTP4_PROTOCOL *Instance,\r
184 IN UINT16 Operation\r
83cbd279 185 );\r
186\r
dab714aa 187/**\r
188 Start the MTFTP session to download. \r
189 \r
190 It will first initialize some of the internal states then build and send a RRQ \r
191 reqeuest packet, at last, it will start receive for the downloading.\r
192\r
193 @param Instance The Mtftp session\r
194 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ\r
195 or EFI_MTFTP4_OPCODE_DIR.\r
196\r
197 @retval EFI_SUCCESS The mtftp download session is started.\r
198 @retval Others Failed to start downloading.\r
199\r
200**/\r
83cbd279 201EFI_STATUS\r
202Mtftp4RrqStart (\r
dab714aa 203 IN MTFTP4_PROTOCOL *Instance,\r
204 IN UINT16 Operation\r
83cbd279 205 );\r
206\r
207#define MTFTP4_SERVICE_FROM_THIS(a) \\r
208 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)\r
209\r
210#define MTFTP4_PROTOCOL_FROM_THIS(a) \\r
211 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)\r
212\r
83cbd279 213#endif\r