aboutsummaryrefslogtreecommitdiff
path: root/networking/tftp.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-10-24 05:00:29 +0000
committerEric Andersen <andersen@codepoet.org>2001-10-24 05:00:29 +0000
commitbdfd0d78bc44e73d693510e70087857785b3b521 (patch)
tree153a573095afac8d8d0ea857759ecabd77fb28b7 /networking/tftp.c
parent9260fc5552a3ee52eb95823aa6689d52a1ffd33c (diff)
downloadbusybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.tar.gz
busybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.tar.bz2
busybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.zip
Major rework of the directory structure and the entire build system.
-Erik
Diffstat (limited to 'networking/tftp.c')
-rw-r--r--networking/tftp.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index 530b3d134..38a6f81f0 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -46,7 +46,7 @@
46 46
47#include "busybox.h" 47#include "busybox.h"
48 48
49//#define BB_FEATURE_TFTP_DEBUG 49//#define CONFIG_FEATURE_TFTP_DEBUG
50 50
51#define TFTP_BLOCKSIZE_DEFAULT 512 /* according to RFC 1350, don't change */ 51#define TFTP_BLOCKSIZE_DEFAULT 512 /* according to RFC 1350, don't change */
52#define TFTP_TIMEOUT 5 /* seconds */ 52#define TFTP_TIMEOUT 5 /* seconds */
@@ -74,7 +74,7 @@ static const char *tftp_error_msg[] = {
74const int tftp_cmd_get = 1; 74const int tftp_cmd_get = 1;
75const int tftp_cmd_put = 2; 75const int tftp_cmd_put = 2;
76 76
77#ifdef BB_FEATURE_TFTP_BLOCKSIZE 77#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
78 78
79static int tftp_blocksize_check(int blocksize, int bufsize) 79static int tftp_blocksize_check(int blocksize, int bufsize)
80{ 80{
@@ -158,11 +158,11 @@ static inline int tftp(const int cmd, const struct hostent *host,
158 int timeout = bb_tftp_num_retries; 158 int timeout = bb_tftp_num_retries;
159 int block_nr = 1; 159 int block_nr = 1;
160 160
161#ifdef BB_FEATURE_TFTP_BLOCKSIZE 161#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
162 int want_option_ack = 0; 162 int want_option_ack = 0;
163#endif 163#endif
164 164
165 RESERVE_BB_BUFFER(buf, tftp_bufsize + 4); /* Opcode + Block # + Data */ 165 RESERVE_CONFIG_BUFFER(buf, tftp_bufsize + 4); /* Opcode + Block # + Data */
166 166
167 tftp_bufsize += 4; 167 tftp_bufsize += 4;
168 168
@@ -230,7 +230,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
230 memcpy(cp, "octet", 6); 230 memcpy(cp, "octet", 6);
231 cp += 6; 231 cp += 6;
232 232
233#ifdef BB_FEATURE_TFTP_BLOCKSIZE 233#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
234 234
235 len = tftp_bufsize - 4; /* data block size */ 235 len = tftp_bufsize - 4; /* data block size */
236 236
@@ -290,7 +290,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
290 290
291 len = cp - buf; 291 len = cp - buf;
292 292
293#ifdef BB_FEATURE_TFTP_DEBUG 293#ifdef CONFIG_FEATURE_TFTP_DEBUG
294 printf("sending %u bytes\n", len); 294 printf("sending %u bytes\n", len);
295 for (cp = buf; cp < &buf[len]; cp++) 295 for (cp = buf; cp < &buf[len]; cp++)
296 printf("%02x ", *cp); 296 printf("%02x ", *cp);
@@ -367,7 +367,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
367 opcode = ntohs(*((unsigned short *) buf)); 367 opcode = ntohs(*((unsigned short *) buf));
368 tmp = ntohs(*((unsigned short *) &buf[2])); 368 tmp = ntohs(*((unsigned short *) &buf[2]));
369 369
370#ifdef BB_FEATURE_TFTP_DEBUG 370#ifdef CONFIG_FEATURE_TFTP_DEBUG
371 printf("received %d bytes: %04x %04x\n", len, opcode, tmp); 371 printf("received %d bytes: %04x %04x\n", len, opcode, tmp);
372#endif 372#endif
373 373
@@ -390,7 +390,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
390 break; 390 break;
391 } 391 }
392 392
393#ifdef BB_FEATURE_TFTP_BLOCKSIZE 393#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
394 if (want_option_ack) { 394 if (want_option_ack) {
395 395
396 want_option_ack = 0; 396 want_option_ack = 0;
@@ -416,7 +416,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
416 else { 416 else {
417 opcode = TFTP_ACK; 417 opcode = TFTP_ACK;
418 } 418 }
419#ifdef BB_FEATURE_TFTP_DEBUG 419#ifdef CONFIG_FEATURE_TFTP_DEBUG
420 printf("using blksize %u\n"); 420 printf("using blksize %u\n");
421#endif 421#endif
422 tftp_bufsize = foo + 4; 422 tftp_bufsize = foo + 4;
@@ -470,10 +470,10 @@ static inline int tftp(const int cmd, const struct hostent *host,
470 } 470 }
471 } 471 }
472 472
473#ifdef BB_FEATURE_CLEAN_UP 473#ifdef CONFIG_FEATURE_CLEAN_UP
474 close(socketfd); 474 close(socketfd);
475 475
476 RELEASE_BB_BUFFER(buf); 476 RELEASE_CONFIG_BUFFER(buf);
477#endif 477#endif
478 478
479 return finished ? EXIT_SUCCESS : EXIT_FAILURE; 479 return finished ? EXIT_SUCCESS : EXIT_FAILURE;
@@ -494,19 +494,19 @@ int tftp_main(int argc, char **argv)
494 494
495 /* figure out what to pass to getopt */ 495 /* figure out what to pass to getopt */
496 496
497#ifdef BB_FEATURE_TFTP_BLOCKSIZE 497#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
498#define BS "b:" 498#define BS "b:"
499#else 499#else
500#define BS 500#define BS
501#endif 501#endif
502 502
503#ifdef BB_FEATURE_TFTP_GET 503#ifdef CONFIG_FEATURE_TFTP_GET
504#define GET "g" 504#define GET "g"
505#else 505#else
506#define GET 506#define GET
507#endif 507#endif
508 508
509#ifdef BB_FEATURE_TFTP_PUT 509#ifdef CONFIG_FEATURE_TFTP_PUT
510#define PUT "p" 510#define PUT "p"
511#else 511#else
512#define PUT 512#define PUT
@@ -514,7 +514,7 @@ int tftp_main(int argc, char **argv)
514 514
515 while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) { 515 while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) {
516 switch (opt) { 516 switch (opt) {
517#ifdef BB_FEATURE_TFTP_BLOCKSIZE 517#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
518 case 'b': 518 case 'b':
519 blocksize = atoi(optarg); 519 blocksize = atoi(optarg);
520 if (!tftp_blocksize_check(blocksize, 0)) { 520 if (!tftp_blocksize_check(blocksize, 0)) {
@@ -522,13 +522,13 @@ int tftp_main(int argc, char **argv)
522 } 522 }
523 break; 523 break;
524#endif 524#endif
525#ifdef BB_FEATURE_TFTP_GET 525#ifdef CONFIG_FEATURE_TFTP_GET
526 case 'g': 526 case 'g':
527 cmd = tftp_cmd_get; 527 cmd = tftp_cmd_get;
528 flags = O_WRONLY | O_CREAT; 528 flags = O_WRONLY | O_CREAT;
529 break; 529 break;
530#endif 530#endif
531#ifdef BB_FEATURE_TFTP_PUT 531#ifdef CONFIG_FEATURE_TFTP_PUT
532 case 'p': 532 case 'p':
533 cmd = tftp_cmd_put; 533 cmd = tftp_cmd_put;
534 flags = O_RDONLY; 534 flags = O_RDONLY;
@@ -558,7 +558,7 @@ int tftp_main(int argc, char **argv)
558 port = atoi(argv[optind + 1]); 558 port = atoi(argv[optind + 1]);
559 } 559 }
560 560
561#ifdef BB_FEATURE_TFTP_DEBUG 561#ifdef CONFIG_FEATURE_TFTP_DEBUG
562 printf("using server \"%s\", remotefile \"%s\", " 562 printf("using server \"%s\", remotefile \"%s\", "
563 "localfile \"%s\".\n", 563 "localfile \"%s\".\n",
564 inet_ntoa(*((struct in_addr *) host->h_addr)), 564 inet_ntoa(*((struct in_addr *) host->h_addr)),
@@ -567,7 +567,7 @@ int tftp_main(int argc, char **argv)
567 567
568 result = tftp(cmd, host, remotefile, fd, port, blocksize); 568 result = tftp(cmd, host, remotefile, fd, port, blocksize);
569 569
570#ifdef BB_FEATURE_CLEAN_UP 570#ifdef CONFIG_FEATURE_CLEAN_UP
571 close(fd); 571 close(fd);
572#endif 572#endif
573 return(result); 573 return(result);