diff options
author | wollman <wollman@FreeBSD.org> | 1994-09-08 02:29:12 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1994-09-08 02:29:12 +0000 |
commit | e3b496d3f0f19932a3182672e8283cb667967c24 (patch) | |
tree | 1bc897dba81610712aa8a71cc98a0bb0b230a870 /usr.sbin/tcpdump | |
parent | 644accfcba4ead1ce68c3b2b12427c870e45ab03 (diff) | |
download | FreeBSD-src-e3b496d3f0f19932a3182672e8283cb667967c24.zip FreeBSD-src-e3b496d3f0f19932a3182672e8283cb667967c24.tar.gz |
Print out more useful information about IGMP packets. (Someday, this should
include a full DVMRP parser.)
Diffstat (limited to 'usr.sbin/tcpdump')
-rw-r--r-- | usr.sbin/tcpdump/tcpdump/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/tcpdump/tcpdump/print-ip.c | 114 |
2 files changed, 98 insertions, 18 deletions
diff --git a/usr.sbin/tcpdump/tcpdump/Makefile b/usr.sbin/tcpdump/tcpdump/Makefile index 8432e58..d9ec9a1 100644 --- a/usr.sbin/tcpdump/tcpdump/Makefile +++ b/usr.sbin/tcpdump/tcpdump/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 0.1 (RWGrimes) 3/24/93 PROG= tcpdump -CFLAGS+=-DCSLIP -DPPP -I. +CFLAGS+=-DCSLIP -DPPP -I. -I${.CURDIR}/../../mrouted MAN1= tcpdump.1 SRCS= version.c addrtoname.c bpf_dump.c bpf_filter.c bpf_image.c etherent.c \ gencode.c inet.c md.c nametoaddr.c optimize.c os.c pcap.c \ diff --git a/usr.sbin/tcpdump/tcpdump/print-ip.c b/usr.sbin/tcpdump/tcpdump/print-ip.c index 8716a01..85c2ad9 100644 --- a/usr.sbin/tcpdump/tcpdump/print-ip.c +++ b/usr.sbin/tcpdump/tcpdump/print-ip.c @@ -21,7 +21,7 @@ #ifndef lint static char rcsid[] = - "@(#) $Header: print-ip.c,v 1.28 92/05/25 14:29:02 mccanne Exp $ (LBL)"; + "@(#) $Header: /home/ncvs/src/usr.sbin/tcpdump/tcpdump/print-ip.c,v 1.1.1.1 1993/06/12 14:42:08 rgrimes Exp $ (LBL)"; #endif #include <sys/param.h> @@ -35,9 +35,11 @@ static char rcsid[] = #include <netinet/udp_var.h> #include <netinet/tcp.h> #include <netinet/tcpip.h> +#include <netinet/igmp.h> #include "interface.h" #include "addrtoname.h" +#include "dvmrp.h" /* in mrouted directory */ void igmp_print(cp, len, ip) @@ -46,6 +48,7 @@ igmp_print(cp, len, ip) register struct ip *ip; { register u_char *ep = (u_char *)snapend; + struct igmp *igmp = (struct igmp *)cp; (void)printf("%s > %s: ", ipaddr_string(&ip->ip_src), @@ -55,32 +58,100 @@ igmp_print(cp, len, ip) (void)printf("[|igmp]"); return; } - switch (cp[0] & 0xf) { - case 1: + switch (igmp->igmp_type) { + case IGMP_HOST_MEMBERSHIP_QUERY: (void)printf("igmp query"); - if (*(int *)&cp[4]) - (void)printf(" [gaddr %s]", ipaddr_string(&cp[4])); - if (len != 8) + if (igmp->igmp_group.s_addr) + (void)printf(" [gaddr %s]", + ipaddr_string(&igmp->igmp_group)); + if (igmp->igmp_code) + printf(" [code %d]", igmp->igmp_code); + if (len != IGMP_MINLEN) (void)printf(" [len %d]", len); break; - case 2: - (void)printf("igmp report %s", ipaddr_string(&cp[4])); - if (len != 8) + case IGMP_HOST_MEMBERSHIP_REPORT: + (void)printf("igmp report %s", ipaddr_string(&igmp->igmp_group)); + if (igmp->igmp_code) + printf(" [code %d]", igmp->igmp_code); + if (len != IGMP_MINLEN) (void)printf(" [len %d]", len); break; - case 3: - (void)printf("igmp dvmrp", ipaddr_string(&cp[4])); - if (len < 8) + case IGMP_HOST_NEW_MEMBERSHIP_REPORT: + printf("igmp new report %s", ipaddr_string(&igmp->igmp_group)); + if (igmp->igmp_code) + printf(" [code %d]", igmp->igmp_code); + if (len != IGMP_MINLEN) + (void)printf(" [len %d]", len); + break; + + case IGMP_HOST_LEAVE_MESSAGE: + printf("igmp leave %s", ipaddr_string(&igmp->igmp_group)); + if (igmp->igmp_code) + printf(" [code %d]", igmp->igmp_code); + if (len != IGMP_MINLEN) + (void)printf(" [len %d]", len); + break; + + case IGMP_DVMRP: + (void)printf("igmp dvmrp"); + switch(igmp->igmp_code) { + case DVMRP_PROBE: + printf(" probe"); + break; + case DVMRP_REPORT: + printf(" report"); + break; + case DVMRP_ASK_NEIGHBORS: + printf(" neighbor list request"); + break; + case DVMRP_NEIGHBORS: + printf(" neighbor list reply"); + break; + case DVMRP_ASK_NEIGHBORS2: + printf(" neighbor list request v2"); + break; + case DVMRP_NEIGHBORS2: + printf(" neighbor list reply v2"); + break; + case DVMRP_PRUNE: + printf(" prune"); + break; + case DVMRP_GRAFT: + printf(" graft"); + break; + case DVMRP_GRAFT_ACK: + printf(" graft ack"); + break; + default: + printf("-%d", igmp->igmp_code); + break; + } + + if (len != IGMP_MINLEN) + (void)printf(" [len %d]", len); + break; + case IGMP_MTRACE: + (void)printf("igmp traceroute %s", + ipaddr_string(&igmp->igmp_group)); + if (igmp->igmp_code) + printf(" [code %d]", igmp->igmp_code); + if (len != IGMP_MINLEN) + (void)printf(" [len %d]", len); + break; + case IGMP_MTRACE_RESP: + (void)printf("igmp traceroute resp %s", + ipaddr_string(&igmp->igmp_group)); + if (igmp->igmp_code) + printf(" [code %d]", igmp->igmp_code); + if (len != IGMP_MINLEN) (void)printf(" [len %d]", len); break; default: - (void)printf("igmp-%d", cp[0] & 0xf); + (void)printf("igmp-%x", igmp->igmp_type); + if (igmp->igmp_code) + printf(" [code %d]", igmp->igmp_code); break; } - if ((cp[0] >> 4) != 1) - (void)printf(" [v%d]", cp[0] >> 4); - if (cp[1]) - (void)printf(" [b1=0x%x]", cp[1]); } /* @@ -214,6 +285,15 @@ ip_print(ip, length) return; } hlen = ip->ip_hl * 4; + if (hlen < sizeof (struct ip)) { + printf("invalid ip header length %d", hlen); + return; + } + + if (ip->ip_v != 4) { + printf("unknown ip version %d", ip->ip_v); + return; + } NTOHS(ip->ip_len); NTOHS(ip->ip_off); |