rename bb_default_error_retval -> xfunc_error_retval
[oweals/busybox.git] / networking / tftp.c
index 237609fad66e20ce5eb03f2edc703990163ff087..42fd9d2cac73c114cbbd0b9286e32458e1c807bb 100644 (file)
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  * ------------------------------------------------------------------------- */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <fcntl.h>
-
 #include "busybox.h"
 
 
 #define TFTP_TIMEOUT 5 /* seconds */
 #define TFTP_NUM_RETRIES 5 /* number of retries */
 
-/* RFC2348 says between 8 and 65464 */
-#define TFTP_OCTECTS_MIN 8
-#define TFTP_OCTECTS_MAX 65464
-
 static const char * const MODE_OCTET = "octet";
 #define MODE_OCTET_LEN 6 /* sizeof(MODE_OCTET)*/
 
@@ -87,7 +71,7 @@ static int tftp_blocksize_check(int blocksize, int bufsize)
         */
 
        if ((bufsize && (blocksize > bufsize)) ||
-               (blocksize < TFTP_OCTECTS_MIN) || (blocksize > TFTP_OCTECTS_MAX)) {
+               (blocksize < 8) || (blocksize > 65564)) {
                bb_error_msg("bad blocksize");
                return 0;
        }
@@ -163,7 +147,7 @@ static int tftp(const int cmd, const struct hostent *host,
        char *buf=xmalloc(tftp_bufsize += 4);
 
        if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
-               /* need to unlink the localfile, so don't use bb_xsocket here. */
+               /* need to unlink the localfile, so don't use xsocket here. */
                bb_perror_msg("socket");
                return EXIT_FAILURE;
        }
@@ -171,7 +155,7 @@ static int tftp(const int cmd, const struct hostent *host,
        len = sizeof(sa);
 
        memset(&sa, 0, len);
-       bb_xbind(socketfd, (struct sockaddr *)&sa, len);
+       xbind(socketfd, (struct sockaddr *)&sa, len);
 
        sa.sin_family = host->h_addrtype;
        sa.sin_port = port;
@@ -253,7 +237,7 @@ static int tftp(const int cmd, const struct hostent *host,
                        block_nr++;
 
                        if ((cmd & tftp_cmd_put) && (opcode == TFTP_DATA)) {
-                               len = bb_full_read(localfd, cp, tftp_bufsize - 4);
+                               len = full_read(localfd, cp, tftp_bufsize - 4);
 
                                if (len < 0) {
                                        bb_perror_msg(bb_msg_read_error);
@@ -424,7 +408,7 @@ static int tftp(const int cmd, const struct hostent *host,
 
                        if (tmp == block_nr) {
 
-                               len = bb_full_write(localfd, &buf[4], len - 4);
+                               len = full_write(localfd, &buf[4], len - 4);
 
                                if (len < 0) {
                                        bb_perror_msg(bb_msg_write_error);