X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fping6.c;h=767aafd2a91b76eb1b791d0e7def276e6005cc8d;hb=59fe8b90890a07c87ec9c2943bae515d5c6d959d;hp=47ab7c15461941bfeafbd90938aed1439580782f;hpb=9e094552c8ca9f7e518a071f12eeafda81e2423b;p=oweals%2Fbusybox.git diff --git a/networking/ping6.c b/networking/ping6.c index 47ab7c154..767aafd2a 100644 --- a/networking/ping6.c +++ b/networking/ping6.c @@ -5,19 +5,7 @@ * * Copyright (C) 1999 by Randolph Chung * - * 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: @@ -37,9 +25,8 @@ #include #include #include -#include #include -#include +#include #include #include @@ -111,7 +98,7 @@ static void ping(const char *host) 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)) @@ -204,7 +191,7 @@ static void sendping(int junk) { struct icmp6_hdr *pkt; int i; - char packet[datalen + 8]; + char packet[datalen + sizeof (struct icmp6_hdr)]; pkt = (struct icmp6_hdr *) packet; @@ -236,15 +223,16 @@ static void sendping(int junk) } } -/* 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) { @@ -255,9 +243,9 @@ 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"; } } @@ -311,7 +299,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit 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, @@ -351,12 +339,6 @@ static void ping(const char *host) 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); @@ -392,7 +374,7 @@ static void ping(const char *host) 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);