]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
Add 'file not found' debug message to MTFTP.
[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
75dce340 12Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 13This program and the accompanying materials\r
83cbd279 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
cfb1461b 33#include <Library/BaseMemoryLib.h>\r
34#include <Library/MemoryAllocationLib.h>\r
772db4bb 35#include <Library/UefiBootServicesTableLib.h>\r
83cbd279 36#include <Library/UdpIoLib.h>\r
1f7eb561 37#include <Library/PrintLib.h>\r
dab714aa 38\r
39extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;\r
83cbd279 40\r
41typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;\r
42typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;\r
43\r
44#include "Mtftp4Driver.h"\r
45#include "Mtftp4Option.h"\r
46#include "Mtftp4Support.h"\r
47\r
dab714aa 48\r
49///\r
50/// Some constant value of Mtftp service.\r
51///\r
f6b7393c 52#define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')\r
53#define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')\r
54\r
55#define MTFTP4_DEFAULT_SERVER_PORT 69\r
56#define MTFTP4_DEFAULT_TIMEOUT 3\r
57#define MTFTP4_DEFAULT_RETRY 5\r
58#define MTFTP4_DEFAULT_BLKSIZE 512\r
59#define MTFTP4_TIME_TO_GETMAP 5\r
60\r
61#define MTFTP4_STATE_UNCONFIGED 0\r
62#define MTFTP4_STATE_CONFIGED 1\r
75dce340 63#define MTFTP4_STATE_DESTROY 2\r
83cbd279 64\r
dab714aa 65///\r
66/// Mtftp service block\r
67///\r
83cbd279 68struct _MTFTP4_SERVICE {\r
69 UINT32 Signature;\r
70 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
71\r
83cbd279 72 UINT16 ChildrenNum;\r
e48e37fc 73 LIST_ENTRY Children;\r
83cbd279 74\r
5be56d99 75 EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients\r
83cbd279 76 EFI_EVENT TimerToGetMap;\r
77\r
78 EFI_HANDLE Controller;\r
79 EFI_HANDLE Image;\r
80\r
81 //\r
82 // This UDP child is used to keep the connection between the UDP\r
83 // and MTFTP, so MTFTP will be notified when UDP is uninstalled.\r
84 //\r
b45b45b2 85 UDP_IO *ConnectUdp;\r
83cbd279 86};\r
87\r
dab714aa 88\r
61066b8d 89typedef struct {\r
90 EFI_MTFTP4_PACKET **Packet;\r
91 UINT32 *PacketLen;\r
92 EFI_STATUS Status;\r
93} MTFTP4_GETINFO_STATE;\r
94\r
83cbd279 95struct _MTFTP4_PROTOCOL {\r
96 UINT32 Signature;\r
e48e37fc 97 LIST_ENTRY Link;\r
83cbd279 98 EFI_MTFTP4_PROTOCOL Mtftp4;\r
99\r
100 INTN State;\r
75dce340 101 BOOLEAN InDestroy;\r
83cbd279 102\r
103 MTFTP4_SERVICE *Service;\r
104 EFI_HANDLE Handle;\r
105\r
106 EFI_MTFTP4_CONFIG_DATA Config;\r
107\r
108 //\r
109 // Operation parameters: token and requested options.\r
110 //\r
111 EFI_MTFTP4_TOKEN *Token;\r
112 MTFTP4_OPTION RequestOption;\r
113 UINT16 Operation;\r
114\r
115 //\r
116 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains\r
117 // holes in the file\r
118 //\r
119 UINT16 BlkSize;\r
120 UINT16 LastBlock;\r
e48e37fc 121 LIST_ENTRY Blocks;\r
83cbd279 122\r
123 //\r
124 // The server's communication end point: IP and two ports. one for\r
125 // initial request, one for its selected port.\r
126 //\r
127 IP4_ADDR ServerIp;\r
128 UINT16 ListeningPort;\r
129 UINT16 ConnectedPort;\r
130 IP4_ADDR Gateway;\r
b45b45b2 131 UDP_IO *UnicastPort;\r
83cbd279 132\r
133 //\r
134 // Timeout and retransmit status\r
135 //\r
136 NET_BUF *LastPacket;\r
137 UINT32 PacketToLive;\r
138 UINT32 CurRetry;\r
139 UINT32 MaxRetry;\r
140 UINT32 Timeout;\r
141\r
142 //\r
143 // Parameter used by RRQ's multicast download.\r
144 //\r
145 IP4_ADDR McastIp;\r
146 UINT16 McastPort;\r
147 BOOLEAN Master;\r
b45b45b2 148 UDP_IO *McastUdpPort;\r
61066b8d 149};\r
36ee91ca 150\r
216f7970 151typedef struct {\r
152 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
153 UINTN NumberOfChildren;\r
154 EFI_HANDLE *ChildHandleBuffer;\r
155} MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;\r
156\r
dab714aa 157/**\r
158 Clean up the MTFTP session to get ready for new operation.\r
159\r
160 @param Instance The MTFTP session to clean up\r
161 @param Result The result to return to the caller who initiated\r
162 the operation.\r
163**/\r
83cbd279 164VOID\r
165Mtftp4CleanOperation (\r
dab714aa 166 IN OUT MTFTP4_PROTOCOL *Instance,\r
167 IN EFI_STATUS Result\r
83cbd279 168 );\r
169\r
dab714aa 170/**\r
171 Start the MTFTP session for upload.\r
172 \r
173 It will first init some states, then send the WRQ request packet, \r
174 and start receiving the packet.\r
175\r
176 @param Instance The MTFTP session\r
177 @param Operation Redundant parameter, which is always\r
178 EFI_MTFTP4_OPCODE_WRQ here.\r
179\r
180 @retval EFI_SUCCESS The upload process has been started.\r
181 @retval Others Failed to start the upload.\r
182\r
183**/\r
83cbd279 184EFI_STATUS\r
185Mtftp4WrqStart (\r
dab714aa 186 IN MTFTP4_PROTOCOL *Instance,\r
187 IN UINT16 Operation\r
83cbd279 188 );\r
189\r
dab714aa 190/**\r
191 Start the MTFTP session to download. \r
192 \r
193 It will first initialize some of the internal states then build and send a RRQ \r
194 reqeuest packet, at last, it will start receive for the downloading.\r
195\r
196 @param Instance The Mtftp session\r
197 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ\r
198 or EFI_MTFTP4_OPCODE_DIR.\r
199\r
200 @retval EFI_SUCCESS The mtftp download session is started.\r
201 @retval Others Failed to start downloading.\r
202\r
203**/\r
83cbd279 204EFI_STATUS\r
205Mtftp4RrqStart (\r
dab714aa 206 IN MTFTP4_PROTOCOL *Instance,\r
207 IN UINT16 Operation\r
83cbd279 208 );\r
209\r
210#define MTFTP4_SERVICE_FROM_THIS(a) \\r
211 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)\r
212\r
213#define MTFTP4_PROTOCOL_FROM_THIS(a) \\r
214 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)\r
215\r
83cbd279 216#endif\r