summaryrefslogtreecommitdiff
path: root/usr.sbin/tcpdump/print-null.c
diff options
context:
space:
mode:
authorJakob Schlyter <jakob@cvs.openbsd.org>2000-04-26 21:35:45 +0000
committerJakob Schlyter <jakob@cvs.openbsd.org>2000-04-26 21:35:45 +0000
commit2dd23c23770ee72b2c221e1b8ddf74531cf67e15 (patch)
tree6bc2e589e5c398c416d7cd4014d0d050bdcea861 /usr.sbin/tcpdump/print-null.c
parent7ffa8e1885137bf28c6c378169c6dc323b6dbbe2 (diff)
INET6
DHCP/BOOTP tcp & udp checksum detection numerous bugfixes
Diffstat (limited to 'usr.sbin/tcpdump/print-null.c')
-rw-r--r--usr.sbin/tcpdump/print-null.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/usr.sbin/tcpdump/print-null.c b/usr.sbin/tcpdump/print-null.c
index 6a6ca9cb4e9..bba644129e8 100644
--- a/usr.sbin/tcpdump/print-null.c
+++ b/usr.sbin/tcpdump/print-null.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-null.c,v 1.10 1999/09/16 20:58:47 brad Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-null.c,v 1.11 2000/04/26 21:35:42 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -44,12 +44,15 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
-#include <netinet/tcpip.h>
#include <pcap.h>
#include <stdio.h>
#include <string.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
#include "interface.h"
#include "addrtoname.h"
@@ -64,8 +67,12 @@ struct rtentry;
#define NULL_HDRLEN 4
static void
-null_print(const u_char *p, u_int length, u_int family)
+null_print(const u_char *p, const struct ip *ip, u_int length)
{
+ u_int family;
+
+ memcpy((char *)&family, (char *)p, sizeof(family));
+
if (nflag) {
/* XXX just dump the header */
return;
@@ -76,6 +83,12 @@ null_print(const u_char *p, u_int length, u_int family)
printf("ip: ");
break;
+#ifdef INET6
+ case AF_INET6:
+ printf("ip6: ");
+ break;
+#endif
+
case AF_NS:
printf("ns: ");
break;
@@ -91,8 +104,7 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
- u_int family;
- const u_char *pkt;
+ const struct ip *ip;
ts_print(&h->ts);
@@ -104,25 +116,24 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
packetp = p;
snapend = p + caplen;
- pkt = p + NULL_HDRLEN;
length -= NULL_HDRLEN;
- memcpy((char *)&family, (char *)p, sizeof(family));
+ ip = (struct ip *)(p + NULL_HDRLEN);
if (eflag)
- null_print(p, length, family);
+ null_print(p, ip, length);
- switch (ntohl(family)) {
- case AF_INET:
- ip_print(pkt, length);
- break;
- case AF_APPLETALK:
- atalk_print(pkt, length);
- break;
- }
+#ifndef INET6
+ ip_print((const u_char *)ip, length);
+#else
+ if (ip->ip_v == IPVERSION)
+ ip_print((const u_char *)ip, length);
+ else if (ip->ip_v == 6)
+ ip6_print((const u_char *)ip, length);
+#endif /*INET6*/
if (xflag)
- default_print(pkt, caplen - NULL_HDRLEN);
+ default_print((const u_char *)ip, caplen - NULL_HDRLEN);
putchar('\n');
}