#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.2 2000-11-02 18:02:52 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.7 2002-06-11 17:08:49 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include <stdio.h>
#include <string.h>
{ 0, NULL }
};
-static void
+static void
print_mtrace(register const u_char *bp, register u_int len)
{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
+ register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mtrace %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
}
-static void
+static void
print_mresp(register const u_char *bp, register u_int len)
{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
+ register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mresp %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
}
-static void
-print_igmpv3_report(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+static void
+print_igmpv3_report(register const u_char *bp, register u_int len)
{
- int group, nsrcs, ngroups;
- register int i, j;
+ u_int group, nsrcs, ngroups;
+ register u_int i, j;
/* Minimum len is 16, and should be a multiple of 4 */
if (len < 16 || len & 0x03) {
- (void)printf(" [invalid len %d]", len);
- return;
+ (void)printf(" [invalid len %d]", len);
+ return;
}
TCHECK2(bp[6], 2);
ngroups = EXTRACT_16BITS(&bp[6]);
- (void)printf(", %d group record(s)", ngroups);
+ (void)printf(", %d group record(s)", ngroups);
if (vflag > 0) {
/* Print the group records */
- group = 8;
+ group = 8;
for (i=0; i<ngroups; i++) {
if (len < group+8) {
(void)printf(" [invalid number of groups]");
}
static void
-print_igmpv3_query(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+print_igmpv3_query(register const u_char *bp, register u_int len)
{
- int nsrcs;
- register int i;
+ u_int mrc;
+ int mrt;
+ u_int nsrcs;
+ register u_int i;
(void)printf(" v3");
/* Minimum len is 12, and should be a multiple of 4 */
if (len < 12 || len & 0x03) {
- (void)printf(" [invalid len %d]", len);
- return;
+ (void)printf(" [invalid len %d]", len);
+ return;
+ }
+ mrc = bp[1];
+ if (mrc < 128) {
+ mrt = mrc;
+ } else {
+ mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3);
+ }
+ if (mrc != 100) {
+ (void)printf(" [max resp time ");
+ relts_print(mrt);
+ (void)printf("]");
}
TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]) == 0)
}
void
-igmp_print(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+igmp_print(register const u_char *bp, register u_int len)
{
- register const struct ip *ip;
-
- ip = (const struct ip *)bp2;
- (void)printf("%s > %s: ",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
-
if (qflag) {
(void)printf("igmp");
return;
case 0x11:
(void)printf("igmp query");
if (len >= 12)
- print_igmpv3_query(bp, len, bp2);
+ print_igmpv3_query(bp, len);
else {
if (bp[1]) {
(void)printf(" v2");
(void)printf(" [max resp time %d]", bp[1]);
} else
(void)printf(" v1");
- if (EXTRACT_32BITS(&bp[4]))
+ if (EXTRACT_32BITS(&bp[4]))
(void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
if (len != 8)
(void)printf(" [len %d]", len);
break;
case 0x22:
(void)printf("igmp v3 report");
- print_igmpv3_report(bp, len, bp2);
+ print_igmpv3_report(bp, len);
break;
case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));