aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-05-16 15:40:51 +0000
committerMatt Kraai <kraai@debian.org>2001-05-16 15:40:51 +0000
commitc55b8d41c15640fa1637f919b3f6eca6e781047a (patch)
tree03c1fca61c1b577b7c527d2b8482c5b7f6972bcd /networking
parent59df6f73988b103f0dcfffeaec10642527336c5e (diff)
downloadbusybox-w32-c55b8d41c15640fa1637f919b3f6eca6e781047a.tar.gz
busybox-w32-c55b8d41c15640fa1637f919b3f6eca6e781047a.tar.bz2
busybox-w32-c55b8d41c15640fa1637f919b3f6eca6e781047a.zip
Add xgethostbyname and herror_msg* functions.
Diffstat (limited to 'networking')
-rw-r--r--networking/hostname.c8
-rw-r--r--networking/nc.c3
-rw-r--r--networking/ping.c19
-rw-r--r--networking/telnet.c11
-rw-r--r--networking/tftp.c7
-rw-r--r--networking/wget.c5
6 files changed, 15 insertions, 38 deletions
diff --git a/networking/hostname.c b/networking/hostname.c
index f4118ea36..75e4d2e57 100644
--- a/networking/hostname.c
+++ b/networking/hostname.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: hostname.c,v 1.27 2001/05/16 14:21:09 kraai Exp $ 3 * $Id: hostname.c,v 1.28 2001/05/16 15:40:48 kraai Exp $
4 * Mini hostname implementation for busybox 4 * Mini hostname implementation for busybox
5 * 5 *
6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -117,11 +117,7 @@ int hostname_main(int argc, char **argv)
117 s = strchr(buf, '.'); 117 s = strchr(buf, '.');
118 puts(s ? s + 1 : ""); 118 puts(s ? s + 1 : "");
119 } else if (opt_ip) { 119 } else if (opt_ip) {
120 h = gethostbyname(buf); 120 h = xgethostbyname(buf);
121 if (!h) {
122 printf("Host not found\n");
123 exit(1);
124 }
125 puts(inet_ntoa(*(struct in_addr *) (h->h_addr))); 121 puts(inet_ntoa(*(struct in_addr *) (h->h_addr)));
126 } else { 122 } else {
127 puts(buf); 123 puts(buf);
diff --git a/networking/nc.c b/networking/nc.c
index b58bd6a12..5335872e5 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -91,8 +91,7 @@ int nc_main(int argc, char **argv)
91 close(sfd); 91 close(sfd);
92 sfd = tmpfd; 92 sfd = tmpfd;
93 } else { 93 } else {
94 if ((hostinfo = gethostbyname(argv[optind])) == NULL) 94 hostinfo = xgethostbyname(argv[optind]);
95 error_msg_and_die("cannot resolve %s\n", argv[optind]);
96 95
97 address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; 96 address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
98 address.sin_port = htons(atoi(argv[optind+1])); 97 address.sin_port = htons(atoi(argv[optind+1]));
diff --git a/networking/ping.c b/networking/ping.c
index 8b82dcaac..0967999a9 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: ping.c,v 1.40 2001/04/09 23:52:18 andersen Exp $ 3 * $Id: ping.c,v 1.41 2001/05/16 15:40:48 kraai Exp $
4 * Mini ping implementation for busybox 4 * Mini ping implementation for busybox
5 * 5 *
6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -200,10 +200,7 @@ static void ping(const char *host)
200 memset(&pingaddr, 0, sizeof(struct sockaddr_in)); 200 memset(&pingaddr, 0, sizeof(struct sockaddr_in));
201 201
202 pingaddr.sin_family = AF_INET; 202 pingaddr.sin_family = AF_INET;
203 if (!(h = gethostbyname(host))) { 203 h = xgethostbyname(host);
204 error_msg("unknown host %s", host);
205 exit(1);
206 }
207 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); 204 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
208 hostname = h->h_name; 205 hostname = h->h_name;
209 206
@@ -446,15 +443,9 @@ static void ping(const char *host)
446 memset(&pingaddr, 0, sizeof(struct sockaddr_in)); 443 memset(&pingaddr, 0, sizeof(struct sockaddr_in));
447 444
448 pingaddr.sin_family = AF_INET; 445 pingaddr.sin_family = AF_INET;
449 if (!(h = gethostbyname(host))) { 446 h = gethostbyname(host);
450 error_msg("unknown host %s", host); 447 if (h->h_addrtype != AF_INET)
451 exit(1); 448 error_msg_and_die("unknown address type; only AF_INET is currently supported.");
452 }
453
454 if (h->h_addrtype != AF_INET) {
455 error_msg("unknown address type; only AF_INET is currently supported.");
456 exit(1);
457 }
458 449
459 pingaddr.sin_family = AF_INET; /* h->h_addrtype */ 450 pingaddr.sin_family = AF_INET; /* h->h_addrtype */
460 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); 451 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
diff --git a/networking/telnet.c b/networking/telnet.c
index 207732b72..2587193e2 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -644,18 +644,15 @@ static int getport(char * p)
644static struct in_addr getserver(char * host) 644static struct in_addr getserver(char * host)
645{ 645{
646 struct in_addr addr; 646 struct in_addr addr;
647 647
648 struct hostent * he; 648 struct hostent * he;
649 if ((he = gethostbyname(host)) == NULL) 649 he = xgethostbyname(host);
650 {
651 error_msg_and_die("%s: Unknown host", host);
652 }
653 memcpy(&addr, he->h_addr, sizeof addr); 650 memcpy(&addr, he->h_addr, sizeof addr);
654 651
655 TRACE(1, ("addr: %s\n", inet_ntoa(addr))); 652 TRACE(1, ("addr: %s\n", inet_ntoa(addr)));
656 653
657 return addr; 654 return addr;
658} 655}
659 656
660static int create_socket() 657static int create_socket()
661{ 658{
diff --git a/networking/tftp.c b/networking/tftp.c
index 466851c1b..bb75c88ec 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -390,15 +390,10 @@ int tftp_main(int argc, char **argv)
390 s = xstrdup(serverstr); 390 s = xstrdup(serverstr);
391 s[cp - serverstr] = '\0'; 391 s[cp - serverstr] = '\0';
392 392
393 if ((host = gethostbyname(s))) { 393 host = xgethostbyname(s);
394 bad = 0;
395 }
396 394
397 free(s); 395 free(s);
398 } 396 }
399 if (bad) {
400 error_msg_and_die("bad \"server:file\" combination");
401 }
402 397
403 if (BB_TFTP_DEBUG) { 398 if (BB_TFTP_DEBUG) {
404 printf("using server \"%s\", serverfile \"%s\"," 399 printf("using server \"%s\", serverfile \"%s\","
diff --git a/networking/wget.c b/networking/wget.c
index 5fa918a19..6fd170d4d 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -556,8 +556,7 @@ FILE *open_socket(char *host, int port)
556 556
557 memset(&s_in, 0, sizeof(s_in)); 557 memset(&s_in, 0, sizeof(s_in));
558 s_in.sin_family = AF_INET; 558 s_in.sin_family = AF_INET;
559 if ((hp = (struct hostent *) gethostbyname(host)) == NULL) 559 hp = xgethostbyname(host);
560 error_msg_and_die("cannot resolve %s", host);
561 memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length); 560 memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
562 s_in.sin_port = htons(port); 561 s_in.sin_port = htons(port);
563 562
@@ -813,7 +812,7 @@ progressmeter(int flag)
813 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 812 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
814 * SUCH DAMAGE. 813 * SUCH DAMAGE.
815 * 814 *
816 * $Id: wget.c,v 1.40 2001/05/15 20:11:49 andersen Exp $ 815 * $Id: wget.c,v 1.41 2001/05/16 15:40:48 kraai Exp $
817 */ 816 */
818 817
819 818