summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/ftp.h
blob: 64e8d4e4f3f71cd3385e2a7e97e3b24e253a256c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef _GPXE_FTP_H
#define _GPXE_FTP_H

/** @file
 *
 * File transfer protocol
 *
 */

#include <stdint.h>
#include <gpxe/async.h>
#include <gpxe/tcp.h>

struct buffer;

/** FTP default port */
#define FTP_PORT 21

/**
 * FTP states
 *
 * These @b must be sequential, i.e. a successful FTP session must
 * pass through each of these states in order.
 */
enum ftp_state {
	FTP_CONNECT = 0,
	FTP_USER,
	FTP_PASS,
	FTP_TYPE,
	FTP_PASV,
	FTP_RETR,
	FTP_QUIT,
	FTP_DONE,
};

/**
 * An FTP request
 *
 */
struct ftp_request {
	/** URI being fetched */
	struct uri *uri;
	/** Data buffer to fill */
	struct buffer *buffer;
	/** Asynchronous operation */
	struct async async;

	/** Current state */
	enum ftp_state state;
	/** Amount of current message already transmitted */
	size_t already_sent;
	/** Buffer to be filled with data received via the control channel */
	char *recvbuf;
	/** Remaining size of recvbuf */
	size_t recvsize;
	/** FTP status code, as text */
	char status_text[4];
	/** Passive-mode parameters, as text */
	char passive_text[24]; /* "aaa,bbb,ccc,ddd,eee,fff" */
	/** TCP application for the control channel */
	struct tcp_application tcp;
	/** TCP application for the data channel */
	struct tcp_application tcp_data;
};

extern int ftp_get ( struct uri *uri, struct buffer *buffer,
		     struct async *parent );

#endif /* _GPXE_FTP_H */