Update IGMP printing, removing the obsolete packet header version number &

changing "new" and "old" to "v2" and "v1" to allow for future changes not
having to be "newer new"

Recognize Router Alert IP option
This commit is contained in:
fenner 1996-03-19 17:25:12 +00:00
parent 4a021e5f35
commit 474e2a6756

View File

@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
/* From: Header: print-ip.c,v 1.28 92/05/25 14:29:02 mccanne Exp $ (LBL) */ /* From: Header: print-ip.c,v 1.28 92/05/25 14:29:02 mccanne Exp $ (LBL) */
static char rcsid[] = static char rcsid[] =
"$Id: /a/ncvs/src/usr.sbin/tcpdump/tcpdump/print-ip.c,v 1.4 1995/03/08 12:52:33 olah Exp $"; "$Id: print-ip.c,v 1.5 1995/06/13 17:39:23 wollman Exp $";
#endif #endif
#include <sys/param.h> #include <sys/param.h>
@ -65,40 +65,46 @@ igmp_print(register const u_char *bp, register int len,
(void)printf("[|igmp]"); (void)printf("[|igmp]");
return; return;
} }
switch (bp[0] & 0xf) { switch (bp[0]) {
case 1: case 0x11:
(void)printf("igmp %squery", bp[1] ? "new " : ""); (void)printf("igmp %s query", bp[1] ? "v2" : "v1");
if (bp[1] != 100) if (bp[1] && bp[1] != 100)
printf(" [intvl %d]", bp[1]); (void)printf(" [intvl %d]", bp[1]);
if (*(int *)&bp[4]) if (*(int *)&bp[4])
(void)printf(" [gaddr %s]", ipaddr_string(&bp[4])); (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
if (len != 8) if (len != 8)
(void)printf(" [len %d]", len); (void)printf(" [len %d]", len);
break; break;
case 2: case 0x12:
case 6: case 0x16:
(void)printf("igmp %sreport %s", (void)printf("igmp %s report %s",
(bp[0] & 0xf) == 6 ? "new " : "", (bp[0] & 0xf) == 6 ? "v2" : "v1",
ipaddr_string(&bp[4])); ipaddr_string(&bp[4]));
if (len != 8) if (len != 8)
(void)printf(" [len %d]", len); (void)printf(" [len %d]", len);
if (bp[1]) if (bp[1])
(void)printf(" [b1=0x%x]", bp[1]); (void)printf(" [b1=0x%x]", bp[1]);
break; break;
case 7: case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4])); (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
if (len != 8) if (len != 8)
(void)printf(" [len %d]", len); (void)printf(" [len %d]", len);
if (bp[1]) if (bp[1])
(void)printf(" [b1=0x%x]", bp[1]); (void)printf(" [b1=0x%x]", bp[1]);
break; break;
case 3: case 0x13:
(void)printf("igmp dvmrp"); (void)printf("igmp dvmrp");
switch(bp[1]) { switch(bp[1]) {
case 1: case 1:
printf(" probe"); printf(" probe");
if (len < 8) if (len < 8)
(void)printf(" [len %d]", len); (void)printf(" [len %d]", len);
if (vflag) {
if (len > 8)
(void)printf(" genid 0x%08x",
ntohl(*(int *)&bp[8]));
(void)printf(" [nf 0x%02x]", bp[5]);
}
if (len > 12) { if (len > 12) {
int i; int i;
for (i = 12; i + 3 < len; i += 4) { for (i = 12; i + 3 < len; i += 4) {
@ -109,6 +115,8 @@ igmp_print(register const u_char *bp, register int len,
break; break;
case 2: case 2:
printf(" report"); printf(" report");
if (vflag)
(void)printf(" [nf 0x%02x]", bp[5]);
if (len < 8) if (len < 8)
(void)printf(" [len %d]", len); (void)printf(" [len %d]", len);
break; break;
@ -158,35 +166,33 @@ igmp_print(register const u_char *bp, register int len,
} }
break; break;
case 4: case 0x14:
printf("igmp pim %s", ipaddr_string(&bp[4])); printf("igmp pim %s", ipaddr_string(&bp[4]));
if (len < 8) if (len < 8)
(void)printf(" [len %d]", len); (void)printf(" [len %d]", len);
if (bp[1]) if (bp[1])
(void)printf(" [b1=0x%x]", bp[1]); (void)printf(" [b1=0x%x]", bp[1]);
break; break;
case 15: case 0x1e:
(void)printf("igmp mtrace %s", ipaddr_string(&bp[4])); case 0x1f:
if (len < 8) (void)printf("igmp mtrace%s %s",
(bp[0] == 0x1e) ? " response" : "",
ipaddr_string(&bp[4]));
if (len < 24)
(void)printf(" [len %d]", len); (void)printf(" [len %d]", len);
if (bp[1]) else if (vflag) {
(void)printf(" [b1=0x%x]", bp[1]); (void)printf(" s=%s", ipaddr_string(&bp[8]));
break; (void)printf(" d=%s", ipaddr_string(&bp[12]));
case 14: (void)printf(" qid=0x%06x",
(void)printf("igmp mtrace-resp %s", ipaddr_string(&bp[4])); bp[21] << 16 + bp[22] << 8 + bp[23]);
if (len < 8) }
(void)printf(" [len %d]", len);
if (bp[1])
(void)printf(" [b1=0x%x]", bp[1]);
break; break;
default: default:
(void)printf("igmp-%d", bp[0] & 0xf); (void)printf("igmp-%d", bp[0]);
if (bp[1]) if (bp[1])
(void)printf(" [b1=0x%x]", bp[1]); (void)printf(" [b1=0x%x]", bp[1]);
break; break;
} }
if ((bp[0] >> 4) != 1)
(void)printf(" [v%d]", bp[0] >> 4);
} }
/* /*
@ -271,6 +277,14 @@ ip_optprint(register const u_char *cp, int length)
ip_printroute("LSRR", cp, len); ip_printroute("LSRR", cp, len);
break; break;
case IPOPT_RA:
printf(" RA");
if (len != 4)
printf("{%d}", len);
if (cp[2] != 0 || cp[3] != 0)
printf("[b23=%04x]",cp[2] << 8 + cp[3]);
break;
default: default:
printf(" IPOPT-%d{%d}", cp[0], len); printf(" IPOPT-%d{%d}", cp[0], len);
break; break;