diff options
Diffstat (limited to 'networking/tftp.c')
-rw-r--r-- | networking/tftp.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/networking/tftp.c b/networking/tftp.c index 378ba2fef..a33b5c21e 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -60,7 +60,7 @@ | |||
60 | #define TFTP_ERROR 5 | 60 | #define TFTP_ERROR 5 |
61 | #define TFTP_OACK 6 | 61 | #define TFTP_OACK 6 |
62 | 62 | ||
63 | static const char *tftp_error_msg[] = { | 63 | static const char *tftp_bb_error_msg[] = { |
64 | "Undefined error", | 64 | "Undefined error", |
65 | "File not found", | 65 | "File not found", |
66 | "Access violation", | 66 | "Access violation", |
@@ -86,7 +86,7 @@ static int tftp_blocksize_check(int blocksize, int bufsize) | |||
86 | 86 | ||
87 | if ((bufsize && (blocksize > bufsize)) || | 87 | if ((bufsize && (blocksize > bufsize)) || |
88 | (blocksize < 8) || (blocksize > 65464)) { | 88 | (blocksize < 8) || (blocksize > 65464)) { |
89 | error_msg("bad blocksize"); | 89 | bb_error_msg("bad blocksize"); |
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
@@ -169,7 +169,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
169 | tftp_bufsize += 4; | 169 | tftp_bufsize += 4; |
170 | 170 | ||
171 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { | 171 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { |
172 | perror_msg("socket"); | 172 | bb_perror_msg("socket"); |
173 | return EXIT_FAILURE; | 173 | return EXIT_FAILURE; |
174 | } | 174 | } |
175 | 175 | ||
@@ -223,7 +223,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
223 | } | 223 | } |
224 | 224 | ||
225 | if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) { | 225 | if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) { |
226 | error_msg("too long remote-filename"); | 226 | bb_error_msg("too long remote-filename"); |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | 229 | ||
@@ -239,7 +239,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
239 | if (len != TFTP_BLOCKSIZE_DEFAULT) { | 239 | if (len != TFTP_BLOCKSIZE_DEFAULT) { |
240 | 240 | ||
241 | if ((&buf[tftp_bufsize - 1] - cp) < 15) { | 241 | if ((&buf[tftp_bufsize - 1] - cp) < 15) { |
242 | error_msg("too long remote-filename"); | 242 | bb_error_msg("too long remote-filename"); |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | 245 | ||
@@ -270,7 +270,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
270 | len = read(localfd, cp, tftp_bufsize - 4); | 270 | len = read(localfd, cp, tftp_bufsize - 4); |
271 | 271 | ||
272 | if (len < 0) { | 272 | if (len < 0) { |
273 | perror_msg("read"); | 273 | bb_perror_msg("read"); |
274 | break; | 274 | break; |
275 | } | 275 | } |
276 | 276 | ||
@@ -298,7 +298,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
298 | #endif | 298 | #endif |
299 | if (sendto(socketfd, buf, len, 0, | 299 | if (sendto(socketfd, buf, len, 0, |
300 | (struct sockaddr *) &sa, sizeof(sa)) < 0) { | 300 | (struct sockaddr *) &sa, sizeof(sa)) < 0) { |
301 | perror_msg("send"); | 301 | bb_perror_msg("send"); |
302 | len = -1; | 302 | len = -1; |
303 | break; | 303 | break; |
304 | } | 304 | } |
@@ -325,7 +325,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
325 | (struct sockaddr *) &from, &fromlen); | 325 | (struct sockaddr *) &from, &fromlen); |
326 | 326 | ||
327 | if (len < 0) { | 327 | if (len < 0) { |
328 | perror_msg("recvfrom"); | 328 | bb_perror_msg("recvfrom"); |
329 | break; | 329 | break; |
330 | } | 330 | } |
331 | 331 | ||
@@ -343,18 +343,18 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
343 | timeout = bb_tftp_num_retries; | 343 | timeout = bb_tftp_num_retries; |
344 | 344 | ||
345 | case 0: | 345 | case 0: |
346 | error_msg("timeout"); | 346 | bb_error_msg("timeout"); |
347 | 347 | ||
348 | if (timeout == 0) { | 348 | if (timeout == 0) { |
349 | len = -1; | 349 | len = -1; |
350 | error_msg("last timeout"); | 350 | bb_error_msg("last timeout"); |
351 | } else { | 351 | } else { |
352 | timeout--; | 352 | timeout--; |
353 | } | 353 | } |
354 | break; | 354 | break; |
355 | 355 | ||
356 | default: | 356 | default: |
357 | perror_msg("select"); | 357 | bb_perror_msg("select"); |
358 | len = -1; | 358 | len = -1; |
359 | } | 359 | } |
360 | 360 | ||
@@ -380,14 +380,14 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
380 | if (buf[4] != '\0') { | 380 | if (buf[4] != '\0') { |
381 | msg = &buf[4]; | 381 | msg = &buf[4]; |
382 | buf[tftp_bufsize - 1] = '\0'; | 382 | buf[tftp_bufsize - 1] = '\0'; |
383 | } else if (tmp < (sizeof(tftp_error_msg) | 383 | } else if (tmp < (sizeof(tftp_bb_error_msg) |
384 | / sizeof(char *))) { | 384 | / sizeof(char *))) { |
385 | 385 | ||
386 | msg = (char *) tftp_error_msg[tmp]; | 386 | msg = (char *) tftp_bb_error_msg[tmp]; |
387 | } | 387 | } |
388 | 388 | ||
389 | if (msg) { | 389 | if (msg) { |
390 | error_msg("server says: %s", msg); | 390 | bb_error_msg("server says: %s", msg); |
391 | } | 391 | } |
392 | 392 | ||
393 | break; | 393 | break; |
@@ -429,11 +429,11 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
429 | } | 429 | } |
430 | /* FIXME: | 430 | /* FIXME: |
431 | * we should send ERROR 8 */ | 431 | * we should send ERROR 8 */ |
432 | error_msg("bad server option"); | 432 | bb_error_msg("bad server option"); |
433 | break; | 433 | break; |
434 | } | 434 | } |
435 | 435 | ||
436 | error_msg("warning: blksize not supported by server" | 436 | bb_error_msg("warning: blksize not supported by server" |
437 | " - reverting to 512"); | 437 | " - reverting to 512"); |
438 | 438 | ||
439 | tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4; | 439 | tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4; |
@@ -447,7 +447,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
447 | len = write(localfd, &buf[4], len - 4); | 447 | len = write(localfd, &buf[4], len - 4); |
448 | 448 | ||
449 | if (len < 0) { | 449 | if (len < 0) { |
450 | perror_msg("write"); | 450 | bb_perror_msg("write"); |
451 | break; | 451 | break; |
452 | } | 452 | } |
453 | 453 | ||
@@ -538,16 +538,16 @@ int tftp_main(int argc, char **argv) | |||
538 | break; | 538 | break; |
539 | #endif | 539 | #endif |
540 | case 'l': | 540 | case 'l': |
541 | localfile = xstrdup(optarg); | 541 | localfile = bb_xstrdup(optarg); |
542 | break; | 542 | break; |
543 | case 'r': | 543 | case 'r': |
544 | remotefile = xstrdup(optarg); | 544 | remotefile = bb_xstrdup(optarg); |
545 | break; | 545 | break; |
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | if ((cmd == 0) || (optind == argc)) { | 549 | if ((cmd == 0) || (optind == argc)) { |
550 | show_usage(); | 550 | bb_show_usage(); |
551 | } | 551 | } |
552 | if(localfile && strcmp(localfile, "-") == 0) { | 552 | if(localfile && strcmp(localfile, "-") == 0) { |
553 | fd = fileno((cmd==tftp_cmd_get)? stdout : stdin); | 553 | fd = fileno((cmd==tftp_cmd_get)? stdout : stdin); |
@@ -560,7 +560,7 @@ int tftp_main(int argc, char **argv) | |||
560 | fd = open(localfile, flags, 0644); | 560 | fd = open(localfile, flags, 0644); |
561 | } | 561 | } |
562 | if (fd < 0) { | 562 | if (fd < 0) { |
563 | perror_msg_and_die("local file"); | 563 | bb_perror_msg_and_die("local file"); |
564 | } | 564 | } |
565 | 565 | ||
566 | host = xgethostbyname(argv[optind]); | 566 | host = xgethostbyname(argv[optind]); |