X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fping6.c;h=1cff59d4b1ca0869e0c2baa0070580926bfc5c09;hb=5929edc1fac4340f99ed84e92bf3a2bedd4177c2;hp=42cf2785c9c132bc4e8486d842cc02d4cc491b6e;hpb=dfba741457cc81eb2ed3a9d4c074fbad74aa3249;p=oweals%2Fbusybox.git diff --git a/networking/ping6.c b/networking/ping6.c index 42cf2785c..1cff59d4b 100644 --- a/networking/ping6.c +++ b/networking/ping6.c @@ -37,9 +37,8 @@ #include #include #include -#include #include -#include +#include #include #include @@ -56,13 +55,15 @@ #include /* offsetof */ #include "busybox.h" -static const int DEFDATALEN = 56; -static const int MAXIPLEN = 60; -static const int MAXICMPLEN = 76; -static const int MAXPACKET = 65468; -#define MAX_DUP_CHK (8 * 128) -static const int MAXWAIT = 10; -static const int PINGINTERVAL = 1; /* second */ +enum { + DEFDATALEN = 56, + MAXIPLEN = 60, + MAXICMPLEN = 76, + MAXPACKET = 65468, + MAX_DUP_CHK = (8 * 128), + MAXWAIT = 10, + PINGINTERVAL = 1 /* second */ +}; #define O_QUIET (1 << 0) #define O_VERBOSE (1 << 1) @@ -109,7 +110,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)) @@ -202,7 +203,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; @@ -234,6 +235,17 @@ static void sendping(int junk) } } +/* 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 MLD_LISTENER_REPORT +# define MLD_LISTENER_REPORT ICMP6_MEMBERSHIP_REPORT +#endif +#ifndef MLD_LISTENER_REDUCTION +# define MLD_LISTENER_REDUCTION ICMP6_MEMBERSHIP_REDUCTION +#endif static char *icmp6_type_name (int id) { switch (id) { @@ -243,9 +255,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"; } }