|
@@ -67,11 +67,26 @@ static inline struct ftp_request * tcp_to_ftp ( struct tcp_connection *conn ) {
|
67
|
67
|
return container_of ( conn, struct ftp_request, tcp );
|
68
|
68
|
}
|
69
|
69
|
|
|
70
|
+/**
|
|
71
|
+ * Set overall FTP operation status
|
|
72
|
+ *
|
|
73
|
+ * @v ftp FTP request
|
|
74
|
+ * @v rc Return status code
|
|
75
|
+ *
|
|
76
|
+ * Set the return status that will eventually be returned via
|
|
77
|
+ * ftp_done(). If multiple errors are flagged, only the first will be
|
|
78
|
+ * returned.
|
|
79
|
+ */
|
70
|
80
|
static void ftp_set_status ( struct ftp_request *ftp, int rc ) {
|
71
|
81
|
if ( ! ftp->rc )
|
72
|
82
|
ftp->rc = rc;
|
73
|
83
|
}
|
74
|
84
|
|
|
85
|
+/**
|
|
86
|
+ * Clear overall FTP operation status
|
|
87
|
+ *
|
|
88
|
+ * @v ftp FTP request
|
|
89
|
+ */
|
75
|
90
|
static void ftp_clear_status ( struct ftp_request *ftp ) {
|
76
|
91
|
ftp->rc = 0;
|
77
|
92
|
}
|
|
@@ -82,6 +97,9 @@ static void ftp_clear_status ( struct ftp_request *ftp ) {
|
82
|
97
|
* @v ftp FTP request
|
83
|
98
|
*/
|
84
|
99
|
static void ftp_done ( struct ftp_request *ftp ) {
|
|
100
|
+
|
|
101
|
+ DBG ( "FTP %p completed with status %d\n", ftp, ftp->rc );
|
|
102
|
+
|
85
|
103
|
async_done ( &ftp->aop, ftp->rc );
|
86
|
104
|
}
|
87
|
105
|
|
|
@@ -118,6 +136,8 @@ static void ftp_parse_value ( char **text, uint8_t *value, size_t len ) {
|
118
|
136
|
static void ftp_reply ( struct ftp_request *ftp ) {
|
119
|
137
|
char status_major = ftp->status_text[0];
|
120
|
138
|
|
|
139
|
+ DBG ( "FTP %p received status %s\n", ftp, ftp->status_text );
|
|
140
|
+
|
121
|
141
|
/* Ignore "intermediate" responses (1xx codes) */
|
122
|
142
|
if ( status_major == '1' )
|
123
|
143
|
return;
|
|
@@ -148,6 +168,13 @@ static void ftp_reply ( struct ftp_request *ftp ) {
|
148
|
168
|
if ( ftp->state < FTP_DONE )
|
149
|
169
|
ftp->state++;
|
150
|
170
|
ftp->already_sent = 0;
|
|
171
|
+
|
|
172
|
+ if ( ftp->state < FTP_DONE ) {
|
|
173
|
+ DBG ( "FTP %p sending ", ftp );
|
|
174
|
+ DBG ( ftp_strings[ftp->state].format, ftp_string_data ( ftp,
|
|
175
|
+ ftp_strings[ftp->state].data_offset ) );
|
|
176
|
+ }
|
|
177
|
+
|
151
|
178
|
return;
|
152
|
179
|
|
153
|
180
|
err:
|
|
@@ -256,6 +283,8 @@ static void ftp_senddata ( struct tcp_connection *conn,
|
256
|
283
|
static void ftp_closed ( struct tcp_connection *conn, int status ) {
|
257
|
284
|
struct ftp_request *ftp = tcp_to_ftp ( conn );
|
258
|
285
|
|
|
286
|
+ DBG ( "FTP %p control connection closed (status %d)\n", ftp, status );
|
|
287
|
+
|
259
|
288
|
/* Close data channel and record status */
|
260
|
289
|
ftp_set_status ( ftp, status );
|
261
|
290
|
tcp_close ( &ftp->tcp_data );
|
|
@@ -305,6 +334,8 @@ tcp_to_ftp_data ( struct tcp_connection *conn ) {
|
305
|
334
|
*/
|
306
|
335
|
static void ftp_data_closed ( struct tcp_connection *conn, int status ) {
|
307
|
336
|
struct ftp_request *ftp = tcp_to_ftp_data ( conn );
|
|
337
|
+
|
|
338
|
+ DBG ( "FTP %p data connection closed (status %d)\n", ftp, status );
|
308
|
339
|
|
309
|
340
|
/* If there was an error, close control channel and record status */
|
310
|
341
|
if ( status ) {
|
|
@@ -353,6 +384,9 @@ static struct tcp_operations ftp_data_tcp_operations = {
|
353
|
384
|
* @v ftp FTP request
|
354
|
385
|
*/
|
355
|
386
|
struct async_operation * ftp_get ( struct ftp_request *ftp ) {
|
|
387
|
+
|
|
388
|
+ DBG ( "FTP %p fetching %s\n", ftp, ftp->filename );
|
|
389
|
+
|
356
|
390
|
ftp->tcp.tcp_op = &ftp_tcp_operations;
|
357
|
391
|
ftp->tcp_data.tcp_op = &ftp_data_tcp_operations;
|
358
|
392
|
ftp->recvbuf = ftp->status_text;
|