Browse Source

Added debug messages

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
9600af14a3
1 changed files with 34 additions and 0 deletions
  1. 34
    0
      src/net/tcp/ftp.c

+ 34
- 0
src/net/tcp/ftp.c View File

67
 	return container_of ( conn, struct ftp_request, tcp );
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
 static void ftp_set_status ( struct ftp_request *ftp, int rc ) {
80
 static void ftp_set_status ( struct ftp_request *ftp, int rc ) {
71
 	if ( ! ftp->rc )
81
 	if ( ! ftp->rc )
72
 		ftp->rc = rc;
82
 		ftp->rc = rc;
73
 }
83
 }
74
 
84
 
85
+/**
86
+ * Clear overall FTP operation status
87
+ *
88
+ * @v ftp		FTP request
89
+ */
75
 static void ftp_clear_status ( struct ftp_request *ftp ) {
90
 static void ftp_clear_status ( struct ftp_request *ftp ) {
76
 	ftp->rc = 0;
91
 	ftp->rc = 0;
77
 }
92
 }
82
  * @v ftp		FTP request
97
  * @v ftp		FTP request
83
  */
98
  */
84
 static void ftp_done ( struct ftp_request *ftp ) {
99
 static void ftp_done ( struct ftp_request *ftp ) {
100
+
101
+	DBG ( "FTP %p completed with status %d\n", ftp, ftp->rc );
102
+
85
 	async_done ( &ftp->aop, ftp->rc );
103
 	async_done ( &ftp->aop, ftp->rc );
86
 }
104
 }
87
 
105
 
118
 static void ftp_reply ( struct ftp_request *ftp ) {
136
 static void ftp_reply ( struct ftp_request *ftp ) {
119
 	char status_major = ftp->status_text[0];
137
 	char status_major = ftp->status_text[0];
120
 
138
 
139
+	DBG ( "FTP %p received status %s\n", ftp, ftp->status_text );
140
+
121
 	/* Ignore "intermediate" responses (1xx codes) */
141
 	/* Ignore "intermediate" responses (1xx codes) */
122
 	if ( status_major == '1' )
142
 	if ( status_major == '1' )
123
 		return;
143
 		return;
148
 	if ( ftp->state < FTP_DONE )
168
 	if ( ftp->state < FTP_DONE )
149
 		ftp->state++;
169
 		ftp->state++;
150
 	ftp->already_sent = 0;
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
 	return;
178
 	return;
152
 
179
 
153
  err:
180
  err:
256
 static void ftp_closed ( struct tcp_connection *conn, int status ) {
283
 static void ftp_closed ( struct tcp_connection *conn, int status ) {
257
 	struct ftp_request *ftp = tcp_to_ftp ( conn );
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
 	/* Close data channel and record status */
288
 	/* Close data channel and record status */
260
 	ftp_set_status ( ftp, status );
289
 	ftp_set_status ( ftp, status );
261
 	tcp_close ( &ftp->tcp_data );
290
 	tcp_close ( &ftp->tcp_data );
305
  */
334
  */
306
 static void ftp_data_closed ( struct tcp_connection *conn, int status ) {
335
 static void ftp_data_closed ( struct tcp_connection *conn, int status ) {
307
 	struct ftp_request *ftp = tcp_to_ftp_data ( conn );
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
 	/* If there was an error, close control channel and record status */
340
 	/* If there was an error, close control channel and record status */
310
 	if ( status ) {
341
 	if ( status ) {
353
  * @v ftp	FTP request
384
  * @v ftp	FTP request
354
  */
385
  */
355
 struct async_operation * ftp_get ( struct ftp_request *ftp ) {
386
 struct async_operation * ftp_get ( struct ftp_request *ftp ) {
387
+	
388
+	DBG ( "FTP %p fetching %s\n", ftp, ftp->filename );
389
+
356
 	ftp->tcp.tcp_op = &ftp_tcp_operations;
390
 	ftp->tcp.tcp_op = &ftp_tcp_operations;
357
 	ftp->tcp_data.tcp_op = &ftp_data_tcp_operations;
391
 	ftp->tcp_data.tcp_op = &ftp_data_tcp_operations;
358
 	ftp->recvbuf = ftp->status_text;
392
 	ftp->recvbuf = ftp->status_text;

Loading…
Cancel
Save