aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-07-14 01:51:25 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-07-14 01:51:25 +0000
commited2dfb60ee4a99850e9e68fb27512a0bab4ba992 (patch)
tree62127f20fc07758e445d8c4e186306cbe83d77b1 /networking
parentf35f4340a4f7ae02b1139ac9f303e5b8081d71e9 (diff)
downloadbusybox-w32-ed2dfb60ee4a99850e9e68fb27512a0bab4ba992.tar.gz
busybox-w32-ed2dfb60ee4a99850e9e68fb27512a0bab4ba992.tar.bz2
busybox-w32-ed2dfb60ee4a99850e9e68fb27512a0bab4ba992.zip
Use errorMsg rather than fprintf.
git-svn-id: svn://busybox.net/trunk/busybox@848 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r--networking/hostname.c5
-rw-r--r--networking/ping.c16
2 files changed, 9 insertions, 12 deletions
diff --git a/networking/hostname.c b/networking/hostname.c
index e909138e4..60f66c073 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.10 2000/06/19 17:25:39 andersen Exp $ 3 * $Id: hostname.c,v 1.11 2000/07/14 01:51:25 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>
@@ -55,8 +55,7 @@ void do_sethostname(char *s, int isfile)
55 if (!isfile) { 55 if (!isfile) {
56 if (sethostname(s, strlen(s)) < 0) { 56 if (sethostname(s, strlen(s)) < 0) {
57 if (errno == EPERM) 57 if (errno == EPERM)
58 fprintf(stderr, 58 errorMsg("you must be root to change the hostname\n");
59 "hostname: you must be root to change the hostname\n");
60 else 59 else
61 perror("sethostname"); 60 perror("sethostname");
62 exit(1); 61 exit(1);
diff --git a/networking/ping.c b/networking/ping.c
index 0359abbd1..52cb07be7 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.20 2000/07/12 17:02:35 kraai Exp $ 3 * $Id: ping.c,v 1.21 2000/07/14 01:51:25 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>
@@ -208,7 +208,7 @@ static void ping(const char *host)
208 208
209 pingaddr.sin_family = AF_INET; 209 pingaddr.sin_family = AF_INET;
210 if (!(h = gethostbyname(host))) { 210 if (!(h = gethostbyname(host))) {
211 fprintf(stderr, "ping: unknown host %s\n", host); 211 errorMsg("unknown host %s\n", host);
212 exit(1); 212 exit(1);
213 } 213 }
214 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); 214 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
@@ -225,7 +225,7 @@ static void ping(const char *host)
225 if (c < 0 || c != sizeof(packet)) { 225 if (c < 0 || c != sizeof(packet)) {
226 if (c < 0) 226 if (c < 0)
227 perror("ping: sendto"); 227 perror("ping: sendto");
228 fprintf(stderr, "ping: write incomplete\n"); 228 errorMsg("write incomplete\n");
229 exit(1); 229 exit(1);
230 } 230 }
231 231
@@ -433,8 +433,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
433 printf("\n"); 433 printf("\n");
434 } else 434 } else
435 if (icmppkt->icmp_type != ICMP_ECHO) 435 if (icmppkt->icmp_type != ICMP_ECHO)
436 fprintf(stderr, 436 errorMsg("Warning: Got ICMP %d (%s)\n",
437 "Warning: Got ICMP %d (%s)\n",
438 icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); 437 icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
439} 438}
440 439
@@ -452,7 +451,7 @@ static void ping(const char *host)
452 if ((pingsock = socket(AF_INET, SOCK_RAW, 451 if ((pingsock = socket(AF_INET, SOCK_RAW,
453 (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ 452 (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
454 if (errno == EPERM) { 453 if (errno == EPERM) {
455 fprintf(stderr, "ping: permission denied. (are you root?)\n"); 454 errorMsg("permission denied. (are you root?)\n");
456 } else { 455 } else {
457 perror("ping: creating a raw socket"); 456 perror("ping: creating a raw socket");
458 } 457 }
@@ -466,13 +465,12 @@ static void ping(const char *host)
466 465
467 pingaddr.sin_family = AF_INET; 466 pingaddr.sin_family = AF_INET;
468 if (!(h = gethostbyname(host))) { 467 if (!(h = gethostbyname(host))) {
469 fprintf(stderr, "ping: unknown host %s\n", host); 468 errorMsg("unknown host %s\n", host);
470 exit(1); 469 exit(1);
471 } 470 }
472 471
473 if (h->h_addrtype != AF_INET) { 472 if (h->h_addrtype != AF_INET) {
474 fprintf(stderr, 473 errorMsg("unknown address type; only AF_INET is currently supported.\n");
475 "ping: unknown address type; only AF_INET is currently supported.\n");
476 exit(1); 474 exit(1);
477 } 475 }
478 476