Skip to content

Commit

Permalink
compatibility fixes and prepare rc2
Browse files Browse the repository at this point in the history
  • Loading branch information
schweikert committed Jan 31, 2017
1 parent cae1bcd commit 6b99b7b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
Unreleased
* INCOMPATIBILITY WARNING:
fping and fping6 are now unified into one binary. This means that for
example doing 'fping www.google.com' is going to ping the IPv6 IP of
www.google.com on IPv6-enabled hosts. If you need exact compatibility with
old versions, you can:
- compile fping with --disable-ipv6 (or use a wrapper, and call 'fping -4')
- compile fping with --enable-ipv6 and rename it to fping6 (same as 'fping -6')

* (feature) Unified 'fping' and 'fping6' into one binary
* (feature) New option '-4' to force IPv4
* (feature) New option '-6' to force IPv6
* (feature) Support kernel-timestamping of received packets (#46)
* (feature) Simplify restrictions: only -i >= 1 and -p >= 10 are enforced now
* (feature) --enable-ipv6 is now default (you can use --disable-ipv6 to disable IPv6 support)
* (bugfix) Fix option -m to return all IPs of a hostname
* (bugfix) Fix option -H (ttl) for IPv6
* (bugfix) Fix option -M (don't fragment) for IPv6
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl Minimum Autoconf version required.
AC_PREREQ(2.59)

AC_INIT([fping],[3.16-rc1])
AC_INIT([fping],[3.16-rc2])

dnl make ipv4 and ipv6 options
AC_ARG_ENABLE([ipv4],
Expand Down
4 changes: 3 additions & 1 deletion src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,14 @@ int main( int argc, char **argv )
perror("setsockopt IP_MTU_DISCOVER");
}
}
#ifdef IPV6
if(socket6) {
int val = IPV6_PMTUDISC_DO;
if (setsockopt(socket6, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val))) {
perror("setsockopt IPV6_MTU_DISCOVER");
}
}
#endif
#else
fprintf(stderr, "%s, -M option not supported on this platform\n", prog);
exit(1);
Expand Down Expand Up @@ -1728,6 +1730,7 @@ int receive_packet(int socket,
0
};
int timestamp_set = 0;
struct cmsghdr *cmsg;

recv_len = recvmsg(socket, &recv_msghdr, 0);
if(recv_len <= 0) {
Expand All @@ -1736,7 +1739,6 @@ int receive_packet(int socket,

#if HAVE_SO_TIMESTAMP
/* ancilliary data */
struct cmsghdr *cmsg;
for(cmsg = CMSG_FIRSTHDR(&recv_msghdr);
cmsg != NULL;
cmsg = CMSG_NXTHDR(&recv_msghdr, cmsg))
Expand Down
14 changes: 7 additions & 7 deletions src/socket4.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ unsigned short calcsum(unsigned short *buffer, int length)
{
unsigned long sum;

// initialize sum to zero and loop until length (in words) is 0
for (sum=0; length>1; length-=2) // sizeof() returns number of bytes, we're interested in number of words
sum += *buffer++; // add 1 word of buffer to sum and proceed to the next
/* initialize sum to zero and loop until length (in words) is 0 */
for (sum=0; length>1; length-=2) /* sizeof() returns number of bytes, we're interested in number of words */
sum += *buffer++; /* add 1 word of buffer to sum and proceed to the next */

// we may have an extra byte
/* we may have an extra byte */
if (length==1)
sum += (char)*buffer;

sum = (sum >> 16) + (sum & 0xFFFF); // add high 16 to low 16
sum += (sum >> 16); // add carry
sum = (sum >> 16) + (sum & 0xFFFF); /* add high 16 to low 16 */
sum += (sum >> 16); /* add carry */
return ~sum;
}

Expand All @@ -131,7 +131,7 @@ int socket_sendto_ping_ipv4(int s, struct sockaddr *saddr, socklen_t saddr_len,
icp->icmp_id = htons(icmp_id_nr);

if (random_data_flag) {
for (n = ((void*)&icp->icmp_data - (void *)icp); n < ping_pkt_size_ipv4; ++n) {
for (n = ((char*)&icp->icmp_data - (char *)icp); n < ping_pkt_size_ipv4; ++n) {
ping_buffer_ipv4[n] = random() & 0xFF;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/socket6.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int socket_sendto_ping_ipv6(int s, struct sockaddr *saddr, socklen_t saddr_len,
}
}

icp->icmp6_cksum = 0; // The IPv6 stack calculates the checksum for us...
icp->icmp6_cksum = 0; /* The IPv6 stack calculates the checksum for us... */

n = sendto(s, icp, ping_pkt_size_ipv6, 0, saddr, saddr_len);

Expand Down
6 changes: 5 additions & 1 deletion src/test-c89.sh
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
gcc -DHAVE_CONFIG_H -D_BSD_SOURCE -D_POSIX_SOURCE -I.. -Wall -std=c89 -pedantic -c -o fping.o fping.c
#!/bin/sh

for f in fping.c socket4.c socket6.c seqmap.c; do
gcc -DHAVE_CONFIG_H -D_BSD_SOURCE -D_POSIX_SOURCE -I.. -Wall -std=c89 -pedantic -c -o /dev/null $f
done

0 comments on commit 6b99b7b

Please sign in to comment.