From 0cd0aa1a484cfafda4854fc93ed6a98937975928 Mon Sep 17 00:00:00 2001 From: mickey Date: Mon, 4 Mar 1996 15:58:52 +0000 Subject: [PATCH] Updating to the latest LBL release. Sun's SKIP support added. --- usr.sbin/tcpdump/CHANGES | 28 +- usr.sbin/tcpdump/Makefile | 5 +- usr.sbin/tcpdump/README | 3 +- usr.sbin/tcpdump/addrtoname.c | 1 + usr.sbin/tcpdump/addrtoname.h | 1 + usr.sbin/tcpdump/appletalk.h | 1 + usr.sbin/tcpdump/atime.awk | 1 + usr.sbin/tcpdump/bootp.h | 1 + usr.sbin/tcpdump/bpf_dump.c | 1 + usr.sbin/tcpdump/decnet.h | 1 + usr.sbin/tcpdump/ethertype.h | 1 + usr.sbin/tcpdump/extract.h | 1 + usr.sbin/tcpdump/fddi.h | 1 + usr.sbin/tcpdump/interface.h | 6 + usr.sbin/tcpdump/ipx.h | 1 + usr.sbin/tcpdump/llc.h | 1 + usr.sbin/tcpdump/makemib | 1 + usr.sbin/tcpdump/md.h | 1 + usr.sbin/tcpdump/mib.h | 1 + usr.sbin/tcpdump/nfsfh.h | 1 + usr.sbin/tcpdump/nfsv2.h | 1 + usr.sbin/tcpdump/ntp.h | 1 + usr.sbin/tcpdump/os.h | 1 + usr.sbin/tcpdump/ospf.h | 1 + usr.sbin/tcpdump/packetdat.awk | 1 + usr.sbin/tcpdump/parsenfsfh.c | 1 + usr.sbin/tcpdump/print-arp.c | 1 + usr.sbin/tcpdump/print-atalk.c | 1 + usr.sbin/tcpdump/print-bootp.c | 1 + usr.sbin/tcpdump/print-decnet.c | 1 + usr.sbin/tcpdump/print-domain.c | 1 + usr.sbin/tcpdump/print-egp.c | 1 + usr.sbin/tcpdump/print-ether.c | 1 + usr.sbin/tcpdump/print-fddi.c | 1 + usr.sbin/tcpdump/print-icmp.c | 1 + usr.sbin/tcpdump/print-ip.c | 54 +- usr.sbin/tcpdump/print-ipx.c | 1 + usr.sbin/tcpdump/print-isoclns.c | 1 + usr.sbin/tcpdump/print-llc.c | 1 + usr.sbin/tcpdump/print-nfs.c | 1 + usr.sbin/tcpdump/print-ntp.c | 1 + usr.sbin/tcpdump/print-null.c | 1 + usr.sbin/tcpdump/print-ospf.c | 1 + usr.sbin/tcpdump/print-ppp.c | 1 + usr.sbin/tcpdump/print-rip.c | 1 + usr.sbin/tcpdump/print-skip.c | 919 +++++++++++++++++++++++++++++++ usr.sbin/tcpdump/print-sl.c | 7 +- usr.sbin/tcpdump/print-snmp.c | 1 + usr.sbin/tcpdump/print-sunrpc.c | 1 + usr.sbin/tcpdump/print-tcp.c | 5 +- usr.sbin/tcpdump/print-tftp.c | 1 + usr.sbin/tcpdump/print-udp.c | 1 + usr.sbin/tcpdump/print-wb.c | 1 + usr.sbin/tcpdump/send-ack.awk | 1 + usr.sbin/tcpdump/stime.awk | 1 + usr.sbin/tcpdump/tcpdump.8 | 1 + usr.sbin/tcpdump/tcpdump.c | 40 +- usr.sbin/tcpdump/util.c | 19 +- usr.sbin/tcpdump/version.c | 3 +- 59 files changed, 1117 insertions(+), 20 deletions(-) create mode 100644 usr.sbin/tcpdump/print-skip.c diff --git a/usr.sbin/tcpdump/CHANGES b/usr.sbin/tcpdump/CHANGES index 78281761384..959ea0217ce 100644 --- a/usr.sbin/tcpdump/CHANGES +++ b/usr.sbin/tcpdump/CHANGES @@ -1,5 +1,31 @@ +$OpenBSD: CHANGES,v 1.2 1996/03/04 15:58:52 mickey Exp $ $NetBSD: CHANGES,v 1.2 1995/03/06 19:09:42 mycroft Exp $ -@(#) Header: CHANGES,v 1.6 94/06/20 19:34:38 leres Exp (LBL) +@(#) Header: CHANGES,v 1.6+ 94/06/20 19:34:38 leres Exp $ (LBL) + +v3.0.2 Thu Apr 20 21:28:16 PDT 1995 + +- Change configuration to not use gcc v2 flags with gcc v1. + +- Redo gmt2local() so that it works under BSDI (which seems to return + an empty timezone struct from gettimeofday()). Based on report from + Terry Kennedy (terry@spcvxa.spc.edu). + +- Change configure to recognize IP[0-9]* as "mips" SGI hardware. Based + on report from Mark Andrews (mandrews@alias.com). + +- Don't pass cc flags to gcc. Resulted from a bug report from Rainer + Orth (ro@techfak.uni-bielefeld.de). + +- Fixed printout of connection id for uncompressed tcp slip packets. + Resulted from a bug report from Richard Stevens (rstevens@noao.edu). + +- Hack around deficiency in Ultrix's make. + +- Add ETHERTYPE_TRAIL define which is missing from irix5. + +v3.0.1 Wed Aug 31 22:42:26 PDT 1994 + +- Fix problems with gcc2 vs. malloc() and read() prototypes under SunOS 4. v3.0 Mon Jun 20 19:23:27 PDT 1994 diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile index 9d9f4dd4fa2..a0d4d949a86 100644 --- a/usr.sbin/tcpdump/Makefile +++ b/usr.sbin/tcpdump/Makefile @@ -1,3 +1,4 @@ +# $OpenBSD: Makefile,v 1.2 1996/03/04 15:58:53 mickey Exp $ # $NetBSD: Makefile,v 1.6 1995/03/07 23:18:39 mycroft Exp $ # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -19,7 +20,7 @@ # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # -# @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/Makefile,v 1.1.1.1 1995/10/18 08:48:23 deraadt Exp $ (LBL) +# @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/Makefile,v 1.2 1996/03/04 15:58:53 mickey Exp $ (LBL) PROG= tcpdump MAN= tcpdump.8 @@ -35,7 +36,7 @@ SRCS= tcpdump.c addrtoname.c \ print-icmp.c print-sl.c print-ppp.c print-rip.c \ print-snmp.c print-ntp.c print-null.c print-egp.c print-ospf.c \ print-fddi.c print-llc.c print-sunrpc.c \ - print-wb.c print-decnet.c print-isoclns.c print-ipx.c \ + print-wb.c print-decnet.c print-isoclns.c print-ipx.c print-skip.c \ util.c bpf_dump.c parsenfsfh.c version.c AWKS = atime.awk packetdat.awk send-ack.awk stime.awk diff --git a/usr.sbin/tcpdump/README b/usr.sbin/tcpdump/README index b88305fd35d..b3b740dffa1 100644 --- a/usr.sbin/tcpdump/README +++ b/usr.sbin/tcpdump/README @@ -1,7 +1,8 @@ +$OpenBSD: README,v 1.2 1996/03/04 15:58:54 mickey Exp $ $NetBSD: README,v 1.3 1995/03/07 23:18:35 mycroft Exp $ @(#) Header: README,v 1.39 94/06/20 20:15:16 leres Exp (LBL) -TCPDUMP 3.0 +TCPDUMP 3.0.2 Lawrence Berkeley Laboratory Network Research Group tcpdump@ee.lbl.gov diff --git a/usr.sbin/tcpdump/addrtoname.c b/usr.sbin/tcpdump/addrtoname.c index d4e3aae843a..5e26d403548 100644 --- a/usr.sbin/tcpdump/addrtoname.c +++ b/usr.sbin/tcpdump/addrtoname.c @@ -1,3 +1,4 @@ +/* $OpenBSD: addrtoname.c,v 1.2 1996/03/04 15:58:55 mickey Exp $ */ /* $NetBSD: addrtoname.c,v 1.4 1995/04/24 13:27:39 cgd Exp $ */ /* diff --git a/usr.sbin/tcpdump/addrtoname.h b/usr.sbin/tcpdump/addrtoname.h index 74a6ba0baa0..5eeff108a87 100644 --- a/usr.sbin/tcpdump/addrtoname.h +++ b/usr.sbin/tcpdump/addrtoname.h @@ -1,3 +1,4 @@ +/* $OpenBSD: addrtoname.h,v 1.2 1996/03/04 15:58:56 mickey Exp $ */ /* $NetBSD: addrtoname.h,v 1.2 1995/03/06 19:09:50 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/appletalk.h b/usr.sbin/tcpdump/appletalk.h index d0941667d02..ca92708b5ac 100644 --- a/usr.sbin/tcpdump/appletalk.h +++ b/usr.sbin/tcpdump/appletalk.h @@ -1,3 +1,4 @@ +/* $OpenBSD: appletalk.h,v 1.2 1996/03/04 15:58:57 mickey Exp $ */ /* $NetBSD: appletalk.h,v 1.2 1995/03/06 19:09:51 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/atime.awk b/usr.sbin/tcpdump/atime.awk index 9f5d9d145a6..377df1cb99f 100644 --- a/usr.sbin/tcpdump/atime.awk +++ b/usr.sbin/tcpdump/atime.awk @@ -1,3 +1,4 @@ +# $OpenBSD: atime.awk,v 1.2 1996/03/04 15:58:58 mickey Exp $ # $NetBSD: atime.awk,v 1.2 1995/03/06 19:09:52 mycroft Exp $ $6 ~ /^ack/ && $5 !~ /[SFR]/ { diff --git a/usr.sbin/tcpdump/bootp.h b/usr.sbin/tcpdump/bootp.h index 6e2a328f414..5ad4fe99287 100644 --- a/usr.sbin/tcpdump/bootp.h +++ b/usr.sbin/tcpdump/bootp.h @@ -1,3 +1,4 @@ +/* $OpenBSD: bootp.h,v 1.2 1996/03/04 15:58:59 mickey Exp $ */ /* $NetBSD: bootp.h,v 1.2 1995/03/06 19:09:54 mycroft Exp $ */ /* @(#) Header: bootp.h,v 1.6 94/01/13 19:06:29 leres Exp (LBL) */ diff --git a/usr.sbin/tcpdump/bpf_dump.c b/usr.sbin/tcpdump/bpf_dump.c index 100d147db81..cb5b6a8fde1 100644 --- a/usr.sbin/tcpdump/bpf_dump.c +++ b/usr.sbin/tcpdump/bpf_dump.c @@ -1,3 +1,4 @@ +/* $OpenBSD: bpf_dump.c,v 1.2 1996/03/04 15:59:00 mickey Exp $ */ /* $NetBSD: bpf_dump.c,v 1.2 1995/03/06 19:09:55 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/decnet.h b/usr.sbin/tcpdump/decnet.h index 5965f77dfde..847a599f841 100644 --- a/usr.sbin/tcpdump/decnet.h +++ b/usr.sbin/tcpdump/decnet.h @@ -1,3 +1,4 @@ +/* $OpenBSD: decnet.h,v 1.2 1996/03/04 15:59:00 mickey Exp $ */ /* $NetBSD: decnet.h,v 1.2 1995/03/06 19:09:58 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/ethertype.h b/usr.sbin/tcpdump/ethertype.h index c4ec760218f..410503e11cc 100644 --- a/usr.sbin/tcpdump/ethertype.h +++ b/usr.sbin/tcpdump/ethertype.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ethertype.h,v 1.2 1996/03/04 15:59:01 mickey Exp $ */ /* $NetBSD: ethertype.h,v 1.2 1995/03/06 19:10:06 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/extract.h b/usr.sbin/tcpdump/extract.h index 2288ca55d58..ef5ce02d489 100644 --- a/usr.sbin/tcpdump/extract.h +++ b/usr.sbin/tcpdump/extract.h @@ -1,3 +1,4 @@ +/* $OpenBSD: extract.h,v 1.2 1996/03/04 15:59:02 mickey Exp $ */ /* $NetBSD: extract.h,v 1.2 1995/03/06 19:10:08 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/fddi.h b/usr.sbin/tcpdump/fddi.h index 2d91b70454f..8c259700a4d 100644 --- a/usr.sbin/tcpdump/fddi.h +++ b/usr.sbin/tcpdump/fddi.h @@ -1,3 +1,4 @@ +/* $OpenBSD: fddi.h,v 1.2 1996/03/04 15:59:03 mickey Exp $ */ /* $NetBSD: fddi.h,v 1.2 1995/03/06 19:10:10 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h index 2e321153116..ba0d465245e 100644 --- a/usr.sbin/tcpdump/interface.h +++ b/usr.sbin/tcpdump/interface.h @@ -1,3 +1,4 @@ +/* $OpenBSD: interface.h,v 1.2 1996/03/04 15:59:04 mickey Exp $ */ /* $NetBSD: interface.h,v 1.2 1995/03/06 19:10:18 mycroft Exp $ */ /* @@ -135,6 +136,11 @@ extern void sunrpcrequest_print(const u_char *, int, const u_char *); extern void tftp_print(const u_char *, int); extern void wb_print(const void *, int); +extern void skip_print(const u_char *, int, const u_char *); +extern void skip_print_old(const u_char *, int, const u_char *); +extern void ah_print(const u_char *, int, const u_char *); +extern void esp_print(const u_char *, int, const u_char *); + #define min(a,b) ((a)>(b)?(b):(a)) #define max(a,b) ((b)>(a)?(b):(a)) diff --git a/usr.sbin/tcpdump/ipx.h b/usr.sbin/tcpdump/ipx.h index e943f6e7673..00133d3fe98 100644 --- a/usr.sbin/tcpdump/ipx.h +++ b/usr.sbin/tcpdump/ipx.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ipx.h,v 1.2 1996/03/04 15:59:05 mickey Exp $ */ /* $NetBSD: ipx.h,v 1.2 1995/03/06 19:10:19 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/llc.h b/usr.sbin/tcpdump/llc.h index 2712fda70a1..0ce8aad8c4c 100644 --- a/usr.sbin/tcpdump/llc.h +++ b/usr.sbin/tcpdump/llc.h @@ -1,3 +1,4 @@ +/* $OpenBSD: llc.h,v 1.2 1996/03/04 15:59:06 mickey Exp $ */ /* $NetBSD: llc.h,v 1.2 1995/03/06 19:10:20 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/makemib b/usr.sbin/tcpdump/makemib index debab1f3763..8203883261e 100644 --- a/usr.sbin/tcpdump/makemib +++ b/usr.sbin/tcpdump/makemib @@ -1,5 +1,6 @@ #!/bin/sh # +# $OpenBSD: makemib,v 1.2 1996/03/04 15:59:07 mickey Exp $ # $NetBSD: makemib,v 1.2 1995/03/06 19:10:22 mycroft Exp $ # # Copyright (c) 1990, by John Robert LoVerso. diff --git a/usr.sbin/tcpdump/md.h b/usr.sbin/tcpdump/md.h index 35306653f23..b68ba111dd5 100644 --- a/usr.sbin/tcpdump/md.h +++ b/usr.sbin/tcpdump/md.h @@ -1,3 +1,4 @@ +/* $OpenBSD: md.h,v 1.2 1996/03/04 15:59:08 mickey Exp $ */ /* $NetBSD: md.h,v 1.2 1995/03/06 19:10:33 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/mib.h b/usr.sbin/tcpdump/mib.h index 747af862f9c..0f42c69e1eb 100644 --- a/usr.sbin/tcpdump/mib.h +++ b/usr.sbin/tcpdump/mib.h @@ -1,3 +1,4 @@ +/* $OpenBSD: mib.h,v 1.2 1996/03/04 15:59:08 mickey Exp $ */ /* $NetBSD: mib.h,v 1.2 1995/03/06 19:10:34 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/nfsfh.h b/usr.sbin/tcpdump/nfsfh.h index 5d6ff780203..ccbbd575275 100644 --- a/usr.sbin/tcpdump/nfsfh.h +++ b/usr.sbin/tcpdump/nfsfh.h @@ -1,3 +1,4 @@ +/* $OpenBSD: nfsfh.h,v 1.2 1996/03/04 15:59:10 mickey Exp $ */ /* $NetBSD: nfsfh.h,v 1.2 1995/03/06 19:10:39 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/nfsv2.h b/usr.sbin/tcpdump/nfsv2.h index e8cdba97dca..1df599fc1a0 100644 --- a/usr.sbin/tcpdump/nfsv2.h +++ b/usr.sbin/tcpdump/nfsv2.h @@ -1,3 +1,4 @@ +/* $OpenBSD: nfsv2.h,v 1.2 1996/03/04 15:59:11 mickey Exp $ */ /* $NetBSD: nfsv2.h,v 1.2 1995/03/06 19:10:40 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/ntp.h b/usr.sbin/tcpdump/ntp.h index 7443ce6e80c..a5442c4d9de 100644 --- a/usr.sbin/tcpdump/ntp.h +++ b/usr.sbin/tcpdump/ntp.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ntp.h,v 1.2 1996/03/04 15:59:11 mickey Exp $ */ /* $NetBSD: ntp.h,v 1.2 1995/03/06 19:10:41 mycroft Exp $ */ /* Header: ntp.h,v 1.2 93/11/12 21:43:36 mccanne Exp */ diff --git a/usr.sbin/tcpdump/os.h b/usr.sbin/tcpdump/os.h index 9f807522041..06ade544d5d 100644 --- a/usr.sbin/tcpdump/os.h +++ b/usr.sbin/tcpdump/os.h @@ -1,3 +1,4 @@ +/* $OpenBSD: os.h,v 1.2 1996/03/04 15:59:12 mickey Exp $ */ /* $NetBSD: os.h,v 1.2 1995/03/06 19:10:56 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/ospf.h b/usr.sbin/tcpdump/ospf.h index 3a6d2b5632f..588cb9e4ac5 100644 --- a/usr.sbin/tcpdump/ospf.h +++ b/usr.sbin/tcpdump/ospf.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ospf.h,v 1.2 1996/03/04 15:59:13 mickey Exp $ */ /* $NetBSD: ospf.h,v 1.2 1995/03/06 19:10:57 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/packetdat.awk b/usr.sbin/tcpdump/packetdat.awk index 97746525f46..bbbf21f96db 100644 --- a/usr.sbin/tcpdump/packetdat.awk +++ b/usr.sbin/tcpdump/packetdat.awk @@ -1,3 +1,4 @@ +# $OpenBSD: packetdat.awk,v 1.2 1996/03/04 15:59:15 mickey Exp $ # $NetBSD: packetdat.awk,v 1.2 1995/03/06 19:10:59 mycroft Exp $ BEGIN { diff --git a/usr.sbin/tcpdump/parsenfsfh.c b/usr.sbin/tcpdump/parsenfsfh.c index bff083088d9..bdebc3f5346 100644 --- a/usr.sbin/tcpdump/parsenfsfh.c +++ b/usr.sbin/tcpdump/parsenfsfh.c @@ -1,3 +1,4 @@ +/* $OpenBSD: parsenfsfh.c,v 1.2 1996/03/04 15:59:15 mickey Exp $ */ /* $NetBSD: parsenfsfh.c,v 1.2 1995/03/06 19:11:00 mycroft Exp $ */ #ifndef lint diff --git a/usr.sbin/tcpdump/print-arp.c b/usr.sbin/tcpdump/print-arp.c index f9636a66282..96848072596 100644 --- a/usr.sbin/tcpdump/print-arp.c +++ b/usr.sbin/tcpdump/print-arp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-arp.c,v 1.2 1996/03/04 15:59:16 mickey Exp $ */ /* $NetBSD: print-arp.c,v 1.2 1995/03/06 19:11:02 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c index 89807fa7257..dd8afd26757 100644 --- a/usr.sbin/tcpdump/print-atalk.c +++ b/usr.sbin/tcpdump/print-atalk.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-atalk.c,v 1.2 1996/03/04 15:59:17 mickey Exp $ */ /* $NetBSD: print-atalk.c,v 1.3 1995/03/06 19:11:04 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-bootp.c b/usr.sbin/tcpdump/print-bootp.c index 2e641419222..13903965e2a 100644 --- a/usr.sbin/tcpdump/print-bootp.c +++ b/usr.sbin/tcpdump/print-bootp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-bootp.c,v 1.2 1996/03/04 15:59:18 mickey Exp $ */ /* $NetBSD: print-bootp.c,v 1.2 1995/03/06 19:11:05 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-decnet.c b/usr.sbin/tcpdump/print-decnet.c index 2e0a419cea5..018618c7e4d 100644 --- a/usr.sbin/tcpdump/print-decnet.c +++ b/usr.sbin/tcpdump/print-decnet.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-decnet.c,v 1.2 1996/03/04 15:59:20 mickey Exp $ */ /* $NetBSD: print-decnet.c,v 1.2 1995/03/06 19:11:07 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-domain.c b/usr.sbin/tcpdump/print-domain.c index bc2cab3db3e..589741481d9 100644 --- a/usr.sbin/tcpdump/print-domain.c +++ b/usr.sbin/tcpdump/print-domain.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-domain.c,v 1.2 1996/03/04 15:59:21 mickey Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. diff --git a/usr.sbin/tcpdump/print-egp.c b/usr.sbin/tcpdump/print-egp.c index 97fc2c3818f..6135ce7d8da 100644 --- a/usr.sbin/tcpdump/print-egp.c +++ b/usr.sbin/tcpdump/print-egp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-egp.c,v 1.2 1996/03/04 15:59:22 mickey Exp $ */ /* $NetBSD: print-egp.c,v 1.2 1995/03/06 19:11:09 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ether.c b/usr.sbin/tcpdump/print-ether.c index d32ceca2213..4d3c5490524 100644 --- a/usr.sbin/tcpdump/print-ether.c +++ b/usr.sbin/tcpdump/print-ether.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-ether.c,v 1.2 1996/03/04 15:59:23 mickey Exp $ */ /* $NetBSD: print-ether.c,v 1.3 1995/03/06 19:11:10 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-fddi.c b/usr.sbin/tcpdump/print-fddi.c index 0d5c0501ccc..9aedc6d2079 100644 --- a/usr.sbin/tcpdump/print-fddi.c +++ b/usr.sbin/tcpdump/print-fddi.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-fddi.c,v 1.2 1996/03/04 15:59:24 mickey Exp $ */ /* $NetBSD: print-fddi.c,v 1.2 1995/03/06 19:11:12 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-icmp.c b/usr.sbin/tcpdump/print-icmp.c index e4154315b4c..202d1be30bd 100644 --- a/usr.sbin/tcpdump/print-icmp.c +++ b/usr.sbin/tcpdump/print-icmp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-icmp.c,v 1.2 1996/03/04 15:59:25 mickey Exp $ */ /* $NetBSD: print-icmp.c,v 1.3 1995/03/06 19:11:13 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index 4c43bcf32fa..ddb10cfcb03 100644 --- a/usr.sbin/tcpdump/print-ip.c +++ b/usr.sbin/tcpdump/print-ip.c @@ -1,4 +1,5 @@ -/* $NetBSD: print-ip.c,v 1.4 1995/04/24 13:27:43 cgd Exp $ */ +/* $OpenBSD: print-ip.c,v 1.2 1996/03/04 15:59:26 mickey Exp $ */ +/* $NetBSD: print-ip.c,v 1.4 1995/04/24 13:27:43 cgd Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -21,9 +22,33 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* + * Copyright (c) 1995 Sun Microsystems, Inc. + * All rights reserved. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + + * IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * SUN MICROSYSTEMS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + + * SUN MICROSYSTEMS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. + * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND SUN + * MICROSYSTEMS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, + * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +*/ + #ifndef lint static char rcsid[] = - "@(#) Header: print-ip.c,v 1.38 94/06/14 20:17:40 leres Exp (LBL)"; + "@(#) Header: print-ip.c,v 1.38 94/06/14 20:17:40 leres Exp $ (LBL)"; #endif #include @@ -305,6 +330,31 @@ ip_print(register const u_char *bp, register int length) return; } break; +#ifndef IPPROTO_SKIP_OLD +#define IPPROTO_SKIP_OLD 79 +#endif + case IPPROTO_SKIP_OLD: + skip_print_old(cp, len, (const u_char *) ip); + break; +#ifndef IPPROTO_ESP +#define IPPROTO_ESP 50 +#endif + case IPPROTO_ESP: + esp_print(cp, len, (const u_char *) ip); + break; +#ifndef IPPROTO_AH +#define IPPROTO_AH 51 +#endif + case IPPROTO_AH: + ah_print(cp, len, (const u_char *) ip); + break; + +#ifndef IPPROTO_SKIP +#define IPPROTO_SKIP 57 +#endif + case IPPROTO_SKIP: + skip_print(cp, len, (const u_char *) ip); + break; default: (void)printf("%s > %s:", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); diff --git a/usr.sbin/tcpdump/print-ipx.c b/usr.sbin/tcpdump/print-ipx.c index 7872e6a6554..e90061692ab 100644 --- a/usr.sbin/tcpdump/print-ipx.c +++ b/usr.sbin/tcpdump/print-ipx.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-ipx.c,v 1.2 1996/03/04 15:59:27 mickey Exp $ */ /* $NetBSD: print-ipx.c,v 1.2 1995/03/06 19:11:16 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-isoclns.c b/usr.sbin/tcpdump/print-isoclns.c index 670ecaf7c72..7153e7473d5 100644 --- a/usr.sbin/tcpdump/print-isoclns.c +++ b/usr.sbin/tcpdump/print-isoclns.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-isoclns.c,v 1.2 1996/03/04 15:59:28 mickey Exp $ */ /* $NetBSD: print-isoclns.c,v 1.2 1995/03/06 19:11:17 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-llc.c b/usr.sbin/tcpdump/print-llc.c index a6c036620d2..b5b3150c66b 100644 --- a/usr.sbin/tcpdump/print-llc.c +++ b/usr.sbin/tcpdump/print-llc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-llc.c,v 1.2 1996/03/04 15:59:29 mickey Exp $ */ /* $NetBSD: print-llc.c,v 1.2 1995/03/06 19:11:19 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-nfs.c b/usr.sbin/tcpdump/print-nfs.c index 5ba11d9e989..419e097f881 100644 --- a/usr.sbin/tcpdump/print-nfs.c +++ b/usr.sbin/tcpdump/print-nfs.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-nfs.c,v 1.2 1996/03/04 15:59:30 mickey Exp $ */ /* $NetBSD: print-nfs.c,v 1.4 1995/04/24 13:27:45 cgd Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ntp.c b/usr.sbin/tcpdump/print-ntp.c index ed92f695224..9a7e8267809 100644 --- a/usr.sbin/tcpdump/print-ntp.c +++ b/usr.sbin/tcpdump/print-ntp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-ntp.c,v 1.2 1996/03/04 15:59:31 mickey Exp $ */ /* $NetBSD: print-ntp.c,v 1.2 1995/03/06 19:11:22 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-null.c b/usr.sbin/tcpdump/print-null.c index 69a34566897..bb56f295d61 100644 --- a/usr.sbin/tcpdump/print-null.c +++ b/usr.sbin/tcpdump/print-null.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-null.c,v 1.2 1996/03/04 15:59:32 mickey Exp $ */ /* $NetBSD: print-null.c,v 1.3 1995/03/06 19:11:24 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ospf.c b/usr.sbin/tcpdump/print-ospf.c index 90ffecf9dd7..0e5e0b91d90 100644 --- a/usr.sbin/tcpdump/print-ospf.c +++ b/usr.sbin/tcpdump/print-ospf.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-ospf.c,v 1.2 1996/03/04 15:59:33 mickey Exp $ */ /* $NetBSD: print-ospf.c,v 1.3 1995/03/06 19:11:25 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ppp.c b/usr.sbin/tcpdump/print-ppp.c index 966e9f58782..e7eb95f6c2e 100644 --- a/usr.sbin/tcpdump/print-ppp.c +++ b/usr.sbin/tcpdump/print-ppp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-ppp.c,v 1.2 1996/03/04 15:59:34 mickey Exp $ */ /* $NetBSD: print-ppp.c,v 1.3 1995/03/06 19:11:27 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-rip.c b/usr.sbin/tcpdump/print-rip.c index 1be9c9dae12..f2ef5069c1f 100644 --- a/usr.sbin/tcpdump/print-rip.c +++ b/usr.sbin/tcpdump/print-rip.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-rip.c,v 1.2 1996/03/04 15:59:35 mickey Exp $ */ /* $NetBSD: print-rip.c,v 1.4 1995/06/20 23:38:49 christos Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-skip.c b/usr.sbin/tcpdump/print-skip.c new file mode 100644 index 00000000000..74db84676bc --- /dev/null +++ b/usr.sbin/tcpdump/print-skip.c @@ -0,0 +1,919 @@ +/* $OpenBSD: print-skip.c,v 1.1 1996/03/04 15:59:35 mickey Exp $ */ +/* + * Copyright (c) 1995 Sun Microsystems, Inc. + * All rights reserved. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + + * IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * SUN MICROSYSTEMS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + + * SUN MICROSYSTEMS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. + * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND SUN + * MICROSYSTEMS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, + * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "interface.h" +#include "addrtoname.h" + +#define MAX_ALGS (256) + +extern int skipflag; + +const int skip_max_algs = MAX_ALGS; + +char *old_skip_crypt_algs[MAX_ALGS] = { + "none", /* 0 */ + "des_cbc", /* 1 */ + "rc2_cbc", /* 2 */ + "rc4(40bit)", /* 3 */ + "rc4(128bit)", /* 4 */ + "des_ede-2", /* 5 */ + "des_ede-3", /* 6 */ + "idea", /* 7 */ + "", /* 8 */ + "", /* 9 */ + "simplecrypt" /* 10 */ + }; + + +char * +skip_alg_to_name(char *table[], int alg) +{ + if (alg > skip_max_algs) { + return (""); + } + if (alg < 0) { + return (""); + } + if (table[alg] == NULL) { + return (""); + } + if (strlen(table[alg]) == 0) { + return (""); + } + return (table[alg]); +} + +/* + * This is what an OLD skip encrypted-authenticated packet looks like: + * + * + * 0 1 2 3 + * --------------------------------- + * | | + * / Clear IP Header / + * | | IP protocol = IPSP + * --------------------------------- + * | | + * | IPSP header | + * | | + * --------------------------------- + * | | + * / Protected IPSP Payload / + * / / + * | | + * --------------------------------- + * + * + * The format of the IPSP header for encrypted-encapsulated mode is shown below. * The fields are transmitted from left to right. + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Ver. |E|A|C|S|B|R| zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Kij alg. | Kp alg. | reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Optional boxid field | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Kp encrypted in Kij... (typically 8-16 bytes) + * +-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Message Indicator (e.g IV)... (typically 8-16 bytes) + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Protected IPSP Payload... + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * + * Field values: + * Ver.: protocol version + * E: 1 if packet is encrypted, 0 otherwise + * A: 1 if packet is authenticated, 0 otherwise + * C: 1 if packet is compressed before encryption, 0 otherwise + * S: 1 if packet is sequenced, 0 otherwise + * B: 1 if packet is tunneled (header contains boxid), 0 otherwise + * R: reserved (should be 0 until specified) + * + */ +/* + * per-algorithm encrytped key sizes... + */ +unsigned char old_skip_ekp_sizes[MAX_ALGS] = { + 8, /* plaintext */ + 8, /* DES */ + 8, /* RC2 */ + 8, /* RC4 (40 bit) */ + 16, /* RC4 (128 bit) */ + 16, /* 3DES 2 */ + 24, /* 3DES 3 */ + 16, /* IDEA */ + 0, /* */ + 0, /* */ + 8, /* simplecrypt */ + }; +/* + * per-algorithm message indicator sizes... + */ +unsigned char old_skip_mid_sizes[MAX_ALGS] = { + 8, /* plaintext */ + 8, /* DES */ + 8, /* RC2 */ + 8, /* RC4 40 bit */ + 8, /* RC4 128 bit */ + 8, /* 3DES 2 */ + 8, /* 3DES 3 */ + 8, /* IDEA */ + 0, /* */ + 0, /* */ + 8, /* simplecrypt */ + }; + +void skip_print_old(register const u_char *bp, register int length, + const u_char *bp2) +{ + struct ip *ip; + const u_char *end; + u_char *p; + unsigned char kij_alg, kp_alg, *c; + unsigned short i; + unsigned short len; + int boxid; + int node; + + ip=(struct ip *)bp2; + p=(u_char *)bp; + end=bp+length; + printf("SKIP: *** OLD SKIP ***\n"); + printf("OSKIP: %s>%s:%d",ipaddr_string(&ip->ip_src), + ipaddr_string(&ip->ip_dst),length); + if (!skipflag) + return; + printf("\nOSKIP: SAID byte 1= 0x%02x\n",*p); + printf("OSKIP: xxxx .... = version %d\n", (int) (*p & 0xf0) >> 4); + if (*p & 0x08) { + printf("OSKIP: .... 1... = encrypted\n"); + } else { + printf("OSKIP: .... 0... = not encrypted\n"); + } + + if (*p & 0x04) { + printf("OSKIP: .... .1.. = authenticated\n"); + } else { + printf("OSKIP: .... .0.. = not authenticated\n"); + } + + if (*p & 0x02) { + printf("OSKIP: .... ..1. = compressed\n"); + } else { + printf("OSKIP: .... ..0. = not compressed\n"); + } + + if (*p & 0x01) { + printf("OSKIP: .... ...1 = sequenced\n"); + } else { + printf("OSKIP: .... ...0 = not sequenced\n"); + } + + p++; + + printf("OSKIP: SAID byte 2 = 0x%02x\n", *p); + + if (*p & 0x80) { + node=1; + printf("OSKIP: 1... .... = Node ID present\n"); + } else { + node=0; + printf("OSKIP: 0... .... = no Node ID present\n"); + } + + if (*p & 0x40) { + printf("OSKIP: .1.. .... = \n"); + } else { + printf("OSKIP: .0.. .... = \n"); + } + + if (*p & 0x20) { + printf("OSKIP: ..1. .... = \n"); + } else { + printf("OSKIP: ..0. .... = \n"); + } + + if (*p & 0x10) { + printf("OSKIP: ...1 .... = \n"); + } else { + printf("OSKIP: ...0 .... = \n"); + } + p++; + printf("OSKIP: SAID byte 3 = 0x%02x\n", *p); + + p++; + printf("OSKIP: SAID byte 4 = 0x%02x\n", *p); + + p++; + + kij_alg = *p; + printf("OSKIP: Kij alg (key encryption algorithm) = 0x%02x (%s)\n", + kij_alg, skip_alg_to_name(old_skip_crypt_algs,kij_alg)); + + p++; + + kp_alg = *p; + printf("OSKIP: Kp alg (traffic encryption algorithm) = 0x%02x (%s)\n", + kp_alg, skip_alg_to_name(old_skip_crypt_algs,kp_alg)); + + p++; + + /* + * the skip reserved field + */ + printf("OSKIP: reserved byte 1 = 0x%02x\n", *p++); + printf("OSKIP: reserved byte 2 = 0x%02x\n", *p++); + + if (node) { + /* + * boxid field + */ + if ((end - p) < sizeof(boxid)) { + return; + } + c = (unsigned char *) &boxid; + *c++ = *p++; + *c++ = *p++; + *c++ = *p++; + *c++ = *p++; + + printf("OSKIP: Node ID = 0x%08x\n", ntohl(boxid)); + } + + /* + * encrypted kp (ekp) field + */ + + /* + * do this with a for-loop to avoid alignment problems and the + * overhead of calling bcopy() + */ + len = old_skip_ekp_sizes[kp_alg]; + if ((unsigned short) (end - p) < len) { + return; + } + + printf("OSKIP: encrypted Kp: "); + for (i = 0; i < len; i++) { + printf("%02x ", (unsigned char) *p++); + } + printf("\n"); + + /* + * message indicator (mid) field + */ + len = old_skip_mid_sizes[kp_alg]; + if ((unsigned short) (end - p) < len) { + return; + } + printf("OSKIP: message indicator field: "); + for (i = 0; i < len; i++) { + printf("%02x ", (unsigned char) *p++); + } + printf("\n"); +} + + + +/* + * The following part is (c) by G. Caronni -- 29.11.95 + * + * This code is in the public domain; do with it what you wish. + * + * NO WARRANTY, NO SUPPORT, NO NOTHING! + */ + + +/* + * This is what a NEW skip encrypted-authenticated packet looks like: + * + * + * 0 1 2 3 + * --------------------------------- + * | | + * / Clear IP Header / + * | | IP protocol = SKIP + * --------------------------------- + * | | + * | SKIP header | + * | | + * --------------------------------- + * | | + * | Auth Header & payload | + * | | + * --------------------------------- + * | | + * | ESP header and SPI | + * | | + * --------------------------------- + * | | + * / Protected ESP Payload / + * | | + * --------------------------------- + * + * + * The format of the SKIP header for encrypted-encapsulated mode is shown below. * The fields are transmitted from left to right. + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Ver | Rsvd | Source NSID | Dest NSID | NEXT HEADER | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Counter n | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Kij Alg | Crypt Alg | MAC Alg | Comp Alg | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Kp encrypted in Kijn... (typically 8-16 bytes) + * +-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Source Master Key-ID (If Source NSID is non-zero) + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Destination Master Key-ID (If Dest NSID is non-zero) + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + + + + +/* + * per name space key ID sizes... + */ +unsigned char skip_nsid_sizes[MAX_ALGS] = { + 0, /* 0 none */ + 4, /* 1 IP v4 Address Space */ + 4, /* 2 POSIX/XOPEN User Ids */ + 16, /* 3 IPv6 Address Space */ + 16, /* 4 MD5 of DNS Names */ + 16, /* 5 MD5 of ISO ASN.1 DN encoding */ + 16, /* 6 MD5 of US Social Security number */ + 6, /* 7 802.x MAC Address */ + 16, /* 8 MD5 of public Value */ + 16, /* 9 MD5 of RFC822 Mailbox Address */ + 16, /* 10 MD5 of Bank Account # */ + 16, /* 11 MD5 of NIS Name */ + }; + + +/* + * per Kp algorithm encrypted Kp sizes... (Kij alg does not matter for now) + */ +unsigned char skip_ekp_sizes[MAX_ALGS] = { + 0, /* 0 plaintext */ + 8, /* 1 DES_CBC */ + 24, /* 2 3 key triple DES-EDE-CBC */ + 0, /* 3 */ + 0, /* 4 */ + 0, /* 5 */ + 0, /* 6 */ + 0, /* 7 */ + 0, /* 8 */ + 0, /* 9 */ /* 10 .. 249 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 8, /* 250 RC4-40 */ + 16, /* 251 RC4-128 */ + 8, /* 252 simple crypt */ + 16, /* 253 IDEA */ + 0, /* 254 */ + 0 /* 255 */ + }; + + +/* + * per-algorithm NSID names ... + */ +char *skip_nsid_names[MAX_ALGS] = { + "none", /* 0 */ + "IPv4", /* 1 */ + "Posix/Xopen UID", /* 2 */ + "IPv6", /* 3 */ + "MD5 DNS", /* 4 */ + "MD5 ASN.1 DN", /* 5 */ + "MD5 U.S. Soc. #", /* 6 */ + "802.x MAC", /* 7 */ + "MD5 DH Public Key",/* 8 */ + "MD5 RFC822 Mail", /* 9 */ + "MD5 Bank Account", /* 10 */ + "MD5 NIS Name", /* 11 */ + }; + + +/* + * per-algorithm Kij alg names ... + */ +char *skip_kij_names[MAX_ALGS] = { + "none", /* 0 */ + "DES-CBC", /* 1 */ + "3DES3-EDE-CBC", /* 2 */ + "IDEA-CBC", /* 3 */ + }; + + +/* for padding of ekp */ + +char skip_kij_sizes[MAX_ALGS] = { + 0, /* 0 none */ + 8, /* 1 des-cbc */ + 8, /* 2 3des3-ede-cbc */ + 8, /* 3 idea-cbc */ + }; + + +/* + * per-algorithm Crypt alg names ... + */ +char *skip_crypt_names[MAX_ALGS] = { + "none", /* 0 */ + "DES-CBC", /* 1 */ + "3 key DES-EDE-CBC", /* 2 */ + "", /* 3 */ + "", /* 4 */ + "", /* 5 */ + "", /* 6 */ + "", /* 7 */ + "", /* 8 */ + "", /* 9 */ /* 10 .. 249 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + "RC4-40", /* 250 */ + "RC4-128", /* 251 */ + "simple crypt", /* 252 */ + "IDEA CBC", /* 253 */ + "", /* 254 */ + "" /* 255 */ + }; + + +/* + * per-algorithm Auth alg names ... + */ +char *skip_auth_names[MAX_ALGS] = { + "none", /* 0 */ + "keyed MD5", /* 1 */ + "DES-CBC MAC", /* 2 */ + "Keyed SHA", /* 3 */ + }; + + +char skip_auth_sizes[MAX_ALGS] = { + 0, /* 0 none */ + 16, /* 1 keyed MD5 */ + 8, /* 2 DES-CBC MAC */ + 20, /* 3 Keyed SHA */ + }; + + +/* + * per-algorithm Crypt alg IV sizes ... + */ +char skip_crypt_sizes[MAX_ALGS] = { + 0, /* 0 none */ + 8, /* 1 DES-CBC */ + 8, /* 2 3key DES-EDE-CBC */ + 0, /* 3 */ + 0, /* 4 */ + 0, /* 5 */ + 0, /* 6 */ + 0, /* 7 */ + 0, /* 8 */ + 0, /* 9 */ /* 10 .. 249 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 8, /* 250 RC4-40 */ + 8, /* 251 RC4-128 */ + 8, /* 252 simple crypt */ + 8, /* 253 IDEA CBC */ + 0, /* 254 */ + 0 /* 255 */ + }; + + +#ifndef IPPROTO_ESP +#define IPPROTO_ESP 50 +#endif +#ifndef IPPROTO_AH +#define IPPROTO_AH 51 +#endif +#ifndef IPPROTO_SKIP +#define IPPROTO_SKIP 57 +#endif +#ifndef IPPROTO_OSKIP +#define IPPROTO_OSKIP 79 +#endif + +static int expected_auth_size=0; +static int expected_iv_size=0; + +char *skip_protocol_name(int p) +{ + switch(p) { + case IPPROTO_IP: return "IP"; + case IPPROTO_ICMP: return "ICMP"; + case IPPROTO_IGMP: return "IGMP"; + case IPPROTO_ENCAP: return "ENCAP"; + case IPPROTO_TCP: return "TCP"; + case IPPROTO_EGP: return "EGP"; + case IPPROTO_UDP: return "UDP"; + case IPPROTO_ESP: return "ESP"; + case IPPROTO_AH: return "AH"; + case IPPROTO_SKIP: return "SKIP"; + case IPPROTO_ND: return "ND"; + case IPPROTO_OSKIP: return "OLD-SKIP"; + case IPPROTO_RAW: return "RAW IP"; + default: return ""; + } +} + +void skip_print_next(u_char nxt, const u_char *p, int len, const u_char *bp2) +{ + switch(nxt) { + case IPPROTO_IP: ip_print(p,len); break; + case IPPROTO_ICMP: icmp_print(p,bp2); break; + case IPPROTO_TCP: tcp_print(p,len,bp2); break; + case IPPROTO_UDP: udp_print(p,len,bp2); break; + case IPPROTO_ESP: esp_print(p,len,bp2); break; + case IPPROTO_AH: ah_print(p,len,bp2); break; + case IPPROTO_SKIP: skip_print(p,len,bp2); break; + default: break; + } +} + +void skip_print(register const u_char *bp, register int length, + const u_char *bp2) +{ + struct ip *ip; + const u_char *end; + const u_char *p; + unsigned char kij_alg, crypt_alg, auth_alg, snsid, dnsid, nxt; + unsigned short i; + unsigned short len; + u_int n; + time_t full_n; + + ip=(struct ip *)bp2; + p=bp; + end=bp+length%s:%d SKIP",ipaddr_string(&ip->ip_src), + ipaddr_string(&ip->ip_dst),length); + if (!skipflag) + return; + + + if ((unsigned short) (end - p) < 4) { + printf("[SKIP|] (truncated)\n"); + return; + } + + printf("\nSKIP: version\t\t\t%d\n", (int) (*p & 0xf0) >> 4); + if (*p & 0xf) + printf("SKIP: version byte \t\treserved,\tis now 0x%x\n", + (int) (*p & 0xf)); + p++; + + snsid = *p; + printf("SKIP: Source NSID\t\t0x%02x\t\t%s\n", + snsid, skip_alg_to_name(skip_nsid_names,snsid)); + p++; + + dnsid = *p; + printf("SKIP: Destination NSID\t\t0x%02x\t\t%s\n", + dnsid, skip_alg_to_name(skip_nsid_names,dnsid)); + p++; + + nxt = *p; + printf("SKIP: Next Protocol Field\t0x%02x\t\t%s\n", nxt, + skip_protocol_name(nxt)); + + p++; + + if ((unsigned short) (end - p) < 4) { + printf("[SKIP|] (truncated)\n"); + return; + } + + n=*p++<<24; + n+=*p++<<16; + n+=*p++<<8; + n+=*p; + full_n=(((365*25+6)*24)+n)*3600; + printf("SKIP: Counter n Field\t\t0x%08x\t%s", n, + asctime(gmtime(&full_n))); + p++; + + if ((unsigned short) (end - p) < 4) { + printf("[SKIP|] (truncated)\n"); + return; + } + + kij_alg = *p; + printf("SKIP: Kij alg (key encryption)\t0x%02x\t\t%s\n", + kij_alg, skip_alg_to_name(skip_kij_names,kij_alg)); + p++; + + crypt_alg = *p; + expected_iv_size=skip_crypt_sizes[crypt_alg]; + printf("SKIP: Crypt Alg\t\t\t0x%02x\t\t%s\n", + crypt_alg, skip_alg_to_name(skip_crypt_names,crypt_alg)); + p++; + + auth_alg = *p; + expected_auth_size=skip_auth_sizes[auth_alg]; + printf("SKIP: Auth Alg\t\t\t0x%02x\t\t%s\n", + auth_alg, skip_alg_to_name(skip_auth_names,auth_alg)); + p++; + + if (*p) printf("SKIP: compression\t\treserved,\tis now0x%02x\n", + (int) *p++); + else p++; + + /* + * encrypted kp (ekp) field + */ + + if (kij_alg==0 && (crypt_alg || auth_alg)) { + printf("Warning: Kij Alg. undefined, but Auth. or Crypt. used!"); + printf("Warning: Assuming empty Kp\n"); + crypt_alg=auth_alg=0; + } + /* + * do this with a for-loop to avoid alignment problems and the + * overhead of calling bcopy() + */ + len = skip_ekp_sizes[crypt_alg]; + len = len>(int)skip_auth_sizes[auth_alg]?len:skip_auth_sizes[auth_alg]; + if (len && skip_kij_sizes[kij_alg] && len % skip_kij_sizes[kij_alg]) { + len += skip_kij_sizes[kij_alg] - (len%skip_kij_sizes[kij_alg]); + } + if ((unsigned short) (end - p) < len) { + printf("[SKIP|] (truncated)\n"); + return; + } + + printf("SKIP: Encrypted Kp\t\t"); + for (i = 0; i < len; i++) { + printf("%02x ", (unsigned char) *p++); + } + printf("\n"); + + + if (snsid) { + /* + * Source Master Key-ID field + */ + if ((end - p) < skip_nsid_sizes[snsid]) { + printf("[SKIP|] (truncated)\n"); + return; + } + printf("SKIP: Source Master Key-ID\t"); + if (snsid==1) { + printf("%s",ipaddr_string(p)); + p+=skip_nsid_sizes[snsid]; + } else { + for (i = 0; i < skip_nsid_sizes[snsid]; i++) { + printf("%02x ", (unsigned char) *p++); + } + } + printf("\n"); + } + + if (dnsid) { + /* + * Destination Master Key-ID field + */ + if ((end - p) < skip_nsid_sizes[dnsid]) { + printf("[SKIP|] (truncated)\n"); + return; + } + printf("SKIP: Dest. Master Key-ID\t"); + if (dnsid==1) { + printf("%s",ipaddr_string(p)); + p+=skip_nsid_sizes[dnsid]; + } else { + for (i = 0; i < skip_nsid_sizes[dnsid]; i++) { + printf("%02x ", (unsigned char) *p++); + } + } + printf("\n"); + } + if (p%s:%d",ipaddr_string(&ip->ip_src), + ipaddr_string(&ip->ip_dst),length); + if (!skipflag) + return; + + if (end-p <4) { + printf("[SKIP-AH|]\n"); + return; + } + + nxt = *p; + printf("\nSKIP-AH: Next Protocol Field\t0x%02x\t\t%s\n", nxt, + skip_protocol_name(nxt)); + p++; + + len= 4 * (int) *p; + printf("SKIP-AH: length\t\t\t%d\n", len); + + p++; + + if (*p) printf("SKIP-AH: byte 3\t\t\treserved,\tis now0x%02x\n", + (int) *p++); + else p++; + if (*p) printf("SKIP-AH: byte 4\t\t\treserved,\tis now0x%02x\n", + (int) *p++); + else p++; + + if (end-p <4) { + printf("[SKIP-AH|]\n"); + return; + } + + spi=*p++<<24; + spi+=*p++<<16; + spi+=*p++<<8; + spi+=*p; + printf("SKIP-AH: SPI\t\t\t0x%08x\t", spi ); + if (spi==0) { + printf("NO association\n"); + } else if (spi==1) { + printf("SKIP association\n"); + if (expected_auth_size) { + if (expected_auth_size != len) { + printf("Warning: Length does not match SKIP Auth Alg!\n"); + } + expected_auth_size=0; + } + } else if (spi<256) { + printf("UNKNOWN association\n"); + } else { + printf("DYNAMIC association\n"); + } + + p++; + + + /* + * authentication data + */ + + if ((unsigned short) (end - p) < len) { + printf("[SKIP-AH|] (truncated)\n"); + return; + } + + printf("SKIP-AH: Authentication Data\t"); + for (i = 0; i < len; i++) { + printf("%02x ", (unsigned char) *p++); + if (i%s:%d",ipaddr_string(&ip->ip_src), + ipaddr_string(&ip->ip_dst),length); + if (!skipflag) + return; + + if (end-p <4) { + printf("[SKIP-ESP|]\n"); + } + + spi=*p++<<24; + spi+=*p++<<16; + spi+=*p++<<8; + spi+=*p; + printf("\nSKIP-ESP: SPI\t\t\t0x%08x\t", spi ); + if (spi==0) { + printf("NO association\n"); + len=0; + } else if (spi==1) { + printf("SKIP association\n"); + len=expected_iv_size; + if (!expected_iv_size) { + printf("Warning: IV size not defined by SKIP Crypt Alg!\n"); + } else expected_iv_size=0; + } else if (spi<256) { + printf("UNKNOWN association\n"); + len=0; + } else { + printf("DYNAMIC association\n"); + len=0; + } + + p++; + + /* + * IV data + */ + + if ((unsigned short) (end - p) < len) { + printf("[SKIP-ESP|] (truncated)\n"); + return; + } + + printf("SKIP-ESP: Initalization Vector\t"); + if (len) { + for (i = 0; i < len; i++) { + printf("%02x ", (unsigned char) *p++); + if (iip_p; + lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p; hlen = ip->ip_hl; hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off; lastlen[dir][lastconn] = length - (hlen << 2); diff --git a/usr.sbin/tcpdump/print-snmp.c b/usr.sbin/tcpdump/print-snmp.c index 87bda376ab3..e414fb1dfd1 100644 --- a/usr.sbin/tcpdump/print-snmp.c +++ b/usr.sbin/tcpdump/print-snmp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-snmp.c,v 1.2 1996/03/04 15:59:37 mickey Exp $ */ /* $NetBSD: print-snmp.c,v 1.3 1995/03/06 19:11:30 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-sunrpc.c b/usr.sbin/tcpdump/print-sunrpc.c index d3e23a334c6..d0d32a72378 100644 --- a/usr.sbin/tcpdump/print-sunrpc.c +++ b/usr.sbin/tcpdump/print-sunrpc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-sunrpc.c,v 1.2 1996/03/04 15:59:39 mickey Exp $ */ /* $NetBSD: print-sunrpc.c,v 1.3 1995/03/06 19:11:32 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c index 50545d19867..f658dc35fcf 100644 --- a/usr.sbin/tcpdump/print-tcp.c +++ b/usr.sbin/tcpdump/print-tcp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-tcp.c,v 1.2 1996/03/04 15:59:39 mickey Exp $ */ /* $NetBSD: print-tcp.c,v 1.5 1995/03/06 19:11:33 mycroft Exp $ */ /* @@ -92,7 +93,7 @@ tcp_print(register const u_char *bp, register int length, register u_char flags; register int hlen; u_short sport, dport, win, urp; - tcp_seq seq, ack; + u_int32 seq, ack; tp = (struct tcphdr *)bp; ip = (struct ip *)bp2; @@ -180,7 +181,7 @@ tcp_print(register const u_char *bp, register int length, hlen = tp->th_off * 4; length -= hlen; if (length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) - (void)printf(" %lu:%lu(%d)", seq, seq + length, length); + (void)printf(" %u:%u(%d)", seq, seq + length, length); if (flags & TH_ACK) (void)printf(" ack %u", ack); diff --git a/usr.sbin/tcpdump/print-tftp.c b/usr.sbin/tcpdump/print-tftp.c index a1938321728..1c84102e4e2 100644 --- a/usr.sbin/tcpdump/print-tftp.c +++ b/usr.sbin/tcpdump/print-tftp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-tftp.c,v 1.2 1996/03/04 15:59:40 mickey Exp $ */ /* $NetBSD: print-tftp.c,v 1.2 1995/03/06 19:11:35 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index 4758c9da601..084c514fab4 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-udp.c,v 1.2 1996/03/04 15:59:41 mickey Exp $ */ /* $NetBSD: print-udp.c,v 1.3 1995/03/06 19:11:36 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-wb.c b/usr.sbin/tcpdump/print-wb.c index ac7d6823e1d..0af30448698 100644 --- a/usr.sbin/tcpdump/print-wb.c +++ b/usr.sbin/tcpdump/print-wb.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print-wb.c,v 1.2 1996/03/04 15:59:42 mickey Exp $ */ /* $NetBSD: print-wb.c,v 1.2 1995/03/06 19:11:37 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/send-ack.awk b/usr.sbin/tcpdump/send-ack.awk index 1f98e50322e..8eb234c161b 100644 --- a/usr.sbin/tcpdump/send-ack.awk +++ b/usr.sbin/tcpdump/send-ack.awk @@ -1,3 +1,4 @@ +# $OpenBSD: send-ack.awk,v 1.2 1996/03/04 15:59:43 mickey Exp $ # $NetBSD: send-ack.awk,v 1.2 1995/03/06 19:11:42 mycroft Exp $ BEGIN { diff --git a/usr.sbin/tcpdump/stime.awk b/usr.sbin/tcpdump/stime.awk index d57968ed932..1faa8fff27a 100644 --- a/usr.sbin/tcpdump/stime.awk +++ b/usr.sbin/tcpdump/stime.awk @@ -1,3 +1,4 @@ +# $OpenBSD: stime.awk,v 1.2 1996/03/04 15:59:44 mickey Exp $ # $NetBSD: stime.awk,v 1.2 1995/03/06 19:11:43 mycroft Exp $ $6 !~ /^ack/ && $5 !~ /[SFR]/ { diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8 index 01879d3b2ce..9e4f20c7bd4 100644 --- a/usr.sbin/tcpdump/tcpdump.8 +++ b/usr.sbin/tcpdump/tcpdump.8 @@ -1,3 +1,4 @@ +.\" $OpenBSD: tcpdump.8,v 1.2 1996/03/04 15:59:45 mickey Exp $ .\" $NetBSD: tcpdump.8,v 1.3 1995/03/06 19:11:46 mycroft Exp $ .\" .\" @(#) Header: tcpdump.1,v 1.45 94/06/20 18:54:27 leres Exp (LBL) diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c index fc6b153c80a..db5ba53a932 100644 --- a/usr.sbin/tcpdump/tcpdump.c +++ b/usr.sbin/tcpdump/tcpdump.c @@ -1,3 +1,4 @@ +/* $OpenBSD: tcpdump.c,v 1.2 1996/03/04 15:59:46 mickey Exp $ */ /* $NetBSD: tcpdump.c,v 1.3 1995/04/24 13:27:48 cgd Exp $ */ /* @@ -20,11 +21,35 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ + +/* + * Copyright (c) 1995 Sun Microsystems, Inc. + * All rights reserved. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + + * IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * SUN MICROSYSTEMS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + + * SUN MICROSYSTEMS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. + * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND SUN + * MICROSYSTEMS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, + * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +*/ #ifndef lint char copyright[] = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994\nThe Regents of the University of California. All rights reserved.\n"; static char rcsid[] = - "@(#)Header: tcpdump.c,v 1.93 94/06/10 17:01:44 mccanne Exp (LBL)"; + "@(#)Header: tcpdump.c,v 1.93 94/06/10 17:01:44 mccanne Exp $ (LBL)"; #endif /* @@ -64,6 +89,7 @@ int xflag; /* print packet in hex */ int Oflag = 1; /* run filter code optimizer */ int Sflag; /* print raw TCP sequence numbers */ int packettype; +int skipflag; /* Print out SKIP packets */ int dflag; /* print filter code */ @@ -153,7 +179,7 @@ main(int argc, char **argv) program_name = argv[0]; opterr = 0; - while ((op = getopt(argc, argv, "c:defF:i:lnNOpqr:s:StT:vw:xY")) != EOF) + while ((op = getopt(argc, argv, "c:defF:i:klnNOpqr:s:StT:vw:xY")) != EOF) switch (op) { case 'c': cnt = atoi(optarg); @@ -179,6 +205,10 @@ main(int argc, char **argv) device = optarg; break; + case 'k': + skipflag++; + break; + case 'l': setlinebuf(stdout); break; @@ -323,7 +353,11 @@ main(int argc, char **argv) fprintf(stderr, "%s: listening on %s\n", program_name, device); fflush(stderr); } - pcap_loop(pd, cnt, printer, pcap_userdata); + if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) { + (void)fprintf(stderr, "%s: pcap_loop: %s\n", + program_name, pcap_geterr(pd)); + exit(1); + } pcap_close(pd); exit(0); } diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c index 2c456a85e27..105b6e4029f 100644 --- a/usr.sbin/tcpdump/util.c +++ b/usr.sbin/tcpdump/util.c @@ -1,3 +1,4 @@ +/* $OpenBSD: util.c,v 1.2 1996/03/04 15:59:47 mickey Exp $ */ /* $NetBSD: util.c,v 1.3 1995/03/06 19:11:53 mycroft Exp $ */ /* @@ -319,16 +320,22 @@ read_infile(char *fname) int gmt2local() { -#ifndef SOLARIS - struct timeval now; +#ifndef SVR4 + struct timeval tv; struct timezone tz; - long t; + register struct tm *tm; + register int t; - if (gettimeofday(&now, &tz) < 0) + if (gettimeofday(&tv, &tz) < 0) error("gettimeofday"); + tm = localtime((time_t *)&tv.tv_sec); +#ifndef SUNOS3 + t = tm->tm_gmtoff; +#else t = tz.tz_minuteswest * -60; - if (localtime((time_t *)&now.tv_sec)->tm_isdst) - t += 3600; + if (tm->tm_isdst) + t += 60 * 60; +#endif return (t); #else tzset(); diff --git a/usr.sbin/tcpdump/version.c b/usr.sbin/tcpdump/version.c index 33cc7ff833a..b24722badf2 100644 --- a/usr.sbin/tcpdump/version.c +++ b/usr.sbin/tcpdump/version.c @@ -1,3 +1,4 @@ +/* $OpenBSD: version.c,v 1.2 1996/03/04 15:59:48 mickey Exp $ */ /* $NetBSD: version.c,v 1.2 1995/03/06 19:11:56 mycroft Exp $ */ -char version[] = "3.0"; +char version[] = "3.0.2"; -- 2.20.1