aboutsummaryrefslogtreecommitdiff
path: root/networking/ping6.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/ping6.c')
-rw-r--r--networking/ping6.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/networking/ping6.c b/networking/ping6.c
index f1ccff483..c40624219 100644
--- a/networking/ping6.c
+++ b/networking/ping6.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: ping6.c,v 1.3 2003/01/12 06:08:33 andersen Exp $ 3 * $Id: ping6.c,v 1.4 2003/03/19 09:12:38 mjn3 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>
@@ -112,7 +112,7 @@ static void ping(const char *host)
112 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); 112 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6));
113 113
114 if (c < 0 || c != sizeof(packet)) 114 if (c < 0 || c != sizeof(packet))
115 perror_msg_and_die("sendto"); 115 bb_perror_msg_and_die("sendto");
116 116
117 signal(SIGALRM, noresp); 117 signal(SIGALRM, noresp);
118 alarm(5); /* give the host 5000ms to respond */ 118 alarm(5); /* give the host 5000ms to respond */
@@ -125,7 +125,7 @@ static void ping(const char *host)
125 (struct sockaddr *) &from, &fromlen)) < 0) { 125 (struct sockaddr *) &from, &fromlen)) < 0) {
126 if (errno == EINTR) 126 if (errno == EINTR)
127 continue; 127 continue;
128 perror_msg("recvfrom"); 128 bb_perror_msg("recvfrom");
129 continue; 129 continue;
130 } 130 }
131 if (c >= 8) { /* icmp6_hdr */ 131 if (c >= 8) { /* icmp6_hdr */
@@ -143,7 +143,7 @@ extern int ping6_main(int argc, char **argv)
143 argc--; 143 argc--;
144 argv++; 144 argv++;
145 if (argc < 1) 145 if (argc < 1)
146 show_usage(); 146 bb_show_usage();
147 ping(*argv); 147 ping(*argv);
148 return EXIT_SUCCESS; 148 return EXIT_SUCCESS;
149} 149}
@@ -218,9 +218,9 @@ static void sendping(int junk)
218 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); 218 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6));
219 219
220 if (i < 0) 220 if (i < 0)
221 perror_msg_and_die("sendto"); 221 bb_perror_msg_and_die("sendto");
222 else if ((size_t)i != sizeof(packet)) 222 else if ((size_t)i != sizeof(packet))
223 error_msg_and_die("ping wrote %d chars; %d expected", i, 223 bb_error_msg_and_die("ping wrote %d chars; %d expected", i,
224 (int)sizeof(packet)); 224 (int)sizeof(packet));
225 225
226 signal(SIGALRM, sendping); 226 signal(SIGALRM, sendping);
@@ -308,7 +308,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit
308 printf("\n"); 308 printf("\n");
309 } else 309 } else
310 if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) 310 if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST)
311 error_msg("Warning: Got ICMP %d (%s)", 311 bb_error_msg("Warning: Got ICMP %d (%s)",
312 icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type)); 312 icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type));
313} 313}
314 314
@@ -329,7 +329,7 @@ static void ping(const char *host)
329 pingaddr.sin6_family = AF_INET6; 329 pingaddr.sin6_family = AF_INET6;
330 hostent = xgethostbyname2(host, AF_INET6); 330 hostent = xgethostbyname2(host, AF_INET6);
331 if (hostent->h_addrtype != AF_INET6) 331 if (hostent->h_addrtype != AF_INET6)
332 error_msg_and_die("unknown address type; only AF_INET6 is currently supported."); 332 bb_error_msg_and_die("unknown address type; only AF_INET6 is currently supported.");
333 333
334 memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr)); 334 memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr));
335 335
@@ -350,7 +350,7 @@ static void ping(const char *host)
350 } 350 }
351 if (setsockopt(pingsock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt, 351 if (setsockopt(pingsock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt,
352 sizeof(filt)) < 0) 352 sizeof(filt)) < 0)
353 error_msg_and_die("setsockopt(ICMP6_FILTER)"); 353 bb_error_msg_and_die("setsockopt(ICMP6_FILTER)");
354 } 354 }
355#endif /*ICMP6_FILTER*/ 355#endif /*ICMP6_FILTER*/
356 356
@@ -374,7 +374,7 @@ static void ping(const char *host)
374 374
375 if (ifname) { 375 if (ifname) {
376 if ((pingaddr.sin6_scope_id = if_nametoindex(ifname)) == 0) 376 if ((pingaddr.sin6_scope_id = if_nametoindex(ifname)) == 0)
377 error_msg_and_die("%s: invalid interface name", ifname); 377 bb_error_msg_and_die("%s: invalid interface name", ifname);
378 } 378 }
379 379
380 printf("PING %s (%s): %d data bytes\n", 380 printf("PING %s (%s): %d data bytes\n",
@@ -405,7 +405,7 @@ static void ping(const char *host)
405 if ((c = recvmsg(pingsock, &msg, 0)) < 0) { 405 if ((c = recvmsg(pingsock, &msg, 0)) < 0) {
406 if (errno == EINTR) 406 if (errno == EINTR)
407 continue; 407 continue;
408 perror_msg("recvfrom"); 408 bb_perror_msg("recvfrom");
409 continue; 409 continue;
410 } 410 }
411 for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; 411 for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL;
@@ -446,30 +446,30 @@ extern int ping6_main(int argc, char **argv)
446 break; 446 break;
447 case 'c': 447 case 'c':
448 if (--argc <= 0) 448 if (--argc <= 0)
449 show_usage(); 449 bb_show_usage();
450 argv++; 450 argv++;
451 pingcount = atoi(*argv); 451 pingcount = atoi(*argv);
452 break; 452 break;
453 case 's': 453 case 's':
454 if (--argc <= 0) 454 if (--argc <= 0)
455 show_usage(); 455 bb_show_usage();
456 argv++; 456 argv++;
457 datalen = atoi(*argv); 457 datalen = atoi(*argv);
458 break; 458 break;
459 case 'I': 459 case 'I':
460 if (--argc <= 0) 460 if (--argc <= 0)
461 show_usage(); 461 bb_show_usage();
462 argv++; 462 argv++;
463 ifname = *argv; 463 ifname = *argv;
464 break; 464 break;
465 default: 465 default:
466 show_usage(); 466 bb_show_usage();
467 } 467 }
468 argc--; 468 argc--;
469 argv++; 469 argv++;
470 } 470 }
471 if (argc < 1) 471 if (argc < 1)
472 show_usage(); 472 bb_show_usage();
473 473
474 myid = getpid() & 0xFFFF; 474 myid = getpid() & 0xFFFF;
475 ping(*argv); 475 ping(*argv);