瀏覽代碼

Make all TCP methods optional; at least FTP data is a read-only

connection and so legitimately ignores acked() and senddata().
tags/v0.9.3
Michael Brown 18 年之前
父節點
當前提交
04b6a1e004
共有 2 個檔案被更改,包括 11 行新增46 行删除
  1. 9
    9
      src/net/tcp.c
  2. 2
    37
      src/net/tcp/ftp.c

+ 9
- 9
src/net/tcp.c 查看文件

@@ -137,20 +137,20 @@ void uip_tcp_appcall ( void ) {
137 137
 	assert ( conn->tcp_op->newdata != NULL );
138 138
 	assert ( conn->tcp_op->senddata != NULL );
139 139
 
140
-	if ( uip_aborted() && op->aborted ) /* optional method */
140
+	if ( uip_aborted() && op->aborted )
141 141
 		op->aborted ( conn );
142
-	if ( uip_timedout() && op->timedout ) /* optional method */
142
+	if ( uip_timedout() && op->timedout )
143 143
 		op->timedout ( conn );
144
-	if ( uip_closed() && op->closed ) /* optional method */
144
+	if ( uip_closed() && op->closed )
145 145
 		op->closed ( conn );
146
-	if ( uip_connected() )
146
+	if ( uip_connected() && op->connected )
147 147
 		op->connected ( conn );
148
-	if ( uip_acked() )
148
+	if ( uip_acked() && op->acked )
149 149
 		op->acked ( conn, uip_conn->len );
150
-	if ( uip_newdata() )
150
+	if ( uip_newdata() && op->newdata )
151 151
 		op->newdata ( conn, ( void * ) uip_appdata, uip_len );
152
-	if ( uip_rexmit() || uip_newdata() || uip_acked() ||
153
-	     uip_connected() || uip_poll() )
152
+	if ( ( uip_rexmit() || uip_newdata() || uip_acked() ||
153
+	       uip_connected() || uip_poll() ) && op->senddata )
154 154
 		op->senddata ( conn );
155 155
 }
156 156
 
@@ -194,7 +194,7 @@ static void tcp_periodic ( void ) {
194 194
  * This calls tcp_periodic() at regular intervals.
195 195
  */
196 196
 static void tcp_step ( struct process *process ) {
197
-	static long timeout = 0;
197
+	static unsigned long timeout = 0;
198 198
 
199 199
 	if ( currticks() > timeout ) {
200 200
 		timeout = currticks() + ( TICKS_PER_SEC / 10 );

+ 2
- 37
src/net/tcp/ftp.c 查看文件

@@ -58,19 +58,13 @@ static void ftp_closed ( struct tcp_connection *conn ) {
58 58
 	ftp_complete ( ftp, 1 );
59 59
 }
60 60
 
61
-static void ftp_connected ( struct tcp_connection *conn ) {
62
-	struct ftp_request *ftp = tcp_to_ftp ( conn );
63
-
64
-	/* Nothing to do */
65
-}
66
-
67 61
 static void ftp_acked ( struct tcp_connection *conn, size_t len ) {
68 62
 	struct ftp_request *ftp = tcp_to_ftp ( conn );
69 63
 	
70 64
 	ftp->already_sent += len;
71 65
 }
72 66
 
73
-static int ftp_open_passive ( struct ftp_request *ftp ) {
67
+int ftp_open_passive ( struct ftp_request *ftp ) {
74 68
 	char *ptr = ftp->passive_text;
75 69
 	uint8_t *byte = ( uint8_t * ) ( &ftp->tcp_data.sin );
76 70
 	int i;
@@ -90,7 +84,7 @@ static int ftp_open_passive ( struct ftp_request *ftp ) {
90 84
 	return 0;
91 85
 }
92 86
 
93
-static void ftp_reply ( struct ftp_request *ftp ) {
87
+void ftp_reply ( struct ftp_request *ftp ) {
94 88
 	char status_major = ftp->status_text[0];
95 89
 	int success;
96 90
 
@@ -190,7 +184,6 @@ static struct tcp_operations ftp_tcp_operations = {
190 184
 	.aborted	= ftp_aborted,
191 185
 	.timedout	= ftp_timedout,
192 186
 	.closed		= ftp_closed,
193
-	.connected	= ftp_connected,
194 187
 	.acked		= ftp_acked,
195 188
 	.newdata	= ftp_newdata,
196 189
 	.senddata	= ftp_senddata,
@@ -208,24 +201,6 @@ static void ftp_data_timedout ( struct tcp_connection *conn ) {
208 201
 	ftp_complete ( ftp, -ETIMEDOUT );
209 202
 }
210 203
 
211
-static void ftp_data_closed ( struct tcp_connection *conn ) {
212
-	struct ftp_request *ftp = tcp_to_ftp_data ( conn );
213
-
214
-	/* Nothing to do */
215
-}
216
-
217
-static void ftp_data_connected ( struct tcp_connection *conn ) {
218
-	struct ftp_request *ftp = tcp_to_ftp_data ( conn );
219
-
220
-	/* Nothing to do */
221
-}
222
-
223
-static void ftp_data_acked ( struct tcp_connection *conn, size_t len ) {
224
-	struct ftp_request *ftp = tcp_to_ftp_data ( conn );
225
-	
226
-	/* Nothing to do */
227
-}
228
-
229 204
 static void ftp_data_newdata ( struct tcp_connection *conn,
230 205
 			       void *data, size_t len ) {
231 206
 	struct ftp_request *ftp = tcp_to_ftp_data ( conn );
@@ -233,20 +208,10 @@ static void ftp_data_newdata ( struct tcp_connection *conn,
233 208
 	ftp->callback ( data, len );
234 209
 }
235 210
 
236
-static void ftp_data_senddata ( struct tcp_connection *conn ) {
237
-	struct ftp_request *ftp = tcp_to_ftp_data ( conn );
238
-	
239
-	/* Nothing to do */
240
-}
241
-
242 211
 static struct tcp_operations ftp_data_tcp_operations = {
243 212
 	.aborted	= ftp_data_aborted,
244 213
 	.timedout	= ftp_data_timedout,
245
-	.closed		= ftp_data_closed,
246
-	.connected	= ftp_data_connected,
247
-	.acked		= ftp_data_acked,
248 214
 	.newdata	= ftp_data_newdata,
249
-	.senddata	= ftp_data_senddata,
250 215
 };
251 216
 
252 217
 /**

Loading…
取消
儲存