aboutsummaryrefslogtreecommitdiff
path: root/networking/tftp.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-12 14:57:37 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-12 14:57:37 +0000
commit2c91652bbcc82c794c26230806058b04f1711033 (patch)
tree1195f7c7fba68bdaf175d85432bf60a60a8c29f0 /networking/tftp.c
parent6536a9b5833febe719988526a095a9cacb8a1042 (diff)
downloadbusybox-w32-2c91652bbcc82c794c26230806058b04f1711033.tar.gz
busybox-w32-2c91652bbcc82c794c26230806058b04f1711033.tar.bz2
busybox-w32-2c91652bbcc82c794c26230806058b04f1711033.zip
next part of ipv6-ization. dnsd code is "interesting"...
Diffstat (limited to 'networking/tftp.c')
-rw-r--r--networking/tftp.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index 43e835a5d..9aa87d57e 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -240,10 +240,8 @@ static int tftp(
240 } 240 }
241 } 241 }
242 242
243
244 /* send packet */ 243 /* send packet */
245 244
246
247 timeout = TFTP_NUM_RETRIES; /* re-initialize */ 245 timeout = TFTP_NUM_RETRIES; /* re-initialize */
248 do { 246 do {
249 len = cp - xbuf; 247 len = cp - xbuf;
@@ -260,13 +258,12 @@ static int tftp(
260 break; 258 break;
261 } 259 }
262 260
263
264 if (finished && (opcode == TFTP_ACK)) { 261 if (finished && (opcode == TFTP_ACK)) {
265 break; 262 break;
266 } 263 }
267 264
268 /* receive packet */ 265 /* receive packet */
269 266 recv_again:
270 tv.tv_sec = TFTP_TIMEOUT; 267 tv.tv_sec = TFTP_TIMEOUT;
271 tv.tv_usec = 0; 268 tv.tv_usec = 0;
272 269
@@ -288,25 +285,16 @@ static int tftp(
288 bb_perror_msg("recvfrom"); 285 bb_perror_msg("recvfrom");
289 break; 286 break;
290 } 287 }
291 timeout = 0;
292 if (from->sa_family == peer_lsa->sa.sa_family) {
293#if ENABLE_FEATURE_IPV6 288#if ENABLE_FEATURE_IPV6
294 if (from->sa_family == AF_INET6 289 if (from->sa_family == AF_INET6)
295 && ((struct sockaddr_in6*)from)->sin6_port == port 290 if (((struct sockaddr_in6*)from)->sin6_port != port)
296 ) 291 goto recv_again;
297 break;
298#endif 292#endif
299 /* Non-internet sockets are ok */ 293 if (from->sa_family == AF_INET)
300 if (from->sa_family != AF_INET) 294 if (((struct sockaddr_in*)from)->sin_port != port)
301 break; 295 goto recv_again;
302 if (((struct sockaddr_in*)from)->sin_port == port) 296 timeout = 0;
303 break; 297 break;
304 }
305 /* family doesn't match, or
306 * it is INET[v6] and port doesn't match -
307 * fall-through for bad packets!
308 * (discard the packet - treat as timeout) */
309 timeout = TFTP_NUM_RETRIES;
310 case 0: 298 case 0:
311 bb_error_msg("timeout"); 299 bb_error_msg("timeout");
312 timeout--; 300 timeout--;
@@ -436,11 +424,11 @@ static int tftp(
436 } 424 }
437 } 425 }
438 426
439#if ENABLE_FEATURE_CLEAN_UP 427 if (ENABLE_FEATURE_CLEAN_UP) {
440 close(socketfd); 428 close(socketfd);
441 free(xbuf); 429 free(xbuf);
442 free(rbuf); 430 free(rbuf);
443#endif 431 }
444 432
445 return finished ? EXIT_SUCCESS : EXIT_FAILURE; 433 return finished ? EXIT_SUCCESS : EXIT_FAILURE;
446} 434}