aboutsummaryrefslogtreecommitdiff
path: root/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'ping.c')
-rw-r--r--ping.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/ping.c b/ping.c
index 0359abbd1..52cb07be7 100644
--- a/ping.c
+++ b/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