diff options
Diffstat (limited to 'ping.c')
-rw-r--r-- | ping.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -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.27 2000/12/01 02:55:13 kraai Exp $ | 3 | * $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw 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> |
@@ -202,7 +202,7 @@ static void ping(const char *host) | |||
202 | 202 | ||
203 | pingaddr.sin_family = AF_INET; | 203 | pingaddr.sin_family = AF_INET; |
204 | if (!(h = gethostbyname(host))) { | 204 | if (!(h = gethostbyname(host))) { |
205 | errorMsg("unknown host %s\n", host); | 205 | error_msg("unknown host %s\n", host); |
206 | exit(1); | 206 | exit(1); |
207 | } | 207 | } |
208 | memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); | 208 | memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); |
@@ -219,7 +219,7 @@ static void ping(const char *host) | |||
219 | if (c < 0 || c != sizeof(packet)) { | 219 | if (c < 0 || c != sizeof(packet)) { |
220 | if (c < 0) | 220 | if (c < 0) |
221 | perror("ping: sendto"); | 221 | perror("ping: sendto"); |
222 | errorMsg("write incomplete\n"); | 222 | error_msg("write incomplete\n"); |
223 | exit(1); | 223 | exit(1); |
224 | } | 224 | } |
225 | 225 | ||
@@ -325,9 +325,9 @@ static void sendping(int junk) | |||
325 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); | 325 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); |
326 | 326 | ||
327 | if (i < 0) | 327 | if (i < 0) |
328 | fatalError("sendto: %s\n", strerror(errno)); | 328 | error_msg_and_die("sendto: %s\n", strerror(errno)); |
329 | else if ((size_t)i != sizeof(packet)) | 329 | else if ((size_t)i != sizeof(packet)) |
330 | fatalError("ping wrote %d chars; %d expected\n", i, | 330 | error_msg_and_die("ping wrote %d chars; %d expected\n", i, |
331 | (int)sizeof(packet)); | 331 | (int)sizeof(packet)); |
332 | 332 | ||
333 | signal(SIGALRM, sendping); | 333 | signal(SIGALRM, sendping); |
@@ -422,7 +422,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) | |||
422 | printf("\n"); | 422 | printf("\n"); |
423 | } else | 423 | } else |
424 | if (icmppkt->icmp_type != ICMP_ECHO) | 424 | if (icmppkt->icmp_type != ICMP_ECHO) |
425 | errorMsg("Warning: Got ICMP %d (%s)\n", | 425 | error_msg("Warning: Got ICMP %d (%s)\n", |
426 | icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); | 426 | icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); |
427 | } | 427 | } |
428 | 428 | ||
@@ -440,7 +440,7 @@ static void ping(const char *host) | |||
440 | if ((pingsock = socket(AF_INET, SOCK_RAW, | 440 | if ((pingsock = socket(AF_INET, SOCK_RAW, |
441 | (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ | 441 | (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ |
442 | if (errno == EPERM) { | 442 | if (errno == EPERM) { |
443 | errorMsg("permission denied. (are you root?)\n"); | 443 | error_msg("permission denied. (are you root?)\n"); |
444 | } else { | 444 | } else { |
445 | perror("ping: creating a raw socket"); | 445 | perror("ping: creating a raw socket"); |
446 | } | 446 | } |
@@ -454,12 +454,12 @@ static void ping(const char *host) | |||
454 | 454 | ||
455 | pingaddr.sin_family = AF_INET; | 455 | pingaddr.sin_family = AF_INET; |
456 | if (!(h = gethostbyname(host))) { | 456 | if (!(h = gethostbyname(host))) { |
457 | errorMsg("unknown host %s\n", host); | 457 | error_msg("unknown host %s\n", host); |
458 | exit(1); | 458 | exit(1); |
459 | } | 459 | } |
460 | 460 | ||
461 | if (h->h_addrtype != AF_INET) { | 461 | if (h->h_addrtype != AF_INET) { |
462 | errorMsg("unknown address type; only AF_INET is currently supported.\n"); | 462 | error_msg("unknown address type; only AF_INET is currently supported.\n"); |
463 | exit(1); | 463 | exit(1); |
464 | } | 464 | } |
465 | 465 | ||