*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* This version of ping is adapted from the ping in netkit-base 0.10,
* which is:
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
-#include <sys/time.h>
#include <sys/times.h>
-#include <sys/signal.h>
+#include <signal.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, (char *) &sockopt,
sizeof(sockopt));
- c = sendto(pingsock, packet, sizeof(packet), 0,
+ c = sendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr), 0,
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6));
if (c < 0 || c != sizeof(packet))
{
struct icmp6_hdr *pkt;
int i;
- char packet[datalen + 8];
+ char packet[datalen + sizeof (struct icmp6_hdr)];
pkt = (struct icmp6_hdr *) packet;
}
}
-/* libc defines have changed around on us, whee ! */
-#ifndef ICMP6_MEMBERSHIP_QUERY
-# define ICMP6_MEMBERSHIP_QUERY MLD_LISTENER_QUERY
+/* RFC3542 changed some definitions from RFC2292 for no good reason, whee !
+ * the newer 3542 uses a MLD_ prefix where as 2292 uses ICMP6_ prefix */
+#ifndef MLD_LISTENER_QUERY
+# define MLD_LISTENER_QUERY ICMP6_MEMBERSHIP_QUERY
#endif
-#ifndef ICMP6_MEMBERSHIP_REPORT
-# define ICMP6_MEMBERSHIP_REPORT MLD_LISTENER_REPORT
+#ifndef MLD_LISTENER_REPORT
+# define MLD_LISTENER_REPORT ICMP6_MEMBERSHIP_REPORT
#endif
-#ifndef ICMP6_MEMBERSHIP_REDUCTION
-# define ICMP6_MEMBERSHIP_REDUCTION MLD_LISTENER_REDUCTION
+#ifndef MLD_LISTENER_REDUCTION
+# define MLD_LISTENER_REDUCTION ICMP6_MEMBERSHIP_REDUCTION
#endif
static char *icmp6_type_name (int id)
{
case ICMP6_PARAM_PROB: return "Parameter Problem";
case ICMP6_ECHO_REPLY: return "Echo Reply";
case ICMP6_ECHO_REQUEST: return "Echo Request";
- case ICMP6_MEMBERSHIP_QUERY: return "Membership Query";
- case ICMP6_MEMBERSHIP_REPORT: return "Membership Report";
- case ICMP6_MEMBERSHIP_REDUCTION: return "Membership Reduction";
+ case MLD_LISTENER_QUERY: return "Listener Query";
+ case MLD_LISTENER_REPORT: return "Listener Report";
+ case MLD_LISTENER_REDUCTION: return "Listener Reduction";
default: return "unknown ICMP type";
}
}
return;
printf("%d bytes from %s: icmp6_seq=%u", sz,
- inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr,
+ inet_ntop(AF_INET6, &pingaddr.sin6_addr,
buf, sizeof(buf)),
icmppkt->icmp6_seq);
printf(" ttl=%d time=%lu.%lu ms", hoplimit,
struct icmp6_filter filt;
if (!(options & O_VERBOSE)) {
ICMP6_FILTER_SETBLOCKALL(&filt);
-#if 0
- if ((options & F_FQDN) || (options & F_FQDNOLD) ||
- (options & F_NODEADDR) || (options & F_SUPTYPES))
- ICMP6_FILTER_SETPASS(ICMP6_NI_REPLY, &filt);
- else
-#endif
ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &filt);
} else {
ICMP6_FILTER_SETPASSALL(&filt);
printf("PING %s (%s): %d data bytes\n",
hostent->h_name,
- inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr,
+ inet_ntop(AF_INET6, &pingaddr.sin6_addr,
buf, sizeof(buf)),
datalen);