summaryrefslogtreecommitdiff
path: root/networking/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/ping.c')
-rw-r--r--networking/ping.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/networking/ping.c b/networking/ping.c
index bbe2c9f..e413bec 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -101,15 +101,9 @@ static void ping4(len_and_sockaddr *lsa)
pkt->icmp_type = ICMP_ECHO;
pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
- c = sendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN, 0,
+ c = xsendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN,
(struct sockaddr *) &pingaddr, sizeof(pingaddr));
- if (c < 0) {
- if (ENABLE_FEATURE_CLEAN_UP)
- close(pingsock);
- bb_perror_msg_and_die("sendto");
- }
-
/* listen for replies */
while (1) {
struct sockaddr_in from;
@@ -153,15 +147,9 @@ static void ping6(len_and_sockaddr *lsa)
sockopt = offsetof(struct icmp6_hdr, icmp6_cksum);
setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, &sockopt, sizeof(sockopt));
- c = sendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr), 0,
+ c = xsendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr),
(struct sockaddr *) &pingaddr, sizeof(pingaddr));
- if (c < 0) {
- if (ENABLE_FEATURE_CLEAN_UP)
- close(pingsock);
- bb_perror_msg_and_die("sendto");
- }
-
/* listen for replies */
while (1) {
struct sockaddr_in6 from;
@@ -306,15 +294,12 @@ static void sendping_tail(void (*sp)(int), const void *pkt, int size_pkt)
/* sizeof(pingaddr) can be larger than real sa size, but I think
* it doesn't matter */
- sz = sendto(pingsock, pkt, size_pkt, 0, &pingaddr.sa, sizeof(pingaddr));
- if (sz < 0)
- bb_perror_msg_and_die("sendto");
+ sz = xsendto(pingsock, pkt, size_pkt, &pingaddr.sa, sizeof(pingaddr));
if (sz != size_pkt)
- bb_error_msg_and_die("ping wrote %d chars; %d expected", sz,
- size_pkt);
+ bb_error_msg_and_die(bb_msg_write_error);
signal(SIGALRM, sp);
- if (pingcount == 0 || ntransmitted < pingcount) { /* schedule next in 1s */
+ if (pingcount == 0 || ntransmitted < pingcount) { /* schedule next in 1s */
alarm(PINGINTERVAL);
} else { /* done, wait for the last ping to come back */
/* todo, don't necessarily need to wait so long... */