summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>2001-04-03 07:45:48 +0000
committerfenner <fenner@FreeBSD.org>2001-04-03 07:45:48 +0000
commitace14a2b50f2cc05c079d0b9137b49066dbb1206 (patch)
tree4953fdd47c44b8ec88d34a4db7b698841365e22f
parent54c4a9c9f2aca2e032cbf41f5eb012e2e9628dd4 (diff)
downloadFreeBSD-src-ace14a2b50f2cc05c079d0b9137b49066dbb1206.zip
FreeBSD-src-ace14a2b50f2cc05c079d0b9137b49066dbb1206.tar.gz
Virgin import of tcpdump.org tcpdump v3.6.2
-rw-r--r--contrib/tcpdump/.cvsignore11
-rw-r--r--contrib/tcpdump/CHANGES41
-rw-r--r--contrib/tcpdump/CREDITS59
-rw-r--r--contrib/tcpdump/FILES95
-rw-r--r--contrib/tcpdump/INSTALL65
-rw-r--r--contrib/tcpdump/LICENSE19
-rw-r--r--contrib/tcpdump/Makefile-devel-adds22
-rw-r--r--contrib/tcpdump/Makefile.in62
-rw-r--r--contrib/tcpdump/PLATFORMS8
-rw-r--r--contrib/tcpdump/README58
-rw-r--r--contrib/tcpdump/TODO6
-rw-r--r--contrib/tcpdump/VERSION2
-rw-r--r--contrib/tcpdump/acconfig.h28
-rw-r--r--contrib/tcpdump/aclocal.m436
-rw-r--r--contrib/tcpdump/addrtoname.c28
-rw-r--r--contrib/tcpdump/ah.h57
-rw-r--r--contrib/tcpdump/appletalk.h60
-rw-r--r--contrib/tcpdump/bootp.h220
-rw-r--r--contrib/tcpdump/bpf_dump.c4
-rw-r--r--contrib/tcpdump/chdlc.h27
-rwxr-xr-xcontrib/tcpdump/config.guess905
-rw-r--r--contrib/tcpdump/config.h.in85
-rwxr-xr-xcontrib/tcpdump/config.sub565
-rwxr-xr-xcontrib/tcpdump/configure1432
-rwxr-xr-xcontrib/tcpdump/configure.in233
-rw-r--r--contrib/tcpdump/decnet.h18
-rw-r--r--contrib/tcpdump/dhcp6.h35
-rw-r--r--contrib/tcpdump/dhcp6opt.h7
-rw-r--r--contrib/tcpdump/esp.h68
-rw-r--r--contrib/tcpdump/ether.h59
-rw-r--r--contrib/tcpdump/ethertype.h29
-rw-r--r--contrib/tcpdump/extract.h34
-rw-r--r--contrib/tcpdump/fddi.h9
-rw-r--r--contrib/tcpdump/gmt2local.c3
-rw-r--r--contrib/tcpdump/icmp6.h412
-rw-r--r--contrib/tcpdump/igrp.h37
-rw-r--r--contrib/tcpdump/interface.h97
-rw-r--r--contrib/tcpdump/ip.h159
-rw-r--r--contrib/tcpdump/ip6.h195
-rw-r--r--contrib/tcpdump/ipsec_doi.h39
-rw-r--r--contrib/tcpdump/ipx.h22
-rw-r--r--contrib/tcpdump/isakmp.h71
-rw-r--r--contrib/tcpdump/l2tp.h25
-rw-r--r--contrib/tcpdump/lane.h10
-rw-r--r--contrib/tcpdump/lbl/os-solaris2.h26
-rw-r--r--contrib/tcpdump/llc.h34
-rw-r--r--contrib/tcpdump/machdep.c6
-rw-r--r--contrib/tcpdump/machdep.h4
-rw-r--r--contrib/tcpdump/missing/addrinfo.h24
-rw-r--r--contrib/tcpdump/missing/getaddrinfo.c42
-rw-r--r--contrib/tcpdump/missing/getnameinfo.c18
-rw-r--r--contrib/tcpdump/missing/inet_aton.c4
-rw-r--r--contrib/tcpdump/missing/inet_ntop.c4
-rw-r--r--contrib/tcpdump/missing/inet_pton.c4
-rw-r--r--contrib/tcpdump/missing/snprintf.c628
-rw-r--r--contrib/tcpdump/missing/strlcat.c78
-rw-r--r--contrib/tcpdump/missing/strlcpy.c75
-rw-r--r--contrib/tcpdump/nameser.h254
-rw-r--r--contrib/tcpdump/nfs.h4
-rw-r--r--contrib/tcpdump/nfsfh.h3
-rw-r--r--contrib/tcpdump/ntp.h6
-rw-r--r--contrib/tcpdump/ospf.h53
-rw-r--r--contrib/tcpdump/ospf6.h26
-rw-r--r--contrib/tcpdump/parsenfsfh.c23
-rw-r--r--contrib/tcpdump/ppp.h11
-rw-r--r--contrib/tcpdump/print-ah.c35
-rw-r--r--contrib/tcpdump/print-arp.c82
-rw-r--r--contrib/tcpdump/print-ascii.c8
-rw-r--r--contrib/tcpdump/print-atalk.c89
-rw-r--r--contrib/tcpdump/print-atm.c19
-rw-r--r--contrib/tcpdump/print-bgp.c129
-rw-r--r--contrib/tcpdump/print-bootp.c101
-rw-r--r--contrib/tcpdump/print-bxxp.c82
-rw-r--r--contrib/tcpdump/print-cdp.c187
-rw-r--r--contrib/tcpdump/print-chdlc.c43
-rw-r--r--contrib/tcpdump/print-cip.c91
-rw-r--r--contrib/tcpdump/print-cnfp.c181
-rw-r--r--contrib/tcpdump/print-decnet.c13
-rw-r--r--contrib/tcpdump/print-dhcp6.c173
-rw-r--r--contrib/tcpdump/print-domain.c407
-rw-r--r--contrib/tcpdump/print-dvmrp.c8
-rw-r--r--contrib/tcpdump/print-egp.c6
-rw-r--r--contrib/tcpdump/print-esp.c70
-rw-r--r--contrib/tcpdump/print-ether.c78
-rw-r--r--contrib/tcpdump/print-fddi.c31
-rw-r--r--contrib/tcpdump/print-frag6.c17
-rw-r--r--contrib/tcpdump/print-gre.c9
-rw-r--r--contrib/tcpdump/print-icmp.c258
-rw-r--r--contrib/tcpdump/print-icmp6.c713
-rw-r--r--contrib/tcpdump/print-igmp.c307
-rw-r--r--contrib/tcpdump/print-igrp.c12
-rw-r--r--contrib/tcpdump/print-ip.c224
-rw-r--r--contrib/tcpdump/print-ip6.c66
-rw-r--r--contrib/tcpdump/print-ip6opts.c185
-rw-r--r--contrib/tcpdump/print-ipcomp.c21
-rw-r--r--contrib/tcpdump/print-ipx.c14
-rw-r--r--contrib/tcpdump/print-isakmp.c458
-rw-r--r--contrib/tcpdump/print-isoclns.c460
-rw-r--r--contrib/tcpdump/print-krb.c7
-rw-r--r--contrib/tcpdump/print-l2tp.c47
-rw-r--r--contrib/tcpdump/print-lane.c23
-rw-r--r--contrib/tcpdump/print-lcp.c18
-rw-r--r--contrib/tcpdump/print-llc.c90
-rw-r--r--contrib/tcpdump/print-mobile.c4
-rw-r--r--contrib/tcpdump/print-netbios.c13
-rw-r--r--contrib/tcpdump/print-nfs.c605
-rw-r--r--contrib/tcpdump/print-ntp.c9
-rw-r--r--contrib/tcpdump/print-null.c100
-rw-r--r--contrib/tcpdump/print-ospf.c7
-rw-r--r--contrib/tcpdump/print-ospf6.c94
-rw-r--r--contrib/tcpdump/print-pim.c32
-rw-r--r--contrib/tcpdump/print-ppp.c1234
-rw-r--r--contrib/tcpdump/print-pppoe.c28
-rw-r--r--contrib/tcpdump/print-radius.c838
-rw-r--r--contrib/tcpdump/print-raw.c21
-rw-r--r--contrib/tcpdump/print-rip.c208
-rw-r--r--contrib/tcpdump/print-ripng.c9
-rw-r--r--contrib/tcpdump/print-rt6.c52
-rw-r--r--contrib/tcpdump/print-rx.c611
-rw-r--r--contrib/tcpdump/print-sl.c75
-rw-r--r--contrib/tcpdump/print-sll.c238
-rw-r--r--contrib/tcpdump/print-smb.c99
-rw-r--r--contrib/tcpdump/print-snmp.c148
-rw-r--r--contrib/tcpdump/print-stp.c106
-rw-r--r--contrib/tcpdump/print-sunrpc.c68
-rw-r--r--contrib/tcpdump/print-tcp.c295
-rw-r--r--contrib/tcpdump/print-telnet.c30
-rw-r--r--contrib/tcpdump/print-timed.c119
-rw-r--r--contrib/tcpdump/print-token.c219
-rw-r--r--contrib/tcpdump/print-udp.c241
-rw-r--r--contrib/tcpdump/print-vjc.c30
-rw-r--r--contrib/tcpdump/print-vrrp.c120
-rw-r--r--contrib/tcpdump/route6d.h16
-rw-r--r--contrib/tcpdump/rx.h35
-rw-r--r--contrib/tcpdump/savestr.c6
-rw-r--r--contrib/tcpdump/savestr.h2
-rw-r--r--contrib/tcpdump/setsignal.c6
-rw-r--r--contrib/tcpdump/slcompress.h87
-rw-r--r--contrib/tcpdump/slip.h34
-rw-r--r--contrib/tcpdump/sll.h127
-rw-r--r--contrib/tcpdump/smb.h1
-rw-r--r--contrib/tcpdump/smbutil.c111
-rw-r--r--contrib/tcpdump/strcasecmp.c5
-rw-r--r--contrib/tcpdump/tcp.h75
-rw-r--r--contrib/tcpdump/tcpdump.1425
-rw-r--r--contrib/tcpdump/tcpdump.c74
-rw-r--r--contrib/tcpdump/timed.h92
-rw-r--r--contrib/tcpdump/token.h33
-rw-r--r--contrib/tcpdump/udp.h46
-rw-r--r--contrib/tcpdump/util.c151
-rw-r--r--contrib/tcpdump/vfprintf.c6
151 files changed, 14070 insertions, 4461 deletions
diff --git a/contrib/tcpdump/.cvsignore b/contrib/tcpdump/.cvsignore
new file mode 100644
index 0000000..f07c8e4
--- /dev/null
+++ b/contrib/tcpdump/.cvsignore
@@ -0,0 +1,11 @@
+version.c
+Makefile
+Makefile-devel.in
+config.status
+config.log
+config.cache
+config.h
+.devel
+stamp-h
+stamp-h.in
+tcpdump
diff --git a/contrib/tcpdump/CHANGES b/contrib/tcpdump/CHANGES
index c11b9d3..4616fb3 100644
--- a/contrib/tcpdump/CHANGES
+++ b/contrib/tcpdump/CHANGES
@@ -1,3 +1,41 @@
+$Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $
+
+Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release
+ Cleaned up documentation.
+ Promisc mode fixes for Linux
+ IPsec changes/cleanups.
+ Alignment fixes for picky architectures
+
+ Removed dependency on native headers for packet dissectors.
+ Removed Linux specific headers that were shipped
+
+ libpcap changes provide for exchanging capture files between
+ systems. Save files now have well known PACKET_ values instead of
+ depending upon system dependant mappings of DLT_* types.
+
+ Support for computing/checking IP and UDP/TCP checksums.
+
+ Updated autoconf stock files.
+
+ IPv6 improvements: dhcp (draft-15), mobile-ip6, ppp, ospf6,
+
+ Added dissector support for: ISOCLNS, Token Ring, IGMPv3, bxxp,
+ timed, vrrp, radius, chdlc, cnfp, cdp, IEEE802.1d, raw-AppleTalk
+
+ Added filtering support for: VLANs, ESIS, ISIS
+
+ Improvements to: print-telnet, IPTalk, bootp/dhcp, ECN, PPP,
+ L2TP, PPPoE
+
+ HP-UX 11.0 -- find the right dlpi device.
+ Solaris 8 - IPv6 works
+ Linux - Added support for an "any" device to capture on all interfaces
+
+ Security fixes: buffer overrun audit done. Strcpy replaced with
+ strlcpy, sprintf replaced with snprintf.
+ Look for lex problems, and warn about them.
+
+
v3.5 Fri Jan 28 18:00:00 PST 2000
Bill Fenner <fenner@research.att.com>
@@ -43,7 +81,6 @@ Love <lha@stacken.kth.se>
Michael C. Richardson <mcr@sandelman.ottawa.on.ca>
- Created tcpdump.org repository
-
v3.4 Sat Jul 25 12:40:55 PDT 1998
- Hardwire Linux slip support since it's too hard to detect.
@@ -558,4 +595,4 @@ v2.0 Sun Jan 13 12:20:40 PST 1991
- Initial public release.
-@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.63.2.1 2000/01/27 23:18:19 fenner Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $ (LBL)
diff --git a/contrib/tcpdump/CREDITS b/contrib/tcpdump/CREDITS
new file mode 100644
index 0000000..3538157
--- /dev/null
+++ b/contrib/tcpdump/CREDITS
@@ -0,0 +1,59 @@
+This file lists people who have contributed to tcpdump:
+
+The current maintainers:
+ Bill Fenner <fenner@research.att.com>
+ Assar Westerlund <assar@sics.se>
+ Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
+ Jun-ichiro itojun Hagino <itojun@iijlab.net>
+ Guy Harris <guy@alum.mit.edu>
+ Torsten Landschoff <t.landschoff@gmx.net>
+ Michael Richardson <mcr@sandelman.ottawa.on.ca>
+ Ken Hornstein <kenh@cmf.nrl.navy.mil>
+
+Additional people who have contributed patches:
+
+ Alfredo Andres <aandres@s21sec.com>
+ Andrew Tridgell <tridge@linuxcare.com>
+ Arkadiusz Miskiewicz <misiek@pld.org.pl>
+ Chris G. Demetriou <cgd@netbsd.org>
+ Craig Rodrigues <rodrigc@mediaone.net>
+ Daniel Hagerty <hag@ai.mit.edu>
+ Francisco Matias Cuenca-Acuna <mcuenca@george.rutgers.edu>
+ Frank Volf <volf@oasis.IAEhv.nl>
+ Gert Doering <gert@greenie.muc.de>
+ Gilbert Ramirez Jr. <gram@xiexie.org>
+ Gisle Vanem <gvanem@eunet.no>
+ JINMEI Tatuya <jinmei@kame.net>
+ Jefferson Ogata <jogata@nodc.noaa.gov>
+ Jeffrey Hutzelman <jhutz@cmu.edu>
+ Juergen Schoenwaelder <schoenw@ibr.cs.tu-bs.de>
+ Ken Hornstein <kenh@cmf.nrl.navy.mil>
+ Kevin Steves <stevesk@sweden.hp.com>
+ Larry Lile <lile@stdio.com>
+ Lennert Buytenhek <buytenh@gnu.org>
+ Love Hörnquist-Åstrand <lha@stacken.kth.se>
+ Marko Kiiskila <carnil@cs.tut.fi>
+ Michael Shalayeff <mickey@openbsd.org>
+ Michael T. Stolarchuk <mts@off.to>
+ Monroe Williams <monroe@pobox.com>
+ Motonori Shindo <mshindo@mshindo.net>
+ Olaf Kirch <okir@caldera.de>
+ Onno van der Linden <onno@simplex.nl>
+ Pascal Hennequin <pascal.hennequin@int-evry.fr>
+ Pasvorn Boonmark <boonmark@juniper.net>
+ Pekka Savola <pekkas@netcore.fi>
+ Peter Jeremy <peter.jeremy@alcatel.com.au>
+ Rafal Maszkowski <rzm@icm.edu.pl>
+ Rick Jones <raj@cup.hp.com>
+ Roderick Schertler <roderick@argon.org>
+ Sebastian Krahmer <krahmer@cs.uni-potsdam.de>
+ Timo Koskiahde
+ Tony Li <tli@jnx.com>
+ Wilbert de Graaf <wilbertdg@hetnet.nl>
+ Kris Kennaway <kris@freebsd.org>
+ Ben Smithurst <ben@scientia.demon.co.uk>
+
+The original LBL crew:
+ Steve McCanne
+ Craig Leres
+ Van Jacobson
diff --git a/contrib/tcpdump/FILES b/contrib/tcpdump/FILES
index 47ffa71..987589e 100644
--- a/contrib/tcpdump/FILES
+++ b/contrib/tcpdump/FILES
@@ -1,21 +1,30 @@
CHANGES
+CREDITS
FILES
INSTALL
+LICENSE
Makefile.in
README
VERSION
+acconfig.h
aclocal.m4
addrtoname.c
addrtoname.h
+ah.h
appletalk.h
atime.awk
bootp.h
-bpf_dump.c
+chdlc.h
config.guess
+config.h.in
config.sub
configure
configure.in
decnet.h
+dhcp6.h
+dhcp6opt.h
+esp.h
+ether.h
ethertype.h
extract.h
fddi.h
@@ -24,80 +33,134 @@ gmt2local.h
igrp.h
install-sh
interface.h
+ip.h
+ipsec_doi.h
ipx.h
-lbl/gnuc.h
+isakmp.h
+l2tp.h
+lane.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
-linux-include/sys/mbuf.h
llc.h
machdep.c
machdep.h
makemib
mib.h
+missing/addrinfo.h
+missing/addrsize.h
+missing/bittypes.h
+missing/getaddrinfo.c
+missing/getnameinfo.c
+missing/inet_aton.c
+missing/inet_ntop.c
+missing/inet_pton.c
+missing/resolv6.h
+missing/resolv_ext.h
+missing/snprintf.c
+missing/sockstorage.h
+missing/strlcat.c
+missing/strlcpy.c
mkdep
+nameser.h
netbios.h
+nfs.h
nfsfh.h
-nfsv2.h
ntp.h
+oakley.h
ospf.h
+ospf6.h
packetdat.awk
parsenfsfh.c
ppp.h
+print-ah.c
print-arp.c
+print-ascii.c
print-atalk.c
print-atm.c
+print-bgp.c
print-bootp.c
+print-bxxp.c
+print-cdp.c
+print-chdlc.c
+print-cip.c
+print-cnfp.c
print-decnet.c
+print-dhcp6.c
print-domain.c
print-dvmrp.c
print-egp.c
+print-esp.c
print-ether.c
print-fddi.c
+print-frag6.c
print-gre.c
print-icmp.c
+print-icmp6.c
+print-igmp.c
print-igrp.c
print-ip.c
+print-ip6.c
+print-ip6opts.c
+print-ipcomp.c
print-ipx.c
+print-isakmp.c
print-isoclns.c
print-krb.c
+print-l2tp.c
+print-lane.c
+print-lcp.c
print-llc.c
+print-mobile.c
print-netbios.c
print-nfs.c
print-ntp.c
print-null.c
print-ospf.c
+print-ospf6.c
print-pim.c
print-ppp.c
+print-pppoe.c
+print-radius.c
print-raw.c
print-rip.c
+print-ripng.c
+print-rt6.c
+print-rx.c
print-sl.c
+print-sll.c
+print-smb.c
print-snmp.c
+print-stp.c
print-sunrpc.c
print-tcp.c
+print-telnet.c
print-tftp.c
+print-timed.c
+print-token.c
print-udp.c
+print-vjc.c
+print-vrrp.c
print-wb.c
+route6d.h
+rx.h
savestr.c
savestr.h
send-ack.awk
setsignal.c
setsignal.h
+slip.h
+slcompress.h
+sll.h
+smb.h
+smbutil.c
stime.awk
strcasecmp.c
+tcp.h
tcpdump.1
tcpdump.c
+timed.h
+token.h
+udp.h
util.c
vfprintf.c
diff --git a/contrib/tcpdump/INSTALL b/contrib/tcpdump/INSTALL
index 8a39565..5e5af94 100644
--- a/contrib/tcpdump/INSTALL
+++ b/contrib/tcpdump/INSTALL
@@ -1,4 +1,4 @@
-@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.36.1.1.2.2 2000/01/29 17:02:09 itojun Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.47 2000/12/16 09:07:45 guy Exp $ (LBL)
If you have not built libpcap, do so first. See the README
file in this directory for the ftp location.
@@ -7,64 +7,44 @@ You will need an ANSI C compiler to build tcpdump. The configure script
will abort if your compiler is not ANSI compliant. If this happens, use
the GNU C compiler, available via anonymous ftp:
- ftp://prep.ai.mit.edu/pub/gnu/gcc.tar.gz
+ ftp://ftp.gnu.org/pub/gnu/gcc/
-After libpcap has been built (either install it with "make install" and
-"make install-incl" or make sure both the libpcap and tcpdump source
-trees are in the same directory), edit the BINDEST and MANDEST paths in
-Makefile.in and run ./configure (a shell script). "configure" will
+After libpcap has been built (either install it with "make install" or
+make sure both the libpcap and tcpdump source trees are in the same
+directory), run ./configure (a shell script). "configure" will
determine your system attributes and generate an appropriate Makefile
from Makefile.in. Now build tcpdump by running "make".
-If everything builds ok, su and type "make install" (and optionally
-"make install-man). This will install tcpdump and the manual entry. By
-default, tcpdump is installed with group execute permissions. The group
-used depends on your os. In addition, BPF packet access is controlled
-by permissions to /dev/bpf0. In any case, DO NOT give untrusted users
-the capability of running tcpdump. Tcpdump can capture any traffic on
-your net, including passwords.
+If everything builds ok, su and type "make install". This will install
+tcpdump and the manual entry. By default, tcpdump is installed with
+group execute permissions. The group used depends on your os. In
+addition, BPF packet access is controlled by permissions to
+/dev/bpf0. In any case, DO NOT give untrusted users the capability of
+running tcpdump. Tcpdump can capture any traffic on your net,
+including passwords.
-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.
+Note that most systems ship tcpdump, but usually an older version.
+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
-generates warnings instead of fatal errors (?!?!) This makes configure
-think that the ether_arp struct is used when in fact it is not. To get
-around this, comment out:
-
-#define ETHER_HEADER_HAS_EA 1
-and
-#define ETHER_ARP_HAS_EA 1
-
-from config.h after running configure (and before attempting to
-compile tcpdump).
-
-Another workaround is to use gcc.
+with 2.0.25 and more modern, and 2.2.x kernels. It is guaranteed not
+to work with 1.X kernels.
If your system is not one which we have tested tcpdump on, you may have
to modify the configure script and Makefile.in. Please send us patches
for any modifications you need to make.
-== Tested platforms ==
-NetBSD 1.4.1/i386 (mcr)
-RedHat Linux 6.1/i386 (assar)
+Please see "PLATFORMS" for notes about tested platforms.
FILES
-----
CHANGES - description of differences between releases
+CREDITS - people that have helped tcpdump along
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
-README-AFS -
VERSION - version of this release
acconfig.h - autoconf input
aclocal.m4 - autoconf macros
@@ -73,7 +53,6 @@ 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.h.in - autoconf input
config.sub - autoconf support
@@ -97,7 +76,6 @@ l2tp.h -
lane.h -
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
@@ -105,6 +83,7 @@ makemib - mib to header script
mib.h - mib definitions
missing/* - replacements for missing library functions
mkdep - construct Makefile dependency list
+nameser.h - DNS definitions
netbios.h - NETBIOS definitions
nfs.h - Network File System V2 definitions
nfsfh.h - Network File System file handle definitions
@@ -123,7 +102,8 @@ print-atm.c - atm printer routines
print-bgp.c - Border Gateway Protocol printer routines
print-bootp.c - BOOTP and IPv4 DHCP printer routines
print-chdlc.c - CHDLC printer routines
-print-cip.c -
+print-cip.c - Classical-IP over ATM routines
+print-cnfp.c - Cisco NetFlow printer routines
print-decnet.c - DECnet printer routines
print-dhcp6.c - IPv6 DHCP printer routines
print-domain.c - Domain Name System printer routines
@@ -167,12 +147,15 @@ print-rx.c - AFS RX printer routines
print-sl.c - Compressed Serial Line Internet Protocol printer routines
print-smb.c - SMB (samba) printer routines
print-snmp.c - Simple Network Management Protocol printer routines
+print-stp.c - IEEE 802.1d spanning tree protocol printer routines
print-sunrpc.c - Sun Remote Procedure Call printer routines
print-tcp.c - TCP printer routines
print-telnet.c - Telnet option printer routines
print-tftp.c - Trivial File Transfer Protocol printer routines
+print-token.c - Token Ring printer routines
print-udp.c - UDP printer routines
print-vjc.c - PPP Van Jacovson compression (RFC1144) printer routines
+print-vrrp.c - Virtual Router Redundancy Protocol
print-wb.c - white board printer routines
route6d.h - packet definition for IPv6 Routing Information Protocol
rx.h -
diff --git a/contrib/tcpdump/LICENSE b/contrib/tcpdump/LICENSE
new file mode 100644
index 0000000..dea5f7d
--- /dev/null
+++ b/contrib/tcpdump/LICENSE
@@ -0,0 +1,19 @@
+License: BSD
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. The names of the authors may not 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.
diff --git a/contrib/tcpdump/Makefile-devel-adds b/contrib/tcpdump/Makefile-devel-adds
new file mode 100644
index 0000000..512a119
--- /dev/null
+++ b/contrib/tcpdump/Makefile-devel-adds
@@ -0,0 +1,22 @@
+#
+# Auto-regenerate configure script or Makefile when things change.
+# From autoconf.info . Works best with GNU Make.
+#
+${srcdir}/configure: configure.in
+ cd ${srcdir} && autoconf
+
+# autoheader might not change config.h.in, so touch a stamp file.
+${srcdir}/config.h.in: ${srcdir}/stamp-h.in
+${srcdir}/stamp-h.in: configure.in acconfig.h
+ cd ${srcdir} && autoheader
+ echo timestamp > ${srcdir}/stamp-h.in
+
+config.h: stamp-h
+stamp-h: ${srcdir}/config.h.in config.status
+ ./config.status
+
+Makefile: Makefile.in config.status
+ ./config.status
+
+config.status: ${srcdir}/configure
+ ./config.status --recheck
diff --git a/contrib/tcpdump/Makefile.in b/contrib/tcpdump/Makefile.in
index 57a4bc2..486e59f 100644
--- a/contrib/tcpdump/Makefile.in
+++ b/contrib/tcpdump/Makefile.in
@@ -17,7 +17,7 @@
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.219 1999/12/22 15:44:09 itojun Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.244 2000/12/21 10:43:20 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -27,9 +27,9 @@
prefix = @prefix@
exec_prefix = @exec_prefix@
# Pathname of directory to install the binary
-BINDEST = @sbindir@
+sbindir = @sbindir@
# Pathname of directory to install the man page
-MANDEST = @mandir@
+mandir = @mandir@
# VPATH
srcdir = @srcdir@
@@ -55,6 +55,8 @@ LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
# 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
@@ -66,17 +68,20 @@ INSTALL = @INSTALL@
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-ether.c print-fddi.c print-gre.c print-icmp.c print-igmp.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-raw.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 gmt2local.c machdep.c \
+ print-snmp.c print-stp.c print-sunrpc.c print-tcp.c print-tftp.c \
+ print-udp.c print-wb.c addrtoname.c gmt2local.c machdep.c \
parsenfsfh.c util.c savestr.c setsignal.c \
print-esp.c print-ah.c print-vjc.c print-isakmp.c print-chdlc.c \
print-ipcomp.c print-mobile.c print-l2tp.c print-bgp.c print-rx.c \
print-lane.c print-cip.c print-pppoe.c print-lcp.c \
- print-smb.c smbutil.c print-ascii.c print-telnet.c
+ print-smb.c smbutil.c print-ascii.c print-telnet.c print-cnfp.c \
+ print-vrrp.c print-cdp.c print-token.c print-bxxp.c print-timed.c \
+ print-radius.c print-sll.c
+
LOCALSRC = @LOCALSRC@
GENSRC = version.c
LIBOBJS = @LIBOBJS@
@@ -85,13 +90,13 @@ 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@
+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 gmt2local.h igrp.h interface.h \
ipx.h llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h \
savestr.c setsignal.h \
- gnuc.h ipsec_doi.h isakmp.h l2tp.h netbios.h oakley.h ospf6.h ppp.h \
- route6d.h
+ gnuc.h ipsec_doi.h isakmp.h l2tp.h nameser.h \
+ netbios.h oakley.h ospf6.h ppp.h route6d.h
TAGHDR = \
/usr/include/arpa/tftp.h \
@@ -124,6 +129,12 @@ inet_ntop.o: $(srcdir)/missing/inet_ntop.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
inet_aton.o: $(srcdir)/missing/inet_aton.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
+snprintf.o: $(srcdir)/missing/snprintf.c
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
+strlcat.o: $(srcdir)/missing/strlcat.c
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
+strlcpy.o: $(srcdir)/missing/strlcpy.c
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
version.o: version.c
$(CC) $(CFLAGS) -c version.c
@@ -132,17 +143,19 @@ version.c: $(srcdir)/VERSION
@rm -f $@
sed -e 's/.*/char version[] = "&";/' $(srcdir)/VERSION > $@
-install: force
- [ -d $(DESTDIR)$(BINDEST) ] || mkdir -p $(DESTDIR)$(BINDEST)
- $(INSTALL) -m 550 -o bin -g @V_GROUP@ $(PROG) \
- $(DESTDIR)$(BINDEST)/$(PROG)
+install:
+ [ -d $(DESTDIR)$(sbindir) ] || \
+ (mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir))
+ $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
+ [ -d $(DESTDIR)$(mandir)/man1 ] || \
+ (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
+ $(INSTALL_DATA) $(srcdir)/$(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1
-install-man: force
- [ -d $(DESTDIR)$(MANDEST)/man1 ] || mkdir -p $(DESTDIR)$(MANDEST)/man1
- $(INSTALL) -m 444 -o bin -g bin $(srcdir)/$(PROG).1 \
- $(DESTDIR)$(MANDEST)/man1/$(PROG).1
+uninstall:
+ rm -f $(DESTDIR)$(sbindir)/$(PROG)
+ rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1
-lint: $(GENSRC) force
+lint: $(GENSRC)
lint -hbxn $(SRC) | \
grep -v 'struct/union .* never defined' | \
grep -v 'possible pointer alignment problem'
@@ -152,14 +165,14 @@ clean:
distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
- config.h gnuc.h os-proto.h
+ config.h gnuc.h os-proto.h stamp-h stamp-h.in
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)
-tar: force
+tar:
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
- list="" ; tar="tar chFFf" ; \
+ list="" ; tar="tar chf" ; \
for i in `cat FILES` ; do list="$$list $$name/$$i" ; done; \
echo \
"rm -f ../$$name; ln -s $$dir ../$$name" ; \
@@ -171,6 +184,5 @@ tar: force
"rm -f ../$$name" ; \
rm -f ../$$name
-force: /tmp
-depend: $(GENSRC) force
- ./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
+depend: $(GENSRC)
+ ${srcdir}/mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
diff --git a/contrib/tcpdump/PLATFORMS b/contrib/tcpdump/PLATFORMS
new file mode 100644
index 0000000..49291176
--- /dev/null
+++ b/contrib/tcpdump/PLATFORMS
@@ -0,0 +1,8 @@
+== Tested platforms ==
+NetBSD 1.5/i386 (mcr - 2000/12/8)
+
+---
+RedHat Linux 6.1/i386 (assar)
+FreeBSD 2.2.8/i386 (itojun)
+
+
diff --git a/contrib/tcpdump/README b/contrib/tcpdump/README
index 644181a..03fe3cf 100644
--- a/contrib/tcpdump/README
+++ b/contrib/tcpdump/README
@@ -1,20 +1,36 @@
-@(#) $Header: /tcpdump/master/tcpdump/README,v 1.54.1.1 1999/10/07 23:47:09 mcr Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/README,v 1.58 2000/12/08 06:59:11 mcr Exp $ (LBL)
-TCPDUMP 3.4
-Lawrence Berkeley National Laboratory
-Network Research Group
-tcpdump@ee.lbl.gov
-ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
+TCPDUMP 3.6
+Now maintained by "The Tcpdump Group"
+See www.tcpdump.org
+
+Please send inquiries/comments/reports to tcpdump-workers@tcpdump.org
+
+Anonymous CVS is available via:
+ cvs -d cvs.tcpdump.org:/tcpdump/master login
+ (password "anoncvs")
+ cvs -d cvs.tcpdump.org:/tcpdump/master checkout tcpdump
+
+Version 3.6 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_6":
+ cvs -d cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_6 tcpdump
+
+Please send patches against the master copy to patches@tcpdump.org.
+
+formerly from Lawrence Berkeley National Laboratory
+ Network Research Group <tcpdump@ee.lbl.gov>
+ ftp://ftp.ee.lbl.gov/tcpdump.tar.Z (3.4)
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.
+monitoring and data acquisition. This software was originally
+developed by the Network Research Group at the Lawrence Berkeley
+National Laboratory. The original distribution is available via
+anonymous ftp to ftp.ee.lbl.gov, in tcpdump.tar.Z. More recent
+development is performed at tcpdump.org, http://www.tcpdump.org/
-Tcpdump now uses libpcap, a system-independent interface for user-level
+Tcpdump 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:
-
- ftp://ftp.ee.lbl.gov/libpcap.tar.Z
+build libpcap, also originally from LBL and now being maintained by
+tcpdump.org; see http://www.tcpdump.org/ .
Once libpcap is built (either install it or make sure it's in
../libpcap), you can build tcpdump using the procedure in the INSTALL
@@ -50,13 +66,18 @@ 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
-"tcpdump@ee.lbl.gov".
+Problems, bugs, questions, desirable enhancements, etc.
+should be sent to the address "tcpdump-workers@tcpdump.org".
+
+Source code contributions, etc. should be sent to the email address
+"patches@tcpdump.org".
+
+Current versions can be found at www.tcpdump.org
+
+ - The TCPdump team
+
+original text by: Steve McCanne, Craig Leres, Van Jacobson
- - Steve McCanne
- Craig Leres
- Van Jacobson
-------------------------------------
This directory also contains some short awk programs intended as
examples of ways to reduce tcpdump data when you're tracking
@@ -205,4 +226,3 @@ The method was:
- Once a week, tell your funding agent that you're discovering
wonderful things and you'll write up that research report
"real soon now".
-
diff --git a/contrib/tcpdump/TODO b/contrib/tcpdump/TODO
new file mode 100644
index 0000000..12c8b3f
--- /dev/null
+++ b/contrib/tcpdump/TODO
@@ -0,0 +1,6 @@
+1. update credits
+2. review "FILES"
+3. search for version info
+4. get PLATFORMS filled in
+5. update CHANGES file
+6. do same for libpcap
diff --git a/contrib/tcpdump/VERSION b/contrib/tcpdump/VERSION
index 5a95802..d70c8f8 100644
--- a/contrib/tcpdump/VERSION
+++ b/contrib/tcpdump/VERSION
@@ -1 +1 @@
-3.5
+3.6
diff --git a/contrib/tcpdump/acconfig.h b/contrib/tcpdump/acconfig.h
index 5721258..6a03387 100644
--- a/contrib/tcpdump/acconfig.h
+++ b/contrib/tcpdump/acconfig.h
@@ -2,14 +2,10 @@
* make them to acconfig.h and rerun autoheader */
@TOP@
-/* Define if you have SSLeay XXX why isn't this HAVE_LIBCRYPTO? */
-#undef CRYPTO
-
/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
#undef HAVE_BUGGY_CAST128
-/* Define both to enable IPv6 support XXX why 2? ENABLE_IPV6 is not used. */
-#undef ENABLE_IPV6
+/* Define if you enable IPv6 support */
#undef INET6
/* Define if you enable support for the libsmi. */
@@ -18,14 +14,6 @@
/* Define if you have the <smi.h> header file. */
#undef HAVE_SMI_H
-/* Is T_AAAA predefined? */
-#undef HAVE_AAAA
-
-/* Fallback definition if not in headers */
-/* XXX why is this not #ifndef HAVE_AAA #define T_AAAA ... ? */
-/* XXX or even #ifndef T_AAAA ... */
-#undef T_AAAA
-
/* define if you have struct __res_state_ext */
#undef HAVE_RES_STATE_EXT
@@ -38,11 +26,6 @@
*/
#undef ETHER_HEADER_HAS_EA
-/*
- * define if struct ether_arp.arp_sha is a struct with ether_addr_octet
- */
-#undef ETHER_ARP_HAS_EA
-
/* define if struct ether_arp contains arp_xsha */
#undef ETHER_ARP_HAS_X
@@ -61,9 +44,6 @@
/* define if INADDRSZ is defined (XXX not used!) */
#undef HAVE_INADDRSZ
-/* define if you have <net/slip.h> */
-#undef HAVE_NET_SLIP_H
-
/* define if this is a development version, to use additional prototypes. */
#undef HAVE_OS_PROTO_H
@@ -79,6 +59,9 @@
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
+/* define if you have both getipnodebyname() and getipnodebyaddr() */
+#undef USE_GETIPNODEBY
+
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@@ -94,9 +77,6 @@
/* AIX hack. */
#undef _SUN
-/* OSF hack: "Workaround around ip_hl vs. ip_vhl problem in netinet/ip.h" */
-#undef __STDC__
-
/* Workaround for missing sized types */
/* XXX this should move to the more standard uint*_t */
#undef int16_t
diff --git a/contrib/tcpdump/aclocal.m4 b/contrib/tcpdump/aclocal.m4
index 4f99be4..06eca60 100644
--- a/contrib/tcpdump/aclocal.m4
+++ b/contrib/tcpdump/aclocal.m4
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.67.2.1 2000/01/25 18:39:02 itojun Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.73 2001/01/02 22:18:27 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1995, 1996, 1997, 1998
dnl The Regents of the University of California. All rights reserved.
@@ -192,7 +192,7 @@ AC_DEFUN(AC_LBL_LIBPCAP,
libpcap=FAIL
lastdir=FAIL
places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
- egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
+ 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
@@ -215,7 +215,7 @@ AC_DEFUN(AC_LBL_LIBPCAP,
else
$1=$libpcap
if test -r $d/pcap.h; then
- $2="-I$d $$2"
+ $2="-I$d $$2"
elif test -r $srcdir/../libpcap/pcap.h; then
$2="-I$d -I$srcdir/../libpcap $$2"
else
@@ -491,7 +491,8 @@ AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
[case "$target_cpu" in
- alpha|hp*|mips|sparc)
+ # XXX: should also check that they don't do weird things (like on arm)
+ alpha*|arm*|hp*|mips|sparc)
ac_cv_lbl_unaligned_fail=yes
;;
@@ -1027,3 +1028,30 @@ AC_DEFUN(AC_VAR_H_ERRNO, [
AC_DEFINE(HAVE_H_ERRNO)
fi
])
+
+dnl
+dnl Test for __attribute__
+dnl
+
+AC_DEFUN(AC_C___ATTRIBUTE__, [
+AC_MSG_CHECKING(for __attribute__)
+AC_CACHE_VAL(ac_cv___attribute__, [
+AC_TRY_COMPILE([
+#include <stdlib.h>
+],
+[
+static void foo(void) __attribute__ ((noreturn));
+
+static void
+foo(void)
+{
+ exit(1);
+}
+],
+ac_cv___attribute__=yes,
+ac_cv___attribute__=no)])
+if test "$ac_cv___attribute__" = "yes"; then
+ AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
+fi
+AC_MSG_RESULT($ac_cv___attribute__)
+])
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c
index 70c70cf..600b329 100644
--- a/contrib/tcpdump/addrtoname.c
+++ b/contrib/tcpdump/addrtoname.c
@@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.64 1999/11/21 09:36:44 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.69.2.1 2001/01/17 18:29:58 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,17 +34,13 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <sys/time.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
#include <net/if.h>
#include <netinet/in.h>
+#ifdef HAVE_NETINET_IF_ETHER_H
#include <netinet/if_ether.h>
-
-#ifdef INET6
-#include <netinet6/ip6.h>
#endif
#include <arpa/inet.h>
@@ -53,12 +49,6 @@ struct rtentry;
#include <netdb.h>
#include <pcap.h>
#include <pcap-namedb.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -495,7 +485,6 @@ protoid_string(register const u_char *pi)
char *
llcsap_string(u_char sap)
{
- register char *cp;
register struct hnamemem *tp;
register u_int32_t i = sap;
char buf[sizeof("sap 00")];
@@ -507,12 +496,7 @@ llcsap_string(u_char sap)
tp->addr = i;
tp->nxt = newhnamemem();
- cp = buf;
- (void)strcpy(cp, "sap ");
- cp += strlen(cp);
- *cp++ = hex[sap >> 4 & 0xf];
- *cp++ = hex[sap & 0xf];
- *cp++ = '\0';
+ snprintf(buf, sizeof(buf), "sap %02x", sap & 0xff);
tp->name = savestr(buf);
return (tp->name);
}
@@ -556,7 +540,7 @@ tcpport_string(u_short port)
tp->addr = i;
tp->nxt = newhnamemem();
- (void)sprintf(buf, "%u", i);
+ (void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = savestr(buf);
return (tp->name);
}
@@ -575,7 +559,7 @@ udpport_string(register u_short port)
tp->addr = i;
tp->nxt = newhnamemem();
- (void)sprintf(buf, "%u", i);
+ (void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = savestr(buf);
return (tp->name);
}
@@ -601,7 +585,7 @@ init_servarray(void)
while (table->name)
table = table->nxt;
if (nflag) {
- (void)sprintf(buf, "%d", port);
+ (void)snprintf(buf, sizeof(buf), "%d", port);
table->name = savestr(buf);
} else
table->name = savestr(sv->s_name);
diff --git a/contrib/tcpdump/ah.h b/contrib/tcpdump/ah.h
new file mode 100644
index 0000000..c22806a
--- /dev/null
+++ b/contrib/tcpdump/ah.h
@@ -0,0 +1,57 @@
+/* $NetBSD: ah.h,v 1.12 2000/07/23 05:23:04 itojun Exp $ */
+/* $KAME: ah.h,v 1.12 2000/07/20 17:41:01 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * RFC1826/2402 authentication header.
+ */
+
+#ifndef _NETINET6_AH_H_
+#define _NETINET6_AH_H_
+
+struct ah {
+ u_int8_t ah_nxt; /* Next Header */
+ u_int8_t ah_len; /* Length of data, in 32bit */
+ u_int16_t ah_reserve; /* Reserved for future use */
+ u_int32_t ah_spi; /* Security parameter index */
+ /* variable size, 32bit bound*/ /* Authentication data */
+};
+
+struct newah {
+ u_int8_t ah_nxt; /* Next Header */
+ u_int8_t ah_len; /* Length of data + 1, in 32bit */
+ u_int16_t ah_reserve; /* Reserved for future use */
+ u_int32_t ah_spi; /* Security parameter index */
+ u_int32_t ah_seq; /* Sequence number field */
+ /* variable size, 32bit bound*/ /* Authentication data */
+};
+
+#endif /*_NETINET6_AH_H_*/
diff --git a/contrib/tcpdump/appletalk.h b/contrib/tcpdump/appletalk.h
index 766982e..73b2e4e 100644
--- a/contrib/tcpdump/appletalk.h
+++ b/contrib/tcpdump/appletalk.h
@@ -20,13 +20,13 @@
*
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
*
- * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.12.1.1 1999/10/07 23:47:09 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.13 2000/10/03 02:54:54 itojun Exp $ (LBL)
*/
struct LAP {
- u_char dst;
- u_char src;
- u_char type;
+ u_int8_t dst;
+ u_int8_t src;
+ u_int8_t type;
};
#define lapShortDDP 1 /* short DDP type */
#define lapDDP 2 /* DDP type */
@@ -35,22 +35,22 @@ struct LAP {
/* Datagram Delivery Protocol */
struct atDDP {
- u_short length;
- u_short checksum;
- u_short dstNet;
- u_short srcNet;
- u_char dstNode;
- u_char srcNode;
- u_char dstSkt;
- u_char srcSkt;
- u_char type;
+ u_int16_t length;
+ u_int16_t checksum;
+ u_int16_t dstNet;
+ u_int16_t srcNet;
+ u_int8_t dstNode;
+ u_int8_t srcNode;
+ u_int8_t dstSkt;
+ u_int8_t srcSkt;
+ u_int8_t type;
};
struct atShortDDP {
- u_short length;
- u_char dstSkt;
- u_char srcSkt;
- u_char type;
+ u_int16_t length;
+ u_int8_t dstSkt;
+ u_int8_t srcSkt;
+ u_int8_t type;
};
#define ddpMaxWKS 0x7F
@@ -73,9 +73,9 @@ struct atShortDDP {
/* AppleTalk Transaction Protocol */
struct atATP {
- u_char control;
- u_char bitmap;
- u_short transID;
+ u_int8_t control;
+ u_int8_t bitmap;
+ u_int16_t transID;
int32_t userData;
};
@@ -94,8 +94,8 @@ struct atATP {
/* AppleTalk Echo Protocol */
struct atEcho {
- u_char echoFunction;
- u_char *echoData;
+ u_int8_t echoFunction;
+ u_int8_t *echoData;
};
#define echoSkt 4 /* the echoer socket */
@@ -107,15 +107,15 @@ struct atEcho {
/* Name Binding Protocol */
struct atNBP {
- u_char control;
- u_char id;
+ u_int8_t control;
+ u_int8_t id;
};
struct atNBPtuple {
- u_short net;
- u_char node;
- u_char skt;
- u_char enumerator;
+ u_int16_t net;
+ u_int8_t node;
+ u_int8_t skt;
+ u_int8_t enumerator;
};
#define nbpBrRq 0x10
@@ -141,8 +141,8 @@ struct atNBPtuple {
/* Zone Information Protocol */
struct zipHeader {
- u_char command;
- u_char netcount;
+ u_int8_t command;
+ u_int8_t netcount;
};
#define zipHeaderSize 2
diff --git a/contrib/tcpdump/bootp.h b/contrib/tcpdump/bootp.h
index bea254e..49899de 100644
--- a/contrib/tcpdump/bootp.h
+++ b/contrib/tcpdump/bootp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.8 1999/10/17 23:35:46 mcr Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.10 2000/12/03 23:42:23 fenner Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@@ -21,21 +21,21 @@
struct bootp {
- unsigned char bp_op; /* packet opcode type */
- unsigned char bp_htype; /* hardware addr type */
- unsigned char bp_hlen; /* hardware addr length */
- unsigned char bp_hops; /* gateway hops */
+ u_int8_t bp_op; /* packet opcode type */
+ u_int8_t bp_htype; /* hardware addr type */
+ u_int8_t bp_hlen; /* hardware addr length */
+ u_int8_t bp_hops; /* gateway hops */
u_int32_t bp_xid; /* transaction ID */
- unsigned short bp_secs; /* seconds since boot began */
- unsigned short bp_flags; /* flags: 0x8000 is broadcast */
+ u_int16_t bp_secs; /* seconds since boot began */
+ u_int16_t bp_flags; /* flags: 0x8000 is broadcast */
struct in_addr bp_ciaddr; /* client IP address */
struct in_addr bp_yiaddr; /* 'your' IP address */
struct in_addr bp_siaddr; /* server IP address */
struct in_addr bp_giaddr; /* gateway IP address */
- unsigned char bp_chaddr[16]; /* client hardware address */
- unsigned char bp_sname[64]; /* server host name */
- unsigned char bp_file[128]; /* boot file name */
- unsigned char bp_vend[64]; /* vendor-specific area */
+ u_int8_t bp_chaddr[16]; /* client hardware address */
+ u_int8_t bp_sname[64]; /* server host name */
+ u_int8_t bp_file[128]; /* boot file name */
+ u_int8_t bp_vend[64]; /* vendor-specific area */
};
/*
@@ -65,85 +65,127 @@ struct bootp {
* the vendor field of the packet.
*/
-#define TAG_PAD ((unsigned char) 0)
-#define TAG_SUBNET_MASK ((unsigned char) 1)
-#define TAG_TIME_OFFSET ((unsigned char) 2)
-#define TAG_GATEWAY ((unsigned char) 3)
-#define TAG_TIME_SERVER ((unsigned char) 4)
-#define TAG_NAME_SERVER ((unsigned char) 5)
-#define TAG_DOMAIN_SERVER ((unsigned char) 6)
-#define TAG_LOG_SERVER ((unsigned char) 7)
-#define TAG_COOKIE_SERVER ((unsigned char) 8)
-#define TAG_LPR_SERVER ((unsigned char) 9)
-#define TAG_IMPRESS_SERVER ((unsigned char) 10)
-#define TAG_RLP_SERVER ((unsigned char) 11)
-#define TAG_HOSTNAME ((unsigned char) 12)
-#define TAG_BOOTSIZE ((unsigned char) 13)
-#define TAG_END ((unsigned char) 255)
+#define TAG_PAD ((u_int8_t) 0)
+#define TAG_SUBNET_MASK ((u_int8_t) 1)
+#define TAG_TIME_OFFSET ((u_int8_t) 2)
+#define TAG_GATEWAY ((u_int8_t) 3)
+#define TAG_TIME_SERVER ((u_int8_t) 4)
+#define TAG_NAME_SERVER ((u_int8_t) 5)
+#define TAG_DOMAIN_SERVER ((u_int8_t) 6)
+#define TAG_LOG_SERVER ((u_int8_t) 7)
+#define TAG_COOKIE_SERVER ((u_int8_t) 8)
+#define TAG_LPR_SERVER ((u_int8_t) 9)
+#define TAG_IMPRESS_SERVER ((u_int8_t) 10)
+#define TAG_RLP_SERVER ((u_int8_t) 11)
+#define TAG_HOSTNAME ((u_int8_t) 12)
+#define TAG_BOOTSIZE ((u_int8_t) 13)
+#define TAG_END ((u_int8_t) 255)
/* RFC1497 tags */
-#define TAG_DUMPPATH ((unsigned char) 14)
-#define TAG_DOMAINNAME ((unsigned char) 15)
-#define TAG_SWAP_SERVER ((unsigned char) 16)
-#define TAG_ROOTPATH ((unsigned char) 17)
-#define TAG_EXTPATH ((unsigned char) 18)
+#define TAG_DUMPPATH ((u_int8_t) 14)
+#define TAG_DOMAINNAME ((u_int8_t) 15)
+#define TAG_SWAP_SERVER ((u_int8_t) 16)
+#define TAG_ROOTPATH ((u_int8_t) 17)
+#define TAG_EXTPATH ((u_int8_t) 18)
/* RFC2132 */
-#define TAG_IP_FORWARD ((unsigned char) 19)
-#define TAG_NL_SRCRT ((unsigned char) 20)
-#define TAG_PFILTERS ((unsigned char) 21)
-#define TAG_REASS_SIZE ((unsigned char) 22)
-#define TAG_DEF_TTL ((unsigned char) 23)
-#define TAG_MTU_TIMEOUT ((unsigned char) 24)
-#define TAG_MTU_TABLE ((unsigned char) 25)
-#define TAG_INT_MTU ((unsigned char) 26)
-#define TAG_LOCAL_SUBNETS ((unsigned char) 27)
-#define TAG_BROAD_ADDR ((unsigned char) 28)
-#define TAG_DO_MASK_DISC ((unsigned char) 29)
-#define TAG_SUPPLY_MASK ((unsigned char) 30)
-#define TAG_DO_RDISC ((unsigned char) 31)
-#define TAG_RTR_SOL_ADDR ((unsigned char) 32)
-#define TAG_STATIC_ROUTE ((unsigned char) 33)
-#define TAG_USE_TRAILERS ((unsigned char) 34)
-#define TAG_ARP_TIMEOUT ((unsigned char) 35)
-#define TAG_ETH_ENCAP ((unsigned char) 36)
-#define TAG_TCP_TTL ((unsigned char) 37)
-#define TAG_TCP_KEEPALIVE ((unsigned char) 38)
-#define TAG_KEEPALIVE_GO ((unsigned char) 39)
-#define TAG_NIS_DOMAIN ((unsigned char) 40)
-#define TAG_NIS_SERVERS ((unsigned char) 41)
-#define TAG_NTP_SERVERS ((unsigned char) 42)
-#define TAG_VENDOR_OPTS ((unsigned char) 43)
-#define TAG_NETBIOS_NS ((unsigned char) 44)
-#define TAG_NETBIOS_DDS ((unsigned char) 45)
-#define TAG_NETBIOS_NODE ((unsigned char) 46)
-#define TAG_NETBIOS_SCOPE ((unsigned char) 47)
-#define TAG_XWIN_FS ((unsigned char) 48)
-#define TAG_XWIN_DM ((unsigned char) 49)
-#define TAG_NIS_P_DOMAIN ((unsigned char) 64)
-#define TAG_NIS_P_SERVERS ((unsigned char) 65)
-#define TAG_MOBILE_HOME ((unsigned char) 68)
-#define TAG_SMPT_SERVER ((unsigned char) 69)
-#define TAG_POP3_SERVER ((unsigned char) 70)
-#define TAG_NNTP_SERVER ((unsigned char) 71)
-#define TAG_WWW_SERVER ((unsigned char) 72)
-#define TAG_FINGER_SERVER ((unsigned char) 73)
-#define TAG_IRC_SERVER ((unsigned char) 74)
-#define TAG_STREETTALK_SRVR ((unsigned char) 75)
-#define TAG_STREETTALK_STDA ((unsigned char) 76)
+#define TAG_IP_FORWARD ((u_int8_t) 19)
+#define TAG_NL_SRCRT ((u_int8_t) 20)
+#define TAG_PFILTERS ((u_int8_t) 21)
+#define TAG_REASS_SIZE ((u_int8_t) 22)
+#define TAG_DEF_TTL ((u_int8_t) 23)
+#define TAG_MTU_TIMEOUT ((u_int8_t) 24)
+#define TAG_MTU_TABLE ((u_int8_t) 25)
+#define TAG_INT_MTU ((u_int8_t) 26)
+#define TAG_LOCAL_SUBNETS ((u_int8_t) 27)
+#define TAG_BROAD_ADDR ((u_int8_t) 28)
+#define TAG_DO_MASK_DISC ((u_int8_t) 29)
+#define TAG_SUPPLY_MASK ((u_int8_t) 30)
+#define TAG_DO_RDISC ((u_int8_t) 31)
+#define TAG_RTR_SOL_ADDR ((u_int8_t) 32)
+#define TAG_STATIC_ROUTE ((u_int8_t) 33)
+#define TAG_USE_TRAILERS ((u_int8_t) 34)
+#define TAG_ARP_TIMEOUT ((u_int8_t) 35)
+#define TAG_ETH_ENCAP ((u_int8_t) 36)
+#define TAG_TCP_TTL ((u_int8_t) 37)
+#define TAG_TCP_KEEPALIVE ((u_int8_t) 38)
+#define TAG_KEEPALIVE_GO ((u_int8_t) 39)
+#define TAG_NIS_DOMAIN ((u_int8_t) 40)
+#define TAG_NIS_SERVERS ((u_int8_t) 41)
+#define TAG_NTP_SERVERS ((u_int8_t) 42)
+#define TAG_VENDOR_OPTS ((u_int8_t) 43)
+#define TAG_NETBIOS_NS ((u_int8_t) 44)
+#define TAG_NETBIOS_DDS ((u_int8_t) 45)
+#define TAG_NETBIOS_NODE ((u_int8_t) 46)
+#define TAG_NETBIOS_SCOPE ((u_int8_t) 47)
+#define TAG_XWIN_FS ((u_int8_t) 48)
+#define TAG_XWIN_DM ((u_int8_t) 49)
+#define TAG_NIS_P_DOMAIN ((u_int8_t) 64)
+#define TAG_NIS_P_SERVERS ((u_int8_t) 65)
+#define TAG_MOBILE_HOME ((u_int8_t) 68)
+#define TAG_SMPT_SERVER ((u_int8_t) 69)
+#define TAG_POP3_SERVER ((u_int8_t) 70)
+#define TAG_NNTP_SERVER ((u_int8_t) 71)
+#define TAG_WWW_SERVER ((u_int8_t) 72)
+#define TAG_FINGER_SERVER ((u_int8_t) 73)
+#define TAG_IRC_SERVER ((u_int8_t) 74)
+#define TAG_STREETTALK_SRVR ((u_int8_t) 75)
+#define TAG_STREETTALK_STDA ((u_int8_t) 76)
/* DHCP options */
-#define TAG_REQUESTED_IP ((unsigned char) 50)
-#define TAG_IP_LEASE ((unsigned char) 51)
-#define TAG_OPT_OVERLOAD ((unsigned char) 52)
-#define TAG_TFTP_SERVER ((unsigned char) 66)
-#define TAG_BOOTFILENAME ((unsigned char) 67)
-#define TAG_DHCP_MESSAGE ((unsigned char) 53)
-#define TAG_SERVER_ID ((unsigned char) 54)
-#define TAG_PARM_REQUEST ((unsigned char) 55)
-#define TAG_MESSAGE ((unsigned char) 56)
-#define TAG_MAX_MSG_SIZE ((unsigned char) 57)
-#define TAG_RENEWAL_TIME ((unsigned char) 58)
-#define TAG_REBIND_TIME ((unsigned char) 59)
-#define TAG_VENDOR_CLASS ((unsigned char) 60)
-#define TAG_CLIENT_ID ((unsigned char) 61)
+#define TAG_REQUESTED_IP ((u_int8_t) 50)
+#define TAG_IP_LEASE ((u_int8_t) 51)
+#define TAG_OPT_OVERLOAD ((u_int8_t) 52)
+#define TAG_TFTP_SERVER ((u_int8_t) 66)
+#define TAG_BOOTFILENAME ((u_int8_t) 67)
+#define TAG_DHCP_MESSAGE ((u_int8_t) 53)
+#define TAG_SERVER_ID ((u_int8_t) 54)
+#define TAG_PARM_REQUEST ((u_int8_t) 55)
+#define TAG_MESSAGE ((u_int8_t) 56)
+#define TAG_MAX_MSG_SIZE ((u_int8_t) 57)
+#define TAG_RENEWAL_TIME ((u_int8_t) 58)
+#define TAG_REBIND_TIME ((u_int8_t) 59)
+#define TAG_VENDOR_CLASS ((u_int8_t) 60)
+#define TAG_CLIENT_ID ((u_int8_t) 61)
+/* RFC 2241 */
+#define TAG_NDS_SERVERS ((u_int8_t) 85)
+#define TAG_NDS_TREE_NAME ((u_int8_t) 86)
+#define TAG_NDS_CONTEXT ((u_int8_t) 87)
+/* RFC 2485 */
+#define TAG_OPEN_GROUP_UAP ((u_int8_t) 98)
+/* RFC 2563 */
+#define TAG_DISABLE_AUTOCONF ((u_int8_t) 116)
+/* RFC 2610 */
+#define TAG_SLP_DA ((u_int8_t) 78)
+#define TAG_SLP_SCOPE ((u_int8_t) 79)
+/* RFC 2937 */
+#define TAG_NS_SEARCH ((u_int8_t) 117)
+/* RFC 3011 */
+#define TAG_IP4_SUBNET_SELECT ((u_int8_t) 118)
+/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
+#define TAG_USER_CLASS ((u_int8_t) 77)
+#define TAG_SLP_NAMING_AUTH ((u_int8_t) 80)
+#define TAG_CLIENT_FQDN ((u_int8_t) 81)
+#define TAG_AGENT_CIRCUIT ((u_int8_t) 82)
+#define TAG_AGENT_REMOTE ((u_int8_t) 83)
+#define TAG_AGENT_MASK ((u_int8_t) 84)
+#define TAG_TZ_STRING ((u_int8_t) 88)
+#define TAG_FQDN_OPTION ((u_int8_t) 89)
+#define TAG_AUTH ((u_int8_t) 90)
+#define TAG_VINES_SERVERS ((u_int8_t) 91)
+#define TAG_SERVER_RANK ((u_int8_t) 92)
+#define TAG_CLIENT_ARCH ((u_int8_t) 93)
+#define TAG_CLIENT_NDI ((u_int8_t) 94)
+#define TAG_CLIENT_GUID ((u_int8_t) 97)
+#define TAG_LDAP_URL ((u_int8_t) 95)
+#define TAG_6OVER4 ((u_int8_t) 96)
+#define TAG_PRINTER_NAME ((u_int8_t) 100)
+#define TAG_MDHCP_SERVER ((u_int8_t) 101)
+#define TAG_IPX_COMPAT ((u_int8_t) 110)
+#define TAG_NETINFO_PARENT ((u_int8_t) 112)
+#define TAG_NETINFO_PARENT_TAG ((u_int8_t) 113)
+#define TAG_URL ((u_int8_t) 114)
+#define TAG_FAILOVER ((u_int8_t) 115)
+#define TAG_EXTENDED_REQUEST ((u_int8_t) 126)
+#define TAG_EXTENDED_OPTION ((u_int8_t) 127)
+
/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
#define DHCPDISCOVER 1
@@ -161,14 +203,14 @@ struct bootp {
*/
struct cmu_vend {
- unsigned char v_magic[4]; /* magic number */
+ u_int8_t v_magic[4]; /* magic number */
u_int32_t v_flags; /* flags/opcodes, etc. */
struct in_addr v_smask; /* Subnet mask */
struct in_addr v_dgate; /* Default gateway */
struct in_addr v_dns1, v_dns2; /* Domain name servers */
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
struct in_addr v_ts1, v_ts2; /* Time servers */
- unsigned char v_unused[24]; /* currently unused */
+ u_int8_t v_unused[24]; /* currently unused */
};
diff --git a/contrib/tcpdump/bpf_dump.c b/contrib/tcpdump/bpf_dump.c
index 8e799ce..4d7f81f 100644
--- a/contrib/tcpdump/bpf_dump.c
+++ b/contrib/tcpdump/bpf_dump.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.10 1999/11/21 09:36:44 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.13 2000/12/09 02:58:45 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,8 +35,6 @@ static const char rcsid[] =
#include "interface.h"
-extern void bpf_dump(struct bpf_program *, int);
-
void
bpf_dump(struct bpf_program *p, int option)
{
diff --git a/contrib/tcpdump/chdlc.h b/contrib/tcpdump/chdlc.h
new file mode 100644
index 0000000..4fb6e1d
--- /dev/null
+++ b/contrib/tcpdump/chdlc.h
@@ -0,0 +1,27 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000/09/18 05:11:43 guy Exp $ (LBL) */
+/*
+ * Copyright (c) 1990, 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
+ * 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.
+ */
+
+#define CHDLC_HDRLEN 4
+#define CHDLC_UNICAST 0x0f
+#define CHDLC_BCAST 0x8f
+#define CHDLC_TYPE_SLARP 0x8035
+#define CHDLC_TYPE_CDP 0x2000
diff --git a/contrib/tcpdump/config.guess b/contrib/tcpdump/config.guess
index e9e4455..980ea5b 100755
--- a/contrib/tcpdump/config.guess
+++ b/contrib/tcpdump/config.guess
@@ -1,7 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
-#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Free Software Foundation, Inc.
+
+timestamp='2000-12-15'
+
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -22,19 +25,97 @@
# the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
+# Please send patches to <config-patches@gnu.org>.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
-# don't specify an explicit system type (host/target name).
+# don't specify an explicit build system type.
#
# Only a few systems have been added to this list; please add others
# (but try to keep the structure clean).
#
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int dummy(){}" > $dummy.c
+ for c in cc gcc c89 ; do
+ ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
+ if test $? = 0 ; then
+ CC_FOR_BUILD="$c"; break
+ fi
+ done
+ rm -f $dummy.c $dummy.o
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac
+
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 8/24/94.)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
@@ -43,37 +124,162 @@ fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
-
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # Netbsd (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ # Determine the machine/vendor (is the vendor relevant).
+ case "${UNAME_MACHINE}" in
+ amiga) machine=m68k-unknown ;;
+ arm32) machine=arm-unknown ;;
+ atari*) machine=m68k-atari ;;
+ sun3*) machine=m68k-sun ;;
+ mac68k) machine=m68k-apple ;;
+ macppc) machine=powerpc-apple ;;
+ hp3[0-9][05]) machine=m68k-hp ;;
+ ibmrt|romp-ibm) machine=romp-ibm ;;
+ *) machine=${UNAME_MACHINE}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE}" in
+ i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'`
+ cat <<EOF >$dummy.s
+ .data
+\$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
+ .globl main
+ .align 4
+ .ent main
+main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
+EOF
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ case `./$dummy` in
+ 0-0)
+ UNAME_MACHINE="alpha"
+ ;;
+ 1-0)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 1-1)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 1-101)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 2-303)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
+ esac
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
exit 0 ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit 0 ;;
Amiga*:UNIX_System_V:4.0:*)
- echo m68k-cbm-sysv4
+ echo m68k-unknown-sysv4
exit 0;;
- amiga:NetBSD:*:*)
- echo m68k-cbm-netbsd${UNAME_RELEASE}
- exit 0 ;;
amiga:OpenBSD:*:*)
- echo m68k-cbm-openbsd${UNAME_RELEASE}
- exit 0 ;;
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ arc64:OpenBSD:*:*)
+ echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hkmips:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
- Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
+ SR2?01:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
@@ -81,9 +287,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo pyramid-pyramid-bsd
fi
exit 0 ;;
- NILE:*:*:dcosx)
+ NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -108,26 +317,61 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
- atari*:NetBSD:*:*)
- echo m68k-atari-netbsd${UNAME_RELEASE}
- exit 0 ;;
atari*:OpenBSD:*:*)
- echo m68k-atari-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sun3*:NetBSD:*:*)
- echo m68k-sun-netbsd${UNAME_RELEASE}
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
sun3*:OpenBSD:*:*)
- echo m68k-sun-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:NetBSD:*:*)
- echo m68k-apple-netbsd${UNAME_RELEASE}
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
- echo m68k-apple-openbsd${UNAME_RELEASE}
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
@@ -141,9 +385,17 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
- sed 's/^ //' << EOF >dummy.c
- int main (argc, argv) int argc; char **argv; {
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
@@ -158,10 +410,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
exit (-1);
}
EOF
- ${CC-cc} dummy.c -o dummy \
- && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
- && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy \
+ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
@@ -179,15 +431,18 @@ EOF
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
- -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
echo m88k-dg-dgux${UNAME_RELEASE}
- else
+ else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
fi
- else echo i586-dg-dgux${UNAME_RELEASE}
- fi
exit 0 ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
@@ -213,7 +468,7 @@ EOF
exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- sed 's/^ //' << EOF >dummy.c
+ sed 's/^ //' << EOF >$dummy.c
#include <sys/systemcfg.h>
main()
@@ -224,8 +479,8 @@ EOF
exit(0);
}
EOF
- ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
@@ -234,7 +489,8 @@ EOF
fi
exit 0 ;;
*:AIX:*:4)
- if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
@@ -246,13 +502,26 @@ EOF
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit 0 ;;
+ *:AIX:*:5)
+ case "`lsattr -El proc0 -a type -F value`" in
+ PowerPC*) IBM_ARCH=powerpc
+ IBM_MANUF=ibm ;;
+ Itanium) IBM_ARCH=ia64
+ IBM_MANUF=unknown ;;
+ POWER*) IBM_ARCH=power
+ IBM_MANUF=ibm ;;
+ *) IBM_ARCH=powerpc
+ IBM_MANUF=ibm ;;
+ esac
+ echo ${IBM_ARCH}-${IBM_MANUF}-aix${UNAME_VERSION}.${UNAME_RELEASE}
+ exit 0 ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit 0 ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit 0 ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit 0 ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
@@ -267,18 +536,71 @@ EOF
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit 0 ;;
- 9000/[3478]??:HP-UX:*:*)
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
- 9000/8?? ) HP_ARCH=hppa1.0 ;;
+ 9000/[678][0-9][0-9])
+ case "${HPUX_REV}" in
+ 11.[0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ esac ;;
+ esac
+ fi ;;
+ esac
+ if [ "${HP_ARCH}" = "" ]; then
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+ if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+ rm -f $dummy.c $dummy
+ fi ;;
esac
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
- sed 's/^ //' << EOF >dummy.c
+ sed 's/^ //' << EOF >$dummy.c
#include <unistd.h>
int
main ()
@@ -303,8 +625,8 @@ EOF
exit (0);
}
EOF
- ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -313,6 +635,9 @@ EOF
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit 0 ;;
+ *9??*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit 0 ;;
@@ -329,6 +654,9 @@ EOF
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
+ hppa*:OpenBSD:*:*)
+ echo hppa-unknown-openbsd
+ exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
@@ -359,101 +687,334 @@ EOF
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
exit 0 ;;
CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE}
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3D:*:*:*)
+ echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
F300:UNIX_System_V:*:*)
- FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
F301:UNIX_System_V:*:*)
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
exit 0 ;;
- hp3[0-9][05]:NetBSD:*:*)
- echo m68k-hp-netbsd${UNAME_RELEASE}
- exit 0 ;;
- hp3[0-9][05]:OpenBSD:*:*)
- echo m68k-hp-openbsd${UNAME_RELEASE}
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
- i?86:BSD/386:*:* | *:BSD/OS:*:*)
+ i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
- *:NetBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
i*:CYGWIN*:*)
- echo i386-pc-cygwin32
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i386-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
exit 0 ;;
p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin32
+ echo powerpcle-unknown-cygwin
exit 0 ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
- echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
exit 0 ;;
*:Linux:*:*)
+
# The BFD linker knows what the default object file format is, so
- # first see if it will tell us.
- ld_help_string=`ld --help 2>&1`
- if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then
- echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0
- elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then
- echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0
- elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then
- echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0
- elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then
- echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0
- elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then
- echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0
- elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then
- echo "powerpc-unknown-linux-gnu" ; exit 0
- elif test "${UNAME_MACHINE}" = "alpha" ; then
- echo alpha-unknown-linux-gnu ; exit 0
- elif test "${UNAME_MACHINE}" = "sparc" ; then
- echo sparc-unknown-linux-gnu ; exit 0
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ ld_supported_emulations=`cd /; ld --help 2>&1 \
+ | sed -ne '/supported emulations:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported emulations: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_emulations" in
+ *ia64)
+ echo "${UNAME_MACHINE}-unknown-linux"
+ exit 0
+ ;;
+ i?86linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0
+ ;;
+ elf_i?86)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ i?86coff)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0
+ ;;
+ sparclinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ elf32_sparc)
+ echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ exit 0
+ ;;
+ armlinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ elf32arm*)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
+ exit 0
+ ;;
+ armelf_linux*)
+ echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ exit 0
+ ;;
+ m68klinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ elf32ppc | elf32ppclinux)
+ # Determine Lib Version
+ cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#if defined(__GLIBC__)
+ printf("%s %s\n", __libc_version, __libc_release);
+#else
+ printf("unkown\n");
+#endif
+ return 0;
+}
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./$dummy | grep 1\.99 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.c $dummy
+ echo powerpc-unknown-linux-gnu${LIBC}
+ exit 0
+ ;;
+ shelf_linux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ exit 0
+ ;;
+ esac
+
+ if test "${UNAME_MACHINE}" = "alpha" ; then
+ cat <<EOF >$dummy.s
+ .data
+ \$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
+ .globl main
+ .align 4
+ .ent main
+ main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ case `./$dummy` in
+ 0-0)
+ UNAME_MACHINE="alpha"
+ ;;
+ 1-0)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 1-1)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 1-101)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 2-303)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
+ esac
+
+ objdump --private-headers $dummy | \
+ grep ld.so.1 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
+ elif test "${UNAME_MACHINE}" = "mips" ; then
+ cat >$dummy.c <<EOF
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __MIPSEB__
+ printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+ printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ elif test "${UNAME_MACHINE}" = "s390"; then
+ echo s390-ibm-linux && exit 0
+ elif test "${UNAME_MACHINE}" = "x86_64"; then
+ echo x86_64-unknown-linux-gnu && exit 0
+ elif test "${UNAME_MACHINE}" = "parisc" -o "${UNAME_MACHINE}" = "hppa"; then
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*)
+ echo hppa1.1-unknown-linux-gnu
+ ;;
+ PA8*)
+ echo hppa2.0-unknown-linux-gnu
+ ;;
+ *)
+ echo hppa-unknown-linux-gnu
+ ;;
+ esac
+ exit 0
else
- # Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us
- # useful --help. Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout.
- test ! -d /usr/lib/ldscripts/. \
+ # Either a pre-BFD a.out linker (linux-gnuoldld)
+ # or one that does not give us useful --help.
+ # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+ # If ld does not provide *any* "supported emulations:"
+ # that means it is gnuoldld.
+ test -z "$ld_supported_emulations" \
&& echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+
+ case "${UNAME_MACHINE}" in
+ i?86)
+ VENDOR=pc;
+ ;;
+ *)
+ VENDOR=unknown;
+ ;;
+ esac
# Determine whether the default compiler is a.out or elf
- cat >dummy.c <<EOF
-main(argc, argv)
-int argc;
-char *argv[];
-{
+ cat >$dummy.c <<EOF
+#include <features.h>
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
#ifdef __ELF__
- printf ("%s-pc-linux-gnu\n", argv[1]);
+# ifdef __GLIBC__
+# if __GLIBC__ >= 2
+ printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
#else
- printf ("%s-pc-linux-gnuaout\n", argv[1]);
+ printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
#endif
return 0;
}
EOF
- ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
i?86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
+ i?86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit 0 ;;
+ i?86:*:5:7*)
+ # Fixed at (any) Pentium or better
+ UNAME_MACHINE=i586
+ if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+ echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
i?86:*:3.2:*)
@@ -465,11 +1026,24 @@ EOF
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
+ i?86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit 0 ;;
@@ -489,7 +1063,7 @@ EOF
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -506,7 +1080,7 @@ EOF
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
- i?86:LynxOS:2.*:*)
+ i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
@@ -518,6 +1092,9 @@ EOF
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit 0 ;;
@@ -529,6 +1106,10 @@ EOF
echo ns32k-sni-sysv
fi
exit 0 ;;
+ PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
@@ -541,23 +1122,83 @@ EOF
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
- R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Darwin:*:*)
+ echo `uname -p`-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ if test "${UNAME_MACHINE}" = "x86pc"; then
+ UNAME_MACHINE=pc
+ fi
+ echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit 0 ;;
+ NSR-[KW]:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit 0 ;;
+ i?86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-cat >dummy.c <<EOF
+cat >$dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
# include <sys/utsname.h>
@@ -595,7 +1236,10 @@ main ()
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
@@ -655,8 +1299,8 @@ main ()
}
EOF
-${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
-rm -f dummy.c dummy
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
# Apollos put the system type in the environment.
@@ -688,6 +1332,47 @@ then
esac
fi
-#echo '(Unable to guess system type)' 1>&2
+cat >&2 <<EOF
+$0: unable to guess system type
+
+The $version version of this script cannot recognize your system type.
+Please download the most up to date version of the config scripts:
+
+ ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess version = $version
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in
index f07e42a..3692681 100644
--- a/contrib/tcpdump/config.h.in
+++ b/contrib/tcpdump/config.h.in
@@ -18,46 +18,21 @@
byte first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
-/* Define if you have SSLeay XXX why isn't this HAVE_LIBCRYPTO? */
-#undef CRYPTO
-
/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
#undef HAVE_BUGGY_CAST128
-/* Define both to enable IPv6 support XXX why 2? ENABLE_IPV6 is not used. */
-#undef ENABLE_IPV6
+/* Define if you enable IPv6 support */
#undef INET6
/* Define if you enable support for the libsmi. */
#undef LIBSMI
-/* Is T_AAAA predefined? */
-#undef HAVE_AAAA
-
-/* Fallback definition if not in headers */
-/* XXX why is this not #ifndef HAVE_AAA #define T_AAAA ... ? */
-/* XXX or even #ifndef T_AAAA ... */
-#undef T_AAAA
-
/* define if you have struct __res_state_ext */
#undef HAVE_RES_STATE_EXT
/* define if your struct __res_state has the nsort member */
#undef HAVE_NEW_RES_STATE
-/*
- * define if struct ether_header.ether_dhost is a struct with ether_addr_octet
- */
-#undef ETHER_HEADER_HAS_EA
-
-/*
- * define if struct ether_arp.arp_sha is a struct with ether_addr_octet
- */
-#undef ETHER_ARP_HAS_EA
-
-/* define if struct ether_arp contains arp_xsha */
-#undef ETHER_ARP_HAS_X
-
/* define if you have the addrinfo function. */
#undef HAVE_ADDRINFO
@@ -73,15 +48,9 @@
/* define if INADDRSZ is defined (XXX not used!) */
#undef HAVE_INADDRSZ
-/* define if you have <net/slip.h> */
-#undef HAVE_NET_SLIP_H
-
/* define if this is a development version, to use additional prototypes. */
#undef HAVE_OS_PROTO_H
-/* define if <unistd.h> defines __P() */
-#undef HAVE_PORTABLE_PROTOTYPE
-
/* define if RES_USE_INET6 is defined */
#undef HAVE_RES_USE_INET6
@@ -91,6 +60,9 @@
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
+/* define if you have both getipnodebyname() and getipnodebyaddr() */
+#undef USE_GETIPNODEBY
+
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@@ -106,9 +78,6 @@
/* AIX hack. */
#undef _SUN
-/* OSF hack: "Workaround around ip_hl vs. ip_vhl problem in netinet/ip.h" */
-#undef __STDC__
-
/* Workaround for missing sized types */
/* XXX this should move to the more standard uint*_t */
#undef int16_t
@@ -129,14 +98,23 @@
/* The number of bytes in a short. */
#undef SIZEOF_SHORT
+/* Define if you have the bpf_dump function. */
+#undef HAVE_BPF_DUMP
+
/* Define if you have the ether_ntohost function. */
#undef HAVE_ETHER_NTOHOST
+/* Define if you have the freeaddrinfo function. */
+#undef HAVE_FREEADDRINFO
+
/* Define if you have the getaddrinfo function. */
#undef HAVE_GETADDRINFO
-/* Define if you have the gethostbyname2 function. */
-#undef HAVE_GETHOSTBYNAME2
+/* Define if you have the getipnodebyaddr function. */
+#undef HAVE_GETIPNODEBYADDR
+
+/* Define if you have the getipnodebyname function. */
+#undef HAVE_GETIPNODEBYNAME
/* Define if you have the getnameinfo function. */
#undef HAVE_GETNAMEINFO
@@ -162,26 +140,32 @@
/* Define if you have the sigset function. */
#undef HAVE_SIGSET
+/* Define if you have the snprintf function. */
+#undef HAVE_SNPRINTF
+
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
+/* Define if you have the strlcat function. */
+#undef HAVE_STRLCAT
+
+/* Define if you have the strlcpy function. */
+#undef HAVE_STRLCPY
+
/* Define if you have the vfprintf function. */
#undef HAVE_VFPRINTF
+/* Define if you have the vsnprintf function. */
+#undef HAVE_VSNPRINTF
+
/* Define if you have the <cast.h> header file. */
#undef HAVE_CAST_H
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
-/* Define if you have the <malloc.h> header file. */
-#undef HAVE_MALLOC_H
-
-/* Define if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define if you have the <net/slip.h> header file. */
-#undef HAVE_NET_SLIP_H
+/* Define if you have the <netinet/if_ether.h> header file. */
+#undef HAVE_NETINET_IF_ETHER_H
/* Define if you have the <rc5.h> header file. */
#undef HAVE_RC5_H
@@ -192,15 +176,15 @@
/* Define if you have the <smi.h> header file. */
#undef HAVE_SMI_H
-/* Define if you have the <zlib.h> header file. */
-#undef HAVE_ZLIB_H
-
/* Define if you have the crypto library (-lcrypto). */
#undef HAVE_LIBCRYPTO
/* Define if you have the dnet library (-ldnet). */
#undef HAVE_LIBDNET
+/* Define if you have the nsl library (-lnsl). */
+#undef HAVE_LIBNSL
+
/* Define if you have the resolv library (-lresolv). */
#undef HAVE_LIBRESOLV
@@ -216,5 +200,6 @@
/* Define if you have the str library (-lstr). */
#undef HAVE_LIBSTR
-/* Define if you have the z library (-lz). */
-#undef HAVE_LIBZ
+/* define if your compiler has __attribute__ */
+#undef HAVE___ATTRIBUTE__
+
diff --git a/contrib/tcpdump/config.sub b/contrib/tcpdump/config.sub
index 0432524..4849dfd 100755
--- a/contrib/tcpdump/config.sub
+++ b/contrib/tcpdump/config.sub
@@ -1,6 +1,10 @@
#! /bin/sh
-# Configuration validation subroutine script, version 1.1.
-# Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Free Software Foundation, Inc.
+
+timestamp='2000-12-15'
+
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
@@ -25,6 +29,8 @@
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
+# Please send patches to <config-patches@gnu.org>.
+#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
@@ -45,30 +51,73 @@
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
-if [ x$1 = x ]
-then
- echo Configuration name missing. 1>&2
- echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
- echo "or $0 ALIAS" 1>&2
- echo where ALIAS is a recognized configuration type. 1>&2
- exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
-# First pass through any local machine types.
-case $1 in
- *local*)
- echo $1
- exit 0
- ;;
- *)
- ;;
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- linux-gnu*)
+ nto-qnx* | linux-gnu* | storm-chaos*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -94,15 +143,25 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple)
+ -apple | -axis)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
-hiux*)
os=-hiuxwe2
;;
-sco5)
- os=sco3.2v5
+ os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
@@ -121,6 +180,9 @@ case $os in
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -143,25 +205,47 @@ case $os in
-psos*)
os=-psos
;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
- tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \
- | arme[lb] | pyramid \
- | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
- | alpha | we32k | ns16k | clipper | i370 | sh \
- | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
- | pdp11 | mips64el | mips64orion | mips64orionel \
- | sparc | sparclet | sparclite | sparc64)
+ tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
+ | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
+ | pyramid | mn10200 | mn10300 | tron | a29k \
+ | 580 | i960 | h8300 \
+ | x86 | ppcbe | mipsbe | mipsle | shbe | shle \
+ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+ | hppa64 \
+ | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+ | alphaev6[78] \
+ | we32k | ns16k | clipper | i370 | sh | sh[34] \
+ | powerpc | powerpcle \
+ | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+ | mips64orion | mips64orionel | mipstx39 | mipstx39el \
+ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+ | mips64vr5000 | miprs64vr5000el | mcore \
+ | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+ | thumb | d10v | d30v | fr30 | avr)
basic_machine=$basic_machine-unknown
;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
+ ;;
+
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
- i[3456]86)
+ i[234567]86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@@ -170,23 +254,50 @@ case $basic_machine in
exit 1
;;
# Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
- | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
- | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
- | hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
- | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
- | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-* | f301-*)
+ # FIXME: clean up the formatting here.
+ vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
+ | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+ | xmp-* | ymp-* \
+ | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+ | hppa2.0n-* | hppa64-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+ | alphaev6[78]-* \
+ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+ | clipper-* | orion-* \
+ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+ | mipstx39-* | mipstx39el-* | mcore-* \
+ | f30[01]-* | s390-* | sv1-* | t3e-* \
+ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+ | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+ | bs2000-* | tic54x-* | c54x-* | x86_64-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
alliant | fx80)
basic_machine=fx80-alliant
;;
@@ -202,20 +313,24 @@ case $basic_machine in
os=-sysv
;;
amiga | amiga-*)
- basic_machine=m68k-cbm
+ basic_machine=m68k-unknown
;;
- amigados)
- basic_machine=m68k-cbm
- os=-amigados
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
;;
amigaunix | amix)
- basic_machine=m68k-cbm
+ basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
aux)
basic_machine=m68k-apple
os=-aux
@@ -259,6 +374,9 @@ case $basic_machine in
crds | unos)
basic_machine=m68k-crds
;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
da30 | da30-*)
basic_machine=m68k-da30
;;
@@ -292,6 +410,10 @@ case $basic_machine in
encore | umax | mmax)
basic_machine=ns32k-encore
;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
fx2800)
basic_machine=i860-alliant
;;
@@ -310,6 +432,14 @@ case $basic_machine in
basic_machine=h8300-hitachi
os=-hms
;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
harris)
basic_machine=m88k-harris
os=-sysv3
@@ -325,13 +455,30 @@ case $basic_machine in
basic_machine=m68k-hp
os=-hpux
;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
- hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
@@ -340,27 +487,54 @@ case $basic_machine in
hppa-next)
os=-nextstep3
;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
- os=-mvs
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[3456]86v32)
+ i[34567]86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
- i[3456]86v4*)
+ i[34567]86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
- i[3456]86v)
+ i[34567]86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
- i[3456]86sol2)
+ i[34567]86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ i386-go32 | go32)
+ basic_machine=i386-unknown
+ os=-go32
+ ;;
+ i386-mingw32 | mingw32)
+ basic_machine=i386-unknown
+ os=-mingw32
+ ;;
+ i[34567]86-pw32 | pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
@@ -389,16 +563,52 @@ case $basic_machine in
miniframe)
basic_machine=m68000-convergent
;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mipsel*-linux*)
+ basic_machine=mipsel-unknown
+ os=-linux-gnu
+ ;;
+ mips*-linux*)
+ basic_machine=mips-unknown
+ os=-linux-gnu
+ ;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ msdos)
+ basic_machine=i386-unknown
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
@@ -411,6 +621,10 @@ case $basic_machine in
basic_machine=mips-sony
os=-newsos
;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
next | m*-next )
basic_machine=m68k-next
case $os in
@@ -436,9 +650,32 @@ case $basic_machine in
basic_machine=i960-intel
os=-nindy
;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
np1)
basic_machine=np1-gould
;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
@@ -456,30 +693,28 @@ case $basic_machine in
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
- pentium | p5)
- basic_machine=i586-intel
+ pentium | p5 | k5 | k6 | nexgen)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon)
+ basic_machine=i686-pc
;;
- pentiumpro | p6)
- basic_machine=i686-intel
+ pentiumii | pentium2)
+ basic_machine=i686-pc
;;
- pentium-* | p5-*)
+ pentium-* | p5-* | k5-* | k6-* | nexgen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- pentiumpro-* | p6-*)
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- k5)
- # We don't have specific support for AMD's K5 yet, so just call it a Pentium
- basic_machine=i586-amd
- ;;
- nexen)
- # We don't have specific support for Nexgen yet, so just call it a Pentium
- basic_machine=i586-nexgen
+ pentiumii-* | pentium2-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
- power) basic_machine=rs6000-ibm
+ power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
@@ -494,12 +729,20 @@ case $basic_machine in
ps2)
basic_machine=i386-ibm
;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
sequent)
basic_machine=i386-sequent
;;
@@ -507,6 +750,10 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
+ sparclite-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
sps7)
basic_machine=m68k-bull
os=-sysv2
@@ -514,6 +761,13 @@ case $basic_machine in
spur)
basic_machine=spur-unknown
;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
sun2)
basic_machine=m68000-sun
;;
@@ -554,10 +808,28 @@ case $basic_machine in
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
+ t3e)
+ basic_machine=t3e-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
tower | tower-32)
basic_machine=m68k-ncr
;;
@@ -569,6 +841,10 @@ case $basic_machine in
basic_machine=a29k-nyu
os=-sym1
;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
vaxv)
basic_machine=vax-dec
os=-sysv
@@ -577,7 +853,7 @@ case $basic_machine in
basic_machine=vax-dec
os=-vms
;;
- vpp*|vx|vx-*)
+ vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
@@ -592,6 +868,14 @@ case $basic_machine in
basic_machine=a29k-wrs
os=-vxworks
;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
xmp)
basic_machine=xmp-cray
os=-unicos
@@ -599,6 +883,10 @@ case $basic_machine in
xps | xps100)
basic_machine=xps100-honeywell
;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
none)
basic_machine=none-none
os=-none
@@ -606,8 +894,21 @@ case $basic_machine in
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
mips)
- basic_machine=mips-mips
+ if [ x$os = x-linux-gnu ]; then
+ basic_machine=mips-unknown
+ else
+ basic_machine=mips-mips
+ fi
;;
romp)
basic_machine=romp-ibm
@@ -624,7 +925,10 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
- sparc)
+ sh3 | sh4)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv9)
basic_machine=sparc-sun
;;
cydra)
@@ -636,6 +940,16 @@ case $basic_machine in
orion105)
basic_machine=clipper-highlevel
;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ c4x*)
+ basic_machine=c4x-none
+ os=-coff
+ ;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@@ -668,9 +982,12 @@ case $os in
-solaris)
os=-solaris2
;;
- -unixware* | svr4*)
+ -svr4*)
os=-sysv4
;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
@@ -681,17 +998,39 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
- | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -linux-gnu* | -uxpv*)
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* | -storm-chaos*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i[34567]86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto*)
+ os=-nto-qnx
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
@@ -701,6 +1040,12 @@ case $os in
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
+ -opened*)
+ os=-openedition
+ ;;
+ -wince*)
+ os=-wince
+ ;;
-osfrose*)
os=-osfrose
;;
@@ -716,12 +1061,18 @@ case $os in
-acis*)
os=-aos
;;
+ -386bsd)
+ os=-bsd
+ ;;
-ctix* | -uts*)
os=-sysv
;;
-ns2 )
os=-nextstep2
;;
+ -nsk*)
+ os=-nsk
+ ;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
@@ -747,9 +1098,18 @@ case $os in
# This must come after -sysvr4.
-sysv*)
;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
-xenix)
os=-xenix
;;
+ -*mint | -*MiNT)
+ os=-mint
+ ;;
-none)
;;
*)
@@ -775,6 +1135,9 @@ case $basic_machine in
*-acorn)
os=-riscix1.2
;;
+ arm*-rebel)
+ os=-linux
+ ;;
arm*-semi)
os=-aout
;;
@@ -796,15 +1159,36 @@ case $basic_machine in
# default.
# os=-sunos4
;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
+ *-be)
+ os=-beos
+ ;;
*-ibm)
os=-aix
;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
*-hp)
os=-hpux
;;
@@ -815,7 +1199,7 @@ case $basic_machine in
os=-sysv
;;
*-cbm)
- os=-amigados
+ os=-amigaos
;;
*-dg)
os=-dgux
@@ -865,9 +1249,21 @@ case $basic_machine in
*-masscomp)
os=-rtu
;;
- f301-fujitsu)
+ f30[01]-fujitsu)
os=-uxpv
;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
*)
os=-none
;;
@@ -889,9 +1285,15 @@ case $basic_machine in
-aix*)
vendor=ibm
;;
+ -beos*)
+ vendor=be
+ ;;
-hpux*)
vendor=hp
;;
+ -mpeix*)
+ vendor=hp
+ ;;
-hiux*)
vendor=hitachi
;;
@@ -907,7 +1309,7 @@ case $basic_machine in
-genix*)
vendor=ns
;;
- -mvs*)
+ -mvs* | -opened*)
vendor=ibm
;;
-ptx*)
@@ -919,9 +1321,26 @@ case $basic_machine in
-aux*)
vendor=apple
;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -*MiNT)
+ vendor=atari
+ ;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure
index 3c5cfa4..bb8eb99 100755
--- a/contrib/tcpdump/configure
+++ b/contrib/tcpdump/configure
@@ -1,5 +1,67 @@
#! /bin/sh
+# From configure.in Revision: 1.132.4.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
@@ -16,6 +78,8 @@ ac_help="$ac_help
ac_help="$ac_help
--enable-ipv6 enable ipv6 (with ipv4) support
--disable-ipv6 disable ipv6 support"
+ac_help="$ac_help
+ --without-crypto disable crypto support"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -574,7 +638,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:578: checking host system type" >&5
+echo "configure:642: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -595,7 +659,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:599: checking target system type" >&5
+echo "configure:663: checking target system type" >&5
target_alias=$target
case "$target_alias" in
@@ -613,7 +677,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$target" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:617: checking build system type" >&5
+echo "configure:681: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@@ -636,12 +700,6 @@ test "$host_alias" != "$target_alias" &&
program_prefix=${target_alias}-
-umask 002
-
-if test -z "$PWD" ; then
- PWD=`pwd`
-fi
-
@@ -667,7 +725,7 @@ fi
# Extract the first word of "shlicc2", so it can be a program name with args.
set dummy shlicc2; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:671: checking for $ac_word" >&5
+echo "configure:729: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_SHLICC2'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -708,7 +766,7 @@ fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:712: checking for $ac_word" >&5
+echo "configure:770: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -738,7 +796,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:742: checking for $ac_word" >&5
+echo "configure:800: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -789,7 +847,7 @@ fi
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:793: checking for $ac_word" >&5
+echo "configure:851: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -821,7 +879,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:825: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:883: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -832,12 +890,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 836 "configure"
+#line 894 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -863,12 +921,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:867: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:925: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:872: checking whether we are using GNU C" >&5
+echo "configure:930: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -877,7 +935,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:881: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:939: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -896,7 +954,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:900: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:958: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -933,7 +991,7 @@ fi
V_CCOPT="-O2"
else
echo $ac_n "checking gcc version""... $ac_c" 1>&6
-echo "configure:937: checking gcc version" >&5
+echo "configure:995: checking gcc version" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_gcc_vers'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -951,19 +1009,19 @@ fi
fi
else
echo $ac_n "checking that $CC handles ansi prototypes""... $ac_c" 1>&6
-echo "configure:955: checking that $CC handles ansi prototypes" >&5
+echo "configure:1013: checking that $CC handles ansi prototypes" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_cc_ansi_prototypes'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 960 "configure"
+#line 1018 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
int frob(int, char *)
; return 0; }
EOF
-if { (eval echo configure:967: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1025: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_ansi_prototypes=yes
else
@@ -981,21 +1039,21 @@ fi
hpux*)
echo $ac_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)""... $ac_c" 1>&6
-echo "configure:985: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
+echo "configure:1043: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
savedcflags="$CFLAGS"
CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
if eval "test \"`echo '$''{'ac_cv_lbl_cc_hpux_cc_aa'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 992 "configure"
+#line 1050 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
int frob(int, char *)
; return 0; }
EOF
-if { (eval echo configure:999: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_hpux_cc_aa=yes
else
@@ -1039,12 +1097,12 @@ EOF
ultrix*)
echo $ac_n "checking that Ultrix $CC hacks const in prototypes""... $ac_c" 1>&6
-echo "configure:1043: checking that Ultrix $CC hacks const in prototypes" >&5
+echo "configure:1101: checking that Ultrix $CC hacks const in prototypes" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_cc_const_proto'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1048 "configure"
+#line 1106 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
@@ -1052,7 +1110,7 @@ struct a { int b; };
void c(const struct a *)
; return 0; }
EOF
-if { (eval echo configure:1056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_const_proto=yes
else
@@ -1076,21 +1134,21 @@ EOF
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1080: checking for inline" >&5
+echo "configure:1138: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
-#line 1087 "configure"
+#line 1145 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:1094: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1152: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
@@ -1116,8 +1174,53 @@ EOF
esac
+echo $ac_n "checking for __attribute__""... $ac_c" 1>&6
+echo "configure:1179: checking for __attribute__" >&5
+if eval "test \"`echo '$''{'ac_cv___attribute__'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+cat > conftest.$ac_ext <<EOF
+#line 1185 "configure"
+#include "confdefs.h"
+
+#include <stdlib.h>
+
+int main() {
+
+static void foo(void) __attribute__ ((noreturn));
+
+static void
+foo(void)
+{
+ exit(1);
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:1202: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv___attribute__=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv___attribute__=no
+fi
+rm -f conftest*
+fi
+
+if test "$ac_cv___attribute__" = "yes"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE___ATTRIBUTE__ 1
+EOF
+
+fi
+echo "$ac_t""$ac_cv___attribute__" 1>&6
+
+
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1121: checking how to run the C preprocessor" >&5
+echo "configure:1224: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1132,13 +1235,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1136 "configure"
+#line 1239 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1142: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1245: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1149,13 +1252,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1153 "configure"
+#line 1256 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1159: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1262: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1166,13 +1269,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1170 "configure"
+#line 1273 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1176: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1279: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1196,21 +1299,21 @@ else
fi
echo "$ac_t""$CPP" 1>&6
-for ac_hdr in fcntl.h malloc.h memory.h rpc/rpcent.h
+for ac_hdr in fcntl.h rpc/rpcent.h netinet/if_ether.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1204: checking for $ac_hdr" >&5
+echo "configure:1307: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1209 "configure"
+#line 1312 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1214: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1317: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1237,12 +1340,12 @@ fi
done
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1241: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1344: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1246 "configure"
+#line 1349 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -1251,7 +1354,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1255: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1358: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -1276,65 +1379,33 @@ case "$target_os" in
linux*)
echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6
-echo "configure:1280: checking Linux kernel version" >&5
- if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then
+echo "configure:1383: checking Linux kernel version" >&5
+ if test "$cross_compiling" = yes; then
+ if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_linux_vers=unknown
+fi
+
+ else
+ if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_linux_vers=`uname -r 2>&1 | \
- sed -n -e '$s/.* //' -e '$s/\..*//p'`
+ sed -n -e '$s/.* //' -e '$s/\..*//p'`
fi
+ fi
echo "$ac_t""$ac_cv_linux_vers" 1>&6
+ if test $ac_cv_linux_vers = unknown ; then
+ { echo "configure: error: cannot determine linux version when cross-compiling" 1>&2; exit 1; }
+ fi
if test $ac_cv_linux_vers -lt 2 ; then
{ echo "configure: error: version 2 or higher required; see the INSTALL doc for more info" 1>&2; exit 1; }
fi
- cat >> confdefs.h <<\EOF
-#define HAVE_NET_SLIP_H 1
-EOF
-
;;
*)
- for ac_hdr in net/slip.h
-do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1303: checking for $ac_hdr" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1308 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1313: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
;;
esac
@@ -1343,17 +1414,17 @@ for ac_hdr in smi.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1347: checking for $ac_hdr" >&5
+echo "configure:1418: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1352 "configure"
+#line 1423 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1357: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1379,23 +1450,27 @@ else
fi
done
-echo $ac_n "checking for main in -lsmi""... $ac_c" 1>&6
-echo "configure:1384: checking for main in -lsmi" >&5
-ac_lib_var=`echo smi'_'main | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for smiInit in -lsmi""... $ac_c" 1>&6
+echo "configure:1455: checking for smiInit in -lsmi" >&5
+ac_lib_var=`echo smi'_'smiInit | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lsmi $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1392 "configure"
+#line 1463 "configure"
#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char smiInit();
int main() {
-main()
+smiInit()
; return 0; }
EOF
-if { (eval echo configure:1399: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1423,25 +1498,35 @@ else
fi
echo $ac_n "checking whether to enable libsmi""... $ac_c" 1>&6
-echo "configure:1427: checking whether to enable libsmi" >&5
+echo "configure:1502: checking whether to enable libsmi" >&5
if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+ echo "$ac_t""not when cross-compiling" 1>&6
+ libsmi=no
+
else
cat > conftest.$ac_ext <<EOF
-#line 1432 "configure"
+#line 1509 "configure"
#include "confdefs.h"
/* libsmi available check */
#include <smi.h>
main()
{
+ int current, revision, age, n;
+ const int required = 2;
if (smiInit(""))
exit(1);
- else
- exit(0);
+ if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
+ exit(2);
+ n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
+ if (n != 3)
+ exit(3);
+ if (required < current - age || required > current)
+ exit(4);
+ exit(0);
}
EOF
-if { (eval echo configure:1445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
echo "$ac_t""yes" 1>&6
cat >> confdefs.h <<\EOF
@@ -1455,7 +1540,6 @@ else
rm -fr conftest*
echo "$ac_t""no" 1>&6
libsmi=no
-
fi
rm -fr conftest*
fi
@@ -1464,16 +1548,12 @@ fi
CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6
-echo "configure:1468: checking whether to enable ipv6" >&5
+echo "configure:1552: checking whether to enable ipv6" >&5
# Check whether --enable-ipv6 or --disable-ipv6 was given.
if test "${enable_ipv6+set}" = set; then
enableval="$enable_ipv6"
case "$enableval" in
yes) echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define ENABLE_IPV6 1
-EOF
-
LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
cat >> confdefs.h <<\EOF
#define INET6 1
@@ -1493,7 +1573,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 1497 "configure"
+#line 1577 "configure"
#include "confdefs.h"
/* AF_INET6 available check */
#include <sys/types.h>
@@ -1507,13 +1587,9 @@ main()
}
EOF
-if { (eval echo configure:1511: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define ENABLE_IPV6 1
-EOF
-
LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
cat >> confdefs.h <<\EOF
#define INET6 1
@@ -1539,12 +1615,12 @@ ipv6trylibc=no
if test "$ipv6" = "yes"; then
echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6
-echo "configure:1543: checking ipv6 stack type" >&5
+echo "configure:1619: checking ipv6 stack type" >&5
for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
case $i in
inria)
cat > conftest.$ac_ext <<EOF
-#line 1548 "configure"
+#line 1624 "configure"
#include "confdefs.h"
dnl
#include <netinet/in.h>
@@ -1563,7 +1639,7 @@ rm -f conftest*
;;
kame)
cat > conftest.$ac_ext <<EOF
-#line 1567 "configure"
+#line 1643 "configure"
#include "confdefs.h"
dnl
#include <netinet/in.h>
@@ -1585,7 +1661,7 @@ rm -f conftest*
;;
linux-glibc)
cat > conftest.$ac_ext <<EOF
-#line 1589 "configure"
+#line 1665 "configure"
#include "confdefs.h"
dnl
#include <features.h>
@@ -1613,7 +1689,7 @@ rm -f conftest*
;;
toshiba)
cat > conftest.$ac_ext <<EOF
-#line 1617 "configure"
+#line 1693 "configure"
#include "confdefs.h"
dnl
#include <sys/param.h>
@@ -1634,7 +1710,7 @@ rm -f conftest*
;;
v6d)
cat > conftest.$ac_ext <<EOF
-#line 1638 "configure"
+#line 1714 "configure"
#include "confdefs.h"
dnl
#include </usr/local/v6/include/sys/v6config.h>
@@ -1655,7 +1731,7 @@ rm -f conftest*
;;
zeta)
cat > conftest.$ac_ext <<EOF
-#line 1659 "configure"
+#line 1735 "configure"
#include "confdefs.h"
dnl
#include <sys/param.h>
@@ -1700,63 +1776,72 @@ fi
if test "$ipv6" = "yes"; then
- for ac_func in getaddrinfo
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1707: checking for $ac_func" >&5
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+
+echo $ac_n "checking for library containing getaddrinfo""... $ac_c" 1>&6
+echo "configure:1782: checking for library containing getaddrinfo" >&5
+if eval "test \"`echo '$''{'ac_cv_search_getaddrinfo'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- cat > conftest.$ac_ext <<EOF
-#line 1712 "configure"
+ ac_func_search_save_LIBS="$LIBS"
+ac_cv_search_getaddrinfo="no"
+cat > conftest.$ac_ext <<EOF
+#line 1789 "configure"
#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char $ac_func();
+char getaddrinfo();
int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
+getaddrinfo()
; return 0; }
EOF
-if { (eval echo configure:1735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
+ ac_cv_search_getaddrinfo="none required"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+test "$ac_cv_search_getaddrinfo" = "no" && for i in socket; do
+LIBS="-l$i $ac_func_search_save_LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1811 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char getaddrinfo();
+
+int main() {
+getaddrinfo()
+; return 0; }
+EOF
+if { (eval echo configure:1822: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
+ ac_cv_search_getaddrinfo="-l$i"
+break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
fi
rm -f conftest*
+done
+LIBS="$ac_func_search_save_LIBS"
fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
- echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6
-echo "configure:1754: checking getaddrinfo bug" >&5
+echo "$ac_t""$ac_cv_search_getaddrinfo" 1>&6
+if test "$ac_cv_search_getaddrinfo" != "no"; then
+ test "$ac_cv_search_getaddrinfo" = "none required" || LIBS="$ac_cv_search_getaddrinfo $LIBS"
+ echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6
+echo "configure:1839: checking getaddrinfo bug" >&5
if test "$cross_compiling" = yes; then
echo "$ac_t""buggy" 1>&6
buggygetaddrinfo=yes
else
cat > conftest.$ac_ext <<EOF
-#line 1760 "configure"
+#line 1845 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -1853,7 +1938,7 @@ main()
}
EOF
-if { (eval echo configure:1857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
echo "$ac_t""good" 1>&6
buggygetaddrinfo=no
@@ -1867,12 +1952,9 @@ fi
rm -fr conftest*
fi
-else
- echo "$ac_t""no" 1>&6
-buggygetaddrinfo=yes
+else :
+ buggygetaddrinfo=yes
fi
-done
-
if test "$buggygetaddrinfo" = "yes"; then
if test "$ipv6type" != "linux"; then
@@ -1888,12 +1970,12 @@ done
for ac_func in getaddrinfo getnameinfo
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1892: checking for $ac_func" >&5
+echo "configure:1974: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1897 "configure"
+#line 1979 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1916,7 +1998,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1943,15 +2025,37 @@ done
fi
-for ac_func in inet_ntop inet_pton inet_aton
+echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
+echo "configure:2030: checking for inet_ntop" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2032 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+int main() {
+char src[4], dst[128];
+inet_ntop(AF_INET, src, dst, sizeof(dst));
+; return 0; }
+EOF
+if { (eval echo configure:2043: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+ for ac_func in inet_ntop
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1950: checking for $ac_func" >&5
+echo "configure:2054: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1955 "configure"
+#line 2059 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1974,7 +2078,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2000,88 +2104,213 @@ fi
done
+fi
+rm -f conftest*
+echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
+echo "configure:2111: checking for inet_pton" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2113 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+int main() {
+char src[128], dst[4];
+inet_pton(AF_INET, src, dst);
+; return 0; }
+EOF
+if { (eval echo configure:2124: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+ for ac_func in inet_pton
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2135: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2140 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:2163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
- echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
-echo "configure:2007: checking if sockaddr struct has sa_len member" >&5
- if eval "test \"`echo '$''{'ac_cv_sockaddr_has_sa_len'+set}'`\" = set"; then
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
+fi
+done
+
+
+fi
+rm -f conftest*
+echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
+echo "configure:2192: checking for inet_aton" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2194 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+int main() {
+char src[128];
+struct in_addr dst;
+inet_aton(src, &dst);
+; return 0; }
+EOF
+if { (eval echo configure:2205: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+ for ac_func in inet_aton
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2216: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2012 "configure"
+#line 2221 "configure"
#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
-# include <sys/types.h>
-# include <sys/socket.h>
int main() {
-u_int i = sizeof(((struct sockaddr *)0)->sa_len)
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
; return 0; }
EOF
-if { (eval echo configure:2021: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
- ac_cv_sockaddr_has_sa_len=yes
+ eval "ac_cv_func_$ac_func=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
- ac_cv_sockaddr_has_sa_len=no
+ eval "ac_cv_func_$ac_func=no"
fi
rm -f conftest*
fi
- echo "$ac_t""$ac_cv_sockaddr_has_sa_len" 1>&6
- if test $ac_cv_sockaddr_has_sa_len = yes ; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SOCKADDR_SA_LEN 1
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
EOF
+
+else
+ echo "$ac_t""no" 1>&6
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
+fi
+done
- fi
-if test "$ac_cv_sockaddr_has_sa_len" = no; then
- missing_includes=yes
fi
+rm -f conftest*
- echo $ac_n "checking for __P""... $ac_c" 1>&6
-echo "configure:2047: checking for __P" >&5
- if eval "test \"`echo '$''{'ac_cv_portable_proto'+set}'`\" = set"; then
+ echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
+echo "configure:2275: checking if sockaddr struct has sa_len member" >&5
+ if eval "test \"`echo '$''{'ac_cv_sockaddr_has_sa_len'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2052 "configure"
+#line 2280 "configure"
#include "confdefs.h"
-# include <unistd.h>
+# include <sys/types.h>
+# include <sys/socket.h>
int main() {
-int f __P(())
+u_int i = sizeof(((struct sockaddr *)0)->sa_len)
; return 0; }
EOF
-if { (eval echo configure:2060: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2289: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
- ac_cv_portable_proto=yes
+ ac_cv_sockaddr_has_sa_len=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
- ac_cv_portable_proto=no
+ ac_cv_sockaddr_has_sa_len=no
fi
rm -f conftest*
fi
- echo "$ac_t""$ac_cv_portable_proto" 1>&6
- if test $ac_cv_portable_proto = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_PORTABLE_PROTOTYPE 1
+ echo "$ac_t""$ac_cv_sockaddr_has_sa_len" 1>&6
+ if test $ac_cv_sockaddr_has_sa_len = yes ; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_SOCKADDR_SA_LEN 1
EOF
fi
-if test "$ac_cv_portable_proto" = no; then
+if test "$ac_cv_sockaddr_has_sa_len" = no; then
missing_includes=yes
fi
echo $ac_n "checking size of char""... $ac_c" 1>&6
-echo "configure:2085: checking size of char" >&5
+echo "configure:2314: checking size of char" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2089,7 +2318,7 @@ else
ac_cv_sizeof_char=1
else
cat > conftest.$ac_ext <<EOF
-#line 2093 "configure"
+#line 2322 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2100,7 +2329,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_char=`cat conftestval`
else
@@ -2120,7 +2349,7 @@ EOF
echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:2124: checking size of short" >&5
+echo "configure:2353: checking size of short" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2128,7 +2357,7 @@ else
ac_cv_sizeof_short=2
else
cat > conftest.$ac_ext <<EOF
-#line 2132 "configure"
+#line 2361 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2139,7 +2368,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_short=`cat conftestval`
else
@@ -2159,7 +2388,7 @@ EOF
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:2163: checking size of int" >&5
+echo "configure:2392: checking size of int" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2167,7 +2396,7 @@ else
ac_cv_sizeof_int=4
else
cat > conftest.$ac_ext <<EOF
-#line 2171 "configure"
+#line 2400 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2178,7 +2407,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_int=`cat conftestval`
else
@@ -2198,7 +2427,7 @@ EOF
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:2202: checking size of long" >&5
+echo "configure:2431: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2206,7 +2435,7 @@ else
ac_cv_sizeof_long=4
else
cat > conftest.$ac_ext <<EOF
-#line 2210 "configure"
+#line 2439 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2217,7 +2446,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
@@ -2240,12 +2469,12 @@ EOF
echo $ac_n "checking for addrinfo""... $ac_c" 1>&6
-echo "configure:2244: checking for addrinfo" >&5
+echo "configure:2473: checking for addrinfo" >&5
if eval "test \"`echo '$''{'ac_cv_addrinfo'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2249 "configure"
+#line 2478 "configure"
#include "confdefs.h"
# include <netdb.h>
@@ -2253,7 +2482,7 @@ int main() {
struct addrinfo a
; return 0; }
EOF
-if { (eval echo configure:2257: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_addrinfo=yes
else
@@ -2284,12 +2513,12 @@ fi
echo $ac_n "checking for NI_MAXSERV""... $ac_c" 1>&6
-echo "configure:2288: checking for NI_MAXSERV" >&5
+echo "configure:2517: checking for NI_MAXSERV" >&5
if eval "test \"`echo '$''{'ac_cv_maxserv'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2293 "configure"
+#line 2522 "configure"
#include "confdefs.h"
#include <netdb.h>
#ifdef NI_MAXSERV
@@ -2322,12 +2551,12 @@ fi
echo $ac_n "checking for NI_NAMEREQD""... $ac_c" 1>&6
-echo "configure:2326: checking for NI_NAMEREQD" >&5
+echo "configure:2555: checking for NI_NAMEREQD" >&5
if eval "test \"`echo '$''{'ac_cv_namereqd'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2331 "configure"
+#line 2560 "configure"
#include "confdefs.h"
#include <netdb.h>
#ifdef NI_NOFQDN
@@ -2360,12 +2589,12 @@ fi
echo $ac_n "checking for sockaddr_storage""... $ac_c" 1>&6
-echo "configure:2364: checking for sockaddr_storage" >&5
+echo "configure:2593: checking for sockaddr_storage" >&5
if eval "test \"`echo '$''{'ac_cv_sa_storage'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2369 "configure"
+#line 2598 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2374,7 +2603,7 @@ int main() {
struct sockaddr_storage s
; return 0; }
EOF
-if { (eval echo configure:2378: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2607: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_sa_storage=yes
else
@@ -2401,12 +2630,12 @@ fi
ac_cv_addrsz=yes
echo $ac_n "checking for INADDRSZ""... $ac_c" 1>&6
-echo "configure:2405: checking for INADDRSZ" >&5
+echo "configure:2634: checking for INADDRSZ" >&5
if eval "test \"`echo '$''{'ac_cv_inaddrsz'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2410 "configure"
+#line 2639 "configure"
#include "confdefs.h"
# include <arpa/nameser.h>
@@ -2414,7 +2643,7 @@ int main() {
int a = INADDRSZ
; return 0; }
EOF
-if { (eval echo configure:2418: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2647: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_inaddrsz=yes
else
@@ -2436,12 +2665,12 @@ EOF
ac_cv_addrsz=no
fi
echo $ac_n "checking for IN6ADDRSZ""... $ac_c" 1>&6
-echo "configure:2440: checking for IN6ADDRSZ" >&5
+echo "configure:2669: checking for IN6ADDRSZ" >&5
if eval "test \"`echo '$''{'ac_cv_in6addrsz'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2445 "configure"
+#line 2674 "configure"
#include "confdefs.h"
# include <arpa/nameser.h>
@@ -2449,7 +2678,7 @@ int main() {
int a = IN6ADDRSZ
; return 0; }
EOF
-if { (eval echo configure:2453: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_in6addrsz=yes
else
@@ -2477,12 +2706,12 @@ fi
echo $ac_n "checking for RES_USE_INET6""... $ac_c" 1>&6
-echo "configure:2481: checking for RES_USE_INET6" >&5
+echo "configure:2710: checking for RES_USE_INET6" >&5
if eval "test \"`echo '$''{'ac_cv_res_inet6'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2486 "configure"
+#line 2715 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2492,7 +2721,7 @@ int main() {
int a = RES_USE_INET6
; return 0; }
EOF
-if { (eval echo configure:2496: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_res_inet6=yes
else
@@ -2517,56 +2746,13 @@ if test "$ac_cv_res_inet6" = no; then
fi
- echo $ac_n "checking for AAAA""... $ac_c" 1>&6
-echo "configure:2522: checking for AAAA" >&5
- if eval "test \"`echo '$''{'ac_cv_aaaa'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2527 "configure"
-#include "confdefs.h"
-
-# include <sys/types.h>
-# include <arpa/nameser.h>
-int main() {
-int a = T_AAAA
-; return 0; }
-EOF
-if { (eval echo configure:2536: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_aaaa=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_aaaa=no
-fi
-rm -f conftest*
-fi
-
- echo "$ac_t""$ac_cv_aaaa" 1>&6
- if test $ac_cv_aaaa = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_AAAA 1
-EOF
-
- fi
-
-if test "$ac_cv_aaaa" = no; then
- cat >> confdefs.h <<\EOF
-#define T_AAAA 28
-EOF
-
-fi
-
-
echo $ac_n "checking for res_state_ext""... $ac_c" 1>&6
-echo "configure:2565: checking for res_state_ext" >&5
+echo "configure:2751: checking for res_state_ext" >&5
if eval "test \"`echo '$''{'ac_cv_res_state_ext'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2570 "configure"
+#line 2756 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2577,7 +2763,7 @@ int main() {
struct __res_state_ext e
; return 0; }
EOF
-if { (eval echo configure:2581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_res_state_ext=yes
else
@@ -2603,12 +2789,12 @@ fi
echo $ac_n "checking for nsort in res_state""... $ac_c" 1>&6
-echo "configure:2607: checking for nsort in res_state" >&5
+echo "configure:2793: checking for nsort in res_state" >&5
if eval "test \"`echo '$''{'ac_cv_res_state'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2612 "configure"
+#line 2798 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2619,7 +2805,7 @@ int main() {
struct __res_state e; e.nsort = 0
; return 0; }
EOF
-if { (eval echo configure:2623: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2809: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_res_state=yes
else
@@ -2646,15 +2832,15 @@ if test "$missing_includes" = "yes"; then
fi
-for ac_func in vfprintf strcasecmp
+for ac_func in vfprintf strcasecmp strlcat strlcpy
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2653: checking for $ac_func" >&5
+echo "configure:2839: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2658 "configure"
+#line 2844 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2677,7 +2863,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2703,15 +2889,15 @@ fi
done
-for ac_func in ether_ntohost setlinebuf gethostbyname2
+for ac_func in ether_ntohost setlinebuf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2710: checking for $ac_func" >&5
+echo "configure:2896: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2715 "configure"
+#line 2901 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2734,7 +2920,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2759,15 +2945,140 @@ fi
done
+usegetipnodeby=yes
+for ac_func in getipnodebyname getipnodebyaddr freeaddrinfo
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2953: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2958 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+usegetipnodeby=no
+fi
+done
+
+if test $usegetipnodeby = yes; then
+ cat >> confdefs.h <<\EOF
+#define USE_GETIPNODEBY 1
+EOF
+
+fi
+
+needsnprintf=no
+for ac_func in vsnprintf snprintf
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3017: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3022 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+needsnprintf=yes
+fi
+done
+
+if test $needsnprintf = yes; then
+ LIBOBJS="$LIBOBJS snprintf.o"
+fi
+
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:2764: checking whether byte ordering is bigendian" >&5
+echo "configure:3075: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
-#line 2771 "configure"
+#line 3082 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -2778,11 +3089,11 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:2782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3093: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
-#line 2786 "configure"
+#line 3097 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -2793,7 +3104,7 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:2797: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3108: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@@ -2813,7 +3124,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2817 "configure"
+#line 3128 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@@ -2826,7 +3137,7 @@ main () {
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:2830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
@@ -2851,7 +3162,7 @@ fi
echo $ac_n "checking for main in -ldnet""... $ac_c" 1>&6
-echo "configure:2855: checking for main in -ldnet" >&5
+echo "configure:3166: checking for main in -ldnet" >&5
ac_lib_var=`echo dnet'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2859,14 +3170,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldnet $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2863 "configure"
+#line 3174 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:2870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2894,7 +3205,7 @@ else
fi
echo $ac_n "checking for main in -lrpc""... $ac_c" 1>&6
-echo "configure:2898: checking for main in -lrpc" >&5
+echo "configure:3209: checking for main in -lrpc" >&5
ac_lib_var=`echo rpc'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2902,14 +3213,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lrpc $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2906 "configure"
+#line 3217 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:2913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2936,27 +3247,27 @@ else
echo "$ac_t""no" 1>&6
fi
-echo $ac_n "checking for uncompress in -lz""... $ac_c" 1>&6
-echo "configure:2941: checking for uncompress in -lz" >&5
-ac_lib_var=`echo z'_'uncompress | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for getrpcbynumber in -lnsl""... $ac_c" 1>&6
+echo "configure:3252: checking for getrpcbynumber in -lnsl" >&5
+ac_lib_var=`echo nsl'_'getrpcbynumber | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
-LIBS="-lz $LIBS"
+LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2949 "configure"
+#line 3260 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char uncompress();
+char getrpcbynumber();
int main() {
-uncompress()
+getrpcbynumber()
; return 0; }
EOF
-if { (eval echo configure:2960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2971,67 +3282,27 @@ LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo z | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ ac_tr_lib=HAVE_LIB`echo nsl | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
cat >> confdefs.h <<EOF
#define $ac_tr_lib 1
EOF
- LIBS="-lz $LIBS"
+ LIBS="-lnsl $LIBS"
else
echo "$ac_t""no" 1>&6
fi
-for ac_hdr in zlib.h
-do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2991: checking for $ac_hdr" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2996 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3001: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3030: checking return type of signal handlers" >&5
+echo "configure:3301: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3035 "configure"
+#line 3306 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -3048,7 +3319,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:3052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3323: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -3090,12 +3361,12 @@ EOF
for ac_func in sigset
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3094: checking for $ac_func" >&5
+echo "configure:3365: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3099 "configure"
+#line 3370 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3118,7 +3389,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3393: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -3146,12 +3417,12 @@ done
for ac_func in sigaction
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3150: checking for $ac_func" >&5
+echo "configure:3421: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3155 "configure"
+#line 3426 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3174,7 +3445,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3178: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -3206,12 +3477,12 @@ done
# Most operating systems have gethostbyname() in the default searched
# libraries (i.e. libc):
echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:3210: checking for gethostbyname" >&5
+echo "configure:3481: checking for gethostbyname" >&5
if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3215 "configure"
+#line 3486 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char gethostbyname(); below. */
@@ -3234,7 +3505,7 @@ gethostbyname();
; return 0; }
EOF
-if { (eval echo configure:3238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_gethostbyname=yes"
else
@@ -3253,7 +3524,7 @@ else
echo "$ac_t""no" 1>&6
# Some OSes (eg. Solaris) place it in libnsl:
echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:3257: checking for gethostbyname in -lnsl" >&5
+echo "configure:3528: checking for gethostbyname in -lnsl" >&5
ac_lib_var=`echo nsl'_'gethostbyname'_' | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3261,7 +3532,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3265 "configure"
+#line 3536 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3272,7 +3543,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:3276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -3299,7 +3570,7 @@ else
echo "$ac_t""no" 1>&6
# Some strange OSes (SINIX) have it in libsocket:
echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6
-echo "configure:3303: checking for gethostbyname in -lsocket" >&5
+echo "configure:3574: checking for gethostbyname in -lsocket" >&5
ac_lib_var=`echo socket'_'gethostbyname'_' | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3307,7 +3578,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3311 "configure"
+#line 3582 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3318,7 +3589,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:3322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -3347,7 +3618,7 @@ else
# AC_CHECK_LIB's API is essentially broken so the
# following ugliness is necessary:
echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6
-echo "configure:3351: checking for gethostbyname in -lsocket" >&5
+echo "configure:3622: checking for gethostbyname in -lsocket" >&5
ac_lib_var=`echo socket'_'gethostbyname'_'-lnsl | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3355,7 +3626,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket -lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3359 "configure"
+#line 3630 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3366,7 +3637,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:3370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -3385,7 +3656,7 @@ if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for gethostbyname in -lresolv""... $ac_c" 1>&6
-echo "configure:3389: checking for gethostbyname in -lresolv" >&5
+echo "configure:3660: checking for gethostbyname in -lresolv" >&5
ac_lib_var=`echo resolv'_'gethostbyname | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3393,7 +3664,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lresolv $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3397 "configure"
+#line 3668 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3404,7 +3675,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:3408: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3440,12 +3711,12 @@ fi
fi
echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:3444: checking for socket" >&5
+echo "configure:3715: checking for socket" >&5
if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3449 "configure"
+#line 3720 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char socket(); below. */
@@ -3468,7 +3739,7 @@ socket();
; return 0; }
EOF
-if { (eval echo configure:3472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_socket=yes"
else
@@ -3486,7 +3757,7 @@ if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:3490: checking for socket in -lsocket" >&5
+echo "configure:3761: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3494,7 +3765,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3498 "configure"
+#line 3769 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3505,7 +3776,7 @@ int main() {
socket()
; return 0; }
EOF
-if { (eval echo configure:3509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3531,7 +3802,7 @@ EOF
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:3535: checking for socket in -lsocket" >&5
+echo "configure:3806: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket'_'-lnsl | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3539,7 +3810,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket -lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3543 "configure"
+#line 3814 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3550,7 +3821,7 @@ int main() {
socket()
; return 0; }
EOF
-if { (eval echo configure:3554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -3576,7 +3847,7 @@ fi
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
echo $ac_n "checking for putmsg in -lstr""... $ac_c" 1>&6
-echo "configure:3580: checking for putmsg in -lstr" >&5
+echo "configure:3851: checking for putmsg in -lstr" >&5
ac_lib_var=`echo str'_'putmsg | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3584,7 +3855,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lstr $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3588 "configure"
+#line 3859 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3595,7 +3866,7 @@ int main() {
putmsg()
; return 0; }
EOF
-if { (eval echo configure:3599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3630,12 +3901,12 @@ fi
for ac_func in pfopen
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3634: checking for $ac_func" >&5
+echo "configure:3905: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3639 "configure"
+#line 3910 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3658,7 +3929,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -3688,11 +3959,11 @@ done
fi
fi
echo $ac_n "checking for local pcap library""... $ac_c" 1>&6
-echo "configure:3692: checking for local pcap library" >&5
+echo "configure:3963: checking for local pcap library" >&5
libpcap=FAIL
lastdir=FAIL
places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
- egrep '/libpcap-[0-9]*\.[0-9]*(\.[0-9]*)?([ab][0-9]*)?$'`
+ 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
@@ -3707,7 +3978,7 @@ echo "configure:3692: checking for local pcap library" >&5
if test $libpcap = FAIL ; then
echo "$ac_t""not found" 1>&6
echo $ac_n "checking for main in -lpcap""... $ac_c" 1>&6
-echo "configure:3711: checking for main in -lpcap" >&5
+echo "configure:3982: checking for main in -lpcap" >&5
ac_lib_var=`echo pcap'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3715,14 +3986,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3719 "configure"
+#line 3990 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:3726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3748,7 +4019,7 @@ fi
else
V_PCAPDEP=$libpcap
if test -r $d/pcap.h; then
- V_INCLS="-I$d $V_INCLS"
+ V_INCLS="-I$d $V_INCLS"
elif test -r $srcdir/../libpcap/pcap.h; then
V_INCLS="-I$d -I$srcdir/../libpcap $V_INCLS"
else
@@ -3762,7 +4033,7 @@ fi
aix*)
pseexe="/lib/pse.exp"
echo $ac_n "checking for $pseexe""... $ac_c" 1>&6
-echo "configure:3766: checking for $pseexe" >&5
+echo "configure:4037: checking for $pseexe" >&5
if test -f $pseexe ; then
echo "$ac_t""yes" 1>&6
LIBS="$LIBS -I:$pseexe"
@@ -3770,6 +4041,63 @@ echo "configure:3766: checking for $pseexe" >&5
;;
esac
+for ac_func in bpf_dump
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:4048: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4053 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:4076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
+fi
+done
+
+
V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
@@ -3787,16 +4115,8 @@ irix*)
V_GROUP=sys
;;
-linux*)
- V_INCLS="$V_INCLS -I\$(srcdir)/linux-include"
- ;;
-
osf*)
V_GROUP=system
- cat >> confdefs.h <<\EOF
-#define __STDC__ 2
-EOF
-
;;
solaris*)
@@ -3809,12 +4129,12 @@ if test -f /dev/bpf0 ; then
fi
echo $ac_n "checking for u_int8_t using $CC""... $ac_c" 1>&6
-echo "configure:3813: checking for u_int8_t using $CC" >&5
+echo "configure:4133: checking for u_int8_t using $CC" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int8_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3818 "configure"
+#line 4138 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -3827,7 +4147,7 @@ int main() {
u_int8_t i
; return 0; }
EOF
-if { (eval echo configure:3831: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4151: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_u_int8_t=yes
else
@@ -3847,12 +4167,12 @@ EOF
fi
echo $ac_n "checking for int16_t using $CC""... $ac_c" 1>&6
-echo "configure:3851: checking for int16_t using $CC" >&5
+echo "configure:4171: checking for int16_t using $CC" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_have_int16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3856 "configure"
+#line 4176 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -3865,7 +4185,7 @@ int main() {
int16_t i
; return 0; }
EOF
-if { (eval echo configure:3869: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_int16_t=yes
else
@@ -3885,12 +4205,12 @@ EOF
fi
echo $ac_n "checking for u_int16_t using $CC""... $ac_c" 1>&6
-echo "configure:3889: checking for u_int16_t using $CC" >&5
+echo "configure:4209: checking for u_int16_t using $CC" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3894 "configure"
+#line 4214 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -3903,7 +4223,7 @@ int main() {
u_int16_t i
; return 0; }
EOF
-if { (eval echo configure:3907: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_u_int16_t=yes
else
@@ -3923,12 +4243,12 @@ EOF
fi
echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6
-echo "configure:3927: checking for int32_t using $CC" >&5
+echo "configure:4247: checking for int32_t using $CC" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_have_int32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3932 "configure"
+#line 4252 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -3941,7 +4261,7 @@ int main() {
int32_t i
; return 0; }
EOF
-if { (eval echo configure:3945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_int32_t=yes
else
@@ -3961,12 +4281,12 @@ EOF
fi
echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6
-echo "configure:3965: checking for u_int32_t using $CC" >&5
+echo "configure:4285: checking for u_int32_t using $CC" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3970 "configure"
+#line 4290 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -3979,7 +4299,7 @@ int main() {
u_int32_t i
; return 0; }
EOF
-if { (eval echo configure:3983: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4303: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_u_int32_t=yes
else
@@ -4039,12 +4359,12 @@ EOF
fi
echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
-echo "configure:4043: checking if sockaddr struct has sa_len member" >&5
+echo "configure:4363: checking if sockaddr struct has sa_len member" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4048 "configure"
+#line 4368 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -4053,7 +4373,7 @@ int main() {
u_int i = sizeof(((struct sockaddr *)0)->sa_len)
; return 0; }
EOF
-if { (eval echo configure:4057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4377: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_sockaddr_has_sa_len=yes
else
@@ -4073,154 +4393,15 @@ EOF
fi
-echo $ac_n "checking if ether_header uses ether_addr structs""... $ac_c" 1>&6
-echo "configure:4078: checking if ether_header uses ether_addr structs" >&5
-if eval "test \"`echo '$''{'ac_cv_ether_header_has_ea'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- LBL_SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $V_INCLS"
- cat > conftest.$ac_ext <<EOF
-#line 4085 "configure"
-#include "confdefs.h"
-
-# include <sys/types.h>
-# if __STDC__
- /* osf3 has REALLY good prototyes */
- struct mbuf;
- struct rtentry;
-# endif
-# include <sys/socket.h>
-# include <net/if.h>
-# include <netinet/in.h>
-# include <netinet/if_ether.h>
-int main() {
-u_int i =
- sizeof(((struct ether_header *)0)->ether_dhost.ether_addr_octet)
-; return 0; }
-EOF
-if { (eval echo configure:4103: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_ether_header_has_ea=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_ether_header_has_ea=no
-fi
-rm -f conftest*
- CFLAGS="$LBL_SAVE_CFLAGS"
-fi
-
-echo "$ac_t""$ac_cv_ether_header_has_ea" 1>&6
-if test $ac_cv_ether_header_has_ea = yes ; then
- cat >> confdefs.h <<\EOF
-#define ETHER_HEADER_HAS_EA 1
-EOF
-
-fi
-
-echo $ac_n "checking if ether_arp uses ether_addr structs""... $ac_c" 1>&6
-echo "configure:4125: checking if ether_arp uses ether_addr structs" >&5
-if eval "test \"`echo '$''{'ac_cv_ether_arp_has_ea'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- LBL_SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $V_INCLS"
- cat > conftest.$ac_ext <<EOF
-#line 4132 "configure"
-#include "confdefs.h"
-
-# include <sys/types.h>
-# if __STDC__
- /* osf3 has REALLY good prototyes */
- struct mbuf;
- struct rtentry;
-# endif
-# include <sys/socket.h>
-# include <net/if.h>
-# include <netinet/in.h>
-# include <netinet/if_ether.h>
-int main() {
-u_int i =
- sizeof(((struct ether_arp *)0)->arp_sha.ether_addr_octet)
-; return 0; }
-EOF
-if { (eval echo configure:4150: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_ether_arp_has_ea=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_ether_arp_has_ea=no
-fi
-rm -f conftest*
- CFLAGS="$LBL_SAVE_CFLAGS"
-fi
-
-echo "$ac_t""$ac_cv_ether_arp_has_ea" 1>&6
-if test $ac_cv_ether_arp_has_ea = yes ; then
- cat >> confdefs.h <<\EOF
-#define ETHER_ARP_HAS_EA 1
-EOF
-
-fi
-
-echo $ac_n "checking if ether_arp uses erp_xsha member""... $ac_c" 1>&6
-echo "configure:4172: checking if ether_arp uses erp_xsha member" >&5
-if eval "test \"`echo '$''{'ac_cv_struct_ether_arp_x'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- LBL_SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $V_INCLS"
- cat > conftest.$ac_ext <<EOF
-#line 4179 "configure"
-#include "confdefs.h"
-
-# include <sys/types.h>
-# include <sys/socket.h>
-# if __STDC__
- /* osf3 has REALLY good prototyes */
- struct mbuf;
- struct rtentry;
-# endif
-# include <net/if.h>
-# include <netinet/in.h>
-# include <netinet/if_ether.h>
-int main() {
-u_int i = sizeof( ((struct ether_arp *)0)->arp_xsha)
-; return 0; }
-EOF
-if { (eval echo configure:4196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_struct_ether_arp_x=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_struct_ether_arp_x=no
-fi
-rm -f conftest*
- CFLAGS="$LBL_SAVE_CFLAGS"
-fi
-
-echo "$ac_t""$ac_cv_struct_ether_arp_x" 1>&6
-if test $ac_cv_struct_ether_arp_x = yes ; then
- cat >> confdefs.h <<\EOF
-#define ETHER_ARP_HAS_X 1
-EOF
-
-fi
-
echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
-echo "configure:4218: checking if unaligned accesses fail" >&5
+echo "configure:4398: checking if unaligned accesses fail" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$target_cpu" in
- alpha|hp*|mips|sparc)
+ # XXX: should also check that they don't do weird things (like on arm)
+ alpha*|arm*|hp*|mips|sparc)
ac_cv_lbl_unaligned_fail=yes
;;
@@ -4278,12 +4459,12 @@ EOF
echo $ac_n "checking for h_errno""... $ac_c" 1>&6
-echo "configure:4282: checking for h_errno" >&5
+echo "configure:4463: checking for h_errno" >&5
if eval "test \"`echo '$''{'ac_cv_var_h_errno'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4287 "configure"
+#line 4468 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -4292,7 +4473,7 @@ int main() {
int foo = h_errno;
; return 0; }
EOF
-if { (eval echo configure:4296: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4477: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_var_h_errno=yes
else
@@ -4313,22 +4494,26 @@ EOF
fi
+# Check whether --with-crypto or --without-crypto was given.
+if test "${with_crypto+set}" = set; then
+ withval="$with_crypto"
+ :
+else
+
echo $ac_n "checking for SSLeay""... $ac_c" 1>&6
-echo "configure:4318: checking for SSLeay" >&5
+echo "configure:4505: checking for SSLeay" >&5
ac_cv_ssleay_path=no
incdir=no
-for dir in /usr/local /usr/local/ssl /usr/pkg; do
+for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do
if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then
ac_cv_ssleay_path=$dir
fi
- if test -d $dir/include -a -f $dir/include/des.h; then
+ if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
+ incdir="-I$dir/include/ssleay"
+ elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
+ incdir="-I$dir/include -I$dir/include/openssl"
+ elif test -d $dir/include -a -f $dir/include/des.h; then
incdir="-I$dir/include"
- else
- if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
- incdir="-I$dir/include/ssleay"
- elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
- incdir="-I$dir/include -I$dir/include/openssl"
- fi
fi
if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
break;
@@ -4340,7 +4525,7 @@ done
echo "$ac_t""$ac_cv_ssleay_path" 1>&6
if test "$ac_cv_ssleay_path" != no; then
V_INCLS="$V_INCLS $incdir"
- LIBS="$LIBS -L$dir/lib"
+ LDFLAGS="-L$dir/lib $LDFLAGS"
if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
LIBS="$LIBS -lRSAglue"
fi
@@ -4348,7 +4533,7 @@ if test "$ac_cv_ssleay_path" != no; then
LIBS="$LIBS -lrsaref"
fi
echo $ac_n "checking for des_cbc_encrypt in -lcrypto""... $ac_c" 1>&6
-echo "configure:4352: checking for des_cbc_encrypt in -lcrypto" >&5
+echo "configure:4537: checking for des_cbc_encrypt in -lcrypto" >&5
ac_lib_var=`echo crypto'_'des_cbc_encrypt | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -4356,7 +4541,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcrypto $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4360 "configure"
+#line 4545 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -4367,7 +4552,7 @@ int main() {
des_cbc_encrypt()
; return 0; }
EOF
-if { (eval echo configure:4371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -4394,28 +4579,24 @@ else
echo "$ac_t""no" 1>&6
fi
- cat >> confdefs.h <<\EOF
-#define CRYPTO 1
-EOF
-
bak_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $V_INCLS"
- for ac_hdr in cast.h rc5.h
+ for ac_hdr in cast.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4409: checking for $ac_hdr" >&5
+echo "configure:4590: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4414 "configure"
+#line 4595 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4419: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4600: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -4444,12 +4625,12 @@ done
if test "$ac_cv_header_cast_h" = "yes"; then
echo $ac_n "checking for buggy CAST128""... $ac_c" 1>&6
-echo "configure:4448: checking for buggy CAST128" >&5
+echo "configure:4629: checking for buggy CAST128" >&5
if test "$cross_compiling" = yes; then
buggy_cast128="cross-compiling, assume yes"
else
cat > conftest.$ac_ext <<EOF
-#line 4453 "configure"
+#line 4634 "configure"
#include "confdefs.h"
#include <cast.h>
@@ -4468,7 +4649,7 @@ main()
return 1;
}
EOF
-if { (eval echo configure:4472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
buggy_cast128=yes
else
@@ -4494,11 +4675,49 @@ EOF
CPPFLAGS=$bak_CPPFLAGS
fi
-if test -r ${srcdir}/lbl/gnuc.h ; then
- rm -f gnuc.h
- ln -s ${srcdir}/lbl/gnuc.h gnuc.h
fi
+for ac_hdr in rc5.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:4685: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4690 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:4695: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
@@ -4517,7 +4736,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:4521: checking for a BSD compatible install" >&5
+echo "configure:4740: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -4572,6 +4791,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
@@ -4942,8 +5162,14 @@ fi; done
EOF
cat >> $CONFIG_STATUS <<EOF
+
EOF
cat >> $CONFIG_STATUS <<\EOF
+if test -f .devel; then
+ echo timestamp > stamp-h
+ cat Makefile-devel-adds >> Makefile
+ make depend
+fi
exit 0
EOF
@@ -4951,8 +5177,4 @@ chmod +x $CONFIG_STATUS
rm -fr confdefs* $ac_clean_files
test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
-if test -f .devel ; then
- make depend
-fi
exit 0
diff --git a/contrib/tcpdump/configure.in b/contrib/tcpdump/configure.in
index 6161766..43f6777 100755
--- a/contrib/tcpdump/configure.in
+++ b/contrib/tcpdump/configure.in
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.87.2.4 2000/01/25 18:39:02 itojun Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.132.4.1 2001/01/17 18:29:58 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@@ -6,59 +6,72 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl
+AC_REVISION($Revision: 1.132.4.1 $)
+AC_PREREQ(2.13)
AC_INIT(tcpdump.c)
AC_CANONICAL_SYSTEM
-umask 002
-
-if test -z "$PWD" ; then
- PWD=`pwd`
-fi
-
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_C_INLINE
+AC_C___ATTRIBUTE__
-AC_CHECK_HEADERS(fcntl.h malloc.h memory.h rpc/rpcent.h)
+AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h)
AC_HEADER_TIME
case "$target_os" in
linux*)
AC_MSG_CHECKING(Linux kernel version)
- AC_CACHE_VAL(ac_cv_linux_vers,
- ac_cv_linux_vers=`uname -r 2>&1 | \
- sed -n -e '$s/.* //' -e '$s/\..*//p'`)
+ if test "$cross_compiling" = yes; then
+ AC_CACHE_VAL(ac_cv_linux_vers,
+ ac_cv_linux_vers=unknown)
+ else
+ AC_CACHE_VAL(ac_cv_linux_vers,
+ ac_cv_linux_vers=`uname -r 2>&1 | \
+ sed -n -e '$s/.* //' -e '$s/\..*//p'`)
+ fi
AC_MSG_RESULT($ac_cv_linux_vers)
+ if test $ac_cv_linux_vers = unknown ; then
+ AC_MSG_ERROR(cannot determine linux version when cross-compiling)
+ fi
if test $ac_cv_linux_vers -lt 2 ; then
AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
fi
- AC_DEFINE(HAVE_NET_SLIP_H)
;;
*)
- AC_CHECK_HEADERS(net/slip.h)
;;
esac
AC_CHECK_HEADERS(smi.h)
-AC_CHECK_LIB(smi, main)
+AC_CHECK_LIB(smi, smiInit)
AC_MSG_CHECKING([whether to enable libsmi])
AC_TRY_RUN([ /* libsmi available check */
#include <smi.h>
main()
{
+ int current, revision, age, n;
+ const int required = 2;
if (smiInit(""))
exit(1);
- else
- exit(0);
+ if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
+ exit(2);
+ n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
+ if (n != 3)
+ exit(3);
+ if (required < current - age || required > current)
+ exit(4);
+ exit(0);
}
],
[ AC_MSG_RESULT(yes)
AC_DEFINE(LIBSMI)
libsmi=yes],
[ AC_MSG_RESULT(no)
+ libsmi=no],
+[ AC_MSG_RESULT(not when cross-compiling)
libsmi=no]
)
@@ -70,7 +83,6 @@ AC_ARG_ENABLE(ipv6,
--disable-ipv6 disable ipv6 support],
[ case "$enableval" in
yes) AC_MSG_RESULT(yes)
- AC_DEFINE(ENABLE_IPV6)
LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
AC_DEFINE(INET6)
ipv6=yes
@@ -93,7 +105,6 @@ main()
}
],
[ AC_MSG_RESULT(yes)
- AC_DEFINE(ENABLE_IPV6)
LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
AC_DEFINE(INET6)
ipv6=yes],
@@ -213,7 +224,7 @@ fi
if test "$ipv6" = "yes"; then
- AC_CHECK_FUNCS(getaddrinfo, [dnl
+ AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
AC_MSG_CHECKING(getaddrinfo bug)
AC_TRY_RUN([
#include <sys/types.h>
@@ -329,7 +340,31 @@ main()
fi
AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
fi
-AC_REPLACE_FUNCS(inet_ntop inet_pton inet_aton)
+dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
+AC_MSG_CHECKING(for inet_ntop)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>], [char src[4], dst[128];
+inet_ntop(AF_INET, src, dst, sizeof(dst));],
+ [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
+ AC_REPLACE_FUNCS(inet_ntop)])
+AC_MSG_CHECKING(for inet_pton)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>], [char src[128], dst[4];
+inet_pton(AF_INET, src, dst);],
+ [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
+ AC_REPLACE_FUNCS(inet_pton)])
+AC_MSG_CHECKING(for inet_aton)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>], [char src[128];
+struct in_addr dst;
+inet_aton(src, &dst);],
+ [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
+ AC_REPLACE_FUNCS(inet_aton)])
dnl portability macros for getaddrinfo/getnameinfo
dnl
@@ -340,13 +375,6 @@ if test "$ac_cv_sockaddr_has_sa_len" = no; then
fi
dnl
-dnl check __P macro
-AC_CHECK_PORTABLE_PROTO(ac_cv_portable_proto)
-if test "$ac_cv_portable_proto" = no; then
- missing_includes=yes
-fi
-
-dnl
dnl check sizeof basic types.
dnl They're very likely to be wrong for cross-compiling.
AC_CHECK_SIZEOF(char, 1)
@@ -404,13 +432,6 @@ if test "$ac_cv_res_inet6" = no; then
fi
dnl
-dnl Checks for AAAA
-AC_CHECK_AAAA(ac_cv_aaaa)
-if test "$ac_cv_aaaa" = no; then
- AC_DEFINE(T_AAAA, 28)
-fi
-
-dnl
dnl Checks for res_state_ext structure
AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
if test "$ac_cv_res_state_ext" = no; then
@@ -429,21 +450,40 @@ if test "$missing_includes" = "yes"; then
fi
-AC_REPLACE_FUNCS(vfprintf strcasecmp)
-AC_CHECK_FUNCS(ether_ntohost setlinebuf gethostbyname2)
+AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy)
+AC_CHECK_FUNCS(ether_ntohost setlinebuf)
+
+usegetipnodeby=yes
+AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freeaddrinfo,
+ [], [usegetipnodeby=no])
+if test $usegetipnodeby = yes; then
+ AC_DEFINE(USE_GETIPNODEBY)
+fi
+
+needsnprintf=no
+AC_CHECK_FUNCS(vsnprintf snprintf,,
+ [needsnprintf=yes])
+if test $needsnprintf = yes; then
+ LIBOBJS="$LIBOBJS snprintf.o"
+fi
dnl The following generates a warning from autoconf...
+errprint(__file__:__line__: please ignore the next warning:
+)dnl
AC_C_BIGENDIAN
AC_CHECK_LIB(dnet, main)
AC_CHECK_LIB(rpc, main)
-AC_CHECK_LIB(z, uncompress)
-AC_CHECK_HEADERS(zlib.h)
+AC_CHECK_LIB(nsl, getrpcbynumber)
+dnl AC_CHECK_LIB(z, uncompress)
+dnl AC_CHECK_HEADERS(zlib.h)
AC_LBL_TYPE_SIGNAL
AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
+AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
+
V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
@@ -459,14 +499,8 @@ irix*)
V_GROUP=sys
;;
-linux*)
- V_INCLS="$V_INCLS -I\$(srcdir)/linux-include"
- ;;
-
osf*)
V_GROUP=system
- dnl Workaround around ip_hl vs. ip_vhl problem in netinet/ip.h
- AC_DEFINE(__STDC__,2)
;;
solaris*)
@@ -488,99 +522,25 @@ AC_LBL_DEVEL(V_CCOPT)
AC_LBL_SOCKADDR_SA_LEN
-AC_MSG_CHECKING(if ether_header uses ether_addr structs)
-AC_CACHE_VAL(ac_cv_ether_header_has_ea,
- LBL_SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $V_INCLS"
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# if __STDC__
- /* osf3 has REALLY good prototyes */
- struct mbuf;
- struct rtentry;
-# endif
-# include <sys/socket.h>
-# include <net/if.h>
-# include <netinet/in.h>
-# include <netinet/if_ether.h>],
- [u_int i =
- sizeof(((struct ether_header *)0)->ether_dhost.ether_addr_octet)],
- ac_cv_ether_header_has_ea=yes,
- ac_cv_ether_header_has_ea=no)
- CFLAGS="$LBL_SAVE_CFLAGS")
-AC_MSG_RESULT($ac_cv_ether_header_has_ea)
-if test $ac_cv_ether_header_has_ea = yes ; then
- AC_DEFINE(ETHER_HEADER_HAS_EA)
-fi
-
-AC_MSG_CHECKING(if ether_arp uses ether_addr structs)
-AC_CACHE_VAL(ac_cv_ether_arp_has_ea,
- LBL_SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $V_INCLS"
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# if __STDC__
- /* osf3 has REALLY good prototyes */
- struct mbuf;
- struct rtentry;
-# endif
-# include <sys/socket.h>
-# include <net/if.h>
-# include <netinet/in.h>
-# include <netinet/if_ether.h>],
- [u_int i =
- sizeof(((struct ether_arp *)0)->arp_sha.ether_addr_octet)],
- ac_cv_ether_arp_has_ea=yes,
- ac_cv_ether_arp_has_ea=no)
- CFLAGS="$LBL_SAVE_CFLAGS")
-AC_MSG_RESULT($ac_cv_ether_arp_has_ea)
-if test $ac_cv_ether_arp_has_ea = yes ; then
- AC_DEFINE(ETHER_ARP_HAS_EA)
-fi
-
-AC_MSG_CHECKING(if ether_arp uses erp_xsha member)
-AC_CACHE_VAL(ac_cv_struct_ether_arp_x,
- LBL_SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $V_INCLS"
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>
-# if __STDC__
- /* osf3 has REALLY good prototyes */
- struct mbuf;
- struct rtentry;
-# endif
-# include <net/if.h>
-# include <netinet/in.h>
-# include <netinet/if_ether.h>],
- [u_int i = sizeof( ((struct ether_arp *)0)->arp_xsha)],
- ac_cv_struct_ether_arp_x=yes,
- ac_cv_struct_ether_arp_x=no)
- CFLAGS="$LBL_SAVE_CFLAGS")
-AC_MSG_RESULT($ac_cv_struct_ether_arp_x)
-if test $ac_cv_struct_ether_arp_x = yes ; then
- AC_DEFINE(ETHER_ARP_HAS_X)
-fi
-
AC_LBL_UNALIGNED_ACCESS
AC_VAR_H_ERRNO
+AC_ARG_WITH(crypto, [ --without-crypto disable crypto support],
+ [], [
AC_MSG_CHECKING(for SSLeay)
ac_cv_ssleay_path=no
incdir=no
-for dir in /usr/local /usr/local/ssl /usr/pkg; do
+for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do
if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then
ac_cv_ssleay_path=$dir
fi
- if test -d $dir/include -a -f $dir/include/des.h; then
+ if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
+ incdir="-I$dir/include/ssleay"
+ elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
+ incdir="-I$dir/include -I$dir/include/openssl"
+ elif test -d $dir/include -a -f $dir/include/des.h; then
incdir="-I$dir/include"
- else
- if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
- incdir="-I$dir/include/ssleay"
- elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
- incdir="-I$dir/include -I$dir/include/openssl"
- fi
fi
if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
break;
@@ -592,7 +552,7 @@ done
AC_MSG_RESULT($ac_cv_ssleay_path)
if test "$ac_cv_ssleay_path" != no; then
V_INCLS="$V_INCLS $incdir"
- LIBS="$LIBS -L$dir/lib"
+ LDFLAGS="-L$dir/lib $LDFLAGS"
if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
LIBS="$LIBS -lRSAglue"
fi
@@ -600,11 +560,10 @@ if test "$ac_cv_ssleay_path" != no; then
LIBS="$LIBS -lrsaref"
fi
AC_CHECK_LIB(crypto, des_cbc_encrypt)
- AC_DEFINE(CRYPTO)
bak_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $V_INCLS"
- AC_CHECK_HEADERS(cast.h rc5.h)
+ AC_CHECK_HEADERS(cast.h)
if test "$ac_cv_header_cast_h" = "yes"; then
AC_MSG_CHECKING(for buggy CAST128)
@@ -638,11 +597,8 @@ main()
CPPFLAGS=$bak_CPPFLAGS
fi
-
-if test -r ${srcdir}/lbl/gnuc.h ; then
- rm -f gnuc.h
- ln -s ${srcdir}/lbl/gnuc.h gnuc.h
-fi
+])
+AC_CHECK_HEADERS(rc5.h)
AC_SUBST(V_CCOPT)
AC_SUBST(V_GROUP)
@@ -654,9 +610,10 @@ AC_PROG_INSTALL
AC_CONFIG_HEADER(config.h)
-AC_OUTPUT(Makefile)
-
-if test -f .devel ; then
+AC_OUTPUT_COMMANDS([if test -f .devel; then
+ echo timestamp > stamp-h
+ cat Makefile-devel-adds >> Makefile
make depend
-fi
+fi])
+AC_OUTPUT(Makefile)
exit 0
diff --git a/contrib/tcpdump/decnet.h b/contrib/tcpdump/decnet.h
index 86dea61..c356bcb 100644
--- a/contrib/tcpdump/decnet.h
+++ b/contrib/tcpdump/decnet.h
@@ -18,21 +18,21 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.6.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.7 2000/10/03 02:54:55 itojun Exp $ (LBL)
*/
-typedef unsigned char byte[1]; /* single byte field */
-typedef unsigned char word[2]; /* 2 byte field */
-typedef unsigned char longword[4]; /* 4 bytes field */
+typedef u_int8_t byte[1]; /* single byte field */
+typedef u_int8_t word[2]; /* 2 byte field */
+typedef u_int8_t longword[4]; /* 4 bytes field */
/*
* Definitions for DECNET Phase IV protocol headers
*/
union etheraddress {
- unsigned char dne_addr[6]; /* full ethernet address */
+ u_int8_t dne_addr[6]; /* full ethernet address */
struct {
- unsigned char dne_hiord[4]; /* DECnet HIORD prefix */
- unsigned char dne_nodeaddr[2]; /* DECnet node address */
+ u_int8_t dne_hiord[4]; /* DECnet HIORD prefix */
+ u_int8_t dne_nodeaddr[2]; /* DECnet node address */
} dne_remote;
};
@@ -46,8 +46,8 @@ typedef union etheraddress etheraddr; /* Ethernet address */
#define DN_MAXADDL 20 /* max size of DECnet address */
struct dn_naddr {
- unsigned short a_len; /* length of address */
- unsigned char a_addr[DN_MAXADDL]; /* address as bytes */
+ u_int16_t a_len; /* length of address */
+ u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */
};
/*
diff --git a/contrib/tcpdump/dhcp6.h b/contrib/tcpdump/dhcp6.h
index 161796f..a451bbf 100644
--- a/contrib/tcpdump/dhcp6.h
+++ b/contrib/tcpdump/dhcp6.h
@@ -1,3 +1,4 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6.h,v 1.4 2000/12/17 23:07:48 guy Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -27,7 +28,7 @@
* SUCH DAMAGE.
*/
/*
- * draft-ietf-dhc-dhcpv6-14
+ * draft-ietf-dhc-dhcpv6-15
*/
#ifndef __DHCP6_H_DEFINED
@@ -79,20 +80,27 @@ struct dhcp6_solicit {
u_int8_t dh6sol_msgtype; /* DH6_SOLICIT */
u_int8_t dh6sol_flags;
#define DH6SOL_CLOSE 0x80
- u_int8_t dh6sol_pad;
- u_int8_t dh6sol_prefixsiz; /* prefix-size */
+#define DH6SOL_PREFIX 0x40
+ /* XXX: solicit-ID is a 9-bit field...ugly! */
+#define DH6SOL_SOLICIT_ID_MASK 0x01ff
+#define DH6SOL_SOLICIT_ID_SHIFT 0
+#define DH6SOL_SOLICIT_ID(x) \
+ (((x) & DH6SOL_SOLICIT_ID_MASK) >> DH6SOL_SOLICIT_ID_SHIFT)
+#define DH6SOL_SOLICIT_PLEN_MASK 0xfe00
+#define DH6SOL_SOLICIT_PLEN_SHIFT 9
+#define DH6SOL_SOLICIT_PLEN(x) \
+ (((x) & DH6SOL_SOLICIT_PLEN_MASK) >> DH6SOL_SOLICIT_PLEN_SHIFT)
+ u_int16_t dh6sol_plen_id; /* prefix-len and solict-ID */
struct in6_addr dh6sol_cliaddr; /* client's lladdr */
struct in6_addr dh6sol_relayaddr; /* relay agent's lladdr */
};
-/* NOTE: dhcpv6-12 and dhcpv6-13+n are not compatible at all */
struct dhcp6_advert {
u_int8_t dh6adv_msgtype; /* DH6_ADVERT */
- u_int8_t dh6adv_flags;
-#define DH6ADV_SERVPRESENT 0x80
- u_int8_t dh6adv_pad;
+ u_int8_t dh6adv_rsv_id; /* reserved and uppermost bit of ID */
+ u_int8_t dh6adv_solcit_id; /* lower 8 bits of solicit-ID */
u_int8_t dh6adv_pref;
- struct in6_addr dh6adv_cliaddr; /* client's lladdr */
+ struct in6_addr dh6adv_cliaddr; /* client's link-local addr */
struct in6_addr dh6adv_relayaddr; /* relay agent's (non-ll) addr */
struct in6_addr dh6adv_serveraddr; /* server's addr */
/* extensions */
@@ -102,25 +110,26 @@ struct dhcp6_request {
u_int8_t dh6req_msgtype; /* DH6_REQUEST */
u_int8_t dh6req_flags;
#define DH6REQ_CLOSE 0x80
-#define DH6REQ_SERVPRESENT 0x40
-#define DH6REQ_REBOOT 0x20
+#define DH6REQ_REBOOT 0x40
u_int16_t dh6req_xid; /* transaction-ID */
struct in6_addr dh6req_cliaddr; /* client's lladdr */
struct in6_addr dh6req_relayaddr; /* relay agent's (non-ll) addr */
- /* struct in6_addr dh6req_serveraddr; optional: server's addr */
+ struct in6_addr dh6req_serveraddr; /* server's addr */
/* extensions */
};
struct dhcp6_reply {
u_int8_t dh6rep_msgtype; /* DH6_REPLY */
u_int8_t dh6rep_flagandstat;
-#define DH6REP_CLIPRESENT 0x80
+#define DH6REP_RELAYPRESENT 0x80
#define DH6REP_STATMASK 0x7f
u_int16_t dh6rep_xid; /* transaction-ID */
- /* struct in6_addr dh6rep_cliaddr; optional: client's lladdr */
+ struct in6_addr dh6rep_cliaddr; /* client's lladdr */
+ /* struct in6_addr dh6rep_relayaddr; optional: relay address */
/* extensions */
};
+/* XXX: followings are based on older drafts */
struct dhcp6_release {
u_int8_t dh6rel_msgtype; /* DH6_RELEASE */
u_int8_t dh6rel_flags;
diff --git a/contrib/tcpdump/dhcp6opt.h b/contrib/tcpdump/dhcp6opt.h
index a9177c6..b4ec2e4 100644
--- a/contrib/tcpdump/dhcp6opt.h
+++ b/contrib/tcpdump/dhcp6opt.h
@@ -1,3 +1,4 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6opt.h,v 1.3 2000/12/17 23:07:49 guy Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -72,9 +73,9 @@ struct dhcp6_opt {
extern struct dhcp6_opt *dh6o_pad;
extern struct dhcp6_opt *dh6o_end;
extern int dhcp6_param[];
-extern void dhcp6opttab_init __P((void));
-extern struct dhcp6_opt *dhcp6opttab_byname __P((char *));
-extern struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
+extern void dhcp6opttab_init (void);
+extern struct dhcp6_opt *dhcp6opttab_byname (char *);
+extern struct dhcp6_opt *dhcp6opttab_bycode (u_int);
#endif
#endif /*__DHCP6OPT_H_DEFINED*/
diff --git a/contrib/tcpdump/esp.h b/contrib/tcpdump/esp.h
new file mode 100644
index 0000000..56cdada
--- /dev/null
+++ b/contrib/tcpdump/esp.h
@@ -0,0 +1,68 @@
+/* $NetBSD: esp.h,v 1.13 2000/09/26 08:37:38 itojun Exp $ */
+/* $KAME: esp.h,v 1.15 2000/09/20 18:15:22 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * RFC1827/2406 Encapsulated Security Payload.
+ */
+
+#ifndef _NETINET6_ESP_H_
+#define _NETINET6_ESP_H_
+
+struct esp {
+ u_int32_t esp_spi; /* ESP */
+ /*variable size, 32bit bound*/ /* Initialization Vector */
+ /*variable size*/ /* Payload data */
+ /*variable size*/ /* padding */
+ /*8bit*/ /* pad size */
+ /*8bit*/ /* next header */
+ /*8bit*/ /* next header */
+ /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
+};
+
+struct newesp {
+ u_int32_t esp_spi; /* ESP */
+ u_int32_t esp_seq; /* Sequence number */
+ /*variable size*/ /* (IV and) Payload data */
+ /*variable size*/ /* padding */
+ /*8bit*/ /* pad size */
+ /*8bit*/ /* next header */
+ /*8bit*/ /* next header */
+ /*variable size, 32bit bound*/ /* Authentication data */
+};
+
+struct esptail {
+ u_int8_t esp_padlen; /* pad length */
+ u_int8_t esp_nxt; /* Next header */
+ /*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/
+};
+
+#endif /*_NETINET6_ESP_H_*/
diff --git a/contrib/tcpdump/ether.h b/contrib/tcpdump/ether.h
new file mode 100644
index 0000000..5c3dff0
--- /dev/null
+++ b/contrib/tcpdump/ether.h
@@ -0,0 +1,59 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.6 2000/10/09 03:24:24 guy Exp $ (LBL) */
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)if_ether.h 8.3 (Berkeley) 5/2/95
+ */
+
+#define ETHERMTU 1500
+
+/*
+ * The number of bytes in an ethernet (MAC) address.
+ */
+#define ETHER_ADDR_LEN 6
+
+/*
+ * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
+ */
+struct ether_header {
+ u_int8_t ether_dhost[ETHER_ADDR_LEN];
+ u_int8_t ether_shost[ETHER_ADDR_LEN];
+ u_int16_t ether_type;
+};
+
+/*
+ * Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some
+ * compilers may pad "struct ether_header" to a multiple of 4 bytes,
+ * for example, so "sizeof (struct ether_header)" may not give the right
+ * answer.
+ */
+#define ETHER_HDRLEN 14
diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h
index fb3f67a..d1a653b 100644
--- a/contrib/tcpdump/ethertype.h
+++ b/contrib/tcpdump/ethertype.h
@@ -18,11 +18,33 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.7.2.1 2000/01/29 22:00:12 fenner Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.12 2000/09/23 08:03:30 guy Exp $ (LBL)
*/
-/* Types missing from some systems */
+/*
+ * Ethernet types.
+ *
+ * We wrap the declarations with #ifdef, so that if a file includes
+ * <netinet/if_ether.h>, which may declare some of these, we don't
+ * get a bunch of complaints from the C compiler about redefinitions
+ * of these values.
+ *
+ * We declare all of them here so that no file has to include
+ * <netinet/if_ether.h> if all it needs are ETHERTYPE_ values.
+ */
+#ifndef ETHERTYPE_PUP
+#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
+#endif
+#ifndef ETHERTYPE_IP
+#define ETHERTYPE_IP 0x0800 /* IP protocol */
+#endif
+#ifndef ETHERTYPE_ARP
+#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
+#endif
+#ifndef ETHERTYPE_REVARP
+#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
+#endif
#ifndef ETHERTYPE_NS
#define ETHERTYPE_NS 0x0600
#endif
@@ -74,6 +96,9 @@
#ifndef ETHERTYPE_8021Q
#define ETHERTYPE_8021Q 0x8100
#endif
+#ifndef ETHERTYPE_IPX
+#define ETHERTYPE_IPX 0x8137
+#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
#endif
diff --git a/contrib/tcpdump/extract.h b/contrib/tcpdump/extract.h
index e4fb6f2..9e5bb9b 100644
--- a/contrib/tcpdump/extract.h
+++ b/contrib/tcpdump/extract.h
@@ -18,40 +18,40 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.15.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.16 2000/10/03 02:54:55 itojun Exp $ (LBL)
*/
/* Network to host order macros */
#ifdef LBL_ALIGN
#define EXTRACT_16BITS(p) \
- ((u_short)*((u_char *)(p) + 0) << 8 | \
- (u_short)*((u_char *)(p) + 1))
+ ((u_int16_t)*((u_int8_t *)(p) + 0) << 8 | \
+ (u_int16_t)*((u_int8_t *)(p) + 1))
#define EXTRACT_32BITS(p) \
- ((u_int32_t)*((u_char *)(p) + 0) << 24 | \
- (u_int32_t)*((u_char *)(p) + 1) << 16 | \
- (u_int32_t)*((u_char *)(p) + 2) << 8 | \
- (u_int32_t)*((u_char *)(p) + 3))
+ ((u_int32_t)*((u_int8_t *)(p) + 0) << 24 | \
+ (u_int32_t)*((u_int8_t *)(p) + 1) << 16 | \
+ (u_int32_t)*((u_int8_t *)(p) + 2) << 8 | \
+ (u_int32_t)*((u_int8_t *)(p) + 3))
#else
#define EXTRACT_16BITS(p) \
- ((u_short)ntohs(*(u_short *)(p)))
+ ((u_int16_t)ntohs(*(u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
((u_int32_t)ntohl(*(u_int32_t *)(p)))
#endif
#define EXTRACT_24BITS(p) \
- ((u_int32_t)*((u_char *)(p) + 0) << 16 | \
- (u_int32_t)*((u_char *)(p) + 1) << 8 | \
- (u_int32_t)*((u_char *)(p) + 2))
+ ((u_int32_t)*((u_int8_t *)(p) + 0) << 16 | \
+ (u_int32_t)*((u_int8_t *)(p) + 1) << 8 | \
+ (u_int32_t)*((u_int8_t *)(p) + 2))
/* Little endian protocol host order macros */
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
- ((u_short)*((u_char *)(p) + 1) << 8 | \
- (u_short)*((u_char *)(p) + 0))
+ ((u_int16_t)*((u_int8_t *)(p) + 1) << 8 | \
+ (u_int16_t)*((u_int8_t *)(p) + 0))
#define EXTRACT_LE_32BITS(p) \
- ((u_int32_t)*((u_char *)(p) + 3) << 24 | \
- (u_int32_t)*((u_char *)(p) + 2) << 16 | \
- (u_int32_t)*((u_char *)(p) + 1) << 8 | \
- (u_int32_t)*((u_char *)(p) + 0))
+ ((u_int32_t)*((u_int8_t *)(p) + 3) << 24 | \
+ (u_int32_t)*((u_int8_t *)(p) + 2) << 16 | \
+ (u_int32_t)*((u_int8_t *)(p) + 1) << 8 | \
+ (u_int32_t)*((u_int8_t *)(p) + 0))
diff --git a/contrib/tcpdump/fddi.h b/contrib/tcpdump/fddi.h
index 894cee3..64ebfb3 100644
--- a/contrib/tcpdump/fddi.h
+++ b/contrib/tcpdump/fddi.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.8.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.9 2000/10/09 02:59:39 guy Exp $ (LBL)
*/
/*
@@ -37,6 +37,13 @@ struct fddi_header {
u_char fddi_shost[6];
};
+/*
+ * Length of an FDDI header; note that some compilers may pad
+ * "struct fddi_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct fddi_header)" may not give the right
+ * answer.
+ */
+#define FDDI_HDRLEN 13
/* Useful values for fddi_fc (frame control) field */
diff --git a/contrib/tcpdump/gmt2local.c b/contrib/tcpdump/gmt2local.c
index 2310dbc..d68c4bf 100644
--- a/contrib/tcpdump/gmt2local.c
+++ b/contrib/tcpdump/gmt2local.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.3 1999/11/21 09:36:47 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.4 2000/07/11 00:49:02 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,7 +36,6 @@ static const char rcsid[] =
#include <time.h>
#endif
-#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
diff --git a/contrib/tcpdump/icmp6.h b/contrib/tcpdump/icmp6.h
new file mode 100644
index 0000000..7f66c2e
--- /dev/null
+++ b/contrib/tcpdump/icmp6.h
@@ -0,0 +1,412 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.4 2000/12/17 23:13:32 guy Exp $ (LBL) */
+/* $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $ */
+/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_ICMP6_H_
+#define _NETINET_ICMP6_H_
+
+struct icmp6_hdr {
+ u_int8_t icmp6_type; /* type field */
+ u_int8_t icmp6_code; /* code field */
+ u_int16_t icmp6_cksum; /* checksum field */
+ union {
+ u_int32_t icmp6_un_data32[1]; /* type-specific field */
+ u_int16_t icmp6_un_data16[2]; /* type-specific field */
+ u_int8_t icmp6_un_data8[4]; /* type-specific field */
+ } icmp6_dataun;
+};
+
+#define icmp6_data32 icmp6_dataun.icmp6_un_data32
+#define icmp6_data16 icmp6_dataun.icmp6_un_data16
+#define icmp6_data8 icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr icmp6_data32[0] /* parameter prob */
+#define icmp6_mtu icmp6_data32[0] /* packet too big */
+#define icmp6_id icmp6_data16[0] /* echo request/reply */
+#define icmp6_seq icmp6_data16[1] /* echo request/reply */
+#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
+
+#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
+#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
+#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
+#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
+
+#define ICMP6_ECHO_REQUEST 128 /* echo service */
+#define ICMP6_ECHO_REPLY 129 /* echo reply */
+#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
+#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
+#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
+#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
+#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
+#define MLD6_LISTENER_DONE 132 /* multicast listener done */
+
+#define ND_ROUTER_SOLICIT 133 /* router solicitation */
+#define ND_ROUTER_ADVERT 134 /* router advertisment */
+#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
+#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
+#define ND_REDIRECT 137 /* redirect */
+
+#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
+
+#define ICMP6_WRUREQUEST 139 /* who are you request */
+#define ICMP6_WRUREPLY 140 /* who are you reply */
+#define ICMP6_FQDN_QUERY 139 /* FQDN query */
+#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
+#define ICMP6_NI_QUERY 139 /* node information request */
+#define ICMP6_NI_REPLY 140 /* node information reply */
+
+/* The definitions below are experimental. TBA */
+#define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */
+#define MLD6_MTRACE 142 /* mtrace messages */
+
+#define ICMP6_MAXTYPE 142
+
+#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
+#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
+#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
+#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
+#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
+#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
+
+#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
+
+#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
+#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
+#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
+
+#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
+
+#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
+#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
+#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
+
+#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
+#define ICMP6_NI_REFUSED 1 /* node information request is refused */
+#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
+
+#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
+#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
+#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
+
+/* Used in kernel only */
+#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
+#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
+
+/*
+ * Multicast Listener Discovery
+ */
+struct mld6_hdr {
+ struct icmp6_hdr mld6_hdr;
+ struct in6_addr mld6_addr; /* multicast address */
+};
+
+#define mld6_type mld6_hdr.icmp6_type
+#define mld6_code mld6_hdr.icmp6_code
+#define mld6_cksum mld6_hdr.icmp6_cksum
+#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
+#define mld6_reserved mld6_hdr.icmp6_data16[1]
+
+/*
+ * Neighbor Discovery
+ */
+
+struct nd_router_solicit { /* router solicitation */
+ struct icmp6_hdr nd_rs_hdr;
+ /* could be followed by options */
+};
+
+#define nd_rs_type nd_rs_hdr.icmp6_type
+#define nd_rs_code nd_rs_hdr.icmp6_code
+#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert { /* router advertisement */
+ struct icmp6_hdr nd_ra_hdr;
+ u_int32_t nd_ra_reachable; /* reachable time */
+ u_int32_t nd_ra_retransmit; /* retransmit timer */
+ /* could be followed by options */
+};
+
+#define nd_ra_type nd_ra_hdr.icmp6_type
+#define nd_ra_code nd_ra_hdr.icmp6_code
+#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED 0x80
+#define ND_RA_FLAG_OTHER 0x40
+#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit { /* neighbor solicitation */
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target; /*target address */
+ /* could be followed by options */
+};
+
+#define nd_ns_type nd_ns_hdr.icmp6_type
+#define nd_ns_code nd_ns_hdr.icmp6_code
+#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert { /* neighbor advertisement */
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target; /* target address */
+ /* could be followed by options */
+};
+
+#define nd_na_type nd_na_hdr.icmp6_type
+#define nd_na_code nd_na_hdr.icmp6_code
+#define nd_na_cksum nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
+/* netowkr endian */
+#define ND_NA_FLAG_ROUTER ((u_int32_t)htonl(0x80000000))
+#define ND_NA_FLAG_SOLICITED ((u_int32_t)htonl(0x40000000))
+#define ND_NA_FLAG_OVERRIDE ((u_int32_t)htonl(0x20000000))
+
+struct nd_redirect { /* redirect */
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target; /* target address */
+ struct in6_addr nd_rd_dst; /* destination address */
+ /* could be followed by options */
+};
+
+#define nd_rd_type nd_rd_hdr.icmp6_type
+#define nd_rd_code nd_rd_hdr.icmp6_code
+#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr { /* Neighbor discovery option header */
+ u_int8_t nd_opt_type;
+ u_int8_t nd_opt_len;
+ /* followed by option specific data*/
+};
+
+#define ND_OPT_SOURCE_LINKADDR 1
+#define ND_OPT_TARGET_LINKADDR 2
+#define ND_OPT_PREFIX_INFORMATION 3
+#define ND_OPT_REDIRECTED_HEADER 4
+#define ND_OPT_MTU 5
+#define ND_OPT_ADVINT 7
+
+struct nd_opt_prefix_info { /* prefix information */
+ u_int8_t nd_opt_pi_type;
+ u_int8_t nd_opt_pi_len;
+ u_int8_t nd_opt_pi_prefix_len;
+ u_int8_t nd_opt_pi_flags_reserved;
+ u_int32_t nd_opt_pi_valid_time;
+ u_int32_t nd_opt_pi_preferred_time;
+ u_int32_t nd_opt_pi_reserved2;
+ struct in6_addr nd_opt_pi_prefix;
+};
+
+#define ND_OPT_PI_FLAG_ONLINK 0x80
+#define ND_OPT_PI_FLAG_AUTO 0x40
+#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
+
+struct nd_opt_rd_hdr { /* redirected header */
+ u_int8_t nd_opt_rh_type;
+ u_int8_t nd_opt_rh_len;
+ u_int16_t nd_opt_rh_reserved1;
+ u_int32_t nd_opt_rh_reserved2;
+ /* followed by IP header and data */
+};
+
+struct nd_opt_mtu { /* MTU option */
+ u_int8_t nd_opt_mtu_type;
+ u_int8_t nd_opt_mtu_len;
+ u_int16_t nd_opt_mtu_reserved;
+ u_int32_t nd_opt_mtu_mtu;
+};
+
+struct nd_opt_advint { /* Advertisement interval option */
+ u_int8_t nd_opt_advint_type;
+ u_int8_t nd_opt_advint_len;
+ u_int16_t nd_opt_advint_reserved;
+ u_int32_t nd_opt_advint_advint;
+};
+
+/*
+ * icmp6 namelookup
+ */
+
+struct icmp6_namelookup {
+ struct icmp6_hdr icmp6_nl_hdr;
+ u_int8_t icmp6_nl_nonce[8];
+ int32_t icmp6_nl_ttl;
+#if 0
+ u_int8_t icmp6_nl_len;
+ u_int8_t icmp6_nl_name[3];
+#endif
+ /* could be followed by options */
+};
+
+/*
+ * icmp6 node information
+ */
+struct icmp6_nodeinfo {
+ struct icmp6_hdr icmp6_ni_hdr;
+ u_int8_t icmp6_ni_nonce[8];
+ /* could be followed by reply data */
+};
+
+#define ni_type icmp6_ni_hdr.icmp6_type
+#define ni_code icmp6_ni_hdr.icmp6_code
+#define ni_cksum icmp6_ni_hdr.icmp6_cksum
+#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
+#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
+
+#define NI_QTYPE_NOOP 0 /* NOOP */
+#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
+#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
+#define NI_QTYPE_DNSNAME 2 /* DNS Name */
+#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
+#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
+
+/* network endian */
+#define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1))
+#define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1))
+
+/* network endian */
+#define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1))
+#define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2))
+#define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4))
+#define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8))
+#define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10))
+#define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20))
+#define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
+
+struct ni_reply_fqdn {
+ u_int32_t ni_fqdn_ttl; /* TTL */
+ u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
+ u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
+};
+
+/*
+ * Router Renumbering. as router-renum-08.txt
+ */
+struct icmp6_router_renum { /* router renumbering header */
+ struct icmp6_hdr rr_hdr;
+ u_int8_t rr_segnum;
+ u_int8_t rr_flags;
+ u_int16_t rr_maxdelay;
+ u_int32_t rr_reserved;
+};
+#define ICMP6_RR_FLAGS_TEST 0x80
+#define ICMP6_RR_FLAGS_REQRESULT 0x40
+#define ICMP6_RR_FLAGS_ALLIF 0x20
+#define ICMP6_RR_FLAGS_SPECSITE 0x10
+#define ICMP6_RR_FLAGS_PREVDONE 0x08
+
+#define rr_type rr_hdr.icmp6_type
+#define rr_code rr_hdr.icmp6_code
+#define rr_cksum rr_hdr.icmp6_cksum
+#define rr_seqnum rr_hdr.icmp6_data32[0]
+
+struct rr_pco_match { /* match prefix part */
+ u_int8_t rpm_code;
+ u_int8_t rpm_len;
+ u_int8_t rpm_ordinal;
+ u_int8_t rpm_matchlen;
+ u_int8_t rpm_minlen;
+ u_int8_t rpm_maxlen;
+ u_int16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
+};
+
+#define RPM_PCO_ADD 1
+#define RPM_PCO_CHANGE 2
+#define RPM_PCO_SETGLOBAL 3
+#define RPM_PCO_MAX 4
+
+struct rr_pco_use { /* use prefix part */
+ u_int8_t rpu_uselen;
+ u_int8_t rpu_keeplen;
+ u_int8_t rpu_ramask;
+ u_int8_t rpu_raflags;
+ u_int32_t rpu_vltime;
+ u_int32_t rpu_pltime;
+ u_int32_t rpu_flags;
+ struct in6_addr rpu_prefix;
+};
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
+
+/* network endian */
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000))
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000))
+
+struct rr_result { /* router renumbering result message */
+ u_int16_t rrr_flags;
+ u_int8_t rrr_ordinal;
+ u_int8_t rrr_matchedlen;
+ u_int32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
+};
+/* network endian */
+#define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
+
+#endif /* not _NETINET_ICMP6_H_ */
diff --git a/contrib/tcpdump/igrp.h b/contrib/tcpdump/igrp.h
index 1d84b54..f94ba3f 100644
--- a/contrib/tcpdump/igrp.h
+++ b/contrib/tcpdump/igrp.h
@@ -1,21 +1,18 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */
/* Cisco IGRP definitions */
/* IGRP Header */
struct igrphdr {
-#ifdef WORDS_BIGENDIAN
- u_int ig_v:4; /* protocol version number */
- u_int ig_op:4; /* opcode */
-#else
- u_int ig_op:4; /* opcode */
- u_int ig_v:4; /* protocol version number */
-#endif
- u_char ig_ed; /* edition number */
- u_short ig_as; /* autonomous system number */
- u_short ig_ni; /* number of subnet in local net */
- u_short ig_ns; /* number of networks in AS */
- u_short ig_nx; /* number of networks ouside AS */
- u_short ig_sum; /* checksum of IGRP header & data */
+ u_int8_t ig_vop; /* protocol version number / opcode */
+#define IGRP_V(x) (((x) & 0xf0) >> 4)
+#define IGRP_OP(x) ((x) & 0x0f)
+ u_int8_t ig_ed; /* edition number */
+ u_int16_t ig_as; /* autonomous system number */
+ u_int16_t ig_ni; /* number of subnet in local net */
+ u_int16_t ig_ns; /* number of networks in AS */
+ u_int16_t ig_nx; /* number of networks ouside AS */
+ u_int16_t ig_sum; /* checksum of IGRP header & data */
};
#define IGRP_UPDATE 1
@@ -24,13 +21,13 @@ struct igrphdr {
/* IGRP routing entry */
struct igrprte {
- u_char igr_net[3]; /* 3 significant octets of IP address */
- u_char igr_dly[3]; /* delay in tens of microseconds */
- u_char igr_bw[3]; /* bandwidth in units of 1 kb/s */
- u_char igr_mtu[2]; /* MTU in octets */
- u_char igr_rel; /* percent packets successfully tx/rx */
- u_char igr_ld; /* percent of channel occupied */
- u_char igr_hct; /* hop count */
+ u_int8_t igr_net[3]; /* 3 significant octets of IP address */
+ u_int8_t igr_dly[3]; /* delay in tens of microseconds */
+ u_int8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */
+ u_int8_t igr_mtu[2]; /* MTU in octets */
+ u_int8_t igr_rel; /* percent packets successfully tx/rx */
+ u_int8_t igr_ld; /* percent of channel occupied */
+ u_int8_t igr_hct; /* hop count */
};
#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h
index 030bafb..89b05d5 100644
--- a/contrib/tcpdump/interface.h
+++ b/contrib/tcpdump/interface.h
@@ -18,16 +18,42 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.118 1999/12/22 15:44:09 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.149 2001/01/02 22:47:06 guy Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
#define tcpdump_interface_h
-#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
+#include <sys/types.h>
+#include <sys/time.h>
+
+#ifndef HAVE___ATTRIBUTE__
+#define __attribute__(x)
+#endif
+
+/* snprintf et al */
+
+#include <stdarg.h>
+
+#if !defined(HAVE_SNPRINTF)
+int snprintf (char *str, size_t sz, const char *format, ...)
+ __attribute__ ((format (printf, 3, 4)));
+#endif
+
+#if !defined(HAVE_VSNPRINTF)
+int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
+ __attribute__((format (printf, 3, 0)));
+#endif
+
+#ifndef HAVE_STRLCAT
+extern size_t strlcat (char *, const char *, size_t);
+#endif
+#ifndef HAVE_STRLCPY
+extern size_t strlcpy (char *, const char *, size_t);
+#endif
struct tok {
int v; /* value */
@@ -45,11 +71,11 @@ extern int Rflag; /* print sequence # field in AH/ESP*/
extern int sflag; /* use the libsmi to translate OIDs */
extern int Sflag; /* print raw TCP sequence numbers */
extern int tflag; /* print packet arrival time */
+extern int uflag; /* Print undecoded NFS handles */
extern int vflag; /* verbose */
extern int xflag; /* print packet in hex */
extern int Xflag; /* print packet in hex/ascii */
-extern char *ahsecret;
extern char *espsecret;
extern int packettype; /* as specified by -T */
@@ -59,6 +85,7 @@ extern int packettype; /* as specified by -T */
#define PT_RTP 4 /* Real-Time Applications protocol */
#define PT_RTCP 5 /* Real-Time Applications control protocol */
#define PT_SNMP 6 /* Simple Network Management Protocol */
+#define PT_CNFP 7 /* Cisco NetFlow protocol */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@@ -84,30 +111,8 @@ extern int packettype; /* as specified by -T */
#define LITTLE_ENDIAN 1234
#endif
-#ifdef ETHER_HEADER_HAS_EA
-#define ESRC(ep) ((ep)->ether_shost.ether_addr_octet)
-#define EDST(ep) ((ep)->ether_dhost.ether_addr_octet)
-#else
#define ESRC(ep) ((ep)->ether_shost)
#define EDST(ep) ((ep)->ether_dhost)
-#endif
-
-#ifdef ETHER_ARP_HAS_X
-#define SHA(ap) ((ap)->arp_xsha)
-#define THA(ap) ((ap)->arp_xtha)
-#define SPA(ap) ((ap)->arp_xspa)
-#define TPA(ap) ((ap)->arp_xtpa)
-#else
-#ifdef ETHER_ARP_HAS_EA
-#define SHA(ap) ((ap)->arp_sha.ether_addr_octet)
-#define THA(ap) ((ap)->arp_tha.ether_addr_octet)
-#else
-#define SHA(ap) ((ap)->arp_sha)
-#define THA(ap) ((ap)->arp_tha)
-#endif
-#define SPA(ap) ((ap)->arp_spa)
-#define TPA(ap) ((ap)->arp_tpa)
-#endif
#ifndef NTOHL
#define NTOHL(x) (x) = ntohl(x)
@@ -138,9 +143,7 @@ extern const u_char *snapend;
/* Bail if "var" was not captured */
#define TCHECK(var) TCHECK2(var, sizeof(var))
-#ifdef __STDC__
struct timeval;
-#endif
extern void ts_print(const struct timeval *);
extern void relts_print(int);
@@ -152,15 +155,16 @@ extern char *dnaddr_string(u_short);
extern void wrapup(int);
-#if __STDC__
-extern __dead void error(const char *, ...)
- __attribute__((volatile, format (printf, 1, 2)));
+extern void error(const char *, ...)
+ __attribute__((noreturn, format (printf, 1, 2)));
extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#endif
extern char *read_infile(char *);
extern char *copy_argv(char **);
+extern void safeputchar(int);
+extern void safeputs(const char *);
+
extern char *isonsap_string(const u_char *);
extern char *llcsap_string(u_char);
extern char *protoid_string(const u_char *);
@@ -169,24 +173,24 @@ extern char *dnnum_string(u_short);
/* The printer routines. */
-#ifdef __STDC__
struct pcap_pkthdr;
-#endif
extern void ascii_print_with_offset(const u_char *, u_int, u_int);
extern void ascii_print(const u_char *, u_int);
extern void hex_print_with_offset(const u_char *, u_int, u_int);
extern void telnet_print(const u_char *, u_int);
extern void hex_print(const u_char *, u_int);
-extern int ether_encap_print(u_short, const u_char *, u_int, u_int);
+extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
- const u_char *);
+ const u_char *, u_short *);
extern void aarp_print(const u_char *, u_int);
extern void arp_print(const u_char *, u_int, u_int);
extern void atalk_print(const u_char *, u_int);
extern void atm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void bootp_print(const u_char *, u_int, u_short, u_short);
extern void bgp_print(const u_char *, int);
+extern void bxxp_print(const u_char *, u_int);
+extern void cnfp_print(const u_char *cp, u_int len, const u_char *bp);
extern void decnet_print(const u_char *, u_int, u_int);
extern void default_print(const u_char *, u_int);
extern void default_print_unaligned(const u_char *, u_int);
@@ -194,15 +198,20 @@ extern void dvmrp_print(const u_char *, u_int);
extern void egp_print(const u_char *, u_int, const u_char *);
extern void ether_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
+extern void token_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 *);
extern void gre_print(const u_char *, u_int);
extern void icmp_print(const u_char *, u_int, const u_char *);
+extern void igmp_print(const u_char *, u_int, const u_char *);
extern void igrp_print(const u_char *, u_int, const u_char *);
extern void ip_print(const u_char *, u_int);
+extern void ipN_print(const u_char *, u_int);
extern void ipx_print(const u_char *, u_int);
extern void isoclns_print(const u_char *, u_int, u_int, const u_char *,
const u_char *);
extern void krb_print(const u_char *, u_int);
+extern void llap_print(const u_char *, u_int);
extern void nfsreply_print(const u_char *, u_int, const u_char *);
extern void nfsreq_print(const u_char *, u_int, const u_char *);
extern void ns_print(const u_char *, u_int);
@@ -214,7 +223,10 @@ extern void cisco_autorp_print(const u_char *, u_int);
extern void mobile_print(const u_char *, u_int);
extern void pim_print(const u_char *, u_int);
extern void pppoe_print(const u_char *, u_int);
+extern void ppp_print(register const u_char *, u_int);
extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
+extern void ppp_hdlc_if_print(u_char *, const struct pcap_pkthdr *,
+ const u_char *);
extern void ppp_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern int vjc_print(register const char *, register u_int, u_short);
@@ -227,18 +239,20 @@ extern void sl_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern void chdlc_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
+extern void sll_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void snmp_print(const u_char *, u_int);
extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
-extern void tcp_print(const u_char *, u_int, const u_char *);
+extern void tcp_print(const u_char *, u_int, const u_char *, int);
extern void tftp_print(const u_char *, u_int);
-extern void udp_print(const u_char *, u_int, const u_char *);
+extern void timed_print(const u_char *, u_int);
+extern void udp_print(const u_char *, u_int, const u_char *, int);
extern void wb_print(const void *, u_int);
extern int ah_print(register const u_char *, register const u_char *);
extern int esp_print(register const u_char *, register const u_char *, int *);
extern void isakmp_print(const u_char *, u_int, const u_char *);
extern int ipcomp_print(register const u_char *, register const u_char *, int *);
extern void rx_print(register const u_char *, int, int, int, u_char *);
-extern void netbeui_print(const u_char *, const u_char *);
+extern void netbeui_print(u_short, const u_char *, const u_char *);
extern void ipx_netbios_print(const u_char *, const u_char *);
extern void nbt_tcp_print(const u_char *, int);
extern void nbt_udp137_print(const u_char *data, int);
@@ -247,6 +261,11 @@ extern char *smb_errstr(int, int);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *, u_int);
extern void lcp_print(const u_char *, u_int);
+extern void vrrp_print(const u_char *bp, u_int len, int ttl);
+extern void cdp_print(const u_char *p, u_int length, u_int caplen,
+ const u_char *esrc, const u_char *edst);
+extern void stp_print(const u_char *p, u_int length);
+extern void radius_print(const u_char *, u_int);
#ifdef INET6
extern void ip6_print(const u_char *, int);
@@ -258,6 +277,6 @@ extern void icmp6_print(const u_char *, const u_char *);
extern void ripng_print(const u_char *, int);
extern int rt6_print(const u_char *, const u_char *);
extern void ospf6_print(const u_char *, u_int);
-extern void dhcp6_print(const u_char *, u_int, u_short, u_short);
+extern void dhcp6_print(const u_char *, u_int, u_int16_t, u_int16_t);
#endif /*INET6*/
extern u_short in_cksum(const u_short *addr, register int len, u_short csum);
diff --git a/contrib/tcpdump/ip.h b/contrib/tcpdump/ip.h
new file mode 100644
index 0000000..77cf2f6
--- /dev/null
+++ b/contrib/tcpdump/ip.h
@@ -0,0 +1,159 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.7 2000/10/03 09:17:40 guy Exp $ (LBL) */
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip.h 8.2 (Berkeley) 6/1/94
+ */
+
+/*
+ * Definitions for internet protocol version 4.
+ * Per RFC 791, September 1981.
+ */
+#define IPVERSION 4
+
+/*
+ * Structure of an internet header, naked of options.
+ *
+ * We declare ip_len and ip_off to be short, rather than u_short
+ * pragmatically since otherwise unsigned comparisons can result
+ * against negative integers quite easily, and fail in subtle ways.
+ */
+struct ip {
+ u_int8_t ip_vhl; /* header length, version */
+#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
+#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
+ u_int8_t ip_tos; /* type of service */
+ u_int16_t ip_len; /* total length */
+ u_int16_t ip_id; /* identification */
+ u_int16_t ip_off; /* fragment offset field */
+#define IP_DF 0x4000 /* dont fragment flag */
+#define IP_MF 0x2000 /* more fragments flag */
+#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
+ u_int8_t ip_ttl; /* time to live */
+ u_int8_t ip_p; /* protocol */
+ u_int16_t ip_sum; /* checksum */
+ struct in_addr ip_src,ip_dst; /* source and dest address */
+};
+
+#define IP_MAXPACKET 65535 /* maximum packet size */
+
+/*
+ * Definitions for IP type of service (ip_tos)
+ */
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+
+/*
+ * Definitions for IP precedence (also in ip_tos) (hopefully unused)
+ */
+#define IPTOS_PREC_NETCONTROL 0xe0
+#define IPTOS_PREC_INTERNETCONTROL 0xc0
+#define IPTOS_PREC_CRITIC_ECP 0xa0
+#define IPTOS_PREC_FLASHOVERRIDE 0x80
+#define IPTOS_PREC_FLASH 0x60
+#define IPTOS_PREC_IMMEDIATE 0x40
+#define IPTOS_PREC_PRIORITY 0x20
+#define IPTOS_PREC_ROUTINE 0x00
+
+/*
+ * Definitions for options.
+ */
+#define IPOPT_COPIED(o) ((o)&0x80)
+#define IPOPT_CLASS(o) ((o)&0x60)
+#define IPOPT_NUMBER(o) ((o)&0x1f)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_DEBMEAS 0x40
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_EOL 0 /* end of option list */
+#define IPOPT_NOP 1 /* no operation */
+
+#define IPOPT_RR 7 /* record packet route */
+#define IPOPT_TS 68 /* timestamp */
+#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
+#define IPOPT_LSRR 131 /* loose source route */
+#define IPOPT_SATID 136 /* satnet id */
+#define IPOPT_SSRR 137 /* strict source route */
+
+/*
+ * Offsets to fields in options other than EOL and NOP.
+ */
+#define IPOPT_OPTVAL 0 /* option ID */
+#define IPOPT_OLEN 1 /* option length */
+#define IPOPT_OFFSET 2 /* offset within option */
+#define IPOPT_MINOFF 4 /* min value of above */
+
+/*
+ * Time stamp option structure.
+ */
+struct ip_timestamp {
+ u_int8_t ipt_code; /* IPOPT_TS */
+ u_int8_t ipt_len; /* size of structure (variable) */
+ u_int8_t ipt_ptr; /* index of current entry */
+ u_int8_t ipt_oflwflg; /* flags, overflow counter */
+#define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4)
+#define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f)
+ union ipt_timestamp {
+ u_int32_t ipt_time[1];
+ struct ipt_ta {
+ struct in_addr ipt_addr;
+ u_int32_t ipt_time;
+ } ipt_ta[1];
+ } ipt_timestamp;
+};
+
+/* flag bits for ipt_flg */
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 3 /* specified modules only */
+
+/* bits for security (not byte swapped) */
+#define IPOPT_SECUR_UNCLASS 0x0000
+#define IPOPT_SECUR_CONFID 0xf135
+#define IPOPT_SECUR_EFTO 0x789a
+#define IPOPT_SECUR_MMMM 0xbc4d
+#define IPOPT_SECUR_RESTR 0xaf13
+#define IPOPT_SECUR_SECRET 0xd788
+#define IPOPT_SECUR_TOPSECRET 0x6bc5
+
+/*
+ * Internet implementation parameters.
+ */
+#define MAXTTL 255 /* maximum time to live (seconds) */
+#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
+#define IPFRAGTTL 60 /* time to live for frags, slowhz */
+#define IPTTLDEC 1 /* subtracted when forwarding */
+
+#define IP_MSS 576 /* default maximum segment size */
diff --git a/contrib/tcpdump/ip6.h b/contrib/tcpdump/ip6.h
new file mode 100644
index 0000000..6e383dd
--- /dev/null
+++ b/contrib/tcpdump/ip6.h
@@ -0,0 +1,195 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.3 2000/12/17 23:07:48 guy Exp $ (LBL) */
+/* $NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp $ */
+/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IP6_H_
+#define _NETINET_IP6_H_
+
+/*
+ * Definition for internet protocol version 6.
+ * RFC 2460
+ */
+
+struct ip6_hdr {
+ union {
+ struct ip6_hdrctl {
+ u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
+ u_int16_t ip6_un1_plen; /* payload length */
+ u_int8_t ip6_un1_nxt; /* next header */
+ u_int8_t ip6_un1_hlim; /* hop limit */
+ } ip6_un1;
+ u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
+ } ip6_ctlun;
+ struct in6_addr ip6_src; /* source address */
+ struct in6_addr ip6_dst; /* destination address */
+};
+
+#define ip6_vfc ip6_ctlun.ip6_un2_vfc
+#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
+#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
+#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
+#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
+
+#define IPV6_VERSION 0x60
+#define IPV6_VERSION_MASK 0xf0
+
+/* in network endian */
+#define IPV6_FLOWINFO_MASK ((u_int32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK ((u_int32_t)htonl(0x000fffff)) /* flow label (20 bits) */
+#if 1
+/* ECN bits proposed by Sally Floyd */
+#define IP6TOS_CE 0x01 /* congestion experienced */
+#define IP6TOS_ECT 0x02 /* ECN-capable transport */
+#endif
+
+/*
+ * Extension Headers
+ */
+
+struct ip6_ext {
+ u_char ip6e_nxt;
+ u_char ip6e_len;
+};
+
+/* Hop-by-Hop options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_hbh {
+ u_int8_t ip6h_nxt; /* next header */
+ u_int8_t ip6h_len; /* length in units of 8 octets */
+ /* followed by options */
+};
+
+/* Destination options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_dest {
+ u_int8_t ip6d_nxt; /* next header */
+ u_int8_t ip6d_len; /* length in units of 8 octets */
+ /* followed by options */
+};
+
+/* Option types and related macros */
+#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
+#define IP6OPT_PADN 0x01 /* 00 0 00001 */
+#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
+#define IP6OPT_JUMBO_LEN 6
+#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
+
+#define IP6OPT_RTALERT_LEN 4
+#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
+#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
+#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
+#define IP6OPT_MINLEN 2
+
+#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
+#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
+#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
+#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
+#define IP6OPT_EID 0x8a /* 10 0 01010 */
+
+#define IP6OPT_TYPE(o) ((o) & 0xC0)
+#define IP6OPT_TYPE_SKIP 0x00
+#define IP6OPT_TYPE_DISCARD 0x40
+#define IP6OPT_TYPE_FORCEICMP 0x80
+#define IP6OPT_TYPE_ICMP 0xC0
+
+#define IP6OPT_MUTABLE 0x20
+
+/* Routing header */
+struct ip6_rthdr {
+ u_int8_t ip6r_nxt; /* next header */
+ u_int8_t ip6r_len; /* length in units of 8 octets */
+ u_int8_t ip6r_type; /* routing type */
+ u_int8_t ip6r_segleft; /* segments left */
+ /* followed by routing type specific data */
+};
+
+/* Type 0 Routing header */
+struct ip6_rthdr0 {
+ u_int8_t ip6r0_nxt; /* next header */
+ u_int8_t ip6r0_len; /* length in units of 8 octets */
+ u_int8_t ip6r0_type; /* always zero */
+ u_int8_t ip6r0_segleft; /* segments left */
+ u_int8_t ip6r0_reserved; /* reserved field */
+ u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */
+ struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
+};
+
+/* Fragment header */
+struct ip6_frag {
+ u_int8_t ip6f_nxt; /* next header */
+ u_int8_t ip6f_reserved; /* reserved field */
+ u_int16_t ip6f_offlg; /* offset, reserved, and flag */
+ u_int32_t ip6f_ident; /* identification */
+};
+
+/* network endian */
+#define IP6F_OFF_MASK ((u_int16_t)htons(0xfff8)) /* mask out offset from _offlg */
+#define IP6F_RESERVED_MASK ((u_int16_t)htons(0x0006)) /* reserved bits in ip6f_offlg */
+#define IP6F_MORE_FRAG ((u_int16_t)htons(0x0001)) /* more-fragments flag */
+
+#endif /* not _NETINET_IP6_H_ */
diff --git a/contrib/tcpdump/ipsec_doi.h b/contrib/tcpdump/ipsec_doi.h
index b2a9c93..f39f0dc 100644
--- a/contrib/tcpdump/ipsec_doi.h
+++ b/contrib/tcpdump/ipsec_doi.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* YIPS @(#)$Id: ipsec_doi.h,v 1.1 1999/10/30 05:11:09 itojun Exp $ */
+/* YIPS @(#)$Id: ipsec_doi.h,v 1.4 2000/10/04 03:00:29 itojun Exp $ */
/* refer to RFC 2407 */
@@ -51,6 +51,9 @@
#define IPSECDOI_AH_MD5 2
#define IPSECDOI_AH_SHA 3
#define IPSECDOI_AH_DES 4
+#define IPSECDOI_AH_SHA2_256 5
+#define IPSECDOI_AH_SHA2_384 6
+#define IPSECDOI_AH_SHA2_512 7
/* 4.4.1 IPSEC Security Protocol Identifiers */
#define IPSECDOI_PROTO_IPSEC_ESP 3
@@ -66,6 +69,8 @@
#define IPSECDOI_ESP_DES_IV32 9
#define IPSECDOI_ESP_RC4 10
#define IPSECDOI_ESP_NULL 11
+#define IPSECDOI_ESP_RIJNDAEL 12
+#define IPSECDOI_ESP_AES 12
/* 4.4.1 IPSEC Security Protocol Identifiers */
#define IPSECDOI_PROTO_IPCOMP 4
@@ -73,7 +78,6 @@
#define IPSECDOI_IPCOMP_OUI 1
#define IPSECDOI_IPCOMP_DEFLATE 2
#define IPSECDOI_IPCOMP_LZS 3
-#define IPSECDOI_IPCOMP_V42BIS 4
/* 4.5 IPSEC Security Association Attributes */
#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */
@@ -88,16 +92,17 @@
#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
#define IPSECDOI_ATTR_AUTH 5 /* B */
+ /* 0 means not to use authentication. */
#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
#define IPSECDOI_ATTR_AUTH_DES_MAC 3
-#define IPSECDOI_ATTR_AUTH_KPDK 4
+#define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/
/*
- When negotiating ESP without authentication, the Auth
- Algorithm attribute MUST NOT be included in the proposal.
- When negotiating ESP without confidentiality, the Auth
- Algorithm attribute MUST be included in the proposal and
- the ESP transform ID must be ESP_NULL.
+ * When negotiating ESP without authentication, the Auth
+ * Algorithm attribute MUST NOT be included in the proposal.
+ * When negotiating ESP without confidentiality, the Auth
+ * Algorithm attribute MUST be included in the proposal and
+ * the ESP transform ID must be ESP_NULL.
*/
#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
@@ -143,22 +148,4 @@ struct ipsecdoi_id {
#define IPSECDOI_NTYPE_REPLAY_STATUS 24577
#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578
-#if 0
-/* ipsec sa structure */
-struct ipsec_sa {
- u_int8_t proto_id; /* Protocol id */
- vchar_t *spi; /* spi to receive, network byte order */
- vchar_t *spi_p; /* spi to send, network byte order */
- vchar_t *keymat; /* KEYMAT */
- u_int8_t t_id; /* transform id */
- u_int8_t enc_t; /* type of cipher */
- u_int8_t mode_t; /* tunnel or transport */
- u_int8_t hash_t; /* type of hash */
- u_int8_t life_t; /* type of duration of lifetime */
- u_int32_t ldur; /* life duration */
- u_int8_t dhgrp; /* DH; group */
- struct ipsec_sa *next;
-};
-#endif
-
#endif /* !defined(_IPSEC_DOI_H_) */
diff --git a/contrib/tcpdump/ipx.h b/contrib/tcpdump/ipx.h
index 7d7fbc5..c65582a 100644
--- a/contrib/tcpdump/ipx.h
+++ b/contrib/tcpdump/ipx.h
@@ -1,7 +1,7 @@
/*
* IPX protocol formats
*
- * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $
+ * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.2 2000/10/03 02:54:56 itojun Exp $
*/
/* well-known sockets */
@@ -13,16 +13,16 @@
/* IPX transport header */
struct ipxHdr {
- u_short cksum; /* Checksum */
- u_short length; /* Length, in bytes, including header */
- u_char tCtl; /* Transport Control (i.e. hop count) */
- u_char pType; /* Packet Type (i.e. level 2 protocol) */
- u_short dstNet[2]; /* destination net */
- u_char dstNode[6]; /* destination node */
- u_short dstSkt; /* destination socket */
- u_short srcNet[2]; /* source net */
- u_char srcNode[6]; /* source node */
- u_short srcSkt; /* source socket */
+ u_int16_t cksum; /* Checksum */
+ u_int16_t length; /* Length, in bytes, including header */
+ u_int8_t tCtl; /* Transport Control (i.e. hop count) */
+ u_int8_t pType; /* Packet Type (i.e. level 2 protocol) */
+ u_int16_t dstNet[2]; /* destination net */
+ u_int8_t dstNode[6]; /* destination node */
+ u_int16_t dstSkt; /* destination socket */
+ u_int16_t srcNet[2]; /* source net */
+ u_int8_t srcNode[6]; /* source node */
+ u_int16_t srcSkt; /* source socket */
} ipx_hdr_t;
#define ipxSize 30
diff --git a/contrib/tcpdump/isakmp.h b/contrib/tcpdump/isakmp.h
index fbd9a1d..b12145f 100644
--- a/contrib/tcpdump/isakmp.h
+++ b/contrib/tcpdump/isakmp.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* YIPS @(#)$Id: isakmp.h,v 1.4.2.1 2000/01/14 19:19:56 mcr Exp $ */
+/* YIPS @(#)$Id: isakmp.h,v 1.7 2000/10/03 05:16:38 itojun Exp $ */
/* refer to RFC 2408 */
@@ -369,75 +369,6 @@ struct isakmp_ph2tab {
int len;
};
-#if 0
-/* isakmp status structure */
-struct isakmp_ph1 {
- isakmp_index index;
- u_int8_t dir; /* INITIATOR or RESPONDER */
- u_int16_t status; /* status of this SA */
- u_int16_t etype;
- u_int32_t doi;
- u_int32_t sit;
- vchar_t *dhp; /* DH; prime, static value */
- vchar_t *dhpriv; /* DH; private value */
- vchar_t *dhpub; /* DH; public value */
- vchar_t *dhpub_p; /* DH; partner's public value */
- vchar_t *dhgxy; /* DH; shared secret */
- vchar_t *nonce; /* nonce value */
- vchar_t *nonce_p; /* partner's nonce value */
- vchar_t *skeyid; /* SKEYID */
- vchar_t *skeyid_d; /* SKEYID_d */
- vchar_t *skeyid_a; /* SKEYID_a, i.e. hash */
- vchar_t *skeyid_e; /* SKEYID_e, i.e. encryption */
- vchar_t *key; /* cipher key */
- vchar_t *hash; /* HASH minus general header */
- vchar_t *iv; /* IV */
- vchar_t *ive; /* new IV to encrypt next packet */
- vchar_t *ivd; /* new IV to decrypt next packet */
- vchar_t *sa; /* SA minus general header including p,t.*/
- vchar_t *id; /* ID minus general header */
- vchar_t *id_p; /* partner's ID minus general header */
- struct sockaddr *local; /* pointer to the my sockaddr */
- struct sockaddr *remote; /* partner's sockaddr */
- struct oakley_sa *isa; /* Is it good that caddr_t ? */
- struct sched *sc; /* back pointer to the record in schedule
- used to resend. */
- struct isakmp_ph1 *next;
- struct isakmp_ph1 *prev;
- struct isakmp_conf *cfp; /* pointer to isakmp configuration */
- struct isakmp_ph2tab ph2tab; /* list on negotiating Phase 2 */
- u_int32_t msgid2; /* XXX: msgid counter for Phase 2 */
-};
-
-struct isakmp_ph2 {
- msgid_t msgid;
- u_int8_t dir; /* INITIATOR or RESPONDER */
- u_int16_t status; /* status of this SA */
- vchar_t *dhp; /* DH; prime, static value */
- vchar_t *dhpriv; /* DH; private value */
- vchar_t *dhpub; /* DH; public value */
- vchar_t *dhpub_p; /* DH; partner's public value */
- vchar_t *dhgxy; /* DH; shared secret */
- vchar_t *id; /* ID */
- vchar_t *id_p; /* ID for peer */
- vchar_t *nonce; /* nonce value in phase 2 */
- vchar_t *nonce_p; /* partner's nonce value in phase 2 */
- vchar_t *hash; /* HASH2 minus general header */
- vchar_t *iv; /* IV for Phase 2 */
- vchar_t *ive; /* new IV to encrypt next packet */
- vchar_t *ivd; /* new IV to decrypt next packet */
- struct isakmp_ph1 *ph1; /* back pointer to isakmp status */
- struct sched *sc; /* back pointer to the schedule using resend */
- struct pfkey_st *pst; /* pointer to the pfkey status record.
- is only used by initiator. */
- u_int8_t proxy; /* is proxy or not ?. */
- vchar_t *sa; /* SA payload */
- struct ipsec_sa *isa; /* values of SA to use, same SA in use. */
- struct isakmp_ph2 *next;
- struct isakmp_ph2 *prev;
-};
-#endif
-
#define EXCHANGE_PROXY 1
#define EXCHANGE_MYSELF 0
diff --git a/contrib/tcpdump/l2tp.h b/contrib/tcpdump/l2tp.h
index 008491e..5c8f98d 100644
--- a/contrib/tcpdump/l2tp.h
+++ b/contrib/tcpdump/l2tp.h
@@ -1,3 +1,4 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -18,7 +19,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * L2TP support contributed by Motonori Shindo (mshindo@ascend.co.jp)
+ * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
@@ -61,22 +62,22 @@
struct l2tp_avp_vec {
const char *name;
- void (*print)(const u_char *, u_int);
+ void (*print)(const u_char *, u_int32_t);
};
struct l2tp_call_errors {
- u_short reserved;
- u_int crc_errs;
- u_int framing_errs;
- u_int hardware_overruns;
- u_int buffer_overruns;
- u_int timeout_errs;
- u_int alignment_errs;
+ u_int16_t reserved;
+ u_int32_t crc_errs;
+ u_int32_t framing_errs;
+ u_int32_t hardware_overruns;
+ u_int32_t buffer_overruns;
+ u_int32_t timeout_errs;
+ u_int32_t alignment_errs;
};
struct l2tp_accm {
- u_short reserved;
- u_int send_accm;
- u_int recv_accm;
+ u_int16_t reserved;
+ u_int32_t send_accm;
+ u_int32_t recv_accm;
};
diff --git a/contrib/tcpdump/lane.h b/contrib/tcpdump/lane.h
index 1e17103..f83e904 100644
--- a/contrib/tcpdump/lane.h
+++ b/contrib/tcpdump/lane.h
@@ -20,15 +20,15 @@
*
*/
-/* $Id: lane.h,v 1.2 1999/11/21 16:35:11 assar Exp $ */
+/* $Id: lane.h,v 1.3 2000/10/03 02:54:56 itojun Exp $ */
#ifndef ETHER_ADDR_LEN
#define ETHER_ADDR_LEN 6
#endif
struct lecdatahdr_8023 {
- u_short le_header;
- u_char h_dest[ETHER_ADDR_LEN];
- u_char h_source[ETHER_ADDR_LEN];
- u_short h_type;
+ u_int16_t le_header;
+ u_int8_t h_dest[ETHER_ADDR_LEN];
+ u_int8_t h_source[ETHER_ADDR_LEN];
+ u_int16_t h_type;
};
diff --git a/contrib/tcpdump/lbl/os-solaris2.h b/contrib/tcpdump/lbl/os-solaris2.h
index 9a8b831..de481c2 100644
--- a/contrib/tcpdump/lbl/os-solaris2.h
+++ b/contrib/tcpdump/lbl/os-solaris2.h
@@ -18,37 +18,13 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.18.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.19 2000/10/11 04:02:15 guy Exp $ (LBL)
*/
/* Prototypes missing in SunOS 5 */
-int daemon(int, int);
-int dn_expand(const u_char *, const u_char *, const u_char *, char *, int);
-int dn_skipname(const u_char *, const 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(const 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 *);
diff --git a/contrib/tcpdump/llc.h b/contrib/tcpdump/llc.h
index cd6ea20..5f0b981 100644
--- a/contrib/tcpdump/llc.h
+++ b/contrib/tcpdump/llc.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.6.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.8 2000/12/18 07:55:36 guy Exp $ (LBL)
*/
/*
@@ -32,19 +32,19 @@
*/
struct llc {
- u_char dsap;
- u_char ssap;
+ u_int8_t dsap;
+ u_int8_t ssap;
union {
- u_char u_ctl;
- u_short is_ctl;
+ u_int8_t u_ctl;
+ u_int16_t is_ctl;
struct {
- u_char snap_ui;
- u_char snap_pi[5];
+ u_int8_t snap_ui;
+ u_int8_t snap_pi[5];
} snap;
struct {
- u_char snap_ui;
- u_char snap_orgcode[3];
- u_char snap_ethertype[2];
+ u_int8_t snap_ui;
+ u_int8_t snap_orgcode[3];
+ u_int8_t snap_ethertype[2];
} snap_ether;
} ctl;
};
@@ -61,7 +61,7 @@ struct llc {
#define LLC_S_FMT 1
#define LLC_U_POLL 0x10
-#define LLC_IS_POLL 0x0001
+#define LLC_IS_POLL 0x0100
#define LLC_XID_FI 0x81
#define LLC_U_CMD(u) ((u) & 0xef)
@@ -74,13 +74,13 @@ struct llc {
#define LLC_XID 0xaf
#define LLC_FRMR 0x87
-#define LLC_S_CMD(is) (((is) >> 10) & 0x03)
-#define LLC_RR 0x0100
-#define LLC_RNR 0x0500
-#define LLC_REJ 0x0900
+#define LLC_S_CMD(is) (((is) >> 1) & 0x03)
+#define LLC_RR 0x0001
+#define LLC_RNR 0x0005
+#define LLC_REJ 0x0009
-#define LLC_IS_NR(is) (((is) >> 1) & 0x7f)
-#define LLC_I_NS(is) (((is) >> 9) & 0x7f)
+#define LLC_IS_NR(is) (((is) >> 9) & 0x7f)
+#define LLC_I_NS(is) (((is) >> 1) & 0x7f)
#ifndef LLCSAP_NULL
#define LLCSAP_NULL 0x00
diff --git a/contrib/tcpdump/machdep.c b/contrib/tcpdump/machdep.c
index 1ed3fd4..3080f85 100644
--- a/contrib/tcpdump/machdep.c
+++ b/contrib/tcpdump/machdep.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.5 1999/11/21 09:36:47 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.6 2000/01/17 06:24:23 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -37,13 +37,13 @@ static const char rcsid[] =
#include "machdep.h"
int
-abort_on_misalignment(char *ebuf)
+abort_on_misalignment(char *ebuf, size_t ebufsiz)
{
#ifdef __osf__
static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS };
if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) {
- (void)sprintf(ebuf, "setsysinfo: errno %d", errno);
+ (void)snprintf(ebuf, ebufsiz, "setsysinfo: errno %d", errno);
return (-1);
}
#endif
diff --git a/contrib/tcpdump/machdep.h b/contrib/tcpdump/machdep.h
index 4cac15b..8d49a7a 100644
--- a/contrib/tcpdump/machdep.h
+++ b/contrib/tcpdump/machdep.h
@@ -18,10 +18,10 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.2 2000/01/17 06:24:24 itojun Exp $ (LBL)
*/
#ifndef tcpdump_machdep_h
#define tcpdump_machdep_h
-int abort_on_misalignment(char *);
+int abort_on_misalignment(char *, size_t);
#endif
diff --git a/contrib/tcpdump/missing/addrinfo.h b/contrib/tcpdump/missing/addrinfo.h
index 954b0b2..7a32937 100644
--- a/contrib/tcpdump/missing/addrinfo.h
+++ b/contrib/tcpdump/missing/addrinfo.h
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
-/* $Id: addrinfo.h,v 1.2 1999/11/21 01:35:41 assar Exp $ */
+/* $Id: addrinfo.h,v 1.3 2000/10/24 00:56:52 fenner Exp $ */
#ifndef HAVE_ADDRINFO
@@ -79,17 +79,17 @@ struct addrinfo {
struct addrinfo *ai_next; /* next structure in linked list */
};
-extern void freeaddrinfo __P((struct addrinfo *));
-extern void freehostent __P((struct hostent *));
-extern char *gai_strerror __P((int));
-extern int getaddrinfo __P((const char *, const char *,
- const struct addrinfo *, struct addrinfo **));
-extern int getnameinfo __P((const struct sockaddr *, size_t, char *,
- size_t, char *, size_t, int));
-extern struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
-extern struct hostent *getipnodebyname __P((const char *, int, int, int *));
-extern int inet_pton __P((int, const char *, void *));
-extern const char *inet_ntop __P((int, const void *, char *, size_t));
+extern void freeaddrinfo (struct addrinfo *);
+extern void freehostent (struct hostent *);
+extern char *gai_strerror (int);
+extern int getaddrinfo (const char *, const char *,
+ const struct addrinfo *, struct addrinfo **);
+extern int getnameinfo (const struct sockaddr *, size_t, char *,
+ size_t, char *, size_t, int);
+extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
+extern struct hostent *getipnodebyname (const char *, int, int, int *);
+extern int inet_pton (int, const char *, void *);
+extern const char *inet_ntop (int, const void *, char *, size_t);
#endif /* HAVE_ADDRINFO */
/*
diff --git a/contrib/tcpdump/missing/getaddrinfo.c b/contrib/tcpdump/missing/getaddrinfo.c
index 87fd652..89b812d 100644
--- a/contrib/tcpdump/missing/getaddrinfo.c
+++ b/contrib/tcpdump/missing/getaddrinfo.c
@@ -51,7 +51,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.6.2.2 2000/01/25 18:39:03 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.10 2000/10/24 00:56:53 fenner Exp $";
#endif
#include <sys/types.h>
@@ -74,10 +74,6 @@ static const char rcsid[] =
#include <stdio.h>
#include <errno.h>
-#ifndef HAVE_PORTABLE_PROTOTYPE
-#include "cdecl_ext.h"
-#endif
-
#ifndef HAVE_U_INT32_T
#include "bittypes.h"
#endif
@@ -175,24 +171,24 @@ static const struct explore explore[] = {
#endif
-static int str_isnumber __P((const char *));
-static int explore_fqdn __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int explore_null __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int explore_numeric __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int explore_numeric_scope __P((const struct addrinfo *, const char *,
- const char *, struct addrinfo **));
-static int get_name __P((const char *, const struct afd *, struct addrinfo **,
- char *, const struct addrinfo *, const char *));
-static int get_canonname __P((const struct addrinfo *,
- struct addrinfo *, const char *));
-static struct addrinfo *get_ai __P((const struct addrinfo *,
- const struct afd *, const char *));
-static int get_portmatch __P((const struct addrinfo *, const char *));
-static int get_port __P((struct addrinfo *, const char *, int));
-static const struct afd *find_afd __P((int));
+static int str_isnumber (const char *);
+static int explore_fqdn (const struct addrinfo *, const char *,
+ const char *, struct addrinfo **);
+static int explore_null (const struct addrinfo *, const char *,
+ const char *, struct addrinfo **);
+static int explore_numeric (const struct addrinfo *, const char *,
+ const char *, struct addrinfo **);
+static int explore_numeric_scope (const struct addrinfo *, const char *,
+ const char *, struct addrinfo **);
+static int get_name (const char *, const struct afd *, struct addrinfo **,
+ char *, const struct addrinfo *, const char *);
+static int get_canonname (const struct addrinfo *,
+ struct addrinfo *, const char *);
+static struct addrinfo *get_ai (const struct addrinfo *,
+ const struct afd *, const char *);
+static int get_portmatch (const struct addrinfo *, const char *);
+static int get_port (struct addrinfo *, const char *, int);
+static const struct afd *find_afd (int);
static char *ai_errlist[] = {
"Success",
diff --git a/contrib/tcpdump/missing/getnameinfo.c b/contrib/tcpdump/missing/getnameinfo.c
index 2d23425..502ac7f 100644
--- a/contrib/tcpdump/missing/getnameinfo.c
+++ b/contrib/tcpdump/missing/getnameinfo.c
@@ -43,7 +43,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.3.2.2 2000/01/25 18:39:03 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.8 2000/10/24 00:56:53 fenner Exp $";
#endif
#include <sys/types.h>
@@ -58,10 +58,6 @@ static const char rcsid[] =
#include <stddef.h>
#include <errno.h>
-#ifndef HAVE_PORTABLE_PROTOTYPE
-#include "cdecl_ext.h"
-#endif
-
#ifdef NEED_ADDRINFO_H
#include "addrinfo.h"
#endif
@@ -159,12 +155,12 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
- if (strlen(sp->s_name) > servlen)
+ if (strlen(sp->s_name) + 1 > servlen)
return ENI_MEMORY;
strcpy(serv, sp->s_name);
} else {
- sprintf(numserv, "%d", ntohs(port));
- if (strlen(numserv) > servlen)
+ snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
+ if (strlen(numserv) + 1 > servlen)
return ENI_MEMORY;
strcpy(serv, numserv);
}
@@ -220,7 +216,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_SYSTEM;
- if (strlen(numaddr) > hostlen)
+ if (strlen(numaddr) + 1 > hostlen)
return ENI_MEMORY;
strcpy(host, numaddr);
#if defined(INET6) && defined(NI_WITHSCOPEID)
@@ -260,7 +256,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
p = strchr(hp->h_name, '.');
if (p) *p = '\0';
}
- if (strlen(hp->h_name) > hostlen) {
+ if (strlen(hp->h_name) + 1 > hostlen) {
#ifdef USE_GETIPNODEBY
freehostent(hp);
#endif
@@ -276,7 +272,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_NOHOSTNAME;
- if (strlen(numaddr) > hostlen)
+ if (strlen(numaddr) + 1 > hostlen)
return ENI_MEMORY;
strcpy(host, numaddr);
}
diff --git a/contrib/tcpdump/missing/inet_aton.c b/contrib/tcpdump/missing/inet_aton.c
index 355b6a1..3d4ebf9 100644
--- a/contrib/tcpdump/missing/inet_aton.c
+++ b/contrib/tcpdump/missing/inet_aton.c
@@ -36,11 +36,11 @@
* SUCH DAMAGE.
*/
-/* $Id: inet_aton.c,v 1.1.2.1 2000/01/11 06:58:29 fenner Exp $ */
+/* $Id: inet_aton.c,v 1.2 2000/01/09 21:35:45 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.1.2.1 2000/01/11 06:58:29 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.2 2000/01/09 21:35:45 fenner Exp $";
#endif
#include <sys/types.h>
diff --git a/contrib/tcpdump/missing/inet_ntop.c b/contrib/tcpdump/missing/inet_ntop.c
index 09506fd..a43c429 100644
--- a/contrib/tcpdump/missing/inet_ntop.c
+++ b/contrib/tcpdump/missing/inet_ntop.c
@@ -36,11 +36,11 @@
* SUCH DAMAGE.
*/
-/* $Id: inet_ntop.c,v 1.2.2.1 2000/01/11 06:58:30 fenner Exp $ */
+/* $Id: inet_ntop.c,v 1.3 2000/01/09 21:35:45 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.2.2.1 2000/01/11 06:58:30 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.3 2000/01/09 21:35:45 fenner Exp $";
#endif
#include <stdio.h>
diff --git a/contrib/tcpdump/missing/inet_pton.c b/contrib/tcpdump/missing/inet_pton.c
index 1138627..34ec0af 100644
--- a/contrib/tcpdump/missing/inet_pton.c
+++ b/contrib/tcpdump/missing/inet_pton.c
@@ -36,11 +36,11 @@
* SUCH DAMAGE.
*/
-/* $Id: inet_pton.c,v 1.1.2.1 2000/01/11 06:58:30 fenner Exp $ */
+/* $Id: inet_pton.c,v 1.2 2000/01/09 21:35:46 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.1.2.1 2000/01/11 06:58:30 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.2 2000/01/09 21:35:46 fenner Exp $";
#endif
#include <errno.h>
diff --git a/contrib/tcpdump/missing/snprintf.c b/contrib/tcpdump/missing/snprintf.c
new file mode 100644
index 0000000..176636f
--- /dev/null
+++ b/contrib/tcpdump/missing/snprintf.c
@@ -0,0 +1,628 @@
+/*
+ * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the Institute 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 BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* $Id: snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $";
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+
+#include <interface.h>
+
+enum format_flags {
+ minus_flag = 1,
+ plus_flag = 2,
+ space_flag = 4,
+ alternate_flag = 8,
+ zero_flag = 16
+};
+
+/*
+ * Common state
+ */
+
+struct state {
+ unsigned char *str;
+ unsigned char *s;
+ unsigned char *theend;
+ size_t sz;
+ size_t max_sz;
+ int (*append_char)(struct state *, unsigned char);
+ int (*reserve)(struct state *, size_t);
+ /* XXX - methods */
+};
+
+#ifndef HAVE_VSNPRINTF
+static int
+sn_reserve (struct state *state, size_t n)
+{
+ return state->s + n > state->theend;
+}
+
+static int
+sn_append_char (struct state *state, unsigned char c)
+{
+ if (sn_reserve (state, 1)) {
+ return 1;
+ } else {
+ *state->s++ = c;
+ return 0;
+ }
+}
+#endif
+
+static int
+as_reserve (struct state *state, size_t n)
+{
+ if (state->s + n > state->theend) {
+ int off = state->s - state->str;
+ unsigned char *tmp;
+
+ if (state->max_sz && state->sz >= state->max_sz)
+ return 1;
+
+ state->sz = max(state->sz * 2, state->sz + n);
+ if (state->max_sz)
+ state->sz = min(state->sz, state->max_sz);
+ tmp = realloc (state->str, state->sz);
+ if (tmp == NULL)
+ return 1;
+ state->str = tmp;
+ state->s = state->str + off;
+ state->theend = state->str + state->sz - 1;
+ }
+ return 0;
+}
+
+static int
+as_append_char (struct state *state, unsigned char c)
+{
+ if(as_reserve (state, 1))
+ return 1;
+ else {
+ *state->s++ = c;
+ return 0;
+ }
+}
+
+static int
+append_number(struct state *state,
+ unsigned long num, unsigned base, char *rep,
+ int width, int prec, int flags, int minusp)
+{
+ int len = 0;
+ int i;
+
+ /* given precision, ignore zero flag */
+ if(prec != -1)
+ flags &= ~zero_flag;
+ else
+ prec = 1;
+ /* zero value with zero precision -> "" */
+ if(prec == 0 && num == 0)
+ return 0;
+ do{
+ if((*state->append_char)(state, rep[num % base]))
+ return 1;
+ len++;
+ num /= base;
+ }while(num);
+ prec -= len;
+ /* pad with prec zeros */
+ while(prec-- > 0){
+ if((*state->append_char)(state, '0'))
+ return 1;
+ len++;
+ }
+ /* add length of alternate prefix (added later) to len */
+ if(flags & alternate_flag && (base == 16 || base == 8))
+ len += base / 8;
+ /* pad with zeros */
+ if(flags & zero_flag){
+ width -= len;
+ if(minusp || (flags & space_flag) || (flags & plus_flag))
+ width--;
+ while(width-- > 0){
+ if((*state->append_char)(state, '0'))
+ return 1;
+ len++;
+ }
+ }
+ /* add alternate prefix */
+ if(flags & alternate_flag && (base == 16 || base == 8)){
+ if(base == 16)
+ if((*state->append_char)(state, rep[10] + 23)) /* XXX */
+ return 1;
+ if((*state->append_char)(state, '0'))
+ return 1;
+ }
+ /* add sign */
+ if(minusp){
+ if((*state->append_char)(state, '-'))
+ return 1;
+ len++;
+ } else if(flags & plus_flag) {
+ if((*state->append_char)(state, '+'))
+ return 1;
+ len++;
+ } else if(flags & space_flag) {
+ if((*state->append_char)(state, ' '))
+ return 1;
+ len++;
+ }
+ if(flags & minus_flag)
+ /* swap before padding with spaces */
+ for(i = 0; i < len / 2; i++){
+ char c = state->s[-i-1];
+ state->s[-i-1] = state->s[-len+i];
+ state->s[-len+i] = c;
+ }
+ width -= len;
+ while(width-- > 0){
+ if((*state->append_char)(state, ' '))
+ return 1;
+ len++;
+ }
+ if(!(flags & minus_flag))
+ /* swap after padding with spaces */
+ for(i = 0; i < len / 2; i++){
+ char c = state->s[-i-1];
+ state->s[-i-1] = state->s[-len+i];
+ state->s[-len+i] = c;
+ }
+
+ return 0;
+}
+
+static int
+append_string (struct state *state,
+ unsigned char *arg,
+ int width,
+ int prec,
+ int flags)
+{
+ if(prec != -1)
+ width -= prec;
+ else
+ width -= strlen((char *)arg);
+ if(!(flags & minus_flag))
+ while(width-- > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+ if (prec != -1) {
+ while (*arg && prec--)
+ if ((*state->append_char) (state, *arg++))
+ return 1;
+ } else {
+ while (*arg)
+ if ((*state->append_char) (state, *arg++))
+ return 1;
+ }
+ if(flags & minus_flag)
+ while(width-- > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+ return 0;
+}
+
+static int
+append_char(struct state *state,
+ unsigned char arg,
+ int width,
+ int flags)
+{
+ while(!(flags & minus_flag) && --width > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+
+ if((*state->append_char) (state, arg))
+ return 1;
+ while((flags & minus_flag) && --width > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+
+ return 0;
+}
+
+/*
+ * This can't be made into a function...
+ */
+
+#define PARSE_INT_FORMAT(res, arg, unsig) \
+if (long_flag) \
+ res = (unsig long)va_arg(arg, unsig long); \
+else if (short_flag) \
+ res = (unsig short)va_arg(arg, unsig int); \
+else \
+ res = (unsig int)va_arg(arg, unsig int)
+
+/*
+ * zyxprintf - return 0 or -1
+ */
+
+static int
+xyzprintf (struct state *state, const char *char_format, va_list ap)
+{
+ const unsigned char *format = (const unsigned char *)char_format;
+ unsigned char c;
+
+ while((c = *format++)) {
+ if (c == '%') {
+ int flags = 0;
+ int width = 0;
+ int prec = -1;
+ int long_flag = 0;
+ int short_flag = 0;
+
+ /* flags */
+ while((c = *format++)){
+ if(c == '-')
+ flags |= minus_flag;
+ else if(c == '+')
+ flags |= plus_flag;
+ else if(c == ' ')
+ flags |= space_flag;
+ else if(c == '#')
+ flags |= alternate_flag;
+ else if(c == '0')
+ flags |= zero_flag;
+ else
+ break;
+ }
+
+ if((flags & space_flag) && (flags & plus_flag))
+ flags ^= space_flag;
+
+ if((flags & minus_flag) && (flags & zero_flag))
+ flags ^= zero_flag;
+
+ /* width */
+ if (isdigit(c))
+ do {
+ width = width * 10 + c - '0';
+ c = *format++;
+ } while(isdigit(c));
+ else if(c == '*') {
+ width = va_arg(ap, int);
+ c = *format++;
+ }
+
+ /* precision */
+ if (c == '.') {
+ prec = 0;
+ c = *format++;
+ if (isdigit(c))
+ do {
+ prec = prec * 10 + c - '0';
+ c = *format++;
+ } while(isdigit(c));
+ else if (c == '*') {
+ prec = va_arg(ap, int);
+ c = *format++;
+ }
+ }
+
+ /* size */
+
+ if (c == 'h') {
+ short_flag = 1;
+ c = *format++;
+ } else if (c == 'l') {
+ long_flag = 1;
+ c = *format++;
+ }
+
+ switch (c) {
+ case 'c' :
+ if(append_char(state, va_arg(ap, int), width, flags))
+ return -1;
+ break;
+ case 's' :
+ if (append_string(state,
+ va_arg(ap, unsigned char*),
+ width,
+ prec,
+ flags))
+ return -1;
+ break;
+ case 'd' :
+ case 'i' : {
+ long arg;
+ unsigned long num;
+ int minusp = 0;
+
+ PARSE_INT_FORMAT(arg, ap, signed);
+
+ if (arg < 0) {
+ minusp = 1;
+ num = -arg;
+ } else
+ num = arg;
+
+ if (append_number (state, num, 10, "0123456789",
+ width, prec, flags, minusp))
+ return -1;
+ break;
+ }
+ case 'u' : {
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 10, "0123456789",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'o' : {
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 010, "01234567",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'x' : {
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 0x10, "0123456789abcdef",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'X' :{
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 0x10, "0123456789ABCDEF",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'p' : {
+ unsigned long arg = (unsigned long)va_arg(ap, void*);
+
+ if (append_number (state, arg, 0x10, "0123456789ABCDEF",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'n' : {
+ int *arg = va_arg(ap, int*);
+ *arg = state->s - state->str;
+ break;
+ }
+ case '\0' :
+ --format;
+ /* FALLTHROUGH */
+ case '%' :
+ if ((*state->append_char)(state, c))
+ return -1;
+ break;
+ default :
+ if ( (*state->append_char)(state, '%')
+ || (*state->append_char)(state, c))
+ return -1;
+ break;
+ }
+ } else
+ if ((*state->append_char) (state, c))
+ return -1;
+ }
+ return 0;
+}
+
+#ifndef HAVE_SNPRINTF
+int
+snprintf (char *str, size_t sz, const char *format, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, format);
+ ret = vsnprintf (str, sz, format, args);
+
+#ifdef PARANOIA
+ {
+ int ret2;
+ char *tmp;
+
+ tmp = malloc (sz);
+ if (tmp == NULL)
+ abort ();
+
+ ret2 = vsprintf (tmp, format, args);
+ if (ret != ret2 || strcmp(str, tmp))
+ abort ();
+ free (tmp);
+ }
+#endif
+
+ va_end(args);
+ return ret;
+}
+#endif
+
+#ifndef HAVE_ASPRINTF
+int
+asprintf (char **ret, const char *format, ...)
+{
+ va_list args;
+ int val;
+
+ va_start(args, format);
+ val = vasprintf (ret, format, args);
+
+#ifdef PARANOIA
+ {
+ int ret2;
+ char *tmp;
+ tmp = malloc (val + 1);
+ if (tmp == NULL)
+ abort ();
+
+ ret2 = vsprintf (tmp, format, args);
+ if (val != ret2 || strcmp(*ret, tmp))
+ abort ();
+ free (tmp);
+ }
+#endif
+
+ va_end(args);
+ return val;
+}
+#endif
+
+#ifndef HAVE_ASNPRINTF
+int
+asnprintf (char **ret, size_t max_sz, const char *format, ...)
+{
+ va_list args;
+ int val;
+
+ va_start(args, format);
+ val = vasnprintf (ret, max_sz, format, args);
+
+#ifdef PARANOIA
+ {
+ int ret2;
+ char *tmp;
+ tmp = malloc (val + 1);
+ if (tmp == NULL)
+ abort ();
+
+ ret2 = vsprintf (tmp, format, args);
+ if (val != ret2 || strcmp(*ret, tmp))
+ abort ();
+ free (tmp);
+ }
+#endif
+
+ va_end(args);
+ return val;
+}
+#endif
+
+#ifndef HAVE_VASPRINTF
+int
+vasprintf (char **ret, const char *format, va_list args)
+{
+ return vasnprintf (ret, 0, format, args);
+}
+#endif
+
+
+#ifndef HAVE_VASNPRINTF
+int
+vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
+{
+ int st;
+ size_t len;
+ struct state state;
+
+ state.max_sz = max_sz;
+ state.sz = 1;
+ state.str = malloc(state.sz);
+ if (state.str == NULL) {
+ *ret = NULL;
+ return -1;
+ }
+ state.s = state.str;
+ state.theend = state.s + state.sz - 1;
+ state.append_char = as_append_char;
+ state.reserve = as_reserve;
+
+ st = xyzprintf (&state, format, args);
+ if (st) {
+ free (state.str);
+ *ret = NULL;
+ return -1;
+ } else {
+ char *tmp;
+
+ *state.s = '\0';
+ len = state.s - state.str;
+ tmp = realloc (state.str, len+1);
+ if (tmp == NULL) {
+ free (state.str);
+ *ret = NULL;
+ return -1;
+ }
+ *ret = tmp;
+ return len;
+ }
+}
+#endif
+
+#ifndef HAVE_VSNPRINTF
+int
+vsnprintf (char *str, size_t sz, const char *format, va_list args)
+{
+ struct state state;
+ int ret;
+ unsigned char *ustr = (unsigned char *)str;
+
+ state.max_sz = 0;
+ state.sz = sz;
+ state.str = ustr;
+ state.s = ustr;
+ state.theend = ustr + sz - 1;
+ state.append_char = sn_append_char;
+ state.reserve = sn_reserve;
+
+ ret = xyzprintf (&state, format, args);
+ *state.s = '\0';
+ if (ret)
+ return sz;
+ else
+ return state.s - state.str;
+}
+#endif
+
diff --git a/contrib/tcpdump/missing/strlcat.c b/contrib/tcpdump/missing/strlcat.c
new file mode 100644
index 0000000..92f46a9
--- /dev/null
+++ b/contrib/tcpdump/missing/strlcat.c
@@ -0,0 +1,78 @@
+/* $NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
+/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcat.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)";
+#endif
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <string.h>
+
+#include "interface.h"
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(dst, src, siz)
+ char *dst;
+ const char *src;
+ size_t siz;
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (*d != '\0' && n-- != 0)
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
diff --git a/contrib/tcpdump/missing/strlcpy.c b/contrib/tcpdump/missing/strlcpy.c
new file mode 100644
index 0000000..f55121d
--- /dev/null
+++ b/contrib/tcpdump/missing/strlcpy.c
@@ -0,0 +1,75 @@
+/* $NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
+/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcpy.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)";
+#endif
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <string.h>
+
+#include "interface.h"
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(dst, src, siz)
+ char *dst;
+ const char *src;
+ size_t siz;
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
diff --git a/contrib/tcpdump/nameser.h b/contrib/tcpdump/nameser.h
new file mode 100644
index 0000000..9963dd0
--- /dev/null
+++ b/contrib/tcpdump/nameser.h
@@ -0,0 +1,254 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.5 2000/12/28 20:30:41 itojun Exp $ (LBL) */
+/*
+ * Copyright (c) 1983, 1989, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)nameser.h 8.2 (Berkeley) 2/16/94
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+#ifndef _NAMESER_H_
+#define _NAMESER_H_
+
+#include <sys/types.h>
+
+/*
+ * Define constants based on rfc883
+ */
+#define PACKETSZ 512 /* maximum packet size */
+#define MAXDNAME 256 /* maximum domain name */
+#define MAXCDNAME 255 /* maximum compressed domain name */
+#define MAXLABEL 63 /* maximum length of domain label */
+ /* Number of bytes of fixed size data in query structure */
+#define QFIXEDSZ 4
+ /* number of bytes of fixed size data in resource record */
+#define RRFIXEDSZ 10
+
+/*
+ * Internet nameserver port number
+ */
+#define NAMESERVER_PORT 53
+
+/*
+ * Currently defined opcodes
+ */
+#define QUERY 0x0 /* standard query */
+#define IQUERY 0x1 /* inverse query */
+#define STATUS 0x2 /* nameserver status query */
+#if 0
+#define xxx 0x3 /* 0x3 reserved */
+#endif
+ /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
+#define UPDATEA 0x9 /* add resource record */
+#define UPDATED 0xa /* delete a specific resource record */
+#define UPDATEDA 0xb /* delete all named resource record */
+#define UPDATEM 0xc /* modify a specific resource record */
+#define UPDATEMA 0xd /* modify all named resource record */
+
+#define ZONEINIT 0xe /* initial zone transfer */
+#define ZONEREF 0xf /* incremental zone referesh */
+
+/*
+ * Currently defined response codes
+ */
+#define NOERROR 0 /* no error */
+#define FORMERR 1 /* format error */
+#define SERVFAIL 2 /* server failure */
+#define NXDOMAIN 3 /* non existent domain */
+#define NOTIMP 4 /* not implemented */
+#define REFUSED 5 /* query refused */
+ /* non standard */
+#define NOCHANGE 0xf /* update failed to change db */
+
+/*
+ * Type values for resources and queries
+ */
+#define T_A 1 /* host address */
+#define T_NS 2 /* authoritative server */
+#define T_MD 3 /* mail destination */
+#define T_MF 4 /* mail forwarder */
+#define T_CNAME 5 /* connonical name */
+#define T_SOA 6 /* start of authority zone */
+#define T_MB 7 /* mailbox domain name */
+#define T_MG 8 /* mail group member */
+#define T_MR 9 /* mail rename name */
+#define T_NULL 10 /* null resource record */
+#define T_WKS 11 /* well known service */
+#define T_PTR 12 /* domain name pointer */
+#define T_HINFO 13 /* host information */
+#define T_MINFO 14 /* mailbox information */
+#define T_MX 15 /* mail routing information */
+#define T_TXT 16 /* text strings */
+#define T_RP 17 /* responsible person */
+#define T_AFSDB 18 /* AFS cell database */
+#define T_NSAP 22 /* NSAP address */
+#define T_NSAP_PTR 23 /* reverse lookup for NSAP */
+ /* non standard */
+#define T_UINFO 100 /* user (finger) information */
+#define T_UID 101 /* user ID */
+#define T_GID 102 /* group ID */
+#define T_UNSPEC 103 /* Unspecified format (binary data) */
+ /* Query type values which do not appear in resource records */
+#define T_AXFR 252 /* transfer zone of authority */
+#define T_MAILB 253 /* transfer mailbox records */
+#define T_MAILA 254 /* transfer mail agent records */
+#define T_ANY 255 /* wildcard match */
+
+/*
+ * Values for class field
+ */
+
+#define C_IN 1 /* the arpa internet */
+#define C_CHAOS 3 /* for chaos net (MIT) */
+#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
+ /* Query class values which do not appear in resource records */
+#define C_ANY 255 /* wildcard match */
+
+/*
+ * Status return codes for T_UNSPEC conversion routines
+ */
+#define CONV_SUCCESS 0
+#define CONV_OVERFLOW -1
+#define CONV_BADFMT -2
+#define CONV_BADCKSUM -3
+#define CONV_BADBUFLEN -4
+
+/*
+ * Structure for query header.
+ */
+typedef struct {
+ u_int16_t id; /* query identification number */
+ u_int8_t flags1; /* first byte of flags */
+ u_int8_t flags2; /* second byte of flags */
+ u_int16_t qdcount; /* number of question entries */
+ u_int16_t ancount; /* number of answer entries */
+ u_int16_t nscount; /* number of authority entries */
+ u_int16_t arcount; /* number of resource entries */
+} HEADER;
+
+/*
+ * Macros for subfields of flag fields.
+ */
+#define DNS_QR(np) ((np)->flags1 & 0x80) /* response flag */
+#define DNS_OPCODE(np) ((((np)->flags1) >> 3) & 0xF) /* purpose of message */
+#define DNS_AA(np) ((np)->flags1 & 0x04) /* authoritative answer */
+#define DNS_TC(np) ((np)->flags1 & 0x02) /* truncated message */
+#define DNS_RD(np) ((np)->flags1 & 0x01) /* recursion desired */
+
+#define DNS_RA(np) ((np)->flags2 & 0x80) /* recursion available */
+#define DNS_AD(np) ((np)->flags2 & 0x20) /* authentic data from named */
+#define DNS_CD(np) ((np)->flags2 & 0x10) /* checking disabled by resolver */
+#define DNS_RCODE(np) ((np)->flags2 & 0xF) /* response code */
+
+/*
+ * Defines for handling compressed domain names, EDNS0 labels, etc.
+ */
+#define INDIR_MASK 0xc0 /* 11.... */
+#define EDNS0_MASK 0x40 /* 01.... */
+# define EDNS0_ELT_BITLABEL 0x01
+
+/*
+ * Structure for passing resource records around.
+ */
+struct rrec {
+ int16_t r_zone; /* zone number */
+ int16_t r_class; /* class number */
+ int16_t r_type; /* type number */
+ u_int32_t r_ttl; /* time to live */
+ int r_size; /* size of data area */
+ char *r_data; /* pointer to data */
+};
+
+/*
+ * Inline versions of get/put short/long. Pointer is advanced.
+ * We also assume that a "u_int16_t" holds 2 "chars"
+ * and that a "u_int32_t" holds 4 "chars".
+ *
+ * These macros demonstrate the property of C whereby it can be
+ * portable or it can be elegant but never both.
+ */
+#define GETSHORT(s, cp) { \
+ register u_char *t_cp = (u_char *)(cp); \
+ (s) = ((u_int16_t)t_cp[0] << 8) | (u_int16_t)t_cp[1]; \
+ (cp) += 2; \
+}
+
+#define GETLONG(l, cp) { \
+ register u_char *t_cp = (u_char *)(cp); \
+ (l) = (((u_int32_t)t_cp[0]) << 24) \
+ | (((u_int32_t)t_cp[1]) << 16) \
+ | (((u_int32_t)t_cp[2]) << 8) \
+ | (((u_int32_t)t_cp[3])); \
+ (cp) += 4; \
+}
+
+#define PUTSHORT(s, cp) { \
+ register u_int16_t t_s = (u_int16_t)(s); \
+ register u_char *t_cp = (u_char *)(cp); \
+ *t_cp++ = t_s >> 8; \
+ *t_cp = t_s; \
+ (cp) += 2; \
+}
+
+/*
+ * Warning: PUTLONG --no-longer-- destroys its first argument. if you
+ * were depending on this "feature", you will lose.
+ */
+#define PUTLONG(l, cp) { \
+ register u_int32_t t_l = (u_int32_t)(l); \
+ register u_char *t_cp = (u_char *)(cp); \
+ *t_cp++ = t_l >> 24; \
+ *t_cp++ = t_l >> 16; \
+ *t_cp++ = t_l >> 8; \
+ *t_cp = t_l; \
+ (cp) += 4; \
+}
+
+#endif /* !_NAMESER_H_ */
diff --git a/contrib/tcpdump/nfs.h b/contrib/tcpdump/nfs.h
index 4e3885b..6de8369 100644
--- a/contrib/tcpdump/nfs.h
+++ b/contrib/tcpdump/nfs.h
@@ -245,7 +245,7 @@
/* File types */
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
- NFSOCK=6, NFFIFO=7 } nfstype;
+ NFSOCK=6, NFFIFO=7 } nfs_type;
/* Structs for common parts of the rpc's */
/*
@@ -294,7 +294,7 @@ typedef struct nfs_uquad nfsuint64;
*/
union nfs_quadconvert {
u_int32_t lval[2];
- u_quad_t qval;
+ u_int64_t qval;
};
typedef union nfs_quadconvert nfsquad_t;
diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h
index 7699df1..8160d0f 100644
--- a/contrib/tcpdump/nfsfh.h
+++ b/contrib/tcpdump/nfsfh.h
@@ -1,5 +1,5 @@
/*
- * $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.8 1999/12/15 06:49:05 fenner Exp $
+ * $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.9 2000/06/01 01:16:36 assar Exp $
*
* nfsfh.h - NFS file handle definitions (for portable use)
*
@@ -25,6 +25,7 @@ typedef struct {
*/
typedef struct {
my_devt Fsid_dev; /* XXX avoid name conflict with AIX */
+ char Opaque_Handle[2 * 32 + 1];
u_int32_t fsid_code;
} my_fsid;
diff --git a/contrib/tcpdump/ntp.h b/contrib/tcpdump/ntp.h
index e92408f2..3a574ed 100644
--- a/contrib/tcpdump/ntp.h
+++ b/contrib/tcpdump/ntp.h
@@ -1,4 +1,4 @@
-/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.3.1.1 1999/10/07 23:47:11 mcr Exp $ */
+/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.4 2000/10/03 02:54:57 itojun Exp $ */
/*
* Based on ntp.h from the U of MD implementation
@@ -33,8 +33,8 @@ struct l_fixedpt {
};
struct s_fixedpt {
- u_short int_part;
- u_short fraction;
+ u_int16_t int_part;
+ u_int16_t fraction;
};
/* ================= Table 3.3. Packet Variables ================= */
diff --git a/contrib/tcpdump/ospf.h b/contrib/tcpdump/ospf.h
index eee7944..69e474e 100644
--- a/contrib/tcpdump/ospf.h
+++ b/contrib/tcpdump/ospf.h
@@ -1,3 +1,4 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -91,14 +92,14 @@
/* link state advertisement header */
struct lsa_hdr {
- u_short ls_age;
- u_char ls_options;
- u_char ls_type;
+ u_int16_t ls_age;
+ u_int8_t ls_options;
+ u_int8_t ls_type;
struct in_addr ls_stateid;
struct in_addr ls_router;
u_int32_t ls_seq;
- u_short ls_chksum;
- u_short ls_length;
+ u_int16_t ls_chksum;
+ u_int16_t ls_length;
} ;
/* link state advertisement */
@@ -109,15 +110,15 @@ struct lsa {
union {
/* Router links advertisements */
struct {
- u_char rla_flags;
- u_char rla_zero[1];
- u_short rla_count;
+ u_int8_t rla_flags;
+ u_int8_t rla_zero[1];
+ u_int16_t rla_count;
struct rlalink {
struct in_addr link_id;
struct in_addr link_data;
- u_char link_type;
- u_char link_toscount;
- u_short link_tos0metric;
+ u_int8_t link_type;
+ u_int8_t link_toscount;
+ u_int16_t link_tos0metric;
} rla_link[1]; /* may repeat */
} un_rla;
@@ -156,9 +157,9 @@ struct lsa {
* TOS metric struct (will be 0 or more in router links update)
*/
struct tos_metric {
- u_char tos_type;
- u_char tos_zero;
- u_short tos_metric;
+ u_int8_t tos_type;
+ u_int8_t tos_zero;
+ u_int16_t tos_metric;
} ;
#define OSPF_AUTH_SIZE 8
@@ -167,22 +168,22 @@ struct tos_metric {
* the main header
*/
struct ospfhdr {
- u_char ospf_version;
- u_char ospf_type;
- u_short ospf_len;
+ u_int8_t ospf_version;
+ u_int8_t ospf_type;
+ u_int16_t ospf_len;
struct in_addr ospf_routerid;
struct in_addr ospf_areaid;
- u_short ospf_chksum;
- u_short ospf_authtype;
- u_char ospf_authdata[OSPF_AUTH_SIZE];
+ u_int16_t ospf_chksum;
+ u_int16_t ospf_authtype;
+ u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
union {
/* Hello packet */
struct {
struct in_addr hello_mask;
- u_short hello_helloint;
- u_char hello_options;
- u_char hello_priority;
+ u_int16_t hello_helloint;
+ u_int8_t hello_options;
+ u_int8_t hello_priority;
u_int32_t hello_deadint;
struct in_addr hello_dr;
struct in_addr hello_bdr;
@@ -191,9 +192,9 @@ struct ospfhdr {
/* Database Description packet */
struct {
- u_char db_zero[2];
- u_char db_options;
- u_char db_flags;
+ u_int8_t db_zero[2];
+ u_int8_t db_options;
+ u_int8_t db_flags;
u_int32_t db_seq;
struct lsa_hdr db_lshdr[1]; /* may repeat */
} un_db;
diff --git a/contrib/tcpdump/ospf6.h b/contrib/tcpdump/ospf6.h
index 85e81d7..3d810cf 100644
--- a/contrib/tcpdump/ospf6.h
+++ b/contrib/tcpdump/ospf6.h
@@ -1,3 +1,4 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -83,10 +84,10 @@
#define SLA_MASK_METRIC 0x00ffffff
#define SLA_SHIFT_TOS 24
-/* asla_tosmetric breakdown */
-#define ASLA_FLAG_EXTERNAL 0x80000000
-#define ASLA_MASK_TOS 0x7f000000
-#define ASLA_SHIFT_TOS 24
+/* asla_metric */
+#define ASLA_FLAG_EXTERNAL 0x04000000
+#define ASLA_FLAG_FWDADDR 0x02000000
+#define ASLA_FLAG_ROUTETAG 0x01000000
#define ASLA_MASK_METRIC 0x00ffffff
/* multicast vertex type */
@@ -149,6 +150,13 @@ struct lsa {
struct lsa_prefix inter_ap_prefix[1];
} un_inter_ap;
+ /* AS external links advertisements */
+ struct {
+ u_int32_t asla_metric;
+ struct lsa_prefix asla_prefix[1];
+ /* some optional fields follow */
+ } un_asla;
+
#if 0
/* Summary links advertisements */
struct {
@@ -156,16 +164,6 @@ struct lsa {
u_int32_t sla_tosmetric[1]; /* may repeat */
} un_sla;
- /* AS external links advertisements */
- struct {
- struct in_addr asla_mask;
- struct aslametric {
- u_int32_t asla_tosmetric;
- struct in_addr asla_forward;
- struct in_addr asla_tag;
- } asla_metric[1]; /* may repeat */
- } un_asla;
-
/* Multicast group membership */
struct mcla {
u_int32_t mcla_vtype;
diff --git a/contrib/tcpdump/parsenfsfh.c b/contrib/tcpdump/parsenfsfh.c
index 7ea8f27..0f4c3a5 100644
--- a/contrib/tcpdump/parsenfsfh.c
+++ b/contrib/tcpdump/parsenfsfh.c
@@ -9,7 +9,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.16 1999/11/21 09:36:47 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.18 2000/07/01 03:39:00 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -20,9 +20,6 @@ static const char rcsid[] =
#include <sys/time.h>
#include <ctype.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
@@ -93,6 +90,7 @@ int ourself; /* true if file handle was generated on this host */
register unsigned char *fhp = (unsigned char *)fh;
u_int32_t temp;
int fhtype = FHT_UNKNOWN;
+ int i;
if (ourself) {
/* File handle generated on this host, no need for guessing */
@@ -370,15 +368,18 @@ int ourself; /* true if file handle was generated on this host */
case FHT_UNKNOWN:
#ifdef DEBUG
- {
- /* XXX debugging */
- int i;
- for (i = 0; i < 32; i++)
- (void)fprintf(stderr, "%x.", fhp[i]);
- (void)fprintf(stderr, "\n");
- }
+ /* XXX debugging */
+ int i;
+ for (i = 0; i < 32; i++)
+ (void)fprintf(stderr, "%x.", fhp[i]);
+ (void)fprintf(stderr, "\n");
#endif
/* XXX for now, give "bogus" values to aid debugging */
+
+ /* Save the actual handle, so it can be display with -u */
+ for (i = 0; i < 32; i++)
+ (void)sprintf(&(fsidp->Opaque_Handle[i*2]), "%.2X", fhp[i]);
+
fsidp->fsid_code = 0;
fsidp->Fsid_dev.Minor = 257;
fsidp->Fsid_dev.Major = 257;
diff --git a/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h
index c121db1..00d3548 100644
--- a/contrib/tcpdump/ppp.h
+++ b/contrib/tcpdump/ppp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.8 1999/11/21 03:43:56 assar Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.11 2000/10/09 01:53:19 guy Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@@ -15,6 +15,8 @@
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
+#define PPP_HDRLEN 4 /* length of PPP header */
+
#define PPP_ADDRESS 0xff /* The address byte value */
#define PPP_CONTROL 0x03 /* The control byte value */
@@ -30,6 +32,7 @@
#define PPP_BRPDU 0x0031 /* Bridging PDU */
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
#define PPP_VINES 0x0035 /* Banyan Vines */
+#define PPP_IPV6 0x0057 /* IPv6 */
#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */
#define PPP_LUXCOM 0x0231 /* Luxcom */
@@ -43,9 +46,15 @@
#define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */
#define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */
#define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */
+#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
+#define PPP_CCP 0x80fd /* Compress Control Protocol */
#define PPP_LCP 0xc021 /* Link Control Protocol */
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
#define PPP_LQM 0xc025 /* Link Quality Monitoring */
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
+#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */
+#define PPP_BAP 0xc02d /* BAP */
+#define PPP_MP 0xc03d /* Multi-Link */
+
extern struct tok ppptype2str[];
diff --git a/contrib/tcpdump/print-ah.c b/contrib/tcpdump/print-ah.c
index 9a36ff4..c7a4fab 100644
--- a/contrib/tcpdump/print-ah.c
+++ b/contrib/tcpdump/print-ah.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.5 1999/12/15 08:10:17 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.14 2000/12/12 09:58:40 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,38 +35,11 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/route.h>
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <stdio.h>
-/* there's no standard definition so we are on our own */
-struct ah {
- u_int8_t ah_nxt; /* Next Header */
- u_int8_t ah_len; /* Length of data, in 32bit */
- u_int16_t ah_reserve; /* Reserved for future use */
- u_int32_t ah_spi; /* Security parameter index */
- /* variable size, 32bit bound*/ /* Authentication data */
-};
-
-struct newah {
- u_int8_t ah_nxt; /* Next Header */
- u_int8_t ah_len; /* Length of data + 1, in 32bit */
- u_int16_t ah_reserve; /* Reserved for future use */
- u_int32_t ah_spi; /* Security parameter index */
- u_int32_t ah_seq; /* Sequence number field */
- /* variable size, 32bit bound*/ /* Authentication data */
-};
+#include "ah.h"
#include "interface.h"
#include "addrtoname.h"
@@ -80,7 +53,7 @@ ah_print(register const u_char *bp, register const u_char *bp2)
u_int32_t spi;
ah = (struct ah *)bp;
- ep = snapend; /* 'ep' points to the end of avaible data. */
+ ep = snapend; /* 'ep' points to the end of available data. */
if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
goto trunc;
@@ -88,7 +61,7 @@ ah_print(register const u_char *bp, register const u_char *bp2)
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
- printf("AH(spi=%u", spi);
+ printf("AH(spi=0x%08x", spi);
if (vflag)
printf(",sumlen=%d", sumlen);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c
index 3a9f7ac..7b693a2 100644
--- a/contrib/tcpdump/print-arp.c
+++ b/contrib/tcpdump/print-arp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.44 1999/11/21 09:36:48 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.49 2000/10/10 05:05:07 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,28 +30,84 @@ static const char rcsid[] =
#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 <netinet/if_ether.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
+#include "ether.h"
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
+/*
+ * Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description. ARP packets are variable
+ * in size; the arphdr structure defines the fixed-length portion.
+ * Protocol type values are the same as those for 10 Mb/s Ethernet.
+ * It is followed by the variable-sized fields ar_sha, arp_spa,
+ * arp_tha and arp_tpa in that order, according to the lengths
+ * specified. Field names used correspond to RFC 826.
+ */
+struct arphdr {
+ u_short ar_hrd; /* format of hardware address */
+#define ARPHRD_ETHER 1 /* ethernet hardware format */
+#define ARPHRD_IEEE802 6 /* token-ring hardware format */
+#define ARPHRD_FRELAY 15 /* frame relay hardware format */
+ u_short ar_pro; /* format of protocol address */
+ u_char ar_hln; /* length of hardware address */
+ u_char ar_pln; /* length of protocol address */
+ u_short ar_op; /* one of: */
+#define ARPOP_REQUEST 1 /* request to resolve address */
+#define ARPOP_REPLY 2 /* response to previous request */
+#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */
+#define ARPOP_REVREPLY 4 /* response giving protocol address */
+#define ARPOP_INVREQUEST 8 /* request to identify peer */
+#define ARPOP_INVREPLY 9 /* response identifying peer */
+/*
+ * The remaining fields are variable in size,
+ * according to the sizes above.
+ */
+#ifdef COMMENT_ONLY
+ u_char ar_sha[]; /* sender hardware address */
+ u_char ar_spa[]; /* sender protocol address */
+ u_char ar_tha[]; /* target hardware address */
+ u_char ar_tpa[]; /* target protocol address */
+#endif
+};
+
+#define ARP_HDRLEN 8
+
+/*
+ * Ethernet Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description. Structure below is adapted
+ * to resolving internet addresses. Field names used correspond to
+ * RFC 826.
+ */
+struct ether_arp {
+ struct arphdr ea_hdr; /* fixed-size header */
+ u_char arp_sha[6]; /* sender hardware address */
+ u_char arp_spa[4]; /* sender protocol address */
+ u_char arp_tha[6]; /* target hardware address */
+ u_char arp_tpa[4]; /* target protocol address */
+};
+#define arp_hrd ea_hdr.ar_hrd
+#define arp_pro ea_hdr.ar_pro
+#define arp_hln ea_hdr.ar_hln
+#define arp_pln ea_hdr.ar_pln
+#define arp_op ea_hdr.ar_op
+
+#define ETHER_ARP_HDRLEN (ARP_HDRLEN + 6 + 4 + 6 + 4)
+
+#define SHA(ap) ((ap)->arp_sha)
+#define THA(ap) ((ap)->arp_tha)
+#define SPA(ap) ((ap)->arp_spa)
+#define TPA(ap) ((ap)->arp_tpa)
+
/* Compatibility */
#ifndef REVARP_REQUEST
#define REVARP_REQUEST 3
@@ -74,7 +130,7 @@ arp_print(register const u_char *bp, u_int length, u_int caplen)
printf("[|arp]");
return;
}
- if (length < sizeof(struct ether_arp)) {
+ if (length < ETHER_ARP_HDRLEN) {
(void)printf("truncated-arp");
default_print((u_char *)ap, length);
return;
diff --git a/contrib/tcpdump/print-ascii.c b/contrib/tcpdump/print-ascii.c
index 29f57b8..8c086d2 100644
--- a/contrib/tcpdump/print-ascii.c
+++ b/contrib/tcpdump/print-ascii.c
@@ -42,7 +42,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.2.2.2 2000/01/11 06:58:23 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.6 2000/01/29 16:47:46 itojun Exp $";
#endif
#include <stdio.h>
#include <sys/types.h>
@@ -72,7 +72,8 @@ ascii_print_with_offset(register const u_char *cp, register u_int length,
while (--nshorts >= 0) {
s1 = *cp++;
s2 = *cp++;
- (void)sprintf(hsp, " %02x%02x", s1, s2);
+ (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ " %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
*(asp++) = (isgraph(s1) ? s1 : '.');
*(asp++) = (isgraph(s2) ? s2 : '.');
@@ -87,7 +88,8 @@ ascii_print_with_offset(register const u_char *cp, register u_int length,
}
if (length & 1) {
s1 = *cp++;
- (void)sprintf(hsp, " %02x", s1);
+ (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ " %02x", s1);
hsp += 3;
*(asp++) = (isgraph(s1) ? s1 : '.');
++i;
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index b553b65..820b7db 100644
--- a/contrib/tcpdump/print-atalk.c
+++ b/contrib/tcpdump/print-atalk.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.51 1999/11/21 09:36:48 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.64 2000/10/30 06:22:14 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,24 +34,12 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <netinet/if_ether.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
#include "interface.h"
#include "addrtoname.h"
@@ -71,13 +59,13 @@ static struct tok type2str[] = {
};
struct aarp {
- u_short htype, ptype;
- u_char halen, palen;
- u_short op;
- u_char hsaddr[6];
- u_char psaddr[4];
- u_char hdaddr[6];
- u_char pdaddr[4];
+ u_int16_t htype, ptype;
+ u_int8_t halen, palen;
+ u_int16_t op;
+ u_int8_t hsaddr[6];
+ u_int8_t psaddr[4];
+ u_int8_t hdaddr[6];
+ u_int8_t pdaddr[4];
};
static char tstr[] = "[|atalk]";
@@ -96,10 +84,10 @@ static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
static const char *ddpskt_string(int);
/*
- * Print AppleTalk Datagram Delivery Protocol packets.
+ * Print AppleTalk LLAP packets.
*/
void
-atalk_print(register const u_char *bp, u_int length)
+llap_print(register const u_char *bp, u_int length)
{
register const struct LAP *lp;
register const struct atDDP *dp;
@@ -156,6 +144,33 @@ atalk_print(register const u_char *bp, u_int length)
}
}
+/*
+ * Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called
+ * when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk
+ * packets in them).
+ */
+void
+atalk_print(register const u_char *bp, u_int length)
+{
+ register const struct atDDP *dp;
+ u_short snet;
+
+ if (length < ddpSize) {
+ (void)printf(" [|ddp %d]", length);
+ return;
+ }
+ dp = (const struct atDDP *)bp;
+ snet = EXTRACT_16BITS(&dp->srcNet);
+ printf("%s.%s", ataddr_string(snet, dp->srcNode),
+ ddpskt_string(dp->srcSkt));
+ printf(" > %s.%s:",
+ ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
+ ddpskt_string(dp->dstSkt));
+ bp += ddpSize;
+ length -= ddpSize;
+ ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
+}
+
/* XXX should probably pass in the snap header and do checks like arp_print() */
void
aarp_print(register const u_char *bp, u_int length)
@@ -166,9 +181,9 @@ aarp_print(register const u_char *bp, u_int length)
printf("aarp ");
ap = (const struct aarp *)bp;
- if (ap->htype == 1 && ap->ptype == ETHERTYPE_ATALK &&
+ if (ntohs(ap->htype) == 1 && ntohs(ap->ptype) == ETHERTYPE_ATALK &&
ap->halen == 6 && ap->palen == 4 )
- switch (ap->op) {
+ switch (ntohs(ap->op)) {
case 1: /* request */
(void)printf("who-has %s tell %s",
@@ -185,10 +200,14 @@ aarp_print(register const u_char *bp, u_int length)
AT(pdaddr), AT(psaddr));
return;
}
- (void)printf("len %d op %d htype %d ptype %#x halen %d palen %d",
- length, ap->op, ap->htype, ap->ptype, ap->halen, ap->palen );
+ (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
+ length, ntohs(ap->op), ntohs(ap->htype), ntohs(ap->ptype),
+ ap->halen, ap->palen);
}
+/*
+ * Print AppleTalk Datagram Delivery Protocol packets.
+ */
static void
ddp_print(register const u_char *bp, register u_int length, register int t,
register u_short snet, register u_char snode, u_char skt)
@@ -491,7 +510,7 @@ ataddr_string(u_short atnet, u_char athost)
{
register struct hnamemem *tp, *tp2;
register int i = (atnet << 8) | athost;
- char nambuf[256];
+ char nambuf[MAXHOSTNAMELEN + 20];
static int first = 1;
FILE *fp;
@@ -507,11 +526,11 @@ ataddr_string(u_short atnet, u_char athost)
while (fgets(line, sizeof(line), fp)) {
if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
continue;
- if (sscanf(line, "%d.%d.%d %s", &i1, &i2, &i3,
+ if (sscanf(line, "%d.%d.%d %256s", &i1, &i2, &i3,
nambuf) == 4)
/* got a hostname. */
i3 |= ((i1 << 8) | i2) << 8;
- else if (sscanf(line, "%d.%d %s", &i1, &i2,
+ else if (sscanf(line, "%d.%d %256s", &i1, &i2,
nambuf) == 3)
/* got a net name */
i3 = (((i1 << 8) | i2) << 8) | 255;
@@ -538,7 +557,8 @@ ataddr_string(u_short atnet, u_char athost)
if (tp2->addr == i) {
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
- (void)sprintf(nambuf, "%s.%d", tp2->name, athost);
+ (void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
+ tp2->name, athost);
tp->name = savestr(nambuf);
return (tp->name);
}
@@ -546,10 +566,11 @@ ataddr_string(u_short atnet, u_char athost)
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
if (athost != 255)
- (void)sprintf(nambuf, "%d.%d.%d",
+ (void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d",
atnet >> 8, atnet & 0xff, athost);
else
- (void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff);
+ (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
+ atnet & 0xff);
tp->name = savestr(nambuf);
return (tp->name);
@@ -569,7 +590,7 @@ ddpskt_string(register int skt)
static char buf[8];
if (nflag) {
- (void)sprintf(buf, "%d", skt);
+ (void)snprintf(buf, sizeof(buf), "%d", skt);
return (buf);
}
return (tok2str(skt2str, "%d", skt));
diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c
index f9fc151..d978086 100644
--- a/contrib/tcpdump/print-atm.c
+++ b/contrib/tcpdump/print-atm.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.12 1999/11/21 09:36:48 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.20 2000/12/22 22:45:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -31,20 +31,7 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.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 <stdio.h>
#include <pcap.h>
@@ -144,8 +131,8 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
/* ether_type not known, print raw packet */
if (!eflag)
printf("%02x %02x %02x %02x-%02x-%02x %04x: ",
- p[0], p[1], p[2], /* dsap/ssap/ctrl */
- p[3], p[4], p[5], /* manufacturer's code */
+ packetp[0], packetp[1], packetp[2], /* dsap/ssap/ctrl */
+ packetp[3], packetp[4], packetp[5], /* manufacturer's code */
ethertype);
if (!xflag && !qflag)
default_print(p, caplen);
diff --git a/contrib/tcpdump/print-bgp.c b/contrib/tcpdump/print-bgp.c
index 23c3faf..71f20c3 100644
--- a/contrib/tcpdump/print-bgp.c
+++ b/contrib/tcpdump/print-bgp.c
@@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.9.2.2 2000/01/25 18:32:53 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.21 2000/12/05 05:48:35 guy Exp $";
#endif
#include <sys/param.h>
@@ -42,18 +42,15 @@ static const char rcsid[] =
#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 <errno.h>
#include <stdio.h>
#include <string.h>
+#include <netdb.h>
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
struct bgp {
u_int8_t bgp_marker[16];
@@ -240,7 +237,7 @@ num_or_str(const char **table, size_t siz, int value)
{
static char buf[20];
if (value < 0 || siz <= value || table[value] == NULL) {
- sprintf(buf, "#%d", value);
+ snprintf(buf, sizeof(buf), "#%d", value);
return buf;
} else
return table[value];
@@ -266,7 +263,7 @@ bgp_notify_minor(int major, int minor)
} else
p = NULL;
if (p == NULL) {
- sprintf(buf, "#%d", minor);
+ snprintf(buf, sizeof(buf), "#%d", minor);
return buf;
} else
return p;
@@ -288,7 +285,7 @@ decode_prefix4(const u_char *pd, char *buf, int buflen)
((u_char *)&addr)[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- sprintf(buf, "%s/%d", getname((char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
@@ -309,7 +306,7 @@ decode_prefix6(const u_char *pd, char *buf, int buflen)
addr.s6_addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- sprintf(buf, "%s/%d", getname6((char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname6((char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
#endif
@@ -323,7 +320,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
int advance;
int tlen;
const u_char *p;
- char buf[256];
+ char buf[MAXHOSTNAMELEN + 100];
p = dat;
@@ -430,20 +427,24 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
tlen = p[0];
if (tlen) {
printf(" nexthop");
- if (af == AFNUM_INET)
- advance = 4;
-#ifdef INET6
- else if (af == AFNUM_INET6)
- advance = 16;
-#endif
-
- for (i = 0; i < tlen; i += advance) {
- if (af == AFNUM_INET)
+ i = 0;
+ while (i < tlen) {
+ switch (af) {
+ case AFNUM_INET:
printf(" %s", getname(p + 1 + i));
+ i += sizeof(struct in_addr);
+ break;
#ifdef INET6
- else if (af == AFNUM_INET6)
+ case AFNUM_INET6:
printf(" %s", getname6(p + 1 + i));
+ i += sizeof(struct in6_addr);
+ break;
#endif
+ default:
+ printf(" (unknown af)");
+ i = tlen; /*exit loop*/
+ break;
+ }
}
printf(",");
}
@@ -462,13 +463,23 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf(" NLRI");
while (len - (p - dat) > 0) {
- if (af == AFNUM_INET)
+ switch (af) {
+ case AFNUM_INET:
advance = decode_prefix4(p, buf, sizeof(buf));
+ printf(" %s", buf);
+ break;
#ifdef INET6
- else if (af == AFNUM_INET6)
+ case AFNUM_INET6:
advance = decode_prefix6(p, buf, sizeof(buf));
+ printf(" %s", buf);
+ break;
#endif
- printf(" %s", buf);
+ default:
+ printf(" (unknown af)");
+ advance = 0;
+ p = dat + len;
+ break;
+ }
p += advance;
}
@@ -488,13 +499,23 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf(" Withdraw");
while (len - (p - dat) > 0) {
- if (af == AFNUM_INET)
+ switch (af) {
+ case AFNUM_INET:
advance = decode_prefix4(p, buf, sizeof(buf));
+ printf(" %s", buf);
+ break;
#ifdef INET6
- else if (af == AFNUM_INET6)
+ case AFNUM_INET6:
advance = decode_prefix6(p, buf, sizeof(buf));
+ printf(" %s", buf);
+ break;
#endif
- printf(" %s", buf);
+ default:
+ printf(" (unknown af)");
+ advance = 0;
+ p = dat + len;
+ break;
+ }
p += advance;
}
@@ -513,13 +534,14 @@ bgp_open_print(const u_char *dat, int length)
const u_char *opt;
int i;
+ TCHECK2(dat[0], sizeof(bgpo));
memcpy(&bgpo, dat, sizeof(bgpo));
hlen = ntohs(bgpo.bgpo_len);
printf(": Version %d,", bgpo.bgpo_version);
printf(" AS #%u,", ntohs(bgpo.bgpo_myas));
printf(" Holdtime %u,", ntohs(bgpo.bgpo_holdtime));
- printf(" ID %s,", getname((char *)&bgpo.bgpo_id));
+ printf(" ID %s,", getname((u_char *)&bgpo.bgpo_id));
printf(" Option length %u", bgpo.bgpo_optlen);
/* ugly! */
@@ -537,6 +559,9 @@ bgp_open_print(const u_char *dat, int length)
bgpopt.bgpopt_len);
i += sizeof(bgpopt) + bgpopt.bgpopt_len;
}
+ return;
+trunc:
+ printf("[|BGP]");
}
static void
@@ -550,19 +575,40 @@ bgp_update_print(const u_char *dat, int length)
int i;
int newline;
+ TCHECK2(dat[0], sizeof(bgp));
memcpy(&bgp, dat, sizeof(bgp));
hlen = ntohs(bgp.bgp_len);
p = dat + BGP_SIZE; /*XXX*/
printf(":");
/* Unfeasible routes */
- len = ntohs(*(u_int16_t *)p);
+ len = EXTRACT_16BITS(p);
if (len) {
+ /* Without keeping state from the original NLRI message,
+ * it's not possible to tell if this a v4 or v6 route,
+ * so only try to decode it if we're not v6 enabled.
+ */
+#ifdef INET6
printf(" (Withdrawn routes: %d bytes)", len);
+#else
+ char buf[MAXHOSTNAMELEN + 100];
+
+ TCHECK2(p[2], len);
+ i = 2;
+
+ printf(" (Withdrawn routes:");
+
+ while(i < 2 + len) {
+ i += decode_prefix4(&p[i], buf, sizeof(buf));
+ printf(" %s", buf);
+ }
+ printf(")\n");
+#endif
}
p += 2 + len;
- len = ntohs(*(u_int16_t *)p);
+ TCHECK2(p[0], 2);
+ len = EXTRACT_16BITS(p);
if (len) {
/* do something more useful!*/
i = 2;
@@ -571,6 +617,7 @@ bgp_update_print(const u_char *dat, int length)
while (i < 2 + len) {
int alen, aoff;
+ TCHECK2(p[i], sizeof(bgpa));
memcpy(&bgpa, &p[i], sizeof(bgpa));
alen = bgp_attr_len(&bgpa);
aoff = bgp_attr_off(&bgpa);
@@ -582,11 +629,14 @@ bgp_update_print(const u_char *dat, int length)
printf("("); /* ) */
printf("%s", bgp_attr_type(bgpa.bgpa_type));
if (bgpa.bgpa_flags) {
- printf("[%s%s%s%s]",
+ printf("[%s%s%s%s",
bgpa.bgpa_flags & 0x80 ? "O" : "",
bgpa.bgpa_flags & 0x40 ? "T" : "",
bgpa.bgpa_flags & 0x20 ? "P" : "",
- bgpa.bgpa_flags & 0x00 ? "E" : "");
+ bgpa.bgpa_flags & 0x10 ? "E" : "");
+ if (bgpa.bgpa_flags & 0xf)
+ printf("+%x", bgpa.bgpa_flags & 0xf);
+ printf("]");
}
bgp_attr_print(&bgpa, &p[i + aoff], alen);
@@ -608,7 +658,7 @@ bgp_update_print(const u_char *dat, int length)
if (dat + length > p) {
printf("(NLRI:"); /* ) */
while (dat + length > p) {
- char buf[256];
+ char buf[MAXHOSTNAMELEN + 100];
i = decode_prefix4(p, buf, sizeof(buf));
printf(" %s", buf);
if (i < 0)
@@ -619,6 +669,9 @@ bgp_update_print(const u_char *dat, int length)
/* ( */
printf(")");
}
+ return;
+trunc:
+ printf("[|BGP]");
}
static void
@@ -627,12 +680,16 @@ bgp_notification_print(const u_char *dat, int length)
struct bgp_notification bgpn;
int hlen;
+ TCHECK2(dat[0], sizeof(bgpn));
memcpy(&bgpn, dat, sizeof(bgpn));
hlen = ntohs(bgpn.bgpn_len);
printf(": error %s,", bgp_notify_major(bgpn.bgpn_major));
printf(" subcode %s",
bgp_notify_minor(bgpn.bgpn_major, bgpn.bgpn_minor));
+ return;
+trunc:
+ printf("[|BGP]");
}
static void
@@ -640,6 +697,7 @@ bgp_header_print(const u_char *dat, int length)
{
struct bgp bgp;
+ TCHECK2(dat[0], sizeof(bgp));
memcpy(&bgp, dat, sizeof(bgp));
printf("(%s", bgp_type(bgp.bgp_type)); /* ) */
@@ -657,6 +715,9 @@ bgp_header_print(const u_char *dat, int length)
/* ( */
printf(")");
+ return;
+trunc:
+ printf("[|BGP]");
}
void
@@ -698,7 +759,7 @@ bgp_print(const u_char *dat, int length)
}
/* found BGP header */
- TCHECK2(p[0], BGP_SIZE); /*XXX*/
+ TCHECK2(p[0], sizeof(bgp)); /*XXX*/
memcpy(&bgp, p, sizeof(bgp));
if (start != p)
diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c
index b1f7fbc..e564a29 100644
--- a/contrib/tcpdump/print-bootp.c
+++ b/contrib/tcpdump/print-bootp.c
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.48 1999/11/21 09:36:49 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.56 2000/12/04 00:00:08 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,24 +33,19 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
+#include "ether.h"
#include "bootp.h"
static void rfc1048_print(const u_char *, u_int);
@@ -179,7 +174,7 @@ bootp_print(register const u_char *cp, u_int length,
else {
u_int32_t ul;
- memcpy((char *)&ul, (char *)bp->bp_vend, sizeof(ul));
+ ul = EXTRACT_32BITS(&bp->bp_vend);
if (ul != 0)
printf("vend-#0x%x", ul);
}
@@ -194,7 +189,7 @@ static struct tok tag2str[] = {
/* RFC1048 tags */
{ TAG_PAD, " PAD" },
{ TAG_SUBNET_MASK, "iSM" }, /* subnet mask (RFC950) */
- { TAG_TIME_OFFSET, "lTZ" }, /* seconds from UTC */
+ { TAG_TIME_OFFSET, "LTZ" }, /* seconds from UTC */
{ TAG_GATEWAY, "iDG" }, /* default gateway */
{ TAG_TIME_SERVER, "iTS" }, /* time servers (RFC868) */
{ TAG_NAME_SERVER, "iIEN" }, /* IEN name servers (IEN116) */
@@ -269,7 +264,46 @@ static struct tok tag2str[] = {
{ TAG_RENEWAL_TIME, "lRN" },
{ TAG_REBIND_TIME, "lRB" },
{ TAG_VENDOR_CLASS, "bVC" },
- { TAG_CLIENT_ID, "bCID" },
+ { TAG_CLIENT_ID, "xCID" },
+/* RFC 2485 */
+ { TAG_OPEN_GROUP_UAP, "aUAP" },
+/* RFC 2563 */
+ { TAG_DISABLE_AUTOCONF, "BNOAUTO" },
+/* RFC 2610 */
+ { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */
+ { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */
+/* RFC 2937 */
+ { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */
+/* RFC 3011 */
+ { TAG_IP4_SUBNET_SELECT, "iSUBNET" },
+/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
+ { TAG_USER_CLASS, "aCLASS" },
+ { TAG_SLP_NAMING_AUTH, "aSLP-NA" },
+ { TAG_CLIENT_FQDN, "bFQDN" }, /* XXX 'b' */
+ { TAG_AGENT_CIRCUIT, "bACKT" },
+ { TAG_AGENT_REMOTE, "bARMT" },
+ { TAG_AGENT_MASK, "bAMSK" },
+ { TAG_TZ_STRING, "aTZSTR" },
+ { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */
+ { TAG_AUTH, "bAUTH" }, /* XXX 'b' */
+ { TAG_VINES_SERVERS, "iVINES" },
+ { TAG_SERVER_RANK, "sRANK" },
+ { TAG_CLIENT_ARCH, "sARCH" },
+ { TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */
+ { TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */
+ { TAG_LDAP_URL, "aLDAP" },
+ { TAG_6OVER4, "i6o4" },
+ { TAG_PRINTER_NAME, "aPRTR" },
+ { TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */
+ { TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */
+ { TAG_NETINFO_PARENT, "iNI" },
+ { TAG_NETINFO_PARENT_TAG, "aNITAG" },
+ { TAG_URL, "aURL" },
+ { TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */
+ { 0, NULL }
+};
+/* 2-byte extended tags */
+static struct tok xtag2str[] = {
{ 0, NULL }
};
@@ -296,7 +330,16 @@ rfc1048_print(register const u_char *bp, register u_int length)
continue;
if (tag == TAG_END)
return;
- cp = tok2str(tag2str, "?T%d", tag);
+ if (tag == TAG_EXTENDED_OPTION) {
+ TCHECK2(*(bp + 1), 2);
+ tag = EXTRACT_16BITS(bp + 1);
+ /* XXX we don't know yet if the IANA will
+ * preclude overlap of 1-byte and 2-byte spaces.
+ * If not, we need to offset tag after this step.
+ */
+ cp = tok2str(xtag2str, "?xT%d", tag);
+ } else
+ cp = tok2str(tag2str, "?T%d", tag);
c = *cp++;
printf(" %s:", cp);
@@ -331,7 +374,21 @@ rfc1048_print(register const u_char *bp, register u_int length)
first = 1;
while (len-- > 0) {
c = *bp++;
- cp = tok2str(tag2str, "?%d", c);
+ cp = tok2str(tag2str, "?T%d", c);
+ if (!first)
+ putchar('+');
+ printf("%s", cp + 1);
+ first = 0;
+ }
+ continue;
+ }
+ if (tag == TAG_EXTENDED_REQUEST) {
+ first = 1;
+ while (len > 1) {
+ len -= 2;
+ c = EXTRACT_16BITS(bp);
+ bp += 2;
+ cp = tok2str(xtag2str, "?xT%d", c);
if (!first)
putchar('+');
printf("%s", cp + 1);
@@ -365,13 +422,17 @@ rfc1048_print(register const u_char *bp, register u_int length)
case 'i':
case 'l':
+ case 'L':
/* ip addresses/32-bit words */
while (size >= sizeof(ul)) {
if (!first)
putchar(',');
- memcpy((char *)&ul, (char *)bp, sizeof(ul));
- if (c == 'i')
+ ul = EXTRACT_32BITS(bp);
+ if (c == 'i') {
+ ul = htonl(ul);
printf("%s", ipaddr_string(&ul));
+ } else if (c == 'L')
+ printf("%d", ul);
else
printf("%u", ul);
bp += sizeof(ul);
@@ -401,7 +462,7 @@ rfc1048_print(register const u_char *bp, register u_int length)
while (size >= sizeof(us)) {
if (!first)
putchar(',');
- memcpy((char *)&us, (char *)bp, sizeof(us));
+ us = EXTRACT_16BITS(bp);
printf("%d", us);
bp += sizeof(us);
size -= sizeof(us);
@@ -432,12 +493,13 @@ rfc1048_print(register const u_char *bp, register u_int length)
break;
case 'b':
+ case 'x':
default:
/* Bytes */
while (size > 0) {
if (!first)
- putchar('.');
- printf("%d", *bp);
+ putchar (c == 'x' ? ':' : '.');
+ printf (c == 'x' ? "%02x" : "%d", *bp);
++bp;
--size;
first = 0;
@@ -448,6 +510,9 @@ rfc1048_print(register const u_char *bp, register u_int length)
if (size)
printf("[len %d]", len);
}
+ return;
+trunc:
+ printf("|[rfc1048]");
}
static void
diff --git a/contrib/tcpdump/print-bxxp.c b/contrib/tcpdump/print-bxxp.c
new file mode 100644
index 0000000..56be54f
--- /dev/null
+++ b/contrib/tcpdump/print-bxxp.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2000, Richard Sharpe
+ *
+ * This software may be distributed either under the terms of the
+ * BSD-style licence that accompanies tcpdump or under the GNU GPL
+ * version 2 or later.
+ *
+ * print-bxxp.c
+ *
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bxxp.c,v 1.3 2000/10/05 04:10:01 itojun Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "interface.h"
+#include "extract.h"
+
+/* Check for a string but not go beyond length
+ * Return TRUE on match, FALSE otherwise
+ *
+ * Looks at the first few chars up to tl1 ...
+ */
+
+int l_strnstart(const u_char *, u_int, const u_char *, u_int);
+
+int
+l_strnstart(register const u_char *tstr1, register u_int tl1,
+ register const u_char *str2, register u_int l2)
+{
+
+ if (tl1 > l2)
+ return 0;
+
+ return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
+
+}
+
+void
+bxxp_print(register const u_char *bp, register u_int length)
+{
+
+ if (l_strnstart("REQ ", 4, bp, length)) { /* A REQuest */
+
+ printf(" BXXP REQ");
+
+ }
+ else if (l_strnstart("RSP ", 4, bp, length)) {
+
+ printf(" BXXP RSP");
+
+ }
+ else if (l_strnstart("SEQ ", 4, bp, length)) {
+
+ printf(" BXXP SEQ");
+
+ }
+ else if (l_strnstart("END", 4, bp, length)) {
+
+ printf(" BXXP END");
+
+ }
+ else
+ printf(" BXXP (payload or undecoded)");
+
+}
diff --git a/contrib/tcpdump/print-cdp.c b/contrib/tcpdump/print-cdp.c
new file mode 100644
index 0000000..53eff98
--- /dev/null
+++ b/contrib/tcpdump/print-cdp.c
@@ -0,0 +1,187 @@
+/*
+ * 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
+ * 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.
+ *
+ * Code by Gert Doering, SpaceNet GmbH, gert@space.net
+ *
+ * Reference documentation:
+ * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.4 2000/07/29 07:27:54 assar Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
+
+static void cdp_print_addr( const u_char * p, int l );
+static void cdp_print_prefixes( const u_char * p, int l );
+
+/*
+ * Returns non-zero IFF it succeeds in printing the header
+ */
+void
+cdp_print(const u_char *p, u_int length, u_int caplen,
+ const u_char *esrc, const u_char *edst)
+{
+ int i;
+ int type, len;
+
+ /* Cisco Discovery Protocol */
+
+
+ if ( caplen < 12 ) {
+ (void)printf("[|cdp]");
+ return;
+ }
+
+ i=8; /* CDP data starts at offset 8 */
+ printf ("CDP v%d, ttl=%ds", p[i], p[i+1] );
+ i+=4; /* skip version, TTL and chksum */
+
+ while (i < length) {
+ if ( i+4 > caplen ) {
+ printf("[!cdp]");
+ return;
+ }
+ type = (p[i]<<8) + p[i+1];
+ len = (p[i+2]<<8) + p[i+3];
+
+ if ( vflag )
+ printf( "\n\t%02x/%02x", type, len );
+ else
+ printf( "\n\t" );
+
+ if ( i+len > caplen ) {
+ printf("[!cdp]");
+ return;
+ }
+
+ switch( type )
+ {
+ case 0x01:
+ printf( " DevID '%.*s'", len-4, p+i+4 );
+ break;
+ case 0x02:
+ printf( " Addr" );
+ cdp_print_addr( p+i+4, len-4 );
+ break;
+ case 0x03:
+ printf( " PortID '%.*s'", len-4, p+i+4 );
+ break;
+ case 0x04:
+ printf( " CAP 0x%02x", (unsigned) p[i+7] );
+ break;
+ case 0x05:
+ if ( vflag )
+ printf( " Version:\n%.*s", len-4, p+i+4 );
+ else
+ printf( " Version: (suppressed)" );
+ break;
+ case 0x06:
+ printf( " Platform: '%.*s'", len-4, p+i+4 );
+ break;
+ case 0x07:
+ cdp_print_prefixes( p+i+4, len-4 );
+ break;
+ case 0x09: /* guess - not documented */
+ printf( " VTP Management Domain: '%.*s'", len-4, p+i+4 );
+ break;
+ case 0x0a: /* guess - not documented */
+ printf( " Native VLAN ID: %d", (p[i+4]<<8) + p[i+4+1] - 1 );
+ break;
+ case 0x0b: /* guess - not documented */
+ printf( " Duplex: %s", p[i+4] ? "full": "half" );
+ break;
+ default:
+ printf( " unknown field type %02x, len %d", type, len );
+ }
+
+ /* avoid infinite loop */
+ if (len == 0)
+ break;
+ i+=len;
+ }
+}
+
+static void
+cdp_print_addr( const u_char * p, int l )
+{
+ int pl, al, num;
+ const u_char * endp = p+l;
+
+ num = (p[0] << 24) + (p[1]<<16) + (p[2]<<8)+ p[3];
+ p+=4;
+
+ printf(" (%d): ", num );
+
+ while( p < endp && num >= 0) {
+ pl=*(p+1);
+ p+=2;
+
+ /* special case: IPv4, protocol type=0xcc, addr. length=4 */
+ if ( pl == 1 && *p == 0xcc &&
+ p[1] == 0 && p[2] == 4 ) {
+ p+=3;
+
+ printf( "IPv4 %d.%d.%d.%d ", p[0], p[1], p[2], p[3] );
+ p+=4;
+ } else { /* generic case: just print raw data */
+ printf("pt=0x%02x, pl=%d, pb=", *(p-2), pl);
+ while( pl-- > 0 )
+ printf( " %02x", *p++);
+ al=(*p << 8) + *(p+1);
+ printf( ", al=%d, a=", al );
+ p+=2;
+ while( al-- > 0 )
+ printf( " %02x", *p++);
+ }
+ printf(" ");
+ num--;
+ }
+}
+
+
+static void
+cdp_print_prefixes( const u_char * p, int l )
+{
+ printf( " IPv4 Prefixes (%d):", l/5 );
+
+ while(l > 0) {
+ printf( " %d.%d.%d.%d/%d", p[0], p[1], p[2], p[3], p[4] );
+ l-=5; p+=5;
+ }
+}
diff --git a/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c
index f9c5ecf..09c58ab 100644
--- a/contrib/tcpdump/print-chdlc.c
+++ b/contrib/tcpdump/print-chdlc.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.2 1999/11/21 09:36:49 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.11 2000/10/09 01:53:19 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -31,40 +31,19 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
-#ifdef __bsdi__
-#include <net/slcompress.h>
-#include <net/if_ppp.h>
-#endif
#include "interface.h"
#include "addrtoname.h"
+#include "ethertype.h"
#include "ppp.h"
-
-/* XXX This goes somewhere else. */
-#define CHDLC_HDRLEN 4
-#define CHDLC_UNICAST 0x0f
-#define CHDLC_BCAST 0x8f
-#define CHDLC_TYPE_SLARP 0x8035
-#define CHDLC_TYPE_CDP 0x2000
+#include "chdlc.h"
static void chdlc_slarp_print(const u_char *, u_int);
@@ -111,7 +90,7 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
length -= CHDLC_HDRLEN;
ip = (struct ip *)(p + CHDLC_HDRLEN);
- switch(proto) {
+ switch (proto) {
case ETHERTYPE_IP:
ip_print((const u_char *)ip, length);
break;
@@ -136,7 +115,7 @@ out:
}
struct cisco_slarp {
- long code;
+ u_int32_t code;
#define SLARP_REQUEST 0
#define SLARP_REPLY 1
#define SLARP_KEEPALIVE 2
@@ -144,14 +123,14 @@ struct cisco_slarp {
struct {
struct in_addr addr;
struct in_addr mask;
- u_short unused[3];
+ u_int16_t unused[3];
} addr;
struct {
- long myseq;
- long yourseq;
- short rel;
- short t1;
- short t2;
+ u_int32_t myseq;
+ u_int32_t yourseq;
+ u_int16_t rel;
+ u_int16_t t1;
+ u_int16_t t2;
} keep;
} un;
};
diff --git a/contrib/tcpdump/print-cip.c b/contrib/tcpdump/print-cip.c
index 5021bc0..1d244c2 100644
--- a/contrib/tcpdump/print-cip.c
+++ b/contrib/tcpdump/print-cip.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.2 1999/11/21 09:36:49 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.11 2000/12/22 22:45:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,59 +34,52 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.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>
#include <stdio.h>
#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
+#include "ethertype.h"
+#include "ether.h"
const u_char *packetp;
const u_char *snapend;
-#define RFC1483LLC_LEN 8
+#define RFC1483LLC_LEN 8
static unsigned char rfcllc[] = {
- 0xaa, /* DSAP: non-ISO */
- 0xaa, /* SSAP: non-ISO */
- 0x03, /* Ctrl: Unnumbered Information Command PDU */
- 0x00, /* OUI: EtherType */
- 0x00,
- 0x00 };
+ 0xaa, /* DSAP: non-ISO */
+ 0xaa, /* SSAP: non-ISO */
+ 0x03, /* Ctrl: Unnumbered Information Command PDU */
+ 0x00, /* OUI: EtherType */
+ 0x00,
+ 0x00 };
static inline void
cip_print(register const u_char *bp, int length)
{
- int i;
-
- if (memcmp(rfcllc, bp, sizeof(rfcllc))) {
- if (qflag) {
- for(i=0;i<RFC1483LLC_LEN;i++)
- (void)printf("%2.2x ",bp[i]);
- } else {
- for(i=0;i<RFC1483LLC_LEN-2;i++)
- (void)printf("%2.2x ",bp[i]);
- etherproto_string(((u_short*)bp)[3]);
- }
- } else {
- if (qflag)
- (void)printf("(null encapsulation)");
- else {
- (void)printf("(null encap)");
- etherproto_string(ETHERTYPE_IP);
- }
- }
+ int i;
+
+ if (memcmp(rfcllc, bp, sizeof(rfcllc))) {
+ if (qflag) {
+ for (i = 0;i < RFC1483LLC_LEN; i++)
+ (void)printf("%2.2x ",bp[i]);
+ } else {
+ for (i = 0;i < RFC1483LLC_LEN - 2; i++)
+ (void)printf("%2.2x ",bp[i]);
+ etherproto_string(((u_short*)bp)[3]);
+ }
+ } else {
+ if (qflag)
+ (void)printf("(null encapsulation)");
+ else {
+ (void)printf("(null encap)");
+ etherproto_string(ETHERTYPE_IP);
+ }
+ }
}
/*
@@ -112,7 +105,7 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
}
if (eflag)
- cip_print(p, length);
+ cip_print(p, length);
/*
* Some printers want to get back at the ethernet addresses,
@@ -123,13 +116,15 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
snapend = p + caplen;
if (memcmp(rfcllc, p, sizeof(rfcllc))==0) {
- length -= RFC1483LLC_LEN;
- caplen -= RFC1483LLC_LEN;
- bp = (u_short*)p;
- p += RFC1483LLC_LEN;
- ether_type = ntohs(bp[3]);
- } else
- ether_type = ETHERTYPE_IP;
+ length -= RFC1483LLC_LEN;
+ caplen -= RFC1483LLC_LEN;
+ bp = (u_short *)p;
+ p += RFC1483LLC_LEN;
+ ether_type = ntohs(bp[3]);
+ } else {
+ ether_type = ETHERTYPE_IP;
+ bp = (u_short *)p;
+ }
/*
* Is it (gag) an 802.3 encapsulation?
@@ -137,10 +132,11 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
extracted_ethertype = 0;
if (ether_type < ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, NULL, NULL)==0) {
+ if (llc_print(p, length, caplen, NULL, NULL,
+ &extracted_ethertype)==0) {
/* ether_type not known, print raw packet */
if (!eflag)
- cip_print((u_char *)bp, length);
+ cip_print((u_char *)bp, length + RFC1483LLC_LEN);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@@ -148,7 +144,8 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (!xflag && !qflag)
default_print(p, caplen);
}
- } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
+ } else if (ether_encap_print(ether_type, p, length, caplen,
+ &extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
cip_print((u_char *)bp, length + RFC1483LLC_LEN);
diff --git a/contrib/tcpdump/print-cnfp.c b/contrib/tcpdump/print-cnfp.c
new file mode 100644
index 0000000..265599c
--- /dev/null
+++ b/contrib/tcpdump/print-cnfp.c
@@ -0,0 +1,181 @@
+/* $OpenBSD: print-cnfp.c,v 1.2 1998/06/25 20:26:59 mickey Exp $ */
+
+/*
+ * Copyright (c) 1998 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Michael Shalayeff.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Cisco NetFlow protocol */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.6 2000/09/23 08:26:32 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+#include <netinet/in.h>
+
+#include <arpa/inet.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+
+#include "tcp.h"
+
+struct nfhdr {
+ u_int32_t ver_cnt; /* version [15], and # of records */
+ u_int32_t msys_uptime;
+ u_int32_t utc_sec;
+ u_int32_t utc_nsec;
+ u_int32_t sequence; /* v5 flow sequence number */
+ u_int32_t reserved; /* v5 only */
+};
+
+struct nfrec {
+ struct in_addr src_ina;
+ struct in_addr dst_ina;
+ struct in_addr nhop_ina;
+ u_int32_t ifaces; /* src,dst ifaces */
+ u_int32_t packets;
+ u_int32_t octets;
+ u_int32_t start_time; /* sys_uptime value */
+ u_int32_t last_time; /* sys_uptime value */
+ u_int32_t ports; /* src,dst ports */
+ u_int32_t proto_tos; /* proto, tos, pad, flags(v5) */
+ u_int32_t asses; /* v1: flags; v5: src,dst AS */
+ u_int32_t masks; /* src,dst addr prefix */
+
+};
+
+void
+cnfp_print(const u_char *cp, u_int len, const u_char *bp)
+{
+ register const struct nfhdr *nh;
+ register const struct nfrec *nr;
+ register const struct ip *ip;
+ struct protoent *pent;
+ int nrecs, ver;
+ time_t t;
+
+ ip = (struct ip *)bp;
+ nh = (struct nfhdr *)cp;
+
+ if ((u_char *)(nh + 1) > snapend)
+ return;
+
+ nrecs = ntohl(nh->ver_cnt) & 0xffff;
+ ver = (ntohl(nh->ver_cnt) & 0xffff0000) >> 16;
+ t = ntohl(nh->utc_sec);
+/* (p = ctime(&t))[24] = '\0'; */
+
+ printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+ (unsigned)ntohl(nh->msys_uptime)/1000,
+ (unsigned)ntohl(nh->msys_uptime)%1000,
+ (unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec));
+
+ if (ver == 5) {
+ printf("#%u, ", (unsigned)htonl(nh->sequence));
+ nr = (struct nfrec *)&nh[1];
+ snaplen -= 24;
+ } else {
+ nr = (struct nfrec *)&nh->sequence;
+ snaplen -= 16;
+ }
+
+ printf("%2u recs", nrecs);
+
+ for (; nrecs-- && (u_char *)(nr + 1) <= snapend; nr++) {
+ char buf[20];
+ char asbuf[20];
+
+ printf("\n started %u.%03u, last %u.%03u",
+ (unsigned)ntohl(nr->start_time)/1000,
+ (unsigned)ntohl(nr->start_time)%1000,
+ (unsigned)ntohl(nr->last_time)/1000,
+ (unsigned)ntohl(nr->last_time)%1000);
+
+ asbuf[0] = buf[0] = '\0';
+ if (ver == 5) {
+ snprintf(buf, sizeof(buf), "/%u",
+ (unsigned)(ntohl(nr->masks) >> 24) & 0xff);
+ snprintf(asbuf, sizeof(asbuf), "%u:",
+ (unsigned)(ntohl(nr->asses) >> 16) & 0xffff);
+ }
+ printf("\n %s%s%s:%u ", inet_ntoa(nr->src_ina), buf, asbuf,
+ (unsigned)ntohl(nr->ports) >> 16);
+
+ if (ver == 5) {
+ snprintf(buf, sizeof(buf), "/%d",
+ (unsigned)(ntohl(nr->masks) >> 16) & 0xff);
+ snprintf(asbuf, sizeof(asbuf), "%u:",
+ (unsigned)ntohl(nr->asses) & 0xffff);
+ }
+ printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf,
+ (unsigned)ntohl(nr->ports) & 0xffff);
+
+ printf(">> %s\n ", inet_ntoa(nr->nhop_ina));
+
+ pent = getprotobynumber((ntohl(nr->proto_tos) >> 8) & 0xff);
+ if (!pent || nflag)
+ printf("%u ",
+ (unsigned)(ntohl(nr->proto_tos) >> 8) & 0xff);
+ else
+ printf("%s ", pent->p_name);
+
+ /* tcp flags for tcp only */
+ if (pent && pent->p_proto == IPPROTO_TCP) {
+ int flags;
+ if (ver == 1)
+ flags = (ntohl(nr->asses) >> 24) & 0xff;
+ else
+ flags = (ntohl(nr->proto_tos) >> 16) & 0xff;
+ if (flags & TH_FIN) putchar('F');
+ if (flags & TH_SYN) putchar('S');
+ if (flags & TH_RST) putchar('R');
+ if (flags & TH_PUSH) putchar('P');
+ if (flags & TH_ACK) putchar('A');
+ if (flags & TH_URG) putchar('U');
+ if (flags)
+ putchar(' ');
+ }
+ printf("tos %u, %u (%u octets)",
+ (unsigned)ntohl(nr->proto_tos) & 0xff,
+ (unsigned)ntohl(nr->packets),
+ (unsigned)ntohl(nr->octets));
+ }
+}
diff --git a/contrib/tcpdump/print-decnet.c b/contrib/tcpdump/print-decnet.c
index c2c5c5a..d589bc9 100644
--- a/contrib/tcpdump/print-decnet.c
+++ b/contrib/tcpdump/print-decnet.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.27 1999/11/21 09:36:50 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.30 2000/09/28 06:42:57 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,20 +32,14 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#ifdef HAVE_LIBDNET
#include <netdnet/dnetdb.h>
#endif
#include <ctype.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -740,13 +734,14 @@ char *
dnnum_string(u_short dnaddr)
{
char *str;
+ size_t siz;
int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT;
int node = dnaddr & NODEMASK;
- str = (char *)malloc(sizeof("00.0000"));
+ str = (char *)malloc(siz = sizeof("00.0000"));
if (str == NULL)
error("dnnum_string: malloc");
- sprintf(str, "%d.%d", area, node);
+ snprintf(str, siz, "%d.%d", area, node);
return(str);
}
diff --git a/contrib/tcpdump/print-dhcp6.c b/contrib/tcpdump/print-dhcp6.c
index 411f166..c9848f0 100644
--- a/contrib/tcpdump/print-dhcp6.c
+++ b/contrib/tcpdump/print-dhcp6.c
@@ -29,7 +29,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.3 1999/12/22 06:27:20 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.12 2000/10/24 00:56:50 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -40,18 +40,12 @@ static const char rcsid[] =
#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>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
@@ -62,10 +56,10 @@ struct rtentry;
#include "dhcp6opt.h"
#if 0
-static void dhcp6opttab_init __P((void));
-static struct dhcp6_opt *dhcp6opttab_byname __P((char *));
+static void dhcp6opttab_init (void);
+static struct dhcp6_opt *dhcp6opttab_byname (char *);
#endif
-static struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
+static struct dhcp6_opt *dhcp6opttab_bycode (u_int);
static char tstr[] = " [|dhcp6]";
@@ -74,36 +68,35 @@ static struct dhcp6_opt dh6opttab[] = {
{ 1, OL6_N, "IP Address", OT6_NONE, },
/* General Extension */
- { 2, 4, "Time Offset", OT6_NUM, },
- { 3, OL6_N, "IEEE 1003.1 POSIX Timezone", OT6_STR, },
- { 6, OL6_16N, "Domain Name Server", OT6_V6, },
- { 10, OL6_N, "Domain Name", OT6_STR, },
-
- /* Application and Service Parameters */
- { 16, OL6_N, "Directory Agent", OT6_NONE, },
- { 17, OL6_N, "Service Scope" , OT6_NONE, },
- { 18, OL6_16N, "Network Time Protocol Servers", OT6_V6, },
- { 19, OL6_N, "NIS Domain", OT6_STR, },
- { 20, OL6_16N, "NIS Servers", OT6_V6, },
- { 21, OL6_N, "NIS+ Domain", OT6_STR, },
- { 22, OL6_16N, "NIS+ Servers", OT6_V6, },
+ { 8193, OL6_N, "IEEE 1003.1 POSIX Timezone", OT6_STR, },
+ { 8194, OL6_16N, "Domain Name Server", OT6_V6, },
+ { 8195, OL6_N, "Domain Name", OT6_STR, },
+
+ { 8196, OL6_N, "SLP Agent", OT6_NONE, },
+ { 8197, OL6_N, "SLP Scope" , OT6_NONE, },
+ { 8198, OL6_16N, "Network Time Protocol Servers", OT6_V6, },
+ { 8199, OL6_N, "NIS Domain", OT6_STR, },
+ { 8200, OL6_16N, "NIS Servers", OT6_V6, },
+ { 8201, OL6_N, "NIS+ Domain", OT6_STR, },
+ { 8202, OL6_16N, "NIS+ Servers", OT6_V6, },
/* TCP Parameters */
- { 32, 4, "TCP Keepalive Interval", OT6_NUM, },
+ { 8203, 4, "TCP Keepalive Interval", OT6_NUM, },
/* DHCPv6 Extensions */
- { 40, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
- { 41, OL6_N, "DHCP Retransmission and Configuration Parameter",
+ { 8204, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
+ { 8205, OL6_N, "DHCP Retransmission and Configuration Parameter",
OT6_NONE, },
- { 48, OL6_N, "Platform Specific Information", OT6_NONE, },
- { 49, OL6_N, "Platform Class Identifier", OT6_STR, },
- { 64, OL6_N, "Class Identifier", OT6_STR, },
- { 66, 16, "Reconfigure Multicast Address", OT6_V6, },
- { 67, 16, "Renumber DHCPv6 Server Address",
+ { 8206, OL6_N, "Extension Request", OT6_NONE, },
+ { 8207, OL6_N, "Subnet Prefix", OT6_NONE, },
+ { 8208, OL6_N, "Platform Specific Information", OT6_NONE, },
+ { 8209, OL6_N, "Platform Class Identifier", OT6_STR, },
+ { 8210, OL6_N, "Class Identifier", OT6_STR, },
+ { 8211, 16, "Reconfigure Multicast Address", OT6_V6, },
+ { 8212, 16, "Renumber DHCPv6 Server Address",
OT6_V6, },
- { 68, OL6_N, "DHCP Relay ICMP Error Message", OT6_NONE, },
- { 84, OL6_N, "Client-Server Authentication", OT6_NONE, },
- { 85, 4, "Client Key Selection", OT6_NUM, },
+ { 8213, OL6_N, "Client-Server Authentication", OT6_NONE, },
+ { 8214, 4, "Client Key Selection", OT6_NUM, },
/* End Extension */
{ 65536, OL6_Z, "End", OT6_NONE, },
@@ -159,13 +152,18 @@ dhcp6ext_print(u_char *cp, u_char *ep)
if (cp == ep)
return;
- printf(" ");
while (cp < ep) {
+ if (ep - cp < sizeof(u_int16_t))
+ break;
code = ntohs(*(u_int16_t *)&cp[0]);
+ if (ep - cp < sizeof(u_int16_t) * 2)
+ break;
if (code != 65535)
len = ntohs(*(u_int16_t *)&cp[2]);
else
len = 0;
+ if (ep - cp < len + 4)
+ break;
p = dhcp6opttab_bycode(code);
if (p == NULL) {
printf("(unknown, len=%d)", len);
@@ -191,11 +189,11 @@ dhcp6ext_print(u_char *cp, u_char *ep)
break;
}
if (cp + 4 + len > ep) {
- printf("[|%s]", p->name);
+ printf(" [|%s]", p->name);
return;
}
- printf("(%s, ", p->name);
+ printf(" (%s, ", p->name);
switch (p->type) {
case OT6_V6:
for (i = 0; i < len; i += 16) {
@@ -232,11 +230,12 @@ trunc:
*/
void
dhcp6_print(register const u_char *cp, u_int length,
- u_short sport, u_short dport)
+ u_int16_t sport, u_int16_t dport)
{
union dhcp6 *dh6;
u_char *ep;
u_char *extp;
+ u_int16_t field16;
printf("dhcp6");
@@ -246,31 +245,43 @@ dhcp6_print(register const u_char *cp, u_int length,
TCHECK(dh6->dh6_msgtype);
switch (dh6->dh6_msgtype) {
case DH6_SOLICIT:
- if (vflag && TTEST(dh6->dh6_sol.dh6sol_relayaddr)) {
- printf(" solicit(");
- if ((dh6->dh6_sol.dh6sol_flags & DH6SOL_CLOSE) != 0)
- printf("C");
- if (dh6->dh6_sol.dh6sol_flags != 0)
- printf(" ");
- printf("cliaddr=%s",
- ip6addr_string(&dh6->dh6_sol.dh6sol_cliaddr));
- printf(" relayaddr=%s",
- ip6addr_string(&dh6->dh6_sol.dh6sol_relayaddr));
- printf(")");
- } else
+ if (!(vflag && TTEST(dh6->dh6_sol.dh6sol_relayaddr))) {
printf(" solicit");
+ break;
+ }
+
+ printf(" solicit ("); /*)*/
+ if (dh6->dh6_sol.dh6sol_flags != 0) {
+ u_int8_t f = dh6->dh6_sol.dh6sol_flags;
+ printf("%s%s ",
+ (f & DH6SOL_PREFIX) ? "P" : "",
+ (f & DH6SOL_CLOSE) ? "C" : "");
+ }
+
+ memcpy(&field16, &dh6->dh6_sol.dh6sol_plen_id,
+ sizeof(field16));
+ field16 = ntohs(field16);
+ if (field16 & ~DH6SOL_SOLICIT_PLEN_MASK)
+ printf("plen=%d ", DH6SOL_SOLICIT_PLEN(field16));
+ printf("solicit-ID=%d", DH6SOL_SOLICIT_ID(field16));
+
+ printf(" cliaddr=%s",
+ ip6addr_string(&dh6->dh6_sol.dh6sol_cliaddr));
+ printf(" relayaddr=%s",
+ ip6addr_string(&dh6->dh6_sol.dh6sol_relayaddr));
+ /*(*/
+ printf(")");
break;
case DH6_ADVERT:
if (!(vflag && TTEST(dh6->dh6_adv.dh6adv_serveraddr))) {
printf(" advert");
break;
}
- printf(" advert(");
- if ((dh6->dh6_adv.dh6adv_flags & DH6ADV_SERVPRESENT) != 0)
- printf("S");
- if (dh6->dh6_adv.dh6adv_flags != 0)
- printf(" ");
- printf("pref=%u", dh6->dh6_adv.dh6adv_pref);
+ printf(" advert ("); /*)*/
+ memcpy(&field16, &dh6->dh6_adv.dh6adv_rsv_id, sizeof(field16));
+ printf("solicit-ID=%d",
+ ntohs(field16) & DH6SOL_SOLICIT_ID_MASK);
+ printf(" pref=%u", dh6->dh6_adv.dh6adv_pref);
printf(" cliaddr=%s",
ip6addr_string(&dh6->dh6_adv.dh6adv_cliaddr));
printf(" relayaddr=%s",
@@ -279,6 +290,7 @@ dhcp6_print(register const u_char *cp, u_int length,
ip6addr_string(&dh6->dh6_adv.dh6adv_serveraddr));
extp = (u_char *)((&dh6->dh6_adv) + 1);
dhcp6ext_print(extp, ep);
+ /*(*/
printf(")");
break;
case DH6_REQUEST:
@@ -286,26 +298,22 @@ dhcp6_print(register const u_char *cp, u_int length,
printf(" request");
break;
}
- printf(" request(");
- if ((dh6->dh6_req.dh6req_flags & DH6REQ_CLOSE) != 0)
- printf("C");
- if ((dh6->dh6_req.dh6req_flags & DH6REQ_SERVPRESENT) != 0)
- printf("S");
- if ((dh6->dh6_req.dh6req_flags & DH6REQ_REBOOT) != 0)
- printf("R");
- if (dh6->dh6_req.dh6req_flags != 0)
- printf(" ");
+ printf(" request ("); /*)*/
+ if (dh6->dh6_req.dh6req_flags != 0) {
+ u_int8_t f = dh6->dh6_req.dh6req_flags;
+ printf("%s%s ",
+ (f & DH6REQ_CLOSE) ? "C" : "",
+ (f & DH6REQ_REBOOT) ? "R" : "");
+ }
printf("xid=0x%04x", dh6->dh6_req.dh6req_xid);
printf(" cliaddr=%s",
- ip6addr_string(&dh6->dh6_req.dh6req_cliaddr));
+ ip6addr_string(&dh6->dh6_req.dh6req_cliaddr));
printf(" relayaddr=%s",
- ip6addr_string(&dh6->dh6_req.dh6req_relayaddr));
- extp = (char *)((&dh6->dh6_req) + 1);
- if ((dh6->dh6_req.dh6req_flags & DH6REQ_SERVPRESENT) != 0) {
- printf(" servaddr=%s", ip6addr_string(extp));
- extp += 16;
- }
- dhcp6ext_print(extp, ep);
+ ip6addr_string(&dh6->dh6_req.dh6req_relayaddr));
+ printf(" servaddr=%s",
+ ip6addr_string(&dh6->dh6_req.dh6req_serveraddr));
+ dhcp6ext_print((char *)(&dh6->dh6_req + 1), ep);
+ /*(*/
printf(")");
break;
case DH6_REPLY:
@@ -313,19 +321,22 @@ dhcp6_print(register const u_char *cp, u_int length,
printf(" reply");
break;
}
- printf(" reply(");
- if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_CLIPRESENT) != 0)
- printf("C");
- if (dh6->dh6_rep.dh6rep_flagandstat != 0)
- printf(" ");
+ printf(" reply ("); /*)*/
+ if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_RELAYPRESENT) != 0)
+ printf("R ");
printf("stat=0x%02x",
dh6->dh6_rep.dh6rep_flagandstat & DH6REP_STATMASK);
+ printf(" xid=0x%04x", dh6->dh6_rep.dh6rep_xid);
+ printf(" cliaddr=%s",
+ ip6addr_string(&dh6->dh6_rep.dh6rep_cliaddr));
extp = (u_char *)((&dh6->dh6_rep) + 1);
- if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_CLIPRESENT) != 0) {
- printf(" cliaddr=%s", ip6addr_string(extp));
- extp += 16;
+ if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_RELAYPRESENT) !=
+ 0) {
+ printf(" relayaddr=%s", ip6addr_string(extp));
+ extp += sizeof(struct in6_addr);
}
dhcp6ext_print(extp, ep);
+ /*(*/
printf(")");
break;
case DH6_RELEASE:
diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c
index 5d66b8d..77da8df 100644
--- a/contrib/tcpdump/print-domain.c
+++ b/contrib/tcpdump/print-domain.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.42 1999/11/21 09:36:50 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.64 2001/01/02 23:24:51 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,22 +30,8 @@ static const char rcsid[] =
#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 <netinet/if_ether.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>
#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
@@ -53,7 +39,7 @@ struct rtentry;
#ifdef NOERROR
#undef T_UNSPEC /* SINIX does too */
#endif
-#include <arpa/nameser.h>
+#include "nameser.h"
#include <stdio.h>
#include <string.h>
@@ -124,7 +110,14 @@ struct rtentry;
#define T_NAPTR 35 /* Naming Authority PoinTeR */
#endif
#ifndef T_A6
-#define T_A6 38 /* IP6 address (ipngwg-dns-lookups) */
+#define T_A6 38 /* IP6 address */
+#endif
+#ifndef T_DNAME
+#define T_DNAME 39 /* non-terminal redirection */
+#endif
+
+#ifndef T_OPT
+#define T_OPT 41 /* EDNS0 option (meta-RR) */
#endif
#ifndef T_UNSPEC
@@ -162,8 +155,22 @@ ns_nskip(register const u_char *cp, register const u_char *bp)
if (((i = *cp++) & INDIR_MASK) == INDIR_MASK)
return (cp + 1);
+ if (cp >= snapend)
+ return(NULL);
while (i && cp < snapend) {
- cp += i;
+ if ((i & INDIR_MASK) == EDNS0_MASK) {
+ int bitlen, bytelen;
+
+ if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
+ return(NULL); /* unknown ELT */
+ if ((bitlen = *cp++) == 0)
+ bitlen = 256;
+ bytelen = (bitlen + 7) / 8;
+ cp += bytelen;
+ } else
+ cp += i;
+ if (cp >= snapend)
+ return(NULL);
i = *cp++;
}
return (cp);
@@ -171,33 +178,135 @@ ns_nskip(register const u_char *cp, register const u_char *bp)
/* print a <domain-name> */
static const u_char *
-ns_nprint(register const u_char *cp, register const u_char *bp)
+blabel_print(const u_char *cp)
+{
+ int bitlen, slen, b;
+ int truncated = 0;
+ const u_char *bitp, *lim;
+ char tc;
+
+ if (cp >= snapend)
+ return(NULL);
+ if ((bitlen = *cp) == 0)
+ bitlen = 256;
+ slen = (bitlen + 3) / 4;
+ if ((lim = cp + 1 + slen) > snapend) {
+ truncated = 1;
+ lim = snapend;
+ }
+
+ /* print the bit string as a hex string */
+ printf("\\[x");
+ for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++)
+ printf("%02x", *bitp);
+ if (bitp == lim)
+ printf("...");
+ else if (b > 4) {
+ tc = *bitp++;
+ printf("%02x", tc & (0xff << (8 - b)));
+ } else if (b > 0) {
+ tc = *bitp++;
+ printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
+ }
+ printf("/%d]", bitlen);
+
+ return(truncated ? NULL : lim);
+}
+
+static int
+labellen(const u_char *cp)
{
register u_int i;
- register const u_char *rp;
- register int compress;
- i = *cp++;
- rp = cp + i;
- if ((i & INDIR_MASK) == INDIR_MASK) {
- rp = cp + 1;
- compress = 1;
+ if (cp >= snapend)
+ return(-1);
+ i = *cp;
+ if ((i & INDIR_MASK) == EDNS0_MASK) {
+ int bitlen, elt;
+
+ if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL)
+ return(-1);
+ if (cp + 1 >= snapend)
+ return(-1);
+ if ((bitlen = *(cp + 1)) == 0)
+ bitlen = 256;
+ return(((bitlen + 7) / 8) + 1);
} else
+ return(i);
+}
+
+static const u_char *
+ns_nprint(register const u_char *cp, register const u_char *bp)
+{
+ register u_int i, l;
+ register const u_char *rp = NULL;
+ register int compress = 0;
+ int chars_processed;
+ int elt;
+ int data_size = snapend - bp;
+
+ if ((l = labellen(cp)) < 0)
+ return(NULL);
+ if (cp >= snapend)
+ return(NULL);
+ chars_processed = 1;
+ if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
compress = 0;
+ rp = cp + l;
+ }
+
if (i != 0)
while (i && cp < snapend) {
if ((i & INDIR_MASK) == INDIR_MASK) {
+ if (!compress) {
+ rp = cp + 1;
+ compress = 1;
+ }
cp = bp + (((i << 8) | *cp) & 0x3fff);
+ if (cp >= snapend)
+ return(NULL);
+ if ((l = labellen(cp)) < 0)
+ return(NULL);
i = *cp++;
+ chars_processed++;
+
+ /*
+ * If we've looked at every character in
+ * the message, this pointer will make
+ * us look at some character again,
+ * which means we're looping.
+ */
+ if (chars_processed >= data_size) {
+ printf("<LOOP>");
+ return (NULL);
+ }
continue;
}
- if (fn_printn(cp, i, snapend))
- break;
- cp += i;
+ if ((i & INDIR_MASK) == EDNS0_MASK) {
+ elt = (i & ~INDIR_MASK);
+ switch(elt) {
+ case EDNS0_ELT_BITLABEL:
+ blabel_print(cp);
+ break;
+ default:
+ /* unknown ELT */
+ printf("<ELT %d>", elt);
+ return(NULL);
+ }
+ } else {
+ if (fn_printn(cp, l, snapend))
+ break;
+ }
+
+ cp += l;
+ chars_processed += l;
putchar('.');
+ if (cp >= snapend || (l = labellen(cp)) < 0)
+ return(NULL);
i = *cp++;
+ chars_processed++;
if (!compress)
- rp += i + 1;
+ rp += l + 1;
}
else
putchar('.');
@@ -210,6 +319,8 @@ ns_cprint(register const u_char *cp, register const u_char *bp)
{
register u_int i;
+ if (cp >= snapend)
+ return NULL;
i = *cp++;
(void)fn_printn(cp, i, snapend);
return (cp + i);
@@ -252,17 +363,10 @@ static struct tok type2str[] = {
{ T_ATMA, "ATMA " },
{ T_NAPTR, "NAPTR " },
{ T_A6, "A6 " },
-#ifndef T_UINFO
-#define T_UINFO 100
-#endif
+ { T_DNAME, "DNAME " },
+ { T_OPT, "OPT " },
{ T_UINFO, "UINFO" },
-#ifndef T_UID
-#define T_UID 101
-#endif
{ T_UID, "UID" },
-#ifndef T_GID
-#define T_GID 102
-#endif
{ T_GID, "GID" },
{ T_UNSPEC, "UNSPEC" },
{ T_UNSPECA, "UNSPECA" },
@@ -282,7 +386,7 @@ static struct tok class2str[] = {
};
/* print a query */
-static void
+static const u_char *
ns_qprint(register const u_char *cp, register const u_char *bp)
{
register const u_char *np = cp;
@@ -290,8 +394,8 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
cp = ns_nskip(cp, bp);
- if (cp + 4 > snapend)
- return;
+ if (cp + 4 > snapend || cp == NULL)
+ return(NULL);
/* print the qtype and qclass (if it's not IN) */
i = *cp++ << 8;
@@ -303,33 +407,35 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
printf(" %s", tok2str(class2str, "(Class %d)", i));
fputs("? ", stdout);
- ns_nprint(np, bp);
+ cp = ns_nprint(np, bp);
+ return(cp ? cp + 4 : NULL);
}
/* print a reply */
static const u_char *
ns_rprint(register const u_char *cp, register const u_char *bp)
{
- register u_int i;
+ register u_int class;
register u_short typ, len;
register const u_char *rp;
if (vflag) {
putchar(' ');
- cp = ns_nprint(cp, bp);
+ if ((cp = ns_nprint(cp, bp)) == NULL)
+ return NULL;
} else
cp = ns_nskip(cp, bp);
- if (cp + 10 > snapend)
+ if (cp + 10 > snapend || cp == NULL)
return (snapend);
/* print the type/qtype and class (if it's not IN) */
typ = *cp++ << 8;
typ |= *cp++;
- i = *cp++ << 8;
- i |= *cp++;
- if (i != C_IN)
- printf(" %s", tok2str(class2str, "(Class %d)", i));
+ class = *cp++ << 8;
+ class |= *cp++;
+ if (class != C_IN && typ != T_OPT)
+ printf(" %s", tok2str(class2str, "(Class %d)", class));
/* ignore ttl */
cp += 4;
@@ -340,9 +446,13 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
rp = cp + len;
printf(" %s", tok2str(type2str, "Type%d", typ));
- switch (typ) {
+ if (rp > snapend)
+ return(NULL);
+ switch (typ) {
case T_A:
+ if (cp + sizeof(struct in_addr) > snapend)
+ return(NULL);
printf(" %s", ipaddr_string(cp));
break;
@@ -350,15 +460,41 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
case T_CNAME:
case T_PTR:
#ifdef T_DNAME
- case T_DNAME: /*XXX not checked as there's no server support yet*/
+ case T_DNAME:
#endif
putchar(' ');
- (void)ns_nprint(cp, bp);
+ if (ns_nprint(cp, bp) == NULL)
+ return(NULL);
break;
+ case T_SOA:
+ if (!vflag)
+ break;
+ putchar(' ');
+ if ((cp = ns_nprint(cp, bp)) == NULL)
+ return(NULL);
+ putchar(' ');
+ if ((cp = ns_nprint(cp, bp)) == NULL)
+ return(NULL);
+ if (cp + 5 * 4 > snapend)
+ return(NULL);
+ printf(" %u", EXTRACT_32BITS(cp));
+ cp += 4;
+ printf(" %u", EXTRACT_32BITS(cp));
+ cp += 4;
+ printf(" %u", EXTRACT_32BITS(cp));
+ cp += 4;
+ printf(" %u", EXTRACT_32BITS(cp));
+ cp += 4;
+ printf(" %u", EXTRACT_32BITS(cp));
+ cp += 4;
+ break;
case T_MX:
putchar(' ');
- (void)ns_nprint(cp + 2, bp);
+ if (cp + 2 > snapend)
+ return(NULL);
+ if (ns_nprint(cp + 2, bp) == NULL)
+ return(NULL);
printf(" %d", EXTRACT_16BITS(cp));
break;
@@ -369,25 +505,43 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
#ifdef INET6
case T_AAAA:
+ if (cp + sizeof(struct in6_addr) > snapend)
+ return(NULL);
printf(" %s", ip6addr_string(cp));
break;
- case T_A6: /*XXX not checked as there's no server support yet*/
+ case T_A6:
{
struct in6_addr a;
- int pbyte;
-
- pbyte = (*cp + 7) / 8;
- memset(&a, 0, sizeof(a));
- memcpy(&a, cp + 1, pbyte);
- printf(" %u %s ", *cp, ip6addr_string(&a));
- (void)ns_nprint(cp + 1 + pbyte, bp);
+ int pbit, pbyte;
+
+ pbit = *cp;
+ pbyte = (pbit & ~7) / 8;
+ if (pbit > 128) {
+ printf(" %u(bad plen)", pbit);
+ break;
+ } else if (pbit < 128) {
+ memset(&a, 0, sizeof(a));
+ memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
+ printf(" %u %s", pbit, ip6addr_string(&a));
+ }
+ if (pbit > 0) {
+ putchar(' ');
+ if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL)
+ return(NULL);
+ }
break;
}
#endif /*INET6*/
+ case T_OPT:
+ printf(" UDPsize=%u", class);
+ break;
+
case T_UNSPECA: /* One long string */
- printf(" %.*s", len, cp);
+ if (cp + len > snapend)
+ return(NULL);
+ fn_printn(cp, len, snapend);
break;
}
return (rp); /* XXX This isn't always right */
@@ -398,7 +552,7 @@ ns_print(register const u_char *bp, u_int length)
{
register const HEADER *np;
register int qdcount, ancount, nscount, arcount;
- register const u_char *cp;
+ register const u_char *cp = NULL;
np = (const HEADER *)bp;
/* get the byte-order right */
@@ -407,44 +561,76 @@ ns_print(register const u_char *bp, u_int length)
nscount = ntohs(np->nscount);
arcount = ntohs(np->arcount);
- if (np->qr) {
+ if (DNS_QR(np)) {
/* this is a response */
- printf(" %d%s%s%s%s%s",
+ printf(" %d%s%s%s%s%s%s",
ntohs(np->id),
- ns_ops[np->opcode],
- ns_resp[np->rcode],
- np->aa? "*" : "",
- np->ra? "" : "-",
- np->tc? "|" : "");
+ ns_ops[DNS_OPCODE(np)],
+ ns_resp[DNS_RCODE(np)],
+ DNS_AA(np)? "*" : "",
+ DNS_RA(np)? "" : "-",
+ DNS_TC(np)? "|" : "",
+ DNS_CD(np)? "%" : "");
+
if (qdcount != 1)
printf(" [%dq]", qdcount);
/* Print QUESTION section on -vv */
if (vflag > 1) {
- fputs(" q: ", stdout);
- cp = ns_nprint((const u_char *)(np + 1), bp);
- } else
- cp = ns_nskip((const u_char *)(np + 1), bp);
+ fputs(" q:", stdout);
+ if ((cp = ns_qprint((const u_char *)(np + 1), bp))
+ == NULL)
+ goto trunc;
+ } else {
+ if ((cp = ns_nskip((const u_char *)(np + 1), bp))
+ == NULL)
+ goto trunc;
+ cp += 4;
+ }
printf(" %d/%d/%d", ancount, nscount, arcount);
if (ancount--) {
- cp = ns_rprint(cp + 4, bp);
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
while (ancount-- && cp < snapend) {
putchar(',');
- cp = ns_rprint(cp, bp);
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ }
+ }
+ /* Print NS and AR sections on -vv */
+ if (vflag > 1) {
+ if (nscount-- && cp < snapend) {
+ fputs(" ns:", stdout);
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ while (nscount-- && cp < snapend) {
+ putchar(',');
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ }
+ }
+ if (arcount-- && cp < snapend) {
+ fputs(" ar:", stdout);
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ while (arcount-- && cp < snapend) {
+ putchar(',');
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ }
}
}
}
else {
/* this is a request */
- printf(" %d%s%s",
- ntohs(np->id),
- ns_ops[np->opcode],
- np->rd? "+" : "");
+ printf(" %d%s%s%s", ntohs(np->id), ns_ops[DNS_OPCODE(np)],
+ DNS_RD(np) ? "+" : "",
+ DNS_AD(np) ? "$" : "");
/* any weirdness? */
- if (*(((u_short *)np)+1) & htons(0x6ff))
+ if (*(((u_short *)np)+1) & htons(0x6cf))
printf(" [b2&3=0x%x]", ntohs(*(((u_short *)np)+1)));
- if (np->opcode == IQUERY) {
+ if (DNS_OPCODE(np) == IQUERY) {
if (qdcount)
printf(" [%dq]", qdcount);
if (ancount != 1)
@@ -461,7 +647,60 @@ ns_print(register const u_char *bp, u_int length)
if (arcount)
printf(" [%dau]", arcount);
- ns_qprint((const u_char *)(np + 1), (const u_char *)np);
+ if (qdcount--) {
+ cp = ns_qprint((const u_char *)(np + 1),
+ (const u_char *)np);
+ if (!cp)
+ goto trunc;
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ while (qdcount-- && cp < snapend) {
+ cp = ns_qprint((const u_char *)cp,
+ (const u_char *)np);
+ if (!cp)
+ goto trunc;
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ }
+ }
+
+ /* Print remaining sections on -vv */
+ if (vflag > 1) {
+ if (ancount--) {
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ while (ancount-- && cp < snapend) {
+ putchar(',');
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ }
+ }
+ if (nscount-- && cp < snapend) {
+ fputs(" ns:", stdout);
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ while (nscount-- && cp < snapend) {
+ putchar(',');
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ }
+ }
+ if (arcount-- && cp < snapend) {
+ fputs(" ar:", stdout);
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ while (arcount-- && cp < snapend) {
+ putchar(',');
+ if ((cp = ns_rprint(cp, bp)) == NULL)
+ goto trunc;
+ }
+ }
+ }
}
printf(" (%d)", length);
+ return;
+
+ trunc:
+ printf("[|domain]");
+ return;
}
diff --git a/contrib/tcpdump/print-dvmrp.c b/contrib/tcpdump/print-dvmrp.c
index 6727c36..04abc2c 100644
--- a/contrib/tcpdump/print-dvmrp.c
+++ b/contrib/tcpdump/print-dvmrp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.17 1999/11/22 04:30:34 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.20 2000/09/29 04:58:36 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,12 +33,6 @@ static const char rcsid[] =
#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 <stdio.h>
#include <string.h>
diff --git a/contrib/tcpdump/print-egp.c b/contrib/tcpdump/print-egp.c
index af52023..5adb9ee 100644
--- a/contrib/tcpdump/print-egp.c
+++ b/contrib/tcpdump/print-egp.c
@@ -20,7 +20,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.24 1999/11/21 09:36:51 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.26 2000/09/29 04:58:36 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,8 +33,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include <netdb.h>
#include <stdio.h>
@@ -42,6 +40,8 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "ip.h"
+
struct egp_packet {
u_char egp_version;
#define EGP_VERSION 2
diff --git a/contrib/tcpdump/print-esp.c b/contrib/tcpdump/print-esp.c
index bc5b7b7..7ebad59 100644
--- a/contrib/tcpdump/print-esp.c
+++ b/contrib/tcpdump/print-esp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.5 1999/12/15 08:10:18 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.17 2000/12/12 09:58:41 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,20 +36,9 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/route.h>
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
-
-#ifdef CRYPTO
+
+#ifdef HAVE_LIBCRYPTO
#include <des.h>
#include <blowfish.h>
#ifdef HAVE_RC5_H
@@ -62,33 +51,12 @@ static const char rcsid[] =
#include <stdio.h>
+#include "ip.h"
+#include "esp.h"
#ifdef INET6
-#include <netinet/ip6.h>
+#include "ip6.h"
#endif
-/* there's no standard definition so we are on our own */
-struct esp {
- u_int32_t esp_spi; /* ESP */
- /*variable size, 32bit bound*/ /* Initialization Vector */
- /*variable size*/ /* Payload data */
- /*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
- /*8bit*/ /* next header */
- /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
-};
-
-struct newesp {
- u_int32_t esp_spi; /* ESP */
- u_int32_t esp_seq; /* Sequence number */
- /*variable size*/ /* (IV and) Payload data */
- /*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
- /*8bit*/ /* next header */
- /*variable size, 32bit bound*/ /* Authentication data */
-};
-
#include "interface.h"
#include "addrtoname.h"
@@ -112,14 +80,14 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
esp = (struct esp *)bp;
spi = (u_int32_t)ntohl(esp->esp_spi);
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
if ((u_char *)(esp + 1) >= ep - sizeof(struct esp)) {
fputs("[|ESP]", stdout);
goto fail;
}
- printf("ESP(spi=%u", spi);
+ printf("ESP(spi=0x%08x", spi);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(esp + 1)));
printf(")");
@@ -164,7 +132,7 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
ip = (struct ip *)bp2;
- switch (ip->ip_v) {
+ switch (IP_V(ip)) {
#ifdef INET6
case 6:
ip6 = (struct ip6_hdr *)bp2;
@@ -197,7 +165,7 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
switch (algo) {
case DESCBC:
-#ifdef CRYPTO
+#ifdef HAVE_LIBCRYPTO
{
u_char iv[8];
des_key_schedule schedule;
@@ -232,10 +200,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
-#endif /*CRYPTO*/
+#endif /*HAVE_LIBCRYPTO*/
case BLOWFISH:
-#ifdef CRYPTO
+#ifdef HAVE_LIBCRYPTO
{
BF_KEY schedule;
u_char *p;
@@ -250,10 +218,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
-#endif /*CRYPTO*/
+#endif /*HAVE_LIBCRYPTO*/
case RC5:
-#if defined(CRYPTO) && defined(HAVE_RC5_H)
+#if defined(HAVE_LIBCRYPTO) && defined(HAVE_RC5_H)
{
RC5_32_KEY schedule;
u_char *p;
@@ -269,10 +237,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
-#endif /*CRYPTO*/
+#endif /*HAVE_LIBCRYPTO*/
case CAST128:
-#if defined(CRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
+#if defined(HAVE_LIBCRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
{
CAST_KEY schedule;
u_char *p;
@@ -287,10 +255,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
-#endif /*CRYPTO*/
+#endif /*HAVE_LIBCRYPTO*/
case DES3CBC:
-#if defined(CRYPTO)
+#if defined(HAVE_LIBCRYPTO)
{
des_key_schedule s1, s2, s3;
u_char *p;
@@ -308,7 +276,7 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
-#endif /*CRYPTO*/
+#endif /*HAVE_LIBCRYPTO*/
case NONE:
default:
diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c
index e014086..d10a86e 100644
--- a/contrib/tcpdump/print-ether.c
+++ b/contrib/tcpdump/print-ether.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.48 1999/11/21 09:36:51 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.61 2000/12/22 22:45:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -31,32 +31,20 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.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 <stdio.h>
#include <pcap.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "ether.h"
+
const u_char *packetp;
const u_char *snapend;
@@ -79,8 +67,6 @@ ether_print(register const u_char *bp, u_int length)
length);
}
-static u_short extracted_ethertype;
-
/*
* This is the top level routine of the printer. 'p' is the points
* to the ether header of the packet, 'h->tv' is the timestamp,
@@ -94,10 +80,11 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_int length = h->len;
struct ether_header *ep;
u_short ether_type;
+ u_short extracted_ethertype;
ts_print(&h->ts);
- if (caplen < sizeof(struct ether_header)) {
+ if (caplen < ETHER_HDRLEN) {
printf("[|ether]");
goto out;
}
@@ -113,10 +100,10 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
packetp = p;
snapend = p + caplen;
- length -= sizeof(struct ether_header);
- caplen -= sizeof(struct ether_header);
+ length -= ETHER_HDRLEN;
+ caplen -= ETHER_HDRLEN;
ep = (struct ether_header *)p;
- p += sizeof(struct ether_header);
+ p += ETHER_HDRLEN;
ether_type = ntohs(ep->ether_type);
@@ -126,10 +113,11 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
extracted_ethertype = 0;
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
+ if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
+ &extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- ether_print((u_char *)ep, length);
+ ether_print((u_char *)ep, length + ETHER_HDRLEN);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@@ -137,10 +125,11 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (!xflag && !qflag)
default_print(p, caplen);
}
- } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
+ } else if (ether_encap_print(ether_type, p, length, caplen,
+ &extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- ether_print((u_char *)ep, length + sizeof(*ep));
+ ether_print((u_char *)ep, length + ETHER_HDRLEN);
if (!xflag && !qflag)
default_print(p, caplen);
}
@@ -156,16 +145,18 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
*
* Returns non-zero if it can do so, zero if the ethertype is unknown.
*
- * Stuffs the ether type into a global for the benefit of lower layers
- * that might want to know what it is.
+ * The Ethernet type code is passed through a pointer; if it was
+ * ETHERTYPE_8021Q, it gets updated to be the Ethernet type of
+ * the 802.1Q payload, for the benefit of lower layers that might
+ * want to know what it is.
*/
int
ether_encap_print(u_short ethertype, const u_char *p,
- u_int length, u_int caplen)
+ u_int length, u_int caplen, u_short *extracted_ethertype)
{
recurse:
- extracted_ethertype = ethertype;
+ *extracted_ethertype = ethertype;
switch (ethertype) {
@@ -198,30 +189,35 @@ ether_encap_print(u_short ethertype, const u_char *p,
aarp_print(p, length);
return (1);
+ case ETHERTYPE_IPX:
+ ipx_print(p, length);
+ return (1);
+
case ETHERTYPE_8021Q:
- printf("802.1Q vlan#%d P%d%s",
- ntohs(*(unsigned short*)p)&0xFFF,
- ntohs(*(unsigned short*)p)>>13,
- (ntohs(*(unsigned short*)p)&0x1000) ? " CFI" : "");
- ethertype = ntohs(*(unsigned short*)(p+2));
+ printf("802.1Q vlan#%d P%d%s ",
+ ntohs(*(u_int16_t *)p) & 0xfff,
+ ntohs(*(u_int16_t *)p) >> 13,
+ (ntohs(*(u_int16_t *)p) & 0x1000) ? " CFI" : "");
+ ethertype = ntohs(*(u_int16_t *)(p + 2));
p += 4;
length -= 4;
caplen -= 4;
- if (ethertype > ETHERMTU)
+ if (ethertype > ETHERMTU)
goto recurse;
- extracted_ethertype = 0;
+ *extracted_ethertype = 0;
- if (llc_print(p, length, caplen, p-18, p-12) == 0) {
+ if (llc_print(p, length, caplen, p - 18, p - 12,
+ extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- ether_print(p-18, length+4);
- if (extracted_ethertype) {
+ ether_print(p - 18, length + 4);
+ if (*extracted_ethertype) {
printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ etherproto_string(htons(*extracted_ethertype)));
}
if (!xflag && !qflag)
- default_print(p-18, caplen+4);
+ default_print(p - 18, caplen + 4);
}
return (1);
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c
index 13bb888..d0286de 100644
--- a/contrib/tcpdump/print-fddi.c
+++ b/contrib/tcpdump/print-fddi.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.40 1999/12/14 16:49:02 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.50 2000/12/23 20:48:13 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,16 +34,7 @@ static const char rcsid[] =
#include <sys/file.h>
#include <sys/ioctl.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include <ctype.h>
#include <netdb.h>
@@ -55,6 +46,7 @@ struct rtentry;
#include "addrtoname.h"
#include "ethertype.h"
+#include "ether.h"
#include "fddi.h"
/*
@@ -96,8 +88,6 @@ int fddi_bitswap = 1;
* - vj
*/
-#define FDDI_HDRLEN (sizeof(struct fddi_header))
-
static u_char fddi_bit_swap[] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
@@ -289,10 +279,10 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
*/
snapend = p + caplen;
/*
- * Actually, the only printer that uses packetp is print-bootp.c,
- * and it assumes that packetp points to an Ethernet header. The
- * right thing to do is to fix print-bootp.c to know which link
- * type is in use when it excavates. XXX
+ * Actually, the only printers that use packetp are print-arp.c
+ * and print-bootp.c, and they assume that packetp points to an
+ * Ethernet header. The right thing to do is to fix them to know
+ * which link type is in use when they excavate. XXX
*/
packetp = (u_char *)&ehdr;
@@ -308,14 +298,14 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
extracted_ethertype = 0;
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr))
- == 0) {
+ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+ &extracted_ethertype) == 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!eflag)
- fddi_print(fddip, length,
+ fddi_print(fddip, length + FDDI_HDRLEN,
ESRC(&ehdr), EDST(&ehdr));
if (extracted_ethertype) {
printf("(LLC %s) ",
@@ -329,7 +319,8 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
else {
/* Some kinds of FDDI packet we cannot handle intelligently */
if (!eflag)
- fddi_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
+ fddi_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
+ EDST(&ehdr));
if (!xflag && !qflag)
default_print(p, caplen);
}
diff --git a/contrib/tcpdump/print-frag6.c b/contrib/tcpdump/print-frag6.c
index a043e8f..abf0cc6 100644
--- a/contrib/tcpdump/print-frag6.c
+++ b/contrib/tcpdump/print-frag6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.3.2.1 2000/01/11 06:58:24 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.12 2000/10/07 05:53:10 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,21 +35,12 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <stdio.h>
-#include <netinet/ip6.h>
+#include "ip6.h"
#include "interface.h"
#include "addrtoname.h"
@@ -68,7 +59,7 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
dp = (struct ip6_frag *)bp;
ip6 = (struct ip6_hdr *)bp2;
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
TCHECK(dp->ip6f_offlg);
@@ -86,7 +77,7 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
(long)(bp - bp2) - sizeof(struct ip6_frag));
}
-#if 0
+#if 1
/* it is meaningless to decode non-first fragment */
if (ntohs(dp->ip6f_offlg & IP6F_OFF_MASK) != 0)
return 65535;
diff --git a/contrib/tcpdump/print-gre.c b/contrib/tcpdump/print-gre.c
index 8584595..e79d300 100644
--- a/contrib/tcpdump/print-gre.c
+++ b/contrib/tcpdump/print-gre.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.6 1999/11/21 09:36:52 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.9 2000/12/18 05:41:59 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -37,8 +37,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include <netdb.h>
#include <stdio.h>
@@ -88,7 +86,7 @@ gre_print(const u_char *bp, u_int length)
{
const u_char *cp = bp + 4;
const struct gre *gre;
- u_short flags, proto;
+ u_short flags, proto, extracted_ethertype;
gre = (const struct gre *)bp;
@@ -125,7 +123,8 @@ gre_print(const u_char *bp, u_int length)
cp += 4;
length -= cp - bp;
- if (ether_encap_print(proto, cp, length, length) == 0)
+ if (ether_encap_print(proto, cp, length, length,
+ &extracted_ethertype) == 0)
printf("gre-proto-0x%04X", proto);
return;
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index 88416b6..59f6465 100644
--- a/contrib/tcpdump/print-icmp.c
+++ b/contrib/tcpdump/print-icmp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.43 1999/11/22 04:28:21 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.57 2000/10/10 05:03:32 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,29 +32,139 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <stdio.h>
#include <string.h>
+#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
+#include "ip.h"
+#include "udp.h"
+
+/*
+ * Interface Control Message Protocol Definitions.
+ * Per RFC 792, September 1981.
+ */
+
+/*
+ * Structure of an icmp header.
+ */
+struct icmp {
+ u_int8_t icmp_type; /* type of message, see below */
+ u_int8_t icmp_code; /* type sub code */
+ u_int16_t icmp_cksum; /* ones complement cksum of struct */
+ union {
+ u_int8_t ih_pptr; /* ICMP_PARAMPROB */
+ struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
+ struct ih_idseq {
+ u_int16_t icd_id;
+ u_int16_t icd_seq;
+ } ih_idseq;
+ u_int32_t ih_void;
+
+ /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
+ struct ih_pmtu {
+ u_int16_t ipm_void;
+ u_int16_t ipm_nextmtu;
+ } ih_pmtu;
+ } icmp_hun;
+#define icmp_pptr icmp_hun.ih_pptr
+#define icmp_gwaddr icmp_hun.ih_gwaddr
+#define icmp_id icmp_hun.ih_idseq.icd_id
+#define icmp_seq icmp_hun.ih_idseq.icd_seq
+#define icmp_void icmp_hun.ih_void
+#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
+#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
+ union {
+ struct id_ts {
+ u_int32_t its_otime;
+ u_int32_t its_rtime;
+ u_int32_t its_ttime;
+ } id_ts;
+ struct id_ip {
+ struct ip idi_ip;
+ /* options and then 64 bits of data */
+ } id_ip;
+ u_int32_t id_mask;
+ u_int8_t id_data[1];
+ } icmp_dun;
+#define icmp_otime icmp_dun.id_ts.its_otime
+#define icmp_rtime icmp_dun.id_ts.its_rtime
+#define icmp_ttime icmp_dun.id_ts.its_ttime
+#define icmp_ip icmp_dun.id_ip.idi_ip
+#define icmp_mask icmp_dun.id_mask
+#define icmp_data icmp_dun.id_data
+};
+
+/*
+ * Lower bounds on packet lengths for various types.
+ * For the error advice packets must first insure that the
+ * packet is large enought to contain the returned ip header.
+ * Only then can we do the check to see if 64 bits of packet
+ * data have been returned, since we need to check the returned
+ * ip header length.
+ */
+#define ICMP_MINLEN 8 /* abs minimum */
+#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
+#define ICMP_MASKLEN 12 /* address mask */
+#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
+#define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
+ /* N.B.: must separately check that ip_hl >= 5 */
+
+/*
+ * Definition of type and code field values.
+ */
+#define ICMP_ECHOREPLY 0 /* echo reply */
+#define ICMP_UNREACH 3 /* dest unreachable, codes: */
+#define ICMP_UNREACH_NET 0 /* bad net */
+#define ICMP_UNREACH_HOST 1 /* bad host */
+#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
+#define ICMP_UNREACH_PORT 3 /* bad port */
+#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
+#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
+#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
+#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
+#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
+#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
+#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
+#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
+#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
+#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
+#define ICMP_REDIRECT 5 /* shorter route, codes: */
+#define ICMP_REDIRECT_NET 0 /* for network */
+#define ICMP_REDIRECT_HOST 1 /* for host */
+#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
+#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
+#define ICMP_ECHO 8 /* echo service */
+#define ICMP_ROUTERADVERT 9 /* router advertisement */
+#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
+#define ICMP_TIMXCEED 11 /* time exceeded, code: */
+#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
+#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
+#define ICMP_PARAMPROB 12 /* ip header bad */
+#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
+#define ICMP_TSTAMP 13 /* timestamp request */
+#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
+#define ICMP_IREQ 15 /* information request */
+#define ICMP_IREQREPLY 16 /* information reply */
+#define ICMP_MASKREQ 17 /* address mask request */
+#define ICMP_MASKREPLY 18 /* address mask reply */
+
+#define ICMP_MAXTYPE 18
+
+#define ICMP_INFOTYPE(type) \
+ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
+ (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
+ (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
+ (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
+ (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
/* rfc1700 */
#ifndef ICMP_UNREACH_NET_UNKNOWN
#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
@@ -89,14 +199,6 @@ struct rtentry;
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
#endif
-/* rfc1256 */
-#ifndef ICMP_ROUTERADVERT
-#define ICMP_ROUTERADVERT 9 /* router advertisement */
-#endif
-#ifndef ICMP_ROUTERSOLICIT
-#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
-#endif
-
/* Most of the icmp types */
static struct tok icmp2str[] = {
{ ICMP_ECHOREPLY, "echo reply" },
@@ -149,15 +251,15 @@ static struct tok type2str[] = {
/* rfc1191 */
struct mtu_discovery {
- short unused;
- short nexthopmtu;
+ u_int16_t unused;
+ u_int16_t nexthopmtu;
};
/* rfc1256 */
struct ih_rdiscovery {
- u_char ird_addrnum;
- u_char ird_addrsiz;
- u_short ird_lifetime;
+ u_int8_t ird_addrnum;
+ u_int8_t ird_addrsiz;
+ u_int16_t ird_lifetime;
};
struct id_rdiscovery {
@@ -175,7 +277,7 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
register const struct ip *oip;
register const struct udphdr *ouh;
register u_int hlen, dport, mtu;
- char buf[256];
+ char buf[MAXHOSTNAMELEN + 100];
dp = (struct icmp *)bp;
ip = (struct ip *)bp2;
@@ -196,35 +298,36 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
case ICMP_UNREACH_PROTOCOL:
TCHECK(dp->icmp_ip.ip_p);
- (void)sprintf(buf, "%s protocol %d unreachable",
- ipaddr_string(&dp->icmp_ip.ip_dst),
- dp->icmp_ip.ip_p);
+ (void)snprintf(buf, sizeof(buf),
+ "%s protocol %d unreachable",
+ ipaddr_string(&dp->icmp_ip.ip_dst),
+ dp->icmp_ip.ip_p);
break;
case ICMP_UNREACH_PORT:
TCHECK(dp->icmp_ip.ip_p);
oip = &dp->icmp_ip;
- hlen = oip->ip_hl * 4;
+ hlen = IP_HL(oip) * 4;
ouh = (struct udphdr *)(((u_char *)oip) + hlen);
dport = ntohs(ouh->uh_dport);
switch (oip->ip_p) {
case IPPROTO_TCP:
- (void)sprintf(buf,
+ (void)snprintf(buf, sizeof(buf),
"%s tcp port %s unreachable",
ipaddr_string(&oip->ip_dst),
tcpport_string(dport));
break;
case IPPROTO_UDP:
- (void)sprintf(buf,
+ (void)snprintf(buf, sizeof(buf),
"%s udp port %s unreachable",
ipaddr_string(&oip->ip_dst),
udpport_string(dport));
break;
default:
- (void)sprintf(buf,
+ (void)snprintf(buf, sizeof(buf),
"%s protocol %d port %d unreachable",
ipaddr_string(&oip->ip_dst),
oip->ip_p, dport);
@@ -233,26 +336,26 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
break;
case ICMP_UNREACH_NEEDFRAG:
- {
+ {
register const struct mtu_discovery *mp;
-
mp = (struct mtu_discovery *)&dp->icmp_void;
mtu = EXTRACT_16BITS(&mp->nexthopmtu);
- if (mtu)
- (void)sprintf(buf,
- "%s unreachable - need to frag (mtu %d)",
- ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
- else
- (void)sprintf(buf,
- "%s unreachable - need to frag",
- ipaddr_string(&dp->icmp_ip.ip_dst));
+ if (mtu) {
+ (void)snprintf(buf, sizeof(buf),
+ "%s unreachable - need to frag (mtu %d)",
+ ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
+ } else {
+ (void)snprintf(buf, sizeof(buf),
+ "%s unreachable - need to frag",
+ ipaddr_string(&dp->icmp_ip.ip_dst));
}
+ }
break;
default:
fmt = tok2str(unreach2str, "#%d %%s unreachable",
dp->icmp_code);
- (void)sprintf(buf, fmt,
+ (void)snprintf(buf, sizeof(buf), fmt,
ipaddr_string(&dp->icmp_ip.ip_dst));
break;
}
@@ -262,55 +365,60 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
TCHECK(dp->icmp_ip.ip_dst);
fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
dp->icmp_code);
- (void)sprintf(buf, fmt,
+ (void)snprintf(buf, sizeof(buf), fmt,
ipaddr_string(&dp->icmp_ip.ip_dst),
ipaddr_string(&dp->icmp_gwaddr));
break;
case ICMP_ROUTERADVERT:
- {
+ {
register const struct ih_rdiscovery *ihp;
register const struct id_rdiscovery *idp;
u_int lifetime, num, size;
- (void)strcpy(buf, "router advertisement");
+ (void)snprintf(buf, sizeof(buf), "router advertisement");
cp = buf + strlen(buf);
ihp = (struct ih_rdiscovery *)&dp->icmp_void;
TCHECK(*ihp);
- (void)strcpy(cp, " lifetime ");
+ (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
cp = buf + strlen(buf);
lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
- if (lifetime < 60)
- (void)sprintf(cp, "%u", lifetime);
- else if (lifetime < 60 * 60)
- (void)sprintf(cp, "%u:%02u",
+ if (lifetime < 60) {
+ (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u",
+ lifetime);
+ } else if (lifetime < 60 * 60) {
+ (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
lifetime / 60, lifetime % 60);
- else
- (void)sprintf(cp, "%u:%02u:%02u",
+ } else {
+ (void)snprintf(cp, sizeof(buf) - (cp - buf),
+ "%u:%02u:%02u",
lifetime / 3600,
(lifetime % 3600) / 60,
lifetime % 60);
+ }
cp = buf + strlen(buf);
num = ihp->ird_addrnum;
- (void)sprintf(cp, " %d:", num);
+ (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num);
cp = buf + strlen(buf);
size = ihp->ird_addrsiz;
if (size != 2) {
- (void)sprintf(cp, " [size %d]", size);
+ (void)snprintf(cp, sizeof(buf) - (cp - buf),
+ " [size %d]", size);
break;
}
idp = (struct id_rdiscovery *)&dp->icmp_data;
while (num-- > 0) {
TCHECK(*idp);
- (void)sprintf(cp, " {%s %u}",
+ (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
ipaddr_string(&idp->ird_addr),
EXTRACT_32BITS(&idp->ird_pref));
cp = buf + strlen(buf);
+ ++idp;
}
- }
+ }
break;
case ICMP_TIMXCEED:
@@ -326,26 +434,46 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
break;
default:
- (void)sprintf(buf, "time exceeded-#%d", dp->icmp_code);
+ (void)snprintf(buf, sizeof(buf), "time exceeded-#%d",
+ dp->icmp_code);
break;
}
break;
case ICMP_PARAMPROB:
if (dp->icmp_code)
- (void)sprintf(buf, "parameter problem - code %d",
- dp->icmp_code);
+ (void)snprintf(buf, sizeof(buf),
+ "parameter problem - code %d", dp->icmp_code);
else {
TCHECK(dp->icmp_pptr);
- (void)sprintf(buf, "parameter problem - octet %d",
- dp->icmp_pptr);
+ (void)snprintf(buf, sizeof(buf),
+ "parameter problem - octet %d", dp->icmp_pptr);
}
break;
case ICMP_MASKREPLY:
TCHECK(dp->icmp_mask);
- (void)sprintf(buf, "address mask is 0x%08x",
- (u_int32_t)ntohl(dp->icmp_mask));
+ (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
+ (unsigned)ntohl(dp->icmp_mask));
+ break;
+
+ case ICMP_TSTAMP:
+ TCHECK(dp->icmp_seq);
+ (void)snprintf(buf, sizeof(buf),
+ "time stamp query id %u seq %u",
+ (unsigned)ntohs(dp->icmp_id),
+ (unsigned)ntohs(dp->icmp_seq));
+ break;
+
+ case ICMP_TSTAMPREPLY:
+ TCHECK(dp->icmp_ttime);
+ (void)snprintf(buf, sizeof(buf),
+ "time stamp reply id %u seq %u : org 0x%lx recv 0x%lx xmit 0x%lx",
+ (unsigned)ntohs(dp->icmp_id),
+ (unsigned)ntohs(dp->icmp_seq),
+ (unsigned long)ntohl(dp->icmp_otime),
+ (unsigned long)ntohl(dp->icmp_rtime),
+ (unsigned long)ntohl(dp->icmp_ttime));
break;
default:
diff --git a/contrib/tcpdump/print-icmp6.c b/contrib/tcpdump/print-icmp6.c
index f6bc864..a983bbb 100644
--- a/contrib/tcpdump/print-icmp6.c
+++ b/contrib/tcpdump/print-icmp6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.2.2.1 2000/01/11 06:58:24 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.42 2000/12/13 07:57:05 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -37,43 +37,46 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <stdio.h>
+#include <netdb.h>
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
+#include "ip6.h"
+#include "icmp6.h"
#include "interface.h"
#include "addrtoname.h"
+#include "udp.h"
+#include "ah.h"
+
void icmp6_opt_print(const u_char *, int);
void mld6_print(const u_char *);
+static struct udphdr *get_upperlayer(u_char *, int *);
+static void dnsname_print(const u_char *, const u_char *);
+void icmp6_nodeinfo_print(int, const u_char *, const u_char *);
+void icmp6_rrenum_print(int, const u_char *, const u_char *);
+
+#ifndef abs
+#define abs(a) ((0 < (a)) ? (a) : -(a))
+#endif
void
icmp6_print(register const u_char *bp, register const u_char *bp2)
{
- register const struct icmp6_hdr *dp;
+ const struct icmp6_hdr *dp;
register const struct ip6_hdr *ip;
register const char *str;
register const struct ip6_hdr *oip;
register const struct udphdr *ouh;
- register int hlen, dport;
+ register int dport;
register const u_char *ep;
char buf[256];
- int icmp6len;
+ int icmp6len, prot;
#if 0
#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
@@ -83,7 +86,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
ip = (struct ip6_hdr *)bp2;
oip = (struct ip6_hdr *)(dp + 1);
str = buf;
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
if (ip->ip6_plen)
icmp6len = (ntohs(ip->ip6_plen) + sizeof(struct ip6_hdr) -
@@ -92,13 +95,13 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
icmp6len = snapend - bp;
#if 0
- (void)printf("%s > %s: ",
+ (void)printf("%s > %s: ",
ip6addr_string(&ip->ip6_src),
ip6addr_string(&ip->ip6_dst));
#endif
TCHECK(dp->icmp6_code);
- switch(dp->icmp6_type) {
+ switch (dp->icmp6_type) {
case ICMP6_DST_UNREACH:
TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
@@ -110,11 +113,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf("icmp6: %s unreachable prohibited",
ip6addr_string(&oip->ip6_dst));
break;
-#ifdef ICMP6_DST_UNREACH_BEYONDSCOPE
case ICMP6_DST_UNREACH_BEYONDSCOPE:
-#else
- case ICMP6_DST_UNREACH_NOTNEIGHBOR:
-#endif
printf("icmp6: %s beyond scope of source address %s",
ip6addr_string(&oip->ip6_dst),
ip6addr_string(&oip->ip6_src));
@@ -124,11 +123,12 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
ip6addr_string(&oip->ip6_dst));
break;
case ICMP6_DST_UNREACH_NOPORT:
- TCHECK(oip->ip6_nxt);
- hlen = sizeof(struct ip6_hdr);
- ouh = (struct udphdr *)(((u_char *)oip) + hlen);
+ if ((ouh = get_upperlayer((u_char *)oip, &prot))
+ == NULL)
+ goto trunc;
+
dport = ntohs(ouh->uh_dport);
- switch (oip->ip6_nxt) {
+ switch (prot) {
case IPPROTO_TCP:
printf("icmp6: %s tcp port %s unreachable",
ip6addr_string(&oip->ip6_dst),
@@ -216,7 +216,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf("icmp6: router solicitation ");
if (vflag) {
#define RTSOLLEN 8
- icmp6_opt_print((const u_char *)dp + RTSOLLEN,
+ icmp6_opt_print((const u_char *)dp + RTSOLLEN,
icmp6len - RTSOLLEN);
}
break;
@@ -232,6 +232,11 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf("M");
if (p->nd_ra_flags_reserved & ND_RA_FLAG_OTHER)
printf("O");
+#ifndef ND_RA_FLAG_HA
+#define ND_RA_FLAG_HA 0x20
+#endif
+ if (p->nd_ra_flags_reserved & ND_RA_FLAG_HA)
+ printf("H");
if (p->nd_ra_flags_reserved != 0)
printf(" ");
printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime));
@@ -240,7 +245,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf("retrans_time=%u)",
(u_int32_t)ntohl(p->nd_ra_retransmit));
#define RTADVLEN 16
- icmp6_opt_print((const u_char *)dp + RTADVLEN,
+ icmp6_opt_print((const u_char *)dp + RTADVLEN,
icmp6len - RTADVLEN);
}
break;
@@ -253,7 +258,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
ip6addr_string(&p->nd_ns_target));
if (vflag) {
#define NDSOLLEN 24
- icmp6_opt_print((const u_char *)dp + NDSOLLEN,
+ icmp6_opt_print((const u_char *)dp + NDSOLLEN,
icmp6len - NDSOLLEN);
}
}
@@ -266,7 +271,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
TCHECK(p->nd_na_target);
printf("icmp6: neighbor adv: tgt is %s",
ip6addr_string(&p->nd_na_target));
- if (vflag) {
+ if (vflag) {
#define ND_NA_FLAG_ALL \
(ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
/* we don't need ntohl() here. see advanced-api-04. */
@@ -285,124 +290,34 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf(")");
}
#define NDADVLEN 24
- icmp6_opt_print((const u_char *)dp + NDADVLEN,
+ icmp6_opt_print((const u_char *)dp + NDADVLEN,
icmp6len - NDADVLEN);
+#undef NDADVLEN
}
}
break;
case ND_REDIRECT:
- {
#define RDR(i) ((struct nd_redirect *)(i))
- char tgtbuf[INET6_ADDRSTRLEN], dstbuf[INET6_ADDRSTRLEN];
-
TCHECK(RDR(dp)->nd_rd_dst);
- inet_ntop(AF_INET6, &RDR(dp)->nd_rd_target,
- tgtbuf, INET6_ADDRSTRLEN);
- inet_ntop(AF_INET6, &RDR(dp)->nd_rd_dst,
- dstbuf, INET6_ADDRSTRLEN);
- printf("icmp6: redirect %s to %s", dstbuf, tgtbuf);
+ printf("icmp6: redirect %s",
+ getname6((const u_char *)&RDR(dp)->nd_rd_dst));
+ printf(" to %s",
+ getname6((const u_char*)&RDR(dp)->nd_rd_target));
#define REDIRECTLEN 40
if (vflag) {
icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
icmp6len - REDIRECTLEN);
}
break;
- }
+#undef REDIRECTLEN
+#undef RDR
case ICMP6_ROUTER_RENUMBERING:
- switch (dp->icmp6_code) {
- case ICMP6_ROUTER_RENUMBERING_COMMAND:
- printf("icmp6: router renum command");
- break;
- case ICMP6_ROUTER_RENUMBERING_RESULT:
- printf("icmp6: router renum result");
- break;
- default:
- printf("icmp6: router renum code-#%d", dp->icmp6_code);
- break;
- }
+ icmp6_rrenum_print(icmp6len, bp, ep);
break;
-#ifdef ICMP6_WRUREQUEST
- case ICMP6_WRUREQUEST: /*ICMP6_FQDN_QUERY*/
- {
- int siz;
- siz = ep - (u_char *)(dp + 1);
- if (siz == 4)
- printf("icmp6: who-are-you request");
- else {
- printf("icmp6: FQDN request");
- if (vflag) {
- if (siz < 8)
- printf("?(icmp6_data %d bytes)", siz);
- else if (8 < siz)
- printf("?(extra %d bytes)", siz - 8);
- }
- }
+ case ICMP6_NI_QUERY:
+ case ICMP6_NI_REPLY:
+ icmp6_nodeinfo_print(icmp6len, bp, ep);
break;
- }
-#endif /*ICMP6_WRUREQUEST*/
-#ifdef ICMP6_WRUREPLY
- case ICMP6_WRUREPLY: /*ICMP6_FQDN_REPLY*/
- {
- enum { UNKNOWN, WRU, FQDN } mode = UNKNOWN;
- u_char const *buf;
- u_char const *cp = NULL;
-
- buf = (u_char *)(dp + 1);
-
- /* fair guess */
- if (buf[12] == ep - buf - 13)
- mode = FQDN;
- else if (dp->icmp6_code == 1)
- mode = FQDN;
-
- /* wild guess */
- if (mode == UNKNOWN) {
- cp = buf + 4;
- while (cp < ep) {
- if (!isprint(*cp++))
- mode = FQDN;
- }
- }
-#ifndef abs
-#define abs(a) ((0 < (a)) ? (a) : -(a))
-#endif
- if (mode == UNKNOWN && 2 < abs(buf[12] - (ep - buf - 13)))
- mode = WRU;
- if (mode == UNKNOWN)
- mode = FQDN;
-
- if (mode == WRU) {
- cp = buf + 4;
- printf("icmp6: who-are-you reply(\"");
- } else if (mode == FQDN) {
- cp = buf + 13;
- printf("icmp6: FQDN reply(\"");
- }
- for (; cp < ep; cp++)
- printf((isprint(*cp) ? "%c" : "\\%03o"), *cp);
- printf("\"");
- if (vflag) {
- printf(",%s", mode == FQDN ? "FQDN" : "WRU");
- if (mode == FQDN) {
- long ttl;
- ttl = (long)ntohl(*(u_long *)&buf[8]);
- if (dp->icmp6_code == 1)
- printf(",TTL=unknown");
- else if (ttl < 0)
- printf(",TTL=%ld:invalid", ttl);
- else
- printf(",TTL=%ld", ttl);
- if (buf[12] != ep - buf - 13) {
- (void)printf(",invalid namelen:%d/%u",
- buf[12],
- (unsigned int)(ep - buf - 13));
- }
- }
- }
- printf(")");
- break;
- }
-#endif /*ICMP6_WRUREPLY*/
default:
printf("icmp6: type-#%d", dp->icmp6_type);
break;
@@ -415,6 +330,79 @@ trunc:
#endif
}
+static struct udphdr *
+get_upperlayer(register u_char *bp, int *prot)
+{
+ register const u_char *ep;
+ struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
+ struct udphdr *uh;
+ struct ip6_hbh *hbh;
+ struct ip6_frag *fragh;
+ struct ah *ah;
+ int nh, hlen;
+
+ /* 'ep' points to the end of available data. */
+ ep = snapend;
+
+ if (TTEST(ip6->ip6_nxt) == 0)
+ return NULL;
+
+ nh = ip6->ip6_nxt;
+ hlen = sizeof(struct ip6_hdr);
+
+ while (bp < snapend) {
+ bp += hlen;
+
+ switch(nh) {
+ case IPPROTO_UDP:
+ case IPPROTO_TCP:
+ uh = (struct udphdr *)bp;
+ if (TTEST(uh->uh_dport)) {
+ *prot = nh;
+ return(uh);
+ }
+ else
+ return(NULL);
+ /* NOTREACHED */
+
+ case IPPROTO_HOPOPTS:
+ case IPPROTO_DSTOPTS:
+ case IPPROTO_ROUTING:
+ hbh = (struct ip6_hbh *)bp;
+ if (TTEST(hbh->ip6h_len) == 0)
+ return(NULL);
+ nh = hbh->ip6h_nxt;
+ hlen = (hbh->ip6h_len + 1) << 3;
+ break;
+
+ case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */
+ fragh = (struct ip6_frag *)bp;
+ if (TTEST(fragh->ip6f_offlg) == 0)
+ return(NULL);
+ /* fragments with non-zero offset are meaningless */
+ if ((fragh->ip6f_offlg & IP6F_OFF_MASK) != 0)
+ return(NULL);
+ nh = fragh->ip6f_nxt;
+ hlen = sizeof(struct ip6_frag);
+ break;
+
+ case IPPROTO_AH:
+ ah = (struct ah *)bp;
+ if (TTEST(ah->ah_len) == 0)
+ return(NULL);
+ nh = ah->ah_nxt;
+ hlen = (ah->ah_len + 2) << 2;
+ break;
+
+ default: /* unknown or undecodable header */
+ *prot = nh; /* meaningless, but set here anyway */
+ return(NULL);
+ }
+ }
+
+ return(NULL); /* should be notreached, though */
+}
+
void
icmp6_opt_print(register const u_char *bp, int resid)
{
@@ -423,6 +411,7 @@ icmp6_opt_print(register const u_char *bp, int resid)
register const struct nd_opt_prefix_info *opp;
register const struct icmp6_opts_redirect *opr;
register const struct nd_opt_mtu *opm;
+ register const struct nd_opt_advint *opa;
register const u_char *ep;
int opts_len;
#if 0
@@ -434,9 +423,6 @@ icmp6_opt_print(register const u_char *bp, int resid)
char buf[256];
#endif
-#if 0
-#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
-#endif
#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
op = (struct nd_opt_hdr *)bp;
@@ -445,13 +431,13 @@ icmp6_opt_print(register const u_char *bp, int resid)
oip = &dp->icmp6_ip6;
str = buf;
#endif
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
ECHECK(op->nd_opt_len);
if (resid <= 0)
return;
- switch(op->nd_opt_type) {
+ switch (op->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
opl = (struct nd_opt_hdr *)op;
#if 1
@@ -460,10 +446,11 @@ icmp6_opt_print(register const u_char *bp, int resid)
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
- printf("(src lladdr: %s",
+ printf("(src lladdr: %s", /*)*/
etheraddr_string((u_char *)(opl + 1)));
if (opl->nd_opt_len != 1)
printf("!");
+ /*(*/
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
@@ -476,10 +463,11 @@ icmp6_opt_print(register const u_char *bp, int resid)
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
- printf("(tgt lladdr: %s",
+ printf("(tgt lladdr: %s", /*)*/
etheraddr_string((u_char *)(opl + 1)));
if (opl->nd_opt_len != 1)
printf("!");
+ /*(*/
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
@@ -487,11 +475,13 @@ icmp6_opt_print(register const u_char *bp, int resid)
case ND_OPT_PREFIX_INFORMATION:
opp = (struct nd_opt_prefix_info *)op;
TCHECK(opp->nd_opt_pi_prefix);
- printf("(prefix info: ");
+ printf("(prefix info: "); /*)*/
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
- printf("L");
+ printf("L");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
- printf("A");
+ printf("A");
+ if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ROUTER)
+ printf("R");
if (opp->nd_opt_pi_flags_reserved)
printf(" ");
printf("valid_ltime=");
@@ -512,6 +502,7 @@ icmp6_opt_print(register const u_char *bp, int resid)
opp->nd_opt_pi_prefix_len);
if (opp->nd_opt_pi_len != 4)
printf("!");
+ /*(*/
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
@@ -526,7 +517,7 @@ icmp6_opt_print(register const u_char *bp, int resid)
case ND_OPT_MTU:
opm = (struct nd_opt_mtu *)op;
TCHECK(opm->nd_opt_mtu_mtu);
- printf("(mtu: ");
+ printf("(mtu: "); /*)*/
printf("mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
if (opm->nd_opt_mtu_len != 1)
printf("!");
@@ -534,6 +525,17 @@ icmp6_opt_print(register const u_char *bp, int resid)
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
+ case ND_OPT_ADVINT:
+ opa = (struct nd_opt_advint *)op;
+ TCHECK(opa->nd_opt_advint_advint);
+ printf("(advint: "); /*)*/
+ printf("advint=%u",
+ (u_int32_t)ntohl(opa->nd_opt_advint_advint));
+ /*(*/
+ printf(")");
+ icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
+ resid - (op->nd_opt_len << 3));
+ break;
default:
opts_len = op->nd_opt_len;
printf("(unknwon opt_type=%d, opt_len=%d)",
@@ -548,9 +550,6 @@ icmp6_opt_print(register const u_char *bp, int resid)
trunc:
fputs("[ndp opt]", stdout);
return;
-#if 0
-#undef TCHECK
-#endif
#undef ECHECK
}
@@ -560,7 +559,7 @@ mld6_print(register const u_char *bp)
register struct mld6_hdr *mp = (struct mld6_hdr *)bp;
register const u_char *ep;
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
if ((u_char *)mp + sizeof(*mp) > ep)
@@ -568,7 +567,427 @@ mld6_print(register const u_char *bp)
printf("max resp delay: %d ", ntohs(mp->mld6_maxdelay));
printf("addr: %s", ip6addr_string(&mp->mld6_addr));
+}
+
+static void
+dnsname_print(const u_char *cp, const u_char *ep)
+{
+ int i;
+
+ /* DNS name decoding - no decompression */
+ printf(", \"");
+ while (cp < ep) {
+ i = *cp++;
+ if (i) {
+ if (i > ep - cp) {
+ printf("???");
+ break;
+ }
+ while (i-- && cp < ep) {
+ safeputchar(*cp);
+ cp++;
+ }
+ if (cp + 1 < ep && *cp)
+ printf(".");
+ } else {
+ if (cp == ep) {
+ /* FQDN */
+ printf(".");
+ } else if (cp + 1 == ep && *cp == '\0') {
+ /* truncated */
+ } else {
+ /* invalid */
+ printf("???");
+ }
+ break;
+ }
+ }
+ printf("\"");
+}
+
+void
+icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
+{
+ struct icmp6_nodeinfo *ni6;
+ struct icmp6_hdr *dp;
+ const u_char *cp;
+ int siz, i;
+ int needcomma;
+
+ dp = (struct icmp6_hdr *)bp;
+ ni6 = (struct icmp6_nodeinfo *)bp;
+ siz = ep - bp;
+
+ switch (ni6->ni_type) {
+ case ICMP6_NI_QUERY:
+ if (siz == sizeof(*dp) + 4) {
+ /* KAME who-are-you */
+ printf("icmp6: who-are-you request");
+ break;
+ }
+ printf("icmp6: node information query");
+
+ TCHECK2(*dp, sizeof(*ni6));
+ ni6 = (struct icmp6_nodeinfo *)dp;
+ printf(" ("); /*)*/
+ switch (ntohs(ni6->ni_qtype)) {
+ case NI_QTYPE_NOOP:
+ printf("noop");
+ break;
+ case NI_QTYPE_SUPTYPES:
+ printf("supported qtypes");
+ i = ntohs(ni6->ni_flags);
+ if (i)
+ printf(" [%s]", (i & 0x01) ? "C" : "");
+ break;
+ break;
+ case NI_QTYPE_FQDN:
+ printf("DNS name");
+ break;
+ case NI_QTYPE_NODEADDR:
+ printf("node addresses");
+ i = ni6->ni_flags;
+ if (!i)
+ break;
+ /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
+ printf(" [%s%s%s%s%s%s]",
+ (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
+ (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
+ (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
+ (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
+ (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
+ (i & NI_NODEADDR_FLAG_ALL) ? "A" : "");
+ break;
+ default:
+ printf("unknown");
+ break;
+ }
+
+ if (ni6->ni_qtype == NI_QTYPE_NOOP ||
+ ni6->ni_qtype == NI_QTYPE_SUPTYPES) {
+ if (siz != sizeof(*ni6))
+ if (vflag)
+ printf(", invalid len");
+ /*(*/
+ printf(")");
+ break;
+ }
+
+
+ /* XXX backward compat, icmp-name-lookup-03 */
+ if (siz == sizeof(*ni6)) {
+ printf(", 03 draft");
+ /*(*/
+ printf(")");
+ break;
+ }
+
+ switch (ni6->ni_code) {
+ case ICMP6_NI_SUBJ_IPV6:
+ if (!TTEST2(*dp,
+ sizeof(*ni6) + sizeof(struct in6_addr)))
+ break;
+ if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) {
+ if (vflag)
+ printf(", invalid subject len");
+ break;
+ }
+ printf(", subject=%s",
+ getname6((const u_char *)(ni6 + 1)));
+ break;
+ case ICMP6_NI_SUBJ_FQDN:
+ printf(", subject=DNS name");
+ cp = (const u_char *)(ni6 + 1);
+ if (cp[0] == ep - cp - 1) {
+ /* icmp-name-lookup-03, pascal string */
+ if (vflag)
+ printf(", 03 draft");
+ cp++;
+ printf(", \"");
+ while (cp < ep) {
+ safeputchar(*cp);
+ cp++;
+ }
+ printf("\"");
+ } else
+ dnsname_print(cp, ep);
+ break;
+ case ICMP6_NI_SUBJ_IPV4:
+ if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
+ break;
+ if (siz != sizeof(*ni6) + sizeof(struct in_addr)) {
+ if (vflag)
+ printf(", invalid subject len");
+ break;
+ }
+ printf(", subject=%s",
+ getname((const u_char *)(ni6 + 1)));
+ break;
+ default:
+ printf(", unknown subject");
+ break;
+ }
+
+ /*(*/
+ printf(")");
+ break;
+
+ case ICMP6_NI_REPLY:
+ if (icmp6len > siz) {
+ printf("[|icmp6: node information reply]");
+ break;
+ }
+
+ needcomma = 0;
+
+ ni6 = (struct icmp6_nodeinfo *)dp;
+ printf("icmp6: node information reply");
+ printf(" ("); /*)*/
+ switch (ni6->ni_code) {
+ case ICMP6_NI_SUCCESS:
+ if (vflag) {
+ printf("success");
+ needcomma++;
+ }
+ break;
+ case ICMP6_NI_REFUSED:
+ printf("refused");
+ needcomma++;
+ if (siz != sizeof(*ni6))
+ if (vflag)
+ printf(", invalid length");
+ break;
+ case ICMP6_NI_UNKNOWN:
+ printf("unknown");
+ needcomma++;
+ if (siz != sizeof(*ni6))
+ if (vflag)
+ printf(", invalid length");
+ break;
+ }
+
+ if (ni6->ni_code != ICMP6_NI_SUCCESS) {
+ /*(*/
+ printf(")");
+ break;
+ }
+
+ switch (ntohs(ni6->ni_qtype)) {
+ case NI_QTYPE_NOOP:
+ if (needcomma)
+ printf(", ");
+ printf("noop");
+ if (siz != sizeof(*ni6))
+ if (vflag)
+ printf(", invalid length");
+ break;
+ case NI_QTYPE_SUPTYPES:
+ if (needcomma)
+ printf(", ");
+ printf("supported qtypes");
+ i = ntohs(ni6->ni_flags);
+ if (i)
+ printf(" [%s]", (i & 0x01) ? "C" : "");
+ break;
+ case NI_QTYPE_FQDN:
+ if (needcomma)
+ printf(", ");
+ printf("DNS name");
+ cp = (const u_char *)(ni6 + 1) + 4;
+ if (cp[0] == ep - cp - 1) {
+ /* icmp-name-lookup-03, pascal string */
+ if (vflag)
+ printf(", 03 draft");
+ cp++;
+ printf(", \"");
+ while (cp < ep) {
+ safeputchar(*cp);
+ cp++;
+ }
+ printf("\"");
+ } else
+ dnsname_print(cp, ep);
+ if ((ntohs(ni6->ni_flags) & 0x01) != 0)
+ printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1));
+ break;
+ case NI_QTYPE_NODEADDR:
+ if (needcomma)
+ printf(", ");
+ printf("node addresses");
+ i = sizeof(*ni6);
+ while (i < siz) {
+ if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
+ break;
+ printf(" %s", getname6(bp + i));
+ i += sizeof(struct in6_addr);
+ printf("(%d)", ntohl(*(int32_t *)(bp + i)));
+ i += sizeof(int32_t);
+ }
+ i = ni6->ni_flags;
+ if (!i)
+ break;
+ printf(" [%s%s%s%s%s%s%s]",
+ (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
+ (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
+ (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
+ (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
+ (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
+ (i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
+ (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : "");
+ break;
+ default:
+ if (needcomma)
+ printf(", ");
+ printf("unknown");
+ break;
+ }
+
+ /*(*/
+ printf(")");
+ break;
+ }
+ return;
+
+trunc:
+ fputs("[|icmp6]", stdout);
+}
+
+void
+icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
+{
+ struct icmp6_router_renum *rr6;
+ struct icmp6_hdr *dp;
+ size_t siz;
+ const char *cp;
+ struct rr_pco_match *match;
+ struct rr_pco_use *use;
+ char hbuf[NI_MAXHOST];
+ int n;
+
+ dp = (struct icmp6_hdr *)bp;
+ rr6 = (struct icmp6_router_renum *)bp;
+ siz = ep - bp;
+ cp = (const char *)(rr6 + 1);
+
+ TCHECK(rr6->rr_reserved);
+ switch (rr6->rr_code) {
+ case ICMP6_ROUTER_RENUMBERING_COMMAND:
+ printf("router renum: command");
+ break;
+ case ICMP6_ROUTER_RENUMBERING_RESULT:
+ printf("router renum: result");
+ break;
+ case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
+ printf("router renum: sequence number reset");
+ break;
+ default:
+ printf("router renum: code-#%d", rr6->rr_code);
+ break;
+ }
+
+ printf(", seq=%u", (u_int32_t)ntohl(rr6->rr_seqnum));
+
+ if (vflag) {
+#define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
+ printf("["); /*]*/
+ if (rr6->rr_flags) {
+ printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
+ F(ICMP6_RR_FLAGS_REQRESULT, "R"),
+ F(ICMP6_RR_FLAGS_ALLIF, "A"),
+ F(ICMP6_RR_FLAGS_SPECSITE, "S"),
+ F(ICMP6_RR_FLAGS_PREVDONE, "P"));
+ }
+ printf("seg=%u,", rr6->rr_segnum);
+ printf("maxdelay=%u", rr6->rr_maxdelay);
+ if (rr6->rr_reserved)
+ printf("rsvd=0x%x", (u_int16_t)ntohs(rr6->rr_reserved));
+ /*[*/
+ printf("]");
+#undef F
+ }
+
+ if (rr6->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) {
+ match = (struct rr_pco_match *)cp;
+ cp = (const char *)(match + 1);
+
+ TCHECK(match->rpm_prefix);
+
+ if (vflag)
+ printf("\n\t");
+ else
+ printf(" ");
+ printf("match("); /*)*/
+ switch (match->rpm_code) {
+ case RPM_PCO_ADD: printf("add"); break;
+ case RPM_PCO_CHANGE: printf("change"); break;
+ case RPM_PCO_SETGLOBAL: printf("setglobal"); break;
+ default: printf("#%u", match->rpm_code); break;
+ }
+
+ if (vflag) {
+ printf(",ord=%u", match->rpm_ordinal);
+ printf(",min=%u", match->rpm_minlen);
+ printf(",max=%u", match->rpm_maxlen);
+ }
+ if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf)))
+ printf(",%s/%u", hbuf, match->rpm_matchlen);
+ else
+ printf(",?/%u", match->rpm_matchlen);
+ /*(*/
+ printf(")");
+
+ n = match->rpm_len - 3;
+ if (n % 4)
+ goto trunc;
+ n /= 4;
+ while (n-- > 0) {
+ use = (struct rr_pco_use *)cp;
+ cp = (const char *)(use + 1);
+
+ TCHECK(use->rpu_prefix);
+
+ if (vflag)
+ printf("\n\t");
+ else
+ printf(" ");
+ printf("use("); /*)*/
+ if (use->rpu_flags) {
+#define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
+ printf("%s%s,",
+ F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
+ F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P"));
+#undef F
+ }
+ if (vflag) {
+ printf("mask=0x%x,", use->rpu_ramask);
+ printf("raflags=0x%x,", use->rpu_raflags);
+ if (~use->rpu_vltime == 0)
+ printf("vltime=infty,");
+ else
+ printf("vltime=%u,",
+ (u_int32_t)ntohl(use->rpu_vltime));
+ if (~use->rpu_pltime == 0)
+ printf("pltime=infty,");
+ else
+ printf("pltime=%u,",
+ (u_int32_t)ntohl(use->rpu_pltime));
+ }
+ if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
+ sizeof(hbuf)))
+ printf("%s/%u/%u", hbuf, use->rpu_uselen,
+ use->rpu_keeplen);
+ else
+ printf("?/%u/%u", use->rpu_uselen,
+ use->rpu_keeplen);
+ /*(*/
+ printf(")");
+ }
+ }
return;
+
+trunc:
+ fputs("[|icmp6]", stdout);
}
+
#endif /* INET6 */
diff --git a/contrib/tcpdump/print-igmp.c b/contrib/tcpdump/print-igmp.c
new file mode 100644
index 0000000..c79244e
--- /dev/null
+++ b/contrib/tcpdump/print-igmp.c
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.3 2001/01/09 08:01:18 fenner Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
+
+#ifndef IN_CLASSD
+#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
+#endif
+
+/* (following from ipmulti/mrouted/prune.h) */
+
+/*
+ * The packet format for a traceroute request.
+ */
+struct tr_query {
+ u_int tr_src; /* traceroute source */
+ u_int tr_dst; /* traceroute destination */
+ u_int tr_raddr; /* traceroute response address */
+ u_int tr_rttlqid; /* response ttl and qid */
+};
+
+#define TR_GETTTL(x) (int)(((x) >> 24) & 0xff)
+#define TR_GETQID(x) ((x) & 0x00ffffff)
+
+/*
+ * Traceroute response format. A traceroute response has a tr_query at the
+ * beginning, followed by one tr_resp for each hop taken.
+ */
+struct tr_resp {
+ u_int tr_qarr; /* query arrival time */
+ u_int tr_inaddr; /* incoming interface address */
+ u_int tr_outaddr; /* outgoing interface address */
+ u_int tr_rmtaddr; /* parent address in source tree */
+ u_int tr_vifin; /* input packet count on interface */
+ u_int tr_vifout; /* output packet count on interface */
+ u_int tr_pktcnt; /* total incoming packets for src-grp */
+ u_char tr_rproto; /* routing proto deployed on router */
+ u_char tr_fttl; /* ttl required to forward on outvif */
+ u_char tr_smask; /* subnet mask for src addr */
+ u_char tr_rflags; /* forwarding error codes */
+};
+
+/* defs within mtrace */
+#define TR_QUERY 1
+#define TR_RESP 2
+
+/* fields for tr_rflags (forwarding error codes) */
+#define TR_NO_ERR 0
+#define TR_WRONG_IF 1
+#define TR_PRUNED 2
+#define TR_OPRUNED 3
+#define TR_SCOPED 4
+#define TR_NO_RTE 5
+#define TR_NO_FWD 7
+#define TR_NO_SPACE 0x81
+#define TR_OLD_ROUTER 0x82
+
+/* fields for tr_rproto (routing protocol) */
+#define TR_PROTO_DVMRP 1
+#define TR_PROTO_MOSPF 2
+#define TR_PROTO_PIM 3
+#define TR_PROTO_CBT 4
+
+/* igmpv3 report types */
+static struct tok igmpv3report2str[] = {
+ { 1, "is_in" },
+ { 2, "is_ex" },
+ { 3, "to_in" },
+ { 4, "to_ex" },
+ { 5, "allow" },
+ { 6, "block" },
+ { 0, NULL }
+};
+
+static void
+print_mtrace(register const u_char *bp, register u_int len)
+{
+ register struct tr_query *tr = (struct tr_query *)(bp + 8);
+
+ printf("mtrace %lu: %s to %s reply-to %s",
+ (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+ ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
+ ipaddr_string(&tr->tr_raddr));
+ if (IN_CLASSD(ntohl(tr->tr_raddr)))
+ printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+}
+
+static void
+print_mresp(register const u_char *bp, register u_int len)
+{
+ register struct tr_query *tr = (struct tr_query *)(bp + 8);
+
+ printf("mresp %lu: %s to %s reply-to %s",
+ (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+ ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
+ ipaddr_string(&tr->tr_raddr));
+ if (IN_CLASSD(ntohl(tr->tr_raddr)))
+ printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+}
+
+static void
+print_igmpv3_report(register const u_char *bp, register u_int len,
+ register const u_char *bp2)
+{
+ int group, nsrcs, ngroups;
+ register int i, j;
+
+ /* Minimum len is 16, and should be a multiple of 4 */
+ if (len < 16 || len & 0x03) {
+ (void)printf(" [invalid len %d]", len);
+ return;
+ }
+ TCHECK2(bp[6], 2);
+ ngroups = EXTRACT_16BITS(&bp[6]);
+ (void)printf(", %d group record(s)", ngroups);
+ if (vflag > 0) {
+ /* Print the group records */
+ group = 8;
+ for (i=0; i<ngroups; i++) {
+ if (len < group+8) {
+ (void)printf(" [invalid number of groups]");
+ return;
+ }
+ TCHECK2(bp[group+4], 4);
+ (void)printf(" [gaddr %s", ipaddr_string(&bp[group+4]));
+ (void)printf(" %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
+ bp[group]));
+ nsrcs = EXTRACT_16BITS(&bp[group+2]);
+ /* Check the number of sources and print them */
+ if (len < group+8+(nsrcs<<2)) {
+ (void)printf(" [invalid number of sources %d]", nsrcs);
+ return;
+ }
+ if (vflag == 1)
+ (void)printf(", %d source(s)", nsrcs);
+ else {
+ /* Print the sources */
+ (void)printf(" {");
+ for (j=0; j<nsrcs; j++) {
+ TCHECK2(bp[group+8+(j<<2)], 4);
+ (void)printf(" %s", ipaddr_string(&bp[group+8+(j<<2)]));
+ }
+ (void)printf(" }");
+ }
+ /* Next group record */
+ group += 8 + (nsrcs << 2);
+ (void)printf("]");
+ }
+ }
+ return;
+trunc:
+ (void)printf("[|igmp]");
+ return;
+}
+
+static void
+print_igmpv3_query(register const u_char *bp, register u_int len,
+ register const u_char *bp2)
+{
+ int nsrcs;
+ register int i;
+
+ (void)printf(" v3");
+ /* Minimum len is 12, and should be a multiple of 4 */
+ if (len < 12 || len & 0x03) {
+ (void)printf(" [invalid len %d]", len);
+ return;
+ }
+ TCHECK2(bp[4], 4);
+ if (EXTRACT_32BITS(&bp[4]) == 0)
+ return;
+ (void)printf(" [gaddr %s", ipaddr_string(&bp[4]));
+ TCHECK2(bp[10], 2);
+ nsrcs = EXTRACT_16BITS(&bp[10]);
+ if (nsrcs > 0) {
+ if (len < 12 + (nsrcs << 2))
+ (void)printf(" [invalid number of sources]");
+ else if (vflag > 1) {
+ (void)printf(" {");
+ for (i=0; i<nsrcs; i++) {
+ TCHECK2(bp[12+(i<<2)], 4);
+ (void)printf(" %s", ipaddr_string(&bp[12+(i<<2)]));
+ }
+ (void)printf(" }");
+ } else
+ (void)printf(", %d source(s)", nsrcs);
+ }
+ (void)printf("]");
+ return;
+trunc:
+ (void)printf("[|igmp]");
+ return;
+}
+
+void
+igmp_print(register const u_char *bp, register u_int len,
+ register const u_char *bp2)
+{
+ if (qflag) {
+ (void)printf("igmp");
+ return;
+ }
+
+ TCHECK2(bp[0], 8);
+ switch (bp[0]) {
+ case 0x11:
+ (void)printf("igmp query");
+ if (len >= 12)
+ print_igmpv3_query(bp, len, bp2);
+ else {
+ if (bp[1]) {
+ (void)printf(" v2");
+ if (bp[1] != 100)
+ (void)printf(" [max resp time %d]", bp[1]);
+ } else
+ (void)printf(" v1");
+ if (EXTRACT_32BITS(&bp[4]))
+ (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
+ if (len != 8)
+ (void)printf(" [len %d]", len);
+ }
+ break;
+ case 0x12:
+ (void)printf("igmp v1 report %s", ipaddr_string(&bp[4]));
+ if (len != 8)
+ (void)printf(" [len %d]", len);
+ break;
+ case 0x16:
+ (void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
+ break;
+ case 0x22:
+ (void)printf("igmp v3 report");
+ print_igmpv3_report(bp, len, bp2);
+ break;
+ case 0x17:
+ (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
+ break;
+ case 0x13:
+ (void)printf("igmp dvmrp");
+ if (len < 8)
+ (void)printf(" [len %d]", len);
+ else
+ dvmrp_print(bp, len);
+ break;
+ case 0x14:
+ (void)printf("igmp pimv1");
+ pimv1_print(bp, len);
+ break;
+ case 0x1e:
+ print_mresp(bp, len);
+ break;
+ case 0x1f:
+ print_mtrace(bp, len);
+ break;
+ default:
+ (void)printf("igmp-%d", bp[0]);
+ break;
+ }
+
+ if (vflag && TTEST2(bp[0], len)) {
+ /* Check the IGMP checksum */
+ if (in_cksum((const u_short*)bp, len, 0))
+ printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
+ }
+ return;
+trunc:
+ fputs("[|igmp]", stdout);
+}
diff --git a/contrib/tcpdump/print-igrp.c b/contrib/tcpdump/print-igrp.c
index edbc1f1..cecee14 100644
--- a/contrib/tcpdump/print-igrp.c
+++ b/contrib/tcpdump/print-igrp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.11 1999/11/21 09:36:53 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.15 2000/09/29 04:58:40 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,11 +35,6 @@ static const char rcsid[] =
#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 <errno.h>
#include <stdio.h>
@@ -47,6 +42,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "igrp.h"
+#include "ip.h"
#include "extract.h" /* must come after interface.h */
static void
@@ -107,8 +103,8 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
next = EXTRACT_16BITS(&hdr->ig_nx);
(void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)",
- tok2str(op2str, "op-#%d", hdr->ig_op),
- hdr->ig_v,
+ tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)),
+ IGRP_V(hdr->ig_vop),
hdr->ig_ed,
EXTRACT_16BITS(&hdr->ig_as),
nint,
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index 9258673..869c9da 100644
--- a/contrib/tcpdump/print-ip.c
+++ b/contrib/tcpdump/print-ip.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.79 1999/12/22 06:27:21 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.92 2001/01/02 23:00:01 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,16 +33,7 @@ static const char rcsid[] =
#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>
-
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -52,161 +43,13 @@ static const char rcsid[] =
#include "interface.h"
#include "extract.h" /* must come after interface.h */
+#include "ip.h"
+
/* Compatibility */
#ifndef IPPROTO_ND
#define IPPROTO_ND 77
#endif
-#ifndef IN_CLASSD
-#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
-#endif
-
-/* (following from ipmulti/mrouted/prune.h) */
-
-/*
- * The packet format for a traceroute request.
- */
-struct tr_query {
- u_int tr_src; /* traceroute source */
- u_int tr_dst; /* traceroute destination */
- u_int tr_raddr; /* traceroute response address */
- u_int tr_rttlqid; /* response ttl and qid */
-};
-
-#define TR_GETTTL(x) (int)(((x) >> 24) & 0xff)
-#define TR_GETQID(x) ((x) & 0x00ffffff)
-
-/*
- * Traceroute response format. A traceroute response has a tr_query at the
- * beginning, followed by one tr_resp for each hop taken.
- */
-struct tr_resp {
- u_int tr_qarr; /* query arrival time */
- u_int tr_inaddr; /* incoming interface address */
- u_int tr_outaddr; /* outgoing interface address */
- u_int tr_rmtaddr; /* parent address in source tree */
- u_int tr_vifin; /* input packet count on interface */
- u_int tr_vifout; /* output packet count on interface */
- u_int tr_pktcnt; /* total incoming packets for src-grp */
- u_char tr_rproto; /* routing proto deployed on router */
- u_char tr_fttl; /* ttl required to forward on outvif */
- u_char tr_smask; /* subnet mask for src addr */
- u_char tr_rflags; /* forwarding error codes */
-};
-
-/* defs within mtrace */
-#define TR_QUERY 1
-#define TR_RESP 2
-
-/* fields for tr_rflags (forwarding error codes) */
-#define TR_NO_ERR 0
-#define TR_WRONG_IF 1
-#define TR_PRUNED 2
-#define TR_OPRUNED 3
-#define TR_SCOPED 4
-#define TR_NO_RTE 5
-#define TR_NO_FWD 7
-#define TR_NO_SPACE 0x81
-#define TR_OLD_ROUTER 0x82
-
-/* fields for tr_rproto (routing protocol) */
-#define TR_PROTO_DVMRP 1
-#define TR_PROTO_MOSPF 2
-#define TR_PROTO_PIM 3
-#define TR_PROTO_CBT 4
-
-static void print_mtrace(register const u_char *bp, register u_int len)
-{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
-
- printf("mtrace %lu: %s to %s reply-to %s",
- (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
- ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
- ipaddr_string(&tr->tr_raddr));
- if (IN_CLASSD(ntohl(tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
-}
-
-static void print_mresp(register const u_char *bp, register u_int len)
-{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
-
- printf("mresp %lu: %s to %s reply-to %s",
- (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
- ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
- ipaddr_string(&tr->tr_raddr));
- if (IN_CLASSD(ntohl(tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
-}
-
-static void
-igmp_print(register const u_char *bp, register u_int len,
- register const u_char *bp2)
-{
- register const struct ip *ip;
-
- ip = (const struct ip *)bp2;
- (void)printf("%s > %s: ",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
-
- if (qflag) {
- (void)printf("igmp");
- return;
- }
-
- TCHECK2(bp[0], 8);
- switch (bp[0]) {
- case 0x11:
- (void)printf("igmp query");
- if (EXTRACT_32BITS(&bp[4]))
- (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
- if (len != 8)
- (void)printf(" [len %d]", len);
- break;
- case 0x12:
- (void)printf("igmp v1 report %s", ipaddr_string(&bp[4]));
- if (len != 8)
- (void)printf(" [len %d]", len);
- break;
- case 0x16:
- (void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
- break;
- case 0x17:
- (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
- break;
- case 0x13:
- (void)printf("igmp dvmrp");
- if (len < 8)
- (void)printf(" [len %d]", len);
- else
- dvmrp_print(bp, len);
- break;
- case 0x14:
- (void)printf("igmp pimv1");
- pimv1_print(bp, len);
- break;
- case 0x1e:
- print_mresp(bp, len);
- break;
- case 0x1f:
- print_mtrace(bp, len);
- break;
- default:
- (void)printf("igmp-%d", bp[0]);
- break;
- }
-
- if (vflag && TTEST2(bp[0], len)) {
- /* Check the IGMP checksum */
- if (in_cksum((const u_short*)bp, len, 0))
- printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
- }
- return;
-trunc:
- fputs("[|igmp]", stdout);
-}
-
/*
* print the recorded route in an IP RR, LSRR or SSRR option.
*/
@@ -299,7 +142,15 @@ ip_optprint(register const u_char *cp, u_int length)
for (; length > 0; cp += len, length -= len) {
int tt = *cp;
- len = (tt == IPOPT_NOP || tt == IPOPT_EOL) ? 1 : cp[1];
+ if (tt == IPOPT_NOP || tt == IPOPT_EOL)
+ len = 1;
+ else {
+ if (&cp[1] >= snapend) {
+ printf("[|ip]");
+ return;
+ }
+ len = cp[1];
+ }
if (len <= 0) {
printf("[|ip op len %d]", len);
return;
@@ -442,7 +293,11 @@ ip_print(register const u_char *bp, register u_int length)
(void)printf("truncated-ip %d", length);
return;
}
- hlen = ip->ip_hl * 4;
+ hlen = IP_HL(ip) * 4;
+ if (hlen < sizeof (struct ip)) {
+ (void)printf("bad-hlen %d", hlen);
+ return;
+ }
len = ntohs(ip->ip_len);
if (length < len)
@@ -508,11 +363,11 @@ again:
}
case IPPROTO_TCP:
- tcp_print(cp, len, (const u_char *)ip);
+ tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
break;
case IPPROTO_UDP:
- udp_print(cp, len, (const u_char *)ip);
+ udp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
break;
case IPPROTO_ICMP:
@@ -626,6 +481,17 @@ again:
pim_print(cp, len);
break;
+#ifndef IPPROTO_VRRP
+#define IPPROTO_VRRP 112
+#endif
+ case IPPROTO_VRRP:
+ if (vflag)
+ (void)printf("vrrp %s > %s: ",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+ vrrp_print(cp, len, ip->ip_ttl);
+ break;
+
default:
#if 0
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
@@ -695,6 +561,8 @@ again:
(void)printf("%sid %d", sep, (int)ntohs(ip->ip_id));
sep = ", ";
}
+ (void)printf("%slen %d", sep, (int)ntohs(ip->ip_len));
+ sep = ", ";
if ((u_char *)ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ip, hlen, 0);
if (sum != 0) {
@@ -710,3 +578,29 @@ again:
printf(")");
}
}
+
+void
+ipN_print(register const u_char *bp, register u_int length)
+{
+ struct ip *ip, hdr;
+
+ ip = (struct ip *)bp;
+ if (length < 4) {
+ (void)printf("truncated-ip %d", length);
+ return;
+ }
+ memcpy (&hdr, (char *)ip, 4);
+ switch (IP_V(&hdr)) {
+ case 4:
+ ip_print (bp, length);
+ return;
+#ifdef INET6
+ case 6:
+ ip6_print (bp, length);
+ return;
+#endif
+ default:
+ (void)printf("unknown ip %d", IP_V(&hdr));
+ return;
+ }
+}
diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c
index 44ce6ce..71cd41c 100644
--- a/contrib/tcpdump/print-ip6.c
+++ b/contrib/tcpdump/print-ip6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.2.2.1 2000/01/11 06:58:25 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.16 2000/11/17 19:08:15 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,23 +36,16 @@ static const char rcsid[] =
#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 <stdio.h>
-#ifdef __STDC__
#include <stdlib.h>
-#endif
#include <unistd.h>
+#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include <netinet/ip6.h>
+#include "ip6.h"
/*
* print an IP6 datagram.
@@ -61,29 +54,30 @@ void
ip6_print(register const u_char *bp, register int length)
{
register const struct ip6_hdr *ip6;
- register int hlen;
+ register int advance;
register int len;
register const u_char *cp;
int nh;
+ int fragmented = 0;
u_int flow;
ip6 = (const struct ip6_hdr *)bp;
-#ifdef TCPDUMP_ALIGN
+#ifdef LBL_ALIGN
/*
- * The IP header is not word aligned, so copy into abuf.
+ * The IP6 header is not 16-byte aligned, so copy into abuf.
* This will never happen with BPF. It does happen raw packet
* dumps from -r.
*/
- if ((int)ip & (sizeof(long)-1)) {
+ if ((u_long)ip6 & 15) {
static u_char *abuf;
- if (abuf == 0)
- abuf = (u_char *)malloc(snaplen);
- bcopy((char *)ip, (char *)abuf, min(length, snaplen));
- snapend += abuf - (u_char *)ip;
+ if (abuf == NULL)
+ abuf = malloc(snaplen);
+ memcpy(abuf, ip6, min(length, snaplen));
+ snapend += abuf - (u_char *)ip6;
packetp = abuf;
- ip = (struct ip6_hdr *)abuf;
+ ip6 = (struct ip6_hdr *)abuf;
}
#endif
if ((u_char *)(ip6 + 1) > snapend) {
@@ -94,17 +88,17 @@ ip6_print(register const u_char *bp, register int length)
(void)printf("truncated-ip6 %d", length);
return;
}
- hlen = sizeof(struct ip6_hdr);
+ advance = sizeof(struct ip6_hdr);
len = ntohs(ip6->ip6_plen);
- if (length < len + hlen)
+ if (length < len + advance)
(void)printf("truncated-ip6 - %d bytes missing!",
- len + hlen - length);
+ len + advance - length);
cp = (const u_char *)ip6;
nh = ip6->ip6_nxt;
while (cp < snapend) {
- cp += hlen;
+ cp += advance;
if (cp == (u_char *)(ip6 + 1)
&& nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
@@ -114,42 +108,43 @@ ip6_print(register const u_char *bp, register int length)
switch (nh) {
case IPPROTO_HOPOPTS:
- hlen = hbhopt_print(cp);
+ advance = hbhopt_print(cp);
nh = *cp;
break;
case IPPROTO_DSTOPTS:
- hlen = dstopt_print(cp);
+ advance = dstopt_print(cp);
nh = *cp;
break;
case IPPROTO_FRAGMENT:
- hlen = frag6_print(cp, (const u_char *)ip6);
- if (snapend <= cp + hlen)
+ advance = frag6_print(cp, (const u_char *)ip6);
+ if (snapend <= cp + advance)
goto end;
nh = *cp;
+ fragmented = 1;
break;
case IPPROTO_ROUTING:
- hlen = rt6_print(cp, (const u_char *)ip6);
+ advance = rt6_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_TCP:
tcp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
- (const u_char *)ip6);
+ (const u_char *)ip6, fragmented);
goto end;
case IPPROTO_UDP:
udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
- (const u_char *)ip6);
+ (const u_char *)ip6, fragmented);
goto end;
case IPPROTO_ICMPV6:
icmp6_print(cp, (const u_char *)ip6);
goto end;
case IPPROTO_AH:
- hlen = ah_print(cp, (const u_char *)ip6);
+ advance = ah_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_ESP:
{
int enh;
- cp += esp_print(cp, (const u_char *)ip6, &enh);
+ advance = esp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
@@ -161,14 +156,17 @@ ip6_print(register const u_char *bp, register int length)
case IPPROTO_IPCOMP:
{
int enh;
- cp += ipcomp_print(cp, (const u_char *)ip6, &enh);
+ advance = ipcomp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
break;
}
+
+#ifndef IPPROTO_PIM
+#define IPPROTO_PIM 103
+#endif
case IPPROTO_PIM:
- (void)printf("PIM");
pim_print(cp, len);
goto end;
#ifndef IPPROTO_OSPF
diff --git a/contrib/tcpdump/print-ip6opts.c b/contrib/tcpdump/print-ip6opts.c
index 756f098..22d017e 100644
--- a/contrib/tcpdump/print-ip6opts.c
+++ b/contrib/tcpdump/print-ip6opts.c
@@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.2.2.1 2000/01/11 06:58:25 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.8 2000/12/13 07:57:05 itojun Exp $";
#endif
#ifdef INET6
@@ -43,13 +43,86 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/ip6.h>
-
#include <stdio.h>
+#include "ip6.h"
+
#include "interface.h"
#include "addrtoname.h"
+/* items outside of rfc2292bis */
+#ifndef IP6OPT_MINLEN
+#define IP6OPT_MINLEN 2
+#endif
+#ifndef IP6OPT_RTALERT_LEN
+#define IP6OPT_RTALERT_LEN 4
+#endif
+#ifndef IP6OPT_JUMBO_LEN
+#define IP6OPT_JUMBO_LEN 6
+#endif
+#define IP6OPT_HOMEADDR_MINLEN 18
+#define IP6OPT_BU_MINLEN 10
+#define IP6OPT_BA_MINLEN 13
+#define IP6OPT_BR_MINLEN 2
+#define IP6SOPT_ALTCOA 0x4
+#define IP6SOPT_ALTCOA_MINLEN 18
+#define IP6SOPT_UI 0x2
+#define IP6SOPT_UI_MINLEN 4
+
+static void ip6_sopt_print(const u_char *, int);
+
+static void
+ip6_sopt_print(const u_char *bp, int len)
+{
+ int i;
+ int optlen;
+
+ for (i = 0; i < len; i += optlen) {
+ switch (bp[i]) {
+ case IP6OPT_PAD1:
+ printf(", pad1");
+ optlen = 1;
+ break;
+ case IP6OPT_PADN:
+ if (len - i < IP6OPT_MINLEN) {
+ printf(", padn: trunc");
+ goto trunc;
+ }
+ printf(", padn");
+ optlen = bp[i + 1] + 2;
+ break;
+ case IP6SOPT_ALTCOA:
+ if (len - i < IP6SOPT_ALTCOA_MINLEN) {
+ printf(", altcoa: trunc");
+ goto trunc;
+ }
+ printf(", alt-CoA: %s", ip6addr_string(&bp[i+2]));
+ optlen = bp[i + 1] + 2;
+ break;
+ case IP6SOPT_UI:
+ if (len - i < IP6SOPT_UI_MINLEN) {
+ printf(", ui: trunc");
+ goto trunc;
+ }
+ printf("(ui: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2]));
+ optlen = bp[i + 1] + 2;
+ break;
+ default:
+ if (len - i < IP6OPT_MINLEN) {
+ printf(", sopt_type %d: trunc)", bp[i]);
+ goto trunc;
+ }
+ printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
+ optlen = bp[i + 1] + 2;
+ break;
+ }
+ }
+ return;
+
+trunc:
+ printf("[trunc] ");
+}
+
void
ip6_opt_print(const u_char *bp, int len)
{
@@ -59,6 +132,7 @@ ip6_opt_print(const u_char *bp, int len)
for (i = 0; i < len; i += optlen) {
switch (bp[i]) {
case IP6OPT_PAD1:
+ printf("(pad1)");
optlen = 1;
break;
case IP6OPT_PADN:
@@ -66,9 +140,10 @@ ip6_opt_print(const u_char *bp, int len)
printf("(padn: trunc)");
goto trunc;
}
+ printf("(padn)");
optlen = bp[i + 1] + 2;
break;
- case IP6OPT_RTALERT:
+ case IP6OPT_ROUTER_ALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
printf("(rtalert: trunc)");
goto trunc;
@@ -77,7 +152,7 @@ ip6_opt_print(const u_char *bp, int len)
printf("(rtalert: invalid len %d)", bp[i + 1]);
goto trunc;
}
- printf("(rtalert: 0x%04x) ", ntohs(*(u_short *)&bp[i + 2]));
+ printf("(rtalert: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2]));
optlen = IP6OPT_RTALERT_LEN;
break;
case IP6OPT_JUMBO:
@@ -89,15 +164,103 @@ ip6_opt_print(const u_char *bp, int len)
printf("(jumbo: invalid len %d)", bp[i + 1]);
goto trunc;
}
- printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int *)&bp[i + 2]));
+ printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 2]));
optlen = IP6OPT_JUMBO_LEN;
break;
+ case IP6OPT_HOME_ADDRESS:
+ if (len - i < IP6OPT_HOMEADDR_MINLEN) {
+ printf("(homeaddr: trunc)");
+ goto trunc;
+ }
+ if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
+ printf("(homeaddr: invalid len %d)", bp[i + 1]);
+ goto trunc;
+ }
+ printf("(homeaddr: %s", ip6addr_string(&bp[i + 2]));
+ if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
+ ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN],
+ (optlen-IP6OPT_HOMEADDR_MINLEN));
+ }
+ printf(")");
+ optlen = bp[i + 1] + 2;
+ break;
+ case IP6OPT_BINDING_UPDATE:
+ if (len - i < IP6OPT_BU_MINLEN) {
+ printf("(bu: trunc)");
+ goto trunc;
+ }
+ if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) {
+ printf("(bu: invalid len %d)", bp[i + 1]);
+ goto trunc;
+ }
+ printf("(bu: ");
+ if (bp[i + 2] & 0x80)
+ printf("A");
+ if (bp[i + 2] & 0x40)
+ printf("H");
+ if (bp[i + 2] & 0x20)
+ printf("R");
+ if (bp[i + 2] & 0x10)
+ printf("D");
+ if (bp[i + 2] & 0x0f)
+ printf("res");
+ printf(", prefixlen: %u", bp[i + 3]);
+ printf(", sequence: %u",
+ (u_int16_t)ntohs(*(u_int16_t *)&bp[i + 4]));
+ printf(", lifetime: %u",
+ (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 8]));
+
+ optlen = bp[i + 1] + 2;
+ if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) {
+ ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN],
+ (optlen - IP6OPT_BU_MINLEN));
+ }
+ printf(")");
+ break;
+ case IP6OPT_BINDING_ACK:
+ if (len - i < IP6OPT_BA_MINLEN) {
+ printf("(ba: trunc)");
+ goto trunc;
+ }
+ if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) {
+ printf("(ba: invalid len %d)", bp[i + 1]);
+ goto trunc;
+ }
+ printf("(ba: ");
+ printf("status: %u", bp[i + 2]);
+ printf(", sequence: %u",
+ (u_int16_t)ntohs(*(u_int16_t *)&bp[i + 3]));
+ printf(", lifetime: %u",
+ (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 7]));
+ printf(", refresh: %u",
+ (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 11]));
+
+ if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
+ ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
+ (optlen-IP6OPT_BA_MINLEN));
+ }
+ printf(")");
+ optlen = bp[i + 1] + 2;
+ break;
+ case IP6OPT_BINDING_REQ:
+ if (len - i < IP6OPT_BR_MINLEN) {
+ printf("(br: trunc)");
+ goto trunc;
+ }
+ printf("(br");
+ if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
+ ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
+ (optlen-IP6OPT_BR_MINLEN));
+ }
+ printf(")");
+ optlen = bp[i + 1] + 2;
+ break;
default:
if (len - i < IP6OPT_MINLEN) {
printf("(type %d: trunc)", bp[i]);
goto trunc;
}
- printf("(type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
+ printf("(opt_type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
optlen = bp[i + 1] + 2;
break;
}
@@ -119,11 +282,11 @@ hbhopt_print(register const u_char *bp)
register const u_char *ep;
int hbhlen = 0;
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
TCHECK(dp->ip6h_len);
hbhlen = (int)((dp->ip6h_len + 1) << 3);
- TCHECK2(dp, hbhlen);
+ TCHECK2(*dp, hbhlen);
printf("HBH ");
if (vflag)
ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
@@ -142,11 +305,11 @@ dstopt_print(register const u_char *bp)
register const u_char *ep;
int dstoptlen = 0;
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
TCHECK(dp->ip6d_len);
dstoptlen = (int)((dp->ip6d_len + 1) << 3);
- TCHECK2(dp, dstoptlen);
+ TCHECK2(*dp, dstoptlen);
printf("DSTOPT ");
if (vflag) {
ip6_opt_print((const u_char *)dp + sizeof(*dp),
diff --git a/contrib/tcpdump/print-ipcomp.c b/contrib/tcpdump/print-ipcomp.c
index 8b2dd47..9975e54 100644
--- a/contrib/tcpdump/print-ipcomp.c
+++ b/contrib/tcpdump/print-ipcomp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.2.2.2 2000/01/25 18:31:10 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.13 2000/12/12 09:58:41 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,25 +34,10 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/route.h>
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <stdio.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-
struct ipcomp {
u_int8_t comp_nxt; /* Next Header */
u_int8_t comp_flags; /* Length of data, in 32bit */
@@ -79,14 +64,14 @@ ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
ipcomp = (struct ipcomp *)bp;
cpi = (u_int16_t)ntohs(ipcomp->comp_cpi);
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
fputs("[|IPCOMP]", stdout);
goto fail;
}
- printf("IPComp(cpi=%u)", cpi);
+ printf("IPComp(cpi=0x%04x)", cpi);
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
if (1)
diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c
index 4e460e2..4925719 100644
--- a/contrib/tcpdump/print-ipx.c
+++ b/contrib/tcpdump/print-ipx.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.22 1999/11/21 09:36:54 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.27 2000/09/29 04:58:41 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,16 +36,8 @@ static const char rcsid[] =
#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>
-
-#ifdef __STDC__
+
#include <stdlib.h>
-#endif
#include <stdio.h>
#include <string.h>
@@ -92,7 +84,7 @@ ipxaddr_string(u_int32_t net, const u_char *node)
{
static char line[256];
- sprintf(line, "%x.%02x:%02x:%02x:%02x:%02x:%02x",
+ snprintf(line, sizeof(line), "%x.%02x:%02x:%02x:%02x:%02x:%02x",
net, node[0], node[1], node[2], node[3], node[4], node[5]);
return line;
diff --git a/contrib/tcpdump/print-isakmp.c b/contrib/tcpdump/print-isakmp.c
index f3c38ac..66df93a 100644
--- a/contrib/tcpdump/print-isakmp.c
+++ b/contrib/tcpdump/print-isakmp.c
@@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.8.2.1 2000/01/14 19:19:56 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.26 2000/12/12 09:20:26 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -43,24 +43,10 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.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>
-
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
#include <stdio.h>
#include <netdb.h>
@@ -72,35 +58,47 @@ struct rtentry;
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
#ifndef HAVE_SOCKADDR_STORAGE
#define sockaddr_storage sockaddr
#endif
-static u_char *isakmp_sa_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_p_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_t_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_ke_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_id_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_hash_print __P((struct isakmp_gen *, u_char *,
- u_int32_t, u_int32_t, u_int32_t));
-static u_char *isakmp_nonce_print __P((struct isakmp_gen *, u_char *,
- u_int32_t, u_int32_t, u_int32_t));
-static u_char *isakmp_n_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_d_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_vid_print __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t));
-static u_char *isakmp_sub0_print __P((u_char, struct isakmp_gen *, u_char *,
- u_int32_t, u_int32_t, u_int32_t));
-static u_char *isakmp_sub_print __P((u_char, struct isakmp_gen *, u_char *,
- u_int32_t, u_int32_t, u_int32_t));
-static char *numstr __P((int));
+static u_char *isakmp_sa_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_p_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_t_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_ke_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_id_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_cert_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_cr_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_sig_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_hash_print(struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t);
+static u_char *isakmp_nonce_print(struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t);
+static u_char *isakmp_n_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_d_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_vid_print(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t);
+static u_char *isakmp_sub0_print(u_char, struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t);
+static u_char *isakmp_sub_print(u_char, struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t);
+static char *numstr(int);
+static void safememcpy(void *, void *, size_t);
#define MAXINITIATORS 20
int ninitiator = 0;
@@ -122,18 +120,18 @@ static char *npstr[] = {
};
/* isakmp->np */
-static u_char *(*npfunc[]) __P((struct isakmp_gen *, u_char *, u_int32_t,
- u_int32_t, u_int32_t)) = {
+static u_char *(*npfunc[])(struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t) = {
NULL,
isakmp_sa_print,
isakmp_p_print,
isakmp_t_print,
isakmp_ke_print,
isakmp_id_print,
- NULL,
- NULL,
+ isakmp_cert_print,
+ isakmp_cr_print,
isakmp_hash_print,
- NULL,
+ isakmp_sig_print,
isakmp_nonce_print,
isakmp_n_print,
isakmp_d_print,
@@ -202,7 +200,7 @@ cookie_record(cookie_t *in, const u_char *bp2)
}
ip = (struct ip *)bp2;
- switch (ip->ip_v) {
+ switch (IP_V(ip)) {
case 4:
memset(&cookiecache[ninitiator].iaddr, 0,
sizeof(cookiecache[ninitiator].iaddr));
@@ -268,7 +266,7 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
memset(&ss, 0, sizeof(ss));
ip = (struct ip *)bp2;
- switch (ip->ip_v) {
+ switch (IP_V(ip)) {
case 4:
sin = (struct sockaddr_in *)&ss;
#ifdef HAVE_SOCKADDR_SA_LEN
@@ -351,11 +349,11 @@ struct attrmap {
static u_char *
isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap)
{
- u_short *q;
+ u_int16_t *q;
int totlen;
u_int32_t t, v;
- q = (u_short *)p;
+ q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
@@ -389,11 +387,11 @@ isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap)
static u_char *
isakmp_attr_print(u_char *p, u_char *ep)
{
- u_short *q;
+ u_int16_t *q;
int totlen;
u_int32_t t;
- q = (u_short *)p;
+ q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
@@ -422,43 +420,47 @@ static u_char *
isakmp_sa_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
- struct isakmp_pl_sa *p;
+ struct isakmp_pl_sa *p, sa;
u_int32_t *q;
- u_int32_t doi;
- u_int32_t sit;
- u_char *cp;
+ u_int32_t doi, sit, ident;
+ u_char *cp, *np;
int t;
printf("%s:", NPSTR(ISAKMP_NPTYPE_SA));
p = (struct isakmp_pl_sa *)ext;
- doi = ntohl(p->doi);
+ safememcpy(&sa, ext, sizeof(sa));
+ doi = ntohl(sa.doi);
+ sit = ntohl(sa.sit);
if (doi != 1) {
printf(" doi=%d", doi);
- printf(" situation=%u", (u_int32_t)ntohl(p->sit));
+ printf(" situation=%u", (u_int32_t)ntohl(sa.sit));
return (u_char *)(p + 1);
}
printf(" doi=ipsec");
- q = (u_int32_t *)&p->sit;
+ q = (u_int32_t *)&sa.sit;
printf(" situation=");
t = 0;
- if (ntohl(*q) & 0x01) {
+ if (sit & 0x01) {
printf("identity");
t++;
}
- if (ntohl(*q) & 0x02) {
+ if (sit & 0x02) {
printf("%ssecrecy", t ? "+" : "");
t++;
}
- if (ntohl(*q) & 0x04)
+ if (sit & 0x04)
printf("%sintegrity", t ? "+" : "");
- sit = htonl(*q++);
- if (sit != 0x01)
- printf(" ident=%u", (u_int32_t)ntohl(*q++));
+ np = (u_char *)ext + sizeof(sa);
+ if (sit != 0x01) {
+ safememcpy(&ident, ext + 1, sizeof(ident));
+ printf(" ident=%u", (u_int32_t)ntohl(ident));
+ np += sizeof(ident);
+ }
- ext = (struct isakmp_gen *)q;
+ ext = (struct isakmp_gen *)np;
cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0);
@@ -469,23 +471,24 @@ static u_char *
isakmp_p_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
- struct isakmp_pl_p *p;
+ struct isakmp_pl_p *p, prop;
u_char *cp;
printf("%s:", NPSTR(ISAKMP_NPTYPE_P));
p = (struct isakmp_pl_p *)ext;
+ safememcpy(&prop, ext, sizeof(prop));
printf(" #%d protoid=%s transform=%d",
- p->p_no, PROTOIDSTR(p->prot_id), p->num_t);
- if (p->spi_size) {
+ prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t);
+ if (prop.spi_size) {
printf(" spi=");
- rawprint((caddr_t)(p + 1), p->spi_size);
+ rawprint((caddr_t)(p + 1), prop.spi_size);
}
- ext = (struct isakmp_gen *)((u_char *)(p + 1) + p->spi_size);
+ ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
cp = isakmp_sub_print(ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
- p->prot_id);
+ prop.prot_id);
return cp;
}
@@ -495,12 +498,13 @@ static char *isakmp_p_map[] = {
};
static char *ah_p_map[] = {
- NULL, "md5", "sha", "1des",
+ NULL, "(reserved)", "md5", "sha", "1des",
+ "sha2-256", "sha2-384", "sha2-512",
};
static char *esp_p_map[] = {
NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast",
- "blowfish", "3idea", "1des-iv32", "rc4", "null"
+ "blowfish", "3idea", "1des-iv32", "rc4", "null", "aes"
};
static char *ipcomp_p_map[] = {
@@ -523,9 +527,10 @@ struct attrmap ipsec_t_map[] = {
struct attrmap oakley_t_map[] = {
{ NULL, 0 },
- { "enc", 7, { NULL, "1des", "idea", "blowfish", "rc5",
- "3des", "cast"}, },
- { "hash", 4, { NULL, "md5", "sha1", "tiger", }, },
+ { "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5",
+ "3des", "cast", "aes", }, },
+ { "hash", 7, { NULL, "md5", "sha1", "tiger",
+ "sha2-256", "sha2-384", "sha2-512", }, },
{ "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc",
"rsa enc revised", }, },
{ "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155",
@@ -548,7 +553,7 @@ static u_char *
isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
- struct isakmp_pl_t *p;
+ struct isakmp_pl_t *p, t;
u_char *cp;
char *idstr;
struct attrmap *map;
@@ -558,25 +563,26 @@ isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_T));
p = (struct isakmp_pl_t *)ext;
+ safememcpy(&t, ext, sizeof(t));
switch (proto) {
case 1:
- idstr = STR_OR_ID(p->t_id, isakmp_p_map);
+ idstr = STR_OR_ID(t.t_id, isakmp_p_map);
map = oakley_t_map;
nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]);
break;
case 2:
- idstr = STR_OR_ID(p->t_id, ah_p_map);
+ idstr = STR_OR_ID(t.t_id, ah_p_map);
map = ipsec_t_map;
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
break;
case 3:
- idstr = STR_OR_ID(p->t_id, esp_p_map);
+ idstr = STR_OR_ID(t.t_id, esp_p_map);
map = ipsec_t_map;
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
break;
case 4:
- idstr = STR_OR_ID(p->t_id, ipcomp_p_map);
+ idstr = STR_OR_ID(t.t_id, ipcomp_p_map);
map = ipsec_t_map;
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
break;
@@ -588,11 +594,11 @@ isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
}
if (idstr)
- printf(" #%d id=%s ", p->t_no, idstr);
+ printf(" #%d id=%s ", t.t_no, idstr);
else
- printf(" #%d id=%d ", p->t_no, p->t_id);
+ printf(" #%d id=%d ", t.t_no, t.t_id);
cp = (u_char *)(p + 1);
- ep2 = (u_char *)p + ntohs(ext->len);
+ ep2 = (u_char *)p + ntohs(t.h.len);
while (cp < ep && cp < ep2) {
if (map && nmap) {
cp = isakmp_attrmap_print(cp, (ep < ep2) ? ep : ep2,
@@ -609,14 +615,17 @@ static u_char *
isakmp_ke_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
+ struct isakmp_gen e;
+
printf("%s:", NPSTR(ISAKMP_NPTYPE_KE));
- printf(" key len=%d", ntohs(ext->len) - 4);
- if (2 < vflag && 4 < ntohs(ext->len)) {
+ safememcpy(&e, ext, sizeof(e));
+ printf(" key len=%d", ntohs(e.len) - 4);
+ if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
- rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
- return (u_char *)ext + ntohs(ext->len);
+ return (u_char *)ext + ntohs(e.len);
}
static u_char *
@@ -624,7 +633,7 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
#define USE_IPSECDOI_IN_PHASE1 1
- struct isakmp_pl_id *p;
+ struct isakmp_pl_id *p, id;
static char *idtypestr[] = {
"IPv4", "IPv4net", "IPv6", "IPv6net",
};
@@ -639,11 +648,12 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_ID));
p = (struct isakmp_pl_id *)ext;
- if (sizeof(*p) < ext->len)
+ safememcpy(&id, ext, sizeof(id));
+ if (sizeof(*p) < id.h.len)
data = (u_char *)(p + 1);
else
data = NULL;
- len = ntohs(ext->len) - sizeof(*p);
+ len = ntohs(id.h.len) - sizeof(*p);
#if 0 /*debug*/
printf(" [phase=%d doi=%d proto=%d]", phase, doi, proto);
@@ -653,9 +663,9 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
case 1:
#endif
default:
- printf(" idtype=%s", STR_OR_ID(p->d.id_type, idtypestr));
+ printf(" idtype=%s", STR_OR_ID(id.d.id_type, idtypestr));
printf(" doi_data=%u",
- (u_int32_t)(ntohl(p->d.doi_data) & 0xffffff));
+ (u_int32_t)(ntohl(id.d.doi_data) & 0xffffff));
break;
#ifdef USE_IPSECDOI_IN_PHASE1
@@ -663,22 +673,26 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
#endif
case 2:
{
- struct ipsecdoi_id *p;
+ struct ipsecdoi_id *p, id;
struct protoent *pe;
p = (struct ipsecdoi_id *)ext;
- printf(" idtype=%s", STR_OR_ID(p->type, ipsecidtypestr));
- setprotoent(1);
- pe = getprotobynumber(p->proto_id);
- if (pe)
- printf(" protoid=%s", pe->p_name);
- else
- printf(" protoid=%s", PROTOIDSTR(p->proto_id));
- endprotoent();
- printf(" port=%d", ntohs(p->port));
+ safememcpy(&id, ext, sizeof(id));
+ printf(" idtype=%s", STR_OR_ID(id.type, ipsecidtypestr));
+ if (id.proto_id) {
+ setprotoent(1);
+ pe = getprotobynumber(id.proto_id);
+ if (pe)
+ printf(" protoid=%s", pe->p_name);
+ endprotoent();
+ } else {
+ /* it DOES NOT mean IPPROTO_IP! */
+ printf(" protoid=%s", "0");
+ }
+ printf(" port=%d", ntohs(id.port));
if (!len)
break;
- switch (p->type) {
+ switch (id.type) {
case IPSECDOI_ID_IPV4_ADDR:
printf(" len=%d %s", len, ipaddr_string(data));
len = 0;
@@ -752,42 +766,113 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
rawprint((caddr_t)data, len);
}
}
- return (u_char *)ext + ntohs(ext->len);
+ return (u_char *)ext + ntohs(id.h.len);
+}
+
+static u_char *
+isakmp_cert_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi0, u_int32_t proto0)
+{
+ struct isakmp_pl_cert *p, cert;
+ static char *certstr[] = {
+ "none", "pkcs7", "pgp", "dns",
+ "x509sign", "x509ke", "kerberos", "crl",
+ "arl", "spki", "x509attr",
+ };
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_CERT));
+
+ p = (struct isakmp_pl_cert *)ext;
+ safememcpy(&cert, ext, sizeof(cert));
+ printf(" len=%d", ntohs(cert.h.len) - 4);
+ printf(" type=%s", STR_OR_ID((cert.encode), certstr));
+ if (2 < vflag && 4 < ntohs(cert.h.len)) {
+ printf(" ");
+ rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4);
+ }
+ return (u_char *)ext + ntohs(cert.h.len);
+}
+
+static u_char *
+isakmp_cr_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi0, u_int32_t proto0)
+{
+ struct isakmp_pl_cert *p, cert;
+ static char *certstr[] = {
+ "none", "pkcs7", "pgp", "dns",
+ "x509sign", "x509ke", "kerberos", "crl",
+ "arl", "spki", "x509attr",
+ };
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_CR));
+
+ p = (struct isakmp_pl_cert *)ext;
+ safememcpy(&cert, ext, sizeof(cert));
+ printf(" len=%d", ntohs(cert.h.len) - 4);
+ printf(" type=%s", STR_OR_ID((cert.encode), certstr));
+ if (2 < vflag && 4 < ntohs(cert.h.len)) {
+ printf(" ");
+ rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4);
+ }
+ return (u_char *)ext + ntohs(cert.h.len);
}
static u_char *
isakmp_hash_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
+ struct isakmp_gen e;
+
printf("%s:", NPSTR(ISAKMP_NPTYPE_HASH));
- printf(" len=%d", ntohs(ext->len) - 4);
- if (2 < vflag && 4 < ntohs(ext->len)) {
+ safememcpy(&e, ext, sizeof(e));
+ printf(" len=%d", ntohs(e.len) - 4);
+ if (2 < vflag && 4 < ntohs(e.len)) {
+ printf(" ");
+ rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
+ }
+ return (u_char *)ext + ntohs(e.len);
+}
+
+static u_char *
+isakmp_sig_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi, u_int32_t proto)
+{
+ struct isakmp_gen e;
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_SIG));
+
+ safememcpy(&e, ext, sizeof(e));
+ printf(" len=%d", ntohs(e.len) - 4);
+ if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
- rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
- return (u_char *)ext + ntohs(ext->len);
+ return (u_char *)ext + ntohs(e.len);
}
static u_char *
isakmp_nonce_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
+ struct isakmp_gen e;
+
printf("%s:", NPSTR(ISAKMP_NPTYPE_NONCE));
- printf(" n len=%d", ntohs(ext->len) - 4);
- if (2 < vflag && 4 < ntohs(ext->len)) {
+ safememcpy(&e, ext, sizeof(e));
+ printf(" n len=%d", ntohs(e.len) - 4);
+ if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
- rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
- return (u_char *)ext + ntohs(ext->len);
+ return (u_char *)ext + ntohs(e.len);
}
static u_char *
isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
- struct isakmp_pl_n *p;
+ struct isakmp_pl_n *p, n;
u_char *cp;
u_char *ep2;
u_int32_t doi;
@@ -823,42 +908,43 @@ isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_N));
p = (struct isakmp_pl_n *)ext;
- doi = ntohl(p->doi);
- proto = p->prot_id;
+ safememcpy(&n, ext, sizeof(n));
+ doi = ntohl(n.doi);
+ proto = n.prot_id;
if (doi != 1) {
printf(" doi=%d", doi);
printf(" proto=%d", proto);
- printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
- if (p->spi_size) {
+ printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
+ if (n.spi_size) {
printf(" spi=");
- rawprint((caddr_t)(p + 1), p->spi_size);
+ rawprint((caddr_t)(p + 1), n.spi_size);
}
- return (u_char *)(p + 1) + p->spi_size;
+ return (u_char *)(p + 1) + n.spi_size;
}
printf(" doi=ipsec");
printf(" proto=%s", PROTOIDSTR(proto));
- if (ntohs(p->type) < 8192)
- printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
- else if (ntohs(p->type) < 16384)
- printf(" type=%s", IPSECNOTIFYSTR(ntohs(p->type)));
- else if (ntohs(p->type) < 24576)
- printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
- else if (ntohs(p->type) < 40960)
- printf(" type=%s", IPSECNOTIFYSTR(ntohs(p->type)));
+ if (ntohs(n.type) < 8192)
+ printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
+ else if (ntohs(n.type) < 16384)
+ printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type)));
+ else if (ntohs(n.type) < 24576)
+ printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
+ else if (ntohs(n.type) < 40960)
+ printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type)));
else
- printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
- if (p->spi_size) {
+ printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
+ if (n.spi_size) {
printf(" spi=");
- rawprint((caddr_t)(p + 1), p->spi_size);
+ rawprint((caddr_t)(p + 1), n.spi_size);
}
- cp = (u_char *)(p + 1) + p->spi_size;
- ep2 = (u_char *)p + ntohs(ext->len);
+ cp = (u_char *)(p + 1) + n.spi_size;
+ ep2 = (u_char *)p + ntohs(n.h.len);
if (cp < ep) {
printf(" orig=(");
- switch (ntohs(p->type)) {
+ switch (ntohs(n.type)) {
case IPSECDOI_NTYPE_RESPONDER_LIFETIME:
{
struct attrmap *map = oakley_t_map;
@@ -880,19 +966,19 @@ isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
default:
/* NULL is dummy */
isakmp_print(cp,
- ntohs(ext->len) - sizeof(*p) - p->spi_size,
+ ntohs(n.h.len) - sizeof(*p) - n.spi_size,
NULL);
}
printf(")");
}
- return (u_char *)ext + ntohs(ext->len);
+ return (u_char *)ext + ntohs(n.h.len);
}
static u_char *
isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
- struct isakmp_pl_d *p;
+ struct isakmp_pl_d *p, d;
u_int8_t *q;
u_int32_t doi;
u_int32_t proto;
@@ -901,8 +987,9 @@ isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_D));
p = (struct isakmp_pl_d *)ext;
- doi = ntohl(p->doi);
- proto = p->prot_id;
+ safememcpy(&d, ext, sizeof(d));
+ doi = ntohl(d.doi);
+ proto = d.prot_id;
if (doi != 1) {
printf(" doi=%u", doi);
printf(" proto=%u", proto);
@@ -910,15 +997,15 @@ isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf(" doi=ipsec");
printf(" proto=%s", PROTOIDSTR(proto));
}
- printf(" spilen=%u", p->spi_size);
- printf(" nspi=%u", ntohs(p->num_spi));
+ printf(" spilen=%u", d.spi_size);
+ printf(" nspi=%u", ntohs(d.num_spi));
printf(" spi=");
q = (u_int8_t *)(p + 1);
- for (i = 0; i < ntohs(p->num_spi); i++) {
+ for (i = 0; i < ntohs(d.num_spi); i++) {
if (i != 0)
printf(",");
- rawprint((caddr_t)q, p->spi_size);
- q += p->spi_size;
+ rawprint((caddr_t)q, d.spi_size);
+ q += d.spi_size;
}
return q;
}
@@ -927,14 +1014,17 @@ static u_char *
isakmp_vid_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
+ struct isakmp_gen e;
+
printf("%s:", NPSTR(ISAKMP_NPTYPE_VID));
- printf(" len=%d", ntohs(ext->len) - 4);
- if (2 < vflag && 4 < ntohs(ext->len)) {
+ safememcpy(&e, ext, sizeof(e));
+ printf(" len=%d", ntohs(e.len) - 4);
+ if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
- rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
- return (u_char *)ext + ntohs(ext->len);
+ return (u_char *)ext + ntohs(e.len);
}
static u_char *
@@ -942,14 +1032,16 @@ isakmp_sub0_print(u_char np, struct isakmp_gen *ext, u_char *ep,
u_int32_t phase, u_int32_t doi, u_int32_t proto)
{
u_char *cp;
+ struct isakmp_gen e;
cp = (u_char *)ext;
+ safememcpy(&e, ext, sizeof(e));
if (NPFUNC(np))
cp = (*NPFUNC(np))(ext, ep, phase, doi, proto);
else {
printf("%s", NPSTR(np));
- cp += ntohs(ext->len);
+ cp += ntohs(e.len);
}
return cp;
}
@@ -961,11 +1053,14 @@ isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep,
u_char *cp;
static int depth = 0;
int i;
+ struct isakmp_gen e;
cp = (u_char *)ext;
while (np) {
- if (ep < (u_char *)ext + ntohs(ext->len)) {
+ safememcpy(&e, ext, sizeof(e));
+
+ if (ep < (u_char *)ext + ntohs(e.len)) {
printf(" [|%s]", NPSTR(np));
cp = ep + 1;
break;
@@ -979,7 +1074,7 @@ isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep,
printf(")");
depth--;
- np = ext->np;
+ np = e.np;
ext = (struct isakmp_gen *)cp;
}
return cp;
@@ -989,63 +1084,76 @@ static char *
numstr(int x)
{
static char buf[20];
- sprintf(buf, "#%d", x);
+ snprintf(buf, sizeof(buf), "#%d", x);
return buf;
}
+/*
+ * some compiler tries to optimize memcpy(), using the alignment constraint
+ * on the argument pointer type. by using this function, we try to avoid the
+ * optimization.
+ */
+static void
+safememcpy(void *p, void *q, size_t l)
+{
+ memcpy(p, q, l);
+}
+
void
isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
{
- struct isakmp *base;
+ struct isakmp *p, base;
u_char *ep;
u_char np;
int i;
int phase;
int major, minor;
- base = (struct isakmp *)bp;
+ p = (struct isakmp *)bp;
ep = (u_char *)snapend;
- if ((struct isakmp *)ep < base + 1) {
+ if ((struct isakmp *)ep < p + 1) {
printf("[|isakmp]");
return;
}
+ safememcpy(&base, p, sizeof(base));
+
printf("isakmp");
if (vflag) {
- major = (base->vers & ISAKMP_VERS_MAJOR)
+ major = (base.vers & ISAKMP_VERS_MAJOR)
>> ISAKMP_VERS_MAJOR_SHIFT;
- minor = (base->vers & ISAKMP_VERS_MINOR)
+ minor = (base.vers & ISAKMP_VERS_MINOR)
>> ISAKMP_VERS_MINOR_SHIFT;
printf(" %d.%d", major, minor);
}
if (vflag) {
printf(" msgid ");
- rawprint((caddr_t)&base->msgid, sizeof(base->msgid));
+ rawprint((caddr_t)&base.msgid, sizeof(base.msgid));
}
if (1 < vflag) {
printf(" cookie ");
- rawprint((caddr_t)&base->i_ck, sizeof(base->i_ck));
+ rawprint((caddr_t)&base.i_ck, sizeof(base.i_ck));
printf("->");
- rawprint((caddr_t)&base->r_ck, sizeof(base->r_ck));
+ rawprint((caddr_t)&base.r_ck, sizeof(base.r_ck));
}
printf(":");
- phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
+ phase = (*(u_int32_t *)base.msgid == 0) ? 1 : 2;
if (phase == 1)
printf(" phase %d", phase);
else
printf(" phase %d/others", phase);
- i = cookie_find(&base->i_ck);
+ i = cookie_find(&base.i_ck);
if (i < 0) {
- if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) {
+ if (iszero((u_char *)&base.r_ck, sizeof(base.r_ck))) {
/* the first packet */
printf(" I");
if (bp2)
- cookie_record(&base->i_ck, bp2);
+ cookie_record(&base.i_ck, bp2);
} else
printf(" ?");
} else {
@@ -1057,10 +1165,10 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
printf(" ?");
}
- printf(" %s", ETYPESTR(base->etype));
- if (base->flags) {
- printf("[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
- base->flags & ISAKMP_FLAG_C ? "C" : "");
+ printf(" %s", ETYPESTR(base.etype));
+ if (base.flags) {
+ printf("[%s%s]", base.flags & ISAKMP_FLAG_E ? "E" : "",
+ base.flags & ISAKMP_FLAG_C ? "C" : "");
}
printf(":");
@@ -1075,28 +1183,28 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
}
/* regardless of phase... */
- if (base->flags & ISAKMP_FLAG_E) {
+ if (base.flags & ISAKMP_FLAG_E) {
/*
* encrypted, nothing we can do right now.
* we hope to decrypt the packet in the future...
*/
- printf(" [|%s]", NPSTR(base->np));
+ printf(" [|%s]", NPSTR(base.np));
goto done;
}
nparen = 0;
- CHECKLEN(base + 1, base->np)
+ CHECKLEN(p + 1, base.np)
- np = base->np;
- ext = (struct isakmp_gen *)(base + 1);
+ np = base.np;
+ ext = (struct isakmp_gen *)(p + 1);
isakmp_sub_print(np, ext, ep, phase, 0, 0);
}
done:
if (vflag) {
- if (ntohl(base->len) != length) {
+ if (ntohl(base.len) != length) {
printf(" (len mismatch: isakmp %u/ip %d)",
- (u_int32_t)ntohl(base->len), length);
+ (u_int32_t)ntohl(base.len), length);
}
}
}
diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c
index 9ac8fdf..aaf360a 100644
--- a/contrib/tcpdump/print-isoclns.c
+++ b/contrib/tcpdump/print-isoclns.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.16 1999/11/21 09:36:55 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.22 2000/10/11 04:04:33 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,33 +34,150 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "ether.h"
+#include "extract.h"
+
+#define NLPID_CLNS 129 /* 0x81 */
+#define NLPID_ESIS 130 /* 0x82 */
+#define NLPID_ISIS 131 /* 0x83 */
+#define NLPID_NULLNS 0
+
+
+/*
+ * IS-IS is defined in ISO 10589. Look there for protocol definitions.
+ */
+
+#define SYSTEM_ID_LEN ETHER_ADDR_LEN
+#define ISIS_VERSION 1
+#define PDU_TYPE_MASK 0x1F
+#define PRIORITY_MASK 0x7F
+
+#define L1_LAN_IIH 15
+#define L2_LAN_IIH 16
+#define PTP_IIH 17
+#define L1_LS_PDU 18
+#define L2_LS_PDU 19
+#define L1_COMPLETE_SEQ_PDU 24
+#define L2_COMPLETE_SEQ_PDU 25
-#define CLNS 129
-#define ESIS 130
-#define ISIS 131
-#define NULLNS 0
+/*
+ * A TLV is a tuple of a type, length and a value and is normally used for
+ * encoding information in all sorts of places. This is an enumeration of
+ * the well known types.
+ */
+
+#define TLV_AREA_ADDR 1
+#define TLV_IS_REACH 2
+#define TLV_ES_REACH 3
+#define TLV_SUMMARY 5
+#define TLV_ISNEIGH 6
+#define TLV_PADDING 8
+#define TLV_LSP 9
+#define TLV_AUTHENT 10
+#define TLV_IP_REACH 128
+#define TLV_PROTOCOLS 129
+#define TLV_IP_EXTERN 130
+#define TLV_IDRP_INFO 131
+#define TLV_IPADDR 132
+#define TLV_IPAUTH 133
+#define TLV_PTP_ADJ 240
-static int osi_cksum(const u_char *, u_int, const u_char *, u_char *, u_char *);
+/*
+ * Katz's point to point adjacency TLV uses codes to tell us the state of
+ * the remote adjacency. Enumerate them.
+ */
+
+#define ISIS_PTP_ADJ_UP 0
+#define ISIS_PTP_ADJ_INIT 1
+#define ISIS_PTP_ADJ_DOWN 2
+
+static int osi_cksum(const u_char *, int, u_char *);
static void esis_print(const u_char *, u_int);
+static int isis_print(const u_char *, u_int);
+
+
+struct isis_ptp_adjancey_values {
+ u_char id;
+ char *name;
+};
+
+static struct isis_ptp_adjancey_values isis_ptp_adjancey_values[] = {
+ { ISIS_PTP_ADJ_UP, "UP" },
+ { ISIS_PTP_ADJ_INIT, "INIT" },
+ { ISIS_PTP_ADJ_DOWN, "DOWN" }
+};
+
+struct isis_common_header {
+ u_char nlpid;
+ u_char fixed_len;
+ u_char version; /* Protocol version? */
+ u_char id_length;
+ u_char enc_pdu_type; /* 3 MSbs are reserved */
+ u_char pkt_version; /* Packet format version? */
+ u_char reserved;
+ u_char enc_max_area;
+};
+
+struct isis_header {
+ u_char nlpid;
+ u_char fixed_len;
+ u_char version; /* Protocol version? */
+ u_char id_length;
+ u_char enc_pdu_type; /* 3 MSbs are reserved */
+ u_char pkt_version; /* Packet format version? */
+ u_char reserved;
+ u_char enc_max_area;
+ u_char circuit;
+ u_char enc_source_id[SYSTEM_ID_LEN];
+ u_char enc_holding_time[2];
+ u_char enc_packet_len[2];
+ u_char enc_priority;
+ u_char enc_lan_id[SYSTEM_ID_LEN+1];
+};
+struct isis_lan_header {
+ u_char circuit;
+ u_char enc_source_id[SYSTEM_ID_LEN];
+ u_char enc_holding_time[2];
+ u_char enc_packet_len[2];
+ u_char enc_priority;
+ u_char enc_lan_id[SYSTEM_ID_LEN+1];
+};
+
+struct isis_ptp_header {
+ u_char circuit;
+ u_char enc_source_id[SYSTEM_ID_LEN];
+ u_char enc_holding_time[2];
+ u_char enc_packet_len[2];
+ u_char loc_circuit_id;
+};
+
+#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
+#define ISIS_HEADER_SIZE (15+(SYSTEM_ID_LEN<<1))
+#define ISIS_PTP_HEADER_SIZE (14+SYSTEM_ID_LEN)
+#define L1_LS_PDU_HEADER_SIZE (21+SYSTEM_ID_LEN)
+#define L2_LS_PDU_HEADER_SIZE L1_LS_PDU_HEADER_SIZE
+#define L1_COMPLETE_SEQ_PDU_HEADER_SIZE 33
+#define L2_COMPLETE_SEQ_PDU_HEADER_SIZE L1_COMPLETE_SEQ_PDU_HEADER_SIZE
+
+
void
isoclns_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst)
{
+ u_char pdu_type;
+ struct isis_header *header;
+
+ header = (struct isis_header *)p;
+ pdu_type = header->enc_pdu_type & PDU_TYPE_MASK;
+
if (caplen < 1) {
printf("[|iso-clns] ");
if (!eflag)
@@ -72,17 +189,16 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
switch (*p) {
- case CLNS:
- /* esis_print(&p, &length); */
- printf("iso-clns");
+ case NLPID_CLNS:
+ printf("iso clns");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
etheraddr_string(edst));
break;
- case ESIS:
- printf("iso-esis");
+ case NLPID_ESIS:
+ printf("iso esis");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@@ -90,20 +206,21 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
esis_print(p, length);
return;
- case ISIS:
- printf("iso-isis");
- if (!eflag)
- (void)printf(" %s > %s",
+ case NLPID_ISIS:
+ printf("iso isis");
+ if (!eflag) {
+ if(pdu_type != PTP_IIH)
+ (void)printf(" %s > %s",
etheraddr_string(esrc),
etheraddr_string(edst));
- /* isis_print(&p, &length); */
+ }
(void)printf(" len=%d ", length);
- if (caplen > 1)
- default_print_unaligned(p, caplen);
+ if (!isis_print(p, length))
+ default_print_unaligned(p, caplen);
break;
- case NULLNS:
- printf("iso-nullns");
+ case NLPID_NULLNS:
+ printf("iso nullns");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@@ -111,7 +228,7 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
break;
default:
- printf("iso-clns %02x", p[0]);
+ printf("iso clns %02x", p[0]);
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@@ -141,7 +258,6 @@ esis_print(const u_char *p, u_int length)
const u_char *ep;
int li = p[1];
const struct esis_hdr *eh = (const struct esis_hdr *) &p[2];
- u_char cksum[2];
u_char off[2];
if (length == 2) {
@@ -189,9 +305,10 @@ esis_print(const u_char *p, u_int length)
}
off[0] = eh->cksum[0];
off[1] = eh->cksum[1];
- if (vflag && osi_cksum(p, li, eh->cksum, cksum, off)) {
- printf(" bad cksum (got %02x%02x want %02x%02x)",
- eh->cksum[1], eh->cksum[0], cksum[1], cksum[0]);
+ if (vflag && osi_cksum(p, li, off)) {
+ printf(" bad cksum (got %02x%02x)",
+ eh->cksum[1], eh->cksum[0]);
+ default_print(p, length);
return;
}
if (eh->version != 1) {
@@ -208,7 +325,7 @@ esis_print(const u_char *p, u_int length)
dst = p; p += *p + 1;
if (p > snapend)
return;
- printf(" %s", isonsap_string(dst));
+ printf("\n\t\t\t %s", isonsap_string(dst));
snpa = p; p += *p + 1;
is = p; p += *p + 1;
if (p > snapend)
@@ -239,7 +356,8 @@ esis_print(const u_char *p, u_int length)
}
if (p > snapend)
return;
- printf(" %s", isonsap_string(is));
+ if (!qflag)
+ printf("\n\t\t\t %s", isonsap_string(is));
li = ep - p;
break;
}
@@ -286,36 +404,270 @@ esis_print(const u_char *p, u_int length)
}
}
+/*
+ * print_nsap
+ * Print out an NSAP.
+ */
+
+static void
+print_nsap (register const u_char *cp, register int length)
+{
+ int i;
+
+ for (i = 0; i < length; i++) {
+ printf("%02x", *cp++);
+ if (((i & 1) == 0) && (i + 1 < length)) {
+ printf(".");
+ }
+
+ }
+}
+
+/*
+ * isis_print
+ * Decode IS-IS packets. Return 0 on error.
+ *
+ * So far, this is only smart enough to print IIH's. Someday...
+ */
+
+static int
+isis_print (const u_char *p, u_int length)
+{
+ struct isis_header *header;
+ struct isis_ptp_header *header_ptp;
+ u_char pdu_type, max_area, priority, type, len, tmp, alen;
+ const u_char *pptr, *tptr;
+ u_short packet_len, holding_time;
+ int i;
+
+ header = (struct isis_header *)p;
+ header_ptp = (struct isis_ptp_header *)header;
+ printf("\n\t\t\t");
+
+ /*
+ * Sanity checking of the header.
+ */
+ if (header->nlpid != NLPID_ISIS) {
+ printf(" coding error!");
+ return(0);
+ }
+
+ if (header->version != ISIS_VERSION) {
+ printf(" version %d packet not supported", header->version);
+ return(0);
+ }
+
+ if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) {
+ printf(" system ID length of %d is not supported",
+ header->id_length);
+ return(0);
+ }
+
+ if ((header->fixed_len != ISIS_HEADER_SIZE) &&
+ (header->fixed_len != ISIS_PTP_HEADER_SIZE) &&
+ (header->fixed_len != L1_LS_PDU_HEADER_SIZE) &&
+ (header-> fixed_len != L1_COMPLETE_SEQ_PDU_HEADER_SIZE) ) {
+ printf(" bogus fixed header length %u",
+ header->fixed_len);
+ return(0);
+ }
+
+ pdu_type = header->enc_pdu_type & PDU_TYPE_MASK;
+ if ((pdu_type != L1_LAN_IIH) && (pdu_type != L2_LAN_IIH) &&
+ (pdu_type != PTP_IIH) &&
+ (pdu_type != L1_COMPLETE_SEQ_PDU) &&
+ (pdu_type != L2_COMPLETE_SEQ_PDU) ) {
+ printf(" PDU type (%d) not supported", pdu_type);
+ return(0);
+ }
+
+ if (header->pkt_version != ISIS_VERSION) {
+ printf(" version %d packet not supported", header->pkt_version);
+ return(0);
+ }
+
+ max_area = header->enc_max_area;
+ switch(max_area) {
+ case 0:
+ max_area = 3; /* silly shit */
+ break;
+ case 255:
+ printf(" bad packet -- 255 areas");
+ return(0);
+ default:
+ break;
+ }
+
+ switch (header->circuit) {
+ case 0:
+ printf(" PDU with circuit type 0");
+ return(0);
+ case 1:
+ if (pdu_type == L2_LAN_IIH) {
+ printf(" L2 IIH on an L1 only circuit");
+ return(0);
+ }
+ break;
+ case 2:
+ if (pdu_type == L1_LAN_IIH) {
+ printf(" L1 IIH on an L2 only circuit");
+ return(0);
+ }
+ break;
+ case 3:
+ break;
+ default:
+ printf(" unknown circuit type");
+ return(0);
+ }
+
+ holding_time = EXTRACT_16BITS(header->enc_holding_time);
+
+ packet_len = EXTRACT_16BITS(header->enc_packet_len);
+ if ((packet_len < ISIS_HEADER_SIZE) ||
+ (packet_len > length)) {
+ printf(" bogus packet length %d, real length %d", packet_len,
+ length);
+ return(0);
+ }
+
+ if(pdu_type != PTP_IIH)
+ priority = header->enc_priority & PRIORITY_MASK;
+
+ /*
+ * Now print the fixed header.
+ */
+ switch (pdu_type) {
+ case L1_LAN_IIH:
+ printf(" L1 lan iih, ");
+ break;
+ case L2_LAN_IIH:
+ printf(" L2 lan iih, ");
+ break;
+ case PTP_IIH:
+ printf(" PTP iih, ");
+ break;
+ }
+
+ printf("circuit ");
+ switch (header->circuit) {
+ case 1:
+ printf("l1 only, ");
+ break;
+ case 2:
+ printf("l2 only, ");
+ break;
+ case 3:
+ printf("l1-l2, ");
+ break;
+ }
+
+ printf ("holding time %d ", holding_time);
+ printf ("\n\t\t\t source %s, length %d",
+ etheraddr_string(header->enc_source_id), packet_len);
+ if((pdu_type==L1_LAN_IIH)||(pdu_type==L2_LAN_IIH))
+ printf ("\n\t\t\t lan id %s(%d)", etheraddr_string(header->enc_lan_id),
+ header->enc_lan_id[SYSTEM_ID_LEN]);
+
+ /*
+ * Now print the TLV's.
+ */
+ if(pdu_type==PTP_IIH) {
+ packet_len -= ISIS_PTP_HEADER_SIZE;
+ pptr = p + ISIS_PTP_HEADER_SIZE;
+ } else {
+ packet_len -= ISIS_HEADER_SIZE;
+ pptr = p + ISIS_HEADER_SIZE;
+ }
+ while (packet_len >= 2) {
+ if (pptr >= snapend) {
+ printf("\n\t\t\t packet exceeded snapshot");
+ return(1);
+ }
+ type = *pptr++;
+ len = *pptr++;
+ packet_len -= 2;
+ if (len > packet_len) {
+ break;
+ }
+
+ switch (type) {
+ case TLV_AREA_ADDR:
+ printf("\n\t\t\t area addresses");
+ tmp = len;
+ tptr = pptr;
+ alen = *tptr++;
+ while (tmp && alen < tmp) {
+ printf("\n\t\t\t ");
+ print_nsap(tptr, alen);
+ printf(" (%d)", alen);
+ tptr += alen;
+ tmp -= alen + 1;
+ alen = *tptr++;
+ }
+ break;
+ case TLV_ISNEIGH:
+ printf("\n\t\t\t neighbor addresses");
+ tmp = len;
+ tptr = pptr;
+ while (tmp >= ETHER_ADDR_LEN) {
+ printf("\n\t\t\t %s", etheraddr_string(tptr));
+ tmp -= ETHER_ADDR_LEN;
+ tptr += ETHER_ADDR_LEN;
+ }
+ break;
+ case TLV_PADDING:
+ printf("\n\t\t\t padding for %d bytes", len);
+ break;
+ case TLV_AUTHENT:
+ printf("\n\t\t\t authentication data");
+ default_print(pptr, len);
+ break;
+ case TLV_PTP_ADJ:
+ printf("\n\t\t\t PTP adjacency status %s",
+ isis_ptp_adjancey_values[*pptr].name);
+ break;
+ case TLV_PROTOCOLS:
+ printf("\n\t\t\t Supports protocols %s", (len>1)? "are":"is");
+ for(i=0;i<len;i++)
+ printf(" %02X", (u_char)*(pptr+i));
+ break;
+ case TLV_IPADDR:
+ printf("\n\t\t\t IP address: %s", ipaddr_string(pptr));
+ break;
+ default:
+ printf("\n\t\t\t unknown TLV, type %d, length %d", type, len);
+ break;
+ }
+
+ pptr += len;
+ packet_len -= len;
+ }
+
+ if (packet_len != 0) {
+ printf("\n\t\t\t %d straggler bytes", packet_len);
+ }
+ return(1);
+}
+
+/*
+ * Verify the checksum. See 8473-1, Appendix C, section C.4.
+ */
+
static int
-osi_cksum(register const u_char *p, register u_int len,
- const u_char *toff, u_char *cksum, u_char *off)
+osi_cksum(register const u_char *p, register int len, u_char *off)
{
- int x, y, f = (len - ((toff - p) + 1));
int32_t c0 = 0, c1 = 0;
- if ((cksum[0] = off[0]) == 0 && (cksum[1] = off[1]) == 0)
+ if ((off[0] == 0) && (off[1] == 0))
return 0;
off[0] = off[1] = 0;
while ((int)--len >= 0) {
c0 += *p++;
- c1 += c0;
c0 %= 255;
+ c1 += c0;
c1 %= 255;
}
- x = (c0 * f - c1);
- if (x < 0)
- x = 255 - (-x % 255);
- else
- x %= 255;
- y = -1 * (x + c0);
- if (y < 0)
- y = 255 - (-y % 255);
- else
- y %= 255;
-
- off[0] = x;
- off[1] = y;
-
- return (off[0] != cksum[0] || off[1] != cksum[1]);
+ return (c0 | c1);
}
diff --git a/contrib/tcpdump/print-krb.c b/contrib/tcpdump/print-krb.c
index 694e5b5..67f440a 100644
--- a/contrib/tcpdump/print-krb.c
+++ b/contrib/tcpdump/print-krb.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.12 1999/11/21 09:36:55 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.15 2000/09/29 04:58:42 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,11 +35,6 @@ static const char rcsid[] =
#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 <ctype.h>
#include <errno.h>
diff --git a/contrib/tcpdump/print-l2tp.c b/contrib/tcpdump/print-l2tp.c
index 94d7188..d054308 100644
--- a/contrib/tcpdump/print-l2tp.c
+++ b/contrib/tcpdump/print-l2tp.c
@@ -18,12 +18,12 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * L2TP support contributed by Motonori Shindo (mshindo@ascend.co.jp)
+ * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.6 1999/12/22 06:27:21 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.8 2000/08/18 07:44:46 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -303,7 +303,7 @@ l2tp_bearer_cap_print(const u_char *dat, u_int length)
static void
l2tp_tie_breaker_print(const u_char *dat, u_int length)
{
- printf("%lx", *(u_long *)dat); /* XXX */
+ print_octets(dat, 8); /* Tie Break Value is 64bits long */
}
static void
@@ -592,23 +592,30 @@ l2tp_avp_print(const u_char *dat, u_int length)
}
ptr++;
- if (ntohs(*ptr)) { /* IETF == 0 */
- printf("vendor=%04x", ntohs(*ptr));
- }
- ptr++;
-
- if (ntohs(*ptr) < L2TP_MAX_AVP_INDEX) {
- printf("%s", l2tp_avp[ntohs(*ptr)].name);
+ if (ntohs(*ptr)) {
+ /* Vendor Specific Attribute */
+ printf("VENDOR%04x:", ntohs(*ptr));
+ ptr++;
+ printf("ATTR%04x", ntohs(*ptr));
printf("(");
- if (!hidden) {
- (l2tp_avp[ntohs(*ptr)].print)
- ((u_char *)ptr+2, len-6);
- } else {
- printf("???");
- }
+ print_octets((u_char *)ptr+2, len-6);
printf(")");
} else {
- printf(" invalid AVP %u", ntohs(*ptr));
+ /* IETF-defined Attribute */
+ ptr++;
+ if (ntohs(*ptr) < L2TP_MAX_AVP_INDEX) {
+ printf("%s", l2tp_avp[ntohs(*ptr)].name);
+ printf("(");
+ if (!hidden) {
+ (l2tp_avp[ntohs(*ptr)].print)
+ ((u_char *)ptr+2, len-6);
+ } else {
+ printf("???");
+ }
+ printf(")");
+ } else {
+ printf(" invalid AVP %u", ntohs(*ptr));
+ }
}
l2tp_avp_print(dat + len, length - len);
@@ -705,12 +712,8 @@ l2tp_print(const u_char *dat, u_int length)
l2tp_avp_print((u_char *)ptr, length - cnt);
}
} else {
-#if 0
printf(" {");
- ppp_hdlc_print((u_char *)ptr, length - cnt);
+ ppp_print((u_char *)ptr, length - cnt);
printf("}");
-#else
- printf("[hdlc|]");
-#endif
}
}
diff --git a/contrib/tcpdump/print-lane.c b/contrib/tcpdump/print-lane.c
index 19061de..db38ef7 100644
--- a/contrib/tcpdump/print-lane.c
+++ b/contrib/tcpdump/print-lane.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.2 1999/11/21 09:36:56 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.11 2000/12/22 22:45:11 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,28 +34,17 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.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>
#include <stdio.h>
#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
+#include "ether.h"
#include "lane.h"
-static const u_char *packetp;
-static const u_char *snapend;
-
static inline void
lane_print(register const u_char *bp, int length)
{
@@ -123,10 +112,11 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
extracted_ethertype = 0;
if (ether_type < ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ep->h_source,ep->h_dest)==0) {
+ if (llc_print(p, length, caplen, ep->h_source, ep->h_dest,
+ &extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- lane_print((u_char *)ep, length);
+ lane_print((u_char *)ep, length + sizeof(*ep));
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@@ -134,7 +124,8 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (!xflag && !qflag)
default_print(p, caplen);
}
- } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
+ } else if (ether_encap_print(ether_type, p, length, caplen,
+ &extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
lane_print((u_char *)ep, length + sizeof(*ep));
diff --git a/contrib/tcpdump/print-lcp.c b/contrib/tcpdump/print-lcp.c
index 78f353a..ddea9c6 100644
--- a/contrib/tcpdump/print-lcp.c
+++ b/contrib/tcpdump/print-lcp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lcp.c,v 1.3 1999/12/15 07:55:42 fenner Exp $ (LBL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-lcp.c,v 1.9 2000/10/06 04:23:12 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,18 +32,8 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
@@ -144,7 +134,7 @@ lcp_print(register const u_char *bp, u_int length)
printf("LCP %s id=0x%x", tok2str(lcpcode2str, "LCP-#%d", lcp_code), lcp_id);
- switch(lcp_code) {
+ switch (lcp_code) {
case LCP_CONFREQ:
case LCP_CONFACK:
case LCP_CONFNAK:
@@ -181,7 +171,7 @@ lcp_print(register const u_char *bp, u_int length)
case LCP_ASYNCMAP:
case LCP_MAGICNUM:
if (snapend < p+4) return;
- printf("%#x",ntohl(*(u_long*)p));
+ printf("%#x", (unsigned)ntohl(*(u_long*)p));
if (lcpopt_length != 6) printf(" len=%d!",lcpopt_length);
break;
case LCP_PCOMP:
@@ -202,7 +192,7 @@ lcp_print(register const u_char *bp, u_int length)
case LCP_ECHOREP:
case LCP_DISCARD:
if (snapend < lcp_data+4) return;
- printf(" magic=%#x", ntohl(*(u_long *) lcp_data));
+ printf(" magic=%#x", (unsigned)ntohl(*(u_long *) lcp_data));
lcp_data +=4;
break;
case LCP_PROTREJ:
diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c
index 19f9f86..988fdfe 100644
--- a/contrib/tcpdump/print-llc.c
+++ b/contrib/tcpdump/print-llc.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.27 1999/12/22 06:27:21 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.32 2000/12/18 07:55:36 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -64,10 +64,11 @@ static struct tok cmd2str[] = {
*/
int
llc_print(const u_char *p, u_int length, u_int caplen,
- const u_char *esrc, const u_char *edst)
+ const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
{
struct llc llc;
register u_short et;
+ u_int16_t control;
register int ret;
if (caplen < 3) {
@@ -83,13 +84,61 @@ llc_print(const u_char *p, u_int length, u_int caplen,
ipx_print(p, length);
return (1);
}
- if (llc.ssap == 0xf0 && llc.dsap == 0xf0) {
+
+ /* Cisco Discovery Protocol - SNAP & ether type 0x2000 */
+ if(llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP &&
+ llc.llcui == LLC_UI &&
+ llc.ethertype[0] == 0x20 && llc.ethertype[1] == 0x00 ) {
+ cdp_print( p, length, caplen, esrc, edst);
+ return (1);
+ }
+
+ if (llc.ssap == LLCSAP_8021D && llc.dsap == LLCSAP_8021D) {
+ stp_print(p, length);
+ return (1);
+ }
+ if (llc.ssap == 0xf0 && llc.dsap == 0xf0
+ && (!(llc.llcu & LLC_S_FMT) || llc.llcu == LLC_U_FMT)) {
/*
* we don't actually have a full netbeui parser yet, but the
* smb parser can handle many smb-in-netbeui packets, which
* is very useful, so we call that
+ *
+ * We don't call it for S frames, however, just I frames
+ * (which are frames that don't have the low-order bit,
+ * LLC_S_FMT, set in the first byte of the control field)
+ * and UI frames (whose control field is just 3, LLC_U_FMT).
+ */
+
+ /*
+ * Skip the DSAP and LSAP.
+ */
+ p += 2;
+ length -= 2;
+ caplen -= 2;
+
+ /*
+ * OK, what type of LLC frame is this? The length
+ * of the control field depends on that - I frames
+ * have a two-byte control field, and U frames have
+ * a one-byte control field.
*/
- netbeui_print(p + 2, p + min(caplen, length));
+ if (llc.llcu == LLC_U_FMT) {
+ control = llc.llcu;
+ p += 1;
+ length -= 1;
+ caplen -= 1;
+ } else {
+ /*
+ * The control field in I and S frames is
+ * little-endian.
+ */
+ control = EXTRACT_LE_16BITS(&llc.llcu);
+ p += 2;
+ length -= 2;
+ caplen -= 2;
+ }
+ netbeui_print(control, p, p + min(caplen, length));
return (1);
}
if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
@@ -114,7 +163,8 @@ llc_print(const u_char *p, u_int length, u_int caplen,
/* This is an encapsulated Ethernet packet */
et = EXTRACT_16BITS(&llc.ethertype[0]);
- ret = ether_encap_print(et, p, length, caplen);
+ ret = ether_encap_print(et, p, length, caplen,
+ extracted_ethertype);
if (ret)
return (ret);
}
@@ -141,9 +191,12 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
if ((llc.llcu & LLC_U_FMT) == LLC_U_FMT) {
+ u_int16_t cmd;
const char *m;
char f;
- m = tok2str(cmd2str, "%02x", LLC_U_CMD(llc.llcu));
+
+ cmd = LLC_U_CMD(llc.llcu);
+ m = tok2str(cmd2str, "%02x", cmd);
switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
@@ -167,35 +220,38 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
}
- if (!strcmp(m,"ui") && f=='C') {
+ if (cmd == LLC_UI && f == 'C') {
/*
* we don't have a proper ipx decoder yet, but there
* is a partial one in the smb code
*/
ipx_netbios_print(p,p+min(caplen,length));
}
-
} else {
char f;
- llc.llcis = ntohs(llc.llcis);
- switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
+
+ /*
+ * The control field in I and S frames is little-endian.
+ */
+ control = EXTRACT_LE_16BITS(&llc.llcu);
+ switch ((llc.ssap & LLC_GSAP) | (control & LLC_IS_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
- case LLC_U_POLL: f = 'P'; break;
- case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
+ case LLC_IS_POLL: f = 'P'; break;
+ case LLC_GSAP|LLC_IS_POLL: f = 'F'; break;
default: f = '?'; break;
}
- if ((llc.llcu & LLC_S_FMT) == LLC_S_FMT) {
+ if ((control & LLC_S_FMT) == LLC_S_FMT) {
static char *llc_s[] = { "rr", "rej", "rnr", "03" };
(void)printf("%s (r=%d,%c)",
- llc_s[LLC_S_CMD(llc.llcis)],
- LLC_IS_NR(llc.llcis),
+ llc_s[LLC_S_CMD(control)],
+ LLC_IS_NR(control),
f);
} else {
(void)printf("I (s=%d,r=%d,%c)",
- LLC_I_NS(llc.llcis),
- LLC_IS_NR(llc.llcis),
+ LLC_I_NS(control),
+ LLC_IS_NR(control),
f);
}
p += 4;
diff --git a/contrib/tcpdump/print-mobile.c b/contrib/tcpdump/print-mobile.c
index 4c09ace..a6116f6 100644
--- a/contrib/tcpdump/print-mobile.c
+++ b/contrib/tcpdump/print-mobile.c
@@ -42,7 +42,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.2.2.1 2000/01/11 06:58:26 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.5 2000/09/29 04:58:43 guy Exp $";
#endif
#include <sys/param.h>
@@ -51,8 +51,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include <netdb.h>
#include <stdio.h>
diff --git a/contrib/tcpdump/print-netbios.c b/contrib/tcpdump/print-netbios.c
index fbf22fb..c834729 100644
--- a/contrib/tcpdump/print-netbios.c
+++ b/contrib/tcpdump/print-netbios.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.13 1999/11/21 09:36:57 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.17 2000/09/29 04:58:43 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,17 +35,8 @@ static const char rcsid[] =
#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 __STDC__
+
#include <stdlib.h>
-#endif
#include <stdio.h>
#include <string.h>
diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c
index ccfb52b..b520160 100644
--- a/contrib/tcpdump/print-nfs.c
+++ b/contrib/tcpdump/print-nfs.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.69 1999/12/15 06:57:25 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.87 2000/10/07 05:53:12 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,16 +32,10 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include <rpc/rpc.h>
@@ -56,14 +50,20 @@ struct rtentry;
#include "nfs.h"
#include "nfsfh.h"
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
static void nfs_printfh(const u_int32_t *, const u_int);
-static void xid_map_enter(const struct rpc_msg *, const struct ip *);
-static int32_t xid_map_find(const struct rpc_msg *, const struct ip *,
+static void xid_map_enter(const struct rpc_msg *, const u_char *);
+static int32_t xid_map_find(const struct rpc_msg *, const u_char *,
u_int32_t *, u_int32_t *);
static void interp_reply(const struct rpc_msg *, u_int32_t, u_int32_t, int);
static const u_int32_t *parse_post_op_attr(const u_int32_t *, int);
static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose);
static int print_int64(const u_int32_t *dp, int how);
+static void print_nfsaddr(const u_char *, const char *, const char *);
/*
* Mapping of old NFS Version 2 RPC numbers to generic numbers.
@@ -97,10 +97,60 @@ u_int32_t nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NOOP
};
-const char *nfsv3_writemodes[NFSV3WRITE_NMODES] = {
- "unstable",
- "datasync",
- "filesync"
+/*
+ * NFS V2 and V3 status values.
+ *
+ * Some of these come from the RFCs for NFS V2 and V3, with the message
+ * strings taken from the FreeBSD C library "errlst.c".
+ *
+ * Others are errors that are not in the RFC but that I suspect some
+ * NFS servers could return; the values are FreeBSD errno values, as
+ * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
+ * was primarily BSD-derived.
+ */
+static struct tok status2str[] = {
+ { 1, "Operation not permitted" }, /* EPERM */
+ { 2, "No such file or directory" }, /* ENOENT */
+ { 5, "Input/output error" }, /* EIO */
+ { 6, "Device not configured" }, /* ENXIO */
+ { 11, "Resource deadlock avoided" }, /* EDEADLK */
+ { 12, "Cannot allocate memory" }, /* ENOMEM */
+ { 13, "Permission denied" }, /* EACCES */
+ { 17, "File exists" }, /* EEXIST */
+ { 18, "Cross-device link" }, /* EXDEV */
+ { 19, "Operation not supported by device" }, /* ENODEV */
+ { 20, "Not a directory" }, /* ENOTDIR */
+ { 21, "Is a directory" }, /* EISDIR */
+ { 22, "Invalid argument" }, /* EINVAL */
+ { 26, "Text file busy" }, /* ETXTBSY */
+ { 27, "File too large" }, /* EFBIG */
+ { 28, "No space left on device" }, /* ENOSPC */
+ { 30, "Read-only file system" }, /* EROFS */
+ { 31, "Too many links" }, /* EMLINK */
+ { 45, "Operation not supported" }, /* EOPNOTSUPP */
+ { 62, "Too many levels of symbolic links" }, /* ELOOP */
+ { 63, "File name too long" }, /* ENAMETOOLONG */
+ { 66, "Directory not empty" }, /* ENOTEMPTY */
+ { 69, "Disc quota exceeded" }, /* EDQUOT */
+ { 70, "Stale NFS file handle" }, /* ESTALE */
+ { 71, "Too many levels of remote in path" }, /* EREMOTE */
+ { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */
+ { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */
+ { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */
+ { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */
+ { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */
+ { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */
+ { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */
+ { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */
+ { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */
+ { 0, NULL }
+};
+
+static struct tok nfsv3_writemodes[] = {
+ { 0, "unstable" },
+ { 1, "datasync" },
+ { 2, "filesync" },
+ { 0, NULL }
};
static struct tok type2str[] = {
@@ -148,74 +198,102 @@ static int print_int64(const u_int32_t *dp, int how)
}
#else
switch (how) {
- case SIGNED :
- case UNSIGNED :
- case HEX :
- printf ("0x%x%08x", dp[0], dp[1]);
- break;
- default :
- return (0);
+ case SIGNED:
+ case UNSIGNED:
+ case HEX:
+ printf("0x%x%08x", (u_int32_t)ntohl(dp[0]),
+ (u_int32_t)ntohl(dp[1]));
+ break;
+ default:
+ return (0);
}
#endif
return 1;
}
+static void
+print_nfsaddr(const u_char *bp, const char *s, const char *d)
+{
+ struct ip *ip;
+#ifdef INET6
+ struct ip6_hdr *ip6;
+ char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN];
+#else
+#ifndef INET_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#endif
+ char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN];
+#endif
+
+ srcaddr[0] = dstaddr[0] = '\0';
+ switch (IP_V((struct ip *)bp)) {
+ case 4:
+ ip = (struct ip *)bp;
+ strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr));
+ strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr));
+ break;
+#ifdef INET6
+ case 6:
+ ip6 = (struct ip6_hdr *)bp;
+ strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src),
+ sizeof(srcaddr));
+ strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst),
+ sizeof(dstaddr));
+ break;
+#endif
+ default:
+ strlcpy(srcaddr, "?", sizeof(srcaddr));
+ strlcpy(dstaddr, "?", sizeof(dstaddr));
+ break;
+ }
+
+ (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d);
+}
+
static const u_int32_t *
parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3)
{
- register const u_int32_t *ep = (u_int32_t *)snapend;
-
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
if ((sa3->sa_modeset = ntohl(*dp++))) {
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
sa3->sa_mode = ntohl(*dp++);
}
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
if ((sa3->sa_uidset = ntohl(*dp++))) {
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
sa3->sa_uid = ntohl(*dp++);
}
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
if ((sa3->sa_gidset = ntohl(*dp++))) {
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
sa3->sa_gid = ntohl(*dp++);
}
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
if ((sa3->sa_sizeset = ntohl(*dp++))) {
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
sa3->sa_size = ntohl(*dp++);
}
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
- if (dp + 2 > ep)
- return (0);
+ TCHECK(dp[1]);
sa3->sa_atime.nfsv3_sec = ntohl(*dp++);
sa3->sa_atime.nfsv3_nsec = ntohl(*dp++);
}
- if (dp + 1 > ep)
- return (0);
+ TCHECK(dp[0]);
if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
- if (dp + 2 > ep)
- return (0);
+ TCHECK(dp[1]);
sa3->sa_mtime.nfsv3_sec = ntohl(*dp++);
sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++);
}
return dp;
+trunc:
+ return NULL;
}
static int nfserr; /* true if we error rather than trunc */
@@ -244,32 +322,28 @@ nfsreply_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
register const struct rpc_msg *rp;
- register const struct ip *ip;
- u_int32_t proc, vers;
+ u_int32_t proc, vers;
+ char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
- ip = (const struct ip *)bp2;
-
- if (!nflag)
- (void)printf("%s.nfs > %s.%u: reply %s %d",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst),
- (u_int32_t)ntohl(rp->rm_xid),
- ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
- "ok":"ERR",
- length);
- else
- (void)printf("%s.%u > %s.%u: reply %s %d",
- ipaddr_string(&ip->ip_src),
- NFS_PORT,
- ipaddr_string(&ip->ip_dst),
- (u_int32_t)ntohl(rp->rm_xid),
- ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
- "ok":"ERR",
+
+ if (!nflag) {
+ strlcpy(srcid, "nfs", sizeof(srcid));
+ snprintf(dstid, sizeof(dstid), "%u",
+ (u_int32_t)ntohl(rp->rm_xid));
+ } else {
+ snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
+ snprintf(dstid, sizeof(dstid), "%u",
+ (u_int32_t)ntohl(rp->rm_xid));
+ }
+ print_nfsaddr(bp2, srcid, dstid);
+ (void)printf("reply %s %d",
+ ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
+ "ok":"ERR",
length);
- if (xid_map_find(rp, ip, &proc, &vers) >= 0)
+ if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
interp_reply(rp, proc, vers, length);
}
@@ -313,17 +387,17 @@ parsefh(register const u_int32_t *dp, int v3)
int len;
if (v3) {
- if (dp + 1 > (u_int32_t *)snapend)
- return (0);
+ TCHECK(dp[0]);
len = (int)ntohl(*dp) / 4;
dp++;
} else
len = NFSX_V2FH / 4;
- if (dp + len <= (u_int32_t *)snapend) {
+ if (TTEST2(*dp, len * sizeof(*dp))) {
nfs_printfh(dp, len);
return (dp + len);
}
+trunc:
return (NULL);
}
@@ -338,24 +412,25 @@ parsefn(register const u_int32_t *dp)
register const u_char *cp;
/* Bail if we don't have the string length */
- if ((u_char *)dp > snapend - sizeof(*dp))
- return (NULL);
+ TCHECK(*dp);
/* Fetch string length; convert to host order */
len = *dp++;
NTOHL(len);
+ TCHECK2(*dp, ((len + 3) & ~3));
+
cp = (u_char *)dp;
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
- if ((u_char *)dp > snapend)
- return (NULL);
/* XXX seems like we should be checking the length */
putchar('"');
(void) fn_printn(cp, len, NULL);
putchar('"');
return (dp);
+trunc:
+ return NULL;
}
/*
@@ -378,31 +453,28 @@ nfsreq_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
register const struct rpc_msg *rp;
- register const struct ip *ip;
register const u_int32_t *dp;
- nfstype type;
+ nfs_type type;
int v3;
u_int32_t proc;
struct nfsv3_sattr sa3;
+ char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
- ip = (const struct ip *)bp2;
- if (!nflag)
- (void)printf("%s.%u > %s.nfs: %d",
- ipaddr_string(&ip->ip_src),
- (u_int32_t)ntohl(rp->rm_xid),
- ipaddr_string(&ip->ip_dst),
- length);
- else
- (void)printf("%s.%u > %s.%u: %d",
- ipaddr_string(&ip->ip_src),
- (u_int32_t)ntohl(rp->rm_xid),
- ipaddr_string(&ip->ip_dst),
- NFS_PORT,
- length);
+ if (!nflag) {
+ snprintf(srcid, sizeof(srcid), "%u",
+ (u_int32_t)ntohl(rp->rm_xid));
+ strlcpy(dstid, "nfs", sizeof(dstid));
+ } else {
+ snprintf(srcid, sizeof(srcid), "%u",
+ (u_int32_t)ntohl(rp->rm_xid));
+ snprintf(dstid, sizeof(dstid), "%u", NFS_PORT);
+ }
+ print_nfsaddr(bp2, srcid, dstid);
+ (void)printf("%d", length);
- xid_map_enter(rp, ip); /* record proc number for later on */
+ xid_map_enter(rp, bp2); /* record proc number for later on */
v3 = (ntohl(rp->rm_call.cb_vers) == NFS_VER3);
proc = ntohl(rp->rm_call.cb_proc);
@@ -443,8 +515,8 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" access");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
- TCHECK2(dp[0], 4);
- printf(" %04x", ntohl(dp[0]));
+ TCHECK(dp[0]);
+ printf(" %04x", (u_int32_t)ntohl(dp[0]));
return;
}
break;
@@ -461,16 +533,16 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
if (v3) {
- TCHECK2(dp[0], 3 * sizeof(*dp));
+ TCHECK(dp[2]);
printf(" %u bytes @ ",
(u_int32_t) ntohl(dp[2]));
print_int64(dp, UNSIGNED);
} else {
- TCHECK2(dp[0], 2 * sizeof(*dp));
- printf(" %u bytes @ %u",
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
- }
+ TCHECK(dp[1]);
+ printf(" %u bytes @ %u",
+ (u_int32_t)ntohl(dp[1]),
+ (u_int32_t)ntohl(dp[0]));
+ }
return;
}
break;
@@ -480,23 +552,24 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
if (v3) {
- TCHECK2(dp[0], 3 * sizeof(*dp));
+ TCHECK(dp[4]);
printf(" %u bytes @ ",
- (u_int32_t) ntohl(dp[4]));
+ (u_int32_t) ntohl(dp[4]));
print_int64(dp, UNSIGNED);
if (vflag) {
dp += 3;
- TCHECK2(dp[0], sizeof(*dp));
+ TCHECK(dp[0]);
printf(" <%s>",
- nfsv3_writemodes[ntohl(*dp)]);
+ tok2str(nfsv3_writemodes,
+ NULL, ntohl(*dp)));
}
} else {
- TCHECK2(dp[0], 4 * sizeof(*dp));
- printf(" %u (%u) bytes @ %u (%u)",
- (u_int32_t)ntohl(dp[3]),
- (u_int32_t)ntohl(dp[2]),
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ TCHECK(dp[3]);
+ printf(" %u (%u) bytes @ %u (%u)",
+ (u_int32_t)ntohl(dp[3]),
+ (u_int32_t)ntohl(dp[2]),
+ (u_int32_t)ntohl(dp[1]),
+ (u_int32_t)ntohl(dp[0]));
}
return;
}
@@ -526,7 +599,7 @@ nfsreq_print(register const u_char *bp, u_int length,
break;
if (v3 && vflag)
print_sattr3(&sa3, vflag);
- return;
+ return;
}
break;
@@ -534,21 +607,21 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" mknod");
if ((dp = parsereq(rp, length)) != 0 &&
(dp = parsefhn(dp, v3)) != 0) {
- if (dp + 1 > (u_int32_t *)snapend)
- break;
- type = (nfstype)ntohl(*dp++);
+ TCHECK(*dp);
+ type = (nfs_type)ntohl(*dp++);
if ((dp = parse_sattr3(dp, &sa3)) == 0)
break;
printf(" %s", tok2str(type2str, "unk-ft %d", type));
if (vflag && (type == NFCHR || type == NFBLK)) {
- if (dp + 2 > (u_int32_t *)snapend)
- break;
- printf(" %u/%u", ntohl(dp[0]), ntohl(dp[1]));
+ TCHECK(dp[1]);
+ printf(" %u/%u",
+ (u_int32_t)ntohl(dp[0]),
+ (u_int32_t)ntohl(dp[1]));
dp += 2;
}
if (vflag)
print_sattr3(&sa3, vflag);
- return;
+ return;
}
break;
@@ -556,7 +629,7 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" remove");
if ((dp = parsereq(rp, length)) != NULL &&
parsefhn(dp, v3) != NULL)
- return;
+ return;
break;
case NFSPROC_RMDIR:
@@ -582,7 +655,7 @@ nfsreq_print(register const u_char *bp, u_int length,
(dp = parsefh(dp, v3)) != NULL) {
fputs(" ->", stdout);
if (parsefhn(dp, v3) != NULL)
- return;
+ return;
}
break;
@@ -591,7 +664,7 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
if (v3) {
- TCHECK2(dp[0], 20);
+ TCHECK(dp[4]);
/*
* We shouldn't really try to interpret the
* offset cookie here.
@@ -603,14 +676,14 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" verf %08x%08x", dp[2],
dp[3]);
} else {
- TCHECK2(dp[0], 2 * sizeof(*dp));
- /*
+ TCHECK(dp[1]);
+ /*
* Print the offset as signed, since -1 is
* common, but offsets > 2^31 aren't.
- */
- printf(" %u bytes @ %d",
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ */
+ printf(" %u bytes @ %d",
+ (u_int32_t)ntohl(dp[1]),
+ (u_int32_t)ntohl(dp[0]));
}
return;
}
@@ -620,7 +693,7 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" readdirplus");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
- TCHECK2(dp[0], 20);
+ TCHECK(dp[4]);
/*
* We don't try to interpret the offset
* cookie here.
@@ -663,6 +736,7 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" proc-%u", (u_int32_t)ntohl(rp->rm_call.cb_proc));
return;
}
+
trunc:
if (!nfserr)
fputs(" [|nfs]", stdout);
@@ -688,22 +762,27 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
if (sfsname) {
/* file system ID is ASCII, not numeric, for this server OS */
- static char temp[NFSX_V3FHMAX+1];
+ static char temp[NFSX_V3FHMAX+1];
/* Make sure string is null-terminated */
- strncpy(temp, sfsname, NFSX_V3FHMAX);
+ strncpy(temp, sfsname, NFSX_V3FHMAX);
+ temp[sizeof(temp) - 1] = '\0';
/* Remove trailing spaces */
sfsname = strchr(temp, ' ');
if (sfsname)
*sfsname = 0;
- (void)printf(" fh %s/%ld", temp, (long) ino);
- }
- else {
- (void)printf(" fh %d,%d/%ld",
- fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor,
- (long) ino);
+ (void)printf(" fh %s/", temp);
+ } else {
+ (void)printf(" fh %d,%d/",
+ fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor);
}
+
+ if(fsid.Fsid_dev.Minor == 257 && uflag)
+ /* Print the undecoded handle */
+ (void)printf("%s", fsid.Opaque_Handle);
+ else
+ (void)printf("%ld", (long) ino);
}
/*
@@ -713,11 +792,17 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
*/
struct xid_map_entry {
- u_int32_t xid; /* transaction ID (net order) */
+ u_int32_t xid; /* transaction ID (net order) */
+ int ipver; /* IP version (4 or 6) */
+#ifdef INET6
+ struct in6_addr client; /* client IP address (net order) */
+ struct in6_addr server; /* server IP address (net order) */
+#else
struct in_addr client; /* client IP address (net order) */
struct in_addr server; /* server IP address (net order) */
- u_int32_t proc; /* call proc number (host order) */
- u_int32_t vers; /* program version (host order) */
+#endif
+ u_int32_t proc; /* call proc number (host order) */
+ u_int32_t vers; /* program version (host order) */
};
/*
@@ -734,51 +819,110 @@ int xid_map_next = 0;
int xid_map_hint = 0;
static void
-xid_map_enter(const struct rpc_msg *rp, const struct ip *ip)
+xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
{
+ struct ip *ip = NULL;
+#ifdef INET6
+ struct ip6_hdr *ip6 = NULL;
+#endif
struct xid_map_entry *xmep;
+ switch (IP_V((struct ip *)bp)) {
+ case 4:
+ ip = (struct ip *)bp;
+ break;
+#ifdef INET6
+ case 6:
+ ip6 = (struct ip6_hdr *)bp;
+ break;
+#endif
+ default:
+ return;
+ }
+
xmep = &xid_map[xid_map_next];
if (++xid_map_next >= XIDMAPSIZE)
xid_map_next = 0;
xmep->xid = rp->rm_xid;
- xmep->client = ip->ip_src;
- xmep->server = ip->ip_dst;
+ if (ip) {
+ xmep->ipver = 4;
+ memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
+ memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
+ }
+#ifdef INET6
+ else if (ip6) {
+ xmep->ipver = 6;
+ memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
+ memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
+ }
+#endif
xmep->proc = ntohl(rp->rm_call.cb_proc);
xmep->vers = ntohl(rp->rm_call.cb_vers);
}
-/* Returns NFSPROC_xxx or -1 on failure */
+/*
+ * Returns 0 and puts NFSPROC_xxx in proc return and
+ * version in vers return, or returns -1 on failure
+ */
static int
-xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc,
+xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
u_int32_t *vers)
{
int i;
struct xid_map_entry *xmep;
u_int32_t xid = rp->rm_xid;
- u_int32_t clip = ip->ip_dst.s_addr;
- u_int32_t sip = ip->ip_src.s_addr;
+ struct ip *ip = (struct ip *)bp;
+#ifdef INET6
+ struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
+#endif
+ int cmp;
/* Start searching from where we last left off */
- i = xid_map_hint;
+ i = xid_map_hint;
do {
xmep = &xid_map[i];
- if (xmep->xid == xid && xmep->client.s_addr == clip &&
- xmep->server.s_addr == sip) {
+ cmp = 1;
+ if (xmep->ipver != IP_V(ip) || xmep->xid != xid)
+ goto nextitem;
+ switch (xmep->ipver) {
+ case 4:
+ if (memcmp(&ip->ip_src, &xmep->server,
+ sizeof(ip->ip_src)) != 0 ||
+ memcmp(&ip->ip_dst, &xmep->client,
+ sizeof(ip->ip_dst)) != 0) {
+ cmp = 0;
+ }
+ break;
+#ifdef INET6
+ case 6:
+ if (memcmp(&ip6->ip6_src, &xmep->server,
+ sizeof(ip6->ip6_src)) != 0 ||
+ memcmp(&ip6->ip6_dst, &xmep->client,
+ sizeof(ip6->ip6_dst)) != 0) {
+ cmp = 0;
+ }
+ break;
+#endif
+ default:
+ cmp = 0;
+ break;
+ }
+ if (cmp) {
/* match */
xid_map_hint = i;
*proc = xmep->proc;
*vers = xmep->vers;
- return 1;
+ return 0;
}
+ nextitem:
if (++i >= XIDMAPSIZE)
i = 0;
} while (i != xid_map_hint);
/* search failed */
- return (0);
+ return (-1);
}
/*
@@ -812,7 +956,7 @@ parserep(register const struct rpc_msg *rp, register u_int length)
* which is an "enum" and so occupies one 32-bit word.
*/
dp = ((const u_int32_t *)&rp->rm_reply) + 1;
- TCHECK2(dp[0], 1);
+ TCHECK(dp[1]);
len = ntohl(dp[1]);
if (len >= length)
return (NULL);
@@ -862,42 +1006,32 @@ parserep(register const struct rpc_msg *rp, register u_int length)
return (NULL);
}
/* successful return */
- if ((sizeof(astat) + ((u_char *)dp)) < snapend)
- return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
+ TCHECK2(*dp, sizeof(astat));
+ return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
trunc:
return (0);
}
-#define T2CHECK(p, l) if ((u_char *)(p) > ((u_char *)snapend) - l) return(0)
-
-/*
- * Not all systems have strerror().
- */
-static const char *
-strerr(int errno)
-{
- return (strerror(errno));
-}
-
static const u_int32_t *
parsestatus(const u_int32_t *dp, int *er)
{
- int errno;
- T2CHECK(dp, 4);
+ int errnum;
- errno = ntohl(dp[0]);
+ TCHECK(dp[0]);
+
+ errnum = ntohl(dp[0]);
if (er)
- *er = errno;
- if (errno != 0 && !qflag) {
- const char *errmsg;
-
- errmsg = strerr(errno);
- if (errmsg)
- printf(" ERROR: '%s'", errmsg);
- else
- printf(" ERROR: %d", errno);
+ *er = errnum;
+ if (errnum != 0) {
+ if (!qflag)
+ printf(" ERROR: %s",
+ tok2str(status2str, "unk %d", errnum));
+ nfserr = 1;
+ return (NULL);
}
return (dp + 1);
+trunc:
+ return NULL;
}
static const u_int32_t *
@@ -905,9 +1039,8 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
{
const struct nfs_fattr *fap;
- T2CHECK(dp, 5 * sizeof(*dp));
-
fap = (const struct nfs_fattr *)dp;
+ TCHECK(fap->fa_gid);
if (verbose) {
printf(" %s %o ids %d/%d",
tok2str(type2str, "unk-ft %d ",
@@ -916,22 +1049,21 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
(u_int32_t)ntohl(fap->fa_uid),
(u_int32_t) ntohl(fap->fa_gid));
if (v3) {
- T2CHECK(dp, 7 * sizeof(*dp));
+ TCHECK(fap->fa3_size);
printf(" sz ");
print_int64((u_int32_t *)&fap->fa3_size, UNSIGNED);
putchar(' ');
- }
- else {
- T2CHECK(dp, 6 * sizeof(*dp));
+ } else {
+ TCHECK(fap->fa2_size);
printf(" sz %d ", (u_int32_t) ntohl(fap->fa2_size));
}
}
/* print lots more stuff */
if (verbose > 1) {
if (v3) {
- T2CHECK(dp, 64);
+ TCHECK(fap->fa3_ctime);
printf("nlink %d rdev %d/%d ",
- (u_int32_t)ntohl(fap->fa_nlink),
+ (u_int32_t)ntohl(fap->fa_nlink),
(u_int32_t) ntohl(fap->fa3_rdev.specdata1),
(u_int32_t) ntohl(fap->fa3_rdev.specdata2));
printf("fsid ");
@@ -941,20 +1073,20 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
printf(" a/m/ctime %u.%06u ",
(u_int32_t) ntohl(fap->fa3_atime.nfsv3_sec),
(u_int32_t) ntohl(fap->fa3_atime.nfsv3_nsec));
- printf("%u.%06u ",
+ printf("%u.%06u ",
(u_int32_t) ntohl(fap->fa3_mtime.nfsv3_sec),
(u_int32_t) ntohl(fap->fa3_mtime.nfsv3_nsec));
- printf("%u.%06u ",
+ printf("%u.%06u ",
(u_int32_t) ntohl(fap->fa3_ctime.nfsv3_sec),
(u_int32_t) ntohl(fap->fa3_ctime.nfsv3_nsec));
} else {
- T2CHECK(dp, 48);
+ TCHECK(fap->fa2_ctime);
printf("nlink %d rdev %x fsid %x nodeid %x a/m/ctime ",
(u_int32_t) ntohl(fap->fa_nlink),
(u_int32_t) ntohl(fap->fa2_rdev),
(u_int32_t) ntohl(fap->fa2_fsid),
(u_int32_t) ntohl(fap->fa2_fileid));
- printf("%u.%06u ",
+ printf("%u.%06u ",
(u_int32_t) ntohl(fap->fa2_atime.nfsv2_sec),
(u_int32_t) ntohl(fap->fa2_atime.nfsv2_usec));
printf("%u.%06u ",
@@ -963,10 +1095,12 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
printf("%u.%06u ",
(u_int32_t) ntohl(fap->fa2_ctime.nfsv2_sec),
(u_int32_t) ntohl(fap->fa2_ctime.nfsv2_usec));
- }
+ }
}
return ((const u_int32_t *)((unsigned char *)dp +
(v3 ? NFSX_V3FATTR : NFSX_V2FATTR)));
+trunc:
+ return (NULL);
}
static int
@@ -1030,7 +1164,7 @@ parsestatfs(const u_int32_t *dp, int v3)
return (0);
}
- T2CHECK(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
+ TCHECK2(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
sfsp = (const struct nfs_statfs *)dp;
@@ -1053,14 +1187,16 @@ parsestatfs(const u_int32_t *dp, int v3)
}
} else {
printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
- (u_int32_t)ntohl(sfsp->sf_tsize),
- (u_int32_t)ntohl(sfsp->sf_bsize),
- (u_int32_t)ntohl(sfsp->sf_blocks),
- (u_int32_t)ntohl(sfsp->sf_bfree),
- (u_int32_t)ntohl(sfsp->sf_bavail));
+ (u_int32_t)ntohl(sfsp->sf_tsize),
+ (u_int32_t)ntohl(sfsp->sf_bsize),
+ (u_int32_t)ntohl(sfsp->sf_blocks),
+ (u_int32_t)ntohl(sfsp->sf_bfree),
+ (u_int32_t)ntohl(sfsp->sf_bavail));
}
return (1);
+trunc:
+ return (0);
}
static int
@@ -1074,12 +1210,15 @@ parserddires(const u_int32_t *dp)
if (qflag)
return (1);
- T2CHECK(dp, 12);
- printf(" offset %x size %d ", ntohl(dp[0]), ntohl(dp[1]));
- if (dp[2] != 0)
- printf(" eof");
+ TCHECK(dp[2]);
+ printf(" offset %x size %d ",
+ (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1]));
+ if (dp[2] != 0)
+ printf(" eof");
return (1);
+trunc:
+ return (0);
}
static const u_int32_t *
@@ -1087,8 +1226,9 @@ parse_wcc_attr(const u_int32_t *dp)
{
printf(" sz ");
print_int64(dp, UNSIGNED);
- printf(" mtime %u.%06u ctime %u.%06u", ntohl(dp[2]), ntohl(dp[3]),
- ntohl(dp[4]), ntohl(dp[5]));
+ printf(" mtime %u.%06u ctime %u.%06u",
+ (u_int32_t)ntohl(dp[2]), (u_int32_t)ntohl(dp[3]),
+ (u_int32_t)ntohl(dp[4]), (u_int32_t)ntohl(dp[5]));
return (dp + 6);
}
@@ -1098,17 +1238,19 @@ parse_wcc_attr(const u_int32_t *dp)
static const u_int32_t *
parse_pre_op_attr(const u_int32_t *dp, int verbose)
{
- T2CHECK(dp, 4);
+ TCHECK(dp[0]);
if (!ntohl(dp[0]))
return (dp + 1);
dp++;
- T2CHECK(dp, 24);
+ TCHECK2(dp, 24);
if (verbose > 1) {
return parse_wcc_attr(dp);
} else {
/* If not verbose enough, just skip over wcc_attr */
return (dp + 6);
}
+trunc:
+ return (NULL);
}
/*
@@ -1117,7 +1259,7 @@ parse_pre_op_attr(const u_int32_t *dp, int verbose)
static const u_int32_t *
parse_post_op_attr(const u_int32_t *dp, int verbose)
{
- T2CHECK(dp, 4);
+ TCHECK(dp[0]);
if (!ntohl(dp[0]))
return (dp + 1);
dp++;
@@ -1125,6 +1267,8 @@ parse_post_op_attr(const u_int32_t *dp, int verbose)
return parsefattr(dp, verbose, 1);
} else
return (dp + (NFSX_V3FATTR / sizeof (u_int32_t)));
+trunc:
+ return (NULL);
}
static const u_int32_t *
@@ -1150,7 +1294,7 @@ parsecreateopres(const u_int32_t *dp, int verbose)
if (er)
dp = parse_wcc_data(dp, verbose);
else {
- T2CHECK(dp, 4);
+ TCHECK(dp[0]);
if (!ntohl(dp[0]))
return (dp + 1);
dp++;
@@ -1166,6 +1310,8 @@ parsecreateopres(const u_int32_t *dp, int verbose)
}
}
return (dp);
+trunc:
+ return (NULL);
}
static int
@@ -1192,12 +1338,14 @@ parsev3rddirres(const u_int32_t *dp, int verbose)
if (er)
return dp;
if (vflag) {
- T2CHECK(dp, 8);
+ TCHECK(dp[1]);
printf(" verf %08x%08x", dp[0], dp[1]);
dp += 2;
}
return dp;
- }
+trunc:
+ return (NULL);
+}
static int
parsefsinfo(const u_int32_t *dp)
@@ -1212,11 +1360,10 @@ parsefsinfo(const u_int32_t *dp)
if (!(dp = parse_post_op_attr(dp, vflag)))
return (0);
if (er)
- return (1);
-
- T2CHECK(dp, sizeof (struct nfsv3_fsinfo));
+ return (1);
sfp = (struct nfsv3_fsinfo *)dp;
+ TCHECK(*sfp);
printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
(u_int32_t) ntohl(sfp->fs_rtmax),
(u_int32_t) ntohl(sfp->fs_rtpref),
@@ -1232,6 +1379,8 @@ parsefsinfo(const u_int32_t *dp)
(u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_sec),
(u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_nsec));
}
+ return (0);
+trunc:
return (1);
}
@@ -1242,7 +1391,7 @@ parsepathconf(const u_int32_t *dp)
struct nfsv3_pathconf *spp;
if (!(dp = parsestatus(dp, &er)))
- return (0);
+ return (0);
if (vflag)
printf(" POST:");
if (!(dp = parse_post_op_attr(dp, vflag)))
@@ -1250,9 +1399,8 @@ parsepathconf(const u_int32_t *dp)
if (er)
return (1);
- T2CHECK(dp, sizeof (struct nfsv3_pathconf));
-
spp = (struct nfsv3_pathconf *)dp;
+ TCHECK(*spp);
printf(" linkmax %u namemax %u %s %s %s %s",
(u_int32_t) ntohl(spp->pc_linkmax),
@@ -1262,6 +1410,8 @@ parsepathconf(const u_int32_t *dp)
ntohl(spp->pc_caseinsensitive) ? "igncase" : "",
ntohl(spp->pc_casepreserving) ? "keepcase" : "");
return (0);
+trunc:
+ return (1);
}
static void
@@ -1302,7 +1452,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
} else {
if (parseattrstat(dp, !qflag, 0) != 0)
- return;
+ return;
}
break;
@@ -1331,7 +1481,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
} else {
if (parsediropres(dp) != 0)
- return;
+ return;
}
break;
@@ -1345,7 +1495,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
if (!(dp = parse_post_op_attr(dp, vflag)))
break;
if (!er)
- printf(" c %04x", ntohl(dp[0]));
+ printf(" c %04x", (u_int32_t)ntohl(dp[0]));
return;
case NFSPROC_READLINK:
@@ -1367,7 +1517,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
if (er)
return;
if (vflag) {
- TCHECK2(dp[0], 8);
+ TCHECK(dp[1]);
printf("%u bytes", (u_int32_t) ntohl(dp[0]));
if (ntohl(dp[1]))
printf(" EOF");
@@ -1375,7 +1525,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
} else {
if (parseattrstat(dp, vflag, 0) != 0)
- return;
+ return;
}
break;
@@ -1389,14 +1539,15 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
if (!(dp = parse_wcc_data(dp, vflag)))
break;
if (er)
- return;
+ return;
if (vflag) {
- TCHECK2(dp[0], 4);
+ TCHECK(dp[0]);
printf("%u bytes", (u_int32_t) ntohl(dp[0]));
if (vflag > 1) {
- TCHECK2(dp[0], 4);
+ TCHECK(dp[1]);
printf(" <%s>",
- nfsv3_writemodes[ntohl(dp[1])]);
+ tok2str(nfsv3_writemodes,
+ NULL, ntohl(dp[1])));
}
return;
}
@@ -1441,7 +1592,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
} else {
if (parsestatus(dp, &er) != 0)
- return;
+ return;
}
break;
@@ -1475,7 +1626,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
} else {
if (parsestatus(dp, &er) != 0)
- return;
+ return;
}
break;
@@ -1519,7 +1670,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
}
} else {
if (parsestatus(dp, &er) != 0)
- return;
+ return;
}
break;
@@ -1532,7 +1683,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
} else {
if (parserddires(dp) != 0)
- return;
+ return;
}
break;
@@ -1576,7 +1727,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
printf(" proc-%u", proc);
return;
}
+trunc:
if (!nfserr)
fputs(" [|nfs]", stdout);
-trunc:;
}
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c
index 5bdec72..fd2712e 100644
--- a/contrib/tcpdump/print-ntp.c
+++ b/contrib/tcpdump/print-ntp.c
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.27 1999/11/21 09:36:57 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.31 2000/10/06 04:23:13 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,14 +36,7 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
#include <stdio.h>
diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c
index 9e19c41..55602a4 100644
--- a/contrib/tcpdump/print-null.c
+++ b/contrib/tcpdump/print-null.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.30 1999/12/22 06:27:21 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.40 2000/12/16 22:00:50 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,84 +34,100 @@ static const char rcsid[] =
#include <sys/file.h>
#include <sys/ioctl.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <pcap.h>
#include <stdio.h>
#include <string.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-
#include "interface.h"
#include "addrtoname.h"
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
#ifndef AF_NS
#define AF_NS 6 /* XEROX NS protocols */
#endif
/*
- * 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
+ * The DLT_NULL packet header is 4 bytes long. It contains a host-byte-order
+ * 32-bit integer that specifies the family, e.g. AF_INET.
+ *
+ * Note here that "host" refers to the host on which the packets were
+ * captured; that isn't necessarily *this* host.
+ *
+ * The OpenBSD DLT_LOOP packet header is the same, except that the integer
+ * is in network byte order.
*/
#define NULL_HDRLEN 4
static void
-null_print(const u_char *p, const struct ip *ip, u_int length)
+null_print(u_int family, u_int length)
{
- u_int family;
-
- memcpy((char *)&family, (char *)p, sizeof(family));
-
- if (nflag) {
- /* XXX just dump the header */
- return;
- }
- switch (family) {
+ if (nflag)
+ printf("AF %u ", family);
+ else {
+ switch (family) {
- case AF_INET:
- printf("ip: ");
- break;
+ case AF_INET:
+ printf("ip ");
+ break;
#ifdef INET6
- case AF_INET6:
- printf("ip6: ");
- break;
+ case AF_INET6:
+ printf("ip6 ");
+ break;
#endif
- case AF_NS:
- printf("ns: ");
- break;
+ case AF_NS:
+ printf("ns ");
+ break;
- default:
- printf("AF %d: ", family);
- break;
+ default:
+ printf("AF %u ", family);
+ break;
+ }
}
+ printf("%d: ", length);
}
+/*
+ * Byte-swap a 32-bit number.
+ * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on
+ * big-endian platforms.)
+ */
+#define SWAPLONG(y) \
+((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
+
void
null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
const struct ip *ip;
+ u_int family;
ts_print(&h->ts);
+ memcpy((char *)&family, (char *)p, sizeof(family));
+
+ /*
+ * This isn't necessarily in our host byte order; if this is
+ * a DLT_LOOP capture, it's in network byte order, and if
+ * this is a DLT_NULL capture from a machine with the opposite
+ * byte-order, it's in the opposite byte order from ours.
+ *
+ * If the upper 16 bits aren't all zero, assume it's byte-swapped.
+ */
+ if ((family & 0xFFFF0000) != 0)
+ family = SWAPLONG(family);
+
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
@@ -125,9 +141,9 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
ip = (struct ip *)(p + NULL_HDRLEN);
if (eflag)
- null_print(p, ip, length);
+ null_print(family, length);
- switch (ip->ip_v) {
+ switch (IP_V(ip)) {
case 4:
ip_print((const u_char *)ip, length);
break;
@@ -137,7 +153,7 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
break;
#endif /* INET6 */
default:
- printf("ip v%d", ip->ip_v);
+ printf("ip v%d", IP_V(ip));
break;
}
diff --git a/contrib/tcpdump/print-ospf.c b/contrib/tcpdump/print-ospf.c
index f69eb84..f5e452f 100644
--- a/contrib/tcpdump/print-ospf.c
+++ b/contrib/tcpdump/print-ospf.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.27 1999/11/21 09:36:58 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.29 2000/09/29 04:58:45 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,9 +35,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
#include <ctype.h>
#include <stdio.h>
@@ -47,6 +44,8 @@ static const char rcsid[] =
#include "ospf.h"
+#include "ip.h"
+
struct bits {
u_int32_t bit;
const char *str;
diff --git a/contrib/tcpdump/print-ospf6.c b/contrib/tcpdump/print-ospf6.c
index f368346..f52b462 100644
--- a/contrib/tcpdump/print-ospf6.c
+++ b/contrib/tcpdump/print-ospf6.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.2 1999/11/21 09:36:58 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.6 2000/09/29 04:58:45 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,9 +35,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
#include <ctype.h>
#include <stdio.h>
@@ -71,6 +68,13 @@ static const struct bits ospf6_rla_flag_bits[] = {
{ 0, NULL }
};
+static const struct bits ospf6_asla_flag_bits[] = {
+ { ASLA_FLAG_EXTERNAL, "E" },
+ { ASLA_FLAG_FWDADDR, "F" },
+ { ASLA_FLAG_ROUTETAG, "T" },
+ { 0, NULL }
+};
+
static struct tok type2str[] = {
{ OSPF_TYPE_UMD, "umd" },
{ OSPF_TYPE_HELLO, "hello" },
@@ -241,6 +245,8 @@ ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp)
lsapp->lsa_p_len);
if (lsapp->lsa_p_opt)
printf("(opt=%x)", lsapp->lsa_p_opt);
+ if (lsapp->lsa_p_mbz)
+ printf("(mbz=%x)", ntohs(lsapp->lsa_p_mbz)); /* XXX */
return sizeof(*lsapp) - 4 + k * 4;
trunc:
@@ -254,7 +260,7 @@ trunc:
static int
ospf6_print_lsa(register const struct lsa *lsap)
{
- register const u_char *ls_end;
+ register const u_char *ls_end, *ls_opt;
register const struct rlalink *rlp;
#if 0
register const struct tos_metric *tosp;
@@ -270,6 +276,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
register const u_int32_t *lp;
#endif
register int j, k;
+ u_int32_t flags32;
if (ospf6_print_lshdr(&lsap->ls_hdr))
return (1);
@@ -342,12 +349,51 @@ ospf6_print_lsa(register const struct lsa *lsap)
lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix;
while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) {
k = ospf6_print_lsaprefix(lsapp);
- if (k < 0)
+ if (k)
goto trunc;
lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
}
break;
+ case LS_SCOPE_AS | LS_TYPE_ASE:
+ TCHECK(lsap->lsa_un.un_asla.asla_metric);
+ flags32 = ntohl(lsap->lsa_un.un_asla.asla_metric);
+ ospf6_print_bits(ospf6_asla_flag_bits, flags32);
+ printf(" metric %u",
+ ntohl(lsap->lsa_un.un_asla.asla_metric) &
+ ASLA_MASK_METRIC);
+ lsapp = lsap->lsa_un.un_asla.asla_prefix;
+ k = ospf6_print_lsaprefix(lsapp);
+ if (k < 0)
+ goto trunc;
+ if ((ls_opt = (u_char *)(((u_char *)lsapp) + k)) < ls_end) {
+ struct in6_addr *fwdaddr6;
+
+ if ((flags32 & ASLA_FLAG_FWDADDR) != 0) {
+ fwdaddr6 = (struct in6_addr *)ls_opt;
+ TCHECK(*fwdaddr6);
+ printf(" forward %s",
+ ip6addr_string(fwdaddr6));
+ ls_opt += sizeof(struct in6_addr);
+ }
+
+ if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
+ TCHECK(*(u_int32_t *)ls_opt);
+ printf(" tag %s",
+ ipaddr_string((u_int32_t *)ls_opt));
+
+ ls_opt += sizeof(u_int32_t);
+ }
+
+ if (lsapp->lsa_p_mbz) {
+ TCHECK(*(u_int32_t *)ls_opt);
+ printf(" RefLSID: %s",
+ ipaddr_string((u_int32_t *)ls_opt));
+
+ ls_opt += sizeof(u_int32_t);
+ }
+ }
+ break;
#if 0
case LS_TYPE_SUM_ABR:
TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
@@ -364,36 +410,6 @@ ospf6_print_lsa(register const struct lsa *lsap)
}
break;
- case LS_TYPE_ASE:
- TCHECK(lsap->lsa_un.un_nla.nla_mask);
- printf(" mask %s",
- ipaddr_string(&lsap->lsa_un.un_asla.asla_mask));
-
- TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
- almp = lsap->lsa_un.un_asla.asla_metric;
- while ((u_char *)almp < ls_end) {
- register u_int32_t ul;
-
- TCHECK(almp->asla_tosmetric);
- ul = ntohl(almp->asla_tosmetric);
- printf(" type %d tos %d metric %d",
- (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1,
- (ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS,
- (ul & ASLA_MASK_METRIC));
- TCHECK(almp->asla_forward);
- if (almp->asla_forward.s_addr) {
- printf(" forward %s",
- ipaddr_string(&almp->asla_forward));
- }
- TCHECK(almp->asla_tag);
- if (almp->asla_tag.s_addr) {
- printf(" tag %s",
- ipaddr_string(&almp->asla_tag));
- }
- ++almp;
- }
- break;
-
case LS_TYPE_GROUP:
/* Multicast extensions as of 23 July 1991 */
mcp = lsap->lsa_un.un_mcla;
@@ -432,7 +448,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
lsapp = llsap->llsa_prefix;
for (j = 0; j < ntohl(llsap->llsa_nprefix); j++) {
k = ospf6_print_lsaprefix(lsapp);
- if (k < 0)
+ if (k)
goto trunc;
lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
}
@@ -455,7 +471,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
j < ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
j++) {
k = ospf6_print_lsaprefix(lsapp);
- if (k < 0)
+ if (k)
goto trunc;
lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
}
@@ -624,7 +640,7 @@ ospf6_print(register const u_char *bp, register u_int length)
/* value. If it's not valid, say so and return */
TCHECK(op->ospf6_type);
cp = tok2str(type2str, "type%d", op->ospf6_type);
- printf(" OSPFv%d-%s %d:", op->ospf6_version, cp, length);
+ printf("OSPFv%d-%s %d:", op->ospf6_version, cp, length);
if (*cp == 't')
return;
diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c
index 5a3bdd0..06ba458 100644
--- a/contrib/tcpdump/print-pim.c
+++ b/contrib/tcpdump/print-pim.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.15.2.1 2000/01/25 18:29:05 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.23 2000/10/03 02:55:00 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,8 +33,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
@@ -43,14 +41,14 @@ static const char rcsid[] =
struct pim {
u_int8_t pim_typever;
- /* upper 4bit: the PIM message type, currently they are:
+ /* upper 4bit: PIM version number; 2 for PIMv2 */
+ /* lower 4bit: the PIM message type, currently they are:
* Hello, Register, Register-Stop, Join/Prune,
* Bootstrap, Assert, Graft (PIM-DM only),
* Graft-Ack (PIM-DM only), C-RP-Adv
*/
- /* lower 4bit: PIM version number; 2 for PIMv2 */
-#define PIM_TYPE(x) (((x) & 0xf0) >> 4)
-#define PIM_VER(x) ((x) & 0x0f)
+#define PIM_VER(x) (((x) & 0xf0) >> 4)
+#define PIM_TYPE(x) ((x) & 0x0f)
u_char pim_rsv; /* Reserved */
u_short pim_cksum; /* IP style check sum */
};
@@ -64,6 +62,8 @@ struct pim {
#include "addrtoname.h"
#include "extract.h"
+#include "ip.h"
+
static void pimv2_print(register const u_char *bp, register u_int len);
static void
@@ -316,7 +316,7 @@ cisco_autorp_print(register const u_char *bp, register u_int len)
TCHECK2(bp[0], 4);
(void)printf(" RP %s", ipaddr_string(bp));
TCHECK(bp[4]);
- switch(bp[4] & 0x3) {
+ switch (bp[4] & 0x3) {
case 0: printf(" PIMv?");
break;
case 1: printf(" PIMv1");
@@ -358,13 +358,13 @@ pim_print(register const u_char *bp, register u_int len)
TCHECK(pim->pim_rsv);
#endif
- switch(PIM_VER(pim->pim_typever)) {
+ switch (PIM_VER(pim->pim_typever)) {
case 2: /* avoid hardcoding? */
- (void)printf("v2");
+ (void)printf("pim v2");
pimv2_print(bp, len);
break;
default:
- (void)printf("v%d", PIM_VER(pim->pim_typever));
+ (void)printf("pim v%d", PIM_VER(pim->pim_typever));
break;
}
return;
@@ -557,6 +557,8 @@ pimv2_print(register const u_char *bp, register u_int len)
ep = (const u_char *)snapend;
if (bp >= ep)
return;
+ if (ep > bp + len)
+ ep = bp + len;
TCHECK(pim->pim_rsv);
pimv2_addr_len = pim->pim_rsv;
if (pimv2_addr_len != 0)
@@ -632,7 +634,7 @@ pimv2_print(register const u_char *bp, register u_int len)
if (bp >= ep)
break;
ip = (struct ip *)bp;
- switch(ip->ip_v) {
+ switch (IP_V(ip)) {
case 4: /* IPv4 */
printf(" ");
ip_print(bp, len);
@@ -644,7 +646,7 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
#endif
default:
- (void)printf(" IP ver %d", ip->ip_v);
+ (void)printf(" IP ver %d", IP_V(ip));
break;
}
break;
@@ -797,12 +799,12 @@ pimv2_print(register const u_char *bp, register u_int len)
(void)printf("...)");
goto bs_done;
}
- (void)printf(" RPcnt=%d", frpcnt = bp[0]);
+ (void)printf(" RPcnt=%d", bp[0]);
if (bp + 1 >= ep) {
(void)printf("...)");
goto bs_done;
}
- (void)printf(" FRPcnt=%d", bp[1]);
+ (void)printf(" FRPcnt=%d", frpcnt = bp[1]);
bp += 4;
for (j = 0; j < frpcnt && bp < ep; j++) {
diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c
index cfb80e5..5dc1b83 100644
--- a/contrib/tcpdump/print-ppp.c
+++ b/contrib/tcpdump/print-ppp.c
@@ -17,11 +17,21 @@
* 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.
+ *
+ * Extensively modified by Motonori Shindo (mshindo@mshindo.net) for more
+ * complete PPP support.
+ */
+
+/*
+ * TODO:
+ * o resolve XXX as much as possible
+ * o MP support
+ * o BAP support
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.33.2.1 2000/01/29 07:31:17 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.58 2000/12/27 11:09:08 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,112 +40,253 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
+#ifdef __bsdi__
+#include <net/slcompress.h>
+#include <net/if_ppp.h>
#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
-#ifdef __bsdi__
-#include <net/slcompress.h>
-#include <net/if_ppp.h>
-#endif
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
#include "ppp.h"
+#include "chdlc.h"
+#include "ethertype.h"
-/* XXX This goes somewhere else. */
-#define PPP_HDRLEN 4
-
-/* LCP */
-
-#define LCP_CONF_REQ 1
-#define LCP_CONF_ACK 2
-#define LCP_CONF_NAK 3
-#define LCP_CONF_REJ 4
-#define LCP_TERM_REQ 5
-#define LCP_TERM_ACK 6
-#define LCP_CODE_REJ 7
-#define LCP_PROT_REJ 8
-#define LCP_ECHO_REQ 9
-#define LCP_ECHO_RPL 10
-#define LCP_DISC_REQ 11
-
-#define LCP_MIN LCP_CONF_REQ
-#define LCP_MAX LCP_DISC_REQ
+/*
+ * The following constatns are defined by IANA. Please refer to
+ * http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
+ * for the up-to-date information.
+ */
-static char *lcpcodes[] = {
+/* Control Protocols (LCP/IPCP/CCP etc.) Codes */
+
+#define CPCODES_VEXT 0 /* Vendor-Specific (RFC2153) */
+#define CPCODES_CONF_REQ 1 /* Configure-Request */
+#define CPCODES_CONF_ACK 2 /* Configure-Ack */
+#define CPCODES_CONF_NAK 3 /* Configure-Nak */
+#define CPCODES_CONF_REJ 4 /* Configure-Reject */
+#define CPCODES_TERM_REQ 5 /* Terminate-Request */
+#define CPCODES_TERM_ACK 6 /* Terminate-Ack */
+#define CPCODES_CODE_REJ 7 /* Code-Reject */
+#define CPCODES_PROT_REJ 8 /* Protocol-Reject (LCP only) */
+#define CPCODES_ECHO_REQ 9 /* Echo-Request (LCP only) */
+#define CPCODES_ECHO_RPL 10 /* Echo-Reply (LCP only) */
+#define CPCODES_DISC_REQ 11 /* Discard-Request (LCP only) */
+#define CPCODES_ID 12 /* Identification (LCP only) */
+#define CPCODES_TIME_REM 13 /* Time-Remaining (LCP only) */
+#define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) */
+#define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */
+
+#define CPCODES_MIN CPCODES_VEXT
+#define CPCODES_MAX CPCODES_RESET_REP
+
+static const char *cpcodes[] = {
/*
- * LCP code values (RFC1661, pp26)
+ * Control Protocol code values (RFC1661)
*/
- "Configure-Request",
- "Configure-Ack",
- "Configure-Nak",
- "Configure-Reject",
- "Terminate-Request",
- "Terminate-Ack",
- "Code-Reject",
- "Protocol-Reject",
- "Echo-Request",
- "Echo-Reply",
- "Discard-Request",
+ "Vend-Ext", /* (0) RFC2153 */
+ "Conf-Req", /* (1) */
+ "Conf-Ack", /* (2) */
+ "Conf-Nak", /* (3) */
+ "Conf-Rej", /* (4) */
+ "Term-Req", /* (5) */
+ "Term-Ack", /* (6) */
+ "Code-Rej", /* (7) */
+ "Prot-Rej", /* (8) */
+ "Echo-Req", /* (9) */
+ "Echo-Rep", /* (10) */
+ "Disc-Req", /* (11) */
+ "Ident", /* (12) RFC1570 */
+ "Time-Rem", /* (13) RFC1570 */
+ "Reset-Req", /* (14) RFC1962 */
+ "Reset-Ack", /* (15) RFC1962 */
};
+/* LCP Config Options */
+
#define LCPOPT_VEXT 0
#define LCPOPT_MRU 1
#define LCPOPT_ACCM 2
#define LCPOPT_AP 3
#define LCPOPT_QP 4
#define LCPOPT_MN 5
+#define LCPOPT_DEP6 6
#define LCPOPT_PFC 7
#define LCPOPT_ACFC 8
+#define LCPOPT_FCSALT 9
+#define LCPOPT_SDP 10
+#define LCPOPT_NUMMODE 11
+#define LCPOPT_DEP12 12
+#define LCPOPT_CBACK 13
+#define LCPOPT_DEP14 14
+#define LCPOPT_DEP15 15
+#define LCPOPT_DEP16 16
+#define LCPOPT_MLMRRU 17
+#define LCPOPT_MLSSNHF 18
+#define LCPOPT_MLED 19
+#define LCPOPT_PROP 20
+#define LCPOPT_DCEID 21
+#define LCPOPT_MPP 22
+#define LCPOPT_LD 23
+#define LCPOPT_LCPAOPT 24
+#define LCPOPT_COBS 25
+#define LCPOPT_PE 26
+#define LCPOPT_MLHF 27
+#define LCPOPT_I18N 28
+#define LCPOPT_SDLOS 29
+#define LCPOPT_PPPMUX 30
+
+#define LCPOPT_MIN LCPOPT_VEXT
+#define LCPOPT_MAX LCPOPT_PPPMUX
+
+static const char *lcpconfopts[] = {
+ "Vend-Ext", /* (0) */
+ "MRU", /* (1) */
+ "ACCM", /* (2) */
+ "Auth-Prot", /* (3) */
+ "Qual-Prot", /* (4) */
+ "Magic-Num", /* (5) */
+ "deprecated(6)", /* used to be a Quality Protocol */
+ "PFC", /* (7) */
+ "ACFC", /* (8) */
+ "FCS-Alt", /* (9) */
+ "SDP", /* (10) */
+ "Num-Mode", /* (11) */
+ "deprecated(12)", /* used to be a Multi-Link-Procedure*/
+ "Call-Back", /* (13) */
+ "deprecated(14)", /* used to be a Connect-Time */
+ "deprecated(15)", /* used to be a Compund-Frames */
+ "deprecated(16)", /* used to be a Nominal-Data-Encap */
+ "MRRU", /* (17) */
+ "SSNHF", /* (18) */
+ "End-Disc", /* (19) */
+ "Proprietary", /* (20) */
+ "DCE-Id", /* (21) */
+ "MP+", /* (22) */
+ "Link-Disc", /* (23) */
+ "LCP-Auth-Opt", /* (24) */
+ "COBS", /* (25) */
+ "Prefix-elision", /* (26) */
+ "Multilink-header-Form",/* (27) */
+ "I18N", /* (28) */
+ "SDL-over-SONET/SDH", /* (29) */
+ "PPP-Muxing", /* (30) */
+};
-#define LCPOPT_MIN 0
-#define LCPOPT_MAX 24
-
-static char *lcpconfopts[] = {
- "Vendor-Ext",
- "Max-Rx-Unit",
- "Async-Ctrl-Char-Map",
- "Auth-Prot",
- "Quality-Prot",
- "Magic-Number",
- "unassigned (6)",
- "Prot-Field-Compr",
- "Add-Ctrl-Field-Compr",
- "FCS-Alternatives",
- "Self-Describing-Pad",
- "Numbered-Mode",
- "Multi-Link-Procedure",
- "Call-Back",
- "Connect-Time",
- "Compund-Frames",
- "Nominal-Data-Encap",
- "Multilink-MRRU",
- "Multilink-SSNHF",
- "Multilink-ED",
- "Proprietary",
- "DCE-Identifier",
- "Multilink-Plus-Proc",
- "Link-Discriminator",
- "LCP-Auth-Option",
+/* IPV6CP - to be supported */
+/* ECP - to be supported */
+
+/* CCP Config Options */
+
+#define CCPOPT_OUI 0 /* RFC1962 */
+#define CCPOPT_PRED1 1 /* RFC1962 */
+#define CCPOPT_PRED2 2 /* RFC1962 */
+#define CCPOPT_PJUMP 3 /* RFC1962 */
+/* 4-15 unassigned */
+#define CCPOPT_HPPPC 16 /* RFC1962 */
+#define CCPOPT_STACLZS 17 /* RFC1974 */
+#define CCPOPT_MPPC 18 /* RFC2118 */
+#define CCPOPT_GFZA 19 /* RFC1962 */
+#define CCPOPT_V42BIS 20 /* RFC1962 */
+#define CCPOPT_BSDCOMP 21 /* RFC1977 */
+/* 22 unassigned */
+#define CCPOPT_LZSDCP 23 /* RFC1967 */
+#define CCPOPT_MVRCA 24 /* RFC1975 */
+#define CCPOPT_DEC 25 /* RFC1976 */
+#define CCPOPT_DEFLATE 26 /* RFC1979 */
+/* 27-254 unassigned */
+#define CCPOPT_RESV 255 /* RFC1962 */
+
+#define CCPOPT_MIN CCPOPT_OUI
+#define CCPOPT_MAX CCPOPT_DEFLATE /* XXX: should be CCPOPT_RESV but... */
+
+static const char *ccpconfopts[] = {
+ "OUI", /* (0) */
+ "Pred-1", /* (1) */
+ "Pred-2", /* (2) */
+ "Puddle", /* (3) */
+ "unassigned(4)", /* (4) */
+ "unassigned(5)", /* (5) */
+ "unassigned(6)", /* (6) */
+ "unassigned(7)", /* (7) */
+ "unassigned(8)", /* (8) */
+ "unassigned(9)", /* (9) */
+ "unassigned(10)", /* (10) */
+ "unassigned(11)", /* (11) */
+ "unassigned(12)", /* (12) */
+ "unassigned(13)", /* (13) */
+ "unassigned(14)", /* (14) */
+ "unassigned(15)", /* (15) */
+ "HP-PPC", /* (16) */
+ "Stac-LZS", /* (17) */
+ "MPPC", /* (18) */
+ "Gand-FZA", /* (19) */
+ "V.42bis", /* (20) */
+ "BSD-Comp", /* (21) */
+ "unassigned(22)", /* (22) */
+ "LZS-DCP", /* (23) */
+ "MVRCA", /* (24) */
+ "DEC", /* (25) */
+ "Deflate", /* (26) */
};
+/* BACP Config Options */
+
+#define BACPOPT_FPEER 1 /* RFC2125 */
+
+/* SDCP - to be supported */
+
+/* IPCP Config Options */
+
+#define IPCPOPT_2ADDR 1 /* RFC1172, RFC1332 (deprecated) */
+#define IPCPOPT_IPCOMP 2 /* RFC1332 */
+#define IPCPOPT_ADDR 3 /* RFC1332 */
+#define IPCPOPT_MOBILE4 4 /* RFC2290 */
+
+#define IPCPOPT_PRIDNS 129 /* RFC1877 */
+#define IPCPOPT_PRINBNS 130 /* RFC1877 */
+#define IPCPOPT_SECDNS 131 /* RFC1877 */
+#define IPCPOPT_SECNBNS 132 /* RFC1877 */
+
+/* ATCP - to be supported */
+/* OSINLCP - to be supported */
+/* BVCP - to be supported */
+/* BCP - to be supported */
+/* IPXCP - to be supported */
+
+/* Auth Algorithms */
+
+/* 0-4 Reserved (RFC1994) */
+#define AUTHALG_CHAPMD5 5 /* RFC1994 */
+#define AUTHALG_MSCHAP1 128 /* RFC2433 */
+#define AUTHALG_MSCHAP2 129 /* RFC2795 */
+
+/* FCS Alternatives - to be supported */
+
+/* Multilink Endpoint Discriminator (RFC1717) */
+#define MEDCLASS_NULL 0 /* Null Class */
+#define MEDCLASS_LOCAL 1 /* Locally Assigned */
+#define MEDCLASS_IPV4 2 /* Internet Protocol (IPv4) */
+#define MEDCLASS_MAC 3 /* IEEE 802.1 global MAC address */
+#define MEDCLASS_MNB 4 /* PPP Magic Number Block */
+#define MEDCLASS_PSNDN 5 /* Public Switched Network Director Number */
+
+/* PPP LCP Callback */
+#define CALLBACK_AUTH 0 /* Location determined by user auth */
+#define CALLBACK_DSTR 1 /* Dialing string */
+#define CALLBACK_LID 2 /* Location identifier */
+#define CALLBACK_E164 3 /* E.164 number */
+#define CALLBACK_X500 4 /* X.500 distinguished name */
+#define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
+
/* CHAP */
#define CHAP_CHAL 1
@@ -143,14 +294,14 @@ static char *lcpconfopts[] = {
#define CHAP_SUCC 3
#define CHAP_FAIL 4
-#define CHAP_CODEMIN 1
-#define CHAP_CODEMAX 4
+#define CHAP_CODEMIN CHAP_CHAL
+#define CHAP_CODEMAX CHAP_FAIL
-static char *chapcode[] = {
- "Challenge",
- "Response",
- "Success",
- "Failure",
+static const char *chapcode[] = {
+ "Chal", /* (1) */
+ "Resp", /* (2) */
+ "Succ", /* (3) */
+ "Fail", /* (4) */
};
/* PAP */
@@ -159,136 +310,223 @@ static char *chapcode[] = {
#define PAP_AACK 2
#define PAP_ANAK 3
-#define PAP_CODEMIN 1
-#define PAP_CODEMAX 3
+#define PAP_CODEMIN PAP_AREQ
+#define PAP_CODEMAX PAP_ANAK
-static char *papcode[] = {
- "Authenticate-Request",
- "Authenticate-Ack",
- "Authenticate-Nak",
+static const char *papcode[] = {
+ "Auth-Req", /* (1) */
+ "Auth-Ack", /* (2) */
+ "Auth-Nak", /* (3) */
};
-/* IPCP */
-
-#define IPCP_2ADDR 1
-#define IPCP_CP 2
-#define IPCP_ADDR 3
-
-static const char *ppp_protoname __P((int proto));
-static void handle_lcp __P((const u_char *p, int length));
-static int print_lcp_config_options __P((const u_char *p));
-static void handle_chap __P((const u_char *p, int length));
-static void handle_ipcp __P((const u_char *p, int length));
-static void handle_pap __P((const u_char *p, int length));
+/* BAP */
+#define BAP_CALLREQ 1
+#define BAP_CALLRES 2
+#define BAP_CBREQ 3
+#define BAP_CBRES 4
+#define BAP_LDQREQ 5
+#define BAP_LDQRES 6
+#define BAP_CSIND 7
+#define BAP_CSRES 8
+
+static const char *ppp_protoname (u_int proto);
+static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
+static void handle_chap (const u_char *p, int length);
+static void handle_pap (const u_char *p, int length);
+static void handle_bap (const u_char *p, int length);
+static int print_lcp_config_options (const u_char *p, int);
+static int print_ipcp_config_options (const u_char *p, int);
+static int print_ccp_config_options (const u_char *p, int);
+static int print_bacp_config_options (const u_char *p, int);
+static void handle_ppp (u_int proto, const u_char *p, int length);
static const char *
-ppp_protoname(int proto)
+ppp_protoname(u_int proto)
{
static char buf[20];
switch (proto) {
case PPP_IP: return "IP";
+ case PPP_IPV6: return "IPv6";
#ifdef PPP_XNS
case PPP_XNS: return "XNS";
#endif
-#ifdef PPP_IPX
case PPP_IPX: return "IPX";
-#endif
+ case PPP_VJC: return "VJC";
+ case PPP_VJNC: return "VJNC";
#ifdef PPP_COMP
case PPP_COMP: return "COMP";
#endif
-#ifdef PPP_IPCP
case PPP_IPCP: return "IPCP";
-#endif
-#ifdef PPP_IPV6CP
- case PPP_IPV6CP: return "IPV6CP";
-#endif
-#ifdef PPP_IPXCP
+ case PPP_IPV6CP: return "IPv6CP";
case PPP_IPXCP: return "IPXCP";
-#endif
-#ifdef PPP_CCP
case PPP_CCP: return "CCP";
-#endif
-#ifdef PPP_LCP
case PPP_LCP: return "LCP";
-#endif
-#ifdef PPP_PAP
case PPP_PAP: return "PAP";
-#endif
#ifdef PPP_LQR
case PPP_LQR: return "LQR";
#endif
-#ifdef PPP_CHAP
case PPP_CHAP: return "CHAP";
-#endif
+ case PPP_BACP: return "BACP";
+ case PPP_BAP: return "BAP";
default:
- sprintf(buf, "unknown-0x%04x\n", proto);
+ snprintf(buf, sizeof(buf), "unknown-0x%04x", proto);
return buf;
}
}
-/* print LCP frame */
+/* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
static void
-handle_lcp(const u_char *p, int length)
+handle_ctrl_proto(u_int proto, const u_char *p, int length)
{
+ u_int code, len;
+ int (*pfunc)(const u_char *, int);
int x, j;
- const u_char *ptr;
- x = p[4];
+ if (length < 1) {
+ printf("[|%s]", ppp_protoname(proto));
+ return;
+ } else if (length < 4) {
+ printf("[|%s 0x%02x]", ppp_protoname(proto), *p);
+ return;
+ }
- if ((x >= LCP_MIN) && (x <= LCP_MAX))
- printf("%s", lcpcodes[x - 1]);
+ code = *p;
+ if ((code >= CPCODES_MIN) && (code <= CPCODES_MAX))
+ printf("%s", cpcodes[code]);
else {
- printf("0x%02x", x);
+ printf("0x%02x", code);
return;
}
+ p++;
+
+ printf("(%u)", *p); /* ID */
+ p++;
+
+ len = EXTRACT_16BITS(p);
+ p += 2;
- length -= 4;
-
- switch (x) {
- case LCP_CONF_REQ:
- case LCP_CONF_ACK:
- case LCP_CONF_NAK:
- case LCP_CONF_REJ:
- x = length;
- ptr = p + 8;
+ if (length <= 4)
+ return; /* there may be a NULL confreq etc. */
+
+ switch (code) {
+ case CPCODES_VEXT:
+ if (length < 11)
+ break;
+ printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
+ p += 4;
+ printf(" OUI=%02x%02x%02x", p[0], p[1], p[2]);
+ /* XXX: need to decode Kind and Value(s)? */
+ break;
+ case CPCODES_CONF_REQ:
+ case CPCODES_CONF_ACK:
+ case CPCODES_CONF_NAK:
+ case CPCODES_CONF_REJ:
+ x = len - 4; /* Code(1), Identifier(1) and Length(2) */
do {
- if ((j = print_lcp_config_options(ptr)) == 0)
+ switch (proto) {
+ case PPP_LCP:
+ pfunc = print_lcp_config_options;
+ break;
+ case PPP_IPCP:
+ pfunc = print_ipcp_config_options;
+ break;
+ case PPP_CCP:
+ pfunc = print_ccp_config_options;
+ break;
+ case PPP_BACP:
+ pfunc = print_bacp_config_options;
+ break;
+ default:
+ /*
+ * This should never happen, but we set
+ * "pfunc" to squelch uninitialized
+ * variable warnings from compilers.
+ */
+ pfunc = NULL;
+ break;
+ }
+ if ((j = (*pfunc)(p, len)) == 0)
break;
x -= j;
- ptr += j;
+ p += j;
} while (x > 0);
break;
- case LCP_ECHO_REQ:
- case LCP_ECHO_RPL:
- printf(", Magic-Number=%u",
- EXTRACT_32BITS(p+8));
+ case CPCODES_TERM_REQ:
+ case CPCODES_TERM_ACK:
+ /* XXX: need to decode Data? */
+ break;
+ case CPCODES_CODE_REJ:
+ /* XXX: need to decode Rejected-Packet? */
+ break;
+ case CPCODES_PROT_REJ:
+ if (length < 6)
+ break;
+ printf(", Rejected-Protocol=%04x", EXTRACT_16BITS(p));
+ /* XXX: need to decode Rejected-Information? */
+ break;
+ case CPCODES_ECHO_REQ:
+ case CPCODES_ECHO_RPL:
+ case CPCODES_DISC_REQ:
+ case CPCODES_ID:
+ if (length < 8)
+ break;
+ printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
+ /* XXX: need to decode Data? */
+ break;
+ case CPCODES_TIME_REM:
+ if (length < 12)
+ break;
+ printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
+ printf(" Seconds-Remaining=%u", EXTRACT_32BITS(p + 4));
+ /* XXX: need to decode Message? */
break;
- case LCP_TERM_REQ:
- case LCP_TERM_ACK:
- case LCP_CODE_REJ:
- case LCP_PROT_REJ:
- case LCP_DISC_REQ:
default:
+ printf(", unknown-Codes-0x%02x", code);
break;
}
}
/* LCP config options */
static int
-print_lcp_config_options(const u_char *p)
+print_lcp_config_options(const u_char *p, int length)
{
- int len = p[1];
- int opt = p[0];
-
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
printf(", %s", lcpconfopts[opt]);
+ else {
+ printf(", unknwhown-%d", opt);
+ return len;
+ }
switch (opt) {
+ case LCPOPT_VEXT:
+ if (len >= 6) {
+ printf(" OUI=%02x%02x%02x", p[2], p[3], p[4]);
+#if 0
+ printf(" kind=%02x", p[5]);
+ printf(" val=")
+ for (i = 0; i < len - 6; i++) {
+ printf("%02x", p[6 + i]);
+ }
+#endif
+ }
+ break;
case LCPOPT_MRU:
if (len == 4)
- printf("=%d", (*(p+2) << 8) + *(p+3));
+ printf("=%u", EXTRACT_16BITS(p + 2));
+ break;
+ case LCPOPT_ACCM:
+ if (len == 6)
+ printf("=%08x", EXTRACT_32BITS(p + 2));
break;
case LCPOPT_AP:
if (len >= 4) {
@@ -300,11 +538,14 @@ print_lcp_config_options(const u_char *p)
default:
printf("unknown-algorithm-%u", p[4]);
break;
- case 5:
+ case AUTHALG_CHAPMD5:
printf("MD5");
break;
- case 0x80:
- printf("Microsoft");
+ case AUTHALG_MSCHAP1:
+ printf("MSCHAPv1");
+ break;
+ case AUTHALG_MSCHAP2:
+ printf("MSCHAPv2");
break;
}
}
@@ -328,14 +569,100 @@ print_lcp_config_options(const u_char *p)
break;
case LCPOPT_MN:
if (len == 6)
- printf("=%u", EXTRACT_32BITS(p+2));
+ printf("=%08x", EXTRACT_32BITS(p + 2));
break;
case LCPOPT_PFC:
- printf(" PFC");
break;
case LCPOPT_ACFC:
- printf(" ACFC");
break;
+ case LCPOPT_LD:
+ if (len == 4)
+ printf("=%04x", EXTRACT_16BITS(p + 2));
+ break;
+ case LCPOPT_CBACK:
+ if (len < 3)
+ break;
+ switch (p[2]) { /* Operation */
+ case CALLBACK_AUTH:
+ printf(" UserAuth");
+ break;
+ case CALLBACK_DSTR:
+ printf(" DialString");
+ break;
+ case CALLBACK_LID:
+ printf(" LocalID");
+ break;
+ case CALLBACK_E164:
+ printf(" E.164");
+ break;
+ case CALLBACK_X500:
+ printf(" X.500");
+ break;
+ case CALLBACK_CBCP:
+ printf(" CBCP");
+ break;
+ default:
+ printf(" unknown-operation=%u", p[2]);
+ break;
+ }
+ break;
+ case LCPOPT_MLMRRU:
+ if (len == 4)
+ printf("=%u", EXTRACT_16BITS(p + 2));
+ break;
+ case LCPOPT_MLED:
+ if (len < 3)
+ break;
+ switch (p[2]) { /* class */
+ case MEDCLASS_NULL:
+ printf(" Null");
+ break;
+ case MEDCLASS_LOCAL:
+ printf(" Local"); /* XXX */
+ break;
+ case MEDCLASS_IPV4:
+ if (len != 7)
+ break;
+ printf(" IPv4=%s", ipaddr_string(p + 3));
+ break;
+ case MEDCLASS_MAC:
+ if (len != 9)
+ break;
+ printf(" MAC=%02x:%02x:%02x:%02x:%02x:%02x",
+ p[3], p[4], p[5], p[6], p[7], p[8]);
+ break;
+ case MEDCLASS_MNB:
+ printf(" Magic-Num-Block"); /* XXX */
+ break;
+ case MEDCLASS_PSNDN:
+ printf(" PSNDN"); /* XXX */
+ break;
+ }
+ break;
+
+/* XXX: to be supported */
+#if 0
+ case LCPOPT_DEP6:
+ case LCPOPT_FCSALT:
+ case LCPOPT_SDP:
+ case LCPOPT_NUMMODE:
+ case LCPOPT_DEP12:
+ case LCPOPT_DEP14:
+ case LCPOPT_DEP15:
+ case LCPOPT_DEP16:
+ case LCPOPT_MLSSNHF:
+ case LCPOPT_PROP:
+ case LCPOPT_DCEID:
+ case LCPOPT_MPP:
+ case LCPOPT_LCPAOPT:
+ case LCPOPT_COBS:
+ case LCPOPT_PE:
+ case LCPOPT_MLHF:
+ case LCPOPT_I18N:
+ case LCPOPT_SDLOS:
+ case LCPOPT_PPPMUX:
+ break;
+#endif
}
return len;
}
@@ -344,119 +671,365 @@ print_lcp_config_options(const u_char *p)
static void
handle_chap(const u_char *p, int length)
{
- int x;
- const u_char *ptr;
+ u_int code, len;
+ int val_size, name_size, msg_size;
+ const u_char *p0;
+ int i;
- x = p[4];
+ p0 = p;
+ if (length < 1) {
+ printf("[|chap]");
+ return;
+ } else if (length < 4) {
+ printf("[|chap 0x%02x]", *p);
+ return;
+ }
- if ((x >= CHAP_CODEMIN) && (x <= CHAP_CODEMAX))
- printf("%s", chapcode[x - 1]);
+ code = *p;
+ if ((code >= CHAP_CODEMIN) && (code <= CHAP_CODEMAX))
+ printf("%s", chapcode[code - 1]);
else {
- printf("0x%02x", x);
+ printf("0x%02x", code);
return;
}
+ p++;
+
+ printf("(%u)", *p); /* ID */
+ p++;
+
+ len = EXTRACT_16BITS(p);
+ p += 2;
- length -= 4;
-
- switch (p[4]) {
+ /*
+ * Note that this is a generic CHAP decoding routine. Since we
+ * don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1,
+ * MS-CHAPv2) is used at this point, we can't decode packet
+ * specifically to each algorithms. Instead, we simply decode
+ * the GCD (Gratest Common Denominator) for all algorithms.
+ */
+ switch (code) {
case CHAP_CHAL:
case CHAP_RESP:
+ if (length - (p - p0) < 1)
+ return;
+ val_size = *p; /* value size */
+ p++;
+ if (length - (p - p0) < val_size)
+ return;
printf(", Value=");
- x = p[8]; /* value size */
- ptr = p + 9;
- while (--x >= 0)
- printf("%02x", *ptr++);
- x = length - p[8] - 1;
+ for (i = 0; i < val_size; i++)
+ printf("%02x", *p++);
+ name_size = len - (p - p0);
printf(", Name=");
- while (--x >= 0) {
- if (isprint(*ptr))
- printf("%c", *ptr);
- else
- printf("\\%03o", *ptr);
- ptr++;
- }
+ for (i = 0; i < name_size; i++)
+ safeputchar(*p++);
+ break;
+ case CHAP_SUCC:
+ case CHAP_FAIL:
+ msg_size = len - (p - p0);
+ printf(", Msg=");
+ for (i = 0; i< msg_size; i++)
+ safeputchar(*p++);
break;
}
}
-/* PAP */
+/* PAP (see RFC 1334) */
static void
handle_pap(const u_char *p, int length)
{
- int x;
- const u_char *ptr;
+ u_int code, len;
+ int peerid_len, passwd_len, msg_len;
+ const u_char *p0;
+ int i;
- x = p[4];
+ p0 = p;
+ if (length < 1) {
+ printf("[|pap]");
+ return;
+ } else if (length < 4) {
+ printf("[|pap 0x%02x]", *p);
+ return;
+ }
- if ((x >= PAP_CODEMIN) && (x <= PAP_CODEMAX))
- printf("%s", papcode[x - 1]);
+ code = *p;
+ if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX))
+ printf("%s", papcode[code - 1]);
else {
- printf("0x%02x", x);
+ printf("0x%02x", code);
return;
}
+ p++;
+
+ printf("(%u)", *p); /* ID */
+ p++;
+
+ len = EXTRACT_16BITS(p);
+ p += 2;
- length -= 4;
-
- switch (x) {
+ switch (code) {
case PAP_AREQ:
- printf(", Peer-Id=");
- x = p[8]; /* peerid size */
- ptr = p + 9;
- while (--x >= 0) {
- if (isprint(*ptr))
- printf("%c", *ptr);
- else
- printf("\\%03o", *ptr);
- ptr++;
- }
- x = *ptr++;
- printf(", Passwd=");
- while (--x >= 0) {
- if (isprint(*ptr))
- printf("%c", *ptr);
- else
- printf("\\%03o", *ptr);
- ptr++;
- }
+ if (length - (p - p0) < 1)
+ return;
+ peerid_len = *p; /* Peer-ID Length */
+ p++;
+ if (length - (p - p0) < peerid_len)
+ return;
+ printf(", Peer=");
+ for (i = 0; i < peerid_len; i++)
+ safeputchar(*p++);
+
+ if (length - (p - p0) < 1)
+ return;
+ passwd_len = *p; /* Password Length */
+ p++;
+ if (length - (p - p0) < passwd_len)
+ return;
+ printf(", Name=");
+ for (i = 0; i < passwd_len; i++)
+ safeputchar(*p++);
break;
case PAP_AACK:
case PAP_ANAK:
+ if (length - (p - p0) < 1)
+ return;
+ msg_len = *p; /* Msg-Length */
+ p++;
+ if (length - (p - p0) < msg_len)
+ return;
+ printf(", Msg=");
+ for (i = 0; i< msg_len; i++)
+ safeputchar(*p++);
break;
}
+ return;
}
-/* IPCP */
+/* BAP */
static void
-handle_ipcp(const u_char *p, int length)
+handle_bap(const u_char *p, int length)
+{
+ /* XXX: to be supported!! */
+}
+
+
+/* IPCP config options */
+static int
+print_ipcp_config_options(const u_char *p, int length)
+{
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
+ switch (opt) {
+ case IPCPOPT_2ADDR: /* deprecated */
+ if (len != 10)
+ goto invlen;
+ printf(", IP-Addrs src=%s dst=%s",
+ ipaddr_string(p + 2),
+ ipaddr_string(p + 6));
+ break;
+ case IPCPOPT_IPCOMP:
+ if (len < 4)
+ goto invlen;
+ printf(", IP-Comp");
+ if (EXTRACT_16BITS(p + 2) == PPP_VJC) {
+ printf(" VJ-Comp");
+ /* XXX: VJ-Comp parameters should be decoded */
+ } else
+ printf(" unknown-comp-proto=%04x", EXTRACT_16BITS(p + 2));
+ break;
+ case IPCPOPT_ADDR:
+ if (len != 6)
+ goto invlen;
+ printf(", IP-Addr=%s", ipaddr_string(p + 2));
+ break;
+ case IPCPOPT_MOBILE4:
+ if (len != 6)
+ goto invlen;
+ printf(", Home-Addr=%s", ipaddr_string(p + 2));
+ break;
+ case IPCPOPT_PRIDNS:
+ if (len != 6)
+ goto invlen;
+ printf(", Pri-DNS=%s", ipaddr_string(p + 2));
+ break;
+ case IPCPOPT_PRINBNS:
+ if (len != 6)
+ goto invlen;
+ printf(", Pri-NBNS=%s", ipaddr_string(p + 2));
+ break;
+ case IPCPOPT_SECDNS:
+ if (len != 6)
+ goto invlen;
+ printf(", Sec-DNS=%s", ipaddr_string(p + 2));
+ break;
+ case IPCPOPT_SECNBNS:
+ if (len != 6)
+ goto invlen;
+ printf(", Sec-NBNS=%s", ipaddr_string(p + 2));
+ break;
+ default:
+ printf(", unknown-%d", opt);
+ break;
+ }
+ return len;
+
+invlen:
+ printf(", invalid-length-%d", opt);
+ return 0;
+}
+
+/* CCP config options */
+static int
+print_ccp_config_options(const u_char *p, int length)
{
- length -= 4;
-
- switch (p[8]) {
- case IPCP_2ADDR:
- printf("IP-Addresses");
- printf(", src=%s", ipaddr_string(p + 10));
- printf(", drc=%s", ipaddr_string(p + 14));
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
+ if ((opt >= CCPOPT_MIN) && (opt <= CCPOPT_MAX))
+ printf(", %s", ccpconfopts[opt]);
+#if 0 /* XXX */
+ switch (opt) {
+ case CCPOPT_OUI:
+ case CCPOPT_PRED1:
+ case CCPOPT_PRED2:
+ case CCPOPT_PJUMP:
+ case CCPOPT_HPPPC:
+ case CCPOPT_STACLZS:
+ case CCPOPT_MPPC:
+ case CCPOPT_GFZA:
+ case CCPOPT_V42BIS:
+ case CCPOPT_BSDCOMP:
+ case CCPOPT_LZSDCP:
+ case CCPOPT_MVRCA:
+ case CCPOPT_DEC:
+ case CCPOPT_DEFLATE:
+ case CCPOPT_RESV:
break;
-
- case IPCP_CP:
- printf("IP-Compression-Protocol");
+
+ default:
+ printf(", unknown-%d", opt);
break;
+ }
+#endif
+ return len;
+}
+
+/* BACP config options */
+static int
+print_bacp_config_options(const u_char *p, int length)
+{
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
+ if (opt == BACPOPT_FPEER) {
+ printf(", Favored-Peer");
+ printf(" Magic-Num=%08x", EXTRACT_32BITS(p + 2));
+ } else {
+ printf(", unknown-option-%d", opt);
+ }
+ return len;
+}
+
- case IPCP_ADDR:
- printf("IP-Address=%s", ipaddr_string(p + 10));
+/* PPP */
+static void
+handle_ppp(u_int proto, const u_char *p, int length)
+{
+ switch (proto) {
+ case PPP_LCP:
+ case PPP_IPCP:
+ case PPP_CCP:
+ case PPP_BACP:
+ handle_ctrl_proto(proto, p, length);
+ break;
+ case PPP_CHAP:
+ handle_chap(p, length);
+ break;
+ case PPP_PAP:
+ handle_pap(p, length);
+ break;
+ case PPP_BAP: /* XXX: not yet completed */
+ handle_bap(p, length);
+ break;
+ case ETHERTYPE_IP: /*XXX*/
+ case PPP_IP:
+ ip_print(p, length);
+ break;
+#ifdef INET6
+ case ETHERTYPE_IPV6: /*XXX*/
+ case PPP_IPV6:
+ ip6_print(p, length);
+ break;
+#endif
+ case ETHERTYPE_IPX: /*XXX*/
+ case PPP_IPX:
+ ipx_print(p, length);
break;
}
}
-
+
/* Standard PPP printer */
void
+ppp_print(register const u_char *p, u_int length)
+{
+ u_int proto;
+ u_int full_length = length;
+
+ /*
+ * Here, we assume that p points to the Address and Control
+ * field (if they present).
+ */
+ if (length < 2)
+ goto trunc;
+ if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
+ p += 2; /* ACFC not used */
+ length -= 2;
+ }
+
+ if (length < 2)
+ goto trunc;
+ if (*p % 2) {
+ proto = *p; /* PFC is used */
+ p++;
+ length--;
+ } else {
+ proto = EXTRACT_16BITS(p);
+ p += 2;
+ length -= 2;
+ }
+
+ printf("%s %d: ", ppp_protoname(proto), full_length);
+
+ handle_ppp(proto, p, length);
+ return;
+trunc:
+ printf("[|ppp]");
+}
+
+
+/* PPP I/F printer */
+void
ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- const struct ip *ip;
- u_int proto;
ts_print(&h->ts);
@@ -468,50 +1041,144 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
+ * Rather than pass them all the way down, we set these globals. */
+
+ packetp = p;
+ snapend = p + caplen;
+
+#if 0
+ /*
+ * XXX: seems to assume that there are 2 octets prepended to an
+ * actual PPP frame. The 1st octet looks like Input/Output flag
+ * while 2nd octet is unknown, at least to me
+ * (mshindo@mshindo.net).
+ *
+ * That was what the original tcpdump code did.
+ *
+ * FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound
+ * packets and 0 for inbound packets - but only if the
+ * protocol field has the 0x8000 bit set (i.e., it's a network
+ * control protocol); it does so before running the packet through
+ * "bpf_filter" to see if it should be discarded, and to see
+ * if we should update the time we sent the most recent packet...
+ *
+ * ...but it puts the original address field back after doing
+ * so.
+ *
+ * NetBSD's "if_ppp.c" doesn't set the first octet in that fashion.
+ *
+ * I don't know if any PPP implementation handed up to a BPF
+ * device packets with the first octet being 1 for outbound and
+ * 0 for inbound packets, so I (guy@alum.mit.edu) don't know
+ * whether that ever needs to be checked or not.
+ *
+ * Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP,
+ * and its tcpdump appears to assume that the frame always
+ * begins with an address field and a control field, and that
+ * the address field might be 0x0f or 0x8f, for Cisco
+ * point-to-point with HDLC framing as per section 4.3.1 of RFC
+ * 1547, as well as 0xff, for PPP in HDLC-like framing as per
+ * RFC 1662.
+ *
+ * (Is the Cisco framing in question what DLT_C_HDLC, in
+ * BSD/OS, is?)
+ */
+ if (eflag)
+ printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]);
+#endif
+
+ ppp_print(p, length);
+
+ if (xflag)
+ default_print(p, caplen);
+out:
+ putchar('\n');
+}
+
+/*
+ * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
+ * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
+ * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL,
+ * discard them *if* those are the first two octets, and parse the remaining
+ * packet as a PPP packet, as "ppp_print()" does).
+ *
+ * This handles, for example, DLT_PPP_SERIAL in NetBSD.
+ */
+void
+ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
+ register const u_char *p)
+{
+ register u_int length = h->len;
+ register u_int caplen = h->caplen;
+ u_int proto;
+
+ if (caplen < 2) {
+ printf("[|ppp]");
+ goto out;
+ }
+
+ /*
+ * Some printers want to get back at the link level addresses,
+ * and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
- proto = ntohs(*(u_short *)&p[2]);
packetp = p;
snapend = p + caplen;
- if (eflag)
- printf("%c %4d %02x %s: ", p[0] ? 'O' : 'I', length,
- p[1], ppp_protoname(proto));
+ switch (p[0]) {
- length -= PPP_HDRLEN;
- ip = (struct ip *)(p + PPP_HDRLEN);
- switch (proto) {
- case PPP_LCP:
- handle_lcp(p, length);
- break;
- case PPP_CHAP:
- handle_chap(p, length);
- break;
- case PPP_PAP:
- handle_pap(p, length);
- break;
- case PPP_IPCP:
- handle_ipcp(p, length);
- break;
- case ETHERTYPE_IP: /*XXX*/
- case PPP_IP:
- ip_print((const u_char *)ip, length);
+ case PPP_ADDRESS:
+ if (caplen < 4) {
+ printf("[|ppp]");
+ goto out;
+ }
+
+ ts_print(&h->ts);
+ if (eflag)
+ printf("%02x %02x %d ", p[0], p[1], length);
+ p += 2;
+ length -= 2;
+
+ proto = EXTRACT_16BITS(p);
+ p += 2;
+ length -= 2;
+ printf("%s: ", ppp_protoname(proto));
+
+ handle_ppp(proto, p, length);
break;
-#ifdef INET6
- case ETHERTYPE_IPV6: /*XXX*/
-#ifdef PPP_IPV6
- case PPP_IPV6:
-#endif
- ip6_print((const u_char *)ip, length);
+
+ case CHDLC_UNICAST:
+ case CHDLC_BCAST:
+ /*
+ * Have the Cisco HDLC print routine do all the work.
+ */
+ chdlc_if_print(user, h, p);
+ return;
+
+ default:
+ ts_print(&h->ts);
+ if (eflag)
+ printf("%02x %02x %d ", p[0], p[1], length);
+ p += 2;
+ length -= 2;
+
+ /*
+ * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats
+ * the next two octets as an Ethernet type; does that
+ * ever happen?
+ */
+ printf("unknown addr %02x; ctrl %02x", p[0], p[1]);
break;
-#endif
}
+
if (xflag)
- default_print((const u_char *)ip, caplen - PPP_HDRLEN);
+ default_print(p, caplen);
out:
putchar('\n');
}
+
+
struct tok ppptype2str[] = {
{ PPP_IP, "IP" },
{ PPP_OSI, "OSI" },
@@ -532,15 +1199,18 @@ struct tok ppptype2str[] = {
{ PPP_OSICP, "OSICP" },
{ PPP_NSCP, "NSCP" },
{ PPP_DECNETCP, "DECNETCP" },
- { PPP_APPLECP, "APPLECP" },
+ { PPP_APPLECP, "APPLECP" },
{ PPP_IPXCP, "IPXCP" },
{ PPP_STIICP, "STIICP" },
- { PPP_VINESCP, "VINESCP" },
+ { PPP_VINESCP, "VINESCP" },
{ PPP_LCP, "LCP" },
{ PPP_PAP, "PAP" },
{ PPP_LQM, "LQM" },
{ PPP_CHAP, "CHAP" },
+ { PPP_BACP, "BACP" },
+ { PPP_BAP, "BAP" },
+ { PPP_MP, "MP" },
{ 0, NULL }
};
@@ -555,7 +1225,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
register u_int length = h->len;
register u_int caplen = h->caplen;
register int hdrlength;
- u_short ptype;
+ u_int16_t ptype;
const u_char *q;
int i;
@@ -577,26 +1247,26 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
- if (eflag)
+ if (eflag)
printf("%02x %02x ", p[0], p[1]);
p += 2;
hdrlength = 2;
}
- if (eflag)
+ if (eflag)
printf("%d ", length);
/* Retrieve the protocol type */
if (*p & 01) {
/* Compressed protocol field */
ptype = *p;
- if (eflag)
+ if (eflag)
printf("%02x ", ptype);
p++;
hdrlength += 1;
} else {
/* Un-compressed protocol field */
- ptype = ntohs(*(u_short *)p);
- if (eflag)
+ ptype = ntohs(*(u_int16_t *)p);
+ if (eflag)
printf("%04x ", ptype);
p += 2;
hdrlength += 2;
@@ -613,7 +1283,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
ph = (struct ppp_header *)q;
if (ph->phdr_addr == PPP_ADDRESS
&& ph->phdr_ctl == PPP_CONTROL) {
- if (eflag)
+ if (eflag)
printf("%02x %02x ", q[0], q[1]);
ptype = ntohs(ph->phdr_type);
if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
@@ -628,9 +1298,9 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
printf("] ");
}
}
- if (eflag)
- printf("%d ", length);
}
+ if (eflag)
+ printf("%d ", length);
if (p[SLC_CHL]) {
q = p + SLC_BPFHDRLEN + p[SLC_LLHL];
@@ -639,15 +1309,31 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
ptype = vjc_print(q, length - (q - p), ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
- if (ptype == PPP_IP)
+ switch (ptype) {
+ case PPP_IP:
ip_print(p, length);
+ break;
+#ifdef INET6
+ case PPP_IPV6:
+ ip6_print(p, length);
+ break;
+#endif
+ }
goto printx;
case PPP_VJNC:
ptype = vjc_print(q, length - (q - p), ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
- if (ptype == PPP_IP)
+ switch (ptype) {
+ case PPP_IP:
ip_print(p, length);
+ break;
+#ifdef INET6
+ case PPP_IPV6:
+ ip6_print(p, length);
+ break;
+#endif
+ }
goto printx;
default:
if (eflag) {
@@ -666,10 +1352,18 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
length -= hdrlength;
p += hdrlength;
- if (ptype == PPP_IP)
+ switch (ptype) {
+ case PPP_IP:
ip_print(p, length);
- else
+ break;
+#ifdef INET6
+ case PPP_IPV6:
+ ip6_print(p, length);
+ break;
+#endif
+ default:
printf("%s ", tok2str(ppptype2str, "proto-#%d", ptype));
+ }
printx:
if (xflag)
diff --git a/contrib/tcpdump/print-pppoe.c b/contrib/tcpdump/print-pppoe.c
index 1aaa0da..81475cd 100644
--- a/contrib/tcpdump/print-pppoe.c
+++ b/contrib/tcpdump/print-pppoe.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
-"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.3 1999/12/15 00:23:06 fenner Exp $ (LBL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.12 2000/10/09 02:59:40 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,18 +32,8 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
@@ -51,6 +41,7 @@ struct rtentry;
#include "addrtoname.h"
#include "ppp.h"
#include "ethertype.h"
+#include "ether.h"
#include "extract.h" /* must come after interface.h */
/* Codes */
@@ -83,7 +74,7 @@ enum {
PPPOE_RELAY_SID = 0x0110,
PPPOE_SERVICE_NAME_ERROR = 0x0201,
PPPOE_AC_SYSTEM_ERROR = 0x0202,
- PPPOE_GENERIC_ERROR = 0x0203,
+ PPPOE_GENERIC_ERROR = 0x0203
};
static struct tok pppoetag2str[] = {
@@ -110,7 +101,7 @@ pppoe_print(register const u_char *bp, u_int length)
const u_char *pppoe_packet, *pppoe_payload;
eh = (struct ether_header *)packetp;
- pppoe_packet = packetp+sizeof(struct ether_header);
+ pppoe_packet = packetp+ETHER_HDRLEN;
if (pppoe_packet > snapend) {
printf("[|pppoe]");
return;
@@ -157,12 +148,12 @@ pppoe_print(register const u_char *bp, u_int length)
if (pppoe_code) {
/* PPP session packets don't contain tags */
- u_short tag_type = -1, tag_len;
+ u_short tag_type = 0xffff, tag_len;
const u_char *p = pppoe_payload;
/* loop invariant:
p points to next tag,
- tag_type is previous tag or -1 for first iteration
+ tag_type is previous tag or 0xffff for first iteration
*/
while (tag_type &&
p+4 < pppoe_payload + length &&
@@ -199,6 +190,10 @@ pppoe_print(register const u_char *bp, u_int length)
/* p points to next tag */
}
} else {
+#if 0
+ /* We now make use of ppp_print() instead, because it has more
+ comprehensive support for PPP. It also gives us a consistent
+ output with other protocols like L2TP. */
u_short ptype;
if (pppoe_payload[0] & 0x1) {
ptype = pppoe_payload[0];
@@ -219,6 +214,9 @@ pppoe_print(register const u_char *bp, u_int length)
lcp_print(pppoe_payload, pppoe_length);
else
printf("%s ", tok2str(ppptype2str, "proto-0x%x", ptype));
+#endif
+ printf(" ");
+ ppp_print(pppoe_payload, pppoe_length);
}
return;
}
diff --git a/contrib/tcpdump/print-radius.c b/contrib/tcpdump/print-radius.c
new file mode 100644
index 0000000..32c8575
--- /dev/null
+++ b/contrib/tcpdump/print-radius.c
@@ -0,0 +1,838 @@
+/*
+ * Radius printer routines as specified on:
+ *
+ * RFC 2865:
+ * "Remote Authentication Dial In User Service (RADIUS)"
+ *
+ * RFC 2866:
+ * "RADIUS Accounting"
+ *
+ * RFC 2867:
+ * "RADIUS Accounting Modifications for Tunnel Protocol Support"
+ *
+ * RFC 2868:
+ * "RADIUS Attributes for Tunnel Protocol Support"
+ *
+ * RFC 2869:
+ * "RADIUS Extensions"
+ *
+ * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
+ *
+ * TODO: Among other things to print ok MacIntosh and Vendor values
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$Id: print-radius.c,v 1.5 2000/12/18 08:16:58 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+
+#include <netinet/in.h>
+
+#include <stdio.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h"
+
+#define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
+
+#define PRINT_HEX(bytes_len, ptr_data) \
+ while(bytes_len) \
+ { \
+ printf("%02X", *ptr_data ); \
+ ptr_data++; \
+ bytes_len--; \
+ }
+
+
+/* Radius packet codes */
+#define RADCMD_ACCESS_REQ 1 /* Access-Request */
+#define RADCMD_ACCESS_ACC 2 /* Access-Accept */
+#define RADCMD_ACCESS_REJ 3 /* Access-Reject */
+#define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
+#define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
+#define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
+#define RADCMD_STATUS_SER 12 /* Status-Server */
+#define RADCMD_STATUS_CLI 13 /* Status-Client */
+#define RADCMD_RESERVED 255 /* Reserved */
+
+
+/********************************/
+/* Begin Radius Attribute types */
+/********************************/
+#define SERV_TYPE 6
+#define FRM_IPADDR 8
+#define LOG_IPHOST 14
+#define LOG_SERVICE 15
+#define FRM_IPX 23
+#define SESSION_TIMEOUT 27
+#define IDLE_TIMEOUT 28
+#define FRM_ATALK_LINK 37
+#define FRM_ATALK_NETWORK 38
+
+#define ACCT_DELAY 41
+#define ACCT_SESSION_TIME 46
+
+#define TUNNEL_TYPE 64
+#define TUNNEL_MEDIUM 65
+#define TUNNEL_CLIENT_END 66
+#define TUNNEL_SERVER_END 67
+#define TUNNEL_PASS 69
+
+#define ARAP_PASS 70
+#define ARAP_FEATURES 71
+
+#define TUNNEL_PRIV_GROUP 81
+#define TUNNEL_ASSIGN_ID 82
+#define TUNNEL_PREFERENCE 83
+
+#define ARAP_CHALLENGE_RESP 84
+#define ACCT_INT_INTERVAL 85
+
+#define TUNNEL_CLIENT_AUTH 90
+#define TUNNEL_SERVER_AUTH 91
+/********************************/
+/* End Radius Attribute types */
+/********************************/
+
+
+static void print_attr_string(register u_char *, u_int, u_short );
+static void print_attr_num(register u_char *, u_int, u_short );
+static void print_attr_address(register u_char *, u_int, u_short);
+static void print_attr_time(register u_char *, u_int, u_short);
+static void print_attr_strange(register u_char *, u_int, u_short);
+
+
+struct radius_hdr { u_int8_t code; /* Radius packet code */
+ u_int8_t id; /* Radius packet id */
+ u_int16_t len; /* Radius total length */
+ u_int8_t auth[16]; /* Authenticator */
+ };
+
+
+struct radius_attr { u_int8_t type; /* Attribute type */
+ u_int8_t len; /* Attribute length */
+ };
+
+
+/* Service-Type Attribute standard values */
+static const char *serv_type[]={ NULL,
+ "Login",
+ "Framed",
+ "Callback Login",
+ "Callback Framed",
+ "Outbound",
+ "Administrative",
+ "NAS Prompt",
+ "Authenticate Only",
+ "Callback NAS Prompt",
+ "Call Check",
+ "Callback Administrative",
+ };
+
+/* Framed-Protocol Attribute standard values */
+static const char *frm_proto[]={ NULL,
+ "PPP",
+ "SLIP",
+ "ARAP",
+ "Gandalf proprietary",
+ "Xylogics IPX/SLIP",
+ "X.75 Synchronous",
+ };
+
+/* Framed-Routing Attribute standard values */
+static const char *frm_routing[]={ "None",
+ "Send",
+ "Listen",
+ "Send&Listen",
+ };
+
+/* Framed-Compression Attribute standard values */
+static const char *frm_comp[]={ "None",
+ "VJ TCP/IP",
+ "IPX",
+ "Stac-LZS",
+ };
+
+/* Login-Service Attribute standard values */
+static const char *login_serv[]={ "Telnet",
+ "Rlogin",
+ "TCP Clear",
+ "PortMaster(proprietary)",
+ "LAT",
+ "X.25-PAD",
+ "X.25-T3POS",
+ "Unassigned",
+ "TCP Clear Quiet",
+ };
+
+
+/* Termination-Action Attribute standard values */
+static const char *term_action[]={ "Default",
+ "RADIUS-Request",
+ };
+
+/* NAS-Port-Type Attribute standard values */
+static const char *nas_port_type[]={ "Async",
+ "Sync",
+ "ISDN Sync",
+ "ISDN Async V.120",
+ "ISDN Async V.110",
+ "Virtual",
+ "PIAFS",
+ "HDLC Clear Channel",
+ "X.25",
+ "X.75",
+ "G.3 Fax",
+ "SDSL",
+ "ADSL-CAP",
+ "ADSL-DMT",
+ "ISDN-DSL",
+ "Ethernet",
+ "xDSL",
+ "Cable",
+ "Wireless - Other",
+ "Wireless - IEEE 802.11",
+ };
+
+/* Acct-Status-Type Accounting Attribute standard values */
+static const char *acct_status[]={ NULL,
+ "Start",
+ "Stop",
+ "Interim-Update",
+ "Unassigned",
+ "Unassigned",
+ "Unassigned",
+ "Accounting-On",
+ "Accounting-Off",
+ "Tunnel-Start",
+ "Tunnel-Stop",
+ "Tunnel-Reject",
+ "Tunnel-Link-Start",
+ "Tunnel-Link-Stop",
+ "Tunnel-Link-Reject",
+ "Failed",
+ };
+
+/* Acct-Authentic Accounting Attribute standard values */
+static const char *acct_auth[]={ NULL,
+ "RADIUS",
+ "Local",
+ "Remote",
+ };
+
+/* Acct-Terminate-Cause Accounting Attribute standard values */
+static const char *acct_term[]={ NULL,
+ "User Request",
+ "Lost Carrier",
+ "Lost Service",
+ "Idle Timeout",
+ "Session Timeout",
+ "Admin Reset",
+ "Admin Reboot",
+ "Port Error",
+ "NAS Error",
+ "NAS Request",
+ "NAS Reboot",
+ "Port Unneeded",
+ "Port Preempted",
+ "Port Suspended",
+ "Service Unavailable",
+ "Callback",
+ "User Error",
+ "Host Request",
+ };
+
+/* Tunnel-Type Attribute standard values */
+static const char *tunnel_type[]={ NULL,
+ "PPTP",
+ "L2F",
+ "L2TP",
+ "ATMP",
+ "VTP",
+ "AH",
+ "IP-IP",
+ "MIN-IP-IP",
+ "ESP",
+ "GRE",
+ "DVS",
+ "IP-in-IP Tunneling",
+ };
+
+/* Tunnel-Medium-Type Attribute standard values */
+static const char *tunnel_medium[]={ NULL,
+ "IPv4",
+ "IPv6",
+ "NSAP",
+ "HDLC",
+ "BBN 1822",
+ "802",
+ "E.163",
+ "E.164",
+ "F.69",
+ "X.121",
+ "IPX",
+ "Appletalk",
+ "Decnet IV",
+ "Banyan Vines",
+ "E.164 with NSAP subaddress",
+ };
+
+/* ARAP-Zone-Access Attribute standard values */
+static const char *arap_zone[]={ NULL,
+ "Only access to dfl zone",
+ "Use zone filter inc.",
+ "Not used",
+ "Use zone filter exc.",
+ };
+
+static const char *prompt[]={ "No Echo",
+ "Echo",
+ };
+
+
+struct attrtype { char *name; /* Attribute name */
+ const char **subtypes; /* Standard Values (if any) */
+ u_char siz_subtypes; /* Size of total standard values */
+ u_char first_subtype; /* First standard value is 0 or 1 */
+ void (*print_func)(register u_char *, u_int, u_short );
+ } attr_type[]=
+ {
+ { NULL, NULL, 0, 0, NULL },
+ { "User", NULL, 0, 0, print_attr_string },
+ { "Pass", NULL, 0, 0, NULL },
+ { "CHAP-Pass", NULL, 0, 0, NULL },
+ { "NAS_ipaddr", NULL, 0, 0, print_attr_address },
+ { "NAS_port", NULL, 0, 0, print_attr_num },
+ { "Service_type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
+ { "Framed_proto", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
+ { "Framed_ipaddr", NULL, 0, 0, print_attr_address },
+ { "Framed_ipnet", NULL, 0, 0, print_attr_address },
+ { "Framed_routing", frm_routing, TAM_SIZE(frm_routing), 0,
+ print_attr_num },
+ { "Filter_id", NULL, 0, 0, print_attr_string },
+ { "Framed_mtu", NULL, 0, 0, print_attr_num },
+ { "Framed_compress", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num },
+ { "Login_iphost", NULL, 0, 0, print_attr_address },
+ { "Login_service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
+ { "Login_TCP_port", NULL, 0, 0, print_attr_num },
+/*17*/ { "Unassigned", NULL, 0, 0, NULL },
+ { "Reply", NULL, 0, 0, print_attr_string },
+ { "Callback-number", NULL, 0, 0, print_attr_string },
+ { "Callback-id", NULL, 0, 0, print_attr_string },
+/*21*/ { "Unassigned", NULL, 0, 0, NULL },
+ { "Framed_route", NULL, 0, 0, print_attr_string },
+ { "Framed_ipx_net", NULL, 0, 0, print_attr_num },
+ { "State", NULL, 0, 0, print_attr_string },
+ { "Class", NULL, 0, 0, print_attr_string },
+ { "Vendor_specific", NULL, 0, 0, print_attr_string },
+ { "Session_timeout", NULL, 0, 0, print_attr_num },
+ { "Idle_timeout", NULL, 0, 0, print_attr_num },
+ { "Term_action", term_action, TAM_SIZE(term_action), 0, print_attr_num },
+ { "Called_station", NULL, 0, 0, print_attr_string },
+ { "Calling_station", NULL, 0, 0, print_attr_string },
+ { "NAS_id", NULL, 0, 0, print_attr_string },
+ { "Proxy_state", NULL, 0, 0, print_attr_string },
+ { "Login_LAT_service", NULL, 0, 0, print_attr_string },
+ { "Login_LAT_node", NULL, 0, 0, print_attr_string },
+ { "Login_LAT_group", NULL, 0, 0, print_attr_string },
+ { "Framed_atalk_link", NULL, 0, 0, print_attr_num },
+ { "Framed_atalk_net", NULL, 0, 0, print_attr_num },
+ { "Framed_atalk_zone", NULL, 0, 0, print_attr_string },
+ { "Acct_status", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
+ { "Acct_delay", NULL, 0, 0, print_attr_num },
+ { "Acct_in_octets", NULL, 0, 0, print_attr_num },
+ { "Acct_out_octets", NULL, 0, 0, print_attr_num },
+ { "Acct_session_id", NULL, 0, 0, print_attr_string },
+ { "Acct_authentic", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
+ { "Acct_session_time", NULL, 0, 0, print_attr_num },
+ { "Acct_in_packets", NULL, 0, 0, print_attr_num },
+ { "Acct_out_packets", NULL, 0, 0, print_attr_num },
+ { "Acct_term_cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
+ { "Acct_multi_session_id", NULL, 0, 0, print_attr_string },
+ { "Acct_link_count", NULL, 0, 0, print_attr_num },
+ { "Acct_in_giga", NULL, 0, 0, print_attr_num },
+ { "Acct_out_giga", NULL, 0, 0, print_attr_num },
+/*54*/ { "Unassigned", NULL, 0, 0, NULL },
+ { "Event_timestamp", NULL, 0, 0, print_attr_time },
+/*56*/ { "Unassigned", NULL, 0, 0, NULL },
+/*57*/ { "Unassigned", NULL, 0, 0, NULL },
+/*58*/ { "Unassigned", NULL, 0, 0, NULL },
+/*59*/ { "Unassigned", NULL, 0, 0, NULL },
+ { "CHAP_challenge", NULL, 0, 0, print_attr_string },
+ { "NAS_port_type", nas_port_type, TAM_SIZE(nas_port_type), 0,
+ print_attr_num },
+ { "Port_limit", NULL, 0, 0, print_attr_num },
+/*63*/ { "Login_LAT_port", NULL, 0, 0, print_attr_string },
+ { "Tunnel_type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
+ { "Tunnel_medium", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1,
+ print_attr_num },
+ { "Tunnel_client_end", NULL, 0, 0, print_attr_string },
+ { "Tunnel_server_end", NULL, 0, 0, print_attr_string },
+ { "Acct_tunnel_connect", NULL, 0, 0, print_attr_string },
+ { "Tunnel_pass", NULL, 0, 0, print_attr_string },
+ { "ARAP_pass", NULL, 0, 0, print_attr_strange },
+ { "ARAP_feature", NULL, 0, 0, print_attr_strange },
+/*72*/ { "ARAP_zone_acces", arap_zone, TAM_SIZE(arap_zone)-1, 1,
+ print_attr_num },
+ { "ARAP_security", NULL, 0, 0, print_attr_string },
+ { "ARAP_security_data", NULL, 0, 0, print_attr_string },
+ { "Password_retry", NULL, 0, 0, print_attr_num },
+ { "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num },
+ { "Connect_info", NULL, 0, 0, print_attr_string },
+ { "Config_token", NULL, 0, 0, print_attr_string },
+ { "EAP_msg", NULL, 0, 0, print_attr_string },
+/*80*/ { "Message_auth", NULL, 0, 0, print_attr_string },
+ { "Tunnel_priv_group", NULL, 0, 0, print_attr_string },
+ { "Tunnel_assign_id", NULL, 0, 0, print_attr_string },
+ { "Tunnel_pref", NULL, 0, 0, print_attr_num },
+ { "ARAP_challenge_resp", NULL, 0, 0, print_attr_strange },
+ { "Acct_interim_interval", NULL, 0, 0, print_attr_num },
+/*86*/ { "Acct_tunnel_pack_lost", NULL, 0, 0, print_attr_num },
+ { "NAS_port_id", NULL, 0, 0, print_attr_string },
+ { "Framed_pool", NULL, 0, 0, print_attr_string },
+ { "Unassigned", NULL, 0, 0, NULL },
+ { "Tunnel_client_auth_id", NULL, 0, 0, print_attr_string },
+ { "Tunnel_server_auth_id", NULL, 0, 0, print_attr_string },
+/*92*/ { "Unassigned", NULL, 0, 0, NULL },
+/*93*/ { "Unassigned", NULL, 0, 0, NULL }
+ };
+
+
+/*****************************/
+/* Print an attribute string */
+/* value pointed by 'data' */
+/* and 'length' size. */
+/*****************************/
+/* Returns nothing. */
+/*****************************/
+static void
+print_attr_string(register u_char *data, u_int length, u_short attr_code )
+{
+ register u_int i;
+
+ TCHECK2(data[0],length);
+
+ printf("{");
+ switch(attr_code)
+ {
+ case TUNNEL_PASS:
+ if (*data && (*data <=0x1F) )
+ printf("Tag[%d] ",*data);
+ data++;
+ printf("Salt[%d] ",EXTRACT_16BITS(data) );
+ data+=2;
+ length-=2;
+ break;
+ case TUNNEL_CLIENT_END:
+ case TUNNEL_SERVER_END:
+ case TUNNEL_PRIV_GROUP:
+ case TUNNEL_ASSIGN_ID:
+ case TUNNEL_CLIENT_AUTH:
+ case TUNNEL_SERVER_AUTH:
+ if (*data <= 0x1F)
+ {
+ printf("Tag[%d] ",*data);
+ data++;
+ length--;
+ }
+ break;
+ }
+
+ for (i=0; i < length ; i++, data++)
+ printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
+
+ printf("}");
+
+ return;
+
+ trunc:
+ printf("|radius");
+}
+
+
+/******************************/
+/* Print an attribute numeric */
+/* value pointed by 'data' */
+/* and 'length' size. */
+/******************************/
+/* Returns nothing. */
+/******************************/
+static void
+print_attr_num(register u_char *data, u_int length, u_short attr_code )
+{
+ u_int8_t tag;
+ u_int32_t timeout;
+
+ if (length != 4)
+ {
+ printf("{length %u != 4}", length);
+ return;
+ }
+
+ TCHECK2(data[0],4);
+ /* This attribute has standard values */
+ if (attr_type[attr_code].siz_subtypes)
+ {
+ static const char **table;
+ u_int32_t data_value;
+ table = attr_type[attr_code].subtypes;
+
+ if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
+ {
+ if (!*data)
+ printf("{Tag[Unused]");
+ else
+ printf("{Tag[%d]", *data);
+ data++;
+ data_value = EXTRACT_24BITS(data);
+ }
+ else
+ {
+ data++;
+ data_value = EXTRACT_32BITS(data);
+ }
+ if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 +
+ attr_type[attr_code].first_subtype) )
+ printf("{%s}",table[data_value]);
+ else
+ printf("{#%d}",data_value);
+ }
+ else
+ {
+ switch(attr_code) /* Be aware of special cases... */
+ {
+ case FRM_IPX:
+ if (EXTRACT_32BITS( data) == 0xFFFFFFFE )
+ printf("{NAS_select}");
+ else
+ printf("{%d}",EXTRACT_32BITS( data) );
+ break;
+
+ case SESSION_TIMEOUT:
+ case IDLE_TIMEOUT:
+ case ACCT_DELAY:
+ case ACCT_SESSION_TIME:
+ case ACCT_INT_INTERVAL:
+ timeout = EXTRACT_32BITS( data);
+ if ( timeout < 60 )
+ printf( "{%02d secs}", timeout);
+ else
+ {
+ if ( timeout < 3600 )
+ printf( "{%02d:%02d min}",
+ timeout / 60, timeout % 60);
+ else
+ printf( "{%02d:%02d:%02d hours}",
+ timeout / 3600, (timeout % 3600) / 60,
+ timeout % 60);
+ }
+ break;
+
+ case FRM_ATALK_LINK:
+ if (EXTRACT_32BITS(data) )
+ printf("{%d}",EXTRACT_32BITS(data) );
+ else
+ printf("{Unnumbered}" );
+ break;
+
+ case FRM_ATALK_NETWORK:
+ if (EXTRACT_32BITS(data) )
+ printf("{%d}",EXTRACT_32BITS(data) );
+ else
+ printf("{NAS_assign}" );
+ break;
+
+ case TUNNEL_PREFERENCE:
+ tag = *data;
+ data++;
+ if (tag == 0)
+ printf("{Tag[Unused] %d}",EXTRACT_24BITS(data) );
+ else
+ printf("{Tag[%d] %d}", tag, EXTRACT_24BITS(data) );
+ break;
+
+ default:
+ printf("{%d}",EXTRACT_32BITS( data) );
+ break;
+
+ } /* switch */
+
+ } /* if-else */
+
+ return;
+
+ trunc:
+ printf("|radius}");
+}
+
+
+/*****************************/
+/* Print an attribute IPv4 */
+/* address value pointed by */
+/* 'data' and 'length' size. */
+/*****************************/
+/* Returns nothing. */
+/*****************************/
+static void
+print_attr_address(register u_char *data, u_int length, u_short attr_code )
+{
+ if (length != 4)
+ {
+ printf("{length %u != 4}", length);
+ return;
+ }
+
+ TCHECK2(data[0],4);
+
+ switch(attr_code)
+ {
+ case FRM_IPADDR:
+ case LOG_IPHOST:
+ if (EXTRACT_32BITS(data) == 0xFFFFFFFF )
+ printf("{User_select}");
+ else
+ if (EXTRACT_32BITS(data) == 0xFFFFFFFE )
+ printf("{NAS_select}");
+ else
+ printf("{%s}",ipaddr_string(data));
+ break;
+
+ default:
+ printf("{%s}",ipaddr_string(data) );
+ break;
+ }
+
+ return;
+
+ trunc:
+ printf("{|radius}");
+}
+
+
+/*************************************/
+/* Print an attribute of 'secs since */
+/* January 1, 1970 00:00 UTC' value */
+/* pointed by 'data' and 'length' */
+/* size. */
+/*************************************/
+/* Returns nothing. */
+/*************************************/
+static void print_attr_time(register u_char *data, u_int length, u_short attr_code)
+{
+ time_t attr_time;
+ char string[26];
+
+ if (length != 4)
+ {
+ printf("{length %u != 4}", length);
+ return;
+ }
+
+ TCHECK2(data[0],4);
+
+ attr_time = EXTRACT_32BITS(data);
+ strcpy(string, ctime(&attr_time));
+ /* Get rid of the newline */
+ string[24] = '\0';
+ printf("{%.24s}", string);
+ return;
+
+ trunc:
+ printf("{|radius}");
+}
+
+
+/***********************************/
+/* Print an attribute of 'strange' */
+/* data format pointed by 'data' */
+/* and 'length' size. */
+/***********************************/
+/* Returns nothing. */
+/***********************************/
+static void print_attr_strange(register u_char *data, u_int length, u_short attr_code)
+{
+ u_short len_data;
+
+ switch(attr_code)
+ {
+ case ARAP_PASS:
+ if (length != 16)
+ {
+ printf("{length %u != 16}", length);
+ return;
+ }
+ printf("{User_challenge[");
+ TCHECK2(data[0],8);
+ len_data = 8;
+ PRINT_HEX(len_data, data);
+ printf("] User_resp[");
+ TCHECK2(data[0],8);
+ len_data = 8;
+ PRINT_HEX(len_data, data);
+ printf("]}");
+ break;
+
+ case ARAP_FEATURES:
+ if (length != 14)
+ {
+ printf("{length %u != 14}", length);
+ return;
+ }
+ TCHECK2(data[0],1);
+ if (*data)
+ printf("{User_can_change_pass");
+ else
+ printf("{User_cant_change_pass");
+ data++;
+ TCHECK2(data[0],1);
+ printf(" Min_pass_len[%d]",*data);
+ data++;
+ printf(" Pass_created_at[");
+ TCHECK2(data[0],4);
+ len_data = 4;
+ PRINT_HEX(len_data, data);
+ printf("] Pass_expired_in[");
+ TCHECK2(data[0],4);
+ len_data = 4;
+ PRINT_HEX(len_data, data);
+ printf("] Current_time[");
+ len_data = 4;
+ TCHECK2(data[0],4);
+ PRINT_HEX(len_data, data);
+ printf("]}");
+ break;
+
+ case ARAP_CHALLENGE_RESP:
+ if (length < 8)
+ {
+ printf("{length %u != 8}", length);
+ return;
+ }
+ printf("{");
+ TCHECK2(data[0],8);
+ len_data = 8;
+ PRINT_HEX(len_data, data);
+ printf("}");
+ break;
+ }
+
+ trunc:
+ printf("|radius}");
+}
+
+
+
+static void
+radius_attr_print(register u_char *attr, u_int length)
+{
+ register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
+
+ if (length < 3)
+ {
+ printf(" [|radius]");
+ return;
+ }
+
+ printf(" Attr[ ");
+ while (length > 0)
+ {
+ if ( rad_attr->len <= length )
+ {
+ if ( !rad_attr->type || (rad_attr->type > (TAM_SIZE(attr_type)-1)) )
+ printf("#%d",rad_attr->type);
+ else
+ {
+ printf(" %s",attr_type[rad_attr->type].name);
+
+ if (rad_attr->len > 2)
+ {
+ if ( attr_type[rad_attr->type].print_func )
+ (*attr_type[rad_attr->type].print_func)(
+ ((u_char *)(rad_attr+1)),
+ rad_attr->len - 2, rad_attr->type);
+ }
+ }
+ }
+ else
+ {
+ printf(" [|radius]");
+ return;
+ }
+ length-=(rad_attr->len);
+ rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len);
+ }
+
+ printf(" ]");
+}
+
+
+void
+radius_print(const u_char *dat, u_int length)
+{
+ register const struct radius_hdr *rad;
+ register int i;
+
+ i = min(length, snapend - dat) - sizeof(*rad);
+
+ if (i < 0)
+ {
+ printf(" [|radius]");
+ return;
+ }
+
+ rad = (struct radius_hdr *)dat;
+
+ switch (rad->code)
+ {
+ case RADCMD_ACCESS_REQ:
+ printf(" rad-access-req %d", length);
+ break;
+
+ case RADCMD_ACCESS_ACC:
+ printf(" rad-access-accept %d", length);
+ break;
+
+ case RADCMD_ACCESS_REJ:
+ printf(" rad-access-reject %d", length);
+ break;
+
+ case RADCMD_ACCOUN_REQ:
+ printf(" rad-account-req %d", length);
+ break;
+
+ case RADCMD_ACCOUN_RES:
+ printf(" rad-account-resp %d", length);
+ break;
+
+ case RADCMD_ACCESS_CHA:
+ printf(" rad-access-cha %d", length);
+ break;
+
+ case RADCMD_STATUS_SER:
+ printf(" rad-status-serv %d", length);
+ break;
+
+ case RADCMD_STATUS_CLI:
+ printf(" rad-status-cli %d", length);
+ break;
+
+ case RADCMD_RESERVED:
+ printf(" rad-reserved %d", length);
+ break;
+
+ default:
+ printf(" rad-#%d %d", rad->code, length);
+ break;
+ }
+ printf(" [id %d]", rad->id);
+
+ if (i)
+ radius_attr_print( ((u_char *)(rad+1)), i);
+}
diff --git a/contrib/tcpdump/print-raw.c b/contrib/tcpdump/print-raw.c
index 114ff09..b6e421c 100644
--- a/contrib/tcpdump/print-raw.c
+++ b/contrib/tcpdump/print-raw.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.25 1999/11/21 09:37:00 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.33 2000/10/06 04:23:13 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,20 +34,7 @@ static const char rcsid[] =
#include <sys/file.h>
#include <sys/ioctl.h>
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
-
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <pcap.h>
#include <stdio.h>
@@ -56,10 +43,6 @@ struct rtentry;
#include "addrtoname.h"
#include "interface.h"
-#ifndef AF_NS
-#define AF_NS 6 /* XEROX NS protocols */
-#endif
-
/*
* The DLT_RAW packet has no header. It contains a raw IP packet.
*/
@@ -83,7 +66,7 @@ raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (eflag)
printf("ip: ");
- ip_print(p, length);
+ ipN_print(p, length);
if (xflag)
default_print(p, caplen);
diff --git a/contrib/tcpdump/print-rip.c b/contrib/tcpdump/print-rip.c
index 72e6cfb..1f02c23 100644
--- a/contrib/tcpdump/print-rip.c
+++ b/contrib/tcpdump/print-rip.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.40 1999/11/22 04:24:28 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.47 2000/10/03 04:19:07 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,13 +33,10 @@ static const char rcsid[] =
#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 <stdio.h>
+#include <ctype.h>
+#include <string.h>
#include "interface.h"
#include "addrtoname.h"
@@ -57,6 +54,8 @@ struct rip {
#define RIPCMD_POLL 5 /* want info from everybody */
#define RIPCMD_POLLENTRY 6 /* poll for entry */
+#define RIP_AUTHLEN 16
+
struct rip_netinfo {
u_short rip_family;
u_short rip_tag;
@@ -67,23 +66,83 @@ struct rip_netinfo {
};
static void
-rip_entry_print(register int vers, register const struct rip_netinfo *ni)
+rip_printblk(const u_char *cp, const u_char *ep)
{
- register u_char *cp, *ep;
+ for (; cp < ep; cp += 2)
+ printf(" %04x", EXTRACT_16BITS(cp));
+ return;
+}
- if (EXTRACT_16BITS(&ni->rip_family) != AF_INET) {
+static void
+rip_entry_print_v1(register int vers, register const struct rip_netinfo *ni)
+{
+ register u_short family;
+
+ /* RFC 1058 */
+ family = EXTRACT_16BITS(&ni->rip_family);
+ if (family != AF_INET) {
+ printf(" [family %d:", family);
+ rip_printblk((u_char *)&ni->rip_tag,
+ (u_char *)&ni->rip_metric +
+ sizeof(ni->rip_metric));
+ printf("]");
+ return;
+ }
+ if (ni->rip_tag || ni->rip_dest_mask || ni->rip_router) {
+ /* MBZ fields not zero */
+ printf(" [");
+ rip_printblk((u_char *)&ni->rip_family,
+ (u_char *)&ni->rip_metric +
+ sizeof(ni->rip_metric));
+ printf("]");
+ return;
+ }
+ printf(" {%s}(%d)", ipaddr_string(&ni->rip_dest),
+ EXTRACT_32BITS(&ni->rip_metric));
+}
- printf(" [family %d:", EXTRACT_16BITS(&ni->rip_family));
- cp = (u_char *)&ni->rip_tag;
- ep = (u_char *)&ni->rip_metric + sizeof(ni->rip_metric);
- for (; cp < ep; cp += 2)
- printf(" %04x", EXTRACT_16BITS(cp));
+static void
+rip_entry_print_v2(register int vers, register const struct rip_netinfo *ni)
+{
+ register u_char *p;
+ register u_short family;
+ u_char buf[RIP_AUTHLEN];
+
+ /* RFC 1723 */
+ family = EXTRACT_16BITS(&ni->rip_family);
+ if (family == 0xFFFF) {
+ if (EXTRACT_16BITS(&ni->rip_tag) == 2) {
+ memcpy(buf, &ni->rip_dest, sizeof(buf));
+ buf[sizeof(buf)-1] = '\0';
+ for (p = buf; *p; p++) {
+ if (!isprint(*p))
+ break;
+ }
+ if (!*p) {
+ printf(" [password %s]", buf);
+ } else {
+ printf(" [password: ");
+ rip_printblk((u_char *)&ni->rip_dest,
+ (u_char *)&ni->rip_metric +
+ sizeof(ni->rip_metric));
+ printf("]");
+ }
+ } else {
+ printf(" [auth %d:",
+ EXTRACT_16BITS(&ni->rip_tag));
+ rip_printblk((u_char *)&ni->rip_dest,
+ (u_char *)&ni->rip_metric +
+ sizeof(ni->rip_metric));
+ printf("]");
+ }
+ } else if (family != AF_INET) {
+ printf(" [family %d:", family);
+ rip_printblk((u_char *)&ni->rip_tag,
+ (u_char *)&ni->rip_metric +
+ sizeof(ni->rip_metric));
printf("]");
- } else if (vers < 2) {
- /* RFC 1058 */
- printf(" %s", ipaddr_string(&ni->rip_dest));
- } else {
- /* RFC 1723 */
+ return;
+ } else { /* AF_INET */
printf(" {%s", ipaddr_string(&ni->rip_dest));
if (ni->rip_dest_mask)
printf("/%s", ipaddr_string(&ni->rip_dest_mask));
@@ -91,9 +150,8 @@ rip_entry_print(register int vers, register const struct rip_netinfo *ni)
printf("->%s", ipaddr_string(&ni->rip_router));
if (ni->rip_tag)
printf(" tag %04x", EXTRACT_16BITS(&ni->rip_tag));
- printf("}");
+ printf("}(%d)", EXTRACT_32BITS(&ni->rip_metric));
}
- printf("(%d)", EXTRACT_32BITS(&ni->rip_metric));
}
void
@@ -110,56 +168,68 @@ rip_print(const u_char *dat, u_int length)
}
rp = (struct rip *)dat;
- switch (rp->rip_cmd) {
-
- case RIPCMD_REQUEST:
- printf(" rip-req %d", length);
- break;
-
- case RIPCMD_RESPONSE:
- j = length / sizeof(*ni);
- if (j * sizeof(*ni) != length - 4)
- printf(" rip-resp %d[%d]:", j, length);
- else
- printf(" rip-resp %d:", j);
- trunc = (i / sizeof(*ni)) != j;
- ni = (struct rip_netinfo *)(rp + 1);
- for (; (i -= sizeof(*ni)) >= 0; ++ni)
- rip_entry_print(rp->rip_vers, ni);
- if (trunc)
- printf("[|rip]");
- break;
-
- case RIPCMD_TRACEON:
- printf(" rip-traceon %d: \"", length);
- (void)fn_print((const u_char *)(rp + 1), snapend);
- fputs("\"\n", stdout);
- break;
-
- case RIPCMD_TRACEOFF:
- printf(" rip-traceoff %d", length);
- break;
-
- case RIPCMD_POLL:
- printf(" rip-poll %d", length);
- break;
-
- case RIPCMD_POLLENTRY:
- printf(" rip-pollentry %d", length);
- break;
-
- default:
- printf(" rip-#%d %d", rp->rip_cmd, length);
- break;
- }
switch (rp->rip_vers) {
-
- case 1:
- case 2:
+ case 0:
+ /*
+ * RFC 1058.
+ *
+ * XXX - RFC 1058 says
+ *
+ * 0 Datagrams whose version number is zero are to be ignored.
+ * These are from a previous version of the protocol, whose
+ * packet format was machine-specific.
+ *
+ * so perhaps we should just dump the first few words of
+ * the packet, in hex.
+ */
+ printf(" RIPv0: ");
+ ni = (struct rip_netinfo *)(rp + 1);
+ rip_printblk((u_char *)&ni->rip_family,
+ (u_char *)&ni->rip_metric +
+ sizeof(ni->rip_metric));
break;
-
default:
- printf(" [vers %d]", rp->rip_vers);
- break;
+ switch (rp->rip_cmd) {
+ case RIPCMD_REQUEST:
+ printf(" RIPv%d-req %d", rp->rip_vers, length);
+ break;
+ case RIPCMD_RESPONSE:
+ j = length / sizeof(*ni);
+ if (j * sizeof(*ni) != length - 4)
+ printf(" RIPv%d-resp [items %d] [%d]:",
+ rp->rip_vers, j, length);
+ else
+ printf(" RIPv%d-resp [items %d]:",
+ rp->rip_vers, j);
+ trunc = (i / sizeof(*ni)) != j;
+ ni = (struct rip_netinfo *)(rp + 1);
+ for (; (i -= sizeof(*ni)) >= 0; ++ni) {
+ if (rp->rip_vers == 1)
+ rip_entry_print_v1(rp->rip_vers, ni);
+ else
+ rip_entry_print_v2(rp->rip_vers, ni);
+ }
+ if (trunc)
+ printf("[|rip]");
+ break;
+ case RIPCMD_TRACEON:
+ printf(" RIPv%d-traceon %d: \"", rp->rip_vers, length);
+ (void)fn_print((const u_char *)(rp + 1), snapend);
+ fputs("\"\n", stdout);
+ break;
+ case RIPCMD_TRACEOFF:
+ printf(" RIPv%d-traceoff %d", rp->rip_vers, length);
+ break;
+ case RIPCMD_POLL:
+ printf(" RIPv%d-poll %d", rp->rip_vers, length);
+ break;
+ case RIPCMD_POLLENTRY:
+ printf(" RIPv%d-pollentry %d", rp->rip_vers, length);
+ break;
+ default:
+ printf(" RIPv%d-#%d %d", rp->rip_vers, rp->rip_cmd,
+ length);
+ break;
+ }
}
}
diff --git a/contrib/tcpdump/print-ripng.c b/contrib/tcpdump/print-ripng.c
index 7a4aee6..e4d11a4 100644
--- a/contrib/tcpdump/print-ripng.c
+++ b/contrib/tcpdump/print-ripng.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.2.2.1 2000/01/11 06:58:26 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.7 2000/10/07 05:46:21 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,17 +36,10 @@ static const char rcsid[] =
#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 <errno.h>
#include <stdio.h>
-#include <netinet/ip6.h>
-
#include "route6d.h"
#include "interface.h"
#include "addrtoname.h"
diff --git a/contrib/tcpdump/print-rt6.c b/contrib/tcpdump/print-rt6.c
index f8a7fcb..ea464e2 100644
--- a/contrib/tcpdump/print-rt6.c
+++ b/contrib/tcpdump/print-rt6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.3.2.1 2000/01/11 06:58:26 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.17 2000/12/13 07:57:05 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,21 +35,12 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include <stdio.h>
-#include <netinet/ip6.h>
+#include "ip6.h"
#include "interface.h"
#include "addrtoname.h"
@@ -62,50 +53,53 @@ rt6_print(register const u_char *bp, register const u_char *bp2)
register const struct ip6_hdr *ip;
register const u_char *ep;
int i, len;
+ register const struct in6_addr *addr;
dp = (struct ip6_rthdr *)bp;
ip = (struct ip6_hdr *)bp2;
len = dp->ip6r_len;
- /* 'ep' points to the end of avaible data. */
+ /* 'ep' points to the end of available data. */
ep = snapend;
- printf("%s > %s: ",
+#if 0
+ printf("%s > %s: ",
ip6addr_string(&ip->ip6_src),
ip6addr_string(&ip->ip6_dst));
+#endif
TCHECK(dp->ip6r_segleft);
- printf("srcrt (len=%d, ", dp->ip6r_len);
- printf("type=%d, ", dp->ip6r_type);
- printf("segleft=%d, ", dp->ip6r_segleft);
+ printf("srcrt (len=%d", dp->ip6r_len); /*)*/
+ printf(", type=%d", dp->ip6r_type);
+ printf(", segleft=%d", dp->ip6r_segleft);
- switch(dp->ip6r_type) {
+ switch (dp->ip6r_type) {
+#ifndef IPV6_RTHDR_TYPE_0
+#define IPV6_RTHDR_TYPE_0 0
+#endif
case IPV6_RTHDR_TYPE_0:
dp0 = (struct ip6_rthdr0 *)dp;
TCHECK(dp0->ip6r0_reserved);
if (dp0->ip6r0_reserved || vflag) {
- printf("rsv=0x%0x, ",
- (u_int32_t)ntohl(dp0->ip6r0_reserved));
+ printf(", rsv=0x%0x",
+ (u_int32_t)ntohl(dp0->ip6r0_reserved));
}
if (len % 2 == 1)
goto trunc;
len >>= 1;
+ addr = &dp0->ip6r0_addr[0];
for (i = 0; i < len; i++) {
- struct in6_addr *addr;
-
- addr = ((struct in6_addr *)(dp0 + 1)) + i;
- if ((u_char *)addr > ep - sizeof(*addr))
+ if ((u_char *)(addr + 1) > ep)
goto trunc;
-
- printf("[%d]%s", i, ip6addr_string((u_char *)addr));
- if (i != len - 1)
- printf(", ");
-
+
+ printf(", [%d]%s", i, ip6addr_string(addr));
+ addr++;
}
- printf(")");
+ /*(*/
+ printf(") ");
return((dp0->ip6r0_len + 1) << 3);
break;
default:
diff --git a/contrib/tcpdump/print-rx.c b/contrib/tcpdump/print-rx.c
index 5f42ce7..aa36124 100644
--- a/contrib/tcpdump/print-rx.c
+++ b/contrib/tcpdump/print-rx.c
@@ -13,7 +13,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.5.2.1 2000/01/11 06:58:27 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.20 2001/01/10 08:12:01 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -21,24 +21,27 @@ static const char rcsid[] =
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include <arpa/inet.h>
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#undef NOERROR /* Solaris sucks */
#include <arpa/nameser.h>
#include "rx.h"
+#include "ip.h"
+
static struct tok rx_types[] = {
{ RX_PACKET_TYPE_DATA, "data" },
{ RX_PACKET_TYPE_ACK, "ack" },
@@ -315,6 +318,39 @@ static struct tok ubik_lock_types[] = {
static char *voltype[] = { "read-write", "read-only", "backup" };
+static struct tok afs_fs_errors[] = {
+ { 101, "salvage volume" },
+ { 102, "no such vnode" },
+ { 103, "no such volume" },
+ { 104, "volume exist" },
+ { 105, "no service" },
+ { 106, "volume offline" },
+ { 107, "voline online" },
+ { 108, "diskfull" },
+ { 109, "diskquota exceeded" },
+ { 110, "volume busy" },
+ { 111, "volume moved" },
+ { 112, "AFS IO error" },
+ { -100, "restarting fileserver" },
+ { 0, NULL }
+};
+
+/*
+ * Reasons for acknowledging a packet
+ */
+
+static struct tok rx_ack_reasons[] = {
+ { 1, "ack requested" },
+ { 2, "duplicate packet" },
+ { 3, "out of sequence" },
+ { 4, "exceeds window" },
+ { 5, "no buffer space" },
+ { 6, "ping" },
+ { 7, "ping response" },
+ { 8, "delay" },
+ { 0, NULL },
+};
+
/*
* Cache entries we keep around so we can figure out the RX opcode
* numbers for replies. This allows us to make sense of RX reply packets.
@@ -339,9 +375,10 @@ static void rx_cache_insert(const u_char *, const struct ip *, int, int);
static int rx_cache_find(const struct rx_header *, const struct ip *,
int, int32_t *);
+static void ack_print(const u_char *, int);
static void fs_print(const u_char *, int);
static void fs_reply_print(const u_char *, int, int32_t);
-static void acl_print(u_char *, u_char *);
+static void acl_print(u_char *, int, u_char *);
static void cb_print(const u_char *, int);
static void cb_reply_print(const u_char *, int, int32_t);
static void prot_print(const u_char *, int);
@@ -357,6 +394,8 @@ static void bos_reply_print(const u_char *, int, int32_t);
static void ubik_print(const u_char *, int);
static void ubik_reply_print(const u_char *, int, int32_t);
+static void rx_ack_print(const u_char *, int);
+
static int is_ubik(u_int32_t);
/*
@@ -381,28 +420,35 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
printf(" rx %s", tok2str(rx_types, "type %d", rxh->type));
- if (vflag > 1) {
+ if (vflag) {
int firstflag = 0;
- printf(" cid %08x call# %d seq %d ser %d",
- (int) ntohl(rxh->cid),
- (int) ntohl(rxh->callNumber),
- (int) ntohl(rxh->seq),
- (int) ntohl(rxh->serial));
+
+ if (vflag > 1)
+ printf(" cid %08x call# %d",
+ (int) EXTRACT_32BITS(&rxh->cid),
+ (int) EXTRACT_32BITS(&rxh->callNumber));
+
+ printf(" seq %d ser %d",
+ (int) EXTRACT_32BITS(&rxh->seq),
+ (int) EXTRACT_32BITS(&rxh->serial));
+
if (vflag > 2)
printf(" secindex %d serviceid %hu",
(int) rxh->securityIndex,
- ntohs(rxh->serviceId));
- for (i = 0; i < NUM_RX_FLAGS; i++) {
- if (rxh->flags & rx_flags[i].v) {
- if (!firstflag) {
- firstflag = 1;
- printf(" ");
- } else {
- printf(",");
+ EXTRACT_16BITS(&rxh->serviceId));
+
+ if (vflag > 1)
+ for (i = 0; i < NUM_RX_FLAGS; i++) {
+ if (rxh->flags & rx_flags[i].v) {
+ if (!firstflag) {
+ firstflag = 1;
+ printf(" ");
+ } else {
+ printf(",");
+ }
+ printf("<%s>", rx_flags[i].s);
}
- printf("<%s>", rx_flags[i].s);
}
- }
}
/*
@@ -414,7 +460,10 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
* as well.
*/
- if (rxh->type == RX_PACKET_TYPE_DATA && ntohl(rxh->seq) == 1 &&
+ if (rxh->type == RX_PACKET_TYPE_ACK)
+ ack_print(bp, length);
+ else if (rxh->type == RX_PACKET_TYPE_DATA &&
+ EXTRACT_32BITS(&rxh->seq) == 1 &&
rxh->flags & RX_CLIENT_INITIATED) {
/*
@@ -458,7 +507,7 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
*/
} else if (((rxh->type == RX_PACKET_TYPE_DATA &&
- ntohl(rxh->seq) == 1) ||
+ EXTRACT_32BITS(&rxh->seq) == 1) ||
rxh->type == RX_PACKET_TYPE_ABORT) &&
(rxh->flags & RX_CLIENT_INITIATED) == 0 &&
rx_cache_find(rxh, (const struct ip *) bp2,
@@ -489,7 +538,15 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
default:
;
}
- }
+
+ /*
+ * If it's an RX ack packet, then use the appropriate ack decoding
+ * function (there isn't any service-specific information in the
+ * ack packet, so we can use one for all AFS services)
+ */
+
+ } else if (rxh->type == RX_PACKET_TYPE_ACK)
+ rx_ack_print(bp, length);
printf(" (%d)", length);
@@ -519,7 +576,7 @@ rx_cache_insert(const u_char *bp, const struct ip *ip, int dport,
rxent->server = ip->ip_dst;
rxent->dport = dport;
rxent->serviceId = rxh->serviceId;
- rxent->opcode = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header));
}
/*
@@ -567,46 +624,45 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
* These extrememly grody macros handle the printing of various AFS stuff.
*/
-#define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
#define FIDOUT() { unsigned long n1, n2, n3; \
- TRUNC(sizeof(int32_t) * 3); \
- n1 = ntohl(*((int *) bp)); \
+ TCHECK2(bp[0], sizeof(int32_t) * 3); \
+ n1 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- n2 = ntohl(*((int *) bp)); \
+ n2 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- n3 = ntohl(*((int *) bp)); \
+ n3 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
}
#define STROUT(MAX) { int i; \
- TRUNC(sizeof(int32_t)); \
- i = (int) ntohl(*((int *) bp)); \
+ TCHECK2(bp[0], sizeof(int32_t)); \
+ i = (int) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- TRUNC(i); \
- strncpy(s, bp, min(MAX, i)); \
+ TCHECK2(bp[0], i); \
+ strncpy(s, (char *) bp, min(MAX, i)); \
s[i] = '\0'; \
printf(" \"%s\"", s); \
bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
}
#define INTOUT() { int i; \
- TRUNC(sizeof(int32_t)); \
- i = (int) ntohl(*((int *) bp)); \
+ TCHECK2(bp[0], sizeof(int32_t)); \
+ i = (int) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
printf(" %d", i); \
}
#define UINTOUT() { unsigned long i; \
- TRUNC(sizeof(int32_t)); \
- i = ntohl(*((int *) bp)); \
+ TCHECK2(bp[0], sizeof(int32_t)); \
+ i = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
printf(" %lu", i); \
}
#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
- TRUNC(sizeof(int32_t)); \
- t = (time_t) ntohl(*((int *) bp)); \
+ TCHECK2(bp[0], sizeof(int32_t)); \
+ t = (time_t) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
tm = localtime(&t); \
strftime(str, 256, "%Y/%m/%d %T", tm); \
@@ -614,45 +670,45 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
}
#define STOREATTROUT() { unsigned long mask, i; \
- TRUNC((sizeof(int32_t)*6)); \
- mask = ntohl(*((int *) bp)); bp += sizeof(int32_t); \
+ TCHECK2(bp[0], (sizeof(int32_t)*6)); \
+ mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
if (mask) printf (" StoreStatus"); \
if (mask & 1) { printf(" date"); DATEOUT(); } \
else bp += sizeof(int32_t); \
- i = ntohl(*((int *) bp)); bp += sizeof(int32_t); \
+ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
if (mask & 2) printf(" owner %lu", i); \
- i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
+ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
if (mask & 4) printf(" group %lu", i); \
- i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
+ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
if (mask & 8) printf(" mode %lo", i & 07777); \
- i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
+ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
if (mask & 16) printf(" segsize %lu", i); \
/* undocumented in 3.3 docu */ \
if (mask & 1024) printf(" fsync"); \
}
#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
- TRUNC(sizeof(int32_t) * 2); \
- epoch = ntohl(*((int *) bp)); \
+ TCHECK2(bp[0], sizeof(int32_t) * 2); \
+ epoch = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- counter = ntohl(*((int *) bp)); \
+ counter = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
printf(" %d.%d", epoch, counter); \
}
#define AFSUUIDOUT() {u_int32_t temp; int i; \
- TRUNC(11*sizeof(u_int32_t)); \
- temp = ntohl(*((int *) bp)); \
+ TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
+ temp = EXTRACT_32BITS(bp); \
bp += sizeof(u_int32_t); \
printf(" %08x", temp); \
- temp = ntohl(*((int *) bp)); \
+ temp = EXTRACT_32BITS(bp); \
bp += sizeof(u_int32_t); \
printf("%04x", temp); \
- temp = ntohl(*((int *) bp)); \
+ temp = EXTRACT_32BITS(bp); \
bp += sizeof(u_int32_t); \
printf("%04x", temp); \
for (i = 0; i < 8; i++) { \
- temp = ntohl(*((int *) bp)); \
+ temp = EXTRACT_32BITS(bp); \
bp += sizeof(u_int32_t); \
printf("%02x", (unsigned char) temp); \
} \
@@ -664,21 +720,90 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
#define VECOUT(MAX) { char *sp; \
int k; \
- TRUNC(MAX * sizeof(int32_t)); \
+ TCHECK2(bp[0], MAX * sizeof(int32_t)); \
sp = s; \
for (k = 0; k < MAX; k++) { \
- *sp++ = (char) ntohl(*((int *) bp)); \
+ *sp++ = (char) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
} \
s[MAX] = '\0'; \
printf(" \"%s\"", s); \
}
+static void
+ack_print(register const u_char *bp, int length)
+{
+ u_char nAcks;
+ int i;
+
+ if (vflag <= 1)
+ return;
+
+ if (length <= sizeof(struct rx_header))
+ return;
+
+ bp += sizeof(struct rx_header);
+
+ /*
+ * Packets < firstPacket are implicitly acknowledged and may
+ * be discarded by the sender.
+ *
+ * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
+ *
+ * No packets with sequence numbers >= firstPacket should be
+ * discarded by the sender (they may thrown out at any time by
+ * the receiver)
+ */
+#define RX_ACK_REASONS "RDOXSprn"
+ /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
+ * Ping, ping_Response, No_{progress, particular_reason}.
+ */
+#if 0
+ struct rx_ackPacket {
+ u_short bufferSpace; /* Skip! */
+ u_short maxSkew; /* Skip! */
+ u_long firstPacket;
+ u_long previousPacket; /* Obsolete! */
+ u_long serial; /* Serial that prompted the ack, */
+ u_char reason; /* and the reason why. */
+ u_char nAcks;
+ u_char acks[RX_MAXACKS]; /* Selective acks (not a bitmap). */
+ };
+#endif
+#define RX_ACK_TYPE_NACK 0
+
+ TCHECK2(bp[0], 8); /* bufferSpace and maxSkew */
+ bp += 4;
+ printf(" fir %u", (unsigned)EXTRACT_32BITS(bp));
+ bp += 4;
+ TCHECK2(bp[0], 8); /* previousPacket and serial */
+ bp += 4;
+ printf(" %u", (unsigned)EXTRACT_32BITS(bp));
+ bp += 4;
+ TCHECK2(bp[0], 1);
+ printf("%c", RX_ACK_REASONS[(*bp - 1) & 07u]);
+ bp += 1; /* reason */
+ TCHECK2(bp[0], 1);
+ nAcks = *bp;
+ bp += 1; /* nAcks */
+
+ for (i = 0; i < nAcks; i++) {
+ TCHECK2(bp[0], 1);
+ putchar(*bp == RX_ACK_TYPE_NACK? '-' : '*');
+ bp += 1;
+ }
+
+ return;
+
+trunc:
+ printf(" [|ack]");
+}
+
/*
* Handle calls to the AFS file service (fs)
*/
-void
+static void
fs_print(register const u_char *bp, int length)
{
int fs_op;
@@ -697,7 +822,7 @@ fs_print(register const u_char *bp, int length)
* gleaned from fsint/afsint.xg
*/
- fs_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op));
@@ -746,15 +871,16 @@ fs_print(register const u_char *bp, int length)
break;
case 134: /* Store ACL */
{
- char a[AFSOPAQUEMAX];
+ char a[AFSOPAQUEMAX+1];
FIDOUT();
- TRUNC(4);
- i = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TRUNC(i);
- strncpy(a, bp, min(AFSOPAQUEMAX, i));
+ TCHECK2(bp[0], i);
+ i = min(AFSOPAQUEMAX, i);
+ strncpy(a, (char *) bp, i);
a[i] = '\0';
- acl_print((u_char *) a, (u_char *) a + i);
+ acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
break;
}
case 137: /* Create file */
@@ -803,8 +929,8 @@ fs_print(register const u_char *bp, int length)
case 155: /* Bulk stat */
{
unsigned long j;
- TRUNC(4);
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
@@ -854,18 +980,19 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
* If it was a data packet, interpret the response
*/
- if (rxh->type == RX_PACKET_TYPE_DATA)
+ if (rxh->type == RX_PACKET_TYPE_DATA) {
switch (opcode) {
case 131: /* Fetch ACL */
{
- char a[AFSOPAQUEMAX];
- TRUNC(4);
- i = ntohl(*((int *) bp));
+ char a[AFSOPAQUEMAX+1];
+ TCHECK2(bp[0], 4);
+ i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TRUNC(i);
- strncpy(a, bp, min(AFSOPAQUEMAX, i));
+ TCHECK2(bp[0], i);
+ i = min(AFSOPAQUEMAX, i);
+ strncpy(a, (char *) bp, i);
a[i] = '\0';
- acl_print((u_char *) a, (u_char *) a + i);
+ acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
break;
}
case 137: /* Create file */
@@ -883,12 +1010,19 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
default:
;
}
- else {
- /*
- * Otherwise, just print out the return code
- */
- printf(" errcode");
- INTOUT();
+ } else if (rxh->type == RX_PACKET_TYPE_ABORT) {
+ int i;
+
+ /*
+ * Otherwise, just print out the return code
+ */
+ TCHECK2(bp[0], sizeof(int32_t));
+ i = (int) EXTRACT_32BITS(bp);
+ bp += sizeof(int32_t);
+
+ printf(" error %s", tok2str(afs_fs_errors, "#%d", i));
+ } else {
+ printf(" strange fs reply of type %d", rxh->type);
}
return;
@@ -912,19 +1046,22 @@ trunc:
*/
static void
-acl_print(u_char *s, u_char *end)
+acl_print(u_char *s, int maxsize, u_char *end)
{
int pos, neg, acl;
int n, i;
- char user[128];
+ char *user;
- if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2)
+ if ((user = (char *)malloc(maxsize)) == NULL)
return;
+
+ if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2)
+ goto finish;
s += n;
if (s > end)
- return;
+ goto finish;
/*
* This wacky order preserves the order used by the "fs" command
@@ -948,25 +1085,29 @@ acl_print(u_char *s, u_char *end)
for (i = 0; i < pos; i++) {
if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
- return;
+ goto finish;
s += n;
printf(" +{%s ", user);
ACLOUT(acl);
printf("}");
if (s > end)
- return;
+ goto finish;
}
for (i = 0; i < neg; i++) {
if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
- return;
+ goto finish;
s += n;
printf(" -{%s ", user);
ACLOUT(acl);
printf("}");
if (s > end)
- return;
+ goto finish;
}
+
+finish:
+ free(user);
+ return;
}
#undef ACLOUT
@@ -993,7 +1134,7 @@ cb_print(register const u_char *bp, int length)
* gleaned from fsint/afscbint.xg
*/
- cb_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op));
@@ -1008,8 +1149,8 @@ cb_print(register const u_char *bp, int length)
case 204: /* Callback */
{
unsigned long j, t;
- TRUNC(4);
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
@@ -1021,7 +1162,7 @@ cb_print(register const u_char *bp, int length)
if (j == 0)
printf(" <none!>");
- j = ntohl(*((int *) bp));
+ j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (j != 0)
@@ -1032,8 +1173,8 @@ cb_print(register const u_char *bp, int length)
INTOUT();
printf(" expires");
DATEOUT();
- TRUNC(4);
- t = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ t = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
tok2str(cb_types, "type %d", t);
}
@@ -1125,7 +1266,7 @@ prot_print(register const u_char *bp, int length)
* gleaned from ptserver/ptint.xg
*/
- pt_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" pt");
@@ -1176,8 +1317,8 @@ prot_print(register const u_char *bp, int length)
case 504: /* Name to ID */
{
unsigned long j;
- TRUNC(4);
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
/*
@@ -1198,8 +1339,8 @@ prot_print(register const u_char *bp, int length)
{
unsigned long j;
printf(" ids:");
- TRUNC(4);
- i = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (j = 0; j < i; j++)
INTOUT();
@@ -1288,8 +1429,8 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
{
unsigned long j;
printf(" ids:");
- TRUNC(4);
- i = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (j = 0; j < i; j++)
INTOUT();
@@ -1300,8 +1441,8 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
case 505: /* ID to name */
{
unsigned long j;
- TRUNC(4);
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
/*
@@ -1325,8 +1466,8 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
case 519: /* Get host CPS */
{
unsigned long j;
- TRUNC(4);
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
INTOUT();
@@ -1381,7 +1522,7 @@ vldb_print(register const u_char *bp, int length)
* gleaned from vlserver/vldbint.xg
*/
- vldb_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" vldb");
@@ -1410,8 +1551,8 @@ vldb_print(register const u_char *bp, int length)
case 518: /* Get entry by ID N */
printf(" volid");
INTOUT();
- TRUNC(sizeof(int32_t));
- i = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (i <= 2)
printf(" type %s", voltype[i]);
@@ -1430,8 +1571,8 @@ vldb_print(register const u_char *bp, int length)
case 520: /* Replace entry N */
printf(" volid");
INTOUT();
- TRUNC(sizeof(int32_t));
- i = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (i <= 2)
printf(" type %s", voltype[i]);
@@ -1500,16 +1641,16 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
case 504: /* Get entry by name */
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
- TRUNC(sizeof(int32_t));
+ TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
printf(" numservers");
- TRUNC(sizeof(int32_t));
- nservers = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
printf(" %lu", nservers);
printf(" servers");
for (i = 0; i < 8; i++) {
- TRUNC(sizeof(int32_t));
+ TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
printf(" %s",
inet_ntoa(*((struct in_addr *) bp)));
@@ -1517,15 +1658,15 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
}
printf(" partitions");
for (i = 0; i < 8; i++) {
- TRUNC(sizeof(int32_t));
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
printf(" %c", 'a' + (int)j);
else if (i < nservers)
printf(" %lu", j);
bp += sizeof(int32_t);
}
- TRUNC(8 * sizeof(int32_t));
+ TCHECK2(bp[0], 8 * sizeof(int32_t));
bp += 8 * sizeof(int32_t);
printf(" rwvol");
UINTOUT();
@@ -1550,13 +1691,13 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
printf(" numservers");
- TRUNC(sizeof(int32_t));
- nservers = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
printf(" %lu", nservers);
printf(" servers");
for (i = 0; i < 13; i++) {
- TRUNC(sizeof(int32_t));
+ TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
printf(" %s",
inet_ntoa(*((struct in_addr *) bp)));
@@ -1564,15 +1705,15 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
}
printf(" partitions");
for (i = 0; i < 13; i++) {
- TRUNC(sizeof(int32_t));
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
printf(" %c", 'a' + (int)j);
else if (i < nservers)
printf(" %lu", j);
bp += sizeof(int32_t);
}
- TRUNC(13 * sizeof(int32_t));
+ TCHECK2(bp[0], 13 * sizeof(int32_t));
bp += 13 * sizeof(int32_t);
printf(" rwvol");
UINTOUT();
@@ -1587,8 +1728,8 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
printf(" numservers");
- TRUNC(sizeof(int32_t));
- nservers = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
printf(" %lu", nservers);
printf(" servers");
@@ -1597,23 +1738,23 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
printf(" afsuuid");
AFSUUIDOUT();
} else {
- TRUNC(44);
+ TCHECK2(bp[0], 44);
bp += 44;
}
}
- TRUNC(4 * 13);
+ TCHECK2(bp[0], 4 * 13);
bp += 4 * 13;
printf(" partitions");
for (i = 0; i < 13; i++) {
- TRUNC(sizeof(int32_t));
- j = ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
printf(" %c", 'a' + (int)j);
else if (i < nservers)
printf(" %lu", j);
bp += sizeof(int32_t);
}
- TRUNC(13 * sizeof(int32_t));
+ TCHECK2(bp[0], 13 * sizeof(int32_t));
bp += 13 * sizeof(int32_t);
printf(" rwvol");
UINTOUT();
@@ -1662,7 +1803,7 @@ kauth_print(register const u_char *bp, int length)
* gleaned from kauth/kauth.rg
*/
- kauth_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" kauth");
@@ -1703,10 +1844,10 @@ kauth_print(register const u_char *bp, int length)
INTOUT();
printf(" domain");
STROUT(KANAMEMAX);
- TRUNC(sizeof(int32_t));
- i = (int) ntohl(*((int *) bp));
+ TCHECK2(bp[0], sizeof(int32_t));
+ i = (int) EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TRUNC(i);
+ TCHECK2(bp[0], i);
bp += i;
printf(" principal");
STROUT(KANAMEMAX);
@@ -1806,7 +1947,7 @@ vol_print(register const u_char *bp, int length)
* gleaned from volser/volint.xg
*/
- vol_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op));
@@ -1889,7 +2030,7 @@ bos_print(register const u_char *bp, int length)
* gleaned from bozo/bosint.xg
*/
- bos_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op));
@@ -2032,7 +2173,7 @@ ubik_print(register const u_char *bp, int length)
* gleaned from ubik/ubik_int.xg
*/
- ubik_op = ntohl(*((int *) (bp + sizeof(struct rx_header))));
+ ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op));
@@ -2044,8 +2185,8 @@ ubik_print(register const u_char *bp, int length)
switch (ubik_op) {
case 10000: /* Beacon */
- TRUNC(4);
- temp = ntohl(*((int *) bp));
+ TCHECK2(bp[0], 4);
+ temp = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
printf(" syncsite %s", temp ? "yes" : "no");
printf(" votestart");
@@ -2076,7 +2217,7 @@ ubik_print(register const u_char *bp, int length)
INTOUT();
printf(" length");
INTOUT();
- temp = ntohl(*((int *) bp));
+ temp = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
tok2str(ubik_lock_types, "type %d", temp);
break;
@@ -2188,3 +2329,197 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
trunc:
printf(" [|ubik]");
}
+
+/*
+ * Handle RX ACK packets.
+ */
+
+static void
+rx_ack_print(register const u_char *bp, int length)
+{
+ struct rx_ackPacket *rxa;
+ int i, start, last;
+
+ if (length < sizeof(struct rx_header))
+ return;
+
+ bp += sizeof(struct rx_header);
+
+ /*
+ * This may seem a little odd .... the rx_ackPacket structure
+ * contains an array of individual packet acknowledgements
+ * (used for selective ack/nack), but since it's variable in size,
+ * we don't want to truncate based on the size of the whole
+ * rx_ackPacket structure.
+ */
+
+ TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
+
+ rxa = (struct rx_ackPacket *) bp;
+ bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS);
+
+ /*
+ * Print out a few useful things from the ack packet structure
+ */
+
+ if (vflag > 2)
+ printf(" bufspace %d maxskew %d",
+ (int) EXTRACT_16BITS(&rxa->bufferSpace),
+ (int) EXTRACT_16BITS(&rxa->maxSkew));
+
+ printf(" first %d serial %d reason %s",
+ EXTRACT_32BITS(&rxa->firstPacket), EXTRACT_32BITS(&rxa->serial),
+ tok2str(rx_ack_reasons, "#%d", (int) rxa->reason));
+
+ /*
+ * Okay, now we print out the ack array. The way _this_ works
+ * is that we start at "first", and step through the ack array.
+ * If we have a contiguous range of acks/nacks, try to
+ * collapse them into a range.
+ *
+ * If you're really clever, you might have noticed that this
+ * doesn't seem quite correct. Specifically, due to structure
+ * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
+ * yield the start of the ack array (because RX_MAXACKS is 255
+ * and the structure will likely get padded to a 2 or 4 byte
+ * boundary). However, this is the way it's implemented inside
+ * of AFS - the start of the extra fields are at
+ * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
+ * the exact start of the ack array. Sigh. That's why we aren't
+ * using bp, but instead use rxa->acks[]. But nAcks gets added
+ * to bp after this, so bp ends up at the right spot. Go figure.
+ */
+
+ if (rxa->nAcks != 0) {
+
+ TCHECK2(bp[0], rxa->nAcks);
+
+ /*
+ * Sigh, this is gross, but it seems to work to collapse
+ * ranges correctly.
+ */
+
+ for (i = 0, start = last = -2; i < rxa->nAcks; i++)
+ if (rxa->acks[i] == RX_ACK_TYPE_ACK) {
+
+ /*
+ * I figured this deserved _some_ explanation.
+ * First, print "acked" and the packet seq
+ * number if this is the first time we've
+ * seen an acked packet.
+ */
+
+ if (last == -2) {
+ printf(" acked %d",
+ rxa->firstPacket + i);
+ start = i;
+ }
+
+ /*
+ * Otherwise, if the there is a skip in
+ * the range (such as an nacked packet in
+ * the middle of some acked packets),
+ * then print the current packet number
+ * seperated from the last number by
+ * a comma.
+ */
+
+ else if (last != i - 1) {
+ printf(",%d", rxa->firstPacket + i);
+ start = i;
+ }
+
+ /*
+ * We always set last to the value of
+ * the last ack we saw. Conversely, start
+ * is set to the value of the first ack
+ * we saw in a range.
+ */
+
+ last = i;
+
+ /*
+ * Okay, this bit a code gets executed when
+ * we hit a nack ... in _this_ case we
+ * want to print out the range of packets
+ * that were acked, so we need to print
+ * the _previous_ packet number seperated
+ * from the first by a dash (-). Since we
+ * already printed the first packet above,
+ * just print the final packet. Don't
+ * do this if there will be a single-length
+ * range.
+ */
+ } else if (last == i - 1 && start != last)
+ printf("-%d", rxa->firstPacket + i - 1);
+
+ /*
+ * So, what's going on here? We ran off the end of the
+ * ack list, and if we got a range we need to finish it up.
+ * So we need to determine if the last packet in the list
+ * was an ack (if so, then last will be set to it) and
+ * we need to see if the last range didn't start with the
+ * last packet (because if it _did_, then that would mean
+ * that the packet number has already been printed and
+ * we don't need to print it again).
+ */
+
+ if (last == i - 1 && start != last)
+ printf("-%d", rxa->firstPacket + i - 1);
+
+ /*
+ * Same as above, just without comments
+ */
+
+ for (i = 0, start = last = -2; i < rxa->nAcks; i++)
+ if (rxa->acks[i] == RX_ACK_TYPE_NACK) {
+ if (last == -2) {
+ printf(" nacked %d",
+ rxa->firstPacket + i);
+ start = i;
+ } else if (last != i - 1) {
+ printf(",%d", rxa->firstPacket + i);
+ start = i;
+ }
+ last = i;
+ } else if (last == i - 1 && start != last)
+ printf("-%d", rxa->firstPacket + i - 1);
+
+ if (last == i - 1 && start != last)
+ printf("-%d", rxa->firstPacket + i - 1);
+
+ bp += rxa->nAcks;
+ }
+
+
+ /*
+ * These are optional fields; depending on your version of AFS,
+ * you may or may not see them
+ */
+
+#define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
+
+ if (vflag > 1) {
+ TRUNCRET(4);
+ printf(" ifmtu");
+ INTOUT();
+
+ TRUNCRET(4);
+ printf(" maxmtu");
+ INTOUT();
+
+ TRUNCRET(4);
+ printf(" rwind");
+ INTOUT();
+
+ TRUNCRET(4);
+ printf(" maxpackets");
+ INTOUT();
+ }
+
+ return;
+
+trunc:
+ printf(" [|ack]");
+}
+#undef TRUNCRET
diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c
index 48125a6..c89a9a3 100644
--- a/contrib/tcpdump/print-sl.c
+++ b/contrib/tcpdump/print-sl.c
@@ -21,36 +21,17 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.46 1999/11/21 12:38:24 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.56 2000/10/10 05:06:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_NET_SLIP_H
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#if __STDC__
-struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-#include <netinet/udp.h>
-#include <netinet/tcp.h>
-
-#include <net/slcompress.h>
-#include <net/slip.h>
#include <ctype.h>
#include <netdb.h>
@@ -61,22 +42,17 @@ struct rtentry;
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
+#include "ip.h"
+#include "tcp.h"
+#include "slip.h"
+#include "slcompress.h"
+
static u_int lastlen[2][256];
static u_int lastconn = 255;
static void sliplink_print(const u_char *, const struct ip *, u_int);
static void compressed_sl_print(const u_char *, const struct ip *, u_int, int);
-/* XXX BSD/OS 2.1 compatibility */
-#if !defined(SLIP_HDRLEN) && defined(SLC_BPFHDR)
-#define SLIP_HDRLEN SLC_BPFHDR
-#define SLX_DIR 0
-#define SLX_CHDR (SLC_BPFHDRLEN - 1)
-#define CHDR_LEN (SLC_BPFHDR - SLC_BPFHDRLEN)
-#endif
-
-/* XXX needs more hacking to work right */
-
void
sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
@@ -105,7 +81,7 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (eflag)
sliplink_print(p, ip, length);
- switch (ip->ip_v) {
+ switch (IP_V(ip)) {
case 4:
ip_print((u_char *)ip, length);
break;
@@ -115,7 +91,7 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
break;
#endif
default:
- printf ("ip v%d", ip->ip_v);
+ printf ("ip v%d", IP_V(ip));
}
if (xflag)
@@ -196,8 +172,8 @@ sliplink_print(register const u_char *p, register const struct ip *ip,
* has restored the IP header copy to IPPROTO_TCP.
*/
lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p;
- hlen = ip->ip_hl;
- hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off;
+ hlen = IP_HL(ip);
+ hlen += TH_OFF((struct tcphdr *)&((int *)ip)[hlen]);
lastlen[dir][lastconn] = length - (hlen << 2);
printf("utcp %d: ", lastconn);
break;
@@ -286,33 +262,8 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
* 'cp - chdr' is the length of the compressed header.
* 'length - hlen' is the amount of data in the packet.
*/
- hlen = ip->ip_hl;
- hlen += ((struct tcphdr *)&((int32_t *)ip)[hlen])->th_off;
+ hlen = IP_HL(ip);
+ hlen += TH_OFF((struct tcphdr *)&((int32_t *)ip)[hlen]);
lastlen[dir][lastconn] = length - (hlen << 2);
- printf(" %d (%d)", lastlen[dir][lastconn], cp - chdr);
+ printf(" %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr));
}
-#else
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <pcap.h>
-#include <stdio.h>
-
-#include "interface.h"
-
-void
-sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
-{
-
- error("not configured for slip");
- /* NOTREACHED */
-}
-
-void
-sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
-{
-
- error("not configured for slip");
- /* NOTREACHED */
-}
-#endif
diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c
new file mode 100644
index 0000000..8f2803a
--- /dev/null
+++ b/contrib/tcpdump/print-sll.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 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
+ * 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: /tcpdump/master/tcpdump/print-sll.c,v 1.3 2000/12/23 20:49:34 guy Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+struct mbuf;
+struct rtentry;
+
+#include <netinet/in.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <pcap.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "ethertype.h"
+
+#include "ether.h"
+#include "sll.h"
+
+const u_char *packetp;
+const u_char *snapend;
+
+static inline void
+sll_print(register const struct sll_header *sllp, u_int length)
+{
+ u_short halen;
+
+ switch (ntohs(sllp->sll_pkttype)) {
+
+ case LINUX_SLL_HOST:
+ (void)printf("< ");
+ break;
+
+ case LINUX_SLL_BROADCAST:
+ (void)printf("B ");
+ break;
+
+ case LINUX_SLL_MULTICAST:
+ (void)printf("M ");
+ break;
+
+ case LINUX_SLL_OTHERHOST:
+ (void)printf("P ");
+ break;
+
+ case LINUX_SLL_OUTGOING:
+ (void)printf("> ");
+ break;
+
+ default:
+ (void)printf("? ");
+ break;
+ }
+
+ /*
+ * XXX - check the link-layer address type value?
+ * For now, we just assume 6 means Ethernet.
+ * XXX - print others as strings of hex?
+ */
+ halen = ntohs(sllp->sll_halen);
+ if (halen == 6)
+ (void)printf("%s ", etheraddr_string(sllp->sll_addr));
+
+ if (!qflag)
+ (void)printf("%s ", etherproto_string(sllp->sll_protocol));
+ (void)printf("%d: ", length);
+}
+
+/*
+ * This is the top level routine of the printer. 'p' is the points
+ * to the ether header of the packet, 'h->tv' is the timestamp,
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+void
+sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+ u_int caplen = h->caplen;
+ u_int length = h->len;
+ register const struct sll_header *sllp;
+ u_short pkttype;
+ struct ether_header ehdr;
+ u_short ether_type;
+ u_short extracted_ethertype;
+
+ ts_print(&h->ts);
+
+ if (caplen < SLL_HDR_LEN) {
+ /*
+ * XXX - this "can't happen" because "pcap-linux.c" always
+ * adds this many bytes of header to every packet in a
+ * cooked socket capture.
+ */
+ printf("[|sll]");
+ goto out;
+ }
+
+ sllp = (const struct sll_header *)p;
+
+ /*
+ * Fake up an Ethernet header for the benefit of printers that
+ * insist on "packetp" pointing to an Ethernet header.
+ */
+ pkttype = ntohs(sllp->sll_pkttype);
+
+ /* The source address is in the packet header */
+ memcpy(ehdr.ether_shost, sllp->sll_addr, ETHER_ADDR_LEN);
+
+ if (pkttype != LINUX_SLL_OUTGOING) {
+ /*
+ * We received this packet.
+ *
+ * We don't know the destination address, so
+ * we fake it - all 0's except that the
+ * bottommost bit of the bottommost octet
+ * is set for a unicast packet, all 0's except
+ * that the bottommost bit of the uppermost
+ * octet is set for a multicast packet, all
+ * 1's for a broadcast packet.
+ */
+ if (pkttype == LINUX_SLL_BROADCAST)
+ memset(ehdr.ether_dhost, 0xFF, ETHER_ADDR_LEN);
+ else {
+ memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN);
+ if (pkttype == LINUX_SLL_MULTICAST)
+ ehdr.ether_dhost[0] = 1;
+ else
+ ehdr.ether_dhost[ETHER_ADDR_LEN-1] = 1;
+ }
+ } else {
+ /*
+ * We sent this packet; we don't know whether it's
+ * broadcast, multicast, or unicast, so just make
+ * the destination address all 0's.
+ */
+ memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN);
+ }
+
+ if (eflag)
+ sll_print(sllp, length);
+
+ /*
+ * Some printers want to get back at the ethernet addresses,
+ * and/or check that they're not walking off the end of the packet.
+ * Rather than pass them all the way down, we set these globals.
+ */
+ snapend = p + caplen;
+ /*
+ * Actually, the only printers that use packetp are print-arp.c
+ * and print-bootp.c, and they assume that packetp points to an
+ * Ethernet header. The right thing to do is to fix them to know
+ * which link type is in use when they excavate. XXX
+ */
+ packetp = (u_char *)&ehdr;
+
+ length -= SLL_HDR_LEN;
+ caplen -= SLL_HDR_LEN;
+ p += SLL_HDR_LEN;
+
+ ether_type = ntohs(sllp->sll_protocol);
+
+ /*
+ * Is it (gag) an 802.3 encapsulation, or some non-Ethernet
+ * packet type?
+ */
+ extracted_ethertype = 0;
+ if (ether_type <= ETHERMTU) {
+ /*
+ * Yes - what type is it?
+ */
+ switch (ether_type) {
+
+ case LINUX_SLL_P_802_2:
+ /*
+ * 802.2.
+ * Try to print the LLC-layer header & higher layers.
+ */
+ if (llc_print(p, length, caplen, ESRC(&ehdr),
+ EDST(&ehdr), &extracted_ethertype) == 0)
+ goto unknown; /* unknown LLC type */
+ break;
+
+ default:
+ unknown:
+ /* ether_type not known, print raw packet */
+ if (!eflag)
+ sll_print(sllp, length + SLL_HDR_LEN);
+ if (extracted_ethertype) {
+ printf("(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype)));
+ }
+ if (!xflag && !qflag)
+ default_print(p, caplen);
+ break;
+ }
+ } else if (ether_encap_print(ether_type, p, length, caplen,
+ &extracted_ethertype) == 0) {
+ /* ether_type not known, print raw packet */
+ if (!eflag)
+ sll_print(sllp, length + SLL_HDR_LEN);
+ if (!xflag && !qflag)
+ default_print(p, caplen);
+ }
+ if (xflag)
+ default_print(p, caplen);
+ out:
+ putchar('\n');
+}
diff --git a/contrib/tcpdump/print-smb.c b/contrib/tcpdump/print-smb.c
index 0a14f59..e5a3da5 100644
--- a/contrib/tcpdump/print-smb.c
+++ b/contrib/tcpdump/print-smb.c
@@ -11,7 +11,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.3.2.1 2000/01/11 06:58:27 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.7 2000/12/05 06:42:47 guy Exp $";
#endif
#include <stdio.h>
@@ -719,6 +719,8 @@ void nbt_tcp_print(const uchar *data,int length)
printf("flags=0x%x\n", flags);
case 0:
data = fdata(data,"NBT Session Packet\nFlags=[rw]\nLength=[rd]\n",data+4);
+ if (data == NULL)
+ break;
if (memcmp(data,"\377SMB",4)==0) {
if (nbt_len>PTR_DIFF(maxbuf,data))
printf("WARNING: Short packet. Try increasing the snap length (%ld)\n",
@@ -789,15 +791,14 @@ void nbt_udp137_print(const uchar *data, int length)
int ancount = RSVAL(data,6);
int nscount = RSVAL(data,8);
int arcount = RSVAL(data,10);
- char des[1024];
- char *opcodestr="OPUNKNOWN";
+ char *opcodestr;
const char *p;
startbuf = data;
if (maxbuf <= data) return;
- strcpy(des,"\n>>> NBT UDP PACKET(137): ");
+ printf("\n>>> NBT UDP PACKET(137): ");
switch (opcode) {
case 0: opcodestr = "QUERY"; break;
@@ -806,27 +807,26 @@ void nbt_udp137_print(const uchar *data, int length)
case 7: opcodestr = "WACK"; break;
case 8: opcodestr = "REFRESH(8)"; break;
case 9: opcodestr = "REFRESH"; break;
+ default: opcodestr = "OPUNKNOWN"; break;
}
- strcat(des,opcodestr);
+ printf("%s", opcodestr);
if (response) {
if (rcode)
- strcat(des,"; NEGATIVE");
+ printf("; NEGATIVE");
else
- strcat(des,"; POSITIVE");
+ printf("; POSITIVE");
}
if (response)
- strcat(des,"; RESPONSE");
+ printf("; RESPONSE");
else
- strcat(des,"; REQUEST");
+ printf("; REQUEST");
if (nm_flags&1)
- strcat(des,"; BROADCAST");
+ printf("; BROADCAST");
else
- strcat(des,"; UNICAST");
+ printf("; UNICAST");
- printf("%s", des);
-
if (vflag == 0) return;
printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
@@ -847,6 +847,8 @@ void nbt_udp137_print(const uchar *data, int length)
printf("QuestionRecords:\n");
for (i=0;i<qdcount;i++)
p = fdata(p,"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",maxbuf);
+ if (p == NULL)
+ goto out;
}
if (total) {
@@ -855,30 +857,39 @@ void nbt_udp137_print(const uchar *data, int length)
int rdlen;
int restype;
p = fdata(p,"Name=[n1]\n#",maxbuf);
+ if (p == NULL)
+ goto out;
restype = RSVAL(p,0);
p = fdata(p,"ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n",p+8);
+ if (p == NULL)
+ goto out;
rdlen = RSVAL(p,0);
printf("ResourceLength=%d\nResourceData=\n",rdlen);
p += 2;
if (rdlen == 6) {
p = fdata(p,"AddrType=[rw]\nAddress=[b.b.b.b]\n",p+rdlen);
+ if (p == NULL)
+ goto out;
} else {
if (restype == 0x21) {
int numnames = CVAL(p,0);
p = fdata(p,"NumNames=[B]\n",p+1);
+ if (p == NULL)
+ goto out;
while (numnames--) {
- char flags[128]="";
p = fdata(p,"Name=[n2]\t#",maxbuf);
- if (p[0] & 0x80) strcat(flags,"<GROUP> ");
- if ((p[0] & 0x60) == 0x00) strcat(flags,"B ");
- if ((p[0] & 0x60) == 0x20) strcat(flags,"P ");
- if ((p[0] & 0x60) == 0x40) strcat(flags,"M ");
- if ((p[0] & 0x60) == 0x60) strcat(flags,"_ ");
- if (p[0] & 0x10) strcat(flags,"<DEREGISTERING> ");
- if (p[0] & 0x08) strcat(flags,"<CONFLICT> ");
- if (p[0] & 0x04) strcat(flags,"<ACTIVE> ");
- if (p[0] & 0x02) strcat(flags,"<PERMANENT> ");
- printf("%s\n",flags);
+ if (p[0] & 0x80) printf("<GROUP> ");
+ switch (p[0] & 0x60) {
+ case 0x00: printf("B "); break;
+ case 0x20: printf("P "); break;
+ case 0x40: printf("M "); break;
+ case 0x60: printf("_ "); break;
+ }
+ if (p[0] & 0x10) printf("<DEREGISTERING> ");
+ if (p[0] & 0x08) printf("<CONFLICT> ");
+ if (p[0] & 0x04) printf("<ACTIVE> ");
+ if (p[0] & 0x02) printf("<PERMANENT> ");
+ printf("\n");
p += 2;
}
} else {
@@ -894,6 +905,7 @@ void nbt_udp137_print(const uchar *data, int length)
fdata(p,"AdditionalData:\n",maxbuf);
}
+out:
printf("\n");
fflush(stdout);
}
@@ -911,7 +923,8 @@ void nbt_udp138_print(const uchar *data, int length)
data = fdata(data,"\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#",maxbuf);
- print_smb(data,maxbuf);
+ if (data != NULL)
+ print_smb(data,maxbuf);
printf("\n");
fflush(stdout);
@@ -922,15 +935,24 @@ void nbt_udp138_print(const uchar *data, int length)
/*
print netbeui frames
*/
-void netbeui_print(const uchar *data, const uchar *maxbuf)
+void netbeui_print(u_short control, const uchar *data, const uchar *maxbuf)
{
- int len = SVAL(data,1);
- int command = CVAL(data,5);
- const uchar *data2 = data + 1 + len;
+ int len = SVAL(data,0);
+ int command = CVAL(data,4);
+ const uchar *data2 = data + len;
+ int is_truncated = 0;
+
+ if (data2 >= maxbuf) {
+ data2 = maxbuf;
+ is_truncated = 1;
+ }
startbuf = data;
- data = fdata(data,"\n>>> NetBeui Packet\nType=[B] Length=[d] Signature=[w] Command=[B]\n#",maxbuf);
+ printf("\n>>> NetBeui Packet\nType=0x%X ", control);
+ data = fdata(data,"Length=[d] Signature=[w] Command=[B]\n#",maxbuf);
+ if (data == NULL)
+ goto out;
switch (command) {
case 0xA:
@@ -965,16 +987,29 @@ void netbeui_print(const uchar *data, const uchar *maxbuf)
data = fdata(data,"SessionEnd:\n[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
break;
+ case 0x1f:
+ data = fdata(data,"SessionAlive\n",data2);
+ break;
+
default:
data = fdata(data,"Unknown Netbios Command ",data2);
break;
}
+ if (data == NULL)
+ goto out;
+
+ if (is_truncated) {
+ /* data2 was past the end of the buffer */
+ goto out;
+ }
if (memcmp(data2,"\377SMB",4)==0) {
print_smb(data2,maxbuf);
} else {
int i;
for (i=0;i<128;i++) {
+ if (&data2[i] >= maxbuf)
+ break;
if (memcmp(&data2[i],"\377SMB",4)==0) {
printf("found SMB packet at %d\n", i);
print_smb(&data2[i],maxbuf);
@@ -983,6 +1018,7 @@ void netbeui_print(const uchar *data, const uchar *maxbuf)
}
}
+out:
printf("\n");
}
@@ -998,7 +1034,8 @@ void ipx_netbios_print(const uchar *data, const uchar *maxbuf)
for (i=0;i<128;i++)
if (memcmp(&data[i],"\377SMB",4)==0) {
fdata(data,"\n>>> IPX transport ",&data[i]);
- print_smb(&data[i],maxbuf);
+ if (data != NULL)
+ print_smb(&data[i],maxbuf);
printf("\n");
fflush(stdout);
break;
diff --git a/contrib/tcpdump/print-snmp.c b/contrib/tcpdump/print-snmp.c
index 5013952..2e2a276 100644
--- a/contrib/tcpdump/print-snmp.c
+++ b/contrib/tcpdump/print-snmp.c
@@ -45,7 +45,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.39 1999/12/22 06:27:22 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.44 2000/11/10 17:34:10 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -56,9 +56,6 @@ static const char rcsid[] =
#include <sys/time.h>
#include <ctype.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
@@ -188,7 +185,8 @@ char *ErrorStatus[] = {
};
#define DECODE_ErrorStatus(e) \
( e >= 0 && e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \
- ? ErrorStatus[e] : (sprintf(errbuf, "err=%u", e), errbuf))
+ ? ErrorStatus[e] \
+ : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
/*
* generic-trap values in the SNMP Trap-PDU
@@ -205,7 +203,8 @@ char *GenericTrap[] = {
};
#define DECODE_GenericTrap(t) \
( t >= 0 && t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \
- ? GenericTrap[t] : (sprintf(buf, "gt=%d", t), buf))
+ ? GenericTrap[t] \
+ : (snprintf(buf, sizeof(buf), "gt=%d", t), buf))
/*
* ASN.1 type class table
@@ -429,13 +428,13 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
elem->form = form;
elem->class = class;
elem->id = id;
- if (vflag)
+ if (vflag > 1)
printf("|%.2x", *p);
p++; len--; hdr = 1;
/* extended tag field */
if (id == ASN_ID_EXT) {
for (id = 0; *p & ASN_BIT8 && len > 0; len--, hdr++, p++) {
- if (vflag)
+ if (vflag > 1)
printf("|%.2x", *p);
id = (id << 7) | (*p & ~ASN_BIT8);
}
@@ -453,7 +452,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
return -1;
}
elem->asnlen = *p;
- if (vflag)
+ if (vflag > 1)
printf("|%.2x", *p);
p++; len--; hdr++;
if (elem->asnlen & ASN_BIT8) {
@@ -464,7 +463,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
return -1;
}
for (; noct-- > 0; len--, hdr++) {
- if (vflag)
+ if (vflag > 1)
printf("|%.2x", *p);
elem->asnlen = (elem->asnlen << ASN_SHIFT8) | *p++;
}
@@ -654,7 +653,7 @@ asn1_print(struct be *elem)
switch (elem->type) {
case BE_OCTET:
- for (i = asnlen; i-- > 0; p++);
+ for (i = asnlen; i-- > 0; p++)
printf("_%.2x", *p);
break;
@@ -730,11 +729,12 @@ asn1_print(struct be *elem)
}
d += (elem->data.uns64.low & 0xfffff000);
#if 0 /*is looks illegal, but what is the intention???*/
- sprintf(first, "%.f", d);
+ snprintf(first, sizeof(first), "%.f", d);
#else
- sprintf(first, "%f", d);
+ snprintf(first, sizeof(first), "%f", d);
#endif
- sprintf(last, "%5.5d", elem->data.uns64.low & 0xfff);
+ snprintf(last, sizeof(last), "%5.5d",
+ elem->data.uns64.low & 0xfff);
for (carry = 0, cpf = first+strlen(first)-1, cpl = last+4;
cpl >= last;
cpf--, cpl--) {
@@ -837,12 +837,31 @@ asn1_decode(u_char *p, u_int length)
#ifdef LIBSMI
+#if (SMI_VERSION_MAJOR == 0 && SMI_VERSION_MINOR >= 2) || (SMI_VERSION_MAJOR > 0)
+#define LIBSMI_API_V2
+#else
+#define LIBSMI_API_V1
+#endif
+
+#ifdef LIBSMI_API_V1
+/* Some of the API revisions introduced new calls that can be
+ * represented by macros.
+ */
+#define smiGetNodeType(n) smiGetType((n)->typemodule, (n)->typename)
+
+#else
+/* These calls in the V1 API were removed in V2. */
+#define smiFreeRange(r)
+#define smiFreeType(r)
+#define smiFreeNode(r)
+#endif
+
struct smi2be {
SmiBasetype basetype;
int be;
};
-struct smi2be smi2betab[] = {
+static struct smi2be smi2betab[] = {
{ SMI_BASETYPE_INTEGER32, BE_INT },
{ SMI_BASETYPE_OCTETSTRING, BE_STR },
{ SMI_BASETYPE_OCTETSTRING, BE_INETADDR },
@@ -899,7 +918,7 @@ static int smi_check_type(SmiBasetype basetype, int be)
static int smi_check_a_range(SmiType *smiType, SmiRange *smiRange,
struct be *elem)
{
- int ok;
+ int ok = 1;
switch (smiType->basetype) {
case SMI_BASETYPE_OBJECTIDENTIFIER:
@@ -947,22 +966,34 @@ static int smi_check_range(SmiType *smiType, struct be *elem)
SmiRange *smiRange;
int ok = 1;
+#ifdef LIBSMI_API_V1
for (smiRange = smiGetFirstRange(smiType->module, smiType->name);
+#else
+ for (smiRange = smiGetFirstRange(smiType);
+#endif
smiRange;
smiRange = smiGetNextRange(smiRange)) {
ok = smi_check_a_range(smiType, smiRange, elem);
-
+
if (ok) {
smiFreeRange(smiRange);
break;
}
}
- if (ok && smiType->parentmodule && smiType->parentname) {
+ if (ok
+#ifdef LIBSMI_API_V1
+ && smiType->parentmodule && smiType->parentname
+#endif
+ ) {
SmiType *parentType;
+#ifdef LIBSMI_API_V1
parentType = smiGetType(smiType->parentmodule,
smiType->parentname);
+#else
+ parentType = smiGetParentType(smiType);
+#endif
if (parentType) {
ok = smi_check_range(parentType, elem);
smiFreeType(parentType);
@@ -985,7 +1016,11 @@ static SmiNode *smi_print_variable(struct be *elem)
return NULL;
}
if (vflag) {
- fputs(smiNode->module, stdout);
+#ifdef LIBSMI_API_V1
+ fputs(smiNode->module, stdout);
+#else
+ fputs(smiGetNodeModule(smiNode)->name, stdout);
+#endif
fputs("::", stdout);
}
fputs(smiNode->name, stdout);
@@ -1010,6 +1045,13 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
return;
}
+ if (elem->type == BE_NOSUCHOBJECT
+ || elem->type == BE_NOSUCHINST
+ || elem->type == BE_ENDOFMIBVIEW) {
+ asn1_print(elem);
+ return;
+ }
+
if (NOTIFY_CLASS(pduid) && smiNode->access < SMI_ACCESS_NOTIFY) {
fputs("[notNotifyable]", stdout);
}
@@ -1027,16 +1069,24 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
fputs("[noAccess]", stdout);
}
- if (! smi_check_type(smiNode->basetype, elem->type)) {
- fputs("[wrongType]", stdout);
- }
-
+#ifdef LIBSMI_API_V1
smiType = smiGetType(smiNode->typemodule, smiNode->typename);
+#else
+ smiType = smiGetNodeType(smiNode);
+#endif
if (! smiType) {
asn1_print(elem);
return;
}
+#ifdef LIBSMI_API_V1
+ if (! smi_check_type(smiNode->basetype, elem->type)) {
+#else
+ if (! smi_check_type(smiType->basetype, elem->type)) {
+#endif
+ fputs("[wrongType]", stdout);
+ }
+
if (! smi_check_range(smiType, elem)) {
fputs("[wrongLength]", stdout);
}
@@ -1051,15 +1101,18 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
switch (elem->type) {
case BE_OID:
- if (smiNode->basetype == SMI_BASETYPE_BITS
- && smiNode->typemodule && smiNode->typename) {
+ if (smiType->basetype == SMI_BASETYPE_BITS) {
/* print bit labels */
} else {
smi_decode_oid(elem, oid, &oidlen);
smiNode = smiGetNodeByOID(oidlen, oid);
if (smiNode) {
if (vflag) {
- fputs(smiNode->module, stdout);
+#ifdef LIBSMI_API_V1
+ fputs(smiNode->module, stdout);
+#else
+ fputs(smiGetNodeModule(smiNode)->name, stdout);
+#endif
fputs("::", stdout);
}
fputs(smiNode->name, stdout);
@@ -1075,10 +1128,15 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
break;
case BE_INT:
+#ifdef LIBSMI_API_V1
if (smiNode->basetype == SMI_BASETYPE_ENUM
&& smiNode->typemodule && smiNode->typename) {
for (nn = smiGetFirstNamedNumber(smiNode->typemodule,
smiNode->typename);
+#else
+ if (smiType->basetype == SMI_BASETYPE_ENUM) {
+ for (nn = smiGetFirstNamedNumber(smiType);
+#endif
nn;
nn = smiGetNextNamedNumber(nn)) {
if (nn->value.value.integer32
@@ -1098,7 +1156,7 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
}
if (smiType) {
- smiFreeType(smiType);
+ smiFreeType(smiType);
}
}
#endif
@@ -1244,7 +1302,8 @@ snmppdu_print(u_char pduid, const u_char *np, u_int length)
asn1_print(&elem);
return;
}
- /* ignore the reqId */
+ if (vflag)
+ printf("R=%d ", elem.data.integer);
length -= count;
np += count;
@@ -1411,7 +1470,11 @@ pdu_print(const u_char *np, u_int length, int version)
}
if (count < length)
printf("[%d extra after PDU]", length - count);
+ if (vflag) {
+ fputs("{ ", stdout);
+ }
asn1_print(&pdu);
+ fputs(" ", stdout);
/* descend into PDU */
length = pdu.asnlen;
np = (u_char *)pdu.data.raw;
@@ -1443,6 +1506,10 @@ pdu_print(const u_char *np, u_int length, int version)
snmppdu_print(pdu.id, np, length);
break;
}
+
+ if (vflag) {
+ fputs("} ", stdout);
+ }
}
/*
@@ -1646,6 +1713,10 @@ v3msg_print(const u_char *np, u_int length)
length = elem.asnlen;
np = (u_char *)elem.data.raw;
+ if (vflag) {
+ fputs("{ ", stdout);
+ }
+
/* msgID (INTEGER) */
if ((count = asn1_parse(np, length, &elem)) < 0)
return;
@@ -1710,9 +1781,13 @@ v3msg_print(const u_char *np, u_int length)
if (count < length)
printf("[%d extra after message SEQ]", length - count);
+ if (vflag) {
+ fputs("} ", stdout);
+ }
+
if (model == 3) {
if (vflag) {
- fputs("USM ", stdout);
+ fputs("{ USM ", stdout);
}
} else {
printf("[security model %d]", model);
@@ -1735,13 +1810,20 @@ v3msg_print(const u_char *np, u_int length)
if (model == 3) {
usm_print(elem.data.str, elem.asnlen);
+ if (vflag) {
+ fputs("} ", stdout);
+ }
}
if (vflag) {
- fputs("ScopedPDU ", stdout);
+ fputs("{ ScopedPDU ", stdout);
}
scopedpdu_print(np, length, 3);
+
+ if (vflag) {
+ fputs("} ", stdout);
+ }
}
/*
@@ -1792,7 +1874,7 @@ snmp_print(const u_char *np, u_int length)
case SNMP_VERSION_2:
case SNMP_VERSION_3:
if (vflag)
- printf("%s ", SnmpVersion[elem.data.integer]);
+ printf("{ %s ", SnmpVersion[elem.data.integer]);
break;
default:
printf("[version = %d]", elem.data.integer);
@@ -1814,4 +1896,8 @@ snmp_print(const u_char *np, u_int length)
printf("[version = %d]", elem.data.integer);
break;
}
+
+ if (vflag) {
+ fputs("} ", stdout);
+ }
}
diff --git a/contrib/tcpdump/print-stp.c b/contrib/tcpdump/print-stp.c
new file mode 100644
index 0000000..9281663
--- /dev/null
+++ b/contrib/tcpdump/print-stp.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2000 Lennert Buytenhek
+ *
+ * This software may be distributed either under the terms of the
+ * BSD-style license that accompanies tcpdump or the GNU General
+ * Public License
+ *
+ * Format and print IEEE 802.1d spanning tree protocol packets.
+ * Contributed by Lennert Buytenhek <buytenh@gnu.org>
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.6 2000/09/29 04:58:50 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h"
+
+static void
+stp_print_bridge_id(const u_char *p)
+{
+ printf("%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
+}
+
+static void
+stp_print_config_bpdu(const u_char *p, u_int length)
+{
+ printf("config ");
+ if (p[7] & 1)
+ printf("TOP_CHANGE ");
+ if (p[7] & 0x80)
+ printf("TOP_CHANGE_ACK ");
+
+ stp_print_bridge_id(p+20);
+ printf(".%.2x%.2x ", p[28], p[29]);
+
+ printf("root ");
+ stp_print_bridge_id(p+8);
+
+ printf(" pathcost %i ", (p[16] << 24) | (p[17] << 16) | (p[18] << 8) | p[19]);
+
+ printf("age %i ", p[30]);
+ printf("max %i ", p[32]);
+ printf("hello %i ", p[34]);
+ printf("fdelay %i ", p[36]);
+}
+
+static void
+stp_print_tcn_bpdu(const u_char *p, u_int length)
+{
+ printf("tcn");
+}
+
+/*
+ * Print 802.1d packets.
+ */
+void
+stp_print(const u_char *p, u_int length)
+{
+ if (length < 7)
+ goto trunc;
+
+ printf("802.1d ");
+ if (p[2] != 0x03 || p[3] || p[4] || p[5]) {
+ printf("unknown version");
+ return;
+ }
+
+ switch (p[6])
+ {
+ case 0:
+ if (length < 10)
+ goto trunc;
+ stp_print_config_bpdu(p, length);
+ break;
+
+ case 1:
+ stp_print_tcn_bpdu(p, length);
+ break;
+
+ default:
+ printf("unknown type %i\n", p[6]);
+ break;
+ }
+
+ return;
+trunc:
+ printf("[|stp %d]", length);
+}
diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c
index 0c686d7..7ab39d0 100644
--- a/contrib/tcpdump/print-sunrpc.c
+++ b/contrib/tcpdump/print-sunrpc.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.29 1999/11/21 09:37:02 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.39 2000/10/07 05:53:13 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,17 +32,10 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
-#if __STDC__
struct mbuf;
struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
#include <rpc/rpc.h>
#ifdef HAVE_RPC_RPCENT_H
@@ -58,6 +51,11 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
static struct tok proc2str[] = {
{ PMAPPROC_NULL, "null" },
{ PMAPPROC_SET, "set" },
@@ -77,24 +75,44 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
{
register const struct rpc_msg *rp;
register const struct ip *ip;
+#ifdef INET6
+ register const struct ip6_hdr *ip6;
+#endif
u_int32_t x;
+ char srcid[20], dstid[20]; /*fits 32bit*/
rp = (struct rpc_msg *)bp;
- ip = (struct ip *)bp2;
-
- if (!nflag)
- (void)printf("%s.%x > %s.sunrpc: %d",
- ipaddr_string(&ip->ip_src),
- (u_int32_t)ntohl(rp->rm_xid),
- ipaddr_string(&ip->ip_dst),
- length);
- else
- (void)printf("%s.%x > %s.%x: %d",
- ipaddr_string(&ip->ip_src),
- (u_int32_t)ntohl(rp->rm_xid),
- ipaddr_string(&ip->ip_dst),
- PMAPPORT,
- length);
+
+ if (!nflag) {
+ snprintf(srcid, sizeof(srcid), "0x%x",
+ (u_int32_t)ntohl(rp->rm_xid));
+ strlcpy(dstid, "sunrpc", sizeof(dstid));
+ } else {
+ snprintf(srcid, sizeof(srcid), "0x%x",
+ (u_int32_t)ntohl(rp->rm_xid));
+ snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT);
+ }
+
+ switch (IP_V((struct ip *)bp2)) {
+ case 4:
+ ip = (struct ip *)bp2;
+ printf("%s.%s > %s.%s: %d",
+ ipaddr_string(&ip->ip_src), srcid,
+ ipaddr_string(&ip->ip_dst), dstid, length);
+ break;
+#ifdef INET6
+ case 6:
+ ip6 = (struct ip6_hdr *)bp2;
+ printf("%s.%s > %s.%s: %d",
+ ip6addr_string(&ip6->ip6_src), srcid,
+ ip6addr_string(&ip6->ip6_dst), dstid, length);
+ break;
+#endif
+ default:
+ printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length);
+ break;
+ }
+
printf(" %s", tok2str(proc2str, " proc #%u",
(u_int32_t)ntohl(rp->rm_call.cb_proc)));
x = ntohl(rp->rm_call.cb_rpcvers);
@@ -129,8 +147,8 @@ progstr(prog)
return (buf);
rp = getrpcbynumber(prog);
if (rp == NULL)
- (void) sprintf(buf, "#%u", prog);
+ (void) snprintf(buf, sizeof(buf), "#%u", prog);
else
- strcpy(buf, rp->r_name);
+ strlcpy(buf, rp->r_name, sizeof(buf));
return (buf);
}
diff --git a/contrib/tcpdump/print-tcp.c b/contrib/tcpdump/print-tcp.c
index 451bab6..40d3f49 100644
--- a/contrib/tcpdump/print-tcp.c
+++ b/contrib/tcpdump/print-tcp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.63 1999/12/22 15:44:10 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.81 2000/12/23 20:55:22 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -31,28 +31,31 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
+#include <rpc/rpc.h>
+
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <netinet/tcp.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <unistd.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
+#include "tcp.h"
+
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
+static void print_tcp_rst_data(register const u_char *sp, u_int length);
+
+#define MAX_RST_DATA_LEN 30
+
/* Compatibility */
#ifndef TCPOPT_WSCALE
#define TCPOPT_WSCALE 3 /* window scale factor (rfc1072) */
@@ -82,6 +85,17 @@ 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 {
#ifndef INET6
struct in_addr src;
@@ -115,17 +129,114 @@ static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
#define BGP_PORT 179
#endif
#define NETBIOS_SSN_PORT 139
+#define BXXP_PORT 10288
+#ifndef NFS_PORT
+#define NFS_PORT 2049
+#endif
+
+static int tcp_cksum(register const struct ip *ip,
+ register const struct tcphdr *tp,
+ register int len)
+{
+ int i, tlen;
+ union phu {
+ struct phdr {
+ u_int32_t src;
+ u_int32_t dst;
+ u_char mbz;
+ u_char proto;
+ u_int16_t len;
+ } ph;
+ u_int16_t pa[6];
+ } phu;
+ register const u_int16_t *sp;
+ u_int32_t sum;
+ tlen = ntohs(ip->ip_len) - ((const char *)tp-(const char*)ip);
+
+ /* pseudo-header.. */
+ phu.ph.len = htons(tlen);
+ phu.ph.mbz = 0;
+ phu.ph.proto = IPPROTO_TCP;
+ memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
+ memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+
+ sp = &phu.pa[0];
+ sum = sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5];
+
+ sp = (const u_int16_t *)tp;
+
+ for (i=0; i<(tlen&~1); i+= 2)
+ sum += *sp++;
+
+ if (tlen & 1) {
+ sum += htons( (*(const u_int8_t *)sp) << 8);
+ }
+
+ while (sum > 0xffff)
+ sum = (sum & 0xffff) + (sum >> 16);
+ sum = ~sum & 0xffff;
+
+ return (sum);
+}
+
+#ifdef INET6
+static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp,
+ int len)
+{
+ int i, tlen;
+ register const u_int16_t *sp;
+ u_int32_t sum;
+ union {
+ struct {
+ struct in6_addr ph_src;
+ struct in6_addr ph_dst;
+ u_int32_t ph_len;
+ u_int8_t ph_zero[3];
+ u_int8_t ph_nxt;
+ } ph;
+ u_int16_t pa[20];
+ } phu;
+
+ tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) -
+ ((const char *)tp - (const char*)ip6);
+
+ /* pseudo-header */
+ memset(&phu, 0, sizeof(phu));
+ phu.ph.ph_src = ip6->ip6_src;
+ phu.ph.ph_dst = ip6->ip6_dst;
+ phu.ph.ph_len = htonl(tlen);
+ phu.ph.ph_nxt = IPPROTO_TCP;
+
+ sum = 0;
+ for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
+ sum += phu.pa[i];
+
+ sp = (const u_int16_t *)tp;
+
+ for (i = 0; i < (tlen & ~1); i += 2)
+ sum += *sp++;
+
+ if (tlen & 1)
+ sum += htons((*(const u_int8_t *)sp) << 8);
+
+ while (sum > 0xffff)
+ sum = (sum & 0xffff) + (sum >> 16);
+ sum = ~sum & 0xffff;
+
+ return (sum);
+}
+#endif
void
tcp_print(register const u_char *bp, register u_int length,
- register const u_char *bp2)
+ register const u_char *bp2, int fragmented)
{
register const struct tcphdr *tp;
register const struct ip *ip;
register u_char flags;
register int hlen;
register char ch;
- u_short sport, dport, win, urp;
+ u_int16_t sport, dport, win, urp;
u_int32_t seq, ack, thseq, thack;
int threv;
#ifdef INET6
@@ -135,7 +246,7 @@ tcp_print(register const u_char *bp, register u_int length,
tp = (struct tcphdr *)bp;
ip = (struct ip *)bp2;
#ifdef INET6
- if (ip->ip_v == 6)
+ if (IP_V(ip) == 6)
ip6 = (struct ip6_hdr *)bp2;
else
ip6 = NULL;
@@ -151,6 +262,28 @@ tcp_print(register const u_char *bp, register u_int length,
sport = ntohs(tp->th_sport);
dport = ntohs(tp->th_dport);
+
+ hlen = TH_OFF(tp) * 4;
+
+ /*
+ * If data present and NFS port used, assume NFS.
+ * Pass offset of data plus 4 bytes for RPC TCP msg length
+ * to NFS print routines.
+ */
+ if (!qflag) {
+ if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend &&
+ dport == NFS_PORT) {
+ nfsreq_print((u_char *)tp + hlen + 4, length-hlen,
+ (u_char *)ip);
+ return;
+ } else if ((u_char *)tp + 4 + sizeof(struct rpc_msg)
+ <= snapend &&
+ sport == NFS_PORT) {
+ nfsreply_print((u_char *)tp + hlen + 4,length-hlen,
+ (u_char *)ip);
+ return;
+ }
+ }
#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_TCP) {
@@ -180,21 +313,17 @@ tcp_print(register const u_char *bp, register u_int length,
TCHECK(*tp);
- seq = ntohl(tp->th_seq);
- ack = ntohl(tp->th_ack);
+ seq = (u_int32_t)ntohl(tp->th_seq);
+ ack = (u_int32_t)ntohl(tp->th_ack);
win = ntohs(tp->th_win);
urp = ntohs(tp->th_urp);
if (qflag) {
- (void)printf("tcp %d", length - tp->th_off * 4);
+ (void)printf("tcp %d", length - TH_OFF(tp) * 4);
return;
}
-#ifdef TH_ECN
- if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|TH_ECN))
-#else
- if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH))
-#endif
- {
+ 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)
@@ -203,22 +332,13 @@ tcp_print(register const u_char *bp, register u_int length,
putchar('R');
if (flags & TH_PUSH)
putchar('P');
-#ifdef TH_ECN
- if (flags & TH_ECN)
- putchar('C');
-#endif
+ if (flags & TH_CWR)
+ putchar('W'); /* congestion _W_indow reduced (ECN) */
+ if (flags & TH_ECNECHO)
+ putchar('E'); /* ecn _E_cho sent (ECN) */
} else
putchar('.');
- if (flags&0xc0) {
- printf(" [");
- if (flags&0x40)
- printf("ECN-Echo");
- if (flags&0x80)
- printf("%sCWR", (flags&0x40) ? "," : "");
- printf("]");
- }
-
if (!Sflag && (flags & TH_ACK)) {
register struct tcp_seq_hash *th;
register int rev;
@@ -230,7 +350,7 @@ tcp_print(register const u_char *bp, register u_int length,
* both directions).
*/
#ifdef INET6
- bzero(&tha, sizeof(tha));
+ memset(&tha, 0, sizeof(tha));
rev = 0;
if (ip6) {
if (sport > dport) {
@@ -292,7 +412,7 @@ tcp_print(register const u_char *bp, register u_int length,
sizeof(th->addr)))
break;
- if (!th->nxt || flags & TH_SYN) {
+ if (!th->nxt || (flags & TH_SYN)) {
/* didn't find it or new conversation */
if (th->nxt == NULL) {
th->nxt = (struct tcp_seq_hash *)
@@ -305,22 +425,48 @@ tcp_print(register const u_char *bp, register u_int length,
th->ack = seq, th->seq = ack - 1;
else
th->seq = seq, th->ack = ack - 1;
- } else {
-
- thseq = th->seq;
- thack = th->ack;
+ } else {
if (rev)
seq -= th->ack, ack -= th->seq;
else
seq -= th->seq, ack -= th->ack;
}
+
+ thseq = th->seq;
+ thack = th->ack;
+ } else {
+ /*fool gcc*/
+ thseq = thack = threv = 0;
}
- hlen = tp->th_off * 4;
if (hlen > length) {
(void)printf(" [bad hdr length]");
return;
}
+
+ if (IP_V(ip) == 4 && vflag && !fragmented) {
+ int sum;
+ if (TTEST2(tp->th_sport, length)) {
+ sum = tcp_cksum(ip, tp, length);
+ if (sum != 0)
+ (void)printf(" [bad tcp cksum %x!]", sum);
+ else
+ (void)printf(" [tcp sum ok]");
+ }
+ }
+#ifdef INET6
+ if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) {
+ int sum;
+ if (TTEST2(tp->th_sport, length)) {
+ sum = tcp6_cksum(ip6, tp, length);
+ if (sum != 0)
+ (void)printf(" [bad tcp cksum %x!]", sum);
+ else
+ (void)printf(" [tcp sum ok]");
+ }
+ }
+#endif
+
length -= hlen;
if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
(void)printf(" %u:%u(%d)", seq, seq + length, length);
@@ -493,14 +639,21 @@ tcp_print(register const u_char *bp, register u_int length,
/*
* Decode payload if necessary.
*/
- bp += (tp->th_off * 4);
- if (!qflag && vflag && length > 0
- && (sport == TELNET_PORT || dport == TELNET_PORT))
- telnet_print(bp, length);
- else if (sport == BGP_PORT || dport == BGP_PORT)
- bgp_print(bp, length);
- else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
- nbt_tcp_print(bp, length);
+ bp += TH_OFF(tp) * 4;
+ if (flags & TH_RST) {
+ if (vflag)
+ print_tcp_rst_data(bp, length);
+ } else {
+ if (sport == TELNET_PORT || dport == TELNET_PORT) {
+ if (!qflag && vflag)
+ telnet_print(bp, length);
+ } else if (sport == BGP_PORT || dport == BGP_PORT)
+ bgp_print(bp, length);
+ else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
+ nbt_tcp_print(bp, length);
+ else if (sport == BXXP_PORT || dport == BXXP_PORT)
+ bxxp_print(bp, length);
+ }
return;
bad:
fputs("[bad opt]", stdout);
@@ -513,3 +666,41 @@ trunc:
putchar('>');
}
+/*
+ * RFC1122 says the following on data in RST segments:
+ *
+ * 4.2.2.12 RST Segment: RFC-793 Section 3.4
+ *
+ * A TCP SHOULD allow a received RST segment to include data.
+ *
+ * DISCUSSION
+ * It has been suggested that a RST segment could contain
+ * ASCII text that encoded and explained the cause of the
+ * RST. No standard has yet been established for such
+ * data.
+ *
+ */
+
+static void
+print_tcp_rst_data(register const u_char *sp, u_int length)
+{
+ int c;
+
+ if (TTEST2(*sp, length))
+ printf(" [RST");
+ else
+ printf(" [!RST");
+ if (length > MAX_RST_DATA_LEN) {
+ length = MAX_RST_DATA_LEN; /* can use -X for longer */
+ putchar('+'); /* indicate we truncate */
+ }
+ putchar(' ');
+ while (length-- && sp <= snapend) {
+ c = *sp++;
+ if (isprint(c))
+ putchar(c);
+ else
+ putchar('.');
+ }
+ putchar(']');
+}
diff --git a/contrib/tcpdump/print-telnet.c b/contrib/tcpdump/print-telnet.c
index bb0f4ab..bad4e7d 100644
--- a/contrib/tcpdump/print-telnet.c
+++ b/contrib/tcpdump/print-telnet.c
@@ -51,35 +51,28 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.2.2.2 2000/01/11 06:58:28 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.12 2000/09/29 04:58:51 guy Exp $";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <ctype.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <netinet/tcp.h>
-#include <netinet/tcpip.h>
#define TELCMDS
#define TELOPTS
#include <arpa/telnet.h>
#include <stdio.h>
-#ifdef __STDC__
#include <stdlib.h>
-#endif
#include <unistd.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-
#ifndef TELCMD_FIRST
# define TELCMD_FIRST SE
#endif
@@ -128,15 +121,16 @@ telnet_print(register const u_char *sp, u_int length)
x = *sp++; /* option */
length--;
if (x >= 0 && x < NTELOPTS) {
- (void)sprintf(tnet, "%s %s",
- telcmds[i], telopts[x]);
+ (void)snprintf(tnet, sizeof(tnet),
+ "%s %s", telcmds[i], telopts[x]);
} else {
- (void)sprintf(tnet, "%s %#x",
- telcmds[i], x);
+ (void)snprintf(tnet, sizeof(tnet),
+ "%s %#x", telcmds[i], x);
}
break;
default:
- (void)strcpy(tnet, telcmds[i]);
+ (void)snprintf(tnet, sizeof(tnet), "%s",
+ telcmds[i]);
}
if (c == SB) {
c = *sp++;
@@ -174,11 +168,13 @@ telnet_print(register const u_char *sp, u_int length)
hex_print_with_offset(osp, i, off);
off += i;
if (i > 8)
- printf("\n\t\t\t\t%s", tnet);
+ printf("\n\t\t\t\t");
else
- printf("%*s\t%s", (8 - i) * 3, "", tnet);
+ printf("%*s\t", (8 - i) * 3, "");
+ safeputs(tnet);
} else {
- printf("%s%s", (first) ? " [telnet " : ", ", tnet);
+ printf("%s", (first) ? " [telnet " : ", ");
+ safeputs(tnet);
}
first = 0;
}
diff --git a/contrib/tcpdump/print-timed.c b/contrib/tcpdump/print-timed.c
new file mode 100644
index 0000000..d683c40
--- /dev/null
+++ b/contrib/tcpdump/print-timed.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2000 Ben Smithurst <ben@scientia.demon.co.uk>
+ * 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: /tcpdump/master/tcpdump/print-timed.c,v 1.1 2000/10/06 05:35:37 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+#include "ip.h"
+#include "udp.h"
+#include "tcp.h"
+
+#include "timed.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
+
+static char *tsptype[TSPTYPENUMBER] =
+ { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
+ "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
+ "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ",
+ "TEST", "SETDATE", "SETDATEREQ", "LOOP" };
+
+void
+timed_print(register const u_char *bp, u_int length)
+{
+#define endof(x) ((u_char *)&(x) + sizeof (x))
+ struct tsp *tsp = (struct tsp *)bp;
+ long sec, usec;
+ const u_char *end;
+
+ if (endof(tsp->tsp_type) > snapend) {
+ fputs("[|timed]", stdout);
+ return;
+ }
+ if (tsp->tsp_type < TSPTYPENUMBER)
+ printf("TSP_%s", tsptype[tsp->tsp_type]);
+ else
+ printf("(tsp_type %#x)", tsp->tsp_type);
+
+ if (endof(tsp->tsp_vers) > snapend) {
+ fputs(" [|timed]", stdout);
+ return;
+ }
+ printf(" vers %d", tsp->tsp_vers);
+
+ if (endof(tsp->tsp_seq) > snapend) {
+ fputs(" [|timed]", stdout);
+ return;
+ }
+ printf(" seq %d", tsp->tsp_seq);
+
+ if (tsp->tsp_type == TSP_LOOP) {
+ if (endof(tsp->tsp_hopcnt) > snapend) {
+ fputs(" [|timed]", stdout);
+ return;
+ }
+ printf(" hopcnt %d", tsp->tsp_hopcnt);
+ } else if (tsp->tsp_type == TSP_SETTIME ||
+ tsp->tsp_type == TSP_ADJTIME ||
+ tsp->tsp_type == TSP_SETDATE ||
+ tsp->tsp_type == TSP_SETDATEREQ) {
+ if (endof(tsp->tsp_time) > snapend) {
+ fputs(" [|timed]", stdout);
+ return;
+ }
+ sec = ntohl((long)tsp->tsp_time.tv_sec);
+ usec = ntohl((long)tsp->tsp_time.tv_usec);
+ if (usec < 0)
+ /* corrupt, skip the rest of the packet */
+ return;
+ fputs(" time ", stdout);
+ if (sec < 0 && usec != 0) {
+ sec++;
+ if (sec == 0)
+ fputc('-', stdout);
+ usec = 1000000 - usec;
+ }
+ printf("%ld.%06ld", sec, usec);
+ }
+
+ end = memchr(tsp->tsp_name, '\0', snapend - (u_char *)tsp->tsp_name);
+ if (end == NULL)
+ fputs(" [|timed]", stdout);
+ else {
+ fputs(" name ", stdout);
+ fwrite(tsp->tsp_name, end - (u_char *)tsp->tsp_name, 1, stdout);
+ }
+}
diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c
index e1dff5b..aff3607 100644
--- a/contrib/tcpdump/print-token.c
+++ b/contrib/tcpdump/print-token.c
@@ -19,81 +19,91 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Hacked version of print-ether.c Larry Lile <lile@stdio.com>
+ *
+ * Further tweaked to more closely resemble print-fddi.c
+ * Guy Harris <guy@alum.mit.edu>
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header$";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.11 2000/12/23 20:48:13 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
#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 "token.h"
-
#include <netinet/in.h>
-#include <net/ethernet.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>
-#include <stdio.h>
#include <pcap.h>
+#include <stdio.h>
+#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
-#include "llc.h"
-const u_char *packetp;
-const u_char *snapend;
+#include "ether.h"
+#include "token.h"
+
+/* Extract src, dst addresses */
+static inline void
+extract_token_addrs(const struct token_header *trp, char *fsrc, char *fdst)
+{
+ memcpy(fdst, (char *)trp->token_dhost, 6);
+ memcpy(fsrc, (char *)trp->token_shost, 6);
+}
+/*
+ * Print the TR MAC header
+ */
static inline void
-token_print(register const u_char *bp, u_int length)
+token_print(register const struct token_header *trp, register u_int length,
+ register const u_char *fsrc, register const u_char *fdst)
{
- register const struct token_header *tp;
- register const struct llc *lp;
- u_short ether_type;
-
- tp = (const struct token_header *)bp;
- lp = (struct llc *)(bp + TOKEN_HDR_LEN);
- if (IS_SOURCE_ROUTED)
- lp = (struct llc *)(bp + TOKEN_HDR_LEN + RIF_LENGTH);
-
- /*
- * Ethertype on ethernet is a short, but ethertype in an llc-snap has
- * been defined as 2 u_chars. This is a stupid little hack to fix
- * this for now but something better should be done using ntohs()
- * XXX
- */
- ether_type = ((u_short)lp->ethertype[1] << 16) | lp->ethertype[0];
-
- if (qflag)
- (void)printf("%s %s %d: ",
- etheraddr_string(ESRC(tp)),
- etheraddr_string(EDST(tp)),
- length);
+ char *srcname, *dstname;
+
+ srcname = etheraddr_string(fsrc);
+ dstname = etheraddr_string(fdst);
+
+ if (vflag)
+ (void) printf("%02x %02x %s %s %d: ",
+ trp->token_ac,
+ trp->token_fc,
+ srcname, dstname,
+ length);
else
- (void)printf("%s %s %s %d: ",
- etheraddr_string(ESRC(tp)),
- etheraddr_string(EDST(tp)),
- etherproto_string(ether_type),
- length);
+ printf("%s %s %d: ", srcname, dstname, length);
}
+static char *broadcast_indicator[] = {
+ "Non-Broadcast", "Non-Broadcast",
+ "Non-Broadcast", "Non-Broadcast",
+ "All-routes", "All-routes",
+ "Single-route", "Single-route"
+};
+
+static char *direction[] = {
+ "Forward", "Backward"
+};
+
+static char *largest_frame[] = {
+ "516",
+ "1500",
+ "2052",
+ "4472",
+ "8144",
+ "11407",
+ "17800",
+ "??"
+};
+
/*
* This is the top level routine of the printer. 'p' is the points
- * to the ether header of the packet, 'tvp' is the timestamp,
+ * to the TR header of the packet, 'tvp' is the timestamp,
* 'length' is the length of the packet off the wire, and 'caplen'
* is the number of bytes actually captured.
*/
@@ -102,64 +112,99 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- struct token_header *tp;
- u_short ether_type;
- extern u_short extracted_ethertype;
- u_int route_len = 0;
- struct llc *lp;
+ struct token_header *trp;
+ u_short extracted_ethertype;
+ struct ether_header ehdr;
+ u_int route_len = 0, seg;
- tp = (struct token_header *)p;
+ trp = (struct token_header *)p;
ts_print(&h->ts);
- if (caplen < TOKEN_HDR_LEN) {
+ if (caplen < TOKEN_HDRLEN) {
printf("[|token-ring]");
goto out;
}
-
- if (eflag)
- token_print(p, length);
-
+ /*
+ * Get the TR addresses into a canonical form
+ */
+ extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));
/*
* Some printers want to get back at the ethernet addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
- tp = (struct token_header *)p;
-
- /* Adjust for source routing information in the MAC header */
- if (IS_SOURCE_ROUTED) {
- route_len = RIF_LENGTH;
- }
-
- /* Set pointer to llc header, adjusted for routing information */
- lp = (struct llc *)(p + TOKEN_HDR_LEN + route_len);
-
- packetp = p;
snapend = p + caplen;
+ /*
+ * Actually, the only printers that use packetp are print-arp.c
+ * and print-bootp.c, and they assume that packetp points to an
+ * Ethernet header. The right thing to do is to fix them to know
+ * which link type is in use when they excavate. XXX
+ */
+ packetp = (u_char *)&ehdr;
+
+ /* Adjust for source routing information in the MAC header */
+ if (IS_SOURCE_ROUTED(trp)) {
+ /* Clear source-routed bit */
+ *ESRC(&ehdr) &= 0x7f;
+
+ if (eflag)
+ token_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+
+ route_len = RIF_LENGTH(trp);
+ if (vflag) {
+ printf("%s ", broadcast_indicator[BROADCAST(trp)]);
+ printf("%s", direction[DIRECTION(trp)]);
+
+ for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
+ printf(" [%d:%d]", RING_NUMBER(trp, seg),
+ BRIDGE_NUMBER(trp, seg));
+ } else {
+ printf("rt = %x", ntohs(trp->token_rcf));
+
+ for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
+ printf(":%x", ntohs(trp->token_rseg[seg]));
+ }
+ printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
+ } else {
+ if (eflag)
+ token_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+ }
- /* Skip over token ring MAC header */
- length -= TOKEN_HDR_LEN + route_len;
- caplen -= TOKEN_HDR_LEN + route_len;
- p += TOKEN_HDR_LEN + route_len;
-
- ether_type = ntohs((int)lp->ethertype);
+ /* Skip over token ring MAC header and routing information */
+ length -= TOKEN_HDRLEN + route_len;
+ p += TOKEN_HDRLEN + route_len;
+ caplen -= TOKEN_HDRLEN + route_len;
+ /* Frame Control field determines interpretation of packet */
extracted_ethertype = 0;
- /* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(tp), EDST(tp)) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- token_print((u_char *)tp, length);
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
+ /* Try to print the LLC-layer header & higher layers */
+ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+ &extracted_ethertype) == 0) {
+ /* ether_type not known, print raw packet */
+ if (!eflag)
+ token_print(trp,
+ length + TOKEN_HDRLEN + route_len,
+ ESRC(&ehdr), EDST(&ehdr));
+ if (extracted_ethertype) {
+ printf("(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype)));
+ }
+ if (!xflag && !qflag)
+ default_print(p, caplen);
}
+ } else {
+ /* Some kinds of TR packet we cannot handle intelligently */
+ /* XXX - dissect MAC packets if frame type is 0 */
+ if (!eflag)
+ token_print(trp, length + TOKEN_HDRLEN + route_len,
+ ESRC(&ehdr), EDST(&ehdr));
if (!xflag && !qflag)
default_print(p, caplen);
}
if (xflag)
default_print(p, caplen);
- out:
+out:
putchar('\n');
}
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index 48de21a..70daef1 100644
--- a/contrib/tcpdump/print-udp.c
+++ b/contrib/tcpdump/print-udp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.70 1999/12/22 06:27:23 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.90 2000/12/23 20:55:22 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,22 +30,9 @@ static const char rcsid[] =
#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>
-#ifdef NOERROR
-#undef NOERROR /* Solaris sucks */
-#endif
-#ifdef T_UNSPEC
-#undef T_UNSPEC /* SINIX does too */
-#endif
-#include <arpa/nameser.h>
#ifdef SEGSIZE
#undef SEGSIZE
#endif
@@ -54,27 +41,38 @@ static const char rcsid[] =
#include <rpc/rpc.h>
#include <stdio.h>
-
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
+#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "appletalk.h"
+#include "udp.h"
+
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
+#ifdef NOERROR
+#undef NOERROR /* Solaris sucks */
+#endif
+#ifdef T_UNSPEC
+#undef T_UNSPEC /* SINIX does too */
+#endif
+#include "nameser.h"
#include "nfs.h"
#include "bootp.h"
struct rtcphdr {
- u_short rh_flags; /* T:2 P:1 CNT:5 PT:8 */
- u_short rh_len; /* length of message (in words) */
- u_int rh_ssrc; /* synchronization src id */
+ u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
+ u_int16_t rh_len; /* length of message (in words) */
+ u_int32_t rh_ssrc; /* synchronization src id */
};
typedef struct {
- u_int upper; /* more significant 32 bits */
- u_int lower; /* less significant 32 bits */
+ u_int32_t upper; /* more significant 32 bits */
+ u_int32_t lower; /* less significant 32 bits */
} ntp64;
/*
@@ -82,9 +80,9 @@ typedef struct {
*/
struct rtcp_sr {
ntp64 sr_ntp; /* 64-bit ntp timestamp */
- u_int sr_ts; /* reference media timestamp */
- u_int sr_np; /* no. packets sent */
- u_int sr_nb; /* no. bytes sent */
+ u_int32_t sr_ts; /* reference media timestamp */
+ u_int32_t sr_np; /* no. packets sent */
+ u_int32_t sr_nb; /* no. bytes sent */
};
/*
@@ -92,12 +90,12 @@ struct rtcp_sr {
* Time stamps are middle 32-bits of ntp timestamp.
*/
struct rtcp_rr {
- u_int rr_srcid; /* sender being reported */
- u_int rr_nl; /* no. packets lost */
- u_int rr_ls; /* extended last seq number received */
- u_int rr_dv; /* jitter (delay variance) */
- u_int rr_lsr; /* orig. ts from last rr from this src */
- u_int rr_dlsr; /* time from recpt of last rr to xmit time */
+ u_int32_t rr_srcid; /* sender being reported */
+ u_int32_t rr_nl; /* no. packets lost */
+ u_int32_t rr_ls; /* extended last seq number received */
+ u_int32_t rr_dv; /* jitter (delay variance) */
+ u_int32_t rr_lsr; /* orig. ts from last rr from this src */
+ u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */
};
/*XXX*/
@@ -119,7 +117,7 @@ static void
vat_print(const void *hdr, u_int len, register const struct udphdr *up)
{
/* vat/vt audio */
- u_int ts = *(u_short *)hdr;
+ u_int ts = *(u_int16_t *)hdr;
if ((ts & 0xf060) != 0) {
/* probably vt */
(void)printf(" udp/vt %u %d / %d",
@@ -127,8 +125,8 @@ vat_print(const void *hdr, u_int len, register const struct udphdr *up)
ts & 0x3ff, ts >> 10);
} else {
/* probably vat */
- u_int i0 = ntohl(((u_int *)hdr)[0]);
- u_int i1 = ntohl(((u_int *)hdr)[1]);
+ u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
+ u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
printf(" udp/vat %u c%d %u%s",
(u_int32_t)(ntohs(up->uh_ulen) - sizeof(*up) - 8),
i0 & 0xffff,
@@ -147,8 +145,8 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
/* rtp v1 or v2 */
u_int *ip = (u_int *)hdr;
u_int hasopt, hasext, contype, hasmarker;
- u_int i0 = ntohl(((u_int *)hdr)[0]);
- u_int i1 = ntohl(((u_int *)hdr)[1]);
+ u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
+ u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
u_int dlen = ntohs(up->uh_ulen) - sizeof(*up) - 8;
const char * ptype;
@@ -182,7 +180,7 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
i0 & 0xffff,
i1);
if (vflag) {
- printf(" %u", i1);
+ printf(" %u", (u_int32_t)ntohl(((u_int *)hdr)[2]));
if (hasopt) {
u_int i2, optlen;
do {
@@ -219,7 +217,7 @@ rtcp_print(const u_char *hdr, const u_char *ep)
struct rtcp_sr *sr;
struct rtcphdr *rh = (struct rtcphdr *)hdr;
u_int len;
- u_short flags;
+ u_int16_t flags;
int cnt;
double ts, dts;
if ((u_char *)(rh + 1) > ep) {
@@ -236,7 +234,7 @@ rtcp_print(const u_char *hdr, const u_char *ep)
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
printf(" [%d]", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
if ((u_char *)(sr + 1) > ep) {
printf(" [|rtcp]");
return (ep);
@@ -254,18 +252,18 @@ rtcp_print(const u_char *hdr, const u_char *ep)
printf(" [%d]", len);
rr = (struct rtcp_rr *)(rh + 1);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
break;
case RTCP_PT_SDES:
printf(" sdes %d", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
cnt = 0;
break;
case RTCP_PT_BYE:
printf(" bye %d", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
cnt = 0;
break;
default:
@@ -292,6 +290,100 @@ rtcp_print(const u_char *hdr, const u_char *ep)
return (hdr + len);
}
+static int udp_cksum(register const struct ip *ip,
+ register const struct udphdr *up,
+ register int len)
+{
+ int i, tlen;
+ union phu {
+ struct phdr {
+ u_int32_t src;
+ u_int32_t dst;
+ u_char mbz;
+ u_char proto;
+ u_int16_t len;
+ } ph;
+ u_int16_t pa[6];
+ } phu;
+ register const u_int16_t *sp;
+ u_int32_t sum;
+ tlen = ntohs(ip->ip_len) - ((const char *)up-(const char*)ip);
+
+ /* pseudo-header.. */
+ phu.ph.len = htons(tlen);
+ phu.ph.mbz = 0;
+ phu.ph.proto = IPPROTO_UDP;
+ memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
+ memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+
+ sp = &phu.pa[0];
+ sum = sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5];
+
+ sp = (const u_int16_t *)up;
+
+ for (i=0; i<(tlen&~1); i+= 2)
+ sum += *sp++;
+
+ if (tlen & 1) {
+ sum += htons( (*(const u_int8_t *)sp) << 8);
+ }
+
+ while (sum > 0xffff)
+ sum = (sum & 0xffff) + (sum >> 16);
+ sum = ~sum & 0xffff;
+
+ return (sum);
+}
+
+#ifdef INET6
+static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
+ int len)
+{
+ int i, tlen;
+ register const u_int16_t *sp;
+ u_int32_t sum;
+ union {
+ struct {
+ struct in6_addr ph_src;
+ struct in6_addr ph_dst;
+ u_int32_t ph_len;
+ u_int8_t ph_zero[3];
+ u_int8_t ph_nxt;
+ } ph;
+ u_int16_t pa[20];
+ } phu;
+
+ tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) -
+ ((const char *)up - (const char*)ip6);
+
+ /* pseudo-header */
+ memset(&phu, 0, sizeof(phu));
+ phu.ph.ph_src = ip6->ip6_src;
+ phu.ph.ph_dst = ip6->ip6_dst;
+ phu.ph.ph_len = htonl(tlen);
+ phu.ph.ph_nxt = IPPROTO_UDP;
+
+ sum = 0;
+ for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
+ sum += phu.pa[i];
+
+ sp = (const u_int16_t *)up;
+
+ for (i = 0; i < (tlen & ~1); i += 2)
+ sum += *sp++;
+
+ if (tlen & 1)
+ sum += htons((*(const u_int8_t *)sp) << 8);
+
+ while (sum > 0xffff)
+ sum = (sum & 0xffff) + (sum >> 16);
+ sum = ~sum & 0xffff;
+
+ return (sum);
+}
+#endif
+
+
/* XXX probably should use getservbyname() and cache answers */
#define TFTP_PORT 69 /*XXX*/
#define KERBEROS_PORT 88 /*XXX*/
@@ -300,6 +392,7 @@ rtcp_print(const u_char *hdr, const u_char *ep)
#define NTP_PORT 123 /*XXX*/
#define SNMPTRAP_PORT 162 /*XXX*/
#define ISAKMP_PORT 500 /*XXX*/
+#define TIMED_PORT 525 /*XXX*/
#define RIP_PORT 520 /*XXX*/
#define KERBEROS_SEC_PORT 750 /*XXX*/
#define L2TP_PORT 1701 /*XXX*/
@@ -310,6 +403,10 @@ rtcp_print(const u_char *hdr, const u_char *ep)
#define NETBIOS_NS_PORT 137
#define NETBIOS_DGRAM_PORT 138
#define CISCO_AUTORP_PORT 496 /*XXX*/
+#define RADIUS_PORT 1645
+#define RADIUS_NEW_PORT 1812
+#define RADIUS_ACCOUNTING_PORT 1646
+#define RADIUS_NEW_ACCOUNTING_PORT 1813
#ifdef INET6
#define RIPNG_PORT 521 /*XXX*/
@@ -318,13 +415,14 @@ rtcp_print(const u_char *hdr, const u_char *ep)
#endif
void
-udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
+udp_print(register const u_char *bp, u_int length,
+ register const u_char *bp2, int fragmented)
{
register const struct udphdr *up;
register const struct ip *ip;
register const u_char *cp;
register const u_char *ep = bp + length;
- u_short sport, dport, ulen;
+ u_int16_t sport, dport, ulen;
#ifdef INET6
register const struct ip6_hdr *ip6;
#endif
@@ -334,7 +432,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
up = (struct udphdr *)bp;
ip = (struct ip *)bp2;
#ifdef INET6
- if (ip->ip_v == 6)
+ if (IP_V(ip) == 6)
ip6 = (struct ip6_hdr *)bp2;
else
ip6 = NULL;
@@ -356,6 +454,13 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
sport = ntohs(up->uh_sport);
dport = ntohs(up->uh_dport);
ulen = ntohs(up->uh_ulen);
+ if (ulen < 8) {
+ (void)printf("%s > %s: truncated-udplength %d",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst),
+ ulen);
+ return;
+ }
if (packettype) {
register struct rpc_msg *rp;
enum msg_type direction;
@@ -418,6 +523,15 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
udpport_string(dport));
snmp_print((const u_char *)(up + 1), length);
break;
+
+ case PT_CNFP:
+ (void)printf("%s.%s > %s.%s:",
+ ipaddr_string(&ip->ip_src),
+ udpport_string(sport),
+ ipaddr_string(&ip->ip_dst),
+ udpport_string(dport));
+ cnfp_print(cp, length, (const u_char *)ip);
+ break;
}
return;
}
@@ -451,7 +565,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
(atalk_port(sport) || atalk_port(dport))) {
if (vflag)
fputs("kip ", stdout);
- atalk_print(cp, length);
+ llap_print(cp, length);
return;
}
}
@@ -488,10 +602,38 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
}
#endif
+ if (IP_V(ip) == 4 && vflag && !fragmented) {
+ int sum = up->uh_sum;
+ if (sum == 0) {
+ (void)printf(" [no cksum]");
+ } else if (TTEST2(cp[0], length)) {
+ sum = udp_cksum(ip, up, length);
+ if (sum != 0)
+ (void)printf(" [bad udp cksum %x!]", sum);
+ else
+ (void)printf(" [udp sum ok]");
+ }
+ }
+#ifdef INET6
+ if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) {
+ int sum = up->uh_sum;
+ /* for IPv6, UDP checksum is mandatory */
+ if (TTEST2(cp[0], length)) {
+ sum = udp6_cksum(ip6, up, length);
+ if (sum != 0)
+ (void)printf(" [bad udp cksum %x!]", sum);
+ else
+ (void)printf(" [udp sum ok]");
+ }
+ }
+#endif
+
if (!qflag) {
#define ISPORT(p) (dport == (p) || sport == (p))
if (ISPORT(NAMESERVER_PORT))
ns_print((const u_char *)(up + 1), length);
+ else if (ISPORT(TIMED_PORT))
+ timed_print((const u_char *)(up + 1), length);
else if (ISPORT(TFTP_PORT))
tftp_print((const u_char *)(up + 1), length);
else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
@@ -544,6 +686,11 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
wb_print((const void *)(up + 1), length);
else if (ISPORT(CISCO_AUTORP_PORT))
cisco_autorp_print((const void *)(up + 1), length);
+ else if (ISPORT(RADIUS_PORT) ||
+ ISPORT(RADIUS_NEW_PORT) ||
+ ISPORT(RADIUS_ACCOUNTING_PORT) ||
+ ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
+ radius_print((const u_char *)(up+1), length);
else
(void)printf(" udp %u",
(u_int32_t)(ulen - sizeof(*up)));
diff --git a/contrib/tcpdump/print-vjc.c b/contrib/tcpdump/print-vjc.c
index 1b8847f..4283da6 100644
--- a/contrib/tcpdump/print-vjc.c
+++ b/contrib/tcpdump/print-vjc.c
@@ -23,48 +23,27 @@
#include "config.h"
#endif
-#if defined(__bsdi__)
-
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.2.2.1 2000/01/11 06:58:28 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.9 2000/10/09 01:53:21 guy Exp $ (LBL)";
#endif
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-
-#if __STDC__
-struct mbuf;
-struct rtentry;
-#endif
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
-#if defined(__NetBSD__)
-#include <sys/mbuf.h>
-#include <net/ppp_defs.h>
-#endif
-
-#if defined(__bsdi__) || defined(__NetBSD__)
-#include <net/if_ppp.h>
-#include <net/slcompress.h>
-#endif
-
#include "interface.h"
#include "addrtoname.h"
+#include "slcompress.h"
+#include "ppp.h"
+
int
vjc_print(register const char *bp, register u_int length, u_short proto)
{
@@ -101,4 +80,3 @@ vjc_print(register const char *bp, register u_int length, u_short proto)
return -1;
}
}
-#endif /* defined(__bsdi__) || defined(__NetBSD__) */
diff --git a/contrib/tcpdump/print-vrrp.c b/contrib/tcpdump/print-vrrp.c
new file mode 100644
index 0000000..6b7ac94
--- /dev/null
+++ b/contrib/tcpdump/print-vrrp.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2000 William C. Fenner.
+ * All rights reserved.
+ *
+ * Kevin Steves <ks@hp.se> July 2000
+ * Modified to:
+ * - print version, type string and packet length
+ * - print IP address count if > 1 (-v)
+ * - verify checksum (-v)
+ * - print authentication string (-v)
+ *
+ * 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, and (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.
+ * The name of William C. Fenner may not 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: /tcpdump/master/tcpdump/print-vrrp.c,v 1.3 2000/10/10 05:05:08 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <netinet/in.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+/*
+ * RFC 2338:
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |Version| Type | Virtual Rtr ID| Priority | Count IP Addrs|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Type | Adver Int | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | IP Address (1) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | . |
+ * | . |
+ * | . |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | IP Address (n) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Authentication Data (1) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Authentication Data (2) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+void
+vrrp_print(register const u_char *bp, register u_int len, int ttl)
+{
+ int version, type, auth_type;
+ char *type_s;
+
+ TCHECK(bp[0]);
+ version = (bp[0] & 0xf0) >> 4;
+ type = bp[0] & 0x0f;
+ if (type == 1)
+ type_s = "advertise";
+ else
+ type_s = "unknown";
+ printf("VRRPv%d-%s %d: ", version, type_s, len);
+ if (ttl != 255)
+ printf("[ttl=%d!] ", ttl);
+ if (version != 2 || type != 1)
+ return;
+ TCHECK(bp[2]);
+ printf("vrid=%d prio=%d", bp[1], bp[2]);
+ TCHECK(bp[5]);
+ auth_type = bp[4];
+ if (auth_type != 0)
+ printf(" authtype=%d", auth_type);
+ printf(" intvl=%d", bp[5]);
+ if (vflag) {
+ int naddrs = bp[3];
+ int i;
+ char c;
+
+ if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0))
+ printf(" (bad vrrp cksum %x!)",
+ EXTRACT_16BITS(&bp[6]));
+ printf(" addrs");
+ if (naddrs > 1)
+ printf("(%d)", naddrs);
+ printf(":");
+ c = ' ';
+ bp += 8;
+ for (i = 0; i < naddrs; i++) {
+ TCHECK(bp[3]);
+ printf("%c%s", c, ipaddr_string(bp));
+ c = ',';
+ bp += 4;
+ }
+ if (auth_type == 1) { /* simple text password */
+ TCHECK(bp[7]);
+ printf(" auth %.8s", bp);
+ }
+ }
+ return;
+trunc:
+ printf("[|vrrp]");
+}
diff --git a/contrib/tcpdump/route6d.h b/contrib/tcpdump/route6d.h
index f9cc3dd..dba49fb 100644
--- a/contrib/tcpdump/route6d.h
+++ b/contrib/tcpdump/route6d.h
@@ -1,5 +1,5 @@
/*
- * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.1 1999/10/30 05:11:22 itojun Exp $
+ * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.2 2000/04/28 11:14:49 itojun Exp $
*/
#define RIP6_VERSION 1
@@ -8,16 +8,16 @@
#define RIP6_RESPONSE 2
struct netinfo6 {
- struct in6_addr rip6_dest;
- u_short rip6_tag;
- u_char rip6_plen;
- u_char rip6_metric;
+ struct in6_addr rip6_dest;
+ u_int16_t rip6_tag;
+ u_int8_t rip6_plen;
+ u_int8_t rip6_metric;
};
struct rip6 {
- u_char rip6_cmd;
- u_char rip6_vers;
- u_char rip6_res1[2];
+ u_int8_t rip6_cmd;
+ u_int8_t rip6_vers;
+ u_int8_t rip6_res1[2];
union {
struct netinfo6 ru6_nets[1];
char ru6_tracefile[1];
diff --git a/contrib/tcpdump/rx.h b/contrib/tcpdump/rx.h
index 5435beb..fe6f963 100644
--- a/contrib/tcpdump/rx.h
+++ b/contrib/tcpdump/rx.h
@@ -1,7 +1,7 @@
/*
* Rx protocol format
*
- * $Id: rx.h,v 1.1 1999/11/17 05:45:58 assar Exp $
+ * $Id: rx.h,v 1.3 2000/10/03 02:55:02 itojun Exp $
*/
#define FS_RX_PORT 7000
@@ -40,7 +40,7 @@ struct rx_header {
u_int32_t callNumber;
u_int32_t seq;
u_int32_t serial;
- u_char type;
+ u_int8_t type;
#define RX_PACKET_TYPE_DATA 1
#define RX_PACKET_TYPE_ACK 2
#define RX_PACKET_TYPE_BUSY 3
@@ -51,18 +51,39 @@ struct rx_header {
#define RX_PACKET_TYPE_DEBUG 8
#define RX_PACKET_TYPE_PARAMS 9
#define RX_PACKET_TYPE_VERSION 13
- u_char flags;
+ u_int8_t flags;
#define RX_CLIENT_INITIATED 1
#define RX_REQUEST_ACK 2
#define RX_LAST_PACKET 4
#define RX_MORE_PACKETS 8
#define RX_FREE_PACKET 16
- u_char userStatus;
- u_char securityIndex;
- u_short spare; /* How clever: even though the AFS */
- u_short serviceId; /* header files indicate that the */
+ u_int8_t userStatus;
+ u_int8_t securityIndex;
+ u_int16_t spare; /* How clever: even though the AFS */
+ u_int16_t serviceId; /* header files indicate that the */
}; /* serviceId is first, it's really */
/* encoded _after_ the spare field */
/* I wasted a day figuring that out! */
#define NUM_RX_FLAGS 5
+
+#define RX_MAXACKS 255
+
+struct rx_ackPacket {
+ u_int16_t bufferSpace; /* Number of packet buffers available */
+ u_int16_t maxSkew; /* Max diff between ack'd packet and */
+ /* highest packet received */
+ u_int32_t firstPacket; /* The first packet in ack list */
+ u_int32_t previousPacket; /* Previous packet recv'd (obsolete) */
+ u_int32_t serial; /* # of packet that prompted the ack */
+ u_int8_t reason; /* Reason for acknowledgement */
+ u_int8_t nAcks; /* Number of acknowledgements */
+ u_int8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
+};
+
+/*
+ * Values for the acks array
+ */
+
+#define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
+#define RX_ACK_TYPE_ACK 1 /* I have this packet */
diff --git a/contrib/tcpdump/savestr.c b/contrib/tcpdump/savestr.c
index a148802..a81227c 100644
--- a/contrib/tcpdump/savestr.c
+++ b/contrib/tcpdump/savestr.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/savestr.c,v 1.4 1999/11/21 09:37:04 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/Attic/savestr.c,v 1.6 2000/07/11 00:49:02 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,14 +30,10 @@ static const char rcsid[] =
#include <sys/types.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
diff --git a/contrib/tcpdump/savestr.h b/contrib/tcpdump/savestr.h
index 26f9c21..8fe995e 100644
--- a/contrib/tcpdump/savestr.h
+++ b/contrib/tcpdump/savestr.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/savestr.h,v 1.1.1.1 1999/10/07 23:47:12 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/Attic/savestr.h,v 1.1.1.1 1999/10/07 23:47:12 mcr Exp $ (LBL)
*/
extern char *savestr(const char *);
diff --git a/contrib/tcpdump/setsignal.c b/contrib/tcpdump/setsignal.c
index 756d1fe..eff2727 100644
--- a/contrib/tcpdump/setsignal.c
+++ b/contrib/tcpdump/setsignal.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.5 1999/11/21 09:37:04 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.7 2000/07/11 00:49:03 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,15 +30,11 @@ static const char rcsid[] =
#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
diff --git a/contrib/tcpdump/slcompress.h b/contrib/tcpdump/slcompress.h
new file mode 100644
index 0000000..d8a596c
--- /dev/null
+++ b/contrib/tcpdump/slcompress.h
@@ -0,0 +1,87 @@
+/*
+ * Definitions for tcp compression routines.
+ *
+ * @(#) $Header: /tcpdump/master/tcpdump/slcompress.h,v 1.2 2000/10/09 02:03:44 guy Exp $ (LBL)
+ *
+ * Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of
+ * California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Van Jacobson (van@ee.lbl.gov), Dec 31, 1989:
+ * - Initial distribution.
+ */
+
+/*
+ * Compressed packet format:
+ *
+ * The first octet contains the packet type (top 3 bits), TCP
+ * 'push' bit, and flags that indicate which of the 4 TCP sequence
+ * numbers have changed (bottom 5 bits). The next octet is a
+ * conversation number that associates a saved IP/TCP header with
+ * the compressed packet. The next two octets are the TCP checksum
+ * from the original datagram. The next 0 to 15 octets are
+ * sequence number changes, one change per bit set in the header
+ * (there may be no changes and there are two special cases where
+ * the receiver implicitly knows what changed -- see below).
+ *
+ * There are 5 numbers which can change (they are always inserted
+ * in the following order): TCP urgent pointer, window,
+ * acknowlegement, sequence number and IP ID. (The urgent pointer
+ * is different from the others in that its value is sent, not the
+ * change in value.) Since typical use of SLIP links is biased
+ * toward small packets (see comments on MTU/MSS below), changes
+ * use a variable length coding with one octet for numbers in the
+ * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
+ * range 256 - 65535 or 0. (If the change in sequence number or
+ * ack is more than 65535, an uncompressed packet is sent.)
+ */
+
+/*
+ * Packet types (must not conflict with IP protocol version)
+ *
+ * The top nibble of the first octet is the packet type. There are
+ * three possible types: IP (not proto TCP or tcp with one of the
+ * control flags set); uncompressed TCP (a normal IP/TCP packet but
+ * with the 8-bit protocol field replaced by an 8-bit connection id --
+ * this type of packet syncs the sender & receiver); and compressed
+ * TCP (described above).
+ *
+ * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
+ * is logically part of the 4-bit "changes" field that follows. Top
+ * three bits are actual packet type. For backward compatibility
+ * and in the interest of conserving bits, numbers are chosen so the
+ * IP protocol version number (4) which normally appears in this nibble
+ * means "IP packet".
+ */
+
+/* packet types */
+#define TYPE_IP 0x40
+#define TYPE_UNCOMPRESSED_TCP 0x70
+#define TYPE_COMPRESSED_TCP 0x80
+#define TYPE_ERROR 0x00
+
+/* Bits in first octet of compressed packet */
+#define NEW_C 0x40 /* flag bits for what changed in a packet */
+#define NEW_I 0x20
+#define NEW_S 0x08
+#define NEW_A 0x04
+#define NEW_W 0x02
+#define NEW_U 0x01
+
+/* reserved, special-case values of above */
+#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
+#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
+#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
+
+#define TCP_PUSH_BIT 0x10
diff --git a/contrib/tcpdump/slip.h b/contrib/tcpdump/slip.h
new file mode 100644
index 0000000..e64f301
--- /dev/null
+++ b/contrib/tcpdump/slip.h
@@ -0,0 +1,34 @@
+/*
+ * Definitions that user level programs might need to know to interact
+ * with serial line IP (slip) lines.
+ *
+ * @(#) $Header: /tcpdump/master/tcpdump/slip.h,v 1.1 2000/10/09 01:53:21 guy Exp $
+ *
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ * definitions of the pseudo- link-level header attached to slip
+ * packets grabbed by the packet filter (bpf) traffic monitor.
+ */
+#define SLIP_HDRLEN 16
+
+#define SLX_DIR 0
+#define SLX_CHDR 1
+#define CHDR_LEN 15
+
+#define SLIPDIR_IN 0
+#define SLIPDIR_OUT 1
diff --git a/contrib/tcpdump/sll.h b/contrib/tcpdump/sll.h
new file mode 100644
index 0000000..821a845
--- /dev/null
+++ b/contrib/tcpdump/sll.h
@@ -0,0 +1,127 @@
+/*-
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.4 2000/12/23 07:52:11 guy Exp $ (LBL)
+ */
+
+/*
+ * For captures on Linux cooked sockets, we construct a fake header
+ * that includes:
+ *
+ * a 2-byte "packet type" which is one of:
+ *
+ * LINUX_SLL_HOST packet was sent to us
+ * LINUX_SLL_BROADCAST packet was broadcast
+ * LINUX_SLL_MULTICAST packet was multicast
+ * LINUX_SLL_OTHERHOST packet was sent to somebody else
+ * LINUX_SLL_OUTGOING packet was sent *by* us;
+ *
+ * a 2-byte Ethernet protocol field;
+ *
+ * a 2-byte link-layer type;
+ *
+ * a 2-byte link-layer address length;
+ *
+ * an 8-byte source link-layer address, whose actual length is
+ * specified by the previous value.
+ *
+ * All fields except for the link-layer address are in network byte order.
+ *
+ * DO NOT change the layout of this structure, or change any of the
+ * LINUX_SLL_ values below. If you must change the link-layer header
+ * for a "cooked" Linux capture, introduce a new DLT_ type (ask
+ * "tcpdump-workers@tcpdump.org" for one, so that you don't give it a
+ * value that collides with a value already being used), and use the
+ * new header in captures of that type, so that programs that can
+ * handle DLT_LINUX_SLL captures will continue to handle them correctly
+ * without any change, and so that capture files with different headers
+ * can be told apart and programs that read them can dissect the
+ * packets in them.
+ *
+ * This structure, and the #defines below, must be the same in the
+ * libpcap and tcpdump versions of "sll.h".
+ */
+
+/*
+ * A DLT_LINUX_SLL fake link-layer header.
+ */
+#define SLL_HDR_LEN 16 /* total header length */
+#define SLL_ADDRLEN 8 /* length of address field */
+
+struct sll_header {
+ u_int16_t sll_pkttype; /* packet type */
+ u_int16_t sll_hatype; /* link-layer address type */
+ u_int16_t sll_halen; /* link-layer address length */
+ u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
+ u_int16_t sll_protocol; /* protocol */
+};
+
+/*
+ * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
+ * PACKET_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux, and so that they
+ * don't change even if the PACKET_ values change.
+ */
+#define LINUX_SLL_HOST 0
+#define LINUX_SLL_BROADCAST 1
+#define LINUX_SLL_MULTICAST 2
+#define LINUX_SLL_OTHERHOST 3
+#define LINUX_SLL_OUTGOING 4
+
+/*
+ * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
+ * ETH_P_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux. We assume, for now,
+ * that the ETH_P_ values won't change in Linux; if they do, then:
+ *
+ * if we don't translate them in "pcap-linux.c", capture files
+ * won't necessarily be readable if captured on a system that
+ * defines ETH_P_ values that don't match these values;
+ *
+ * if we do translate them in "pcap-linux.c", that makes life
+ * unpleasant for the BPF code generator, as the values you test
+ * for in the kernel aren't the values that you test for when
+ * reading a capture file, so the fixup code run on BPF programs
+ * handed to the kernel ends up having to do more work.
+ *
+ * Add other values here as necessary, for handling packet types that
+ * might show up on non-Ethernet, non-802.x networks. (Not all the ones
+ * in the Linux "if_ether.h" will, I suspect, actually show up in
+ * captures.)
+ */
+#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
+#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
diff --git a/contrib/tcpdump/smb.h b/contrib/tcpdump/smb.h
index 0c5461a..63be64b 100644
--- a/contrib/tcpdump/smb.h
+++ b/contrib/tcpdump/smb.h
@@ -1,3 +1,4 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */
/*
Copyright (C) Andrew Tridgell 1995-1999
diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c
index 2ddd3f6..898345d 100644
--- a/contrib/tcpdump/smbutil.c
+++ b/contrib/tcpdump/smbutil.c
@@ -11,7 +11,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.4.2.1 2000/01/11 06:58:28 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.12 2000/12/04 00:35:45 guy Exp $";
#endif
#include <sys/param.h>
@@ -19,20 +19,19 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include "interface.h"
#include "smb.h"
-extern uchar *startbuf;
+extern const uchar *startbuf;
/*******************************************************************
interpret a 32 bit dos packed date/time to some parameters
@@ -115,12 +114,18 @@ static time_t interpret_long_date(const char *p)
/****************************************************************************
-interpret the weird netbios "name". Return the name type
+interpret the weird netbios "name". Return the name type, or -1 if
+we run past the end of the buffer
****************************************************************************/
-static int name_interpret(char *in,char *out)
+static int name_interpret(const uchar *in,const uchar *maxbuf,char *out)
{
int ret;
- int len = (*in++) / 2;
+ int len;
+
+ if (in >= maxbuf)
+ return(-1); /* name goes past the end of the buffer */
+ TCHECK2(*in, 1);
+ len = (*in++) / 2;
*out=0;
@@ -128,6 +133,9 @@ static int name_interpret(char *in,char *out)
while (len--)
{
+ if (in + 1 >= maxbuf)
+ return(-1); /* name goes past the end of the buffer */
+ TCHECK2(*in, 2);
if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
*out = 0;
return(0);
@@ -140,46 +148,86 @@ static int name_interpret(char *in,char *out)
ret = out[-1];
return(ret);
+
+trunc:
+ return(-1);
}
/****************************************************************************
find a pointer to a netbios name
****************************************************************************/
-static char *name_ptr(char *buf,int ofs)
+static const uchar *name_ptr(const uchar *buf,int ofs,const uchar *maxbuf)
{
- unsigned char c = *(unsigned char *)(buf+ofs);
+ const uchar *p;
+ uchar c;
+
+ p = buf+ofs;
+ if (p >= maxbuf)
+ return(NULL); /* name goes past the end of the buffer */
+ TCHECK2(*p, 1);
+ c = *p;
+
+ /* XXX - this should use the same code that the DNS dissector does */
if ((c & 0xC0) == 0xC0)
{
uint16 l = RSVAL(buf, ofs) & 0x3FFF;
+ if (l == 0)
+ {
+ /* We have a pointer that points to itself. */
+ return(NULL);
+ }
+ p = buf + l;
+ if (p >= maxbuf)
+ return(NULL); /* name goes past the end of the buffer */
+ TCHECK2(*p, 1);
return(buf + l);
}
else
return(buf+ofs);
+
+trunc:
+ return(NULL); /* name goes past the end of the buffer */
}
/****************************************************************************
extract a netbios name from a buf
****************************************************************************/
-static int name_extract(char *buf,int ofs,char *name)
+static int name_extract(const uchar *buf,int ofs,const uchar *maxbuf,char *name)
{
- char *p = name_ptr(buf,ofs);
+ const uchar *p = name_ptr(buf,ofs,maxbuf);
+ if (p == NULL)
+ return(-1); /* error (probably name going past end of buffer) */
strcpy(name,"");
- return(name_interpret(p,name));
+ return(name_interpret(p,maxbuf,name));
}
/****************************************************************************
return the total storage length of a mangled name
****************************************************************************/
-static int name_len(const unsigned char *s)
+static int name_len(const unsigned char *s, const unsigned char *maxbuf)
{
- const char *s0 = s;
- unsigned char c = *(unsigned char *)s;
+ const unsigned char *s0 = s;
+ unsigned char c;
+
+ if (s >= maxbuf)
+ return(-1); /* name goes past the end of the buffer */
+ TCHECK2(*s, 1);
+ c = *s;
if ((c & 0xC0) == 0xC0)
- return(2);
- while (*s) s += (*s)+1;
+ return(2);
+ while (*s)
+ {
+ if (s >= maxbuf)
+ return(-1); /* name goes past the end of the buffer */
+ TCHECK2(*s, 1);
+ s += (*s)+1;
+ }
return(PTR_DIFF(s,s0)+1);
+
+trunc:
+ return(-1); /* name goes past the end of the buffer */
}
static void print_asc(const unsigned char *buf,int len)
@@ -429,10 +477,17 @@ static const uchar *fdata1(const uchar *buf, const char *fmt, const uchar *maxbu
int t = atoi(fmt+1);
char nbuf[255];
int name_type;
+ int len;
switch (t) {
case 1:
- name_type = name_extract(startbuf,PTR_DIFF(buf,startbuf),nbuf);
- buf += name_len(buf);
+ name_type = name_extract(startbuf,PTR_DIFF(buf,startbuf),maxbuf,
+ nbuf);
+ if (name_type < 0)
+ goto trunc;
+ len = name_len(buf,maxbuf);
+ if (len < 0)
+ goto trunc;
+ buf += len;
printf("%-15.15s NameType=0x%02X (%s)",
nbuf,name_type,name_type_str(name_type));
break;
@@ -485,6 +540,11 @@ static const uchar *fdata1(const uchar *buf, const char *fmt, const uchar *maxbu
printf("END OF BUFFER\n");
return(buf);
+
+trunc:
+ printf("\n");
+ printf("WARNING: Short packet. Try increasing the snap length\n");
+ return(NULL);
}
const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
@@ -525,11 +585,13 @@ const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
case '[':
fmt++;
if (buf>=maxbuf) return(buf);
- bzero(s,sizeof(s));
+ memset(s, 0, sizeof(s));
p = strchr(fmt,']');
strncpy(s,fmt,p-fmt);
fmt = p+1;
buf = fdata1(buf,s,maxbuf);
+ if (buf == NULL)
+ return(NULL);
break;
default:
@@ -680,19 +742,16 @@ char *smb_errstr(int class,int num)
for (j=0;err[j].name;j++)
if (num == err[j].code)
{
- sprintf(ret,"%s - %s (%s)",err_classes[i].class,
+ snprintf(ret,sizeof(ret),"%s - %s (%s)",err_classes[i].class,
err[j].name,err[j].message);
return ret;
}
}
- sprintf(ret,"%s - %d",err_classes[i].class,num);
+ snprintf(ret,sizeof(ret),"%s - %d",err_classes[i].class,num);
return ret;
}
- sprintf(ret,"ERROR: Unknown error (%d,%d)",class,num);
+ snprintf(ret,sizeof(ret),"ERROR: Unknown error (%d,%d)",class,num);
return(ret);
}
-
-
-
diff --git a/contrib/tcpdump/strcasecmp.c b/contrib/tcpdump/strcasecmp.c
index 78d5ae7..acba36a 100644
--- a/contrib/tcpdump/strcasecmp.c
+++ b/contrib/tcpdump/strcasecmp.c
@@ -14,6 +14,11 @@
#include "config.h"
#endif
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/strcasecmp.c,v 1.3 2000/01/09 21:34:21 fenner Exp $";
+#endif
+
#include <sys/types.h>
#include "interface.h"
diff --git a/contrib/tcpdump/tcp.h b/contrib/tcpdump/tcp.h
new file mode 100644
index 0000000..a93c14f
--- /dev/null
+++ b/contrib/tcpdump/tcp.h
@@ -0,0 +1,75 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.7 2000/10/03 09:17:41 guy Exp $ (LBL) */
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tcp.h 8.1 (Berkeley) 6/10/93
+ */
+
+typedef u_int32_t tcp_seq;
+/*
+ * TCP header.
+ * Per RFC 793, September, 1981.
+ */
+struct tcphdr {
+ u_int16_t th_sport; /* source port */
+ u_int16_t th_dport; /* destination port */
+ tcp_seq th_seq; /* sequence number */
+ tcp_seq th_ack; /* acknowledgement number */
+ u_int8_t th_offx2; /* data offset, rsvd */
+#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4)
+ u_int8_t th_flags;
+#define TH_FIN 0x01
+#define TH_SYN 0x02
+#define TH_RST 0x04
+#define TH_PUSH 0x08
+#define TH_ACK 0x10
+#define TH_URG 0x20
+ u_int16_t th_win; /* window */
+ u_int16_t th_sum; /* checksum */
+ u_int16_t th_urp; /* urgent pointer */
+};
+
+#define TCPOPT_EOL 0
+#define TCPOPT_NOP 1
+#define TCPOPT_MAXSEG 2
+#define TCPOLEN_MAXSEG 4
+#define TCPOPT_WINDOW 3
+#define TCPOLEN_WINDOW 3
+#define TCPOPT_SACK_PERMITTED 4 /* Experimental */
+#define TCPOLEN_SACK_PERMITTED 2
+#define TCPOPT_SACK 5 /* Experimental */
+#define TCPOPT_TIMESTAMP 8
+#define TCPOLEN_TIMESTAMP 10
+#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
+
+#define TCPOPT_TSTAMP_HDR \
+ (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
diff --git a/contrib/tcpdump/tcpdump.1 b/contrib/tcpdump/tcpdump.1
index 5e949d4..e639407 100644
--- a/contrib/tcpdump/tcpdump.1
+++ b/contrib/tcpdump/tcpdump.1
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.72.2.2 2000/01/29 16:42:03 itojun Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.92.2.2 2001/01/18 04:38:31 guy Exp $ (LBL)
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
@@ -20,7 +20,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "30 June 1997"
+.TH TCPDUMP 1 "3 January 2001"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
@@ -66,6 +66,10 @@ tcpdump \- dump traffic on a network
.br
.ti +8
[
+.B \-E
+.I algo:secret
+]
+[
.I expression
]
.br
@@ -83,7 +87,7 @@ you must have read access to
or
.IR /dev/bpf* .
.B Under Solaris with dlpi:
-You must have read access to the network pseudo device, e.g.
+You must have read/write access to the network pseudo device, e.g.
.IR /dev/le .
.B Under HP-UX with dlpi:
You must be root or it must be installed setuid to root.
@@ -122,6 +126,27 @@ Dump packet-matching code as decimal numbers (preceded with a count).
.B \-e
Print the link-level header on each dump line.
.TP
+.B \-E
+Use \fIalgo:secret\fP for decrypting IPsec ESP packets. Algorithms may be
+\fBdes-cbc\fP,
+\fB3des-cbc\fP,
+\fBblowfish-cbc\fP,
+\fBrc3-cbc\fP,
+\fBcast128-cbc\fP, or
+\fBnone\fP.
+The default is \fBdes-cbc\fP.
+The ability to decrypt packets is only present if \fItcpdump\fP was compiled
+with cryptography enabled.
+\fIsecret\fP the ascii text for ESP secret key.
+We cannot take arbitrary binary value at this moment.
+The option assumes RFC2406 ESP, not RFC1827 ESP.
+The option is only for debugging purposes, and
+the use of this option with truly `secret' key is discouraged.
+By presenting IPsec secret key onto command line
+you make it visible to others, via
+.IR ps (1)
+and other occasions.
+.TP
.B \-f
Print `foreign' internet addresses numerically rather than symbolically
(this option is intended to get around serious brain damage in
@@ -137,6 +162,12 @@ Listen on \fIinterface\fP.
If unspecified, \fItcpdump\fP searches the system interface list for the
lowest numbered, configured up interface (excluding loopback).
Ties are broken by choosing the earliest match.
+.IP
+On Linux systems with 2.2 or later kernels, an
+.I interface
+argument of ``any'' can be used to capture packets from all interfaces.
+Note that captures on the ``any'' device will not be done in promiscuous
+mode.
.TP
.B \-l
Make stdout line buffered. Useful if you want to see the data
@@ -155,7 +186,7 @@ instead of ``nic.ddn.mil''.
.TP
.B \-m
Load SMI MIB module definitions from file \fImodule\fR. This option
-can be used several times to load several MIB modules into tcpdump.
+can be used several times to load several MIB modules into \fItcpdump\fP.
.TP
.B \-O
Do not run the packet-matching code optimizer. This is useful only
@@ -187,11 +218,13 @@ Note that taking larger snapshots both increases
the amount of time it takes to process packets and, effectively,
decreases the amount of packet buffering. This may cause packets to be
lost. You should limit \fIsnaplen\fP to the smallest number that will
-capture the protocol information you're interested in.
+capture the protocol information you're interested in. Setting
+\fIsnaplen\fP to 0 means use the required length to catch whole packets.
.TP
.B \-T
Force packets selected by "\fIexpression\fP" to be interpreted the
specified \fItype\fR. Currently known types are
+\fBcnfp\fR (Cisco NetFlow protocol),
\fBrpc\fR (Remote Procedure Call),
\fBrtp\fR (Real-Time Applications protocol),
\fBrtcp\fR (Real-Time Applications control protocol),
@@ -216,8 +249,10 @@ Print absolute, rather than relative, TCP sequence numbers.
Print an unformatted timestamp on each dump line.
.TP
.B \-v
-(Slightly more) verbose output. For example, the time to live
-and type of service information in an IP packet is printed.
+(Slightly more) verbose output. For example, the time to live,
+identification, total length and options in an IP packet are printed.
+Also enables additional packet integrity checks such as verifying the
+IP and ICMP header checksum.
.TP
.B \-vv
Even more verbose output. For example, additional fields are
@@ -275,7 +310,7 @@ qualifier,
is assumed.
.IP \fIdir\fP
qualifiers specify a particular transfer direction to and/or from
-.I id.
+.IR id .
Possible directions are
.BR src ,
.BR dst ,
@@ -297,17 +332,12 @@ qualifiers restrict the match to a particular protocol. Possible
protos are:
.BR ether ,
.BR fddi ,
+.BR tr ,
.BR ip ,
.BR ip6 ,
.BR arp ,
.BR rarp ,
.BR decnet ,
-.BR lat ,
-.BR sca ,
-.BR moprc ,
-.BR mopdl ,
-.BR icmp ,
-.BR icmp6 ,
.B tcp
and
.BR udp .
@@ -323,7 +353,10 @@ network interface.'' FDDI headers contain Ethernet-like source
and destination addresses, and often contain Ethernet-like packet
types, so you can filter on these FDDI fields just as with the
analogous Ethernet fields. FDDI headers also contain other fields,
-but you cannot name them explicitly in a filter expression.]
+but you cannot name them explicitly in a filter expression.
+.LP
+Similarly, `tr' is an alias for `ether'; the previous paragraph's
+statements about FDDI headers also apply to Token Ring headers.]
.LP
In addition to the above, there are some special `primitive' keywords
that don't follow the pattern:
@@ -446,11 +479,12 @@ This is equivalent to:
.fi
.in -.5i
.IP "\fBip proto \fIprotocol\fR"
-True if the packet is an ip packet (see
+True if the packet is an IP packet (see
.IR ip (4P))
of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
-\fIicmp\fP, \fIigrp\fP, \fIudp\fP, \fInd\fP, or \fItcp\fP.
+\fIicmp\fP, \fIicmp6\fP, \fIigmp\fP, \fIigrp\fP, \fIpim\fP, \fIah\fP,
+\fIesp\fP, \fIudp\fP, or \fItcp\fP.
Note that the identifiers \fItcp\fP, \fIudp\fP, and \fIicmp\fP are also
keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
Note that this primitive does not chase protocol header chain.
@@ -493,8 +527,10 @@ True if the packet is an IP multicast packet.
True if the packet is an IPv6 multicast packet.
.IP "\fBether proto \fIprotocol\fR"
True if the packet is of ether type \fIprotocol\fR.
-\fIProtocol\fP can be a number or a name like
-\fIip\fP, \fIip6\fP, \fIarp\fP, or \fIrarp\fP.
+\fIProtocol\fP can be a number or one of the names
+\fIip\fP, \fIip6\fP, \fIarp\fP, \fIrarp\fP, \fIatalk\fP, \fIaarp\fP,
+\fIdecnet\fP, \fIsca\fP, \fIlat\fP, \fImopdl\fP, \fImoprc\fP, or
+\fIiso\fP.
Note these identifiers are also keywords
and must be escaped via backslash (\\).
[In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), the
@@ -502,7 +538,7 @@ protocol identification comes from the 802.2 Logical Link Control
(LLC) header, which is usually layered on top of the FDDI header.
\fITcpdump\fP assumes, when filtering on the protocol identifier,
that all FDDI packets include an LLC header, and that the LLC header
-is in so-called SNAP format.]
+is in so-called SNAP format. The same applies to Token Ring.]
.IP "\fBdecnet src \fIhost\fR"
True if the DECNET source address is
.IR host ,
@@ -515,7 +551,7 @@ True if the DECNET destination address is
.IP "\fBdecnet host \fIhost\fR"
True if either the DECNET source or destination address is
.IR host .
-.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBdecnet\fR"
+.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR"
Abbreviations for:
.in +.5i
.nf
@@ -533,6 +569,13 @@ Abbreviations for:
where \fIp\fR is one of the above protocols.
Note that
\fItcpdump\fP does not currently know how to parse these protocols.
+.IP "\fBvlan \fI[vlan_id]\fR"
+True if the packet is an IEEE 802.1Q VLAN packet.
+If \fI[vlan_id]\fR is specified, only true is the packet has the specified
+\fIvlan_id\fR.
+Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
+changes the decoding offsets for the remainder of \fIexpression\fR
+on the assumption that the packet is a VLAN packet.
.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
Abbreviations for:
.in +.5i
@@ -541,6 +584,19 @@ Abbreviations for:
.fi
.in -.5i
where \fIp\fR is one of the above protocols.
+.IP "\fBiso proto \fIprotocol\fR"
+True if the packet is an OSI packet of protocol type \fIprotocol\fP.
+\fIProtocol\fP can be a number or one of the names
+\fIclnp\fP, \fIesis\fP, or \fIisis\fP.
+.IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
+Abbreviations for:
+.in +.5i
+.nf
+\fBiso proto \fIp\fR
+.fi
+.in -.5i
+where \fIp\fR is one of the above protocols.
+Note that \fItcpdump\fR does an incomplete job of parsing these protocols.
.IP "\fIexpr relop expr\fR"
True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=,
and \fIexpr\fR is an arithmetic expression composed of integer constants
@@ -553,7 +609,7 @@ data inside the packet, use the following syntax:
\fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
.fi
.in -.5i
-\fIProto\fR is one of \fBether, fddi,
+\fIProto\fR is one of \fBether, fddi, tr,
ip, arp, rarp, tcp, udp, icmp\fR or \fBip6\fR, and
indicates the protocol layer for the index operation.
Note that \fItcp, udp\fR and other upper-layer protocol types only
@@ -613,8 +669,8 @@ which should not be confused with
.fi
.in -.5i
.LP
-Expression arguments can be passed to tcpdump as either a single argument
-or as multiple arguments, whichever is more convenient.
+Expression arguments can be passed to \fItcpdump\fP as either a single
+argument or as multiple arguments, whichever is more convenient.
Generally, if the expression contains Shell metacharacters, it is
easier to pass it as a single, quoted argument.
Multiple arguments are concatenated with spaces before being parsed.
@@ -701,7 +757,7 @@ ping packets):
.RS
.nf
.B
-tcpdump 'icmp[0] != 8 and icmp[0] != 0"
+tcpdump 'icmp[0] != 8 and icmp[0] != 0'
.fi
.RE
.SH OUTPUT FORMAT
@@ -729,6 +785,13 @@ are assumed to contain an 802.2 Logical Link Control (LLC) packet;
the LLC header is printed if it is \fInot\fR an ISO datagram or a
so-called SNAP packet.
.LP
+On Token Ring networks, the '-e' option causes \fItcpdump\fP to print
+the `access control' and `frame control' fields, the source and
+destination addresses, and the packet length. As on FDDI networks,
+packets are assumed to contain an LLC packet. Regardless of whether
+the '-e' option is specified or not, the source routing information is
+printed for source-routed packets.
+.LP
\fI(N.B.: The following description assumes familiarity with
the SLIP compression algorithm described in RFC-1144.)\fP
.LP
@@ -770,7 +833,7 @@ host \fIrtsg\fP to host \fIcsam\fP:
.nf
.sp .5
\f(CWarp who-has csam tell rtsg
-arp reply csam is-at CSAM\fP
+arp reply csam is-at CSAM\fR
.sp .5
.fi
.RE
@@ -794,7 +857,7 @@ broadcast and the second is point-to-point would be visible:
.nf
.sp .5
\f(CWRTSG Broadcast 0806 64: arp who-has csam tell rtsg
-CSAM RTSG 0806 64: arp reply csam is-at CSAM\fP
+CSAM RTSG 0806 64: arp reply csam is-at CSAM\fR
.sp .5
.fi
.RE
@@ -806,7 +869,7 @@ TCP Packets
.LP
\fI(N.B.:The following description assumes familiarity with
the TCP protocol described in RFC-793. If you are not familiar
-with the protocol, neither this description nor tcpdump will
+with the protocol, neither this description nor \fItcpdump\fP will
be of much use to you.)\fP
.LP
The general format of a tcp protocol line is:
@@ -846,7 +909,7 @@ csam.login > rtsg.1023: . ack 2 win 4096
rtsg.1023 > csam.login: P 2:21(19) ack 1 win 4096
csam.login > rtsg.1023: P 1:2(1) ack 21 win 4077
csam.login > rtsg.1023: P 2:3(1) ack 21 win 4077 urg 1
-csam.login > rtsg.1023: P 3:4(1) ack 21 win 4077 urg 1\fP\s+2
+csam.login > rtsg.1023: P 3:4(1) ack 21 win 4077 urg 1\fR\s+2
.sp .5
.fi
.RE
@@ -866,7 +929,7 @@ ack for rtsg's SYN. Rtsg then acks csam's SYN. The `.' means no
flags were set.
The packet contained no data so there is no data sequence number.
Note that the ack sequence
-number is a small integer (1). The first time \fBtcpdump\fP sees a
+number is a small integer (1). The first time \fItcpdump\fP sees a
tcp `conversation', it prints the sequence number from the packet.
On subsequent packets of the conversation, the difference between
the current packet's sequence number and this initial sequence number
@@ -886,15 +949,201 @@ Csam also sends one byte of data to rtsg in this packet.
On the 8th and 9th lines,
csam sends two bytes of urgent, pushed data to rtsg.
.LP
-If the snapshot was small enough that \fBtcpdump\fP didn't capture
+If the snapshot was small enough that \fItcpdump\fP didn't capture
the full TCP header, it interprets as much of the header as it can
and then reports ``[|\fItcp\fP]'' to indicate the remainder could not
be interpreted. If the header contains a bogus option (one with a length
-that's either too small or beyond the end of the header), tcpdump reports
-it as ``[\fIbad opt\fP]'' and does not interpret any further options (since
-it's impossible to tell where they start). If the header length indicates
-options are present but the IP datagram length is not long enough for the
-options to actually be there, tcpdump reports it as ``[\fIbad hdr length\fP]''.
+that's either too small or beyond the end of the header), \fItcpdump\fP
+reports it as ``[\fIbad opt\fP]'' and does not interpret any further
+options (since it's impossible to tell where they start). If the header
+length indicates options are present but the IP datagram length is not
+long enough for the options to actually be there, \fItcpdump\fP reports
+it as ``[\fIbad hdr length\fP]''.
+.HD
+.B Capturing TCP packets with particular flag combinations (SYN-ACK, URG-ACK, etc.)
+.PP
+There are 6 bits in the control bits section of the TCP header:
+.IP
+.I URG | ACK | PSH | RST | SYN | FIN
+.PP
+Let's assume that we want to watch packets used in establishing
+a TCP connection. Recall that TCP uses a 3-way handshake protocol
+when it initializes a new connection; the connection sequence with
+regard to the TCP control bits is
+.PP
+.RS
+1) Caller sends SYN
+.RE
+.RS
+2) Recipient responds with SYN, ACK
+.RE
+.RS
+3) Caller sends ACK
+.RE
+.PP
+Now we're interested in capturing packets that have only the
+SYN bit set (Step 1). Note that we don't want packets from step 2
+(SYN-ACK), just a plain initial SYN. What we need is a correct filter
+expression for \fItcpdump\fP.
+.PP
+Recall the structure of a TCP header without options:
+.PP
+.nf
+ 0 15 31
+-----------------------------------------------------------------
+| source port | destination port |
+-----------------------------------------------------------------
+| sequence number |
+-----------------------------------------------------------------
+| acknowledgment number |
+-----------------------------------------------------------------
+| HL | reserved |U|A|P|R|S|F| window size |
+-----------------------------------------------------------------
+| TCP checksum | urgent pointer |
+-----------------------------------------------------------------
+.fi
+.PP
+A TCP header usually holds 20 octets of data, unless options are
+present. The fist line of the graph contains octets 0 - 3, the
+second line shows octets 4 - 7 etc.
+.PP
+Starting to count with 0, the relevant TCP control bits are contained
+in octet 13:
+.PP
+.nf
+ 0 7| 15| 23| 31
+----------------|---------------|---------------|----------------
+| HL | reserved |U|A|P|R|S|F| window size |
+----------------|---------------|---------------|----------------
+| | 13th octet | | |
+.fi
+.PP
+Let's have a closer look at octet no. 13:
+.PP
+.nf
+ | |
+ |---------------|
+ | |U|A|P|R|S|F|
+ |---------------|
+ |7 5 3 0|
+.fi
+.PP
+We see that this octet contains 2 bytes from the reserved field.
+According to RFC 793 this field is reserved for future use and must
+be 0. The remaining 6 bits are the TCP control bits we are interested
+in. We have numbered the bits in this octet from 0 to 7, right to
+left, so the PSH bit is bit number 3, while the URG bit is number 5.
+.PP
+Recall that we want to capture packets with only SYN set.
+Let's see what happens to octet 13 if a TCP datagram arrives
+with the SYN bit set in its header:
+.PP
+.nf
+ | |U|A|P|R|S|F|
+ |---------------|
+ |0 0 0 0 0 0 1 0|
+ |---------------|
+ |7 6 5 4 3 2 1 0|
+.fi
+.PP
+We already mentioned that bits number 7 and 6 belong to the
+reserved field, so they must must be 0. Looking at the
+control bits section we see that only bit number 1 (SYN) is set.
+.PP
+Assuming that octet number 13 is an 8-bit unsigned integer in
+network byte order, the binary value of this octet is
+.IP
+00000010
+.PP
+and its decimal representation is
+.PP
+.nf
+ 7 6 5 4 3 2 1 0
+0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2 = 2
+.fi
+.PP
+We're almost done, because now we know that if only SYN is set,
+the value of the 13th octet in the TCP header, when interpreted
+as a 8-bit unsigned integer in network byte order, must be exactly 2.
+.PP
+This relationship can be expressed as
+.RS
+.B
+tcp[13] == 2
+.RE
+.PP
+We can use this expression as the filter for \fItcpdump\fP in order
+to watch packets which have only SYN set:
+.RS
+.B
+tcpdump -i xl0 tcp[13] == 2
+.RE
+.PP
+The expression says "let the 13th octet of a TCP datagram have
+the decimal value 2", which is exactly what we want.
+.PP
+Now, let's assume that we need to capture SYN packets, but we
+don't care if ACK or any other TCP control bit is set at the
+same time. Let's see what happens to octet 13 when a TCP datagram
+with SYN-ACK set arrives:
+.PP
+.nf
+ | |U|A|P|R|S|F|
+ |---------------|
+ |0 0 0 1 0 0 1 0|
+ |---------------|
+ |7 6 5 4 3 2 1 0|
+.fi
+.PP
+Now bits 1 and 4 are set in the 13th octet. The binary value of
+octet 13 is
+.IP
+ 00010010
+.PP
+which translates to decimal
+.PP
+.nf
+ 7 6 5 4 3 2 1 0
+0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2 = 18
+.fi
+.PP
+Now we can't just use 'tcp[13] == 18' in the \fItcpdump\fP filter
+expression, because that would select only those packets that have
+SYN-ACK set, but not those with only SYN set. Remember that we don't care
+if ACK or any other control bit is set as long as SYN is set.
+.PP
+In order to achieve our goal, we need to logically AND the
+binary value of octet 13 with some other value to preserve
+the SYN bit. We know that we want SYN to be set in any case,
+so we'll logically AND the value in the 13th octet with
+the binary value of a SYN:
+.PP
+.nf
+
+ 00010010 SYN-ACK 00000010 SYN
+ AND 00000010 (we want SYN) AND 00000010 (we want SYN)
+ -------- --------
+ = 00000010 = 00000010
+.fi
+.PP
+We see that this AND operation delivers the same result
+regardless whether ACK or another TCP control bit is set.
+The decimal representation of the AND value as well as
+the result of this operation is 2 (binary 00000010),
+so we know that for packets with SYN set the following
+relation must hold true:
+.IP
+( ( value of octet 13 ) AND ( 2 ) ) == ( 2 )
+.PP
+This points us to the \fItcpdump\fP filter expression
+.RS
+.B
+ tcpdump -i xl0 'tcp[13] & 2 == 2'
+.RE
+.PP
+Note that you should use single quotes or a backslash
+in the expression to hide the AND ('&') special character
+from the shell.
.HD
.B
UDP Packets
@@ -929,7 +1178,7 @@ Name server requests are formatted as
.sp .5
\fIsrc > dst: id op? flags qtype qclass name (len)\fP
.sp .5
-\f(CWh2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)\fP
+\f(CWh2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)\fR
.sp .5
.fi
.RE
@@ -966,7 +1215,7 @@ Name server responses are formatted as
\fIsrc > dst: id op rcode flags a/n/au type class data (len)\fP
.sp .5
\f(CWhelios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
-helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)\fP
+helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)\fR
.sp .5
.fi
.RE
@@ -997,7 +1246,7 @@ has worked well for me.
.HD
SMB/CIFS decoding
.LP
-tcpdump now includes fairly extensive SMB/CIFS/NBT decoding for data
+\fItcpdump\fP now includes fairly extensive SMB/CIFS/NBT decoding for data
on UDP/137, UDP/138 and TCP/139. Some primitive decoding of IPX and
NetBEUI SMB data is also done.
@@ -1032,7 +1281,7 @@ sushi.201b > wrl.nfs:
144 lookup fh 9,74/4096.6878 "xcolors"
wrl.nfs > sushi.201b:
reply ok 128 lookup fh 9,74/4134.3150
-\fP
+\fR
.sp .5
.fi
.RE
@@ -1066,7 +1315,7 @@ wrl.nfs > sushi.1372a:
.sp .5
.fi
.RE
-(\-v also prints the IP header TTL, ID, and fragmentation fields,
+(\-v also prints the IP header TTL, ID, length, and fragmentation fields,
which have been omitted from this example.) In the first line,
\fIsushi\fP asks \fIwrl\fP to read 8192 bytes from file 21,11/12.195,
at byte offset 24576. \fIWrl\fP replies `ok'; the packet shown on the
@@ -1089,7 +1338,7 @@ NFS reply packets do not explicitly identify the RPC operation. Instead,
replies using the transaction ID. If a reply does not closely follow the
corresponding request, it might not be parsable.
.HD
-AFS Request and Replies
+AFS Requests and Replies
.LP
Transarc AFS (Andrew File System) requests and replies are printed
as:
@@ -1106,7 +1355,7 @@ elvis.7001 > pike.afsfs:
rx data fs call rename old fid 536876964/1/1 ".newsrc.new"
new fid 536876964/1/1 ".newsrc"
pike.afsfs > elvis.7001: rx data fs reply rename
-\fP
+\fR
.sp .5
.fi
.RE
@@ -1126,11 +1375,16 @@ The format is intended to be self-describing, but it will probably
not be useful to people who are not familiar with the workings of
AFS and RX.
.LP
-If the -v (verbose) flag is given twice, additional information is printed,
-such as the the RX call ID, call number, sequence number, serial number,
-and the RX packet flags.
+If the -v (verbose) flag is given twice, acknowledgement packets and
+additional header information is printed, such as the the RX call ID,
+call number, sequence number, serial number, and the RX packet flags.
.LP
-If the -v flag is given again, the security index and service id are printed.
+If the -v flag is given twice, additional information is printed,
+such as the the RX call ID, serial number, and the RX packet flags.
+The MTU negotiation information is also printed from RX ack packets.
+.LP
+If the -v flag is given three times, the security index and service id
+are printed.
.LP
Error codes are printed for abort packets, with the exception of Ubik
beacon packets (because abort packets are used to signify a yes vote
@@ -1162,7 +1416,7 @@ Lines in this file have the form
\f(CW1.254 ether
16.1 icsd-net
-1.254.110 ace\fP
+1.254.110 ace\fR
.sp .5
.fi
.RE
@@ -1185,7 +1439,7 @@ Appletalk addresses are printed in the form
\f(CW144.1.209.2 > icsd-net.112.220
office.2 > icsd-net.112.220
-jssmag.149.235 > icsd-net.2\fP
+jssmag.149.235 > icsd-net.2\fR
.sp .5
.fi
.RE
@@ -1213,7 +1467,7 @@ protocol) and packet size.
.sp .5
\s-2\f(CWicsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250
-techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186\fP\s+2
+techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186\fR\s+2
.sp .5
.fi
.RE
@@ -1242,7 +1496,7 @@ jssmag.209.165 > helios.132: atp-req 12266<3,5> 0xae030001
helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
jssmag.209.165 > helios.132: atp-rel 12266<0-7> 0xae030001
-jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002\fP\s+2
+jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002\fR\s+2
.sp .5
.fi
.RE
@@ -1326,12 +1580,22 @@ serviced the `new packet' interrupt.
.SH "SEE ALSO"
traffic(1C), nit(4P), bpf(4), pcap(3)
.SH AUTHORS
+The original authors are:
+.LP
Van Jacobson,
Craig Leres and
Steven McCanne, all of the
Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
.LP
-The current version is available via anonymous ftp:
+It is currently being maintained by tcpdump.org.
+.LP
+The current version is available via http:
+.LP
+.RS
+.I http://www.tcpdump.org/
+.RE
+.LP
+The original distribution is available via anonymous ftp:
.LP
.RS
.I ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
@@ -1340,40 +1604,61 @@ The current version is available via anonymous ftp:
IPv6/IPsec support is added by WIDE/KAME project.
This program uses Eric Young's SSLeay library, under specific configuration.
.SH BUGS
-Please send bug reports to tcpdump@ee.lbl.gov.
+Please send problems, bugs, questions, desirable enhancements, etc. to:
+.LP
+.RS
+tcpdump-workers@tcpdump.org
+.RE
+.LP
+Please send source code contributions, etc. to:
+.LP
+.RS
+patches@tcpdump.org
+.RE
.LP
NIT doesn't let you watch your own outbound traffic, BPF will.
We recommend that you use the latter.
.LP
+On Linux systems with 2.0[.x] kernels:
+.IP
+packets on the loopback device will be seen twice;
+.IP
+packet filtering cannot be done in the kernel, so that all packets must
+be copied from the kernel in order to be filtered in user mode;
+.IP
+all of a packet, not just the part that's within the snapshot length,
+will be copied from the kernel (the 2.0[.x] packet capture mechanism, if
+asked to copy only part of a packet to userland, will not report the
+true length of the packet; this would cause most IP packets to get an
+error from
+.BR tcpdump ).
+.LP
+We recommend that you upgrade to a 2.2 or later kernel.
+.LP
Some attempt should be made to reassemble IP fragments or, at least
to compute the right length for the higher level protocol.
.LP
-Name server inverse queries are not dumped correctly: The (empty)
+Name server inverse queries are not dumped correctly: the (empty)
question section is printed rather than real query in the answer
section. Some believe that inverse queries are themselves a bug and
-prefer to fix the program generating them rather than tcpdump.
-.LP
-Apple Ethertalk DDP packets could be dumped as easily as KIP DDP
-packets but aren't.
-Even if we were inclined to do anything to promote the use of
-Ethertalk (we aren't), LBL doesn't allow Ethertalk on any of its
-networks so we'd would have no way of testing this code.
+prefer to fix the program generating them rather than \fItcpdump\fP.
.LP
A packet trace that crosses a daylight savings time change will give
skewed time stamps (the time change is ignored).
.LP
-Filters expressions that manipulate FDDI headers assume that all FDDI
-packets are encapsulated Ethernet packets. This is true for IP, ARP,
-and DECNET Phase IV, but is not true for protocols such as ISO CLNS.
-Therefore, the filter may inadvertently accept certain packets that
-do not properly match the filter expression.
+Filter expressions that manipulate FDDI or Token Ring headers assume
+that all FDDI and Token Ring packets are SNAP-encapsulated Ethernet
+packets. This is true for IP, ARP, and DECNET Phase IV, but is not true
+for protocols such as ISO CLNS. Therefore, the filter may inadvertently
+accept certain packets that do not properly match the filter expression.
+.LP
+Filter expressions on fields other than those that manipulate Token Ring
+headers will not correctly handle source-routed Token Ring packets.
.LP
.BR "ip6 proto"
should chase header chain, but at this moment it does not.
-.BR tcp
-or
-.BR udp
-should chase header chain too.
+.BR "ip6 protochain"
+is supplied for this behavior.
.LP
Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
does not work against IPv6 packets.
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index 7273866..4749271 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -24,7 +24,7 @@ static const char copyright[] =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.138.2.1 2000/01/11 07:34:00 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.158 2000/12/21 10:43:24 guy Exp $ (LBL)";
#endif
/*
@@ -52,8 +52,6 @@ static const char rcsid[] =
#include <unistd.h>
#include <ctype.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
#include "interface.h"
#include "addrtoname.h"
@@ -74,11 +72,11 @@ int Rflag = 1; /* print sequence # field in AH/ESP*/
int sflag = 0; /* use the libsmi to translate OIDs */
int Sflag; /* print raw TCP sequence numbers */
int tflag = 1; /* print packet arrival time */
+int uflag = 0; /* Print undecoded NFS handles */
int vflag; /* verbose */
int xflag; /* print packet in hex */
int Xflag; /* print packet in ascii as well as hex */
-char *ahsecret = NULL; /* AH secret key */
char *espsecret = NULL; /* ESP secret key */
int packettype;
@@ -88,12 +86,9 @@ char *program_name;
int32_t thiszone; /* seconds offset from gmt to local time */
-/* Externs */
-extern void bpf_dump(struct bpf_program *, int);
-
/* Forwards */
-RETSIGTYPE cleanup(int);
-extern __dead void usage(void) __attribute__((volatile));
+static RETSIGTYPE cleanup(int);
+static void usage(void) __attribute__((noreturn));
/* Length of saved portion of packet. */
int snaplen = DEFAULT_SNAPLEN;
@@ -105,23 +100,35 @@ struct printer {
static struct printer printers[] = {
{ ether_if_print, DLT_EN10MB },
- { ether_if_print, DLT_IEEE802 },
+ { token_if_print, DLT_IEEE802 },
#ifdef DLT_LANE8023
{ lane_if_print, DLT_LANE8023 },
#endif
#ifdef DLT_CIP
{ cip_if_print, DLT_CIP },
#endif
+#ifdef DLT_ATM_CLIP
+ { cip_if_print, DLT_ATM_CLIP },
+#endif
{ sl_if_print, DLT_SLIP },
{ sl_bsdos_if_print, DLT_SLIP_BSDOS },
{ ppp_if_print, DLT_PPP },
{ ppp_bsdos_if_print, DLT_PPP_BSDOS },
{ fddi_if_print, DLT_FDDI },
{ null_if_print, DLT_NULL },
+#ifdef DLT_LOOP
+ { null_if_print, DLT_LOOP },
+#endif
{ raw_if_print, DLT_RAW },
{ atm_if_print, DLT_ATM_RFC1483 },
-#ifdef DLT_CHDLC
- { chdlc_if_print, DLT_CHDLC },
+#ifdef DLT_C_HDLC
+ { chdlc_if_print, DLT_C_HDLC },
+#endif
+#ifdef DLT_PPP_SERIAL
+ { ppp_hdlc_if_print, DLT_PPP_SERIAL },
+#endif
+#ifdef DLT_LINUX_SLL
+ { sll_if_print, DLT_LINUX_SLL },
#endif
{ NULL, 0 },
};
@@ -135,7 +142,7 @@ lookup_printer(int type)
if (type == p->type)
return p->f;
- error("unknown data link type 0x%x", type);
+ error("unknown data link type %d", type);
/* NOTREACHED */
}
@@ -167,7 +174,7 @@ main(int argc, char **argv)
else
program_name = argv[0];
- if (abort_on_misalignment(ebuf) < 0)
+ if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
error("%s", ebuf);
#ifdef LIBSMI
@@ -176,22 +183,13 @@ main(int argc, char **argv)
opterr = 0;
while (
- (op = getopt(argc, argv, "ac:deE:fF:i:lnNm:Opqr:Rs:StT:vw:xXY")) != EOF)
+ (op = getopt(argc, argv, "ac:deE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
switch (op) {
case 'a':
++aflag;
break;
-#if 0
- case 'A':
-#ifndef CRYPTO
- warning("crypto code not compiled in");
-#endif
- ahsecret = optarg;
- break;
-#endif
-
case 'c':
cnt = atoi(optarg);
if (cnt <= 0)
@@ -207,7 +205,7 @@ main(int argc, char **argv)
break;
case 'E':
-#ifndef CRYPTO
+#ifndef HAVE_LIBCRYPTO
warning("crypto code not compiled in");
#endif
espsecret = optarg;
@@ -273,11 +271,17 @@ main(int argc, char **argv)
Rflag = 0;
break;
- case 's':
- snaplen = atoi(optarg);
- if (snaplen <= 0)
+ case 's': {
+ char *end;
+
+ snaplen = strtol(optarg, &end, 0);
+ if (optarg == end || *end != '\0'
+ || snaplen < 0 || snaplen > 65535)
error("invalid snaplen %s", optarg);
+ else if (snaplen == 0)
+ snaplen = 65535;
break;
+ }
case 'S':
++Sflag;
@@ -300,10 +304,16 @@ main(int argc, char **argv)
packettype = PT_RTCP;
else if (strcasecmp(optarg, "snmp") == 0)
packettype = PT_SNMP;
+ else if (strcasecmp(optarg, "cnfp") == 0)
+ packettype = PT_CNFP;
else
error("unknown packet type `%s'", optarg);
break;
+ case 'u':
+ ++uflag;
+ break;
+
case 'v':
++vflag;
break;
@@ -317,7 +327,7 @@ main(int argc, char **argv)
break;
case 'X':
- ++xflag;
+ ++xflag;
++Xflag;
break;
@@ -426,7 +436,7 @@ main(int argc, char **argv)
}
/* make a clean exit on interrupts */
-RETSIGTYPE
+static RETSIGTYPE
cleanup(int signo)
{
struct pcap_stat stat;
@@ -483,7 +493,7 @@ default_print(register const u_char *bp, register u_int length)
default_print_unaligned(bp, length);
}
-__dead void
+static void
usage(void)
{
extern char version[];
@@ -492,7 +502,7 @@ usage(void)
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
(void)fprintf(stderr,
-"Usage: %s [-adeflnNOpqStvxX] [-c count] [ -F file ]\n", program_name);
+"Usage: %s [-adeflnNOpqStuvxX] [-c count] [ -F file ]\n", program_name);
(void)fprintf(stderr,
"\t\t[ -i interface ] [ -r file ] [ -s snaplen ]\n");
(void)fprintf(stderr,
diff --git a/contrib/tcpdump/timed.h b/contrib/tcpdump/timed.h
new file mode 100644
index 0000000..136e55e
--- /dev/null
+++ b/contrib/tcpdump/timed.h
@@ -0,0 +1,92 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.3 2000/12/17 23:07:51 guy Exp $ (LBL) */
+/*
+ * Copyright (c) 1983, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)timed.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _PROTOCOLS_TIMED_H_
+#define _PROTOCOLS_TIMED_H_
+
+/*
+ * Time Synchronization Protocol
+ */
+
+#define TSPVERSION 1
+#define ANYADDR NULL
+
+struct tsp {
+ u_char tsp_type;
+ u_char tsp_vers;
+ u_short tsp_seq;
+ union {
+ struct timeval tspu_time;
+ char tspu_hopcnt;
+ } tsp_u;
+ char tsp_name[256];
+};
+
+#define tsp_time tsp_u.tspu_time
+#define tsp_hopcnt tsp_u.tspu_hopcnt
+
+/*
+ * Command types.
+ */
+#define TSP_ANY 0 /* match any types */
+#define TSP_ADJTIME 1 /* send adjtime */
+#define TSP_ACK 2 /* generic acknowledgement */
+#define TSP_MASTERREQ 3 /* ask for master's name */
+#define TSP_MASTERACK 4 /* acknowledge master request */
+#define TSP_SETTIME 5 /* send network time */
+#define TSP_MASTERUP 6 /* inform slaves that master is up */
+#define TSP_SLAVEUP 7 /* slave is up but not polled */
+#define TSP_ELECTION 8 /* advance candidature for master */
+#define TSP_ACCEPT 9 /* support candidature of master */
+#define TSP_REFUSE 10 /* reject candidature of master */
+#define TSP_CONFLICT 11 /* two or more masters present */
+#define TSP_RESOLVE 12 /* masters' conflict resolution */
+#define TSP_QUIT 13 /* reject candidature if master is up */
+#define TSP_DATE 14 /* reset the time (date command) */
+#define TSP_DATEREQ 15 /* remote request to reset the time */
+#define TSP_DATEACK 16 /* acknowledge time setting */
+#define TSP_TRACEON 17 /* turn tracing on */
+#define TSP_TRACEOFF 18 /* turn tracing off */
+#define TSP_MSITE 19 /* find out master's site */
+#define TSP_MSITEREQ 20 /* remote master's site request */
+#define TSP_TEST 21 /* for testing election algo */
+#define TSP_SETDATE 22 /* New from date command */
+#define TSP_SETDATEREQ 23 /* New remote for above */
+#define TSP_LOOP 24 /* loop detection packet */
+
+#define TSPTYPENUMBER 25
+
+#endif /* !_TIMED_H_ */
diff --git a/contrib/tcpdump/token.h b/contrib/tcpdump/token.h
index 6f28a1e..9565969 100644
--- a/contrib/tcpdump/token.h
+++ b/contrib/tcpdump/token.h
@@ -1,3 +1,4 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.3 2000/10/03 02:55:03 itojun Exp $ (LBL) */
/*
* Copyright (c) 1998, Larry Lile
* All rights reserved.
@@ -26,18 +27,26 @@
*
*/
-#define TOKEN_HDR_LEN 14
-#define IS_SOURCE_ROUTED (tp->ether_shost[0] & 0x80)
-#define RIF_LENGTH ((ntohs(tp->rcf) & 0x1f00) >> 8)
-#define TOKEN_RING_MAC_LEN 6
-#define ROUTING_SEGMENT_MAX 16
+#define TOKEN_HDRLEN 14
+#define TOKEN_RING_MAC_LEN 6
+#define ROUTING_SEGMENT_MAX 16
+#define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80)
+#define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6)
+#define TOKEN_FC_LLC 1
+
+#define BROADCAST(trp) ((ntohs((trp)->token_rcf) & 0xE000) >> 13)
+#define RIF_LENGTH(trp) ((ntohs((trp)->token_rcf) & 0x1f00) >> 8)
+#define DIRECTION(trp) ((ntohs((trp)->token_rcf) & 0x0080) >> 7)
+#define LARGEST_FRAME(trp) ((ntohs((trp)->token_rcf) & 0x0070) >> 4)
+#define RING_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0xfff0) >> 4)
+#define BRIDGE_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0x000f))
+#define SEGMENT_COUNT(trp) ((RIF_LENGTH(trp) - 2) / 2)
struct token_header {
- u_char ac;
- u_char fc;
- u_char ether_dhost[TOKEN_RING_MAC_LEN];
- u_char ether_shost[TOKEN_RING_MAC_LEN];
- u_short rcf;
- u_short rseg[ROUTING_SEGMENT_MAX];
+ u_int8_t token_ac;
+ u_int8_t token_fc;
+ u_int8_t token_dhost[TOKEN_RING_MAC_LEN];
+ u_int8_t token_shost[TOKEN_RING_MAC_LEN];
+ u_int16_t token_rcf;
+ u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
};
-
diff --git a/contrib/tcpdump/udp.h b/contrib/tcpdump/udp.h
new file mode 100644
index 0000000..089ca01
--- /dev/null
+++ b/contrib/tcpdump/udp.h
@@ -0,0 +1,46 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.2 2000/10/03 02:55:03 itojun Exp $ (LBL) */
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * 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 the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)udp.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Udp protocol header.
+ * Per RFC 768, September, 1981.
+ */
+struct udphdr {
+ u_int16_t uh_sport; /* source port */
+ u_int16_t uh_dport; /* destination port */
+ u_int16_t uh_ulen; /* udp length */
+ u_int16_t uh_sum; /* udp checksum */
+};
diff --git a/contrib/tcpdump/util.c b/contrib/tcpdump/util.c
index 3a3094c..57e3a03 100644
--- a/contrib/tcpdump/util.c
+++ b/contrib/tcpdump/util.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.62 1999/12/15 06:58:03 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.69 2000/07/11 00:49:03 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -38,16 +38,9 @@ static const char rcsid[] =
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#include <pcap.h>
#include <stdio.h>
-#if __STDC__
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <stdlib.h>
#include <string.h>
#ifdef TIME_WITH_SYS_TIME
@@ -129,37 +122,51 @@ void
ts_print(register const struct timeval *tvp)
{
register int s;
+ struct tm *tm;
+ time_t Time;
+ static unsigned b_sec;
+ static unsigned b_usec;
- if (tflag > 0) {
- /* Default */
+ switch(tflag) {
+ case 1: /* Default */
s = (tvp->tv_sec + thiszone) % 86400;
(void)printf("%02d:%02d:%02d.%06u ",
- s / 3600, (s % 3600) / 60, s % 60, (u_int32_t)tvp->tv_usec);
- } else if (tflag < 0) {
- if (tflag < -1) {
- static unsigned b_sec;
- static unsigned b_usec;
- if (b_sec == 0) {
- printf("000000 ");
- } else {
- int d_usec = tvp->tv_usec - b_usec;
- int d_sec = tvp->tv_sec - b_sec;
-
- while (d_usec < 0) {
- d_usec += 1000000;
- d_sec--;
- }
- if (d_sec)
- printf("%d. ", d_sec);
- printf("%06d ", d_usec);
- }
- b_sec = tvp->tv_sec;
- b_usec = tvp->tv_usec;
+ s / 3600, (s % 3600) / 60, s % 60,
+ (unsigned)tvp->tv_usec);
+ break;
+ case -1: /* Unix timeval style */
+ (void)printf("%u.%06u ",
+ (unsigned)tvp->tv_sec,
+ (unsigned)tvp->tv_usec);
+ break;
+ case -2:
+ if (b_sec == 0) {
+ printf("000000 ");
} else {
- /* Unix timeval style */
- (void)printf("%u.%06u ",
- (u_int32_t)tvp->tv_sec, (u_int32_t)tvp->tv_usec);
+ int d_usec = tvp->tv_usec - b_usec;
+ int d_sec = tvp->tv_sec - b_sec;
+
+ while (d_usec < 0) {
+ d_usec += 1000000;
+ d_sec--;
+ }
+ if (d_sec)
+ printf("%d. ", d_sec);
+ printf("%06d ", d_usec);
}
+ b_sec = tvp->tv_sec;
+ b_usec = tvp->tv_usec;
+ break;
+ case -3: /* Default + Date*/
+ s = (tvp->tv_sec + thiszone) % 86400;
+ Time = (tvp->tv_sec + thiszone) - s;
+ tm = gmtime (&Time);
+ (void)printf("%02d/%02d/%04d %02d:%02d:%02d.%06u ",
+ tm->tm_mon+1, tm->tm_mday,
+ tm->tm_year+1900,
+ s / 3600, (s % 3600) / 60,
+ s % 60, (unsigned)tvp->tv_usec);
+ break;
}
}
@@ -171,22 +178,23 @@ ts_print(register const struct timeval *tvp)
void
relts_print(int secs)
{
- static char *lengths[]={"y","w","d","h","m","s"};
- static int seconds[]={31536000,604800,86400,3600,60,1};
- char **l = lengths;
- int *s = seconds;
-
- if (secs == 0) {
- (void)printf("0s");
- return;
- }
- while (secs) {
- if (secs >= *s) {
- (void)printf("%d%s", secs / *s, *l);
- secs -= (secs / *s) * *s;
+ static char *lengths[] = {"y", "w", "d", "h", "m", "s"};
+ static int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
+ char **l = lengths;
+ int *s = seconds;
+
+ if (secs <= 0) {
+ (void)printf("0s");
+ return;
+ }
+ while (secs > 0) {
+ if (secs >= *s) {
+ (void)printf("%d%s", secs / *s, *l);
+ secs -= (secs / *s) * *s;
+ }
+ s++;
+ l++;
}
- s++; l++;
- }
}
/*
@@ -205,29 +213,19 @@ tok2str(register const struct tok *lp, register const char *fmt,
}
if (fmt == NULL)
fmt = "#%d";
- (void)sprintf(buf, fmt, v);
+ (void)snprintf(buf, sizeof(buf), fmt, v);
return (buf);
}
/* VARARGS */
-__dead void
-#if __STDC__
+void
error(const char *fmt, ...)
-#else
-error(fmt, va_alist)
- const char *fmt;
- va_dcl
-#endif
{
va_list ap;
(void)fprintf(stderr, "%s: ", program_name);
-#if __STDC__
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
if (*fmt) {
@@ -241,22 +239,12 @@ error(fmt, va_alist)
/* VARARGS */
void
-#if __STDC__
warning(const char *fmt, ...)
-#else
-warning(fmt, va_alist)
- const char *fmt;
- va_dcl
-#endif
{
va_list ap;
(void)fprintf(stderr, "%s: WARNING: ", program_name);
-#if __STDC__
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
if (*fmt) {
@@ -324,3 +312,24 @@ read_infile(char *fname)
return (cp);
}
+
+void
+safeputs(const char *s)
+{
+ while (*s) {
+ safeputchar(*s);
+ s++;
+ }
+}
+
+void
+safeputchar(int c)
+{
+ unsigned char ch;
+
+ ch = (unsigned char)(c & 0xff);
+ if (c < 0x80 && isprint(c))
+ printf("%c", c & 0xff);
+ else
+ printf("\\%03o", c & 0xff);
+}
diff --git a/contrib/tcpdump/vfprintf.c b/contrib/tcpdump/vfprintf.c
index 51fa63e..9fea58e 100644
--- a/contrib/tcpdump/vfprintf.c
+++ b/contrib/tcpdump/vfprintf.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/vfprintf.c,v 1.3 1999/11/21 09:37:05 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/vfprintf.c,v 1.4 2000/07/01 03:39:12 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -31,11 +31,7 @@ static const char rcsid[] =
#include <sys/types.h>
#include <stdio.h>
-#if __STDC__
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <stdlib.h>
#include <unistd.h>
OpenPOWER on IntegriCloud