diff options
author | Bernhard Reutner-Fischer | 2007-04-12 11:34:39 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer | 2007-04-12 11:34:39 +0000 |
commit | b290889f0265e1278e8a868aa82a65bcc9099b0f (patch) | |
tree | 2fc8dcc3b7f525f61817417e32c2827b57e17b8a /networking/ping.c | |
parent | 51742f4bb0c57a4d5063ece9437a2f34a42e52c8 (diff) | |
download | busybox-b290889f0265e1278e8a868aa82a65bcc9099b0f.zip busybox-b290889f0265e1278e8a868aa82a65bcc9099b0f.tar.gz |
- add xsendto and use where appropriate; shrink iplink; sanitize libiproute a bit.
-916 byte
Diffstat (limited to 'networking/ping.c')
-rw-r--r-- | networking/ping.c | 25 |
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... */ |