summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/tcpdump/CHANGES73
-rw-r--r--usr.sbin/tcpdump/FILES94
-rw-r--r--usr.sbin/tcpdump/INSTALL36
-rw-r--r--usr.sbin/tcpdump/Makefile6
-rw-r--r--usr.sbin/tcpdump/Makefile.in145
-rw-r--r--usr.sbin/tcpdump/README51
-rw-r--r--usr.sbin/tcpdump/acsite.m4505
-rw-r--r--usr.sbin/tcpdump/addrtoname.c27
-rw-r--r--usr.sbin/tcpdump/addrtoname.h6
-rw-r--r--usr.sbin/tcpdump/gmt2local.c72
-rw-r--r--usr.sbin/tcpdump/gmt2local.h (renamed from usr.sbin/tcpdump/os-ultrix4.h)22
-rw-r--r--usr.sbin/tcpdump/interface.h8
-rw-r--r--usr.sbin/tcpdump/lbl/gnuc.h43
-rw-r--r--usr.sbin/tcpdump/lbl/os-sunos4.h215
-rw-r--r--usr.sbin/tcpdump/llc.h8
-rw-r--r--usr.sbin/tcpdump/machdep.c4
-rw-r--r--usr.sbin/tcpdump/mkdep109
-rw-r--r--usr.sbin/tcpdump/nfsfh.h4
-rw-r--r--usr.sbin/tcpdump/os-sunos4.h215
-rw-r--r--usr.sbin/tcpdump/ospf.h4
-rw-r--r--usr.sbin/tcpdump/parsenfsfh.c7
-rw-r--r--usr.sbin/tcpdump/print-arp.c3
-rw-r--r--usr.sbin/tcpdump/print-atalk.c11
-rw-r--r--usr.sbin/tcpdump/print-bootp.c5
-rw-r--r--usr.sbin/tcpdump/print-domain.c20
-rw-r--r--usr.sbin/tcpdump/print-ether.c4
-rw-r--r--usr.sbin/tcpdump/print-ike.c260
-rw-r--r--usr.sbin/tcpdump/print-ip.c44
-rw-r--r--usr.sbin/tcpdump/print-ipsec.c104
-rw-r--r--usr.sbin/tcpdump/print-isoclns.c4
-rw-r--r--usr.sbin/tcpdump/print-krb.c6
-rw-r--r--usr.sbin/tcpdump/print-ntp.c4
-rw-r--r--usr.sbin/tcpdump/print-null.c9
-rw-r--r--usr.sbin/tcpdump/print-ospf.c24
-rw-r--r--usr.sbin/tcpdump/print-sunrpc.c4
-rw-r--r--usr.sbin/tcpdump/print-tcp.c19
-rw-r--r--usr.sbin/tcpdump/print-udp.c11
-rw-r--r--usr.sbin/tcpdump/savestr.c (renamed from usr.sbin/tcpdump/os-solaris2.h)74
-rw-r--r--usr.sbin/tcpdump/savestr.h (renamed from usr.sbin/tcpdump/lbl/os-solaris2.h)36
-rw-r--r--usr.sbin/tcpdump/setsignal.c78
-rw-r--r--usr.sbin/tcpdump/setsignal.h (renamed from usr.sbin/tcpdump/lbl/os-ultrix4.h)22
-rw-r--r--usr.sbin/tcpdump/strcasecmp.c88
-rw-r--r--usr.sbin/tcpdump/tcpdump.817
-rw-r--r--usr.sbin/tcpdump/tcpdump.c163
-rw-r--r--usr.sbin/tcpdump/util.c59
-rw-r--r--usr.sbin/tcpdump/version.c4
46 files changed, 1002 insertions, 1725 deletions
diff --git a/usr.sbin/tcpdump/CHANGES b/usr.sbin/tcpdump/CHANGES
index 51b3a3bfb19..d973278e5c2 100644
--- a/usr.sbin/tcpdump/CHANGES
+++ b/usr.sbin/tcpdump/CHANGES
@@ -1,4 +1,75 @@
-@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/CHANGES,v 1.5 1996/12/12 16:23:05 bitblt Exp $ (LBL)
+@(#) $LBL: CHANGES,v 1.54 98/07/25 12:41:06 leres Exp $
+
+v3.4 Sat Jul 25 12:40:55 PDT 1998
+
+- Hardwire Linux slip support since it's too hard to detect.
+
+- Redo configuration of "network" libraries (-lsocket and -lnsl) to
+ deal with IRIX. Thanks to John Hawkinson (jhawk@mit.edu)
+
+- Added -a which tries to translate network and broadcast addresses to
+ names. Suggested by Rob van Nieuwkerk (robn@verdi.et.tudelft.nl)
+
+- Added a configure option to disable gcc.
+
+- Added a "raw" packet printer.
+
+- Not having an interface address is no longer fatal. Requested by John
+ Hawkinson.
+
+- Rework signal setup to accommodate Linux.
+
+- OSPF truncation check fix. Also display the type of OSPF packets
+ using MD5 authentication. Thanks to Brian Wellington
+ (bwelling@tis.com)
+
+- Fix truncation check bugs in the Kerberos printer. Reported by Ezra
+ Peisach (epeisach@mit.edu)
+
+- Don't catch SIGHUP when invoked with nohup(1). Thanks to Dave Plonka
+ (plonka@mfa.com)
+
+- Specify full install target as a way of detecting if install
+ directory does not exist. Thanks to Dave Plonka.
+
+- Bit-swap FDDI addresses for BSD/OS too. Thanks to Paul Vixie
+ (paul@vix.com)
+
+- Fix off-by-one bug when testing size of ethernet packets. Thanks to
+ Marty Leisner (leisner@sdsp.mc.xerox.com)
+
+- Add a local autoconf macro to check for routines in libraries; the
+ autoconf version is broken (it only puts the library name in the
+ cache variable name). Thanks to John Hawkinson.
+
+- Add a local autoconf macro to check for types; the autoconf version
+ is broken (it uses grep instead of actually compiling a code fragment).
+
+- Modified to support the new BSD/OS 2.1 PPP and SLIP link layer header
+ formats.
+
+- Extend OSF ip header workaround to versions 1 and 2.
+
+- Fix some signed problems in the nfs printer. As reported by David
+ Sacerdote (davids@silence.secnet.com)
+
+- Detect group wheel and use it as the default since BSD/OS' install
+ can't hack numeric groups. Reported by David Sacerdote.
+
+- AIX needs special loader options. Thanks to Jonathan I. Kamens
+ (jik@cam.ov.com)
+
+- Fixed the nfs printer to print port numbers in decimal. Thanks to
+ Kent Vander Velden (graphix@iastate.edu)
+
+- Find installed libpcap in /usr/local/lib when not using gcc.
+
+- Disallow network masks with non-network bits set.
+
+- Attempt to detect "egcs" versions of gcc.
+
+- Add missing closing double quotes when displaying bootp strings.
+ Reported by Viet-Trung Luu (vluu@picard.math.uwaterloo.ca)
v3.3 Sat Nov 30 20:56:27 PST 1996
diff --git a/usr.sbin/tcpdump/FILES b/usr.sbin/tcpdump/FILES
deleted file mode 100644
index 549cee3b8e2..00000000000
--- a/usr.sbin/tcpdump/FILES
+++ /dev/null
@@ -1,94 +0,0 @@
-CHANGES
-FILES
-INSTALL
-Makefile.in
-README
-VERSION
-acsite.m4
-addrtoname.c
-addrtoname.h
-appletalk.h
-atime.awk
-bootp.h
-bpf_dump.c
-config.guess
-config.sub
-configure
-configure.in
-decnet.h
-ethertype.h
-extract.h
-fddi.h
-igrp.h
-install-sh
-interface.h
-ipx.h
-lbl/gnuc.h
-lbl/os-solaris2.h
-lbl/os-sunos4.h
-lbl/os-ultrix4.h
-linux-include/net/slcompress.h
-linux-include/net/slip.h
-linux-include/netinet/if_ether.h
-linux-include/netinet/in_systm.h
-linux-include/netinet/ip.h
-linux-include/netinet/ip_icmp.h
-linux-include/netinet/ip_var.h
-linux-include/netinet/tcp.h
-linux-include/netinet/tcp_var.h
-linux-include/netinet/tcpip.h
-linux-include/netinet/udp.h
-linux-include/netinet/udp_var.h
-llc.h
-machdep.c
-machdep.h
-makemib
-mib.h
-mkdep
-netbios.h
-nfsfh.h
-nfsv2.h
-ntp.h
-ospf.h
-packetdat.awk
-parsenfsfh.c
-print-arp.c
-print-atalk.c
-print-atm.c
-print-bootp.c
-print-decnet.c
-print-domain.c
-print-dvmrp.c
-print-egp.c
-print-ether.c
-print-fddi.c
-print-gre.c
-print-icmp.c
-print-igrp.c
-print-ip.c
-print-ipx.c
-print-isoclns.c
-print-krb.c
-print-llc.c
-print-netbios.c
-print-nfs.c
-print-ntp.c
-print-null.c
-print-ospf.c
-print-pim.c
-print-ppp.c
-print-rip.c
-print-sl.c
-print-snmp.c
-print-sunrpc.c
-print-tcp.c
-print-tftp.c
-print-udp.c
-print-wb.c
-send-ack.awk
-stime.awk
-strcasecmp.c
-tcpdump.1
-tcpdump.c
-util.c
-vfprintf.c
diff --git a/usr.sbin/tcpdump/INSTALL b/usr.sbin/tcpdump/INSTALL
index 023d59ac0a8..9c515f5a6d5 100644
--- a/usr.sbin/tcpdump/INSTALL
+++ b/usr.sbin/tcpdump/INSTALL
@@ -1,4 +1,4 @@
-@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/INSTALL,v 1.1 1996/12/12 16:23:03 bitblt Exp $ (LBL)
+@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/INSTALL,v 1.2 1999/07/28 20:41:34 jakob Exp $ (LBL)
If you have not built libpcap, do so first. See the README
file in this directory for the ftp location.
@@ -28,6 +28,10 @@ Note that tcpdump is shipped with some systems, for example, DEC/OSF
and BSD/386. Remember to remove or rename the installed binary
when upgrading.
+If you use Linux, this version of libpcap is known to compile and run
+under Red Hat 4.0 with the 2.0.25 kernel. It may work with earlier 2.X
+versions but is guaranteed not to work with 1.X kernels.
+
If you use OSF 4, note that that there appears to be some serious bugs
with the stock C compiler. The configure code fragments that detect if
the ether_header and ether_arp structs use the ether_addr struct
@@ -52,40 +56,32 @@ needed to write a password sniffer to grab clear text passwords.
FILES
-----
CHANGES - description of differences between releases
-FILES - list of files exported as part of the distribution
INSTALL - this file
-Makefile.in - compilation rules (input to the configure script)
README - description of distribution
VERSION - version of this release
-acsite.m4 - autoconf macros
addrtoname.c - address to hostname routines
addrtoname.h - address to hostname definitions
appletalk.h - AppleTalk definitions
atime.awk - TCP ack awk script
bootp.h - BOOTP definitions
bpf_dump.c - bpf instruction pretty-printer routine
-config.guess - autoconf support
-config.sub - autoconf support
-configure - configure script (run this first)
-configure.in - configure script source
decnet.h - DECnet definitions
ethertype.h - ethernet definitions
extract.h - alignment definitions
fddi.h - Fiber Distributed Data Interface definitions
+gmt2local.c - time conversion routines
+gmt2local.h - time conversion prototypes
+gnuc.h - XXX
igrp.h - Interior Gateway Routing Protocol definitions
-install-sh - BSD style install script
interface.h - globals, prototypes and definitions
ipx.h - IPX definitions
-lbl/gnuc.h - gcc macros and defines
-lbl/os-*.h - os dependent defines and prototypes
-linux-include/* - network include files missing on Linux
llc.h - LLC definitions
machdep.c - machine dependent routines
machdep.h - machine dependent definitions
makemib - mib to header script
mib.h - mib definitions
-mkdep - construct Makefile dependency list
netbios.h - NETBIOS definitions
+nfs.h - XXX
nfsfh.h - Network File System file handle definitions
nfsv2.h - Network File System V2 definitions
ntp.h - Network Time Protocol definitions
@@ -96,15 +92,19 @@ print-arp.c - Address Resolution Protocol printer routines
print-atalk.c - AppleTalk printer routines
print-atm.c - atm printer routines
print-bootp.c - BOOTP printer routines
+print-cnfp.c - Cisco NetFlow printer routines
print-decnet.c - DECnet printer routines
print-domain.c - Domain Name System printer routines
print-egp.c - External Gateway Protocol printer routines
+print-enc.c - Encapsulated printer routines
print-ether.c - ethernet printer routines
print-fddi.c - Fiber Distributed Data Interface printer routines
print-gre.c - Generic Routing Encapsulation printer routines
print-icmp.c - Internet Control Message Protocol printer routines
print-igrp.c - Interior Gateway Routing Protocol printer routines
+print-ike.c - internet key exchange (ike, isakmp/oakley) printer routines
print-ip.c - ip printer routines
+print-ipsec.c - ipsec (esp/ah) printer routines
print-ipx.c - IPX printer routines
print-isoclns.c - isoclns printer routines
print-krb.c - Kerberos printer routines
@@ -116,7 +116,9 @@ print-null.c - null printer routines
print-ospf.c - Open Shortest Path First printer routines
print-pim.c - Protocol Independent Multicast printer routines
print-ppp.c - Point to Point Protocol printer routines
+print-raw.c - raw printer routines
print-rip.c - Routing Information Protocol printer routines
+print-skip.c - SKIP printer routines
print-sl.c - Compressed Serial Line Internet Protocol printer routines
print-snmp.c - Simple Network Management Protocol printer routines
print-sunrpc.c - Sun Remote Procedure Call printer routines
@@ -124,9 +126,13 @@ print-tcp.c - TCP printer routines
print-tftp.c - Trivial File Transfer Protocol printer routines
print-udp.c - UDP printer routines
print-wb.c - white board printer routines
+radius.h - XXX
+savestr.c - savestr prototypes
+savestr.h - strdup() replacement
send-ack.awk - unidirectional tcp send/ack awk script
+setsignal.c - os independent signal routines
+setsignal.h - os independent signal prototypes
stime.awk - TCP send awk script
-tcpdump.1 - manual entry
+tcpdump.8 - manual entry
tcpdump.c - main program
util.c - utility routines
-vfprintf.c - emulation routine
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile
index 7470c8736fa..907c21d29cc 100644
--- a/usr.sbin/tcpdump/Makefile
+++ b/usr.sbin/tcpdump/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.13 1998/06/25 19:42:43 mickey Exp $
+# $OpenBSD: Makefile,v 1.14 1999/07/28 20:41:34 jakob Exp $
#
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
# The Regents of the University of California. All rights reserved.
@@ -40,7 +40,9 @@ SRCS= tcpdump.c addrtoname.c \
print-wb.c print-decnet.c print-isoclns.c print-ipx.c \
print-atm.c print-dvmrp.c print-krb.c print-pim.c print-netbios.c \
util.c bpf_dump.c parsenfsfh.c version.c machdep.c print-igrp.c \
- print-gre.c print-radius.c print-enc.c print-cnfp.c
+ print-gre.c print-radius.c print-enc.c print-cnfp.c \
+ print-ipsec.c print-ike.c \
+ gmt2local.c savestr.c setsignal.c
AWKS = atime.awk packetdat.awk send-ack.awk stime.awk
diff --git a/usr.sbin/tcpdump/Makefile.in b/usr.sbin/tcpdump/Makefile.in
deleted file mode 100644
index 0be1ce19d15..00000000000
--- a/usr.sbin/tcpdump/Makefile.in
+++ /dev/null
@@ -1,145 +0,0 @@
-# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
-# The Regents of the University of California. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that: (1) source code distributions
-# retain the above copyright notice and this paragraph in its entirety, (2)
-# distributions including binary code include the above copyright notice and
-# this paragraph in its entirety in the documentation or other materials
-# provided with the distribution, and (3) all advertising materials mentioning
-# features or use of this software display the following acknowledgement:
-# ``This product includes software developed by the University of California,
-# Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
-# the University nor the names of its contributors may be used to endorse
-# or promote products derived from this software without specific prior
-# written permission.
-# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-#
-# @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/Attic/Makefile.in,v 1.1 1996/12/12 16:23:02 bitblt Exp $ (LBL)
-
-#
-# Various configurable paths (remember to edit Makefile.in, not Makefile)
-#
-
-# Top level hierarchy
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-# Pathname of directory to install the binary
-BINDEST = @sbindir@
-# Pathname of directory to install the man page
-MANDEST = @mandir@
-
-# VPATH
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-#
-# You shouldn't need to edit anything below here.
-#
-
-CC = @CC@
-CCOPT = @V_CCOPT@
-INCLS = -I. @V_INCLS@
-DEFS = @DEFS@ -DPPP -DHAVE_FDDI
-
-# Standard CFLAGS
-CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
-
-# Standard LIBS
-LIBS = @LIBS@
-
-INSTALL = @INSTALL@
-
-# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
-# Also, gcc does not remove the .o before forking 'as', which can be a
-# problem if you don't own the file but can write to the directory.
-.c.o:
- @rm -f $@
- $(CC) $(CFLAGS) -c $(srcdir)/$*.c
-
-CSRC = tcpdump.c \
- print-arp.c print-atalk.c print-atm.c print-bootp.c \
- print-decnet.c print-domain.c print-dvmrp.c print-egp.c \
- print-ether.c print-fddi.c print-gre.c print-icmp.c \
- print-igrp.c print-ip.c print-ipx.c print-isoclns.c print-krb.c \
- print-llc.c print-nfs.c print-ntp.c print-null.c print-ospf.c \
- print-pim.c print-ppp.c print-rip.c print-sl.c print-snmp.c \
- print-sunrpc.c print-tcp.c print-tftp.c print-udp.c print-wb.c \
- addrtoname.c bpf_dump.c machdep.c parsenfsfh.c util.c
-LOCALSRC =
-GENSRC = version.c
-
-SRC = $(CSRC) $(GENSRC) $(LOCALSRC)
-
-# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
-# hack the extra indirection
-OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) @LIBOBJS@
-HDR = addrtoname.h appletalk.h bootp.h decnet.h \
- ethertype.h extract.h fddi.h interface.h igrp.h ipx.h \
- llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h
-
-TAGHDR = \
- /usr/include/arpa/tftp.h \
- /usr/include/net/if_arp.h \
- /usr/include/net/slip.h \
- /usr/include/netinet/if_ether.h \
- /usr/include/netinet/in.h \
- /usr/include/netinet/ip_icmp.h \
- /usr/include/netinet/tcp.h \
- /usr/include/netinet/udp.h \
- /usr/include/protocols/routed.h
-
-TAGFILES = $(SRC) $(HDR) $(TAGHDR)
-
-CLEANFILES = $(OBJ) tcpdump $(GENSRC)
-
-tcpdump: $(OBJ) @V_PCAPDEP@
- @rm -f $@
- $(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS)
-
-version.o: version.c
-version.c: $(srcdir)/VERSION
- @rm -f $@
- sed -e 's/.*/char version[] = "&";/' $(srcdir)/VERSION > $@
-
-install: force
- $(INSTALL) -m 550 -o bin -g @V_GROUP@ tcpdump $(DESTDIR)$(BINDEST)
-
-install-man: force
- $(INSTALL) -m 444 -o bin -g bin $(srcdir)/tcpdump.1 \
- $(DESTDIR)$(MANDEST)/man1
-
-lint: $(GENSRC) force
- lint -hbxn $(SRC) | \
- grep -v 'struct/union .* never defined' | \
- grep -v 'possible pointer alignment problem'
-
-clean:
- rm -f $(CLEANFILES)
-
-distclean:
- rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
- gnuc.h os-proto.h
-
-tags: $(TAGFILES)
- ctags -wtd $(TAGFILES)
-
-tar: force
- @cwd=`pwd` ; dir=`basename $$cwd` ; name=tcpdump-`cat VERSION` ; \
- list="" ; tar="tar chFFf" ; \
- for i in `cat FILES` ; do list="$$list $$name/$$i" ; done; \
- echo \
- "rm -f ../$$name; ln -s $$dir ../$$name" ; \
- rm -f ../$$name; ln -s $$dir ../$$name ; \
- echo \
- "(cd .. ; $$tar - [lots of files]) | compress > /tmp/$$name.tar.Z" ; \
- (cd .. ; $$tar - $$list) | compress > /tmp/$$name.tar.Z ; \
- echo \
- "rm -f ../$$name" ; \
- rm -f ../$$name
-
-force: /tmp
-depend: $(GENSRC) force
- ./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
diff --git a/usr.sbin/tcpdump/README b/usr.sbin/tcpdump/README
index caecde9a087..177ffdd08b5 100644
--- a/usr.sbin/tcpdump/README
+++ b/usr.sbin/tcpdump/README
@@ -1,6 +1,6 @@
-@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/README,v 1.5 1996/12/12 16:23:02 bitblt Exp $ (LBL)
+@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/README,v 1.6 1999/07/28 20:41:34 jakob Exp $ (LBL)
-TCPDUMP 3.3
+TCPDUMP 3.4
Lawrence Berkeley National Laboratory
Network Research Group
tcpdump@ee.lbl.gov
@@ -10,7 +10,7 @@ This directory contains source code for tcpdump, a tool for network
monitoring and data acquisition. The original distribution is
available via anonymous ftp to ftp.ee.lbl.gov, in tcpdump.tar.Z.
-Tcpdump now uses libcap, a system-independent interface for user-level
+Tcpdump now uses libpcap, a system-independent interface for user-level
packet capture. Before building tcpdump, you must first retrieve and
build libpcap, also from LBL, in:
@@ -20,30 +20,35 @@ Once libpcap is built (either install it or make sure it's in
../libpcap), you can build tcpdump using the procedure in the INSTALL
file.
-The program is loosely based on SMI's "etherfind" although none
-of the etherfind code remains. It was originally written by Van
-Jacobson as part of an ongoing research project to investigate and
-improve tcp and internet gateway performance. The parts of the
-program originally taken from Sun's etherfind were later re-written
-by Steven McCanne of LBL. To insure that there would be no vestige
-of proprietary code in tcpdump, Steve wrote these pieces from the
-specification given by the manual entry, with no access to the
-source of tcpdump or etherfind.
-
-Over the past few years, tcpdump has been steadily improved
-by the excellent contributions from the Internet community
-(just browse through the CHANGES file). We are grateful for
-all the input.
-
-Richard Stevens gives an excellent treatment of the Internet
-protocols in his book ``TCP/IP Illustrated, Volume 1''.
-If you want to learn more about tcpdump and how to interpret
-its output, pick up this book.
+The program is loosely based on SMI's "etherfind" although none of the
+etherfind code remains. It was originally written by Van Jacobson as
+part of an ongoing research project to investigate and improve tcp and
+internet gateway performance. The parts of the program originally
+taken from Sun's etherfind were later re-written by Steven McCanne of
+LBL. To insure that there would be no vestige of proprietary code in
+tcpdump, Steve wrote these pieces from the specification given by the
+manual entry, with no access to the source of tcpdump or etherfind.
+
+Over the past few years, tcpdump has been steadily improved by the
+excellent contributions from the Internet community (just browse
+through the CHANGES file). We are grateful for all the input.
+
+Richard Stevens gives an excellent treatment of the Internet protocols
+in his book ``TCP/IP Illustrated, Volume 1''. If you want to learn more
+about tcpdump and how to interpret its output, pick up this book.
Some tools for viewing and analyzing tcpdump trace files are available
from the Internet Traffic Archive:
- http://town.hall.org/Archives/pub/ITA/
+ http://www.acm.org/sigcomm/ITA/
+
+Another tool that tcpdump users might find useful is tcpslice:
+
+ ftp://ftp.ee.lbl.gov/tcpslice.tar.Z
+
+It is a program that can be used to extract portions of tcpdump binary
+trace files. See the above distribution for further details and
+documentation.
Problems, bugs, questions, desirable enhancements, source code
contributions, etc., should be sent to the email address
diff --git a/usr.sbin/tcpdump/acsite.m4 b/usr.sbin/tcpdump/acsite.m4
deleted file mode 100644
index 27832805804..00000000000
--- a/usr.sbin/tcpdump/acsite.m4
+++ /dev/null
@@ -1,505 +0,0 @@
-dnl @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/Attic/acsite.m4,v 1.1 1996/12/12 16:23:01 bitblt Exp $ (LBL)
-dnl
-dnl Copyright (c) 1995, 1996
-dnl The Regents of the University of California. All rights reserved.
-dnl
-dnl Redistribution and use in source and binary forms, with or without
-dnl modification, are permitted provided that: (1) source code distributions
-dnl retain the above copyright notice and this paragraph in its entirety, (2)
-dnl distributions including binary code include the above copyright notice and
-dnl this paragraph in its entirety in the documentation or other materials
-dnl provided with the distribution, and (3) all advertising materials mentioning
-dnl features or use of this software display the following acknowledgement:
-dnl ``This product includes software developed by the University of California,
-dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
-dnl the University nor the names of its contributors may be used to endorse
-dnl or promote products derived from this software without specific prior
-dnl written permission.
-dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-dnl
-dnl LBL autoconf macros
-dnl
-
-dnl
-dnl Determine which compiler we're using (cc or gcc)
-dnl If using gcc, determine the version number
-dnl If using cc, require that it support ansi prototypes
-dnl If using gcc, use -O2 (otherwise use -O)
-dnl If using cc, explicitly specify /usr/local/include
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_C_INIT(copt, incls)
-dnl
-dnl results:
-dnl
-dnl $1 (copt set)
-dnl $2 (incls set)
-dnl CC
-dnl ac_cv_gcc_vers
-dnl LBL_CFLAGS
-dnl
-dnl XXX need to add test to make sure ac_prog_cc hasn't been called
-AC_DEFUN(AC_LBL_C_INIT,
- [AC_PREREQ(2.12)
- $1=-O
- $2=""
- if test "${CFLAGS+set}" = set; then
- LBL_CFLAGS="$CFLAGS"
- fi
- if test -z "$CC" ; then
- case "$target_os" in
-
- bsdi*)
- AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
- if test $SHLICC2 = yes ; then
- CC=shlicc2
- export CC
- fi
- ;;
- esac
- fi
- AC_PROG_CC
- if test $ac_cv_prog_gcc = yes ; then
- if test "$SHLICC2" = yes ; then
- ac_cv_gcc_vers=2
- $1=-O2
- else
- AC_MSG_CHECKING(gcc version)
- AC_CACHE_VAL(ac_cv_gcc_vers,
- ac_cv_gcc_vers=`$CC -v 2>&1 | \
- sed -n -e '$s/.* //' -e '$s/\..*//p'`)
- AC_MSG_RESULT($ac_cv_gcc_vers)
- if test $ac_cv_gcc_vers -gt 1 ; then
- $1=-O2
- fi
- fi
- else
- AC_MSG_CHECKING(that $CC handles ansi prototypes)
- AC_CACHE_VAL(ac_cv_cc_ansi_prototypes,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_cc_ansi_prototypes=yes,
- ac_cv_cc_ansi_prototypes=no))
- AC_MSG_RESULT($ac_cv_cc_ansi_prototypes)
- if test $ac_cv_cc_ansi_prototypes = no ; then
- case "$target_os" in
-
- hpux*)
- AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
- savedcflags="$CFLAGS"
- CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
- AC_CACHE_VAL(ac_cv_cc_hpux_cc_aa,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_cc_hpux_cc_aa=yes,
- ac_cv_cc_hpux_cc_aa=no))
- AC_MSG_RESULT($ac_cv_cc_hpux_cc_aa)
- if test $ac_cv_cc_hpux_cc_aa = no ; then
- AC_MSG_ERROR(see the INSTALL for more info)
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-Aa $V_CCOPT"
- AC_DEFINE(_HPUX_SOURCE)
- ;;
-
- *)
- AC_MSG_ERROR(see the INSTALL for more info)
- ;;
- esac
- fi
- $2=-I/usr/local/include
-
- case "$target_os" in
-
- irix*)
- V_CCOPT="$V_CCOPT -xansi -signed -g3"
- ;;
-
- osf*)
- V_CCOPT="$V_CCOPT -g3"
- ;;
-
- ultrix*)
- AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
- AC_CACHE_VAL(ac_cv_cc_const_proto,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [struct a { int b; };
- void c(const struct a *)],
- ac_cv_cc_const_proto=yes,
- ac_cv_cc_const_proto=no))
- AC_MSG_RESULT($ac_cv_cc_const_proto)
- if test $ac_cv_cc_const_proto = no ; then
- AC_DEFINE(const,)
- fi
- ;;
- esac
- fi
-])
-
-dnl
-dnl Use pfopen.c if available and pfopen() not in standard libraries
-dnl Require libpcap
-dnl Look for libpcap in ..
-dnl Use the installed libpcap if there is no local version
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LIBPCAP(pcapdep, incls)
-dnl
-dnl results:
-dnl
-dnl $1 (pcapdep set)
-dnl $2 (incls appended)
-dnl LIBS
-dnl
-AC_DEFUN(AC_LBL_LIBPCAP,
- [pfopen=/usr/examples/packetfilter/pfopen.c
- if test -f $pfopen ; then
- AC_CHECK_FUNCS(pfopen)
- if test $ac_cv_func_pfopen = "no" ; then
- AC_MSG_RESULT(Using $pfopen)
- LIBS="$LIBS $pfopen"
- fi
- fi
- AC_MSG_CHECKING(for local pcap library)
- libpcap=FAIL
- lastdir=FAIL
- places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
- egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
- for dir in $places ../libpcap libpcap ; do
- basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
- if test $lastdir = $basedir ; then
- dnl skip alphas when an actual release is present
- continue;
- fi
- lastdir=$dir
- if test -r $dir/pcap.c ; then
- libpcap=$dir/libpcap.a
- d=$dir
- dnl continue and select the last one that exists
- fi
- done
- if test $libpcap = FAIL ; then
- AC_MSG_RESULT(not found)
- AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
- if test $libpcap = FAIL ; then
- AC_MSG_ERROR(see the INSTALL doc for more info)
- fi
- else
- $1=$libpcap
- $2="-I$d $$2"
- AC_MSG_RESULT($libpcap)
- fi
- LIBS="$libpcap $LIBS"])
-
-dnl
-dnl Define RETSIGTYPE and RETSIGVAL
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_TYPE_SIGNAL
-dnl
-dnl results:
-dnl
-dnl RETSIGTYPE (defined)
-dnl RETSIGVAL (defined)
-dnl
-AC_DEFUN(AC_LBL_TYPE_SIGNAL,
- [AC_TYPE_SIGNAL
- if test "$ac_cv_type_signal" = void ; then
- AC_DEFINE(RETSIGVAL,)
- else
- AC_DEFINE(RETSIGVAL,(0))
- fi
- case "$target_os" in
-
- irix*)
- AC_DEFINE(_BSD_SIGNALS)
- ;;
-
- *)
- AC_CHECK_FUNCS(sigset)
- if test $ac_cv_func_sigset = yes ; then
- AC_DEFINE(signal, sigset)
- fi
- ;;
- esac])
-
-dnl
-dnl If using gcc, see if fixincludes should be run
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_FIXINCLUDES
-dnl
-AC_DEFUN(AC_LBL_FIXINCLUDES,
- [if test $ac_cv_prog_gcc = yes ; then
- AC_MSG_CHECKING(if fixincludes is needed)
- AC_CACHE_VAL(ac_cv_gcc_fixincludes,
- AC_TRY_COMPILE(
- [/*
- * This generates a "duplicate case value" when fixincludes
- * has not be run.
- */
-# include <sys/types.h>
-# include <sys/time.h>
-# include <sys/ioctl.h>
-# ifdef HAVE_SYS_IOCCOM_H
-# include <sys/ioccom.h>
-# endif],
- [switch (0) {
- case _IO('A', 1):;
- case _IO('B', 1):;
- }],
- ac_cv_gcc_fixincludes=yes,
- ac_cv_gcc_fixincludes=no))
- AC_MSG_RESULT($ac_cv_gcc_fixincludes)
- if test $ac_cv_gcc_fixincludes = no ; then
- # Don't cache failure
- unset ac_cv_gcc_fixincludes
- AC_MSG_ERROR(see the INSTALL for more info)
- fi
- fi])
-
-dnl
-dnl Check for flex, default to lex
-dnl Require flex 2.4 or higher
-dnl Check for bison, default to yacc
-dnl Default to lex/yacc if both flex and bison are not available
-dnl Define the yy prefix string if using flex and bison
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
-dnl
-dnl results:
-dnl
-dnl $1 (lex set)
-dnl $2 (yacc appended)
-dnl $3 (optional flex and bison -P prefix)
-dnl
-AC_DEFUN(AC_LBL_LEX_AND_YACC,
- [AC_CHECK_PROGS($1, flex, lex)
- if test "$$1" = flex ; then
- # The -V flag was added in 2.4
- AC_MSG_CHECKING(for flex 2.4 or higher)
- AC_CACHE_VAL(ac_cv_flex_v24,
- if flex -V >/dev/null 2>&1; then
- ac_cv_flex_v24=yes
- else
- ac_cv_flex_v24=no
- fi)
- AC_MSG_RESULT($ac_cv_flex_v24)
- if test $ac_cv_flex_v24 = no ; then
- s="2.4 or higher required"
- AC_MSG_WARN(ignoring obsolete flex executable ($s))
- $1=lex
- fi
- fi
- AC_CHECK_PROGS($2, bison, yacc)
- if test "$$2" = bison ; then
- $2="$$2 -y"
- fi
- if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
- AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
- $1=lex
- $2=yacc
- fi
- if test "$$1" = flex -a -n "$3" ; then
- $1="$$1 -P$3"
- $2="$$2 -p $3"
- fi])
-
-dnl
-dnl Checks to see if union wait is used with WEXITSTATUS()
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_UNION_WAIT
-dnl
-dnl results:
-dnl
-dnl DECLWAITSTATUS (defined)
-dnl
-AC_DEFUN(AC_LBL_UNION_WAIT,
- [AC_MSG_CHECKING(if union wait is used)
- AC_CACHE_VAL(ac_cv_union_wait,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/wait.h>],
- [int status;
- u_int i = WEXITSTATUS(status);
- u_int j = waitpid(0, &status, 0);],
- ac_cv_union_wait=no,
- ac_cv_union_wait=yes))
- AC_MSG_RESULT($ac_cv_union_wait)
- if test $ac_cv_union_wait = yes ; then
- AC_DEFINE(DECLWAITSTATUS,union wait)
- else
- AC_DEFINE(DECLWAITSTATUS,int)
- fi])
-
-dnl
-dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_SOCKADDR_SA_LEN
-dnl
-dnl results:
-dnl
-dnl HAVE_SOCKADDR_SA_LEN (defined)
-dnl
-AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
- [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
- AC_CACHE_VAL(ac_cv_sockaddr_has_sa_len,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
- ac_cv_sockaddr_has_sa_len=yes,
- ac_cv_sockaddr_has_sa_len=no))
- AC_MSG_RESULT($ac_cv_sockaddr_has_sa_len)
- if test $ac_cv_sockaddr_has_sa_len = yes ; then
- AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
- fi])
-
-dnl
-dnl Checks to see if -R is used
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_HAVE_RUN_PATH
-dnl
-dnl results:
-dnl
-dnl ac_cv_have_run_path (yes or no)
-dnl
-AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
- [AC_MSG_CHECKING(for ${CC-cc} -R)
- AC_CACHE_VAL(ac_cv_have_run_path,
- [echo 'main(){}' > conftest.c
- ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
- if test ! -s conftest.out ; then
- ac_cv_have_run_path=yes
- else
- ac_cv_have_run_path=no
- fi
- rm -f conftest*])
- AC_MSG_RESULT($ac_cv_have_run_path)
- ])
-
-dnl
-dnl Checks to see if unaligned memory accesses fail
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_UNALIGNED_ACCESS
-dnl
-dnl results:
-dnl
-dnl LBL_ALIGN (DEFINED)
-dnl
-AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
- [AC_MSG_CHECKING(if unaligned accesses fail)
- AC_CACHE_VAL(ac_cv_unaligned_fail,
- [case "$target_cpu" in
-
- alpha|hp*|mips|sparc)
- ac_cv_unaligned_fail=yes
- ;;
-
- *)
- cat >conftest.c <<EOF
-# include <sys/types.h>
-# include <sys/wait.h>
-# include <stdio.h>
- unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
- main() {
- unsigned int i;
- pid_t pid;
- int status;
- /* avoid "core dumped" message */
- pid = fork();
- if (pid < 0)
- exit(2);
- if (pid > 0) {
- /* parent */
- pid = waitpid(pid, &status, 0);
- if (pid < 0)
- exit(3);
- exit(!WIFEXITED(status));
- }
- /* child */
- i = *(unsigned int *)&a[[1]];
- printf("%d\n", i);
- exit(0);
- }
-EOF
- ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
- conftest.c $LIBS >/dev/null 2>&1
- if test ! -x conftest ; then
- dnl failed to compile for some reason
- ac_cv_unaligned_fail=yes
- else
- ./conftest >conftest.out
- if test ! -s conftest.out ; then
- ac_cv_unaligned_fail=yes
- else
- ac_cv_unaligned_fail=no
- fi
- fi
- rm -f conftest* core core.conftest
- ;;
- esac])
- AC_MSG_RESULT($ac_cv_unaligned_fail)
- if test $ac_cv_unaligned_fail = yes ; then
- AC_DEFINE(LBL_ALIGN)
- fi])
-
-dnl
-dnl If using gcc and the file .devel exists:
-dnl Compile with -g (if supported) and -Wall
-dnl If using gcc 2, do extra prototype checking
-dnl If an os prototype include exists, symlink os-proto.h to it
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_DEVEL(copt)
-dnl
-dnl results:
-dnl
-dnl $1 (copt appended)
-dnl HAVE_OS_PROTO_H (defined)
-dnl os-proto.h (symlinked)
-dnl
-AC_DEFUN(AC_LBL_DEVEL,
- [rm -f os-proto.h
- if test "${LBL_CFLAGS+set}" = set; then
- $1="$$1 ${LBL_CFLAGS}"
- fi
- if test $ac_cv_prog_gcc = yes -a -f .devel ; then
- if test "${LBL_CFLAGS+set}" != set; then
- if test "$ac_cv_prog_cc_g" = yes ; then
- $1="-g $$1"
- fi
- $1="$$1 -Wall"
- if test $ac_cv_gcc_vers -gt 1 ; then
- $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
- fi
- fi
- os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
- name="lbl/os-$os.h"
- if test -f $name ; then
- ln -s $name os-proto.h
- AC_DEFINE(HAVE_OS_PROTO_H)
- else
- AC_MSG_WARN(can't find $name)
- fi
- fi])
diff --git a/usr.sbin/tcpdump/addrtoname.c b/usr.sbin/tcpdump/addrtoname.c
index b418aa3e902..360eab320fa 100644
--- a/usr.sbin/tcpdump/addrtoname.c
+++ b/usr.sbin/tcpdump/addrtoname.c
@@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.c,v 1.6 1997/07/25 20:12:20 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.c,v 1.7 1999/07/28 20:41:35 jakob Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -45,6 +45,7 @@ struct rtentry;
#include <netdb.h>
#include <pcap.h>
#include <pcap-namedb.h>
+#include <memory.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -54,6 +55,8 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
#include "llc.h"
+#include "savestr.h"
+#include "setsignal.h"
/* Forwards */
static RETSIGTYPE nohostname(int);
@@ -208,16 +211,18 @@ getname(const u_char *ap)
/*
* Only print names when:
* (1) -n was not given.
- * (2) Address is foreign and -f was given. If -f was not
- * present, f_netmask and f_local are 0 and the second
- * test will succeed.
- * (3) The host portion is not 0 (i.e., a network address).
- * (4) The host portion is not broadcast.
+ * (2) Address is foreign and -f was given. (If -f was not
+ * give, f_netmask and f_local are 0 and the test
+ * evaluates to true)
+ * (3) -a was given or the host portion is not all ones
+ * nor all zeros (i.e. not a network or broadcast address)
*/
- if (!nflag && (addr & f_netmask) == f_localnet
- && (addr &~ netmask) != 0 && (addr | netmask) != 0xffffffff) {
+ if (!nflag &&
+ (addr & f_netmask) == f_localnet &&
+ (aflag ||
+ !((addr & ~netmask) == 0 || (addr | netmask) == 0xffffffff))) {
if (!setjmp(getname_env)) {
- (void)signal(SIGALRM, nohostname);
+ (void)setsignal(SIGALRM, nohostname);
(void)alarm(20);
hp = gethostbyaddr((char *)&addr, 4, AF_INET);
(void)alarm(0);
@@ -307,7 +312,7 @@ lookup_nsap(register const u_char *nsap)
tp->e_nsap = (u_char *)malloc(nlen + 1);
if (tp->e_nsap == NULL)
error("lookup_nsap: malloc");
- memcpy(tp->e_nsap, nsap, nlen + 1);
+ memcpy((char *)tp->e_nsap, (char *)nsap, nlen + 1);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
error("lookup_nsap: calloc");
@@ -696,7 +701,7 @@ init_llcsaparray(void)
* of the local network. mask is its subnet mask.
*/
void
-init_addrtoname(int fflag, u_int32_t localnet, u_int32_t mask)
+init_addrtoname(u_int32_t localnet, u_int32_t mask)
{
netmask = mask;
if (fflag) {
diff --git a/usr.sbin/tcpdump/addrtoname.h b/usr.sbin/tcpdump/addrtoname.h
index cbf912bd3d2..c3be7ea8a61 100644
--- a/usr.sbin/tcpdump/addrtoname.h
+++ b/usr.sbin/tcpdump/addrtoname.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 1992, 1993, 1994, 1995
+ * Copyright (c) 1990, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.h,v 1.5 1996/12/12 16:22:59 bitblt Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.h,v 1.6 1999/07/28 20:41:35 jakob Exp $ (LBL)
*/
/* Name to address translation routines. */
@@ -30,7 +30,7 @@ extern char *udpport_string(u_short);
extern char *getname(const u_char *);
extern char *intoa(u_int32_t);
-extern void init_addrtoname(int, u_int32_t, u_int32_t);
+extern void init_addrtoname(u_int32_t, u_int32_t);
extern struct hnamemem *newhnamemem(void);
#define ipaddr_string(p) getname((const u_char *)(p))
diff --git a/usr.sbin/tcpdump/gmt2local.c b/usr.sbin/tcpdump/gmt2local.c
new file mode 100644
index 00000000000..dd27bc04afd
--- /dev/null
+++ b/usr.sbin/tcpdump/gmt2local.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/gmt2local.c,v 1.1 1999/07/28 20:41:35 jakob Exp $ (LBL)";
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <stdio.h>
+#ifdef TIME_WITH_SYS_TIME
+#include <time.h>
+#endif
+
+#include "gnuc.h"
+#ifdef HAVE_OS_PROTO_H
+#include "os-proto.h"
+#endif
+
+#include "gmt2local.h"
+
+/*
+ * Returns the difference between gmt and local time in seconds.
+ * Use gmtime() and localtime() to keep things simple.
+ */
+int32_t
+gmt2local(time_t t)
+{
+ register int dt, dir;
+ register struct tm *gmt, *loc;
+ struct tm sgmt;
+
+ if (t == 0)
+ t = time(NULL);
+ gmt = &sgmt;
+ *gmt = *gmtime(&t);
+ loc = localtime(&t);
+ dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
+ (loc->tm_min - gmt->tm_min) * 60;
+
+ /*
+ * If the year or julian day is different, we span 00:00 GMT
+ * and must add or subtract a day. Check the year first to
+ * avoid problems when the julian day wraps.
+ */
+ dir = loc->tm_year - gmt->tm_year;
+ if (dir == 0)
+ dir = loc->tm_yday - gmt->tm_yday;
+ dt += dir * 24 * 60 * 60;
+
+ return (dt);
+}
diff --git a/usr.sbin/tcpdump/os-ultrix4.h b/usr.sbin/tcpdump/gmt2local.h
index 1c8a568d043..9ea4f1e845e 100644
--- a/usr.sbin/tcpdump/os-ultrix4.h
+++ b/usr.sbin/tcpdump/gmt2local.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 1993, 1994, 1995, 1996
+ * Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,22 +18,10 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/Attic/os-ultrix4.h,v 1.1 1996/12/12 16:22:45 bitblt Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/gmt2local.h,v 1.1 1999/07/28 20:41:35 jakob Exp $ (LBL)
*/
+#ifndef gmt2local_h
+#define gmt2local_h
-/* Prototypes missing in Ultrix 4 */
-int bcmp(const char *, const char *, u_int);
-void bcopy(const void *, void *, u_int);
-void bzero(void *, u_int);
-void endservent(void);
-int getopt(int, char * const *, const char *);
-#ifdef __STDC__
-struct timeval;
-struct timezone;
+int32_t gmt2local(time_t);
#endif
-int gettimeofday(struct timeval *, struct timezone *);
-int ioctl(int, int, caddr_t);
-int pfopen(char *, int);
-int setlinebuf(FILE *);
-int socket(int, int, int);
-int strcasecmp(const char *, const char *);
diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h
index 2743f7b8d72..3c77af2445a 100644
--- a/usr.sbin/tcpdump/interface.h
+++ b/usr.sbin/tcpdump/interface.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.10 1998/09/22 22:03:00 provos Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.11 1999/07/28 20:41:35 jakob Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -34,8 +34,10 @@ struct tok {
char *s; /* string */
};
+extern int aflag; /* translate network and broadcast addresses */
extern int dflag; /* print filter code */
extern int eflag; /* print ethernet header */
+extern int fflag; /* don't translate "foreign" IP address */
extern int nflag; /* leave addresses as numbers */
extern int Nflag; /* remove domains from printed host names */
extern int qflag; /* quick (shorter) output */
@@ -132,13 +134,11 @@ struct timeval;
#endif
extern void ts_print(const struct timeval *);
-extern int32_t gmt2local(void);
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
extern const char *tok2str(const struct tok *, const char *, int);
extern char *dnaddr_string(u_short);
-extern char *savestr(const char *);
extern void wrapup(int);
@@ -177,6 +177,7 @@ extern void default_print(const u_char *, u_int);
extern void default_print_unaligned(const u_char *, u_int);
extern void dvmrp_print(const u_char *, u_int);
extern void egp_print(const u_char *, u_int, const u_char *);
+extern void enc_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void ether_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern void fddi_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
@@ -196,7 +197,6 @@ extern void null_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void ospf_print(const u_char *, u_int, const u_char *);
extern void pim_print(const u_char *, u_int);
extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
-extern void enc_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void rip_print(const u_char *, u_int);
extern void sl_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void snmp_print(const u_char *, u_int);
diff --git a/usr.sbin/tcpdump/lbl/gnuc.h b/usr.sbin/tcpdump/lbl/gnuc.h
deleted file mode 100644
index b8edbf1ef9a..00000000000
--- a/usr.sbin/tcpdump/lbl/gnuc.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/lbl/Attic/gnuc.h,v 1.2 1997/07/25 20:12:19 mickey Exp $ (LBL) */
-
-/* Define __P() macro, if necessary */
-#ifndef __P
-#ifdef __STDC__
-#define __P(protos) protos
-#else
-#define __P(protos) ()
-#endif
-#endif
-
-/* inline foo */
-#ifdef __GNUC__
-#define inline __inline
-#else
-#define inline
-#endif
-
-/*
- * Handle new and old "dead" routine prototypes
- *
- * For example:
- *
- * __dead void foo(void) __attribute__((volatile));
- *
- */
-#ifdef __GNUC__
-#ifndef __dead
-#define __dead volatile
-#endif
-#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#ifndef __attribute__
-#define __attribute__(args)
-#endif
-#endif
-#else
-#ifndef __dead
-#define __dead
-#endif
-#ifndef __attribute__
-#define __attribute__(args)
-#endif
-#endif
diff --git a/usr.sbin/tcpdump/lbl/os-sunos4.h b/usr.sbin/tcpdump/lbl/os-sunos4.h
deleted file mode 100644
index 5a63ccb71ba..00000000000
--- a/usr.sbin/tcpdump/lbl/os-sunos4.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 1989, 1990, 1993, 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/lbl/Attic/os-sunos4.h,v 1.1 1996/12/12 16:08:23 bitblt Exp $ (LBL)
- */
-
-/* Prototypes missing in SunOS 4 */
-#ifdef FILE
-int _filbuf(FILE *);
-int _flsbuf(u_char, FILE *);
-int fclose(FILE *);
-int fflush(FILE *);
-int fgetc(FILE *);
-int fprintf(FILE *, const char *, ...);
-int fputc(int, FILE *);
-int fputs(const char *, FILE *);
-u_int fread(void *, u_int, u_int, FILE *);
-int fseek(FILE *, long, int);
-u_int fwrite(const void *, u_int, u_int, FILE *);
-int pclose(FILE *);
-void rewind(FILE *);
-void setbuf(FILE *, char *);
-int setlinebuf(FILE *);
-int ungetc(int, FILE *);
-int vfprintf(FILE *, const char *, ...);
-int vprintf(const char *, ...);
-#endif
-
-#if __GNUC__ <= 1
-int read(int, char *, u_int);
-int write(int, char *, u_int);
-#endif
-
-long a64l(const char *);
-#ifdef __STDC__
-struct sockaddr;
-#endif
-int accept(int, struct sockaddr *, int *);
-int bind(int, struct sockaddr *, int);
-int bcmp(const void *, const void *, u_int);
-void bcopy(const void *, void *, u_int);
-void bzero(void *, int);
-int chroot(const char *);
-int close(int);
-void closelog(void);
-int connect(int, struct sockaddr *, int);
-char *crypt(const char *, const char *);
-int daemon(int, int);
-int fchmod(int, int);
-int fchown(int, int, int);
-void endgrent(void);
-void endpwent(void);
-void endservent(void);
-#ifdef __STDC__
-struct ether_addr;
-#endif
-struct ether_addr *ether_aton(const char *);
-int flock(int, int);
-#ifdef __STDC__
-struct stat;
-#endif
-int fstat(int, struct stat *);
-#ifdef __STDC__
-struct statfs;
-#endif
-int fstatfs(int, struct statfs *);
-int fsync(int);
-#ifdef __STDC__
-struct timeb;
-#endif
-int ftime(struct timeb *);
-int ftruncate(int, off_t);
-int getdtablesize(void);
-long gethostid(void);
-int gethostname(char *, int);
-int getopt(int, char * const *, const char *);
-int getpagesize(void);
-char *getpass(char *);
-int getpeername(int, struct sockaddr *, int *);
-int getpriority(int, int);
-#ifdef __STDC__
-struct rlimit;
-#endif
-int getrlimit(int, struct rlimit *);
-int getsockname(int, struct sockaddr *, int *);
-int getsockopt(int, int, int, char *, int *);
-#ifdef __STDC__
-struct timeval;
-struct timezone;
-#endif
-int gettimeofday(struct timeval *, struct timezone *);
-char *getusershell(void);
-char *getwd(char *);
-int initgroups(const char *, int);
-int ioctl(int, int, caddr_t);
-int iruserok(u_long, int, char *, char *);
-int isatty(int);
-int killpg(int, int);
-int listen(int, int);
-#ifdef __STDC__
-struct utmp;
-#endif
-void login(struct utmp *);
-int logout(const char *);
-off_t lseek(int, off_t, int);
-int lstat(const char *, struct stat *);
-int mkstemp(char *);
-char *mktemp(char *);
-int munmap(caddr_t, int);
-void openlog(const char *, int, int);
-void perror(const char *);
-int printf(const char *, ...);
-int puts(const char *);
-long random(void);
-int readlink(const char *, char *, int);
-#ifdef __STDC__
-struct iovec;
-#endif
-int readv(int, struct iovec *, int);
-int recv(int, char *, u_int, int);
-int recvfrom(int, char *, u_int, int, struct sockaddr *, int *);
-int rename(const char *, const char *);
-int rcmd(char **, u_short, char *, char *, char *, int *);
-int rresvport(int *);
-int send(int, char *, u_int, int);
-int sendto(int, char *, u_int, int, struct sockaddr *, int);
-int setenv(const char *, const char *, int);
-int seteuid(int);
-int setpriority(int, int, int);
-int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-int setpgrp(int, int);
-void setpwent(void);
-int setrlimit(int, struct rlimit *);
-void setservent(int);
-int setsockopt(int, int, int, char *, int);
-int shutdown(int, int);
-int sigblock(int);
-void (*signal (int, void (*) (int))) (int);
-int sigpause(int);
-int sigsetmask(int);
-#ifdef __STDC__
-struct sigvec;
-#endif
-int sigvec(int, struct sigvec *, struct sigvec*);
-int snprintf(char *, size_t, const char *, ...);
-int socket(int, int, int);
-int socketpair(int, int, int, int *);
-int symlink(const char *, const char *);
-void srandom(int);
-int sscanf(char *, const char *, ...);
-int stat(const char *, struct stat *);
-int statfs(char *, struct statfs *);
-char *strerror(int);
-int strcasecmp(const char *, const char *);
-#ifdef __STDC__
-struct tm;
-#endif
-int strftime(char *, int, char *, struct tm *);
-int strncasecmp(const char *, const char *, int);
-long strtol(const char *, char **, int);
-void sync(void);
-void syslog(int, const char *, ...);
-int system(const char *);
-long tell(int);
-time_t time(time_t *);
-char *timezone(int, int);
-int tolower(int);
-int toupper(int);
-int truncate(char *, off_t);
-void unsetenv(const char *);
-int vfork(void);
-int vsprintf(char *, const char *, ...);
-int writev(int, struct iovec *, int);
-#ifdef __STDC__
-struct rusage;
-#endif
-int utimes(const char *, struct timeval *);
-#if __GNUC__ <= 1
-int wait(int *);
-pid_t wait3(int *, int, struct rusage *);
-#endif
-
-/* Ugly signal hacking */
-#ifdef SIG_ERR
-#undef SIG_ERR
-#define SIG_ERR (void (*)(int))-1
-#undef SIG_DFL
-#define SIG_DFL (void (*)(int))0
-#undef SIG_IGN
-#define SIG_IGN (void (*)(int))1
-
-#ifdef KERNEL
-#undef SIG_CATCH
-#define SIG_CATCH (void (*)(int))2
-#endif
-#undef SIG_HOLD
-#define SIG_HOLD (void (*)(int))3
-#endif
diff --git a/usr.sbin/tcpdump/llc.h b/usr.sbin/tcpdump/llc.h
index cf1496f7baa..f55dc6b1792 100644
--- a/usr.sbin/tcpdump/llc.h
+++ b/usr.sbin/tcpdump/llc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1993, 1994
+ * Copyright (c) 1993, 1994, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/llc.h,v 1.5 1996/12/12 16:22:52 bitblt Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/llc.h,v 1.6 1999/07/28 20:41:35 jakob Exp $ (LBL)
*/
/*
@@ -79,8 +79,8 @@ struct llc {
#define LLC_RNR 0x0500
#define LLC_REJ 0x0900
-#define LLC_IS_NR(is) (((is) >> 9) & 0x7f)
-#define LLC_I_NS(is) (((is) >> 1) & 0x7f)
+#define LLC_IS_NR(is) (((is) >> 1) & 0x7f)
+#define LLC_I_NS(is) (((is) >> 9) & 0x7f)
#ifndef LLCSAP_NULL
#define LLCSAP_NULL 0x00
diff --git a/usr.sbin/tcpdump/machdep.c b/usr.sbin/tcpdump/machdep.c
index 058fa393aaa..59e6dd44e56 100644
--- a/usr.sbin/tcpdump/machdep.c
+++ b/usr.sbin/tcpdump/machdep.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/machdep.c,v 1.1 1996/12/12 16:22:51 bitblt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/machdep.c,v 1.2 1999/07/28 20:41:35 jakob Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -41,7 +41,7 @@ abort_on_misalignment(char *ebuf)
static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS };
if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) {
- (void)sprintf(ebuf, "setsysinfo: %s", pcap_strerror(errno));
+ (void)sprintf(ebuf, "setsysinfo: errno %d", errno);
return (-1);
}
#endif
diff --git a/usr.sbin/tcpdump/mkdep b/usr.sbin/tcpdump/mkdep
deleted file mode 100644
index 2a9c221b1f1..00000000000
--- a/usr.sbin/tcpdump/mkdep
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/bin/sh -
-#
-# Copyright (c) 1994, 1996
-# The Regents of the University of California. All rights reserved.
-#
-# Redistribution and use in source and binary forms are permitted
-# provided that this notice is preserved and that due credit is given
-# to the University of California at Berkeley. The name of the University
-# may not be used to endorse or promote products derived from this
-# software without specific prior written permission. This software
-# is provided ``as is'' without express or implied warranty.
-#
-# @(#)mkdep.sh 5.11 (Berkeley) 5/5/88
-#
-
-PATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/bin
-export PATH
-
-MAKE=Makefile # default makefile name is "Makefile"
-CC=cc # default C compiler is "cc"
-
-while :
- do case "$1" in
- # -c allows you to specify the C compiler
- -c)
- CC=$2
- shift; shift ;;
-
- # -f allows you to select a makefile name
- -f)
- MAKE=$2
- shift; shift ;;
-
- # the -p flag produces "program: program.c" style dependencies
- # so .o's don't get produced
- -p)
- SED='s;\.o;;'
- shift ;;
- *)
- break ;;
- esac
-done
-
-if [ $# = 0 ] ; then
- echo 'usage: mkdep [-p] [-c cc] [-f makefile] [flags] file ...'
- exit 1
-fi
-
-if [ ! -w $MAKE ]; then
- echo "mkdep: no writeable file \"$MAKE\""
- exit 1
-fi
-
-TMP=/tmp/mkdep$$
-
-trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
-
-cp $MAKE ${MAKE}.bak
-
-sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
-
-cat << _EOF_ >> $TMP
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-
-_EOF_
-
-# If your compiler doesn't have -M, add it. If you can't, the next two
-# lines will try and replace the "cc -M". The real problem is that this
-# hack can't deal with anything that requires a search path, and doesn't
-# even try for anything using bracket (<>) syntax.
-#
-# egrep '^#include[ ]*".*"' /dev/null $* |
-# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
-
-# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
-$CC -M $* |
-sed "
- s; \./; ;g
- $SED" |
-awk '{
- if ($1 != prev) {
- if (rec != "")
- print rec;
- rec = $0;
- prev = $1;
- }
- else {
- if (length(rec $2) > 78) {
- print rec;
- rec = $0;
- }
- else
- rec = rec " " $2
- }
-}
-END {
- print rec
-}' >> $TMP
-
-cat << _EOF_ >> $TMP
-
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
-_EOF_
-
-# copy to preserve permissions
-cp $TMP $MAKE
-rm -f ${MAKE}.bak $TMP
-exit 0
diff --git a/usr.sbin/tcpdump/nfsfh.h b/usr.sbin/tcpdump/nfsfh.h
index 598f815a297..5b2cbc41610 100644
--- a/usr.sbin/tcpdump/nfsfh.h
+++ b/usr.sbin/tcpdump/nfsfh.h
@@ -1,5 +1,5 @@
/*
- * $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/nfsfh.h,v 1.5 1996/12/12 16:22:48 bitblt Exp $
+ * $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/nfsfh.h,v 1.6 1999/07/28 20:41:35 jakob Exp $
*
* nfsfh.h - NFS file handle definitions (for portable use)
*
@@ -29,6 +29,6 @@ typedef struct {
} my_fsid;
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
- dev_eq(a.fsid_dev, b.fsid_dev))
+ dev_eq(a.Fsid_dev, b.Fsid_dev))
extern void Parse_fh(caddr_t *, my_fsid *, ino_t *, char **, char **, int);
diff --git a/usr.sbin/tcpdump/os-sunos4.h b/usr.sbin/tcpdump/os-sunos4.h
deleted file mode 100644
index 8e730313657..00000000000
--- a/usr.sbin/tcpdump/os-sunos4.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 1989, 1990, 1993, 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/Attic/os-sunos4.h,v 1.1 1996/12/12 16:22:46 bitblt Exp $ (LBL)
- */
-
-/* Prototypes missing in SunOS 4 */
-#ifdef FILE
-int _filbuf(FILE *);
-int _flsbuf(u_char, FILE *);
-int fclose(FILE *);
-int fflush(FILE *);
-int fgetc(FILE *);
-int fprintf(FILE *, const char *, ...);
-int fputc(int, FILE *);
-int fputs(const char *, FILE *);
-u_int fread(void *, u_int, u_int, FILE *);
-int fseek(FILE *, long, int);
-u_int fwrite(const void *, u_int, u_int, FILE *);
-int pclose(FILE *);
-void rewind(FILE *);
-void setbuf(FILE *, char *);
-int setlinebuf(FILE *);
-int ungetc(int, FILE *);
-int vfprintf(FILE *, const char *, ...);
-int vprintf(const char *, ...);
-#endif
-
-#if __GNUC__ <= 1
-int read(int, char *, u_int);
-int write(int, char *, u_int);
-#endif
-
-long a64l(const char *);
-#ifdef __STDC__
-struct sockaddr;
-#endif
-int accept(int, struct sockaddr *, int *);
-int bind(int, struct sockaddr *, int);
-int bcmp(const void *, const void *, u_int);
-void bcopy(const void *, void *, u_int);
-void bzero(void *, int);
-int chroot(const char *);
-int close(int);
-void closelog(void);
-int connect(int, struct sockaddr *, int);
-char *crypt(const char *, const char *);
-int daemon(int, int);
-int fchmod(int, int);
-int fchown(int, int, int);
-void endgrent(void);
-void endpwent(void);
-void endservent(void);
-#ifdef __STDC__
-struct ether_addr;
-#endif
-struct ether_addr *ether_aton(const char *);
-int flock(int, int);
-#ifdef __STDC__
-struct stat;
-#endif
-int fstat(int, struct stat *);
-#ifdef __STDC__
-struct statfs;
-#endif
-int fstatfs(int, struct statfs *);
-int fsync(int);
-#ifdef __STDC__
-struct timeb;
-#endif
-int ftime(struct timeb *);
-int ftruncate(int, off_t);
-int getdtablesize(void);
-long gethostid(void);
-int gethostname(char *, int);
-int getopt(int, char * const *, const char *);
-int getpagesize(void);
-char *getpass(char *);
-int getpeername(int, struct sockaddr *, int *);
-int getpriority(int, int);
-#ifdef __STDC__
-struct rlimit;
-#endif
-int getrlimit(int, struct rlimit *);
-int getsockname(int, struct sockaddr *, int *);
-int getsockopt(int, int, int, char *, int *);
-#ifdef __STDC__
-struct timeval;
-struct timezone;
-#endif
-int gettimeofday(struct timeval *, struct timezone *);
-char *getusershell(void);
-char *getwd(char *);
-int initgroups(const char *, int);
-int ioctl(int, int, caddr_t);
-int iruserok(u_long, int, char *, char *);
-int isatty(int);
-int killpg(int, int);
-int listen(int, int);
-#ifdef __STDC__
-struct utmp;
-#endif
-void login(struct utmp *);
-int logout(const char *);
-off_t lseek(int, off_t, int);
-int lstat(const char *, struct stat *);
-int mkstemp(char *);
-char *mktemp(char *);
-int munmap(caddr_t, int);
-void openlog(const char *, int, int);
-void perror(const char *);
-int printf(const char *, ...);
-int puts(const char *);
-long random(void);
-int readlink(const char *, char *, int);
-#ifdef __STDC__
-struct iovec;
-#endif
-int readv(int, struct iovec *, int);
-int recv(int, char *, u_int, int);
-int recvfrom(int, char *, u_int, int, struct sockaddr *, int *);
-int rename(const char *, const char *);
-int rcmd(char **, u_short, char *, char *, char *, int *);
-int rresvport(int *);
-int send(int, char *, u_int, int);
-int sendto(int, char *, u_int, int, struct sockaddr *, int);
-int setenv(const char *, const char *, int);
-int seteuid(int);
-int setpriority(int, int, int);
-int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-int setpgrp(int, int);
-void setpwent(void);
-int setrlimit(int, struct rlimit *);
-void setservent(int);
-int setsockopt(int, int, int, char *, int);
-int shutdown(int, int);
-int sigblock(int);
-void (*signal (int, void (*) (int))) (int);
-int sigpause(int);
-int sigsetmask(int);
-#ifdef __STDC__
-struct sigvec;
-#endif
-int sigvec(int, struct sigvec *, struct sigvec*);
-int snprintf(char *, size_t, const char *, ...);
-int socket(int, int, int);
-int socketpair(int, int, int, int *);
-int symlink(const char *, const char *);
-void srandom(int);
-int sscanf(char *, const char *, ...);
-int stat(const char *, struct stat *);
-int statfs(char *, struct statfs *);
-char *strerror(int);
-int strcasecmp(const char *, const char *);
-#ifdef __STDC__
-struct tm;
-#endif
-int strftime(char *, int, char *, struct tm *);
-int strncasecmp(const char *, const char *, int);
-long strtol(const char *, char **, int);
-void sync(void);
-void syslog(int, const char *, ...);
-int system(const char *);
-long tell(int);
-time_t time(time_t *);
-char *timezone(int, int);
-int tolower(int);
-int toupper(int);
-int truncate(char *, off_t);
-void unsetenv(const char *);
-int vfork(void);
-int vsprintf(char *, const char *, ...);
-int writev(int, struct iovec *, int);
-#ifdef __STDC__
-struct rusage;
-#endif
-int utimes(const char *, struct timeval *);
-#if __GNUC__ <= 1
-int wait(int *);
-pid_t wait3(int *, int, struct rusage *);
-#endif
-
-/* Ugly signal hacking */
-#ifdef SIG_ERR
-#undef SIG_ERR
-#define SIG_ERR (void (*)(int))-1
-#undef SIG_DFL
-#define SIG_DFL (void (*)(int))0
-#undef SIG_IGN
-#define SIG_IGN (void (*)(int))1
-
-#ifdef KERNEL
-#undef SIG_CATCH
-#define SIG_CATCH (void (*)(int))2
-#endif
-#undef SIG_HOLD
-#define SIG_HOLD (void (*)(int))3
-#endif
diff --git a/usr.sbin/tcpdump/ospf.h b/usr.sbin/tcpdump/ospf.h
index c111a9047e9..b6d0ed944b2 100644
--- a/usr.sbin/tcpdump/ospf.h
+++ b/usr.sbin/tcpdump/ospf.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996
+ * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,8 @@
/* ospf_authtype */
#define OSPF_AUTH_NONE 0 /* No auth-data */
#define OSPF_AUTH_SIMPLE 1 /* Simple password */
+#define OSPF_AUTH_MD5 2 /* MD5 authentication */
+#define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */
/* db_flags */
#define OSPF_DB_INIT 0x04 /* */
diff --git a/usr.sbin/tcpdump/parsenfsfh.c b/usr.sbin/tcpdump/parsenfsfh.c
index 5ecc37b5a08..347e7b71b9a 100644
--- a/usr.sbin/tcpdump/parsenfsfh.c
+++ b/usr.sbin/tcpdump/parsenfsfh.c
@@ -9,7 +9,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/parsenfsfh.c,v 1.5 1996/12/12 16:22:44 bitblt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/parsenfsfh.c,v 1.6 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -312,13 +312,14 @@ int ourself; /* true if file handle was generated on this host */
if (sizeof(*fsidp) >= 14) {
if (sizeof(*fsidp) > 14)
memset((char *)fsidp, 0, sizeof(*fsidp));
- memcpy((char *)fsidp, fh, 14); /* just use the whole thing */
+ /* just use the whole thing */
+ memcpy((char *)fsidp, (char *)fh, 14);
}
else {
u_int32_t tempa[4]; /* at least 16 bytes, maybe more */
memset((char *)tempa, 0, sizeof(tempa));
- memcpy((char *)tempa, fh, 14); /* ensure alignment */
+ memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */
fsidp->Fsid_dev.Minor = tempa[0] + (tempa[1]<<1);
fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1);
fsidp->fsid_code = 0;
diff --git a/usr.sbin/tcpdump/print-arp.c b/usr.sbin/tcpdump/print-arp.c
index 56abb3b4984..64dfb5c45a8 100644
--- a/usr.sbin/tcpdump/print-arp.c
+++ b/usr.sbin/tcpdump/print-arp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-arp.c,v 1.6 1997/07/25 20:12:21 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-arp.c,v 1.7 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -37,6 +37,7 @@ struct rtentry;
#include <netinet/in.h>
#include <netinet/if_ether.h>
+#include <memory.h>
#include <stdio.h>
#include <string.h>
diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c
index 9b3731d5c3d..654eb7b66b0 100644
--- a/usr.sbin/tcpdump/print-atalk.c
+++ b/usr.sbin/tcpdump/print-atalk.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-atalk.c,v 1.9 1998/07/13 22:13:46 deraadt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-atalk.c,v 1.10 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -55,6 +55,7 @@ struct rtentry;
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
#include "appletalk.h"
+#include "savestr.h"
static struct tok type2str[] = {
{ ddpRTMP, "rtmp" },
@@ -462,7 +463,7 @@ print_cstring(register const char *cp, register const u_char *ep)
(void)printf("[len=%d]", length);
return (0);
}
- while (--length >= 0) {
+ while ((int)--length >= 0) {
if (cp >= (char *)ep) {
fputs(tstr, stdout);
return (0);
@@ -596,9 +597,11 @@ ataddr_string(u_short atnet, u_char athost)
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
if (athost != 255)
- (void)snprintf(nambuf, sizeof nambuf, "%d.%d", atnet, athost);
+ (void)snprintf(nambuf, sizeof nambuf, "%d.%d.%d",
+ atnet >> 8, atnet & 0xff, athost);
else
- (void)snprintf(nambuf, sizeof nambuf, "%d", atnet);
+ (void)snprintf(nambuf, sizeof nambuf, "%d.%d",
+ atnet >> 8, atnet & 0xff);
tp->name = savestr(nambuf);
return (tp->name);
diff --git a/usr.sbin/tcpdump/print-bootp.c b/usr.sbin/tcpdump/print-bootp.c
index 4020b57214a..111eb13f36d 100644
--- a/usr.sbin/tcpdump/print-bootp.c
+++ b/usr.sbin/tcpdump/print-bootp.c
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-bootp.c,v 1.7 1998/07/08 22:32:03 deraadt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-bootp.c,v 1.8 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -39,6 +39,7 @@ struct rtentry;
#include <netinet/if_ether.h>
#include <ctype.h>
+#include <memory.h>
#include <stdio.h>
#include <string.h>
@@ -145,6 +146,7 @@ bootp_print(register const u_char *cp, u_int length,
fputs(tstr + 1, stdout);
return;
}
+ putchar('"');
}
TCHECK2(bp->bp_file[0], 1); /* check first char only */
if (*bp->bp_file) {
@@ -154,6 +156,7 @@ bootp_print(register const u_char *cp, u_int length,
fputs(tstr + 1, stdout);
return;
}
+ putchar('"');
}
/* Decode the vendor buffer */
diff --git a/usr.sbin/tcpdump/print-domain.c b/usr.sbin/tcpdump/print-domain.c
index 2eab9bdfedb..c9505f26142 100644
--- a/usr.sbin/tcpdump/print-domain.c
+++ b/usr.sbin/tcpdump/print-domain.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-domain.c,v 1.6 1997/07/25 20:12:23 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-domain.c,v 1.7 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -44,8 +44,13 @@ struct rtentry;
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
+#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
+#endif
+#ifdef NOERROR
#undef T_UNSPEC /* SINIX does too */
+#endif
+
#include <arpa/nameser.h>
#include <stdio.h>
@@ -98,9 +103,22 @@ struct rtentry;
#define T_LOC 29 /* Location Information */
#endif
+#ifndef T_UINFO
+#define T_UINFO 100
+#endif
+
+#ifndef T_UID
+#define T_UID 101
+#endif
+
+#ifndef T_GID
+#define T_GID 102
+#endif
+
#ifndef T_UNSPEC
#define T_UNSPEC 103 /* Unspecified format (binary data) */
#endif
+
#ifndef T_UNSPECA
#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
#endif
diff --git a/usr.sbin/tcpdump/print-ether.c b/usr.sbin/tcpdump/print-ether.c
index 7d881e01317..03c560d7973 100644
--- a/usr.sbin/tcpdump/print-ether.c
+++ b/usr.sbin/tcpdump/print-ether.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ether.c,v 1.7 1997/07/27 01:34:34 denny Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ether.c,v 1.8 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -116,7 +116,7 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
* Is it (gag) an 802.3 encapsulation?
*/
extracted_ethertype = 0;
- if (ether_type < ETHERMTU) {
+ if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
/* ether_type not known, print raw packet */
diff --git a/usr.sbin/tcpdump/print-ike.c b/usr.sbin/tcpdump/print-ike.c
new file mode 100644
index 00000000000..de7686cf520
--- /dev/null
+++ b/usr.sbin/tcpdump/print-ike.c
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Format and print ike (isakmp) packets.
+ * By Tero Kivinen <kivinen@ssh.fi>, Tero Mononen <tmo@ssh.fi>,
+ * Tatu Ylonen <ylo@ssh.fi> and Timo J. Rinne <tri@ssh.fi>
+ * in co-operation with SSH Communications Security, Espoo, Finland
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ike.c,v 1.1 1999/07/28 20:41:36 jakob Exp $ (XXX)";
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#ifdef MODEMASK
+#undef MODEMASK /* Solaris sucks */
+#endif
+
+struct isakmp_header {
+ u_char init_cookie[8];
+ u_char resp_cookie[8];
+ u_char nextpayload;
+ u_char version;
+ u_char exgtype;
+ u_char flags;
+ u_char msgid[4];
+ u_int32_t length;
+ u_char payloads[0];
+};
+
+static int isakmp_doi;
+
+#define FLAGS_ENCRYPTION 1
+#define FLAGS_COMMIT 2
+
+#define PAYLOAD_NONE 0
+#define PAYLOAD_SA 1
+#define PAYLOAD_PROPOSAL 2
+#define PAYLOAD_TRANSFORM 3
+#define PAYLOAD_KE 4
+#define PAYLOAD_ID 5
+#define PAYLOAD_CERT 6
+#define PAYLOAD_CERTREQUEST 7
+#define PAYLOAD_HASH 8
+#define PAYLOAD_SIG 9
+#define PAYLOAD_NONCE 10
+#define PAYLOAD_NOTIFICATION 11
+#define PAYLOAD_DELETE 12
+
+#define IPSEC_DOI 1
+
+static void isakmp_pl_print(register u_char type,
+ register u_char *payload,
+ register int paylen);
+
+/*
+ * Print isakmp requests
+ */
+void isakmp_print(register const u_char *cp, register int length)
+{
+ struct isakmp_header *ih;
+ register const u_char *ep;
+ int mode, version, leapind;
+ u_char *payload;
+ u_char nextpayload, np1;
+ u_int paylen;
+ int encrypted;
+
+ encrypted = 0;
+
+#ifdef TCHECK
+#undef TCHECK
+#endif
+#define TCHECK(var, l) if ((u_char *)&(var) > ep - l) goto trunc
+
+ ih = (struct isakmp_header *)cp;
+ /* Note funny sized packets */
+ if (length < 20) {
+ (void)printf(" [len=%d]", length);
+ }
+
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+
+ printf(" isakmp");
+
+ printf(" v%d.%d\n\t", ih->version >> 4, ih->version & 0xf);
+
+ if (ih->flags & FLAGS_ENCRYPTION) {
+ printf(" encrypted");
+ encrypted = 1;
+ }
+
+ if (ih->flags & FLAGS_COMMIT) {
+ printf(" commit");
+ }
+
+ printf(" cookie: %02x%02x%02x%02x%02x%02x%02x%02x->%02x%02x%02x%02x%02x%02x%02x%02x\n\t",
+ ih->init_cookie[0], ih->init_cookie[1],
+ ih->init_cookie[2], ih->init_cookie[3],
+ ih->init_cookie[4], ih->init_cookie[5],
+ ih->init_cookie[6], ih->init_cookie[7],
+ ih->resp_cookie[0], ih->resp_cookie[1],
+ ih->resp_cookie[2], ih->resp_cookie[3],
+ ih->resp_cookie[4], ih->resp_cookie[5],
+ ih->resp_cookie[6], ih->resp_cookie[7]);
+
+ TCHECK(ih->msgid, sizeof(ih->msgid));
+ printf(" msgid:%02x%02x%02x%02x",
+ ih->msgid[0], ih->msgid[1],
+ ih->msgid[2], ih->msgid[3]);
+
+ TCHECK(ih->length, sizeof(ih->length));
+ printf(" length %d", ntohl(ih->length));
+
+ if (ih->version > 16) {
+ printf(" new version");
+ return;
+ }
+
+ /* now, process payloads */
+ payload = ih->payloads;
+ nextpayload = ih->nextpayload;
+
+ /* if encrypted, then open special file for encryption keys */
+ if (encrypted) {
+ /* decrypt XXX */
+ return;
+ }
+
+ while (nextpayload != 0) {
+ np1 = payload[0];
+ paylen = (payload[2] << 8) + payload[3];
+ printf("\n\t\tload: %02x len: %04x",
+ nextpayload, paylen);
+ TCHECK(payload[0], paylen);
+ isakmp_pl_print(nextpayload, payload, paylen);
+ payload += paylen;
+ nextpayload = np1;
+ }
+
+ return;
+
+trunc:
+ fputs(" [|isakmp]", stdout);
+}
+
+void isakmp_sa_print(register u_char *buf, register int len)
+{
+ isakmp_doi = ntohl((*(u_int32_t *)(buf+4)));
+ printf(" SA doi: %d",
+ isakmp_doi, (isakmp_doi == IPSEC_DOI ? "(ipsec)" : ""));
+ printf(" situation\n");
+}
+
+void isakmp_proposal_print(register u_char *buf, register int len)
+{
+ u_char *spis;
+ int spisize, numspi, i;
+
+ spisize = buf[6];
+ numspi = buf[7];
+
+
+ printf(" proposal number: %d protocol: %d spisize: %d #spi: %d",
+ buf[4], buf[5], spisize, numspi);
+
+ spis = buf+8;
+ while (numspi) {
+ printf("\n\t ");
+ for (i=0; i<spisize; i++) {
+ printf("%02x", *spis);
+ spis++;
+ }
+ }
+}
+
+void isakmp_ke_print(register u_char *buf, register int len)
+{
+ if (isakmp_doi != IPSEC_DOI) {
+ printf("KE unknown doi\n");
+ return;
+ }
+}
+
+void isakmp_pl_print(register u_char type,
+ register u_char *buf,
+ register int len)
+{
+ switch(type) {
+ case PAYLOAD_NONE:
+ return;
+ case PAYLOAD_SA:
+ isakmp_sa_print(buf, len);
+ break;
+
+ case PAYLOAD_PROPOSAL:
+ isakmp_proposal_print(buf, len);
+ break;
+
+ case PAYLOAD_TRANSFORM:
+ break;
+
+ case PAYLOAD_KE:
+ isakmp_ke_print(buf, len);
+ break;
+
+ case PAYLOAD_ID:
+ case PAYLOAD_CERT:
+ case PAYLOAD_CERTREQUEST:
+ case PAYLOAD_HASH:
+ case PAYLOAD_SIG:
+ break;
+
+ case PAYLOAD_NONCE:
+#if 0
+ isakmp_nonce_print(buf, len);
+#endif
+ break;
+
+ case PAYLOAD_NOTIFICATION:
+ case PAYLOAD_DELETE:
+ default:
+ }
+}
diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c
index 838d4cb1560..55cca732941 100644
--- a/usr.sbin/tcpdump/print-ip.c
+++ b/usr.sbin/tcpdump/print-ip.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.5 1996/12/12 16:22:35 bitblt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.6 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -55,6 +55,15 @@ static const char rcsid[] =
#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
#endif
+/* Definitions required for ECN
+ for use if the OS running tcpdump does not have ECN */
+#ifndef IPTOS_ECT
+#define IPTOS_ECT 0x02 /* ECN Capable Transport in IP header*/
+#endif
+#ifndef IPTOS_CE
+#define IPTOS_CE 0x01 /* ECN Cong. Experienced in IP header*/
+#endif
+
/* (following from ipmulti/mrouted/prune.h) */
/*
@@ -463,6 +472,20 @@ ip_print(register const u_char *bp, register u_int length)
}
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;
+
default:
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
@@ -489,8 +512,23 @@ ip_print(register const u_char *bp, register u_int length)
} else if (off & IP_DF)
(void)printf(" (DF)");
- if (ip->ip_tos)
- (void)printf(" [tos 0x%x]", (int)ip->ip_tos);
+ if (ip->ip_tos) {
+ (void)printf(" [tos 0x%x", (int)ip->ip_tos);
+ if (ip->ip_tos & (IPTOS_CE|IPTOS_ECT)) {
+ (void)printf(" (");
+ if (ip->ip_tos & IPTOS_ECT) {
+ /* ECN-capable transport */
+ putchar('E');
+ }
+ if (ip->ip_tos & IPTOS_CE) {
+ /* _C_ongestion experienced (ECN) */
+ putchar('C');
+ }
+ (void)printf(")");
+ }
+ (void)printf("]");
+ }
+
if (ip->ip_ttl <= 1)
(void)printf(" [ttl %d]", (int)ip->ip_ttl);
diff --git a/usr.sbin/tcpdump/print-ipsec.c b/usr.sbin/tcpdump/print-ipsec.c
new file mode 100644
index 00000000000..798a460a2d1
--- /dev/null
+++ b/usr.sbin/tcpdump/print-ipsec.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Format and print ipsec (esp/ah) packets.
+ * By Tero Kivinen <kivinen@ssh.fi>, Tero Mononen <tmo@ssh.fi>,
+ * Tatu Ylonen <ylo@ssh.fi> and Timo J. Rinne <tri@ssh.fi>
+ * in co-operation with SSH Communications Security, Espoo, Finland
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ipsec.c,v 1.1 1999/07/28 20:41:36 jakob Exp $ (XXX)";
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcpip.h>
+
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "addrtoname.h"
+#include "interface.h"
+#include "extract.h" /* must come after interface.h */
+
+/*
+ * IPSec/ESP header
+ */
+struct esp_hdr {
+ u_int esp_spi;
+ u_int esp_seq;
+};
+
+void esp_print(register const u_char *bp, register u_int len,
+ register const u_char *bp2)
+{
+ const struct ip *ip;
+ const struct esp_hdr *esp;
+
+ ip = (const struct ip *)bp2;
+ esp = (const struct esp_hdr *)bp;
+
+ (void)printf("esp %s > %s spi 0x%08X seq %d",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst),
+ ntohl(esp->esp_spi), ntohl(esp->esp_seq));
+
+}
+
+/*
+ * IPSec/AH header
+ */
+struct ah_hdr {
+ u_int ah_dummy;
+ u_int ah_spi;
+ u_int ah_seq;
+};
+
+ah_print(register const u_char *bp, register u_int len,
+ register const u_char *bp2)
+{
+ const struct ip *ip;
+ const struct ah_hdr *ah;
+
+ ip = (const struct ip *)bp2;
+ ah = (const struct ah_hdr *)bp;
+
+ (void)printf("ah %s > %s spi 0x%08X seq %d",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst),
+ ntohl(ah->ah_spi), ntohl(ah->ah_seq));
+
+}
diff --git a/usr.sbin/tcpdump/print-isoclns.c b/usr.sbin/tcpdump/print-isoclns.c
index 9538045f9c6..1347db5bc0a 100644
--- a/usr.sbin/tcpdump/print-isoclns.c
+++ b/usr.sbin/tcpdump/print-isoclns.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-isoclns.c,v 1.6 1997/07/25 20:12:25 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-isoclns.c,v 1.7 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -293,7 +293,7 @@ osi_cksum(register const u_char *p, register u_int len,
return 0;
off[0] = off[1] = 0;
- while (--len >= 0) {
+ while ((int)--len >= 0) {
c0 += *p++;
c1 += c0;
c0 %= 255;
diff --git a/usr.sbin/tcpdump/print-krb.c b/usr.sbin/tcpdump/print-krb.c
index db42edeb637..f69d8091bc1 100644
--- a/usr.sbin/tcpdump/print-krb.c
+++ b/usr.sbin/tcpdump/print-krb.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-krb.c,v 1.2 1996/12/12 16:22:33 bitblt Exp $";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-krb.c,v 1.3 1999/07/28 20:41:36 jakob Exp $";
#endif
#include <sys/param.h>
@@ -160,7 +160,7 @@ krb4_print_hdr(const u_char *cp)
{
cp+=2;
-#define PRINT if ((cp=c_print(cp, snapend))==NULL) goto trunc
+#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
TCHECK2(cp, 0);
PRINT;
@@ -184,7 +184,7 @@ krb4_print(const u_char *cp)
u_char type;
u_short len;
-#define PRINT if ((cp=c_print(cp, snapend))==NULL) goto trunc
+#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
/* True if struct krb is little endian */
#define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0)
#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? vtohsp(cp) : ntohsp(cp))
diff --git a/usr.sbin/tcpdump/print-ntp.c b/usr.sbin/tcpdump/print-ntp.c
index 2633f8aa526..d1ef45d0b8c 100644
--- a/usr.sbin/tcpdump/print-ntp.c
+++ b/usr.sbin/tcpdump/print-ntp.c
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ntp.c,v 1.6 1997/07/25 20:12:26 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ntp.c,v 1.7 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -47,7 +47,9 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
+#ifdef MODEMASK
#undef MODEMASK /* Solaris sucks */
+#endif
#include "ntp.h"
static void p_sfix(const struct s_fixedpt *);
diff --git a/usr.sbin/tcpdump/print-null.c b/usr.sbin/tcpdump/print-null.c
index 62340b73926..b8d109c445e 100644
--- a/usr.sbin/tcpdump/print-null.c
+++ b/usr.sbin/tcpdump/print-null.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996
+ * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-null.c,v 1.8 1998/06/26 09:14:50 deraadt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-null.c,v 1.9 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -53,6 +53,10 @@ struct rtentry;
#include "addrtoname.h"
#include "interface.h"
+/*
+ * The DLT_NULL packet header is 4 bytes long. It contains a network
+ * order 32 bit integer that specifies the family, e.g. AF_INET
+ */
#define NULL_HDRLEN 4
#ifndef AF_NS
@@ -62,7 +66,6 @@ struct rtentry;
static void
null_print(const u_char *p, u_int length, u_int family)
{
-
if (nflag) {
/* XXX just dump the header */
return;
diff --git a/usr.sbin/tcpdump/print-ospf.c b/usr.sbin/tcpdump/print-ospf.c
index 319a1e6baff..0443993dc66 100644
--- a/usr.sbin/tcpdump/print-ospf.c
+++ b/usr.sbin/tcpdump/print-ospf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ospf.c,v 1.5 1996/12/12 16:22:30 bitblt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ospf.c,v 1.6 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -215,11 +215,7 @@ ospf_print_lsa(register const struct lsa *lsap)
TCHECK(lsap->lsa_un.un_rla.rla_link);
rlp = lsap->lsa_un.un_rla.rla_link;
while (j--) {
- register struct rlalink *rln =
- (struct rlalink *)((u_char *)(rlp + 1) +
- ((rlp->link_toscount) * sizeof(*tosp)));
-
- TCHECK(*rln);
+ TCHECK(*rlp);
printf(" {"); /* } (ctags) */
switch (rlp->link_type) {
@@ -262,7 +258,8 @@ ospf_print_lsa(register const struct lsa *lsap)
}
/* { (ctags) */
printf(" }");
- rlp = rln;
+ rlp = (struct rlalink *)((u_char *)(rlp + 1) +
+ ((rlp->link_toscount) * sizeof(*tosp)));
}
break;
@@ -514,6 +511,13 @@ ospf_print(register const u_char *bp, register u_int length,
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
+ /* XXX Before we do anything else, strip off the MD5 trailer */
+ TCHECK(op->ospf_authtype);
+ if (ntohs(op->ospf_authtype) == OSPF_AUTH_MD5) {
+ length -= OSPF_AUTH_MD5_LEN;
+ snapend -= OSPF_AUTH_MD5_LEN;
+ }
+
/* If the type is valid translate it, or just print the type */
/* value. If it's not valid, say so and return */
TCHECK(op->ospf_type);
@@ -555,6 +559,10 @@ ospf_print(register const u_char *bp, register u_int length,
printf("\"");
break;
+ case OSPF_AUTH_MD5:
+ printf(" auth MD5");
+ break;
+
default:
printf(" ??authtype-%d??", ntohs(op->ospf_authtype));
return;
diff --git a/usr.sbin/tcpdump/print-sunrpc.c b/usr.sbin/tcpdump/print-sunrpc.c
index 876401033a7..a822041db3a 100644
--- a/usr.sbin/tcpdump/print-sunrpc.c
+++ b/usr.sbin/tcpdump/print-sunrpc.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.7 1998/07/14 00:01:11 deraadt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.8 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -119,7 +119,7 @@ progstr(prog)
{
register struct rpcent *rp;
static char buf[32];
- static lastprog = 0;
+ static int lastprog = 0;
if (lastprog != 0 && prog == lastprog)
return (buf);
diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c
index 55aade745f4..37a9dbbd959 100644
--- a/usr.sbin/tcpdump/print-tcp.c
+++ b/usr.sbin/tcpdump/print-tcp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.6 1998/09/22 22:03:01 provos Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-tcp.c,v 1.7 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -75,6 +75,15 @@ static const char rcsid[] =
#define TCPOPT_CCECHO 13 /* T/TCP CC options (rfc1644) */
#endif
+/* Definitions required for ECN
+ for use if the OS running tcpdump does not have ECN */
+#ifndef TH_ECNECHO
+#define TH_ECNECHO 0x40 /* ECN Echo in tcp header */
+#endif
+#ifndef TH_CWR
+#define TH_CWR 0x80 /* ECN Cwnd Reduced in tcp header*/
+#endif
+
struct tha {
struct in_addr src;
struct in_addr dst;
@@ -95,6 +104,7 @@ struct tcp_seq_hash {
static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
+#define NETBIOS_SSN_PORT 139
void
tcp_print(register const u_char *bp, register u_int length,
@@ -134,7 +144,8 @@ tcp_print(register const u_char *bp, register u_int length,
(void)printf("tcp %d", length - tp->th_off * 4);
return;
}
- if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) {
+ if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|
+ TH_ECNECHO|TH_CWR)) {
if (flags & TH_SYN)
putchar('S');
if (flags & TH_FIN)
@@ -143,6 +154,10 @@ tcp_print(register const u_char *bp, register u_int length,
putchar('R');
if (flags & TH_PUSH)
putchar('P');
+ if (flags & TH_CWR)
+ putchar('W'); /* congestion _W_indow reduced (ECN) */
+ if (flags & TH_ECNECHO)
+ putchar('E'); /* ecn _E_cho sent (ECN) */
} else
putchar('.');
diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c
index 373d30b3b5b..3f67424227d 100644
--- a/usr.sbin/tcpdump/print-udp.c
+++ b/usr.sbin/tcpdump/print-udp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-udp.c,v 1.8 1998/06/25 19:42:47 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-udp.c,v 1.9 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -286,6 +286,11 @@ rtcp_print(const u_char *hdr, const u_char *ep)
#define SNMPTRAP_PORT 162 /*XXX*/
#define RIP_PORT 520 /*XXX*/
#define KERBEROS_SEC_PORT 750 /*XXX*/
+#define ISAKMP_PORT 500 /*XXX*/
+#define ISAKMP_UPORT1 7500 /*XXX*/
+#define ISAKMP_UPORT2 8500 /*XXX*/
+#define NETBIOS_NS_PORT 137 /*XXX*/
+#define NETBIOS_DGRAM_PORT 138 /*XXX*/
#define OLD_RADIUS_AUTH_PORT 1645
#define OLD_RADIUS_ACCT_PORT 1646
#define RADIUS_AUTH_PORT 1812
@@ -433,6 +438,10 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
ntp_print((const u_char *)(up + 1), length);
else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
krb_print((const void *)(up + 1), length);
+ else if (ISPORT(ISAKMP_PORT) ||
+ ISPORT(ISAKMP_UPORT1) ||
+ ISPORT(ISAKMP_UPORT2))
+ isakmp_print((const u_char *)(up + 1), length);
else if (ISPORT(OLD_RADIUS_AUTH_PORT) ||
ISPORT(OLD_RADIUS_ACCT_PORT) ||
ISPORT(RADIUS_AUTH_PORT) ||
diff --git a/usr.sbin/tcpdump/os-solaris2.h b/usr.sbin/tcpdump/savestr.c
index f5ac55b21b8..d3c8df5f3e8 100644
--- a/usr.sbin/tcpdump/os-solaris2.h
+++ b/usr.sbin/tcpdump/savestr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1993, 1994, 1995, 1996
+ * Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -17,38 +17,48 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/Attic/os-solaris2.h,v 1.1 1996/12/12 16:22:46 bitblt Exp $ (LBL)
*/
-/* Prototypes missing in SunOS 5 */
-int daemon(int, int);
-int dn_expand(u_char *, u_char *, u_char *, u_char *, int);
-int dn_skipname(u_char *, u_char *);
-int flock(int, int);
-int getdtablesize(void);
-int gethostname(char *, int);
-int getpagesize(void);
-char *getusershell(void);
-char *getwd(char *);
-int iruserok(u_int, int, char *, char *);
-#ifdef __STDC__
-struct utmp;
-void login(struct utmp *);
-#endif
-int logout(const char *);
-int res_query(char *, int, int, u_char *, int);
-int setenv(const char *, const char *, int);
-#if defined(_STDIO_H) && defined(HAVE_SETLINEBUF)
-int setlinebuf(FILE *);
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/savestr.c,v 1.1 1999/07/28 20:41:36 jakob Exp $ (LBL)";
#endif
-int sigblock(int);
-int sigsetmask(int);
-char *strerror(int);
-int snprintf(char *, size_t, const char *, ...);
-int strcasecmp(const char *, const char *);
-void unsetenv(const char *);
-#ifdef __STDC__
-struct timeval;
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gnuc.h"
+#ifdef HAVE_OS_PROTO_H
+#include "os-proto.h"
#endif
-int utimes(const char *, struct timeval *);
+
+#include "savestr.h"
+
+/* A replacement for strdup() that cuts down on malloc() overhead */
+char *
+savestr(register const char *str)
+{
+ register u_int size;
+ register char *p;
+ static char *strptr = NULL;
+ static u_int strsize = 0;
+
+ size = strlen(str) + 1;
+ if (size > strsize) {
+ strsize = 1024;
+ if (strsize < size)
+ strsize = size;
+ strptr = (char *)malloc(strsize);
+ if (strptr == NULL) {
+ fprintf(stderr, "savestr: malloc\n");
+ exit(1);
+ }
+ }
+ (void)strcpy(strptr, str);
+ p = strptr;
+ strptr += size;
+ strsize -= size;
+ return (p);
+}
diff --git a/usr.sbin/tcpdump/lbl/os-solaris2.h b/usr.sbin/tcpdump/savestr.h
index 4620dfd9876..37e0d6d719b 100644
--- a/usr.sbin/tcpdump/lbl/os-solaris2.h
+++ b/usr.sbin/tcpdump/savestr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1993, 1994, 1995, 1996
+ * Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,37 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/lbl/Attic/os-solaris2.h,v 1.1 1996/12/12 16:08:23 bitblt Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/savestr.h,v 1.1 1999/07/28 20:41:36 jakob Exp $ (LBL)
*/
-/* Prototypes missing in SunOS 5 */
-int daemon(int, int);
-int dn_expand(u_char *, u_char *, u_char *, u_char *, int);
-int dn_skipname(u_char *, u_char *);
-int flock(int, int);
-int getdtablesize(void);
-int gethostname(char *, int);
-int getpagesize(void);
-char *getusershell(void);
-char *getwd(char *);
-int iruserok(u_int, int, char *, char *);
-#ifdef __STDC__
-struct utmp;
-void login(struct utmp *);
-#endif
-int logout(const char *);
-int res_query(char *, int, int, u_char *, int);
-int setenv(const char *, const char *, int);
-#if defined(_STDIO_H) && defined(HAVE_SETLINEBUF)
-int setlinebuf(FILE *);
-#endif
-int sigblock(int);
-int sigsetmask(int);
-char *strerror(int);
-int snprintf(char *, size_t, const char *, ...);
-int strcasecmp(const char *, const char *);
-void unsetenv(const char *);
-#ifdef __STDC__
-struct timeval;
-#endif
-int utimes(const char *, struct timeval *);
+extern char *savestr(const char *);
diff --git a/usr.sbin/tcpdump/setsignal.c b/usr.sbin/tcpdump/setsignal.c
new file mode 100644
index 00000000000..e7ee4297f75
--- /dev/null
+++ b/usr.sbin/tcpdump/setsignal.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/setsignal.c,v 1.1 1999/07/28 20:41:36 jakob Exp $ (LBL)";
+#endif
+
+#include <sys/types.h>
+
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
+#include <signal.h>
+#ifdef HAVE_SIGACTION
+#include <string.h>
+#endif
+
+#include "gnuc.h"
+#ifdef HAVE_OS_PROTO_H
+#include "os-proto.h"
+#endif
+
+#include "setsignal.h"
+
+/*
+ * An os independent signal() with BSD semantics, e.g. the signal
+ * catcher is restored following service of the signal.
+ *
+ * When sigset() is available, signal() has SYSV semantics and sigset()
+ * has BSD semantics and call interface. Unfortunately, Linux does not
+ * have sigset() so we use the more complicated sigaction() interface
+ * there.
+ *
+ * Did I mention that signals suck?
+ */
+RETSIGTYPE
+(*setsignal (int sig, RETSIGTYPE (*func)(int)))(int)
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction old, new;
+
+ memset(&new, 0, sizeof(new));
+ new.sa_handler = func;
+#ifdef SA_RESTART
+ new.sa_flags |= SA_RESTART;
+#endif
+ if (sigaction(sig, &new, &old) < 0)
+ return (SIG_ERR);
+ return (old.sa_handler);
+
+#else
+#ifdef HAVE_SIGSET
+ return (sigset(sig, func));
+#else
+ return (signal(sig, func));
+#endif
+#endif
+}
+
diff --git a/usr.sbin/tcpdump/lbl/os-ultrix4.h b/usr.sbin/tcpdump/setsignal.h
index 34099fb9ac5..996a61446c9 100644
--- a/usr.sbin/tcpdump/lbl/os-ultrix4.h
+++ b/usr.sbin/tcpdump/setsignal.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 1993, 1994, 1995, 1996
+ * Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,22 +18,10 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/lbl/Attic/os-ultrix4.h,v 1.1 1996/12/12 16:08:24 bitblt Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/setsignal.h,v 1.1 1999/07/28 20:41:36 jakob Exp $ (LBL)
*/
+#ifndef setsignal_h
+#define setsignal_h
-/* Prototypes missing in Ultrix 4 */
-int bcmp(const char *, const char *, u_int);
-void bcopy(const void *, void *, u_int);
-void bzero(void *, u_int);
-void endservent(void);
-int getopt(int, char * const *, const char *);
-#ifdef __STDC__
-struct timeval;
-struct timezone;
+RETSIGTYPE (*setsignal(int, RETSIGTYPE (*)(int)))(int);
#endif
-int gettimeofday(struct timeval *, struct timezone *);
-int ioctl(int, int, caddr_t);
-int pfopen(char *, int);
-int setlinebuf(FILE *);
-int socket(int, int, int);
-int strcasecmp(const char *, const char *);
diff --git a/usr.sbin/tcpdump/strcasecmp.c b/usr.sbin/tcpdump/strcasecmp.c
deleted file mode 100644
index f2ac0771318..00000000000
--- a/usr.sbin/tcpdump/strcasecmp.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific written prior permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-
-#include "interface.h"
-
-/*
- * This array is designed for mapping upper and lower case letter
- * together for a case independent comparison. The mappings are
- * based upon ascii character sequences.
- */
-static u_char charmap[] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
-};
-
-int
-strcasecmp(s1, s2)
- const char *s1, *s2;
-{
- register u_char *cm = charmap,
- *us1 = (u_char *)s1,
- *us2 = (u_char *)s2;
-
- while (cm[*us1] == cm[*us2++])
- if (*us1++ == '\0')
- return(0);
- return(cm[*us1] - cm[*--us2]);
-}
-
-int
-strncasecmp(s1, s2, n)
- const char *s1, *s2;
- register int n;
-{
- register u_char *cm = charmap,
- *us1 = (u_char *)s1,
- *us2 = (u_char *)s2;
-
- while (--n >= 0 && cm[*us1] == cm[*us2++])
- if (*us1++ == '\0')
- return(0);
- return(n < 0 ? 0 : cm[*us1] - cm[*--us2]);
-}
diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8
index 76d1a6d5582..68e3f4c062d 100644
--- a/usr.sbin/tcpdump/tcpdump.8
+++ b/usr.sbin/tcpdump/tcpdump.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tcpdump.8,v 1.18 1999/07/09 13:35:54 aaron Exp $
+.\" $OpenBSD: tcpdump.8,v 1.19 1999/07/28 20:41:37 jakob Exp $
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996
.\" The Regents of the University of California. All rights reserved.
@@ -27,7 +27,7 @@
.Nd dump traffic on a network
.Sh SYNOPSIS
.Nm tcpdump
-.Op Fl deflnNOpqStvx
+.Op Fl adeflnNOpqStvxX
.Op Fl c Ar count
.Op Fl F Ar file
.Op Fl i Ar interface
@@ -45,6 +45,8 @@ You must have read access to
.Pa /dev/bpf\&* .
.Sh OPTIONS
.Bl -tag -width "-ddd"
+.It Fl a
+Attempt to convert network and broadcast addresses to names.
.It Fl c Ar count
Exit after receiving
.Ar count
@@ -221,6 +223,10 @@ in hex.
The smaller of the entire packet or
.Ar snaplen
bytes will be printed.
+.It Fl X
+Like
+.Fl x
+but dumps the packet in emacs-hexl like format.
.It Ar expression
selects which packets will be dumped. If no
.Ar expression
@@ -1110,7 +1116,11 @@ is some combination of
.Pq Tn PUSH ,
or
.Sq R
-.Pq Tn RST
+.Pq Tn RST ,
+.Sq W
+.Pq Tn congestion Window reduced ,
+.Sq E
+.Pq Tn ecn ECHO
or a single
.Ql \&.
.Pq no flags .
@@ -1835,4 +1845,3 @@ but is not true for protocols such as
.Tn ISO CLNS .
Therefore, the filter may inadvertently accept certain packets that
do not properly match the filter expression.
-
diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c
index 8bd3e9b425a..88f177405c1 100644
--- a/usr.sbin/tcpdump/tcpdump.c
+++ b/usr.sbin/tcpdump/tcpdump.c
@@ -24,7 +24,7 @@ static const char copyright[] =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.12 1999/06/29 20:33:29 deraadt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.13 1999/07/28 20:41:37 jakob Exp $ (LBL)";
#endif
/*
@@ -50,21 +50,25 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "machdep.h"
+#include "setsignal.h"
+#include "gmt2local.h"
+int aflag; /* translate network and broadcast addresses */
+int dflag; /* print filter code */
+int eflag; /* print ethernet header */
int fflag; /* don't translate "foreign" IP address */
int nflag; /* leave addresses as numbers */
int Nflag; /* remove domains from printed host names */
+int Oflag = 1; /* run filter code optimizer */
int pflag; /* don't go promiscuous */
int qflag; /* quick (shorter) output */
+int Sflag; /* print raw TCP sequence numbers */
int tflag = 1; /* print packet arrival time */
-int eflag; /* print ethernet header */
int vflag; /* verbose */
int xflag; /* print packet in hex */
-int Oflag = 1; /* run filter code optimizer */
-int Sflag; /* print raw TCP sequence numbers */
-int packettype;
+int Xflag; /* print packet in emacs-hexl style */
-int dflag; /* print filter code */
+int packettype;
char *program_name;
@@ -100,7 +104,6 @@ static struct printer printers[] = {
{ atm_if_print, DLT_ATM_RFC1483 },
{ null_if_print, DLT_LOOP },
{ enc_if_print, DLT_ENC },
- { null_if_print, DLT_LOOP },
{ NULL, 0 },
};
@@ -131,6 +134,7 @@ main(int argc, char **argv)
register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName;
pcap_handler printer;
struct bpf_program fcode;
+ RETSIGTYPE (*oldhandler)(int);
u_char *pcap_userdata;
char ebuf[PCAP_ERRBUF_SIZE];
@@ -148,8 +152,13 @@ main(int argc, char **argv)
error("%s", ebuf);
opterr = 0;
- while ((op = getopt(argc, argv, "c:defF:i:lnNOpqr:s:StT:vw:xY")) != -1)
+ while ((op = getopt(argc, argv, "ac:defF:i:lnNOpqr:s:StT:vw:xXY")) != -1)
switch (op) {
+
+ case 'a':
+ ++aflag;
+ break;
+
case 'c':
cnt = atoi(optarg);
if (cnt <= 0)
@@ -261,13 +270,18 @@ main(int argc, char **argv)
++xflag;
break;
+ case 'X':
+ ++Xflag;
+ if (xflag == 0) ++xflag;
+ break;
+
default:
usage();
/* NOTREACHED */
}
if (tflag > 0)
- thiszone = gmt2local();
+ thiszone = gmt2local(0);
if (RFileName != NULL) {
/*
@@ -320,11 +334,13 @@ main(int argc, char **argv)
bpf_dump(&fcode, dflag);
exit(0);
}
- init_addrtoname(fflag, localnet, netmask);
+ init_addrtoname(localnet, netmask);
- (void)signal(SIGTERM, cleanup);
- (void)signal(SIGINT, cleanup);
- (void)signal(SIGHUP, cleanup);
+ (void)setsignal(SIGTERM, cleanup);
+ (void)setsignal(SIGINT, cleanup);
+ /* Cooperate with nohup(1) */
+ if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
+ (void)setsignal(SIGHUP, oldhandler);
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
@@ -375,6 +391,55 @@ cleanup(int signo)
exit(0);
}
+/* dump the buffer in `emacs-hexl' style */
+void
+default_print_hexl(const u_char *cp, unsigned int length, unsigned int offset)
+{
+ unsigned int i, j, jm;
+ int c;
+ char ln[128];
+
+ printf("\n");
+ for (i = 0; i < length; i += 0x10) {
+ snprintf(ln,
+ sizeof(ln),
+ " %04x: ", (unsigned int)(i + offset));
+ jm = length - i;
+ jm = jm > 16 ? 16 : jm;
+
+ for (j = 0; j < jm; j++) {
+ if ((j % 2) == 1)
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ "%02x ", (unsigned int)cp[i+j]);
+ else
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ "%02x", (unsigned int)cp[i+j]);
+ }
+ for (; j < 16; j++) {
+ if ((j % 2) == 1)
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ " ");
+ else
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ " ");
+ }
+
+ snprintf(ln + strlen(ln), sizeof(ln) - strlen(ln), " ");
+ for (j = 0; j < jm; j++) {
+ c = cp[i+j];
+ c = isprint(c) ? c : '.';
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ "%c", c);
+ }
+ printf("%s\n", ln);
+ }
+}
+
/* Like default_print() but data need not be aligned */
void
default_print_unaligned(register const u_char *cp, register u_int length)
@@ -382,18 +447,24 @@ default_print_unaligned(register const u_char *cp, register u_int length)
register u_int i, s;
register int nshorts;
- nshorts = (u_int) length / sizeof(u_short);
- i = 0;
- while (--nshorts >= 0) {
- if ((i++ % 8) == 0)
- (void)printf("\n\t\t\t");
- s = *cp++;
- (void)printf(" %02x%02x", s, *cp++);
- }
- if (length & 1) {
- if ((i % 8) == 0)
- (void)printf("\n\t\t\t");
- (void)printf(" %02x", *cp);
+ if (Xflag) {
+ /* dump the buffer in `emacs-hexl' style */
+ default_print_hexl(cp, length, 0);
+ } else {
+ /* dump the buffer in old tcpdump style */
+ nshorts = (u_int) length / sizeof(u_short);
+ i = 0;
+ while (--nshorts >= 0) {
+ if ((i++ % 8) == 0)
+ (void)printf("\n\t\t\t");
+ s = *cp++;
+ (void)printf(" %02x%02x", s, *cp++);
+ }
+ if (length & 1) {
+ if ((i % 8) == 0)
+ (void)printf("\n\t\t\t");
+ (void)printf(" %02x", *cp);
+ }
}
}
@@ -404,22 +475,28 @@ default_print(register const u_char *bp, register u_int length)
register u_int i;
register int nshorts;
- if ((long)bp & 1) {
- default_print_unaligned(bp, length);
- return;
- }
- sp = (u_short *)bp;
- nshorts = (u_int) length / sizeof(u_short);
- i = 0;
- while (--nshorts >= 0) {
- if ((i++ % 8) == 0)
- (void)printf("\n\t\t\t");
- (void)printf(" %04x", ntohs(*sp++));
- }
- if (length & 1) {
- if ((i % 8) == 0)
- (void)printf("\n\t\t\t");
- (void)printf(" %02x", *(u_char *)sp);
+ if (Xflag) {
+ /* dump the buffer in `emacs-hexl' style */
+ default_print_hexl(bp, length, 0);
+ } else {
+ /* dump the buffer in old tcpdump style */
+ if ((long)bp & 1) {
+ default_print_unaligned(bp, length);
+ return;
+ }
+ sp = (u_short *)bp;
+ nshorts = (u_int) length / sizeof(u_short);
+ i = 0;
+ while (--nshorts >= 0) {
+ if ((i++ % 8) == 0)
+ (void)printf("\n\t\t\t");
+ (void)printf(" %04x", ntohs(*sp++));
+ }
+ if (length & 1) {
+ if ((i % 8) == 0)
+ (void)printf("\n\t\t\t");
+ (void)printf(" %02x", *(u_char *)sp);
+ }
}
}
@@ -428,9 +505,9 @@ usage(void)
{
extern char version[];
- (void)fprintf(stderr, "Version %s\n", version);
+ (void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr,
-"Usage: tcpdump [-deflnNOpqStvx] [-c count] [ -F file ]\n");
+"Usage: tcpdump [-adeflnNOpqStvxX] [-c count] [ -F file ]\n");
(void)fprintf(stderr,
"\t\t[ -i interface ] [ -r file ] [ -s snaplen ]\n");
(void)fprintf(stderr,
diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c
index d2883300108..fff5634038a 100644
--- a/usr.sbin/tcpdump/util.c
+++ b/usr.sbin/tcpdump/util.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.6 1997/07/25 20:12:28 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.7 1999/07/28 20:41:37 jakob Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -246,31 +246,6 @@ copy_argv(register char **argv)
return buf;
}
-/* A replacement for strdup() that cuts down on malloc() overhead */
-char *
-savestr(register const char *str)
-{
- register u_int size;
- register char *p;
- static char *strptr = NULL;
- static u_int strsize = 0;
-
- size = strlen(str) + 1;
- if (size > strsize) {
- strsize = 1024;
- if (strsize < size)
- strsize = size;
- strptr = (char *)malloc(strsize);
- if (strptr == NULL)
- error("savestr: malloc");
- }
- (void)strcpy(strptr, str);
- p = strptr;
- strptr += size;
- strsize -= size;
- return (p);
-}
-
char *
read_infile(char *fname)
{
@@ -295,35 +270,3 @@ read_infile(char *fname)
return (cp);
}
-
-/*
- * Returns the difference between gmt and local time in seconds.
- * Use gmtime() and localtime() to keep things simple.
- */
-int32_t
-gmt2local(void)
-{
- register int dt, dir;
- register struct tm *gmt, *loc;
- time_t t;
- struct tm sgmt;
-
- t = time(NULL);
- gmt = &sgmt;
- *gmt = *gmtime(&t);
- loc = localtime(&t);
- dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
- (loc->tm_min - gmt->tm_min) * 60;
-
- /*
- * If the year or julian day is different, we span 00:00 GMT
- * and must add or subtract a day. Check the year first to
- * avoid problems when the julian day wraps.
- */
- dir = loc->tm_year - gmt->tm_year;
- if (dir == 0)
- dir = loc->tm_yday - gmt->tm_yday;
- dt += dir * 24 * 60 * 60;
-
- return (dt);
-}
diff --git a/usr.sbin/tcpdump/version.c b/usr.sbin/tcpdump/version.c
index 51a2b5780b6..81b655cdfe0 100644
--- a/usr.sbin/tcpdump/version.c
+++ b/usr.sbin/tcpdump/version.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: version.c,v 1.4 1996/07/13 11:01:35 mickey Exp $ */
+/* $OpenBSD: version.c,v 1.5 1999/07/28 20:41:37 jakob Exp $ */
/* $NetBSD: version.c,v 1.3 1996/05/20 00:41:20 fvdl Exp $ */
-char version[] = "3.2.0";
+char version[] = "3.4.0";