aboutsummaryrefslogtreecommitdiff
path: root/networking/tftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/tftp.c')
-rw-r--r--networking/tftp.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index a1a79a09c..146857686 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -138,7 +138,7 @@ static char *tftp_option_get(char *buf, int len, char *option)
138#endif 138#endif
139 139
140static inline int tftp(const int cmd, const struct hostent *host, 140static inline int tftp(const int cmd, const struct hostent *host,
141 const char *remotefile, int localfd, const int port, int tftp_bufsize) 141 const char *remotefile, int localfd, const unsigned short port, int tftp_bufsize)
142{ 142{
143 const int cmd_get = cmd & tftp_cmd_get; 143 const int cmd_get = cmd & tftp_cmd_get;
144 const int cmd_put = cmd & tftp_cmd_put; 144 const int cmd_put = cmd & tftp_cmd_put;
@@ -179,7 +179,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
179 bind(socketfd, (struct sockaddr *)&sa, len); 179 bind(socketfd, (struct sockaddr *)&sa, len);
180 180
181 sa.sin_family = host->h_addrtype; 181 sa.sin_family = host->h_addrtype;
182 sa.sin_port = htons(port); 182 sa.sin_port = port;
183 memcpy(&sa.sin_addr, (struct in_addr *) host->h_addr, 183 memcpy(&sa.sin_addr, (struct in_addr *) host->h_addr,
184 sizeof(sa.sin_addr)); 184 sizeof(sa.sin_addr));
185 185
@@ -332,7 +332,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
332 332
333 timeout = 0; 333 timeout = 0;
334 334
335 if (sa.sin_port == htons(port)) { 335 if (sa.sin_port == port) {
336 sa.sin_port = from.sin_port; 336 sa.sin_port = from.sin_port;
337 } 337 }
338 if (sa.sin_port == from.sin_port) { 338 if (sa.sin_port == from.sin_port) {
@@ -487,7 +487,7 @@ int tftp_main(int argc, char **argv)
487 struct hostent *host = NULL; 487 struct hostent *host = NULL;
488 char *localfile = NULL; 488 char *localfile = NULL;
489 char *remotefile = NULL; 489 char *remotefile = NULL;
490 int port = 69; 490 int port;
491 int cmd = 0; 491 int cmd = 0;
492 int fd = -1; 492 int fd = -1;
493 int flags = 0; 493 int flags = 0;
@@ -564,10 +564,7 @@ int tftp_main(int argc, char **argv)
564 } 564 }
565 565
566 host = xgethostbyname(argv[optind]); 566 host = xgethostbyname(argv[optind]);
567 567 port = bb_lookup_port(argv[optind + 1], "udp", 69);
568 if (optind + 2 == argc) {
569 port = atoi(argv[optind + 1]);
570 }
571 568
572#ifdef CONFIG_FEATURE_TFTP_DEBUG 569#ifdef CONFIG_FEATURE_TFTP_DEBUG
573 printf("using server \"%s\", remotefile \"%s\", " 570 printf("using server \"%s\", remotefile \"%s\", "