From 740e55c20bb4b80dbd3e7d87a403bf7a8e6e58d5 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 27 Oct 2001 07:42:45 +0000 Subject: [PATCH] From Crist J. Clark : print the IP protocol field for fragments other than the first fragment. Also, for packets whose IP protocols we don't handle ourselves, print the protocol name if "getprotobynumber()" finds it, otherwise print the protocol number. --- CREDITS | 1 + print-ip.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CREDITS b/CREDITS index c017b3c9..004d059d 100644 --- a/CREDITS +++ b/CREDITS @@ -22,6 +22,7 @@ Additional people who have contributed patches: Chris G. Demetriou Chris Jepeway Craig Rodrigues + Crist J. Clark Daniel Hagerty Francisco Matias Cuenca-Acuna Frank Volf diff --git a/print-ip.c b/print-ip.c index da34def9..62c70342 100644 --- a/print-ip.c +++ b/print-ip.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.100 2001-09-17 21:58:03 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.101 2001-10-27 07:42:46 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -34,6 +34,7 @@ static const char rcsid[] = #include +#include #include #include #include @@ -257,6 +258,7 @@ ip_print(register const u_char *bp, register u_int length) register const u_char *cp; u_char nh; int advance; + struct protoent *proto; ip = (const struct ip *)bp; #ifdef LBL_ALIGN @@ -461,7 +463,11 @@ again: break; default: - (void)printf(" ip-proto-%d %d", nh, len); + if ((proto = getprotobynumber(nh)) != NULL) + (void)printf(" %s", proto->p_name); + else + (void)printf(" ip-proto-%d", nh); + printf(" %d", len); break; } } @@ -480,11 +486,17 @@ again: if (off & 0x3fff) { /* * if this isn't the first frag, we're missing the - * next level protocol header. print the ip addr. + * next level protocol header. print the ip addr + * and the protocol. */ - if (off & 0x1fff) + if (off & 0x1fff) { (void)printf("%s > %s:", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); + if ((proto = getprotobynumber(ip->ip_p)) != NULL) + (void)printf(" %s", proto->p_name); + else + (void)printf(" ip-proto-%d", ip->ip_p); + } #ifndef IP_MF #define IP_MF 0x2000 #endif /* IP_MF */ -- 2.39.5