summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-ip.c
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>2003-03-02 08:22:26 +0000
committerfenner <fenner@FreeBSD.org>2003-03-02 08:22:26 +0000
commit5f76ebca43302f98858e83a6212d9c610e939bad (patch)
treec244ceda18deb5fc8e576971e1e83b7b631f5219 /contrib/tcpdump/print-ip.c
parent24ede2d805a7ffac09999aafe7d4f285e45a6edd (diff)
downloadFreeBSD-src-5f76ebca43302f98858e83a6212d9c610e939bad.zip
FreeBSD-src-5f76ebca43302f98858e83a6212d9c610e939bad.tar.gz
Import tcpdump 3.7.2 (fudging for multi-DLT support) from
http://www.tcpdump.org/release/tcpdump-3.7.2.tar.gz
Diffstat (limited to 'contrib/tcpdump/print-ip.c')
-rw-r--r--contrib/tcpdump/print-ip.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index e3e35ea..e1619c1 100644
--- a/contrib/tcpdump/print-ip.c
+++ b/contrib/tcpdump/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.100.4.1 2002/01/25 05:39:54 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,6 +34,7 @@ static const char rcsid[] =
#include <netinet/in.h>
+#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -257,13 +258,12 @@ 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
/*
* If the IP header is not aligned, copy into abuf.
- * This will never happen with BPF. It does happen raw packet
- * dumps from -r.
*/
if ((long)ip & 3) {
static u_char *abuf = NULL;
@@ -461,7 +461,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 +484,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 */
OpenPOWER on IntegriCloud