* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.12 2003-11-15 00:39:26 guy Exp $ (LBL)";
-#endif
#ifndef IN_CLASSD
#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
#endif
+static const char tstr[] = "[|igmp]";
+
/* (following from ipmulti/mrouted/prune.h) */
/*
#define TR_PROTO_CBT 4
/* igmpv3 report types */
-static struct tok igmpv3report2str[] = {
+static const struct tok igmpv3report2str[] = {
{ 1, "is_in" },
{ 2, "is_ex" },
{ 3, "to_in" },
printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
return;
trunc:
- (void)printf("[|igmp]");
+ printf("%s", tstr);
return;
}
printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
return;
trunc:
- (void)printf("[|igmp]");
+ printf("%s", tstr);
return;
}
}
return;
trunc:
- (void)printf("[|igmp]");
+ (void)printf("%s", tstr);
return;
}
(void)printf(" [invalid len %d]", len);
return;
}
+ TCHECK(bp[1]);
mrc = bp[1];
if (mrc < 128) {
mrt = mrc;
}
if (mrc != 100) {
(void)printf(" [max resp time ");
- relts_print(mrt);
+ if (mrt < 600) {
+ (void)printf("%.1fs", mrt * 0.1);
+ } else {
+ relts_print(mrt / 10);
+ }
(void)printf("]");
}
TCHECK2(bp[4], 4);
(void)printf("]");
return;
trunc:
- (void)printf("[|igmp]");
+ (void)printf("%s", tstr);
return;
}
void
igmp_print(register const u_char *bp, register u_int len)
{
+ struct cksum_vec vec[1];
+
if (qflag) {
(void)printf("igmp");
return;
}
- TCHECK2(bp[0], 8);
+ TCHECK(bp[0]);
switch (bp[0]) {
case 0x11:
(void)printf("igmp query");
if (len >= 12)
print_igmpv3_query(bp, len);
else {
+ TCHECK(bp[1]);
if (bp[1]) {
(void)printf(" v2");
if (bp[1] != 100)
(void)printf(" [max resp time %d]", bp[1]);
} else
(void)printf(" v1");
+ TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]))
(void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
if (len != 8)
}
break;
case 0x12:
+ TCHECK2(bp[4], 4);
(void)printf("igmp v1 report %s", ipaddr_string(&bp[4]));
if (len != 8)
(void)printf(" [len %d]", len);
break;
case 0x16:
+ TCHECK2(bp[4], 4);
(void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
break;
case 0x22:
print_igmpv3_report(bp, len);
break;
case 0x17:
+ TCHECK2(bp[4], 4);
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));
break;
case 0x13:
if (vflag && TTEST2(bp[0], len)) {
/* Check the IGMP checksum */
- if (in_cksum((const u_short*)bp, len, 0))
+ vec[0].ptr = bp;
+ vec[0].len = len;
+ if (in_cksum(vec, 1))
printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
}
return;
trunc:
- fputs("[|igmp]", stdout);
+ (void)printf("%s", tstr);
}