1 diff -Naur fping-2.4b2/ChangeLog fping-2.4b2_to-ipv6/ChangeLog
2 --- fping-2.4b2/ChangeLog Thu Mar 15 03:09:39 2001
3 +++ fping-2.4b2_to-ipv6/ChangeLog Mon Jan 21 02:15:04 2002
5 -Tue Mar 14 18:37:50 2001
\r
6 -Jason Ewasiuk (ZeroHype Technologies Inc.) <noc@zerohype.com>
\r
9 +- Revision v2.4b2-to-IPv6
10 + - Added IPv6 support.
11 + - Added -I option for selecting source IPv4/IPv6 address.
12 + - Makefile.in now generates a Makefile which will build both
13 + fping (IPv4) and fping6 (IPv6). Thus it makes an fping (IPv4 only)
14 + and an fping6 (IPv6 only).
15 + - num_unreachable was counted twice when a sendto() generated errors.
16 + - See http://unfix.org/projects/ipv6/
19 +Jason Ewasiuk <jasone@remote.net>
\r
21 - added -g option for generating IPs from a start to an end value
\r
22 - two available options, generate IPs from start IP to end IP
\r
23 or from a passed netmask, such as 192.168.1.0/24
\r
25 -Thu Feb 15 14:35:00 2001
\r
26 -Jason Ewasiuk (ZeroHype Technologies Inc.) <noc@zerohype.com>
\r
28 +Jason Ewasiuk <jasone@remote.net>
\r
30 - formatting changes to code layout (fping.c)
\r
31 NOTE: Best viewed with a tab stop of 4
\r
32 diff -Naur fping-2.4b2/Makefile.am fping-2.4b2_to-ipv6/Makefile.am
33 --- fping-2.4b2/Makefile.am Thu Mar 15 03:07:52 2001
34 +++ fping-2.4b2_to-ipv6/Makefile.am Wed Jan 16 01:52:18 2002
38 fping_SOURCES = fping.c options.h linux.h
40 AUTOMAKE_OPTIONS=foreign
41 +EXTRA_DIST = $(man_MANS)
42 diff -Naur fping-2.4b2/README fping-2.4b2_to-ipv6/README
43 --- fping-2.4b2/README Wed Apr 25 20:29:10 2001
44 +++ fping-2.4b2_to-ipv6/README Mon Jan 21 02:02:12 2002
49 -Current maintainer and cool feature adder:
52 -ZeroHype Technologies Inc. (noc@zerohype.com) http://www.zerohype.com
53 +David Papp - david@remote.net
56 fping website: http://www.fping.com
59 Original author: Roland Schemers (schemers@stanford.edu)
60 Previous maintainer: RL "Bob" Morgan (morgan@stanford.edu)
61 +IPv6 Support: Jeroen Massar (jeroen@unfix.org / jeroen@ipng.nl)
64 Suggestions and patches:
65 diff -Naur fping-2.4b2/acconfig.h fping-2.4b2_to-ipv6/acconfig.h
66 --- fping-2.4b2/acconfig.h Thu Mar 15 03:07:52 2001
67 +++ fping-2.4b2_to-ipv6/acconfig.h Sat Nov 3 16:23:40 2001
74 /* VERSION (from configure.in) */
80 +/* some OSes do not define this ... lets take a wild guess */
83 +# define INADDR_NONE 0xffffffffU
86 +#endif /* CONFIG_H */
87 diff -Naur fping-2.4b2/aclocal.m4 fping-2.4b2_to-ipv6/aclocal.m4
88 --- fping-2.4b2/aclocal.m4 Thu Jan 1 01:00:00 1970
89 +++ fping-2.4b2_to-ipv6/aclocal.m4 Wed Jan 16 01:48:55 2002
91 +dnl aclocal.m4 generated automatically by aclocal 1.4
93 +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
94 +dnl This file is free software; the Free Software Foundation
95 +dnl gives unlimited permission to copy and/or distribute it,
96 +dnl with or without modifications, as long as this notice is preserved.
98 +dnl This program is distributed in the hope that it will be useful,
99 +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
100 +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
101 +dnl PARTICULAR PURPOSE.
103 +# Do all the work for Automake. This macro actually does too much --
104 +# some checks are only needed if your package does certain things.
105 +# But this isn't really a big deal.
110 +dnl AM_INIT_AUTOMAKE(package,version, [no-define])
112 +AC_DEFUN(AM_INIT_AUTOMAKE,
113 +[AC_REQUIRE([AC_PROG_INSTALL])
118 +dnl test to see if srcdir already configured
119 +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
120 + AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
123 +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
124 +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
125 +AC_REQUIRE([AM_SANITY_CHECK])
126 +AC_REQUIRE([AC_ARG_PROGRAM])
127 +dnl FIXME This is truly gross.
128 +missing_dir=`cd $ac_aux_dir && pwd`
129 +AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
130 +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
131 +AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
132 +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
133 +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
134 +AC_REQUIRE([AC_PROG_MAKE_SET])])
137 +# Check to make sure that the build environment is sane.
140 +AC_DEFUN(AM_SANITY_CHECK,
141 +[AC_MSG_CHECKING([whether build environment is sane])
144 +echo timestamp > conftestfile
145 +# Do `set' in a subshell so we don't clobber the current shell's
146 +# arguments. Must try -L first in case configure is actually a
147 +# symlink; some systems play weird games with the mod time of symlinks
148 +# (eg FreeBSD returns the mod time of the symlink's containing
151 + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
152 + if test "[$]*" = "X"; then
154 + set X `ls -t $srcdir/configure conftestfile`
156 + if test "[$]*" != "X $srcdir/configure conftestfile" \
157 + && test "[$]*" != "X conftestfile $srcdir/configure"; then
159 + # If neither matched, then we have a broken ls. This can happen
160 + # if, for instance, CONFIG_SHELL is bash and it inherits a
161 + # broken ls alias from the environment. This has actually
162 + # happened. Such a system could not be considered "sane".
163 + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
164 +alias in your environment])
167 + test "[$]2" = conftestfile
173 + AC_MSG_ERROR([newly created file is older than distributed files!
174 +Check your system clock])
177 +AC_MSG_RESULT(yes)])
179 +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
180 +dnl The program must properly implement --version.
181 +AC_DEFUN(AM_MISSING_PROG,
182 +[AC_MSG_CHECKING(for working $2)
183 +# Run test in a subshell; some versions of sh will print an error if
184 +# an executable is not found, even if stderr is redirected.
185 +# Redirect stdin to placate older versions of autoconf. Sigh.
186 +if ($2 --version) < /dev/null > /dev/null 2>&1; then
188 + AC_MSG_RESULT(found)
191 + AC_MSG_RESULT(missing)
195 +# Like AC_CONFIG_HEADER, but automatically create stamp file.
197 +AC_DEFUN(AM_CONFIG_HEADER,
199 +AC_CONFIG_HEADER([$1])
200 +dnl When config.status generates a header, we must update the stamp-h file.
201 +dnl This file resides in the same directory as the config header
202 +dnl that is generated. We must strip everything past the first ":",
203 +dnl and everything past the last "/".
204 +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
205 +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
206 +<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
208 +for am_file in <<$1>>; do
209 + case " <<$>>CONFIG_HEADERS " in
210 + *" <<$>>am_file "*<<)>>
211 + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
214 + am_indx=`expr "<<$>>am_indx" + 1`
218 diff -Naur fping-2.4b2/config.h.in fping-2.4b2_to-ipv6/config.h.in
219 --- fping-2.4b2/config.h.in Thu Mar 15 03:07:52 2001
220 +++ fping-2.4b2_to-ipv6/config.h.in Wed Jan 16 01:49:45 2002
222 /* config.h.in. Generated automatically from configure.in by autoheader. */
227 /* VERSION (from configure.in) */
231 /* Define if you have the socket library (-lsocket). */
232 #undef HAVE_LIBSOCKET
234 +/* Name of package */
237 +/* Version number of package */
241 +/* some OSes do not define this ... lets take a wild guess */
244 +# define INADDR_NONE 0xffffffffU
247 +#endif /* CONFIG_H */
248 diff -Naur fping-2.4b2/configure.in fping-2.4b2_to-ipv6/configure.in
249 --- fping-2.4b2/configure.in Thu Nov 7 21:11:57 2002
250 +++ fping-2.4b2_to-ipv6/configure.in Wed Jan 16 01:48:02 2002
252 dnl Process this file with autoconf to produce a configure script.
254 -AM_INIT_AUTOMAKE(fping,fping)
255 +AM_INIT_AUTOMAKE(fping, 2.4b2_to_ipv6)
257 AM_CONFIG_HEADER(config.h)
262 +AC_DEFINE_UNQUOTED(VERSION,"$VERSION")
264 dnl Checks for programs.
271 dnl Checks for libraries.
273 -AC_CHECK_FUNC(gethostbyname, [] AC_CHECK_LIB(nsl, gethostbyname))
274 +AC_CHECK_FUNC(gethostbyname)
275 +if test $ac_cv_func_gethostbyname = no; then
276 + AC_CHECK_LIB(nsl, gethostbyname)
278 AC_CHECK_FUNC(connect)
279 if test $ac_cv_func_connect = no; then
280 AC_CHECK_LIB(socket, connect)
282 dnl Checks for header files.
283 AC_CHECK_HEADERS(unistd.h sys/file.h stdlib.h sys/select.h)
285 -AC_OUTPUT([Makefile])
287 diff -Naur fping-2.4b2/fping.8 fping-2.4b2_to-ipv6/fping.8
288 --- fping-2.4b2/fping.8 Thu Mar 15 03:10:45 2001
289 +++ fping-2.4b2_to-ipv6/fping.8 Mon Jan 21 02:05:48 2002
292 Roland J. Schemers III, Stanford University, concept and versions 1.x
\r
293 RL "Bob" Morgan, Stanford University, versions 2.x
\r
294 -ZeroHype Technologies Inc. (http://www.zerohype.com), versions 2.3x and up,
\r
295 +David Papp, versions 2.3x and up,
\r
296 fping website: http://www.fping.com
\r
299 diff -Naur fping-2.4b2/fping.c fping-2.4b2_to-ipv6/fping.c
300 --- fping-2.4b2/fping.c Fri Jul 20 19:10:26 2001
301 +++ fping-2.4b2_to-ipv6/fping.c Mon Jan 21 02:06:30 2002
304 * Current maintainers of fping:
306 - * ZeroHype Technologies Inc. (http://www.zerohype.com)
307 - * Suggestions and patches, please email noc@zerohype.com
309 + * Suggestions and patches, please email david@remote.net
313 - * Original author: Roland Schemers <schemers@stanford.edu>
314 + * Original author: Roland Schemers <schemers@stanford.edu>
315 + * IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl>
320 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
321 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
323 +#define IPV6 1 /* This should be a compiler option, or even better be done from the Makefile... ;) */
326 #if !__STDC__ && !defined( __cplusplus ) && !defined( FUNCPROTO ) \
329 /*** autoconf includes ***/
338 +#include <netinet/in.h>
344 #endif /* HAVE_UNISTD_H */
346 #include <sys/file.h>
347 #endif /* HAVE_SYS_FILE_H */
350 +#include <netinet/icmp6.h>
352 #include <netinet/in_systm.h>
353 -#include <netinet/in.h>
355 /* Linux has bizarre ip.h and ip_icmp.h */
356 #if defined( __linux__ )
361 -#define REV_DATE "2001/01/25 11:25:04"
362 -#define EMAIL "noc@zerohype.com"
363 +#define REV_DATE "2002/01/16 00:33:42"
364 +#define EMAIL "david@remote.net"
366 /*** Ping packet defines ***/
371 #define ICMP_UNREACH_MAXTYPE 15
373 +#define FPING_SOCKADDR struct sockaddr_in
374 +#define FPING_ICMPHDR struct icmp
376 +#define FPING_SOCKADDR struct sockaddr_in6
377 +#define FPING_ICMPHDR struct icmp6_hdr
380 /* entry used to keep track of each host we are pinging */
383 char *name; /* name as given by user */
384 char *host; /* text description of host */
385 char *pad; /* pad to align print names */
386 - struct sockaddr_in saddr; /* internet address */
387 + FPING_SOCKADDR saddr; /* internet address */
388 int timeout; /* time to wait for response */
389 u_char running; /* unset when through sending */
390 u_char waiting; /* waiting for response */
394 void add_name( char *name );
396 void add_addr( char *name, char *host, struct in_addr ipaddr );
398 +void add_addr( char *name, char *host, FPING_SOCKADDR *ipaddr );
400 char *na_cat( char *name, struct in_addr ipaddr );
401 char *cpystr( char *string );
402 void crash_and_burn( char *message );
404 char *get_host_by_address( struct in_addr in );
405 int in_cksum( u_short *p, int n );
406 void u_sleep( int u_sec );
407 -int recvfrom_wto ( int s, char *buf, int len, struct sockaddr *saddr, int timo );
408 +int recvfrom_wto ( int s, char *buf, int len, FPING_SOCKADDR *saddr, int timo );
409 void remove_job( HOST_ENTRY *h );
410 void send_ping( int s, HOST_ENTRY *h );
411 long timeval_diff( struct timeval *a, struct timeval *b );
413 void print_per_system_splits( void );
414 void print_global_stats( void );
416 -int handle_random_icmp( struct icmp *p, int psize, struct sockaddr_in *addr );
417 +int handle_random_icmp( FPING_ICMPHDR *p, int psize, FPING_SOCKADDR *addr );
418 char *sprint_tm( int t );
420 #endif /* _NO_PROTO */
421 @@ -382,12 +400,14 @@
422 #endif /* _NO_PROTO */
430 struct protoent *proto;
434 /* check if we are root */
437 @@ -400,15 +420,62 @@
440 /* confirm that ICMP is available on this machine */
442 if( ( proto = getprotobyname( "icmp" ) ) == NULL )
444 + if( ( proto = getprotobyname( "ipv6-icmp" ) ) == NULL )
446 crash_and_burn( "icmp: unknown protocol" );
448 /* create raw socket for ICMP calls (ping) */
450 s = socket( AF_INET, SOCK_RAW, proto->p_proto );
452 + s = socket( AF_INET6, SOCK_RAW, proto->p_proto );
456 errno_crash_and_burn( "can't create raw socket" );
460 + * let the kerel pass extension headers of incoming packets,
461 + * for privileged socket options
463 +#ifdef IPV6_RECVHOPOPTS
464 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPOPTS, &opton,
466 + err(1, "setsockopt(IPV6_RECVHOPOPTS)");
467 +#else /* old adv. API */
468 + if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPOPTS, &opton,
470 + err(1, "setsockopt(IPV6_HOPOPTS)");
472 +#ifdef IPV6_RECVDSTOPTS
473 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVDSTOPTS, &opton,
475 + err(1, "setsockopt(IPV6_RECVDSTOPTS)");
476 +#else /* old adv. API */
477 + if (setsockopt(s, IPPROTO_IPV6, IPV6_DSTOPTS, &opton,
479 + err(1, "setsockopt(IPV6_DSTOPTS)");
481 +#ifdef IPV6_RECVRTHDRDSTOPTS
482 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVRTHDRDSTOPTS, &opton,
484 + err(1, "setsockopt(IPV6_RECVRTHDRDSTOPTS)");
486 +#ifdef IPV6_RECVRTHDR
487 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVRTHDR, &opton,
489 + err(1, "setsockopt(IPV6_RECVRTHDR)");
490 +#else /* old adv. API */
491 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RTHDR, &opton,
493 + err(1, "setsockopt(IPV6_RTHDR)");
497 if( ( uid = getuid() ) )
500 @@ -1425,7 +1492,7 @@
501 #endif /* _NO_PROTO */
505 + FPING_ICMPHDR *icp;
509 @@ -1434,9 +1501,10 @@
510 crash_and_burn( "can't malloc ping packet" );
512 memset( buffer, 0, ping_pkt_size * sizeof( char ) );
513 - icp = ( struct icmp* )buffer;
514 + icp = ( FPING_ICMPHDR* )buffer;
516 gettimeofday( &h->last_send_time, &tz );
518 icp->icmp_type = ICMP_ECHO;
521 @@ -1448,14 +1516,25 @@
522 pdp->ping_count = h->num_sent;
524 icp->icmp_cksum = in_cksum( ( u_short* )icp, ping_pkt_size );
526 + icp->icmp6_type = ICMP6_ECHO_REQUEST;
527 + icp->icmp6_code = 0;
528 + icp->icmp6_seq = h->i;
529 + icp->icmp6_id = ident;
531 + pdp = ( PING_DATA* )( buffer + SIZE_ICMP_HDR );
532 + pdp->ping_ts = h->last_send_time;
533 + pdp->ping_count = h->num_sent;
535 + icp->icmp6_cksum = 0; // The IPv6 stack calculates the checksum for us...
537 #if defined(DEBUG) || defined(_DEBUG)
539 printf( "sending [%d] to %s\n", h->num_sent, h->host );
540 #endif /* DEBUG || _DEBUG */
542 n = sendto( s, buffer, ping_pkt_size, 0,
543 - ( struct sockaddr* )&h->saddr, sizeof( struct sockaddr_in ) );
544 + ( struct sockaddr* )&h->saddr, sizeof( FPING_SOCKADDR ) );
546 if( n < 0 || n != ping_pkt_size )
548 @@ -1520,18 +1599,17 @@
551 static char buffer[4096];
552 - struct sockaddr_in response_addr;
553 + FPING_SOCKADDR response_addr;
558 + FPING_ICMPHDR *icp;
563 struct timeval sent_time;
565 - result = recvfrom_wto( s, buffer, 4096,
566 - ( struct sockaddr* )&response_addr, select_time );
567 + result = recvfrom_wto( s, buffer, sizeof(buffer), &response_addr, select_time );
570 return 0; /* timeout */
571 @@ -1546,7 +1624,7 @@
572 #endif /* DEBUG || _DEBUG */
574 ip = ( struct ip* )buffer;
577 #if defined( __alpha__ ) && __STDC__ && !defined( __GLIBC__ )
578 /* The alpha headers are decidedly broken.
579 * Using an ANSI compiler, it provides ip_vhl instead of ip_hl and
580 @@ -1556,37 +1634,59 @@
582 hlen = ip->ip_hl << 2;
583 #endif /* defined(__alpha__) && __STDC__ */
585 if( result < hlen + ICMP_MINLEN )
587 + if( result < sizeof(FPING_ICMPHDR) )
593 printf( "received packet too short for ICMP (%d bytes from %s)\n", result,
594 inet_ntoa( response_addr.sin_addr ) );
597 + char buf[INET6_ADDRSTRLEN];
598 + inet_ntop(response_addr.sin6_family, &response_addr.sin6_addr, buf, INET6_ADDRSTRLEN);
599 + printf( "received packet too short for ICMP (%d bytes from %s)\n", result, buf);
602 return( 1 ); /* too short */
606 - icp = ( struct icmp* )( buffer + hlen );
607 + icp = ( FPING_ICMPHDR* )( buffer + hlen );
609 if( icp->icmp_type != ICMP_ECHOREPLY )
611 + if( icp->icmp6_type != ICMP6_ECHO_REPLY )
614 /* handle some problem */
615 if( handle_random_icmp( icp, result, &response_addr ) )
623 if( icp->icmp_id != ident )
625 + if( icp->icmp6_id != ident )
627 return 1; /* packet received, but not the one we are looking for! */
632 if( icp->icmp_seq >= ( n_short )num_hosts )
634 + if( icp->icmp6_seq >= ( n_short )num_hosts )
636 return( 1 ); /* packet received, don't worry about it anymore */
641 + n = icp->icmp6_seq;
645 /* received ping is cool, so process it */
646 @@ -1595,9 +1695,14 @@
647 h->timeout = timeout;
653 memcpy( &sent_time, icp->icmp_data + offsetof( PING_DATA, ping_ts ), sizeof( sent_time ) );
654 memcpy( &this_count, icp->icmp_data, sizeof( this_count ) );
656 + memcpy( &sent_time, ((char *)icp->icmp6_data32)+4+offsetof(PING_DATA, ping_ts), sizeof( sent_time ) );
657 + memcpy( &this_count, ((char *)icp->icmp6_data32)+4, sizeof( this_count ) );
660 #if defined( DEBUG ) || defined( _DEBUG )
662 @@ -1627,10 +1732,18 @@
664 fprintf( stderr, "%s : duplicate for [%d], %d bytes, %s ms",
665 h->host, this_count, result, sprint_tm( this_reply ) );
668 if( response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr )
669 fprintf( stderr, " [<- %s]", inet_ntoa( response_addr.sin_addr ) );
672 + if(memcmp(&response_addr.sin6_addr, &h->saddr.sin6_addr, sizeof(response_addr.sin6_addr)))
674 + char buf[INET6_ADDRSTRLEN];
675 + inet_ntop(response_addr.sin6_family, &response_addr.sin6_addr, buf, INET6_ADDRSTRLEN);
677 + fprintf( stderr, " [<- %s]", buf);
680 fprintf( stderr, "\n" );
683 @@ -1660,10 +1773,17 @@
686 printf( " (%s ms)", sprint_tm( this_reply ) );
689 if( response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr )
690 printf( " [<- %s]", inet_ntoa( response_addr.sin_addr ) );
693 + if(memcmp(&response_addr.sin6_addr, &h->saddr.sin6_addr, sizeof(response_addr.sin6_addr)))
695 + char buf[INET6_ADDRSTRLEN];
696 + inet_ntop(response_addr.sin6_family, &response_addr.sin6_addr, buf, INET6_ADDRSTRLEN);
697 + fprintf( stderr, " [<- %s]", buf);
703 @@ -1688,9 +1808,17 @@
704 ( h->num_recv * 100 ) / h->num_sent );
709 if( response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr )
710 printf( " [<- %s]", inet_ntoa( response_addr.sin_addr ) );
712 + if(memcmp(&response_addr.sin6_addr, &h->saddr.sin6_addr, sizeof(response_addr.sin6_addr)))
714 + char buf[INET6_ADDRSTRLEN];
715 + inet_ntop(response_addr.sin6_family, &response_addr.sin6_addr, buf, INET6_ADDRSTRLEN);
716 + fprintf( stderr, " [<- %s]", buf);
722 @@ -1706,7 +1834,7 @@
724 *************************************************************
726 - Inputs: struct icmp *p, int psize, struct sockaddr_in *addr
727 + Inputs: FPING_ICMPHDR *p, int psize, FPING_SOCKADDR *addr
731 @@ -1717,22 +1845,33 @@
734 int handle_random_icmp( p, psize, addr )
738 - struct sockaddr_in *addr;
739 + FPING_SOCKADDR *addr;
741 -int handle_random_icmp( struct icmp *p, int psize, struct sockaddr_in *addr )
742 +int handle_random_icmp( FPING_ICMPHDR *p, int psize, FPING_SOCKADDR *addr )
743 #endif /* _NO_PROTO */
745 - struct icmp *sent_icmp;
746 + FPING_ICMPHDR *sent_icmp;
751 + char addr_ascii[INET6_ADDRSTRLEN];
752 + inet_ntop(addr->sin6_family, &addr->sin6_addr, addr_ascii, INET6_ADDRSTRLEN);
757 switch( p->icmp_type )
759 + switch( p->icmp6_type )
763 + sent_icmp = ( FPING_ICMPHDR* )( c + 28 );
766 sent_icmp = ( struct icmp* )( c + 28 );
768 if( ( sent_icmp->icmp_type == ICMP_ECHO ) &&
769 @@ -1747,16 +1886,37 @@
770 fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
771 inet_ntoa( addr->sin_addr ), h->host );
774 + if( ( sent_icmp->icmp6_type == ICMP_ECHO ) &&
775 + ( sent_icmp->icmp6_id == ident ) &&
776 + ( sent_icmp->icmp6_seq < ( n_short )num_hosts ) )
778 + /* this is a response to a ping we sent */
779 + h = table[sent_icmp->icmp6_seq];
781 + if( p->icmp6_code > ICMP_UNREACH_MAXTYPE )
783 + fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
784 + addr_ascii, h->host );
789 fprintf( stderr, "%s from %s for ICMP Echo sent to %s",
791 icmp_unreach_str[p->icmp_code], inet_ntoa( addr->sin_addr ), h->host );
793 + icmp_unreach_str[p->icmp6_code], addr_ascii, h->host );
798 if( inet_addr( h->host ) == -1 )
800 fprintf( stderr, " (%s)", inet_ntoa( h->saddr.sin_addr ) );
802 + fprintf( stderr, " (%s)", addr_ascii);
805 fprintf( stderr, "\n" );
807 @@ -1768,7 +1928,8 @@
811 - sent_icmp = ( struct icmp* )( c + 28 );
812 + sent_icmp = ( FPING_ICMPHDR* )( c + 28 );
814 if( ( sent_icmp->icmp_type = ICMP_ECHO ) &&
815 ( sent_icmp->icmp_id = ident ) &&
816 ( sent_icmp->icmp_seq < ( n_short )num_hosts ) )
817 @@ -1780,6 +1941,19 @@
819 if( inet_addr( h->host ) == -1 )
820 fprintf( stderr, " (%s)", inet_ntoa( h->saddr.sin_addr ) );
822 + if( ( sent_icmp->icmp6_type = ICMP_ECHO ) &&
823 + ( sent_icmp->icmp6_id = ident ) &&
824 + ( sent_icmp->icmp6_seq < ( n_short )num_hosts ) )
826 + /* this is a response to a ping we sent */
827 + h = table[sent_icmp->icmp6_seq];
828 + fprintf( stderr, "%s from %s for ICMP Echo sent to %s",
829 + icmp_type_str[p->icmp6_type], addr_ascii, h->host );
831 + if( inet_addr( h->host ) == -1 )
832 + fprintf( stderr, " (%s)", addr_ascii );
835 fprintf( stderr, "\n" );
837 @@ -1879,6 +2053,7 @@
838 void add_name( char *name )
839 #endif /* _NO_PROTO */
842 struct hostent *host_ent;
844 struct in_addr *ipa = ( struct in_addr* )&ipaddress;
845 @@ -1985,7 +2160,27 @@
851 + FPING_SOCKADDR dst;
852 + struct addrinfo *res, hints;
857 + bzero(&hints, sizeof(struct addrinfo));
858 + hints.ai_flags = AI_CANONNAME;
859 + hints.ai_family = AF_INET6;
860 + hints.ai_socktype = SOCK_RAW;
861 + hints.ai_protocol = IPPROTO_ICMPV6;
863 + ret_ga = getaddrinfo(name, NULL, &hints, &res);
864 + if (ret_ga) errx(1, "%s", gai_strerror(ret_ga));
865 + if (res->ai_canonname) hostname = res->ai_canonname;
866 + else hostname = name;
867 + if (!res->ai_addr) errx(1, "getaddrinfo failed");
868 + (void)memcpy(&dst, res->ai_addr, sizeof(FPING_SOCKADDR)); /*res->ai_addrlen);*/
869 + add_addr(name, name, &dst);
874 @@ -2048,9 +2243,17 @@
875 void add_addr( name, host, ipaddr )
879 struct in_addr ipaddr;
881 +FPING_SOCKADDR *ipaddr;
885 void add_addr( char *name, char *host, struct in_addr ipaddr )
887 +void add_addr( char *name, char *host, FPING_SOCKADDR *ipaddr )
889 #endif /* _NO_PROTO */
892 @@ -2064,8 +2267,13 @@
897 p->saddr.sin_family = AF_INET;
898 p->saddr.sin_addr = ipaddr;
900 + p->saddr.sin6_family = AF_INET6;
901 + (void)memcpy(&p->saddr, ipaddr, sizeof(FPING_SOCKADDR));
903 p->timeout = timeout;
905 p->min_reply = 10000000;
906 @@ -2193,7 +2401,11 @@
907 #endif /* _NO_PROTO */
911 h = gethostbyaddr( ( char* )&in, sizeof( struct in_addr ),AF_INET );
913 + h = gethostbyaddr( ( char* )&in, sizeof( FPING_SOCKADDR ),AF_INET6 );
916 if( h == NULL || h->h_name == NULL )
917 return inet_ntoa( in );
918 @@ -2429,7 +2641,7 @@
920 *************************************************************
922 - Inputs: int s, char* buf, int len, struct sockaddr *saddr, int timo
923 + Inputs: int s, char* buf, int len, FPING_SOCKADDR *saddr, int timo
927 @@ -2443,9 +2655,9 @@
930 int recvfrom_wto( s, buf, len, saddr, timo )
931 -int s; char *buf; int len; struct sockaddr *saddr; int timo;
932 +int s; char *buf; int len; FPING_SOCKADDR *saddr; int timo;
934 -int recvfrom_wto( int s, char *buf, int len, struct sockaddr *saddr, int timo )
935 +int recvfrom_wto( int s, char *buf, int len, FPING_SOCKADDR *saddr, int timo )
936 #endif /* _NO_PROTO */
939 @@ -2465,8 +2677,12 @@
941 return -1; /* timeout */
944 slen = sizeof( struct sockaddr );
945 - n = recvfrom( s, buf, len, 0, saddr, &slen );
947 + slen = sizeof( FPING_SOCKADDR );
949 + n = recvfrom( s, buf, len, 0, (struct sockaddr *)saddr, &slen );
951 errno_crash_and_burn( "recvfrom" );