1 /* vi: set sw=4 ts=4: */
3 * Mini ping implementation for busybox
5 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
7 * Adapted from the ping in netkit-base 0.10:
8 * Copyright (c) 1989 The Regents of the University of California.
11 * This code is derived from software contributed to Berkeley by
14 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
17 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
19 * This version of ping is adapted from the ping in netkit-base 0.10,
22 * Original copyright notice is retained at the end of this file.
24 * This version is an adaptation of ping.c from busybox.
25 * The code was modified by Bart Visscher <magick@linux-fan.com>
29 #include <netinet/ip_icmp.h>
33 #include <netinet/icmp6.h>
34 /* I see RENUMBERED constants in bits/in.h - !!?
35 * What a fuck is going on with libc? Is it a glibc joke? */
36 #ifdef IPV6_2292HOPLIMIT
38 #define IPV6_HOPLIMIT IPV6_2292HOPLIMIT
47 MAX_DUP_CHK
= (8 * 128),
49 PINGINTERVAL
= 1, /* 1 second */
54 static int in_cksum(unsigned short *buf
, int sz
)
58 unsigned short *w
= buf
;
59 unsigned short ans
= 0;
67 *(unsigned char *) (&ans
) = *(unsigned char *) w
;
71 sum
= (sum
>> 16) + (sum
& 0xFFFF);
77 #if !ENABLE_FEATURE_FANCY_PING
81 static char *hostname
;
83 static void noresp(int ign UNUSED_PARAM
)
85 printf("No response from %s\n", hostname
);
89 static void ping4(len_and_sockaddr
*lsa
)
91 struct sockaddr_in pingaddr
;
94 char packet
[DEFDATALEN
+ MAXIPLEN
+ MAXICMPLEN
];
96 pingsock
= create_icmp_socket();
97 pingaddr
= lsa
->u
.sin
;
99 pkt
= (struct icmp
*) packet
;
100 memset(pkt
, 0, sizeof(packet
));
101 pkt
->icmp_type
= ICMP_ECHO
;
102 pkt
->icmp_cksum
= in_cksum((unsigned short *) pkt
, sizeof(packet
));
104 c
= xsendto(pingsock
, packet
, DEFDATALEN
+ ICMP_MINLEN
,
105 (struct sockaddr
*) &pingaddr
, sizeof(pingaddr
));
107 /* listen for replies */
109 struct sockaddr_in from
;
110 socklen_t fromlen
= sizeof(from
);
112 c
= recvfrom(pingsock
, packet
, sizeof(packet
), 0,
113 (struct sockaddr
*) &from
, &fromlen
);
116 bb_perror_msg("recvfrom");
119 if (c
>= 76) { /* ip + icmp */
120 struct iphdr
*iphdr
= (struct iphdr
*) packet
;
122 pkt
= (struct icmp
*) (packet
+ (iphdr
->ihl
<< 2)); /* skip ip hdr */
123 if (pkt
->icmp_type
== ICMP_ECHOREPLY
)
127 if (ENABLE_FEATURE_CLEAN_UP
)
132 static void ping6(len_and_sockaddr
*lsa
)
134 struct sockaddr_in6 pingaddr
;
135 struct icmp6_hdr
*pkt
;
138 char packet
[DEFDATALEN
+ MAXIPLEN
+ MAXICMPLEN
];
140 pingsock
= create_icmp6_socket();
141 pingaddr
= lsa
->u
.sin6
;
143 pkt
= (struct icmp6_hdr
*) packet
;
144 memset(pkt
, 0, sizeof(packet
));
145 pkt
->icmp6_type
= ICMP6_ECHO_REQUEST
;
147 sockopt
= offsetof(struct icmp6_hdr
, icmp6_cksum
);
148 setsockopt(pingsock
, SOL_RAW
, IPV6_CHECKSUM
, &sockopt
, sizeof(sockopt
));
150 c
= xsendto(pingsock
, packet
, DEFDATALEN
+ sizeof (struct icmp6_hdr
),
151 (struct sockaddr
*) &pingaddr
, sizeof(pingaddr
));
153 /* listen for replies */
155 struct sockaddr_in6 from
;
156 socklen_t fromlen
= sizeof(from
);
158 c
= recvfrom(pingsock
, packet
, sizeof(packet
), 0,
159 (struct sockaddr
*) &from
, &fromlen
);
162 bb_perror_msg("recvfrom");
165 if (c
>= 8) { /* icmp6_hdr */
166 pkt
= (struct icmp6_hdr
*) packet
;
167 if (pkt
->icmp6_type
== ICMP6_ECHO_REPLY
)
171 if (ENABLE_FEATURE_CLEAN_UP
)
176 int ping_main(int argc
, char **argv
) MAIN_EXTERNALLY_VISIBLE
;
177 int ping_main(int argc UNUSED_PARAM
, char **argv
)
179 len_and_sockaddr
*lsa
;
181 sa_family_t af
= AF_UNSPEC
;
183 while ((++argv
)[0] && argv
[0][0] == '-') {
184 if (argv
[0][1] == '4') {
188 if (argv
[0][1] == '6') {
203 lsa
= xhost_and_af2sockaddr(hostname
, 0, af
);
205 lsa
= xhost_and_af2sockaddr(hostname
, 0, AF_INET
);
207 /* Set timer _after_ DNS resolution */
208 signal(SIGALRM
, noresp
);
209 alarm(5); /* give the host 5000ms to respond */
212 if (lsa
->u
.sa
.sa_family
== AF_INET6
)
217 printf("%s is alive!\n", hostname
);
222 #else /* FEATURE_FANCY_PING */
225 /* full(er) version */
227 #define OPT_STRING ("qvc:s:w:W:I:4" USE_PING6("6"))
230 OPT_VERBOSE
= 1 << 1,
237 OPT_IPV6
= (1 << 8) * ENABLE_PING6
,
245 len_and_sockaddr
*source_lsa
;
247 unsigned pingcount
; /* must be int-sized */
248 unsigned long ntransmitted
, nreceived
, nrepeats
;
250 unsigned tmin
, tmax
; /* in us */
251 unsigned long long tsum
; /* in us, sum of all times */
255 const char *hostname
;
259 struct sockaddr_in sin
;
261 struct sockaddr_in6 sin6
;
264 char rcvd_tbl
[MAX_DUP_CHK
/ 8];
266 #define G (*(struct globals*)&bb_common_bufsiz1)
267 #define pingsock (G.pingsock )
268 #define if_index (G.if_index )
269 #define source_lsa (G.source_lsa )
270 #define str_I (G.str_I )
271 #define datalen (G.datalen )
272 #define ntransmitted (G.ntransmitted)
273 #define nreceived (G.nreceived )
274 #define nrepeats (G.nrepeats )
275 #define pingcount (G.pingcount )
276 #define myid (G.myid )
277 #define tmin (G.tmin )
278 #define tmax (G.tmax )
279 #define tsum (G.tsum )
280 #define deadline (G.deadline )
281 #define timeout (G.timeout )
282 #define total_secs (G.total_secs )
283 #define hostname (G.hostname )
284 #define dotted (G.dotted )
285 #define pingaddr (G.pingaddr )
286 #define rcvd_tbl (G.rcvd_tbl )
287 void BUG_ping_globals_too_big(void);
288 #define INIT_G() do { \
289 if (sizeof(G) > COMMON_BUFSIZE) \
290 BUG_ping_globals_too_big(); \
292 datalen = DEFDATALEN; \
298 #define A(bit) rcvd_tbl[(bit)>>3] /* identify byte in array */
299 #define B(bit) (1 << ((bit) & 0x07)) /* identify bit in byte */
300 #define SET(bit) (A(bit) |= B(bit))
301 #define CLR(bit) (A(bit) &= (~B(bit)))
302 #define TST(bit) (A(bit) & B(bit))
304 /**************************************************************************/
306 static void print_stats_and_exit(int junk
) NORETURN
;
307 static void print_stats_and_exit(int junk UNUSED_PARAM
)
309 signal(SIGINT
, SIG_IGN
);
311 printf("\n--- %s ping statistics ---\n", hostname
);
312 printf("%lu packets transmitted, ", ntransmitted
);
313 printf("%lu packets received, ", nreceived
);
315 printf("%lu duplicates, ", nrepeats
);
317 ntransmitted
= (ntransmitted
- nreceived
) * 100 / ntransmitted
;
318 printf("%lu%% packet loss\n", ntransmitted
);
319 if (tmin
!= UINT_MAX
) {
320 unsigned tavg
= tsum
/ (nreceived
+ nrepeats
);
321 printf("round-trip min/avg/max = %u.%03u/%u.%03u/%u.%03u ms\n",
322 tmin
/ 1000, tmin
% 1000,
323 tavg
/ 1000, tavg
% 1000,
324 tmax
/ 1000, tmax
% 1000);
326 /* if condition is true, exit with 1 -- 'failure' */
327 exit(nreceived
== 0 || (deadline
&& nreceived
< pingcount
));
330 static void sendping_tail(void (*sp
)(int), const void *pkt
, int size_pkt
)
334 CLR((uint16_t)ntransmitted
% MAX_DUP_CHK
);
337 /* sizeof(pingaddr) can be larger than real sa size, but I think
338 * it doesn't matter */
339 sz
= xsendto(pingsock
, pkt
, size_pkt
, &pingaddr
.sa
, sizeof(pingaddr
));
341 bb_error_msg_and_die(bb_msg_write_error
);
343 if (pingcount
== 0 || deadline
|| ntransmitted
< pingcount
) {
344 /* Didn't send all pings yet - schedule next in 1s */
347 total_secs
+= PINGINTERVAL
;
348 if (total_secs
>= deadline
)
349 signal(SIGALRM
, print_stats_and_exit
);
352 } else { /* -c NN, and all NN are sent (and no deadline) */
353 /* Wait for the last ping to come back.
354 * -W timeout: wait for a response in seconds.
355 * Affects only timeout in absense of any responses,
356 * otherwise ping waits for two RTTs. */
357 unsigned expire
= timeout
;
360 /* approx. 2*tmax, in seconds (2 RTT) */
361 expire
= tmax
/ (512*1024);
365 signal(SIGALRM
, print_stats_and_exit
);
370 static void sendping4(int junk UNUSED_PARAM
)
372 /* +4 reserves a place for timestamp, which may end up sitting
373 * *after* packet. Saves one if() */
374 struct icmp
*pkt
= alloca(datalen
+ ICMP_MINLEN
+ 4);
376 memset(pkt
, 0, datalen
+ ICMP_MINLEN
+ 4);
377 pkt
->icmp_type
= ICMP_ECHO
;
378 /*pkt->icmp_code = 0;*/
379 /*pkt->icmp_cksum = 0;*/
380 pkt
->icmp_seq
= htons(ntransmitted
); /* don't ++ here, it can be a macro */
383 /* We don't do hton, because we will read it back on the same machine */
384 /*if (datalen >= 4)*/
385 *(uint32_t*)&pkt
->icmp_dun
= monotonic_us();
387 pkt
->icmp_cksum
= in_cksum((unsigned short *) pkt
, datalen
+ ICMP_MINLEN
);
389 sendping_tail(sendping4
, pkt
, datalen
+ ICMP_MINLEN
);
392 static void sendping6(int junk UNUSED_PARAM
)
394 struct icmp6_hdr
*pkt
= alloca(datalen
+ sizeof(struct icmp6_hdr
) + 4);
396 memset(pkt
, 0, datalen
+ sizeof(struct icmp6_hdr
) + 4);
397 pkt
->icmp6_type
= ICMP6_ECHO_REQUEST
;
398 /*pkt->icmp6_code = 0;*/
399 /*pkt->icmp6_cksum = 0;*/
400 pkt
->icmp6_seq
= htons(ntransmitted
); /* don't ++ here, it can be a macro */
401 pkt
->icmp6_id
= myid
;
403 /*if (datalen >= 4)*/
404 *(uint32_t*)(&pkt
->icmp6_data8
[4]) = monotonic_us();
406 sendping_tail(sendping6
, pkt
, datalen
+ sizeof(struct icmp6_hdr
));
410 static const char *icmp_type_name(int id
)
413 case ICMP_ECHOREPLY
: return "Echo Reply";
414 case ICMP_DEST_UNREACH
: return "Destination Unreachable";
415 case ICMP_SOURCE_QUENCH
: return "Source Quench";
416 case ICMP_REDIRECT
: return "Redirect (change route)";
417 case ICMP_ECHO
: return "Echo Request";
418 case ICMP_TIME_EXCEEDED
: return "Time Exceeded";
419 case ICMP_PARAMETERPROB
: return "Parameter Problem";
420 case ICMP_TIMESTAMP
: return "Timestamp Request";
421 case ICMP_TIMESTAMPREPLY
: return "Timestamp Reply";
422 case ICMP_INFO_REQUEST
: return "Information Request";
423 case ICMP_INFO_REPLY
: return "Information Reply";
424 case ICMP_ADDRESS
: return "Address Mask Request";
425 case ICMP_ADDRESSREPLY
: return "Address Mask Reply";
426 default: return "unknown ICMP type";
430 /* RFC3542 changed some definitions from RFC2292 for no good reason, whee!
431 * the newer 3542 uses a MLD_ prefix where as 2292 uses ICMP6_ prefix */
432 #ifndef MLD_LISTENER_QUERY
433 # define MLD_LISTENER_QUERY ICMP6_MEMBERSHIP_QUERY
435 #ifndef MLD_LISTENER_REPORT
436 # define MLD_LISTENER_REPORT ICMP6_MEMBERSHIP_REPORT
438 #ifndef MLD_LISTENER_REDUCTION
439 # define MLD_LISTENER_REDUCTION ICMP6_MEMBERSHIP_REDUCTION
441 static const char *icmp6_type_name(int id
)
444 case ICMP6_DST_UNREACH
: return "Destination Unreachable";
445 case ICMP6_PACKET_TOO_BIG
: return "Packet too big";
446 case ICMP6_TIME_EXCEEDED
: return "Time Exceeded";
447 case ICMP6_PARAM_PROB
: return "Parameter Problem";
448 case ICMP6_ECHO_REPLY
: return "Echo Reply";
449 case ICMP6_ECHO_REQUEST
: return "Echo Request";
450 case MLD_LISTENER_QUERY
: return "Listener Query";
451 case MLD_LISTENER_REPORT
: return "Listener Report";
452 case MLD_LISTENER_REDUCTION
: return "Listener Reduction";
453 default: return "unknown ICMP type";
458 static void unpack_tail(int sz
, uint32_t *tp
,
459 const char *from_str
,
460 uint16_t recv_seq
, int ttl
)
462 const char *dupmsg
= " (DUP!)";
463 unsigned triptime
= triptime
; /* for gcc */
468 /* (int32_t) cast is for hypothetical 64-bit unsigned */
469 /* (doesn't hurt 32-bit real-world anyway) */
470 triptime
= (int32_t) ((uint32_t)monotonic_us() - *tp
);
478 if (TST(recv_seq
% MAX_DUP_CHK
)) {
482 SET(recv_seq
% MAX_DUP_CHK
);
486 if (option_mask32
& OPT_QUIET
)
489 printf("%d bytes from %s: seq=%u ttl=%d", sz
,
490 from_str
, recv_seq
, ttl
);
492 printf(" time=%u.%03u ms", triptime
/ 1000, triptime
% 1000);
496 static void unpack4(char *buf
, int sz
, struct sockaddr_in
*from
)
498 struct icmp
*icmppkt
;
502 /* discard if too short */
503 if (sz
< (datalen
+ ICMP_MINLEN
))
506 /* check IP header */
507 iphdr
= (struct iphdr
*) buf
;
508 hlen
= iphdr
->ihl
<< 2;
510 icmppkt
= (struct icmp
*) (buf
+ hlen
);
511 if (icmppkt
->icmp_id
!= myid
)
512 return; /* not our ping */
514 if (icmppkt
->icmp_type
== ICMP_ECHOREPLY
) {
515 uint16_t recv_seq
= ntohs(icmppkt
->icmp_seq
);
518 if (sz
>= ICMP_MINLEN
+ sizeof(uint32_t))
519 tp
= (uint32_t *) icmppkt
->icmp_data
;
521 inet_ntoa(*(struct in_addr
*) &from
->sin_addr
.s_addr
),
522 recv_seq
, iphdr
->ttl
);
523 } else if (icmppkt
->icmp_type
!= ICMP_ECHO
) {
524 bb_error_msg("warning: got ICMP %d (%s)",
526 icmp_type_name(icmppkt
->icmp_type
));
530 static void unpack6(char *packet
, int sz
, /*struct sockaddr_in6 *from,*/ int hoplimit
)
532 struct icmp6_hdr
*icmppkt
;
533 char buf
[INET6_ADDRSTRLEN
];
535 /* discard if too short */
536 if (sz
< (datalen
+ sizeof(struct icmp6_hdr
)))
539 icmppkt
= (struct icmp6_hdr
*) packet
;
540 if (icmppkt
->icmp6_id
!= myid
)
541 return; /* not our ping */
543 if (icmppkt
->icmp6_type
== ICMP6_ECHO_REPLY
) {
544 uint16_t recv_seq
= ntohs(icmppkt
->icmp6_seq
);
547 if (sz
>= sizeof(struct icmp6_hdr
) + sizeof(uint32_t))
548 tp
= (uint32_t *) &icmppkt
->icmp6_data8
[4];
550 inet_ntop(AF_INET6
, &pingaddr
.sin6
.sin6_addr
,
553 } else if (icmppkt
->icmp6_type
!= ICMP6_ECHO_REQUEST
) {
554 bb_error_msg("warning: got ICMP %d (%s)",
556 icmp6_type_name(icmppkt
->icmp6_type
));
561 static void ping4(len_and_sockaddr
*lsa
)
563 char packet
[datalen
+ MAXIPLEN
+ MAXICMPLEN
];
566 pingsock
= create_icmp_socket();
567 pingaddr
.sin
= lsa
->u
.sin
;
569 if (setsockopt(pingsock
, IPPROTO_IP
, IP_MULTICAST_IF
,
570 &source_lsa
->u
.sa
, source_lsa
->len
))
571 bb_error_msg_and_die("can't set multicast source interface");
572 xbind(pingsock
, &source_lsa
->u
.sa
, source_lsa
->len
);
575 setsockopt_bindtodevice(pingsock
, str_I
);
577 /* enable broadcast pings */
578 setsockopt_broadcast(pingsock
);
580 /* set recv buf (needed if we can get lots of responses: flood ping,
581 * broadcast ping etc) */
582 sockopt
= (datalen
* 2) + 7 * 1024; /* giving it a bit of extra room */
583 setsockopt(pingsock
, SOL_SOCKET
, SO_RCVBUF
, &sockopt
, sizeof(sockopt
));
585 signal(SIGINT
, print_stats_and_exit
);
587 /* start the ping's going ... */
590 /* listen for replies */
592 struct sockaddr_in from
;
593 socklen_t fromlen
= (socklen_t
) sizeof(from
);
596 c
= recvfrom(pingsock
, packet
, sizeof(packet
), 0,
597 (struct sockaddr
*) &from
, &fromlen
);
600 bb_perror_msg("recvfrom");
603 unpack4(packet
, c
, &from
);
604 if (pingcount
&& nreceived
>= pingcount
)
609 extern int BUG_bad_offsetof_icmp6_cksum(void);
610 static void ping6(len_and_sockaddr
*lsa
)
612 char packet
[datalen
+ MAXIPLEN
+ MAXICMPLEN
];
615 struct sockaddr_in6 from
;
617 char control_buf
[CMSG_SPACE(36)];
619 pingsock
= create_icmp6_socket();
620 pingaddr
.sin6
= lsa
->u
.sin6
;
621 /* untested whether "-I addr" really works for IPv6: */
623 xbind(pingsock
, &source_lsa
->u
.sa
, source_lsa
->len
);
625 setsockopt_bindtodevice(pingsock
, str_I
);
629 struct icmp6_filter filt
;
630 if (!(option_mask32
& OPT_VERBOSE
)) {
631 ICMP6_FILTER_SETBLOCKALL(&filt
);
632 ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY
, &filt
);
634 ICMP6_FILTER_SETPASSALL(&filt
);
636 if (setsockopt(pingsock
, IPPROTO_ICMPV6
, ICMP6_FILTER
, &filt
,
638 bb_error_msg_and_die("setsockopt(ICMP6_FILTER)");
640 #endif /*ICMP6_FILTER*/
642 /* enable broadcast pings */
643 setsockopt_broadcast(pingsock
);
645 /* set recv buf (needed if we can get lots of responses: flood ping,
646 * broadcast ping etc) */
647 sockopt
= (datalen
* 2) + 7 * 1024; /* giving it a bit of extra room */
648 setsockopt(pingsock
, SOL_SOCKET
, SO_RCVBUF
, &sockopt
, sizeof(sockopt
));
650 sockopt
= offsetof(struct icmp6_hdr
, icmp6_cksum
);
651 if (offsetof(struct icmp6_hdr
, icmp6_cksum
) != 2)
652 BUG_bad_offsetof_icmp6_cksum();
653 setsockopt(pingsock
, SOL_RAW
, IPV6_CHECKSUM
, &sockopt
, sizeof(sockopt
));
655 /* request ttl info to be returned in ancillary data */
656 setsockopt(pingsock
, SOL_IPV6
, IPV6_HOPLIMIT
, &const_int_1
, sizeof(const_int_1
));
659 pingaddr
.sin6
.sin6_scope_id
= if_index
;
661 signal(SIGINT
, print_stats_and_exit
);
663 /* start the ping's going ... */
666 /* listen for replies */
667 msg
.msg_name
= &from
;
668 msg
.msg_namelen
= sizeof(from
);
671 msg
.msg_control
= control_buf
;
672 iov
.iov_base
= packet
;
673 iov
.iov_len
= sizeof(packet
);
678 msg
.msg_controllen
= sizeof(control_buf
);
680 c
= recvmsg(pingsock
, &msg
, 0);
683 bb_perror_msg("recvfrom");
686 for (mp
= CMSG_FIRSTHDR(&msg
); mp
; mp
= CMSG_NXTHDR(&msg
, mp
)) {
687 if (mp
->cmsg_level
== SOL_IPV6
688 && mp
->cmsg_type
== IPV6_HOPLIMIT
689 /* don't check len - we trust the kernel: */
690 /* && mp->cmsg_len >= CMSG_LEN(sizeof(int)) */
692 hoplimit
= *(int*)CMSG_DATA(mp
);
695 unpack6(packet
, c
, /*&from,*/ hoplimit
);
696 if (pingcount
&& nreceived
>= pingcount
)
702 static void ping(len_and_sockaddr
*lsa
)
704 printf("PING %s (%s)", hostname
, dotted
);
707 xmalloc_sockaddr2dotted_noport(&source_lsa
->u
.sa
));
709 printf(": %d data bytes\n", datalen
);
712 if (lsa
->u
.sa
.sa_family
== AF_INET6
)
719 int ping_main(int argc
, char **argv
) MAIN_EXTERNALLY_VISIBLE
;
720 int ping_main(int argc UNUSED_PARAM
, char **argv
)
722 len_and_sockaddr
*lsa
;
728 /* exactly one argument needed; -v and -q don't mix; -c NUM, -w NUM, -W NUM */
729 opt_complementary
= "=1:q--v:v--q:c+:w+:W+";
730 opt
= getopt32(argv
, OPT_STRING
, &pingcount
, &str_s
, &deadline
, &timeout
, &str_I
);
732 datalen
= xatou16(str_s
); // -s
733 if (opt
& OPT_I
) { // -I
734 if_index
= if_nametoindex(str_I
);
736 /* TODO: I'm not sure it takes IPv6 unless in [XX:XX..] format */
737 source_lsa
= xdotted2sockaddr(str_I
, 0);
738 str_I
= NULL
; /* don't try to bind to device later */
741 myid
= (uint16_t) getpid();
742 hostname
= argv
[optind
];
745 sa_family_t af
= AF_UNSPEC
;
750 lsa
= xhost_and_af2sockaddr(hostname
, 0, af
);
753 lsa
= xhost_and_af2sockaddr(hostname
, 0, AF_INET
);
756 if (source_lsa
&& source_lsa
->u
.sa
.sa_family
!= lsa
->u
.sa
.sa_family
)
757 /* leaking it here... */
760 dotted
= xmalloc_sockaddr2dotted_noport(&lsa
->u
.sa
);
762 print_stats_and_exit(EXIT_SUCCESS
);
763 /*return EXIT_SUCCESS;*/
765 #endif /* FEATURE_FANCY_PING */
769 int ping6_main(int argc
, char **argv
) MAIN_EXTERNALLY_VISIBLE
;
770 int ping6_main(int argc UNUSED_PARAM
, char **argv
)
772 argv
[0] = (char*)"-6";
773 return ping_main(0 /* argc+1 - but it's unused anyway */,
779 * Copyright (c) 1989 The Regents of the University of California.
780 * All rights reserved.
782 * This code is derived from software contributed to Berkeley by
785 * Redistribution and use in source and binary forms, with or without
786 * modification, are permitted provided that the following conditions
788 * 1. Redistributions of source code must retain the above copyright
789 * notice, this list of conditions and the following disclaimer.
790 * 2. Redistributions in binary form must reproduce the above copyright
791 * notice, this list of conditions and the following disclaimer in the
792 * documentation and/or other materials provided with the distribution.
794 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
795 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
797 * 4. Neither the name of the University nor the names of its contributors
798 * may be used to endorse or promote products derived from this software
799 * without specific prior written permission.
801 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
802 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
803 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
804 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
805 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
806 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
807 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
808 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
809 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
810 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF