]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Ftp4.h
26e158c86759fbbfcb73e75f649a8b67e6f0e62a
[mirror_edk2.git] / MdePkg / Include / Protocol / Ftp4.h
1 /** @file
2 EFI FTPv4 (File Transfer Protocol version 4) Protocol Definition
3 The EFI FTPv4 Protocol is used to locate communication devices that are
4 supported by an EFI FTPv4 Protocol driver and to create and destroy instances
5 of the EFI FTPv4 Protocol child protocol driver that can use the underlying
6 communication device.
7 The definitions in this file are defined in UEFI Specification 2.3, which have
8 not been verified by one implementation yet.
9
10 Copyright (c) 2009, Intel Corporation
11 All rights reserved. This program and the accompanying materials
12 are licensed and made available under the terms and conditions of the BSD License
13 which accompanies this distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
15
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18
19 **/
20
21 #ifndef __EFI_FTP4_PROTOCOL_H__
22 #define __EFI_FTP4_PROTOCOL_H__
23
24
25 #define EFI_FTP4_SERVICE_BINDING_PROTOCOL_GUID \
26 { \
27 0xfaaecb1, 0x226e, 0x4782, {0xaa, 0xce, 0x7d, 0xb9, 0xbc, 0xbf, 0x4d, 0xaf } \
28 }
29
30 #define EFI_FTP4_PROTOCOL_GUID \
31 { \
32 0xeb338826, 0x681b, 0x4295, {0xb3, 0x56, 0x2b, 0x36, 0x4c, 0x75, 0x7b, 0x9 } \
33 }
34
35 typedef struct _EFI_FTP4_PROTOCOL EFI_FTP4_PROTOCOL;
36
37 ///
38 /// EFI_FTP4_CONNECTION_TOKEN
39 ///
40 typedef struct {
41 ///
42 /// The Event to signal after the connection is established and Status field is updated
43 /// by the EFI FTP v4 Protocol driver. The type of Event must be
44 /// EVENT_NOTIFY_SIGNAL, and its Task Priority Level (TPL) must be lower than or
45 /// equal to TPL_CALLBACK. If it is set to NULL, this function will not return until the
46 /// function completes.
47 ///
48 EFI_EVENT Event;
49 ///
50 /// The variable to receive the result of the completed operation.
51 /// EFI_SUCCESS: The FTP connection is established successfully
52 /// EFI_ACCESS_DENIED: The FTP server denied the access the user's request to access it.
53 /// EFI_CONNECTION_RESET: The connect fails because the connection is reset either by instance
54 /// itself or communication peer.
55 /// EFI_TIMEOUT: The connection establishment timer expired and no more specific
56 /// information is available.
57 /// EFI_NETWORK_UNREACHABLE: The active open fails because an ICMP network unreachable error is
58 /// received.
59 /// EFI_HOST_UNREACHABLE: The active open fails because an ICMP host unreachable error is
60 /// received.
61 /// EFI_PROTOCOL_UNREACHABLE: The active open fails because an ICMP protocol unreachable error is
62 /// received.
63 /// EFI_PORT_UNREACHABLE: The connection establishment timer times out and an ICMP port
64 /// unreachable error is received.
65 /// EFI_ICMP_ERROR: The connection establishment timer timeout and some other ICMP
66 /// error is received.
67 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
68 ///
69 EFI_STATUS Status;
70 } EFI_FTP4_CONNECTION_TOKEN;
71
72 ///
73 /// EFI_FTP4_CONFIG_DATA
74 ///
75 typedef struct {
76 ///
77 /// Pointer to a ASCII string that contains user name. The caller is
78 /// responsible for freeing Username after GetModeData() is called.
79 ///
80 UINT8 *Username;
81 ///
82 /// Pointer to a ASCII string that contains password. The caller is
83 /// responsible for freeing Password after GetModeData() is called.
84 ///
85 UINT8 *Password;
86 ///
87 /// Set it to TRUE to initiate an active data connection. Set it to
88 /// FALSE to initiate a passive data connection.
89 ///
90 BOOLEAN Active;
91 ///
92 /// Boolean value indicating if default network settting used.
93 ///
94 BOOLEAN UseDefaultSetting;
95 ///
96 /// IP address of station if UseDefaultSetting is FALSE.
97 ///
98 EFI_IPv4_ADDRESS StationIp;
99 ///
100 /// Subnet mask of station if UseDefaultSetting is FALSE.
101 ///
102 EFI_IPv4_ADDRESS SubnetMask;
103 ///
104 /// IP address of gateway if UseDefaultSetting is FALSE.
105 ///
106 EFI_IPv4_ADDRESS GatewayIp;
107 ///
108 /// IP address of FTPv4 server.
109 ///
110 EFI_IPv4_ADDRESS ServerIp;
111 ///
112 /// FTPv4 server port number of control connection, and the default
113 /// value is 21 as convention.
114 ///
115 UINT16 ServerPort;
116 ///
117 /// FTPv4 server port number of data connection. If it is zero, use
118 /// (ServerPort - 1) by convention.
119 ///
120 UINT16 AltDataPort;
121 ///
122 /// A byte indicate the representation type. The right 4 bit is used for
123 /// first parameter, the left 4 bit is use for second parameter
124 /// - For the first parameter, 0x0 = image, 0x1 = EBCDIC, 0x2 = ASCII, 0x3 = local
125 /// - For the second parameter, 0x0 = Non-print, 0x1 = Telnet format effectors, 0x2 =
126 /// Carriage Control.
127 /// - If it is a local type, the second parameter is the local byte byte size.
128 /// - If it is a image type, the second parameter is undefined.
129 ///
130 UINT8 RepType;
131 ///
132 /// Defines the file structure in FTP used. 0x00 = file, 0x01 = record, 0x02 = page.
133 ///
134 UINT8 FileStruct;
135 ///
136 /// Defines the transifer mode used in FTP. 0x00 = stream, 0x01 = Block, 0x02 = Compressed.
137 ///
138 UINT8 TransMode;
139 } EFI_FTP4_CONFIG_DATA;
140
141 typedef struct _EFI_FTP4_COMMAND_TOKEN EFI_FTP4_COMMAND_TOKEN;
142
143 /**
144 Callback function when process inbound or outbound data.
145
146 If it is receiving function that leads to inbound data, the callback function
147 is called when data buffer is full. Then, old data in the data buffer should be
148 flushed and new data is stored from the beginning of data buffer.
149 If it is a transmit function that lead to outbound data and the size of
150 Data in daata buffer has been transmitted, this callback function is called to
151 supply additional data to be transmitted.
152
153 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
154 @param[in] Token Pointer to the token structure to provide the parameters that
155 are used in this operation.
156 @return User defined Status.
157
158 **/
159 typedef
160 EFI_STATUS
161 (EFIAPI *EFI_FTP4_DATA_CALLBACK)(
162 IN EFI_FTP4_PROTOCOL *This,
163 IN EFI_FTP4_COMMAND_TOKEN *Token
164 );
165
166 ///
167 /// EFI_FTP4_COMMAND_TOKEN
168 ///
169 struct _EFI_FTP4_COMMAND_TOKEN {
170 ///
171 /// The Event to signal after request is finished and Status field
172 /// is updated by the EFI FTP v4 Protocol driver. The type of Event
173 /// must be EVT_NOTIFY_SIGNAL, and its Task Priority Level
174 /// (TPL) must be lower than or equal to TPL_CALLBACK. If it is
175 /// set to NULL, related function must wait until the function
176 /// completes.
177 ///
178 EFI_EVENT Event;
179 ///
180 /// Pointer to an ASCIIZ path name string.
181 ///
182 UINT8 *Pathname;
183 ///
184 /// The size of data buffer in bytes.
185 ///
186 UINT64 DataBufferSize;
187 ///
188 /// Pointer to the data buffer. Data downloaded from FTP server
189 /// through connection is downloaded here.
190 ///
191 VOID *DataBuffer;
192 ///
193 /// Pointer to a callback function. If it is receiving function that leads
194 /// to inbound data, the callback function is called when databuffer is
195 /// full. Then, old data in the data buffer should be flushed and new
196 /// data is stored from the beginning of data buffer. If it is a transmit
197 /// function that lead to outbound data and DataBufferSize of
198 /// Data in DataBuffer has been transmitted, this callback
199 /// function is called to supply additional data to be transmitted. The
200 /// size of additional data to be transmitted is indicated in
201 /// DataBufferSize, again. If there is no data remained,
202 /// DataBufferSize should be set to 0.
203 ///
204 EFI_FTP4_DATA_CALLBACK *DataCallback;
205 ///
206 /// Pointer to the parameter for DataCallback.
207 ///
208 VOID *Context;
209 ///
210 /// The variable to receive the result of the completed operation.
211 /// EFI_SUCCESS: The FTP command is completed successfully.
212 /// EFI_ACCESS_DENIED: The FTP server denied the access to the requested file.
213 /// EFI_CONNECTION_RESET: The connect fails because the connection is reset either
214 /// by instance itself or communication peer.
215 /// EFI_TIMEOUT: The connection establishment timer expired and no more
216 /// specific information is available.
217 /// EFI_NETWORK_UNREACHABLE: The active open fails because an ICMP network unreachable
218 /// error is received.
219 /// EFI_HOST_UNREACHABLE: The active open fails because an ICMP host unreachable
220 /// error is received.
221 /// EFI_PROTOCOL_UNREACHABLE: The active open fails because an ICMP protocol unreachable
222 /// error is received.
223 /// EFI_PORT_UNREACHABLE: The connection establishment timer times out and an ICMP port
224 /// unreachable error is received.
225 /// EFI_ICMP_ERROR: The connection establishment timer timeout and some other ICMP
226 /// error is received.
227 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
228 ///
229 EFI_STATUS Status;
230 };
231
232 /**
233 Gets the current operational settings.
234
235 The GetModeData() function reads the current operational settings of this
236 EFI FTPv4 Protocol driver instance. EFI_FTP4_CONFIG_DATA is defined in the
237 EFI_FTP4_PROTOCOL.Configure.
238
239 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
240 @param[out] ModeData Pointer to storage for the EFI FTPv4 Protocol driver
241 mode data. The string buffers for Username and Password
242 in EFI_FTP4_CONFIG_DATA are allocated by the function,
243 and the caller should take the responsibility to free the
244 buffer later.
245
246 @retval EFI_SUCCESS This function is called successfully.
247 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
248 - This is NULL.
249 - ModeData is NULL.
250 @retval EFI_NOT_STARTED The EFI FTPv4 Protocol driver has not been started
251 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
252 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
253
254 **/
255 typedef
256 EFI_STATUS
257 (EFIAPI *EFI_FTP4_GET_MODE_DATA)(
258 IN EFI_FTP4_PROTOCOL *This,
259 OUT EFI_FTP4_CONFIG_DATA *ModeData
260 );
261
262 /**
263 Disconnecting a FTP connection gracefully.
264
265 The Connect() function will initiate a connection request to the remote FTP server
266 with the corresponding connection token. If this function returns EFI_SUCCESS, the
267 connection sequence is initiated successfully. If the connection succeeds or faild
268 due to any error, the Token->Event will be signaled and Token->Status will be updated
269 accordingly.
270
271 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
272 @param[in] Token Pointer to the token used to establish control connection.
273
274 @retval EFI_SUCCESS The connection sequence is successfully initiated.
275 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
276 - This is NULL.
277 - Token is NULL.
278 - Token->Event is NULL.
279 @retval EFI_NOT_STARTED The EFI FTPv4 Protocol driver has not been started.
280 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
281 RARP, etc.) is not finished yet.
282 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
283 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
284
285 **/
286 typedef
287 EFI_STATUS
288 (EFIAPI *EFI_FTP4_CONNECT)(
289 IN EFI_FTP4_PROTOCOL *This,
290 IN EFI_FTP4_CONNECTION_TOKEN *Token
291 );
292
293 /**
294 Disconnecting a FTP connection gracefully.
295
296 The Close() function will initiate a close request to the remote FTP server with the
297 corresponding connection token. If this function returns EFI_SUCCESS, the control
298 connection with the remote FTP server is closed.
299
300 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
301 @param[in] Token Pointer to the token used to close control connection.
302
303 @retval EFI_SUCCESS The close request is successfully initiated.
304 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
305 - This is NULL.
306 - Token is NULL.
307 - Token->Event is NULL.
308 @retval EFI_NOT_STARTED The EFI FTPv4 Protocol driver has not been started.
309 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
310 RARP, etc.) is not finished yet.
311 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
312 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
313
314 **/
315 typedef
316 EFI_STATUS
317 (EFIAPI *EFI_FTP4_CLOSE)(
318 IN EFI_FTP4_PROTOCOL *This,
319 IN EFI_FTP4_CONNECTION_TOKEN *Token
320 );
321
322 /**
323 Sets or clears the operational parameters for the FTP child driver.
324
325 The Configure() function will configure the connected FTP session with the
326 configuration setting specified in FtpConfigData. The configuration data can
327 be reset by calling Configure() with FtpConfigData set to NULL.
328
329 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
330 @param[in] FtpConfigData Pointer to configuration data that will be assigned to
331 the FTP child driver instance. If NULL, the FTP child
332 driver instance is reset to startup defaults and all
333 pending transmit and receive requests are flushed.
334
335 @retval EFI_SUCCESS The FTPv4 driver was configured successfully.
336 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
337 - This is NULL.
338 - FtpConfigData.RepType is invalid.
339 - FtpConfigData.FileStruct is invalid.
340 - FtpConfigData.TransMode is invalid.
341 - IP address in FtpConfigData is invalid.
342 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
343 RARP, etc.) is not finished yet.
344 @retval EFI_UNSUPPORTED One or more of the configuration parameters are not supported
345 by this implementation.
346 @retval EFI_OUT_OF_RESOURCES The EFI FTPv4 Protocol driver instance data could not be
347 allocated.
348 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI FTPv4
349 Protocol driver instance is not configured.
350
351 **/
352 typedef
353 EFI_STATUS
354 (EFIAPI *EFI_FTP4_CONFIGURE)(
355 IN EFI_FTP4_PROTOCOL *This,
356 IN EFI_FTP4_CONFIG_DATA *FtpConfigData OPTIONAL
357 );
358
359
360 /**
361 Downloads a file from an FTPv4 server.
362
363 The ReadFile() function is used to initialize and start an FTPv4 download process
364 and optionally wait for completion. When the download operation completes, whether
365 successfully or not, the Token.Status field is updated by the EFI FTPv4 Protocol
366 driver and then Token.Event is signaled (if it is not NULL).
367
368 Data will be downloaded from the FTPv4 server into Token.DataBuffer. If the file size
369 is larger than Token.DataBufferSize, Token.DataCallback will be called to allow for
370 processing data and then new data will be placed at the beginning of Token.DataBuffer.
371
372 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
373 @param[in] Token Pointer to the token structure to provide the parameters that
374 are used in this operation.
375
376 @retval EFI_SUCCESS The data file is being downloaded successfully.
377 @retval EFI_INVALID_PARAMETER One or more of the parameters is not valid.
378 - This is NULL.
379 - Token is NULL.
380 - Token.Pathname is NULL.
381 - Token. DataBuffer is NULL.
382 - Token. DataBufferSize is 0.
383 @retval EFI_NOT_STARTED The EFI FTPv4 Protocol driver has not been started.
384 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
385 RARP, etc.) is not finished yet.
386 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
387 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
388
389 **/
390 typedef
391 EFI_STATUS
392 (EFIAPI *EFI_FTP4_READ_FILE)(
393 IN EFI_FTP4_PROTOCOL *This,
394 IN EFI_FTP4_COMMAND_TOKEN *Token
395 );
396
397 /**
398 Uploads a file from an FTPv4 server.
399
400 The WriteFile() function is used to initialize and start an FTPv4 upload process and
401 optionally wait for completion. When the upload operation completes, whether successfully
402 or not, the Token.Status field is updated by the EFI FTPv4 Protocol driver and then
403 Token.Event is signaled (if it is not NULL). Data to be uploaded to server is stored
404 into Token.DataBuffer. Token.DataBufferSize is the number bytes to be transferred.
405 If the file size is larger than Token.DataBufferSize, Token.DataCallback will be called
406 to allow for processing data and then new data will be placed at the beginning of
407 Token.DataBuffer. Token.DataBufferSize is updated to reflect the actual number of bytes
408 to be transferred. Token.DataBufferSize is set to 0 by the call back to indicate the
409 completion of data transfer.
410
411 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
412 @param[in] Token Pointer to the token structure to provide the parameters that
413 are used in this operation.
414
415 @retval EFI_SUCCESS TThe data file is being uploaded successfully.
416 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
417 @retval EFI_INVALID_PARAMETER One or more of the parameters is not valid.
418 - This is NULL.
419 - Token is NULL.
420 - Token.Pathname is NULL.
421 - Token. DataBuffer is NULL.
422 - Token. DataBufferSize is 0.
423 @retval EFI_NOT_STARTED The EFI FTPv4 Protocol driver has not been started.
424 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
425 RARP, etc.) is not finished yet.
426 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
427 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
428
429 **/
430 typedef
431 EFI_STATUS
432 (EFIAPI *EFI_FTP4_WRITE_FILE)(
433 IN EFI_FTP4_PROTOCOL *This,
434 IN EFI_FTP4_COMMAND_TOKEN *Token
435 );
436
437 /**
438 Download a data file "directory" from a FTPv4 server. May be unsupported in some EFI
439 implementations.
440
441 The ReadDirectory() function is used to return a list of files on the FTPv4 server that
442 logically (or operationally) related to Token.Pathname, and optionally wait for completion.
443 When the download operation completes, whether successfully or not, the Token.Status field
444 is updated by the EFI FTPv4 Protocol driver and then Token.Event is signaled (if it is not
445 NULL). Data will be downloaded from the FTPv4 server into Token.DataBuffer. If the file size
446 is larger than Token.DataBufferSize, Token.DataCallback will be called to allow for processing
447 data and then new data will be placed at the beginning of Token.DataBuffer.
448
449 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
450 @param[in] Token Pointer to the token structure to provide the parameters that
451 are used in this operation.
452
453 @retval EFI_SUCCESS The file list information is being downloaded successfully.
454 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
455 @retval EFI_INVALID_PARAMETER One or more of the parameters is not valid.
456 - This is NULL.
457 - Token is NULL.
458 - Token. DataBuffer is NULL.
459 - Token. DataBufferSize is 0.
460 @retval EFI_NOT_STARTED The EFI FTPv4 Protocol driver has not been started.
461 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
462 RARP, etc.) is not finished yet.
463 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
464 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
465
466 **/
467 typedef
468 EFI_STATUS
469 (EFIAPI *EFI_FTP4_READ_DIRECTORY)(
470 IN EFI_FTP4_PROTOCOL *This,
471 IN EFI_FTP4_COMMAND_TOKEN *Token
472 );
473
474 /**
475 Polls for incoming data packets and processes outgoing data packets.
476
477 The Poll() function can be used by network drivers and applications to increase the
478 rate that data packets are moved between the communications device and the transmit
479 and receive queues. In some systems, the periodic timer event in the managed network
480 driver may not poll the underlying communications device fast enough to transmit
481 and/or receive all data packets without missing incoming packets or dropping outgoing
482 packets. Drivers and applications that are experiencing packet loss should try calling
483 the Poll() function more often.
484
485 @param[in] This Pointer to the EFI_FTP4_PROTOCOL instance.
486
487 @retval EFI_SUCCESS Incoming or outgoing data was processed.
488 @retval EFI_NOT_STARTED This EFI FTPv4 Protocol instance has not been started.
489 @retval EFI_INVALID_PARAMETER This is NULL.
490 @retval EFI_DEVICE_ERROR EapAuthType An unexpected system or network error occurred.
491 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
492 Consider increasing the polling rate.
493
494 **/
495 typedef
496 EFI_STATUS
497 (EFIAPI *EFI_FTP4_POLL)(
498 IN EFI_FTP4_PROTOCOL *This
499 );
500
501 ///
502 /// EFI_FTP4_PROTOCOL
503 /// provides basic services for client-side FTP (File Transfer Protocol)
504 /// operations.
505 ///
506 struct _EFI_FTP4_PROTOCOL {
507 EFI_FTP4_GET_MODE_DATA GetModeData;
508 EFI_FTP4_CONNECT Connect;
509 EFI_FTP4_CLOSE Close;
510 EFI_FTP4_CONFIGURE Configure;
511 EFI_FTP4_READ_FILE ReadFile;
512 EFI_FTP4_WRITE_FILE WriteFile;
513 EFI_FTP4_READ_DIRECTORY ReadDirectory;
514 EFI_FTP4_POLL Poll;
515 };
516
517 extern EFI_GUID gEfiFtp4ServiceBindingProtocolGuid;
518 extern EFI_GUID gEfiFtp4ProtocolGuid;
519
520 #endif
521