aboutsummaryrefslogtreecommitdiff
path: root/contrib/tcpdump
diff options
context:
space:
mode:
authorBill Fenner <fenner@FreeBSD.org>2002-06-21 00:43:23 +0000
committerBill Fenner <fenner@FreeBSD.org>2002-06-21 00:43:23 +0000
commit1c6248dba05782c255d12a9a0bfdc2d72e5843f6 (patch)
treed2a4d6a54eab217f47aba0c94d3e2ce39792f79a /contrib/tcpdump
parent2746c2944596eaed537c2a9e3b26debd32f53976 (diff)
parenta90e161be323456b08b7fe13acb201536809510f (diff)
downloadsrc-1c6248dba05782c255d12a9a0bfdc2d72e5843f6.tar.gz
src-1c6248dba05782c255d12a9a0bfdc2d72e5843f6.zip
This commit was generated by cvs2svn to compensate for changes in r98524,
which included commits to RCS files with non-trunk default branches.
Notes
Notes: svn path=/head/; revision=98525
Diffstat (limited to 'contrib/tcpdump')
-rw-r--r--contrib/tcpdump/CHANGES62
-rw-r--r--contrib/tcpdump/CREDITS32
-rw-r--r--contrib/tcpdump/FILES24
-rw-r--r--contrib/tcpdump/Makefile.in39
-rw-r--r--contrib/tcpdump/PLATFORMS3
-rw-r--r--contrib/tcpdump/README8
-rw-r--r--contrib/tcpdump/VERSION2
-rw-r--r--contrib/tcpdump/acconfig.h14
-rw-r--r--contrib/tcpdump/addrtoname.h17
-rw-r--r--contrib/tcpdump/arcnet.h79
-rw-r--r--contrib/tcpdump/bootp.h5
-rwxr-xr-xcontrib/tcpdump/config.guess471
-rw-r--r--contrib/tcpdump/config.h.in43
-rwxr-xr-xcontrib/tcpdump/config.sub98
-rwxr-xr-xcontrib/tcpdump/configure1248
-rwxr-xr-xcontrib/tcpdump/configure.in96
-rw-r--r--contrib/tcpdump/dhcp6.h2
-rw-r--r--contrib/tcpdump/dhcp6opt.h4
-rw-r--r--contrib/tcpdump/extract.h36
-rw-r--r--contrib/tcpdump/icmp6.h49
-rw-r--r--contrib/tcpdump/ieee802_11.h244
-rw-r--r--contrib/tcpdump/ipx.h4
-rw-r--r--contrib/tcpdump/l2tp.h25
-rw-r--r--contrib/tcpdump/llc.h22
-rw-r--r--contrib/tcpdump/machdep.c13
-rwxr-xr-xcontrib/tcpdump/makemib43
-rw-r--r--contrib/tcpdump/missing/snprintf.c8
-rw-r--r--contrib/tcpdump/missing/strdup.c57
-rw-r--r--contrib/tcpdump/nameser.h41
-rw-r--r--contrib/tcpdump/print-802_11.c858
-rw-r--r--contrib/tcpdump/print-ah.c9
-rw-r--r--contrib/tcpdump/print-arcnet.c248
-rw-r--r--contrib/tcpdump/print-beep.c73
-rw-r--r--contrib/tcpdump/print-bgp.c70
-rw-r--r--contrib/tcpdump/print-cdp.c293
-rw-r--r--contrib/tcpdump/print-chdlc.c40
-rw-r--r--contrib/tcpdump/print-cip.c78
-rw-r--r--contrib/tcpdump/print-cnfp.c39
-rw-r--r--contrib/tcpdump/print-decnet.c13
-rw-r--r--contrib/tcpdump/print-dhcp6.c10
-rw-r--r--contrib/tcpdump/print-dvmrp.c22
-rw-r--r--contrib/tcpdump/print-egp.c16
-rw-r--r--contrib/tcpdump/print-esp.c229
-rw-r--r--contrib/tcpdump/print-frag6.c10
-rw-r--r--contrib/tcpdump/print-gre.c118
-rw-r--r--contrib/tcpdump/print-hsrp.c137
-rw-r--r--contrib/tcpdump/print-icmp6.c377
-rw-r--r--contrib/tcpdump/print-igmp.c40
-rw-r--r--contrib/tcpdump/print-igrp.c10
-rw-r--r--contrib/tcpdump/print-ip6opts.c44
-rw-r--r--contrib/tcpdump/print-isakmp.c13
-rw-r--r--contrib/tcpdump/print-l2tp.c760
-rw-r--r--contrib/tcpdump/print-lane.c6
-rw-r--r--contrib/tcpdump/print-lwres.c599
-rw-r--r--contrib/tcpdump/print-mobile.c32
-rw-r--r--contrib/tcpdump/print-mpls.c123
-rw-r--r--contrib/tcpdump/print-msdp.c102
-rw-r--r--contrib/tcpdump/print-ospf.c13
-rw-r--r--contrib/tcpdump/print-ospf6.c4
-rw-r--r--contrib/tcpdump/print-pppoe.c309
-rw-r--r--contrib/tcpdump/print-pptp.c1070
-rw-r--r--contrib/tcpdump/print-radius.c57
-rw-r--r--contrib/tcpdump/print-raw.c6
-rw-r--r--contrib/tcpdump/print-rip.c8
-rw-r--r--contrib/tcpdump/print-ripng.c16
-rw-r--r--contrib/tcpdump/print-rt6.c8
-rw-r--r--contrib/tcpdump/print-rx.c78
-rw-r--r--contrib/tcpdump/print-sctp.c351
-rw-r--r--contrib/tcpdump/print-sll.c16
-rw-r--r--contrib/tcpdump/print-smb.c1933
-rw-r--r--contrib/tcpdump/print-snmp.c135
-rw-r--r--contrib/tcpdump/print-tcp.c125
-rw-r--r--contrib/tcpdump/print-telnet.c271
-rw-r--r--contrib/tcpdump/print-timed.c12
-rw-r--r--contrib/tcpdump/print-vrrp.c41
-rw-r--r--contrib/tcpdump/print-wb.c6
-rw-r--r--contrib/tcpdump/print-zephyr.c311
-rw-r--r--contrib/tcpdump/route6d.h30
-rw-r--r--contrib/tcpdump/rx.h28
-rw-r--r--contrib/tcpdump/sctpConstants.h576
-rw-r--r--contrib/tcpdump/sctpHeader.h323
-rw-r--r--contrib/tcpdump/smb.h51
-rw-r--r--contrib/tcpdump/smbutil.c1354
-rw-r--r--contrib/tcpdump/tcp.h19
-rw-r--r--contrib/tcpdump/telnet.h348
-rw-r--r--contrib/tcpdump/util.c40
86 files changed, 10457 insertions, 4240 deletions
diff --git a/contrib/tcpdump/CHANGES b/contrib/tcpdump/CHANGES
index 4616fb33a783..d293a115c8bd 100644
--- a/contrib/tcpdump/CHANGES
+++ b/contrib/tcpdump/CHANGES
@@ -1,4 +1,62 @@
-$Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $
+$Header: /tcpdump/master/tcpdump/CHANGES,v 1.81 2002/01/21 11:03:33 mcr Exp $
+
+Monday, January 21, 2002. mcr@sandelman.ottawa.on.ca. Summary for 3.7 release
+see http://www.tcpdump.org/cvs-log/2002-01-21.10:16:48.html for commit log.
+ keyword "ipx" added.
+ Better OSI/802.2 support on Linux.
+ IEEE 802.11 support, from clenahan@fortresstech.com, achirica@ttd.net.
+ LLC SAP support for FDDI/token ring/RFC-1483 style ATM
+ BXXP protocol was replaced by the BEEP protocol;
+ improvements to SNAP demux.
+ Changes to "any" interface documentation.
+ Documentation on pcap_stats() counters.
+ Fix a memory leak found by Miklos Szeredi - pcap_ether_aton().
+ Added MPLS encapsulation decoding per RFC3032.
+ DNS dissector handles TKEY, TSIG and IXFR.
+ adaptive SLIP interface patch from Igor Khristophorov <igor@atdot.org>
+ SMB printing has much improved bounds checks
+ OUI 0x0000f8 decoded as encapsulated ethernet for Cisco-custom bridging
+ Zephyr support, from Nickolai Zeldovich <kolya@MIT.EDU>.
+ Solaris - devices with digits in them. Stefan Hudson <hudson@mbay.net>
+ IPX socket 0x85be is for Cisco EIGRP over IPX.
+ Improvements to fragmented ESP handling.
+ SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
+ Linux ARPHDR_ATM support fixed.
+ Added a "netbeui" keyword, which selects NetBEUI packets.
+ IPv6 ND improvements, MobileIP dissector, 2292bis-02 for RA option.
+ Handle ARPHDR_HDLC from Marcus Felipe Pereira <marcus@task.com.br>.
+ Handle IPX socket 0x553 -> NetBIOS-over-IPX socket, "nwlink-dgm"
+ Better Linux libc5 compat.
+ BIND9 lwres dissector added.
+ MIPS and SPARC get strict alignment macros (affects print-bgp.c)
+ Apple LocalTalk LINKTYPE_ reserved.
+ New time stamp formats documented.
+ DHCP6 updated to draft-22.txt spec.
+ ICMP types/codes now accept symbolic names.
+ Add SIGINFO handler from LBL
+ encrypted CIPE tunnels in IRIX, from Franz Schaefer <schaefer@mond.at>.
+ now we are -Wstrict-prototype clean.
+ NetBSD DLT_PPP_ETHER; adapted from Martin Husemann <martin@netbsd.org>.
+ PPPoE dissector cleaned up.
+ Support for LocalTalk hardware, from Uns Lider <unslider@miranda.org>.
+ In dissector, now the caller prints the IP addresses rather than proto.
+ cjclark@alum.mit.edu: print the IP proto for non-initial fragments.
+ LLC frames with a DSAP and LSAP of 0xe0 are IPX frames.
+ Linux cooked frames with a type value of LINUX_SLL_P_802_3 are IPX.
+ captures on the "any" device won't be done in promiscuous mode
+ Token Ring support on DLPI - Onno van der Linden <onno@simplex.nl>
+ ARCNet support, from NetBSD.
+ HSRP dissector, from Julian Cowley <julian@lava.net>.
+ Handle (GRE-encapsulated) PPTP
+ added -C option to rotate save file every optarg * 1,000,000 bytes.
+ support for "vrrp" name - NetBSD, by Klaus Klein <kleink@netbsd.org>.
+ PPTP support, from Motonori Shindo <mshindo@mshindo.net>.
+ IS-IS over PPP support, from Hannes Gredler <hannes@juniper.net>.
+ CNFP support for IPv6,format. Harry Raaymakers <harryr@connect.com.au>.
+ ESP printing updated to RFC2406.
+ HP-UX can now handle large number of PPAs.
+ MSDP printer added.
+ L2TP dissector improvements from Motonori Shindo.
Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release
Cleaned up documentation.
@@ -595,4 +653,4 @@ v2.0 Sun Jan 13 12:20:40 PST 1991
- Initial public release.
-@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.81 2002/01/21 11:03:33 mcr Exp $ (LBL)
diff --git a/contrib/tcpdump/CREDITS b/contrib/tcpdump/CREDITS
index e53d6895ccb5..e766e89ca457 100644
--- a/contrib/tcpdump/CREDITS
+++ b/contrib/tcpdump/CREDITS
@@ -15,29 +15,55 @@ Additional people who have contributed patches:
Alfredo Andres <aandres@s21sec.com>
Andrew Tridgell <tridge@linuxcare.com>
Arkadiusz Miskiewicz <misiek@pld.org.pl>
+ Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
+ Ben Smithurst <ben@scientia.demon.co.uk>
+ Brent L. Bates <blbates@vigyan.com>
+ Charlie Lenahan <clenahan@fortresstech.com>
Chris G. Demetriou <cgd@netbsd.org>
+ Chris Jepeway <jepeway@blasted-heath.com>
Craig Rodrigues <rodrigc@mediaone.net>
+ Crist J. Clark <cjclark@alum.mit.edu>
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>
+ Hannes Gredler <hannes@juniper.net>
+ Harry Raaymakers <harryr@connect.com.au>
+ Heinz-Ado Arnolds <Ado.Arnolds@dhm-systems.de>
+ Hendrik Scholz <hendrik@scholz.net>
+ Jakob Schlyter <jakob@openbsd.org>
+ Jan Oravec <wsx@wsx6.net>
+ Jason R. Thorpe <thorpej@zembu.com>
Jefferson Ogata <jogata@nodc.noaa.gov>
Jeffrey Hutzelman <jhutz@cmu.edu>
Jim Hutchins <jim@ca.sandia.gov>
+ JINMEI Tatuya <jinmei@kame.net>
Juergen Schoenwaelder <schoenw@ibr.cs.tu-bs.de>
+ Julian Cowley <julian@lava.net>
+ Kaarthik Sivakumar <kaarthik@torrentnet.com>
+ Kazushi Sugyo <sugyo@pb.jp.nec.com>
+ Kelly Carmichael <kcarmich@ipapp.com>
Ken Hornstein <kenh@cmf.nrl.navy.mil>
Kevin Steves <stevesk@sweden.hp.com>
+ Klaus Klein <kleink@reziprozitaet.de>
+ Kris Kennaway <kris@freebsd.org>
Larry Lile <lile@stdio.com>
Lennert Buytenhek <buytenh@gnu.org>
Love Hörnquist-Åstrand <lha@stacken.kth.se>
+ Maciej W. Rozycki <macro@ds2.pg.gda.pl>
Marko Kiiskila <carnil@cs.tut.fi>
+ Marshall Rose <mrose@dbc.mtview.ca.us>
+ Martin Husemann <martin@netbsd.org>
+ Michael Madore <mmadore@turbolinux.com>
Michael Shalayeff <mickey@openbsd.org>
Michael T. Stolarchuk <mts@off.to>
Monroe Williams <monroe@pobox.com>
Motonori Shindo <mshindo@mshindo.net>
+ Nathan J. Williams <nathanw@MIT.EDU>
+ Nathaniel Couper-Noles <Nathaniel@isi1.tccisi.com>
+ Nickolai Zeldovich <kolya@MIT.EDU>
Olaf Kirch <okir@caldera.de>
Onno van der Linden <onno@simplex.nl>
Pascal Hennequin <pascal.hennequin@int-evry.fr>
@@ -48,11 +74,11 @@ Additional people who have contributed patches:
Rick Jones <raj@cup.hp.com>
Roderick Schertler <roderick@argon.org>
Sebastian Krahmer <krahmer@cs.uni-potsdam.de>
+ Seth Webster <swebster@sst.ll.mit.edu>
Timo Koskiahde
Tony Li <tli@jnx.com>
+ Uns Lider <unslider@miranda.org>
Wilbert de Graaf <wilbertdg@hetnet.nl>
- Kris Kennaway <kris@freebsd.org>
- Ben Smithurst <ben@scientia.demon.co.uk>
The original LBL crew:
Steve McCanne
diff --git a/contrib/tcpdump/FILES b/contrib/tcpdump/FILES
index 987589e95cec..3b4f3d42ad2b 100644
--- a/contrib/tcpdump/FILES
+++ b/contrib/tcpdump/FILES
@@ -12,8 +12,10 @@ addrtoname.c
addrtoname.h
ah.h
appletalk.h
+arcnet.h
atime.awk
bootp.h
+bpf_dump.c
chdlc.h
config.guess
config.h.in
@@ -30,10 +32,13 @@ extract.h
fddi.h
gmt2local.c
gmt2local.h
+icmp6.h
+ieee802_11.h
igrp.h
install-sh
interface.h
ip.h
+ip6.h
ipsec_doi.h
ipx.h
isakmp.h
@@ -59,6 +64,7 @@ missing/resolv6.h
missing/resolv_ext.h
missing/snprintf.c
missing/sockstorage.h
+missing/strdup.c
missing/strlcat.c
missing/strlcpy.c
mkdep
@@ -73,14 +79,16 @@ ospf6.h
packetdat.awk
parsenfsfh.c
ppp.h
+print-802_11.c
print-ah.c
+print-arcnet.c
print-arp.c
print-ascii.c
print-atalk.c
print-atm.c
print-bgp.c
print-bootp.c
-print-bxxp.c
+print-beep.c
print-cdp.c
print-chdlc.c
print-cip.c
@@ -95,6 +103,7 @@ print-ether.c
print-fddi.c
print-frag6.c
print-gre.c
+print-hsrp.c
print-icmp.c
print-icmp6.c
print-igmp.c
@@ -111,7 +120,10 @@ print-l2tp.c
print-lane.c
print-lcp.c
print-llc.c
+print-lwres.c
print-mobile.c
+print-mpls.c
+print-msdp.c
print-netbios.c
print-nfs.c
print-ntp.c
@@ -121,12 +133,14 @@ print-ospf6.c
print-pim.c
print-ppp.c
print-pppoe.c
+print-pptp.c
print-radius.c
print-raw.c
print-rip.c
print-ripng.c
print-rt6.c
print-rx.c
+print-sctp.c
print-sl.c
print-sll.c
print-smb.c
@@ -142,15 +156,16 @@ print-udp.c
print-vjc.c
print-vrrp.c
print-wb.c
+print-zephyr.c
route6d.h
rx.h
-savestr.c
-savestr.h
+sctpConstants.h
+sctpHeader.h
send-ack.awk
setsignal.c
setsignal.h
-slip.h
slcompress.h
+slip.h
sll.h
smb.h
smbutil.c
@@ -159,6 +174,7 @@ strcasecmp.c
tcp.h
tcpdump.1
tcpdump.c
+telnet.h
timed.h
token.h
udp.h
diff --git a/contrib/tcpdump/Makefile.in b/contrib/tcpdump/Makefile.in
index 486e59f6c668..ec8750e45d63 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.244 2000/12/21 10:43:20 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.260 2001/12/10 08:21:23 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -65,22 +65,25 @@ INSTALL_DATA = @INSTALL_DATA@
@rm -f $@
$(CC) $(CFLAGS) -c $(srcdir)/$*.c
-CSRC = tcpdump.c \
- print-arp.c print-atalk.c print-atm.c print-bootp.c \
- print-decnet.c print-domain.c print-dvmrp.c print-egp.c \
- print-ether.c print-fddi.c print-gre.c print-icmp.c print-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-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-cnfp.c \
- print-vrrp.c print-cdp.c print-token.c print-bxxp.c print-timed.c \
- print-radius.c print-sll.c
+CSRC = addrtoname.c gmt2local.c machdep.c parsenfsfh.c \
+ print-802_11.c print-ah.c print-arcnet.c print-arp.c \
+ print-ascii.c print-atalk.c print-atm.c print-bgp.c \
+ print-bootp.c print-beep.c print-cdp.c print-chdlc.c \
+ print-cip.c print-cnfp.c print-decnet.c print-domain.c \
+ print-dvmrp.c print-egp.c print-esp.c print-ether.c \
+ print-fddi.c print-gre.c print-hsrp.c print-icmp.c \
+ print-igmp.c print-igrp.c print-ip.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-lwres.c \
+ print-msdp.c print-mobile.c print-mpls.c print-nfs.c \
+ print-ntp.c print-null.c print-ospf.c print-pim.c \
+ print-ppp.c print-pppoe.c print-pptp.c print-radius.c \
+ print-raw.c print-rip.c print-rx.c print-sctp.c \
+ print-sl.c print-sll.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 print-zephyr.c \
+ setsignal.c tcpdump.c util.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
@@ -94,7 +97,7 @@ 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 \
+ setsignal.h \
gnuc.h ipsec_doi.h isakmp.h l2tp.h nameser.h \
netbios.h oakley.h ospf6.h ppp.h route6d.h
diff --git a/contrib/tcpdump/PLATFORMS b/contrib/tcpdump/PLATFORMS
index 492911765f7e..2e1aedf773d4 100644
--- a/contrib/tcpdump/PLATFORMS
+++ b/contrib/tcpdump/PLATFORMS
@@ -1,5 +1,6 @@
== Tested platforms ==
-NetBSD 1.5/i386 (mcr - 2000/12/8)
+NetBSD 1.5/i386 (mcr - 2002/1/1)
+Debian Linux (woody/i386) (mcr - 2002/1/1)
---
RedHat Linux 6.1/i386 (assar)
diff --git a/contrib/tcpdump/README b/contrib/tcpdump/README
index 6d52e1f12823..bd6d1845770c 100644
--- a/contrib/tcpdump/README
+++ b/contrib/tcpdump/README
@@ -1,6 +1,6 @@
-@(#) $Header: /tcpdump/master/tcpdump/README,v 1.58.2.1 2001/04/11 05:27:42 guy Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/README,v 1.60 2002/01/21 11:16:33 mcr Exp $ (LBL)
-TCPDUMP 3.6.2
+TCPDUMP 3.7.1
Now maintained by "The Tcpdump Group"
See www.tcpdump.org
@@ -11,8 +11,8 @@ Anonymous CVS is available via:
(password "anoncvs")
cvs -d cvs.tcpdump.org:/tcpdump/master checkout tcpdump
-Version 3.6.2 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_6rel2":
- cvs -d cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_6rel2 tcpdump
+Version 3.7.1 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_7rel1":
+ cvs -d cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_7rel1 tcpdump
Please send patches against the master copy to patches@tcpdump.org.
diff --git a/contrib/tcpdump/VERSION b/contrib/tcpdump/VERSION
index 4a788a01dad4..a76ccff2a6e0 100644
--- a/contrib/tcpdump/VERSION
+++ b/contrib/tcpdump/VERSION
@@ -1 +1 @@
-3.6.3
+3.7.1
diff --git a/contrib/tcpdump/acconfig.h b/contrib/tcpdump/acconfig.h
index 6a033871e0bc..213b83333ede 100644
--- a/contrib/tcpdump/acconfig.h
+++ b/contrib/tcpdump/acconfig.h
@@ -62,6 +62,9 @@
/* define if you have both getipnodebyname() and getipnodebyaddr() */
#undef USE_GETIPNODEBY
+/* define if you have ether_ntohost() and it works */
+#undef USE_ETHER_NTOHOST
+
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@@ -84,3 +87,14 @@
#undef u_int16_t
#undef u_int32_t
#undef u_int8_t
+
+/* Whether or not to include the possibly-buggy SMB printer */
+#undef TCPDUMP_DO_SMB
+
+/* Long story short: aclocal.m4 depends on autoconf 2.13
+ * implementation details wrt "const"; newer versions
+ * have different implementation details so for now we
+ * put "const" here. This may cause duplicate definitions
+ * in config.h but that should be OK since they're the same.
+ */
+#undef const
diff --git a/contrib/tcpdump/addrtoname.h b/contrib/tcpdump/addrtoname.h
index 72e79b8db1d1..67ded6e69484 100644
--- a/contrib/tcpdump/addrtoname.h
+++ b/contrib/tcpdump/addrtoname.h
@@ -18,20 +18,21 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.16 1999/10/30 05:11:07 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.18 2001/09/17 21:57:51 fenner Exp $ (LBL)
*/
/* Name to address translation routines. */
-extern char *etheraddr_string(const u_char *);
-extern char *etherproto_string(u_short);
-extern char *tcpport_string(u_short);
-extern char *udpport_string(u_short);
-extern char *getname(const u_char *);
+extern const char *linkaddr_string(const u_char *, const unsigned int);
+extern const char *etheraddr_string(const u_char *);
+extern const char *etherproto_string(u_short);
+extern const char *tcpport_string(u_short);
+extern const char *udpport_string(u_short);
+extern const char *getname(const u_char *);
#ifdef INET6
-extern char *getname6(const u_char *);
+extern const char *getname6(const u_char *);
#endif
-extern char *intoa(u_int32_t);
+extern const char *intoa(u_int32_t);
extern void init_addrtoname(u_int32_t, u_int32_t);
extern struct hnamemem *newhnamemem(void);
diff --git a/contrib/tcpdump/arcnet.h b/contrib/tcpdump/arcnet.h
new file mode 100644
index 000000000000..89867e06ba29
--- /dev/null
+++ b/contrib/tcpdump/arcnet.h
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ *
+ * @(#) $Id: arcnet.h,v 1.1 2001/04/17 08:39:18 guy Exp $ (LBL)
+ *
+ * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
+ */
+
+/*
+ * Structure of a 2.5MB/s Arcnet header.
+ * as given to interface code.
+ */
+struct arc_header {
+ u_int8_t arc_shost;
+ u_int8_t arc_dhost;
+ u_int8_t arc_type;
+ /*
+ * only present for newstyle encoding with LL fragmentation.
+ * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
+ */
+ u_int8_t arc_flag;
+ u_int16_t arc_seqid;
+
+ /*
+ * only present in exception packets (arc_flag == 0xff)
+ */
+ u_int8_t arc_type2; /* same as arc_type */
+ u_int8_t arc_flag2; /* real flag value */
+ u_int16_t arc_seqid2; /* real seqid value */
+} __attribute__((__packed__));
+
+#define ARC_HDRLEN 3
+#define ARC_HDRNEWLEN 6
+#define ARC_HDRNEWLEN_EXC 10
+
+/* RFC 1051 */
+#define ARCTYPE_IP_OLD 240 /* IP protocol */
+#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
+
+/* RFC 1201 */
+#define ARCTYPE_IP 212 /* IP protocol */
+#define ARCTYPE_ARP 213 /* address resolution protocol */
+#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
+
+#define ARCTYPE_ATALK 221 /* Appletalk */
+#define ARCTYPE_BANIAN 247 /* Banyan Vines */
+#define ARCTYPE_IPX 250 /* Novell IPX */
+
+#define ARCTYPE_INET6 0xc4 /* IPng */
+#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
diff --git a/contrib/tcpdump/bootp.h b/contrib/tcpdump/bootp.h
index 49899de92b26..152d25177f81 100644
--- a/contrib/tcpdump/bootp.h
+++ b/contrib/tcpdump/bootp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.10 2000/12/03 23:42:23 fenner Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.11 2001/01/09 07:39:13 fenner Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@@ -148,6 +148,9 @@ struct bootp {
#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 2242 */
+#define TAG_NDS_IPDOMAIN ((u_int8_t) 62)
+#define TAG_NDS_IPINFO ((u_int8_t) 63)
/* RFC 2485 */
#define TAG_OPEN_GROUP_UAP ((u_int8_t) 98)
/* RFC 2563 */
diff --git a/contrib/tcpdump/config.guess b/contrib/tcpdump/config.guess
index 980ea5b09820..ba661651615d 100755
--- a/contrib/tcpdump/config.guess
+++ b/contrib/tcpdump/config.guess
@@ -1,9 +1,9 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
-timestamp='2000-12-15'
+timestamp='2001-04-20'
# 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
@@ -33,10 +33,6 @@ timestamp='2000-12-15'
#
# The plan is that this can be called by configure scripts if you
# 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,.*/,,'`
@@ -93,7 +89,7 @@ fi
dummy=dummy-$$
-trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
+trap 'rm -f $dummy.c $dummy.o $dummy.rel $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
@@ -107,7 +103,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in
CC_FOR_BUILD="$c"; break
fi
done
- rm -f $dummy.c $dummy.o
+ rm -f $dummy.c $dummy.o $dummy.rel
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found
fi
@@ -276,7 +272,7 @@ EOF
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
- SR2?01:HI-UX/MPP:*:*)
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
@@ -412,10 +408,13 @@ EOF
EOF
$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 && exit 0
rm -f $dummy.c $dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
@@ -463,9 +462,17 @@ EOF
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i?86:AIX:*:*)
+ i*86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
sed 's/^ //' << EOF >$dummy.c
@@ -479,7 +486,7 @@ EOF
exit(0);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $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
@@ -488,9 +495,9 @@ EOF
echo rs6000-ibm-aix3.2
fi
exit 0 ;;
- *:AIX:*:4)
+ *:AIX:*:[45])
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
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
@@ -498,23 +505,10 @@ EOF
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
- IBM_REV=4.${UNAME_RELEASE}
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
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 ;;
@@ -599,6 +593,10 @@ EOF
esac
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit 0 ;;
3050*:HI-UX:*:*)
sed 's/^ //' << EOF >$dummy.c
#include <unistd.h>
@@ -625,7 +623,7 @@ EOF
exit (0);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
@@ -644,7 +642,7 @@ EOF
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
- i?86:OSF1:*:*)
+ i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
@@ -701,18 +699,16 @@ EOF
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
- F300:UNIX_System_V:*:*)
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
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}"
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
- F301:UNIX_System_V:*:*)
- echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
- exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
- i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
sparc*:BSD/OS:*:*)
@@ -757,60 +753,38 @@ EOF
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. 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
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux
+ exit 0 ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ mips:Linux:*:*)
+ 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 -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ ;;
+ ppc:Linux:*:*)
+ # Determine Lib Version
+ cat >$dummy.c <<EOF
#include <features.h>
#if defined(__GLIBC__)
extern char __libc_version[];
@@ -823,143 +797,127 @@ main(argc, argv)
#if defined(__GLIBC__)
printf("%s %s\n", __libc_version, __libc_release);
#else
- printf("unkown\n");
+ printf("unknown\n");
#endif
return 0;
}
EOF
- LIBC=""
- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+ 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 ;;
+ alpha:Linux:*:*)
+ 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
- ./$dummy | grep 1\.99 > /dev/null
- if test "$?" = 0 ; then
- LIBC="libc1"
- fi
+ LIBC="libc1"
fi
- rm -f $dummy.c $dummy
- echo powerpc-unknown-linux-gnu${LIBC}
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit 0 ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # 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 ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit 0 ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit 0 ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit 0 ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # 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
+ i*86linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0
;;
- shelf_linux)
- echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ elf_i*86)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ i*86coff)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
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.
- # 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
+ # 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
#include <features.h>
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
@@ -983,16 +941,16 @@ EOF
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
- test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
- fi ;;
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+ ;;
# 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*:*)
+ i*86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
- i?86:UNIX_SV:4.2MP:2.*)
+ 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,
@@ -1000,7 +958,7 @@ EOF
# 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.*:*)
+ 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_REL}
@@ -1008,7 +966,7 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit 0 ;;
- i?86:*:5:7*)
+ i*86:*:5:7*)
# Fixed at (any) Pentium or better
UNAME_MACHINE=i586
if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
@@ -1017,7 +975,7 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- i?86:*:3.2:*)
+ i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
@@ -1035,7 +993,7 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
- i?86:*DOS:*:*)
+ i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
pc:*:*:*)
@@ -1074,21 +1032,24 @@ EOF
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
- m68*:LynxOS:2.*:*)
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
- i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
- rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+ rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
@@ -1188,11 +1149,29 @@ EOF
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;;
- i?86:OS/2:*:*)
+ 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 ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit 0 ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit 0 ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit 0 ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit 0 ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit 0 ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1284,11 +1263,24 @@ main ()
#endif
#if defined (vax)
-#if !defined (ultrix)
- printf ("vax-dec-bsd\n"); exit (0);
-#else
- printf ("vax-dec-ultrix\n"); exit (0);
-#endif
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
#endif
#if defined (alliant) && defined (i860)
@@ -1299,7 +1291,7 @@ main ()
}
EOF
-$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
# Apollos put the system type in the environment.
@@ -1335,8 +1327,9 @@ fi
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:
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
ftp://ftp.gnu.org/pub/gnu/config/
@@ -1345,7 +1338,7 @@ 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
+config.guess timestamp = $timestamp
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in
index 36926814960b..87eced89e8d6 100644
--- a/contrib/tcpdump/config.h.in
+++ b/contrib/tcpdump/config.h.in
@@ -14,10 +14,6 @@
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
-/* Define if your processor stores words with the most significant
- byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
-
/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
#undef HAVE_BUGGY_CAST128
@@ -60,8 +56,8 @@
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
-/* define if you have both getipnodebyname() and getipnodebyaddr() */
-#undef USE_GETIPNODEBY
+/* define if you have ether_ntohost() and it works */
+#undef USE_ETHER_NTOHOST
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@@ -86,6 +82,17 @@
#undef u_int32_t
#undef u_int8_t
+/* Whether or not to include the possibly-buggy SMB printer */
+#undef TCPDUMP_DO_SMB
+
+/* Long story short: aclocal.m4 depends on autoconf 2.13
+ * implementation details wrt "const"; newer versions
+ * have different implementation details so for now we
+ * put "const" here. This may cause duplicate definitions
+ * in config.h but that should be OK since they're the same.
+ */
+#undef const
+
/* The number of bytes in a char. */
#undef SIZEOF_CHAR
@@ -104,18 +111,9 @@
/* 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 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
@@ -146,6 +144,9 @@
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
+/* Define if you have the strdup function. */
+#undef HAVE_STRDUP
+
/* Define if you have the strlcat function. */
#undef HAVE_STRLCAT
@@ -182,24 +183,12 @@
/* 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
-
/* Define if you have the rpc library (-lrpc). */
#undef HAVE_LIBRPC
/* Define if you have the smi library (-lsmi). */
#undef HAVE_LIBSMI
-/* Define if you have the socket library (-lsocket). */
-#undef HAVE_LIBSOCKET
-
-/* Define if you have the str library (-lstr). */
-#undef HAVE_LIBSTR
-
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
diff --git a/contrib/tcpdump/config.sub b/contrib/tcpdump/config.sub
index 4849dfd81033..a06a480adafd 100755
--- a/contrib/tcpdump/config.sub
+++ b/contrib/tcpdump/config.sub
@@ -1,9 +1,9 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
-timestamp='2000-12-15'
+timestamp='2001-04-20'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -69,7 +69,7 @@ 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
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@@ -117,7 +117,7 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- nto-qnx* | linux-gnu* | storm-chaos*)
+ nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -226,12 +226,15 @@ case $basic_machine in
| alphaev6[78] \
| we32k | ns16k | clipper | i370 | sh | sh[34] \
| powerpc | powerpcle \
- | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+ | 1750a | dsp16xx | pdp10 | 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)
+ | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \
+ | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
+ | v850 | c4x \
+ | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
+ | pj | pjl | h8500)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
@@ -239,13 +242,13 @@ case $basic_machine in
basic_machine=$basic_machine-unknown
os=-none
;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65)
;;
# 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[234567]86 | x86_64)
+ i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@@ -255,7 +258,7 @@ case $basic_machine in
;;
# Recognize the basic CPU types with company name.
# FIXME: clean up the formatting here.
- vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ vax-* | tahoe-* | i*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-* \
@@ -268,15 +271,17 @@ case $basic_machine in
| alphaev6[78]-* \
| we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
| clipper-* | orion-* \
- | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
- | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+ | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
+ | mips16-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
| mipstx39-* | mipstx39el-* | mcore-* \
- | f30[01]-* | s390-* | sv1-* | t3e-* \
+ | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
+ | [cjt]90-* \
| m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
- | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
- | bs2000-* | tic54x-* | c54x-* | x86_64-*)
+ | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
+ | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -367,8 +372,8 @@ case $basic_machine in
basic_machine=cray2-cray
os=-unicos
;;
- [ctj]90-cray)
- basic_machine=c90-cray
+ [cjt]90)
+ basic_machine=${basic_machine}-cray
os=-unicos
;;
crds | unos)
@@ -424,6 +429,10 @@ case $basic_machine in
basic_machine=tron-gmicro
os=-sysv
;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
@@ -499,19 +508,19 @@ case $basic_machine in
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[34567]86v32)
+ i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
- i[34567]86v4*)
+ i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
- i[34567]86v)
+ i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
- i[34567]86sol2)
+ i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
@@ -523,18 +532,6 @@ case $basic_machine in
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
@@ -560,6 +557,10 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
miniframe)
basic_machine=m68000-convergent
;;
@@ -590,7 +591,7 @@ case $basic_machine in
os=-coff
;;
msdos)
- basic_machine=i386-unknown
+ basic_machine=i386-pc
os=-msdos
;;
mvs)
@@ -729,6 +730,10 @@ case $basic_machine in
ps2)
basic_machine=i386-ibm
;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@@ -919,6 +924,10 @@ case $basic_machine in
vax)
basic_machine=vax-dec
;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
pdp11)
basic_machine=pdp11-dec
;;
@@ -928,7 +937,7 @@ case $basic_machine in
sh3 | sh4)
basic_machine=sh-unknown
;;
- sparc | sparcv9)
+ sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
cydra)
@@ -950,6 +959,9 @@ case $basic_machine in
basic_machine=c4x-none
os=-coff
;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@@ -1009,12 +1021,13 @@ case $os in
| -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*)
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
- x86-* | i[34567]86-*)
+ x86-* | i*86-*)
;;
*)
os=-nto$os
@@ -1107,7 +1120,7 @@ case $os in
-xenix)
os=-xenix
;;
- -*mint | -*MiNT)
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-none)
@@ -1141,6 +1154,9 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
+ pdp10-*)
+ os=-tops20
+ ;;
pdp11-*)
os=-none
;;
@@ -1249,7 +1265,7 @@ case $basic_machine in
*-masscomp)
os=-rtu
;;
- f30[01]-fujitsu)
+ f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
@@ -1327,7 +1343,7 @@ case $basic_machine in
-mpw* | -macos*)
vendor=apple
;;
- -*mint | -*MiNT)
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
esac
diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure
index bb8eb99b5cda..5c4e84f0bb25 100755
--- a/contrib/tcpdump/configure
+++ b/contrib/tcpdump/configure
@@ -1,6 +1,6 @@
#! /bin/sh
-# From configure.in Revision: 1.132.4.1
+# From configure.in Revision: 1.145
@@ -76,6 +76,9 @@ ac_default_prefix=/usr/local
ac_help="$ac_help
--without-gcc don't use gcc"
ac_help="$ac_help
+ --enable-smb enable possibly-buggy SMB printer [default=yes]
+ --disable-smb disable possibly-buggy SMB printer"
+ac_help="$ac_help
--enable-ipv6 enable ipv6 (with ipv4) support
--disable-ipv6 disable ipv6 support"
ac_help="$ac_help
@@ -611,34 +614,13 @@ ac_config_sub=$ac_aux_dir/config.sub
ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
-# Do some error checking and defaulting for the host and target type.
-# The inputs are:
-# configure --host=HOST --target=TARGET --build=BUILD NONOPT
-#
-# The rules are:
-# 1. You are not allowed to specify --host, --target, and nonopt at the
-# same time.
-# 2. Host defaults to nonopt.
-# 3. If nonopt is not specified, then host defaults to the current host,
-# as determined by config.guess.
-# 4. Target and build default to nonopt.
-# 5. If nonopt is not specified, then target and build default to host.
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-case $host---$target---$nonopt in
-NONE---*---* | *---NONE---* | *---*---NONE) ;;
-*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
-esac
-
-
# Make sure we can run config.sub.
if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
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:642: checking host system type" >&5
+echo "configure:624: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -658,47 +640,6 @@ host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
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:663: checking target system type" >&5
-
-target_alias=$target
-case "$target_alias" in
-NONE)
- case $nonopt in
- NONE) target_alias=$host_alias ;;
- *) target_alias=$nonopt ;;
- esac ;;
-esac
-
-target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
-target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-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:681: checking build system type" >&5
-
-build_alias=$build
-case "$build_alias" in
-NONE)
- case $nonopt in
- NONE) build_alias=$host_alias ;;
- *) build_alias=$nonopt ;;
- esac ;;
-esac
-
-build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
-build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$build" 1>&6
-
-test "$host_alias" != "$target_alias" &&
- test "$program_prefix$program_suffix$program_transform_name" = \
- NONENONEs,x,x, &&
- program_prefix=${target_alias}-
-
@@ -719,13 +660,13 @@ fi
LBL_CFLAGS="$CFLAGS"
fi
if test -z "$CC" ; then
- case "$target_os" in
+ case "$host_os" in
bsdi*)
# 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:729: checking for $ac_word" >&5
+echo "configure:670: 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
@@ -766,7 +707,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:770: checking for $ac_word" >&5
+echo "configure:711: 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
@@ -796,7 +737,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:800: checking for $ac_word" >&5
+echo "configure:741: 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
@@ -847,7 +788,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:851: checking for $ac_word" >&5
+echo "configure:792: 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
@@ -879,7 +820,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:883: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:824: 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.
@@ -890,12 +831,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 894 "configure"
+#line 835 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:840: \"$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
@@ -921,12 +862,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:925: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:866: 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:930: checking whether we are using GNU C" >&5
+echo "configure:871: 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
@@ -935,7 +876,7 @@ else
yes;
#endif
EOF
-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
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:880: \"$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
@@ -954,7 +895,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:958: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:899: 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
@@ -991,7 +932,7 @@ fi
V_CCOPT="-O2"
else
echo $ac_n "checking gcc version""... $ac_c" 1>&6
-echo "configure:995: checking gcc version" >&5
+echo "configure:936: 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
@@ -1009,19 +950,19 @@ fi
fi
else
echo $ac_n "checking that $CC handles ansi prototypes""... $ac_c" 1>&6
-echo "configure:1013: checking that $CC handles ansi prototypes" >&5
+echo "configure:954: 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 1018 "configure"
+#line 959 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
int frob(int, char *)
; return 0; }
EOF
-if { (eval echo configure:1025: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:966: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_ansi_prototypes=yes
else
@@ -1035,25 +976,25 @@ fi
echo "$ac_t""$ac_cv_lbl_cc_ansi_prototypes" 1>&6
if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
- case "$target_os" in
+ case "$host_os" in
hpux*)
echo $ac_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)""... $ac_c" 1>&6
-echo "configure:1043: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
+echo "configure:984: 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 1050 "configure"
+#line 991 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
int frob(int, char *)
; return 0; }
EOF
-if { (eval echo configure:1057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:998: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_hpux_cc_aa=yes
else
@@ -1085,24 +1026,24 @@ EOF
V_INCLS="$V_INCLS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
- case "$target_os" in
+ case "$host_os" in
irix*)
- V_CCOPT="$V_CCOPT -xansi -signed -g3"
+ V_CCOPT="$V_CCOPT -xansi -signed -O"
;;
osf*)
- V_CCOPT="$V_CCOPT -std1 -g3"
+ V_CCOPT="$V_CCOPT -std1 -O"
;;
ultrix*)
echo $ac_n "checking that Ultrix $CC hacks const in prototypes""... $ac_c" 1>&6
-echo "configure:1101: checking that Ultrix $CC hacks const in prototypes" >&5
+echo "configure:1042: 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 1106 "configure"
+#line 1047 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
@@ -1110,7 +1051,7 @@ struct a { int b; };
void c(const struct a *)
; return 0; }
EOF
-if { (eval echo configure:1114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1055: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_const_proto=yes
else
@@ -1134,21 +1075,21 @@ EOF
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1138: checking for inline" >&5
+echo "configure:1079: 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 1145 "configure"
+#line 1086 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:1152: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1093: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
@@ -1175,13 +1116,13 @@ esac
echo $ac_n "checking for __attribute__""... $ac_c" 1>&6
-echo "configure:1179: checking for __attribute__" >&5
+echo "configure:1120: 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"
+#line 1126 "configure"
#include "confdefs.h"
#include <stdlib.h>
@@ -1198,7 +1139,7 @@ foo(void)
; return 0; }
EOF
-if { (eval echo configure:1202: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1143: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv___attribute__=yes
else
@@ -1220,7 +1161,7 @@ echo "$ac_t""$ac_cv___attribute__" 1>&6
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1224: checking how to run the C preprocessor" >&5
+echo "configure:1165: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1235,13 +1176,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 1239 "configure"
+#line 1180 "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:1245: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1186: \"$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
:
@@ -1252,13 +1193,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1256 "configure"
+#line 1197 "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:1262: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1203: \"$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
:
@@ -1269,13 +1210,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1273 "configure"
+#line 1214 "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:1279: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1220: \"$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
:
@@ -1303,17 +1244,17 @@ 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:1307: checking for $ac_hdr" >&5
+echo "configure:1248: 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 1312 "configure"
+#line 1253 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1317: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1258: \"$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*
@@ -1340,12 +1281,12 @@ fi
done
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1344: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1285: 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 1349 "configure"
+#line 1290 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -1354,7 +1295,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1358: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1299: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -1375,11 +1316,11 @@ EOF
fi
-case "$target_os" in
+case "$host_os" in
linux*)
echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6
-echo "configure:1383: checking Linux kernel version" >&5
+echo "configure:1324: 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
@@ -1414,17 +1355,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:1418: checking for $ac_hdr" >&5
+echo "configure:1359: 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 1423 "configure"
+#line 1364 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1369: \"$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*
@@ -1451,7 +1392,7 @@ fi
done
echo $ac_n "checking for smiInit in -lsmi""... $ac_c" 1>&6
-echo "configure:1455: checking for smiInit in -lsmi" >&5
+echo "configure:1396: 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
@@ -1459,7 +1400,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsmi $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1463 "configure"
+#line 1404 "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
@@ -1470,7 +1411,7 @@ int main() {
smiInit()
; return 0; }
EOF
-if { (eval echo configure:1474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1415: \"$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
@@ -1497,15 +1438,17 @@ else
echo "$ac_t""no" 1>&6
fi
+if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
+then
echo $ac_n "checking whether to enable libsmi""... $ac_c" 1>&6
-echo "configure:1502: checking whether to enable libsmi" >&5
+echo "configure:1445: checking whether to enable libsmi" >&5
if test "$cross_compiling" = yes; then
echo "$ac_t""not when cross-compiling" 1>&6
libsmi=no
else
cat > conftest.$ac_ext <<EOF
-#line 1509 "configure"
+#line 1452 "configure"
#include "confdefs.h"
/* libsmi available check */
#include <smi.h>
@@ -1526,7 +1469,7 @@ main()
}
EOF
-if { (eval echo configure:1530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1473: \"$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
@@ -1538,17 +1481,46 @@ else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -fr conftest*
- echo "$ac_t""no" 1>&6
+ case $? in
+ 1) echo "$ac_t""no - smiInit failed" 1>&6 ;;
+ 2) echo "$ac_t""no - header/library version mismatch" 1>&6 ;;
+ 3) echo "$ac_t""no - can't determine library version" 1>&6 ;;
+ 4) echo "$ac_t""no - too old" 1>&6 ;;
+ *) echo "$ac_t""no" 1>&6 ;;
+ esac
libsmi=no
fi
rm -fr conftest*
fi
+fi
+echo $ac_n "checking whether to enable the possibly-buggy SMB printer""... $ac_c" 1>&6
+echo "configure:1500: checking whether to enable the possibly-buggy SMB printer" >&5
+# Check whether --enable-smb or --disable-smb was given.
+if test "${enable_smb+set}" = set; then
+ enableval="$enable_smb"
+ :
+else
+ enableval=yes
+fi
+
+case "$enableval" in
+yes) echo "$ac_t""yes" 1>&6
+ echo "configure: warning: The SMB printer may have exploitable buffer overflows!!!" 1>&2
+ cat >> confdefs.h <<\EOF
+#define TCPDUMP_DO_SMB 1
+EOF
+
+ LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
+ ;;
+*) echo "$ac_t""no" 1>&6
+ ;;
+esac
CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6
-echo "configure:1552: checking whether to enable ipv6" >&5
+echo "configure:1524: 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"
@@ -1573,7 +1545,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 1577 "configure"
+#line 1549 "configure"
#include "confdefs.h"
/* AF_INET6 available check */
#include <sys/types.h>
@@ -1587,7 +1559,7 @@ main()
}
EOF
-if { (eval echo configure:1591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1563: \"$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
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"
@@ -1615,12 +1587,12 @@ ipv6trylibc=no
if test "$ipv6" = "yes"; then
echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6
-echo "configure:1619: checking ipv6 stack type" >&5
+echo "configure:1591: 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 1624 "configure"
+#line 1596 "configure"
#include "confdefs.h"
dnl
#include <netinet/in.h>
@@ -1639,7 +1611,7 @@ rm -f conftest*
;;
kame)
cat > conftest.$ac_ext <<EOF
-#line 1643 "configure"
+#line 1615 "configure"
#include "confdefs.h"
dnl
#include <netinet/in.h>
@@ -1661,7 +1633,7 @@ rm -f conftest*
;;
linux-glibc)
cat > conftest.$ac_ext <<EOF
-#line 1665 "configure"
+#line 1637 "configure"
#include "confdefs.h"
dnl
#include <features.h>
@@ -1689,7 +1661,7 @@ rm -f conftest*
;;
toshiba)
cat > conftest.$ac_ext <<EOF
-#line 1693 "configure"
+#line 1665 "configure"
#include "confdefs.h"
dnl
#include <sys/param.h>
@@ -1710,7 +1682,7 @@ rm -f conftest*
;;
v6d)
cat > conftest.$ac_ext <<EOF
-#line 1714 "configure"
+#line 1686 "configure"
#include "confdefs.h"
dnl
#include </usr/local/v6/include/sys/v6config.h>
@@ -1731,7 +1703,7 @@ rm -f conftest*
;;
zeta)
cat > conftest.$ac_ext <<EOF
-#line 1735 "configure"
+#line 1707 "configure"
#include "confdefs.h"
dnl
#include <sys/param.h>
@@ -1778,14 +1750,14 @@ fi
if test "$ipv6" = "yes"; then
echo $ac_n "checking for library containing getaddrinfo""... $ac_c" 1>&6
-echo "configure:1782: checking for library containing getaddrinfo" >&5
+echo "configure:1754: 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
ac_func_search_save_LIBS="$LIBS"
ac_cv_search_getaddrinfo="no"
cat > conftest.$ac_ext <<EOF
-#line 1789 "configure"
+#line 1761 "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
@@ -1796,7 +1768,7 @@ int main() {
getaddrinfo()
; return 0; }
EOF
-if { (eval echo configure:1800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_search_getaddrinfo="none required"
else
@@ -1807,7 +1779,7 @@ 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"
+#line 1783 "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
@@ -1818,7 +1790,7 @@ 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
+if { (eval echo configure:1794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_search_getaddrinfo="-l$i"
break
@@ -1835,13 +1807,13 @@ 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
+echo "configure:1811: 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 1845 "configure"
+#line 1817 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -1938,7 +1910,7 @@ main()
}
EOF
-if { (eval echo configure:1942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1914: \"$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
@@ -1970,12 +1942,12 @@ fi
for ac_func in getaddrinfo getnameinfo
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1974: checking for $ac_func" >&5
+echo "configure:1946: 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 1979 "configure"
+#line 1951 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1998,7 +1970,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1974: \"$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
@@ -2026,9 +1998,9 @@ done
fi
echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
-echo "configure:2030: checking for inet_ntop" >&5
+echo "configure:2002: checking for inet_ntop" >&5
cat > conftest.$ac_ext <<EOF
-#line 2032 "configure"
+#line 2004 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -2039,7 +2011,7 @@ 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
+if { (eval echo configure:2015: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
@@ -2050,12 +2022,12 @@ else
for ac_func in inet_ntop
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2054: checking for $ac_func" >&5
+echo "configure:2026: 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 2059 "configure"
+#line 2031 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2078,7 +2050,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2054: \"$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
@@ -2107,9 +2079,9 @@ done
fi
rm -f conftest*
echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
-echo "configure:2111: checking for inet_pton" >&5
+echo "configure:2083: checking for inet_pton" >&5
cat > conftest.$ac_ext <<EOF
-#line 2113 "configure"
+#line 2085 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -2120,7 +2092,7 @@ 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
+if { (eval echo configure:2096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
@@ -2131,12 +2103,12 @@ else
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
+echo "configure:2107: 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"
+#line 2112 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2159,7 +2131,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2135: \"$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
@@ -2188,9 +2160,9 @@ done
fi
rm -f conftest*
echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
-echo "configure:2192: checking for inet_aton" >&5
+echo "configure:2164: checking for inet_aton" >&5
cat > conftest.$ac_ext <<EOF
-#line 2194 "configure"
+#line 2166 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <netinet/in.h>
@@ -2201,7 +2173,7 @@ 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
+if { (eval echo configure:2177: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
@@ -2212,12 +2184,12 @@ else
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
+echo "configure:2188: 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 2221 "configure"
+#line 2193 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2240,7 +2212,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2216: \"$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
@@ -2271,12 +2243,12 @@ rm -f conftest*
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
+echo "configure:2247: 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 2280 "configure"
+#line 2252 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2285,7 +2257,7 @@ int main() {
u_int i = sizeof(((struct sockaddr *)0)->sa_len)
; return 0; }
EOF
-if { (eval echo configure:2289: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2261: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_sockaddr_has_sa_len=yes
else
@@ -2310,7 +2282,7 @@ if test "$ac_cv_sockaddr_has_sa_len" = no; then
fi
echo $ac_n "checking size of char""... $ac_c" 1>&6
-echo "configure:2314: checking size of char" >&5
+echo "configure:2286: 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
@@ -2318,7 +2290,7 @@ else
ac_cv_sizeof_char=1
else
cat > conftest.$ac_ext <<EOF
-#line 2322 "configure"
+#line 2294 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2329,7 +2301,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2305: \"$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
@@ -2349,7 +2321,7 @@ EOF
echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:2353: checking size of short" >&5
+echo "configure:2325: 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
@@ -2357,7 +2329,7 @@ else
ac_cv_sizeof_short=2
else
cat > conftest.$ac_ext <<EOF
-#line 2361 "configure"
+#line 2333 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2368,7 +2340,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2344: \"$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
@@ -2388,7 +2360,7 @@ EOF
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:2392: checking size of int" >&5
+echo "configure:2364: 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
@@ -2396,7 +2368,7 @@ else
ac_cv_sizeof_int=4
else
cat > conftest.$ac_ext <<EOF
-#line 2400 "configure"
+#line 2372 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2407,7 +2379,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2383: \"$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
@@ -2427,7 +2399,7 @@ EOF
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:2431: checking size of long" >&5
+echo "configure:2403: 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
@@ -2435,7 +2407,7 @@ else
ac_cv_sizeof_long=4
else
cat > conftest.$ac_ext <<EOF
-#line 2439 "configure"
+#line 2411 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -2446,7 +2418,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2422: \"$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
@@ -2469,12 +2441,12 @@ EOF
echo $ac_n "checking for addrinfo""... $ac_c" 1>&6
-echo "configure:2473: checking for addrinfo" >&5
+echo "configure:2445: 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 2478 "configure"
+#line 2450 "configure"
#include "confdefs.h"
# include <netdb.h>
@@ -2482,7 +2454,7 @@ int main() {
struct addrinfo a
; return 0; }
EOF
-if { (eval echo configure:2486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2458: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_addrinfo=yes
else
@@ -2513,12 +2485,12 @@ fi
echo $ac_n "checking for NI_MAXSERV""... $ac_c" 1>&6
-echo "configure:2517: checking for NI_MAXSERV" >&5
+echo "configure:2489: 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 2522 "configure"
+#line 2494 "configure"
#include "confdefs.h"
#include <netdb.h>
#ifdef NI_MAXSERV
@@ -2551,12 +2523,12 @@ fi
echo $ac_n "checking for NI_NAMEREQD""... $ac_c" 1>&6
-echo "configure:2555: checking for NI_NAMEREQD" >&5
+echo "configure:2527: 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 2560 "configure"
+#line 2532 "configure"
#include "confdefs.h"
#include <netdb.h>
#ifdef NI_NOFQDN
@@ -2589,12 +2561,12 @@ fi
echo $ac_n "checking for sockaddr_storage""... $ac_c" 1>&6
-echo "configure:2593: checking for sockaddr_storage" >&5
+echo "configure:2565: 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 2598 "configure"
+#line 2570 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2603,7 +2575,7 @@ int main() {
struct sockaddr_storage s
; return 0; }
EOF
-if { (eval echo configure:2607: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2579: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_sa_storage=yes
else
@@ -2630,12 +2602,12 @@ fi
ac_cv_addrsz=yes
echo $ac_n "checking for INADDRSZ""... $ac_c" 1>&6
-echo "configure:2634: checking for INADDRSZ" >&5
+echo "configure:2606: 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 2639 "configure"
+#line 2611 "configure"
#include "confdefs.h"
# include <arpa/nameser.h>
@@ -2643,7 +2615,7 @@ int main() {
int a = INADDRSZ
; return 0; }
EOF
-if { (eval echo configure:2647: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2619: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_inaddrsz=yes
else
@@ -2665,12 +2637,12 @@ EOF
ac_cv_addrsz=no
fi
echo $ac_n "checking for IN6ADDRSZ""... $ac_c" 1>&6
-echo "configure:2669: checking for IN6ADDRSZ" >&5
+echo "configure:2641: 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 2674 "configure"
+#line 2646 "configure"
#include "confdefs.h"
# include <arpa/nameser.h>
@@ -2678,7 +2650,7 @@ int main() {
int a = IN6ADDRSZ
; return 0; }
EOF
-if { (eval echo configure:2682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_in6addrsz=yes
else
@@ -2706,12 +2678,12 @@ fi
echo $ac_n "checking for RES_USE_INET6""... $ac_c" 1>&6
-echo "configure:2710: checking for RES_USE_INET6" >&5
+echo "configure:2682: 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 2715 "configure"
+#line 2687 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2721,7 +2693,7 @@ int main() {
int a = RES_USE_INET6
; return 0; }
EOF
-if { (eval echo configure:2725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2697: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_res_inet6=yes
else
@@ -2747,12 +2719,12 @@ fi
echo $ac_n "checking for res_state_ext""... $ac_c" 1>&6
-echo "configure:2751: checking for res_state_ext" >&5
+echo "configure:2723: 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 2756 "configure"
+#line 2728 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2763,7 +2735,7 @@ int main() {
struct __res_state_ext e
; return 0; }
EOF
-if { (eval echo configure:2767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_res_state_ext=yes
else
@@ -2789,12 +2761,12 @@ fi
echo $ac_n "checking for nsort in res_state""... $ac_c" 1>&6
-echo "configure:2793: checking for nsort in res_state" >&5
+echo "configure:2765: 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 2798 "configure"
+#line 2770 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2805,7 +2777,7 @@ int main() {
struct __res_state e; e.nsort = 0
; return 0; }
EOF
-if { (eval echo configure:2809: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2781: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_res_state=yes
else
@@ -2832,15 +2804,15 @@ if test "$missing_includes" = "yes"; then
fi
-for ac_func in vfprintf strcasecmp strlcat strlcpy
+for ac_func in vfprintf strcasecmp strlcat strlcpy strdup
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2839: checking for $ac_func" >&5
+echo "configure:2811: 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 2844 "configure"
+#line 2816 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2863,7 +2835,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2839: \"$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
@@ -2889,15 +2861,15 @@ fi
done
-for ac_func in ether_ntohost setlinebuf
+for ac_func in ether_ntohost
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2896: checking for $ac_func" >&5
+echo "configure:2868: 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 2901 "configure"
+#line 2873 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2920,7 +2892,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2896: \"$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
@@ -2939,22 +2911,71 @@ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
#define $ac_tr_func 1
EOF
+ echo $ac_n "checking for buggy ether_ntohost""... $ac_c" 1>&6
+echo "configure:2916: checking for buggy ether_ntohost" >&5
+if eval "test \"`echo '$''{'ac_cv_buggy_ether_ntohost'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ if test "$cross_compiling" = yes; then
+ ac_cv_buggy_ether_ntohost=not while cross-compiling
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2925 "configure"
+#include "confdefs.h"
+
+ #include <netdb.h>
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+
+ int
+ main(int argc, char **argv)
+ {
+ u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
+ char name[MAXHOSTNAMELEN];
+
+ ether_ntohost(name, (struct ether_addr *)ea);
+ exit(0);
+ }
+
+EOF
+if { (eval echo configure:2944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_buggy_ether_ntohost=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_buggy_ether_ntohost=yes
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_buggy_ether_ntohost" 1>&6
+ if test "$ac_cv_buggy_ether_ntohost" = "no"; then
+ cat >> confdefs.h <<\EOF
+#define USE_ETHER_NTOHOST 1
+EOF
+
+ fi
+
else
echo "$ac_t""no" 1>&6
fi
done
-
-usegetipnodeby=yes
-for ac_func in getipnodebyname getipnodebyaddr freeaddrinfo
+for ac_func in setlinebuf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2953: checking for $ac_func" >&5
+echo "configure:2974: 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"
+#line 2979 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2977,7 +2998,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3002: \"$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
@@ -2998,27 +3019,20 @@ 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
+echo "configure:3031: 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"
+#line 3036 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3041,7 +3055,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3059: \"$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
@@ -3070,239 +3084,14 @@ 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: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 3082 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-int main() {
-
-#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
- bogus endian macros
-#endif
-; return 0; }
-EOF
-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 3097 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-int main() {
-
-#if BYTE_ORDER != BIG_ENDIAN
- not big endian
-#endif
-; return 0; }
-EOF
-if { (eval echo configure:3108: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_c_bigendian=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_c_bigendian=no
-fi
-rm -f conftest*
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
-fi
-rm -f conftest*
-if test $ac_cv_c_bigendian = unknown; then
-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 3128 "configure"
-#include "confdefs.h"
-main () {
- /* Are we little or big endian? From Harbison&Steele. */
- union
- {
- long l;
- char c[sizeof (long)];
- } u;
- u.l = 1;
- exit (u.c[sizeof (long) - 1] == 1);
-}
-EOF
-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
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_c_bigendian=yes
-fi
-rm -fr conftest*
-fi
-
-fi
-fi
-
-echo "$ac_t""$ac_cv_c_bigendian" 1>&6
-if test $ac_cv_c_bigendian = yes; then
- cat >> confdefs.h <<\EOF
-#define WORDS_BIGENDIAN 1
-EOF
-
-fi
-
-
-echo $ac_n "checking for main in -ldnet""... $ac_c" 1>&6
-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
-else
- ac_save_LIBS="$LIBS"
-LIBS="-ldnet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3174 "configure"
-#include "confdefs.h"
-
-int main() {
-main()
-; return 0; }
-EOF
-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
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-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 dnet | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
-
- LIBS="-ldnet $LIBS"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for main in -lrpc""... $ac_c" 1>&6
-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
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lrpc $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3217 "configure"
-#include "confdefs.h"
-
-int main() {
-main()
-; return 0; }
-EOF
-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
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-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 rpc | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
-
- LIBS="-lrpc $LIBS"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-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="-lnsl $LIBS"
-cat > conftest.$ac_ext <<EOF
-#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 getrpcbynumber();
-
-int main() {
-getrpcbynumber()
-; return 0; }
-EOF
-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
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-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 nsl | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
-
- LIBS="-lnsl $LIBS"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3301: checking return type of signal handlers" >&5
+echo "configure:3090: 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 3306 "configure"
+#line 3095 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -3319,7 +3108,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:3323: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -3348,7 +3137,7 @@ EOF
EOF
fi
- case "$target_os" in
+ case "$host_os" in
irix*)
cat >> confdefs.h <<\EOF
@@ -3361,12 +3150,12 @@ EOF
for ac_func in sigset
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3365: checking for $ac_func" >&5
+echo "configure:3154: 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 3370 "configure"
+#line 3159 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3389,7 +3178,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3393: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3182: \"$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
@@ -3417,12 +3206,12 @@ done
for ac_func in sigaction
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3421: checking for $ac_func" >&5
+echo "configure:3210: 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 3426 "configure"
+#line 3215 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3445,7 +3234,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3238: \"$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
@@ -3473,160 +3262,176 @@ done
;;
esac
-
- # 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:3481: checking for gethostbyname" >&5
-if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
+echo $ac_n "checking for dnet_htoa in -ldnet""... $ac_c" 1>&6
+echo "configure:3267: checking for dnet_htoa in -ldnet" >&5
+ac_lib_var=`echo dnet'_'dnet_htoa | 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
- cat > conftest.$ac_ext <<EOF
-#line 3486 "configure"
+ ac_save_LIBS="$LIBS"
+LIBS="-ldnet $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3275 "configure"
#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char gethostbyname(); 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 gethostbyname();
+char dnet_htoa();
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_gethostbyname) || defined (__stub___gethostbyname)
-choke me
-#else
-gethostbyname();
-#endif
-
+dnet_htoa()
; 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:3286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
- eval "ac_cv_func_gethostbyname=yes"
+ eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
- eval "ac_cv_func_gethostbyname=no"
+ eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
-fi
+LIBS="$ac_save_LIBS"
-if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then
+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 dnet | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-ldnet $LIBS"
+
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: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
+fi
+
+
+echo $ac_n "checking for main in -lrpc""... $ac_c" 1>&6
+echo "configure:3315: 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
else
ac_save_LIBS="$LIBS"
-LIBS="-lnsl $LIBS"
+LIBS="-lrpc $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3536 "configure"
+#line 3323 "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 gethostbyname();
int main() {
-gethostbyname()
+main()
; return 0; }
EOF
-if { (eval echo configure:3547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3330: \"$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"
+ eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
- eval "ac_cv_lbl_lib_$ac_lib_var=no"
+ eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
-if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo nsl | sed -e 's/^a-zA-Z0-9_/_/g' \
+ ac_tr_lib=HAVE_LIB`echo rpc | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
cat >> confdefs.h <<EOF
#define $ac_tr_lib 1
EOF
- LIBS="-lnsl $LIBS"
+ LIBS="-lrpc $LIBS"
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: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
+fi
+
+
+echo $ac_n "checking for library containing getrpcbynumber""... $ac_c" 1>&6
+echo "configure:3359: checking for library containing getrpcbynumber" >&5
+if eval "test \"`echo '$''{'ac_cv_search_getrpcbynumber'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- ac_save_LIBS="$LIBS"
-LIBS="-lsocket $LIBS"
+ ac_func_search_save_LIBS="$LIBS"
+ac_cv_search_getrpcbynumber="no"
cat > conftest.$ac_ext <<EOF
-#line 3582 "configure"
+#line 3366 "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 gethostbyname();
+char getrpcbynumber();
int main() {
-gethostbyname()
+getrpcbynumber()
; return 0; }
EOF
-if { (eval echo configure:3593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3377: \"$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"
+ ac_cv_search_getrpcbynumber="none required"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+test "$ac_cv_search_getrpcbynumber" = "no" && for i in nsl; do
+LIBS="-l$i $ac_func_search_save_LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3388 "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 getrpcbynumber();
+
+int main() {
+getrpcbynumber()
+; return 0; }
+EOF
+if { (eval echo configure:3399: \"$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=no"
+ ac_cv_search_getrpcbynumber="-l$i"
+break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
fi
rm -f conftest*
-LIBS="$ac_save_LIBS"
+done
+LIBS="$ac_func_search_save_LIBS"
+fi
+echo "$ac_t""$ac_cv_search_getrpcbynumber" 1>&6
+if test "$ac_cv_search_getrpcbynumber" != "no"; then
+ test "$ac_cv_search_getrpcbynumber" = "none required" || LIBS="$ac_cv_search_getrpcbynumber $LIBS"
+
+else :
+
fi
-if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/^a-zA-Z0-9_/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
- LIBS="-lsocket $LIBS"
-else
- echo "$ac_t""no" 1>&6
-# Unfortunately libsocket sometimes depends on libnsl.
- # 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: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
+
+ # Most operating systems have gethostbyname() in the default searched
+ # libraries (i.e. libc):
+ # Some OSes (eg. Solaris) place it in libnsl
+ # Some strange OSes (SINIX) have it in libsocket:
+
+echo $ac_n "checking for library containing gethostbyname""... $ac_c" 1>&6
+echo "configure:3428: checking for library containing gethostbyname" >&5
+if eval "test \"`echo '$''{'ac_cv_search_gethostbyname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- ac_save_LIBS="$LIBS"
-LIBS="-lsocket -lnsl $LIBS"
+ ac_func_search_save_LIBS="$LIBS"
+ac_cv_search_gethostbyname="no"
cat > conftest.$ac_ext <<EOF
-#line 3630 "configure"
+#line 3435 "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
@@ -3637,34 +3442,62 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:3641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3446: \"$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"
+ ac_cv_search_gethostbyname="none required"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+test "$ac_cv_search_gethostbyname" = "no" && for i in nsl socket resolv; do
+LIBS="-l$i $ac_func_search_save_LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3457 "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 gethostbyname();
+
+int main() {
+gethostbyname()
+; return 0; }
+EOF
+if { (eval echo configure:3468: \"$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=no"
+ ac_cv_search_gethostbyname="-l$i"
+break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
fi
rm -f conftest*
-LIBS="$ac_save_LIBS"
+done
+LIBS="$ac_func_search_save_LIBS"
+fi
+echo "$ac_t""$ac_cv_search_gethostbyname" 1>&6
+if test "$ac_cv_search_gethostbyname" != "no"; then
+ test "$ac_cv_search_gethostbyname" = "none required" || LIBS="$ac_cv_search_gethostbyname $LIBS"
+
+else :
+
fi
-if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="-lsocket -lnsl $LIBS"
-else
- echo "$ac_t""no" 1>&6
-echo $ac_n "checking for gethostbyname in -lresolv""... $ac_c" 1>&6
-echo "configure:3660: checking for gethostbyname in -lresolv" >&5
-ac_lib_var=`echo resolv'_'gethostbyname | sed 'y%./+-%__p_%'`
+ # Unfortunately libsocket sometimes depends on libnsl and
+ # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
+ if test "$ac_cv_search_gethostbyname" = "no"
+ then
+ echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6
+echo "configure:3493: checking for gethostbyname in -lsocket" >&5
+ac_lib_var=`echo socket'_'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
else
ac_save_LIBS="$LIBS"
-LIBS="-lresolv $LIBS"
+LIBS="-lsocket -lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3668 "configure"
+#line 3501 "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
@@ -3675,7 +3508,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:3679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3512: \"$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
@@ -3690,82 +3523,44 @@ 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 resolv | sed -e 's/^a-zA-Z0-9_/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
-
- LIBS="-lresolv $LIBS"
-
+ LIBS="-lsocket -lnsl $LIBS"
else
echo "$ac_t""no" 1>&6
fi
-fi
-
-fi
-
-fi
-
-fi
-
- echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:3715: checking for socket" >&5
-if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
+ fi
+
+echo $ac_n "checking for library containing socket""... $ac_c" 1>&6
+echo "configure:3535: checking for library containing socket" >&5
+if eval "test \"`echo '$''{'ac_cv_search_socket'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- cat > conftest.$ac_ext <<EOF
-#line 3720 "configure"
+ ac_func_search_save_LIBS="$LIBS"
+ac_cv_search_socket="no"
+cat > conftest.$ac_ext <<EOF
+#line 3542 "configure"
#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char socket(); 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 socket();
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_socket) || defined (__stub___socket)
-choke me
-#else
-socket();
-#endif
-
+socket()
; return 0; }
EOF
-if { (eval echo configure:3743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
- eval "ac_cv_func_socket=yes"
+ ac_cv_search_socket="none required"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_socket=no"
fi
rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-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
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lsocket $LIBS"
+test "$ac_cv_search_socket" = "no" && for i in socket; do
+LIBS="-l$i $ac_func_search_save_LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3769 "configure"
+#line 3564 "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
@@ -3776,41 +3571,34 @@ int main() {
socket()
; return 0; }
EOF
-if { (eval echo configure:3780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3575: \"$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"
+ ac_cv_search_socket="-l$i"
+break
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
-LIBS="$ac_save_LIBS"
-
+done
+LIBS="$ac_func_search_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 socket | sed -e 's/^a-zA-Z0-9_/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
- LIBS="-lsocket $LIBS"
-
-else
- echo "$ac_t""no" 1>&6
-echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-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_t""$ac_cv_search_socket" 1>&6
+if test "$ac_cv_search_socket" != "no"; then
+ test "$ac_cv_search_socket" = "none required" || LIBS="$ac_cv_search_socket $LIBS"
+
+else :
+ echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+echo "configure:3594: 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
else
ac_save_LIBS="$LIBS"
LIBS="-lsocket -lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3814 "configure"
+#line 3602 "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
@@ -3821,20 +3609,20 @@ int main() {
socket()
; return 0; }
EOF
-if { (eval echo configure:3825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3613: \"$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"
+ eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
- eval "ac_cv_lbl_lib_$ac_lib_var=no"
+ eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
-if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
LIBS="-lsocket -lnsl $LIBS"
else
@@ -3842,20 +3630,17 @@ else
fi
fi
-
-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: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 "checking for library containing putmsg""... $ac_c" 1>&6
+echo "configure:3637: checking for library containing putmsg" >&5
+if eval "test \"`echo '$''{'ac_cv_search_putmsg'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- ac_save_LIBS="$LIBS"
-LIBS="-lstr $LIBS"
+ ac_func_search_save_LIBS="$LIBS"
+ac_cv_search_putmsg="no"
cat > conftest.$ac_ext <<EOF
-#line 3859 "configure"
+#line 3644 "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
@@ -3866,33 +3651,48 @@ int main() {
putmsg()
; return 0; }
EOF
-if { (eval echo configure:3870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3655: \"$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"
+ ac_cv_search_putmsg="none required"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
-LIBS="$ac_save_LIBS"
+test "$ac_cv_search_putmsg" = "no" && for i in str; do
+LIBS="-l$i $ac_func_search_save_LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3666 "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 putmsg();
-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 str | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
+int main() {
+putmsg()
+; return 0; }
EOF
-
- LIBS="-lstr $LIBS"
-
+if { (eval echo configure:3677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ ac_cv_search_putmsg="-l$i"
+break
else
- echo "$ac_t""no" 1>&6
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+LIBS="$ac_func_search_save_LIBS"
fi
+echo "$ac_t""$ac_cv_search_putmsg" 1>&6
+if test "$ac_cv_search_putmsg" != "no"; then
+ test "$ac_cv_search_putmsg" = "none required" || LIBS="$ac_cv_search_putmsg $LIBS"
+
+else :
+
+fi
LBL_LIBS="$LIBS"
@@ -3901,12 +3701,12 @@ fi
for ac_func in pfopen
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3905: checking for $ac_func" >&5
+echo "configure:3705: 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 3910 "configure"
+#line 3710 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3929,7 +3729,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3733: \"$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
@@ -3959,7 +3759,7 @@ done
fi
fi
echo $ac_n "checking for local pcap library""... $ac_c" 1>&6
-echo "configure:3963: checking for local pcap library" >&5
+echo "configure:3763: checking for local pcap library" >&5
libpcap=FAIL
lastdir=FAIL
places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
@@ -3978,7 +3778,7 @@ echo "configure:3963: 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:3982: checking for main in -lpcap" >&5
+echo "configure:3782: 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
@@ -3986,14 +3786,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3990 "configure"
+#line 3790 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:3997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3797: \"$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
@@ -4018,22 +3818,24 @@ fi
fi
else
V_PCAPDEP=$libpcap
+ places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
if test -r $d/pcap.h; then
V_INCLS="-I$d $V_INCLS"
- elif test -r $srcdir/../libpcap/pcap.h; then
- V_INCLS="-I$d -I$srcdir/../libpcap $V_INCLS"
+ elif test -r $places/pcap.h; then
+ V_INCLS="-I$places $V_INCLS"
else
{ echo "configure: error: cannot find pcap.h" 1>&2; exit 1; }
fi
echo "$ac_t""$libpcap" 1>&6
fi
LIBS="$libpcap $LIBS"
- case "$target_os" in
+ case "$host_os" in
aix*)
pseexe="/lib/pse.exp"
echo $ac_n "checking for $pseexe""... $ac_c" 1>&6
-echo "configure:4037: checking for $pseexe" >&5
+echo "configure:3839: checking for $pseexe" >&5
if test -f $pseexe ; then
echo "$ac_t""yes" 1>&6
LIBS="$LIBS -I:$pseexe"
@@ -4044,12 +3846,12 @@ echo "configure:4037: checking for $pseexe" >&5
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
+echo "configure:3850: 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"
+#line 3855 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -4072,7 +3874,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:4076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3878: \"$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
@@ -4102,7 +3904,7 @@ V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
fi
-case "$target_os" in
+case "$host_os" in
aix*)
cat >> confdefs.h <<\EOF
@@ -4129,12 +3931,12 @@ if test -f /dev/bpf0 ; then
fi
echo $ac_n "checking for u_int8_t using $CC""... $ac_c" 1>&6
-echo "configure:4133: checking for u_int8_t using $CC" >&5
+echo "configure:3935: 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 4138 "configure"
+#line 3940 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -4147,7 +3949,7 @@ int main() {
u_int8_t i
; return 0; }
EOF
-if { (eval echo configure:4151: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3953: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_u_int8_t=yes
else
@@ -4167,12 +3969,12 @@ EOF
fi
echo $ac_n "checking for int16_t using $CC""... $ac_c" 1>&6
-echo "configure:4171: checking for int16_t using $CC" >&5
+echo "configure:3973: 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 4176 "configure"
+#line 3978 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -4185,7 +3987,7 @@ int main() {
int16_t i
; return 0; }
EOF
-if { (eval echo configure:4189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_int16_t=yes
else
@@ -4205,12 +4007,12 @@ EOF
fi
echo $ac_n "checking for u_int16_t using $CC""... $ac_c" 1>&6
-echo "configure:4209: checking for u_int16_t using $CC" >&5
+echo "configure:4011: 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 4214 "configure"
+#line 4016 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -4223,7 +4025,7 @@ int main() {
u_int16_t i
; return 0; }
EOF
-if { (eval echo configure:4227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4029: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_u_int16_t=yes
else
@@ -4243,12 +4045,12 @@ EOF
fi
echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6
-echo "configure:4247: checking for int32_t using $CC" >&5
+echo "configure:4049: 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 4252 "configure"
+#line 4054 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -4261,7 +4063,7 @@ int main() {
int32_t i
; return 0; }
EOF
-if { (eval echo configure:4265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4067: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_int32_t=yes
else
@@ -4281,12 +4083,12 @@ EOF
fi
echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6
-echo "configure:4285: checking for u_int32_t using $CC" >&5
+echo "configure:4087: 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 4290 "configure"
+#line 4092 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -4299,7 +4101,7 @@ int main() {
u_int32_t i
; return 0; }
EOF
-if { (eval echo configure:4303: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4105: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_u_int32_t=yes
else
@@ -4335,7 +4137,7 @@ rm -f os-proto.h
fi
fi
else
- case "$target_os" in
+ case "$host_os" in
irix6*)
V_CCOPT="$V_CCOPT -n32"
@@ -4345,7 +4147,7 @@ rm -f os-proto.h
;;
esac
fi
- os=`echo $target_os | sed -e 's/\([0-9][0-9]*\)[^0-9].*$/\1/'`
+ os=`echo $host_os | sed -e 's/\([0-9][0-9]*\)[^0-9].*$/\1/'`
name="lbl/os-$os.h"
if test -f $name ; then
ln -s $name os-proto.h
@@ -4359,12 +4161,12 @@ EOF
fi
echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
-echo "configure:4363: checking if sockaddr struct has sa_len member" >&5
+echo "configure:4165: 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 4368 "configure"
+#line 4170 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -4373,7 +4175,7 @@ int main() {
u_int i = sizeof(((struct sockaddr *)0)->sa_len)
; return 0; }
EOF
-if { (eval echo configure:4377: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4179: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_sockaddr_has_sa_len=yes
else
@@ -4394,14 +4196,14 @@ EOF
fi
echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
-echo "configure:4398: checking if unaligned accesses fail" >&5
+echo "configure:4200: 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
+ case "$host_cpu" in
# XXX: should also check that they don't do weird things (like on arm)
- alpha*|arm*|hp*|mips|sparc)
+ alpha*|arm*|hp*|mips*|sparc*|ia64)
ac_cv_lbl_unaligned_fail=yes
;;
@@ -4459,12 +4261,12 @@ EOF
echo $ac_n "checking for h_errno""... $ac_c" 1>&6
-echo "configure:4463: checking for h_errno" >&5
+echo "configure:4265: 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 4468 "configure"
+#line 4270 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -4473,7 +4275,7 @@ int main() {
int foo = h_errno;
; return 0; }
EOF
-if { (eval echo configure:4477: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4279: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_var_h_errno=yes
else
@@ -4501,18 +4303,14 @@ if test "${with_crypto+set}" = set; then
else
echo $ac_n "checking for SSLeay""... $ac_c" 1>&6
-echo "configure:4505: checking for SSLeay" >&5
+echo "configure:4307: checking for SSLeay" >&5
ac_cv_ssleay_path=no
incdir=no
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/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
+ if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
incdir="-I$dir/include"
fi
if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
@@ -4533,7 +4331,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:4537: checking for des_cbc_encrypt in -lcrypto" >&5
+echo "configure:4335: 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
@@ -4541,7 +4339,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcrypto $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4545 "configure"
+#line 4343 "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
@@ -4552,7 +4350,7 @@ int main() {
des_cbc_encrypt()
; return 0; }
EOF
-if { (eval echo configure:4556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4354: \"$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
@@ -4586,17 +4384,17 @@ fi
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4590: checking for $ac_hdr" >&5
+echo "configure:4388: 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 4595 "configure"
+#line 4393 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4600: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4398: \"$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*
@@ -4625,12 +4423,12 @@ done
if test "$ac_cv_header_cast_h" = "yes"; then
echo $ac_n "checking for buggy CAST128""... $ac_c" 1>&6
-echo "configure:4629: checking for buggy CAST128" >&5
+echo "configure:4427: checking for buggy CAST128" >&5
if test "$cross_compiling" = yes; then
buggy_cast128="cross-compiling, assume yes"
else
cat > conftest.$ac_ext <<EOF
-#line 4634 "configure"
+#line 4432 "configure"
#include "confdefs.h"
#include <cast.h>
@@ -4649,7 +4447,7 @@ main()
return 1;
}
EOF
-if { (eval echo configure:4653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
buggy_cast128=yes
else
@@ -4681,17 +4479,17 @@ 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
+echo "configure:4483: 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"
+#line 4488 "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; }
+{ (eval echo configure:4493: \"$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*
@@ -4736,7 +4534,7 @@ done
# 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:4740: checking for a BSD compatible install" >&5
+echo "configure:4538: 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
@@ -4930,16 +4728,6 @@ s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g
s%@host_vendor@%$host_vendor%g
s%@host_os@%$host_os%g
-s%@target@%$target%g
-s%@target_alias@%$target_alias%g
-s%@target_cpu@%$target_cpu%g
-s%@target_vendor@%$target_vendor%g
-s%@target_os@%$target_os%g
-s%@build@%$build%g
-s%@build_alias@%$build_alias%g
-s%@build_cpu@%$build_cpu%g
-s%@build_vendor@%$build_vendor%g
-s%@build_os@%$build_os%g
s%@SHLICC2@%$SHLICC2%g
s%@CC@%$CC%g
s%@CPP@%$CPP%g
diff --git a/contrib/tcpdump/configure.in b/contrib/tcpdump/configure.in
index 43f677795809..361fba0d1038 100755
--- a/contrib/tcpdump/configure.in
+++ b/contrib/tcpdump/configure.in
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.132.4.1 2001/01/17 18:29:58 guy Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.145 2002/01/17 05:00:16 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@@ -6,11 +6,11 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl
-AC_REVISION($Revision: 1.132.4.1 $)
+AC_REVISION($Revision: 1.145 $)
AC_PREREQ(2.13)
AC_INIT(tcpdump.c)
-AC_CANONICAL_SYSTEM
+AC_CANONICAL_HOST
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_C_INLINE
@@ -19,7 +19,7 @@ AC_C___ATTRIBUTE__
AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h)
AC_HEADER_TIME
-case "$target_os" in
+case "$host_os" in
linux*)
AC_MSG_CHECKING(Linux kernel version)
@@ -47,6 +47,8 @@ esac
AC_CHECK_HEADERS(smi.h)
AC_CHECK_LIB(smi, smiInit)
+if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
+then
AC_MSG_CHECKING([whether to enable libsmi])
AC_TRY_RUN([ /* libsmi available check */
#include <smi.h>
@@ -69,12 +71,36 @@ main()
[ AC_MSG_RESULT(yes)
AC_DEFINE(LIBSMI)
libsmi=yes],
-[ AC_MSG_RESULT(no)
+dnl autoconf documentation says that $? contains the exit value.
+dnl reality is that it does not. We leave this in just in case
+dnl autoconf ever comes back to match the documentation.
+[ case $? in
+ 1) AC_MSG_RESULT(no - smiInit failed) ;;
+ 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
+ 3) AC_MSG_RESULT(no - can't determine library version) ;;
+ 4) AC_MSG_RESULT(no - too old) ;;
+ *) AC_MSG_RESULT(no) ;;
+ esac
libsmi=no],
[ AC_MSG_RESULT(not when cross-compiling)
libsmi=no]
)
+fi
+AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
+AC_ARG_ENABLE(smb,
+[ --enable-smb enable possibly-buggy SMB printer [default=yes]
+ --disable-smb disable possibly-buggy SMB printer],,
+ enableval=yes)
+case "$enableval" in
+yes) AC_MSG_RESULT(yes)
+ AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
+ AC_DEFINE(TCPDUMP_DO_SMB)
+ LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
+ ;;
+*) AC_MSG_RESULT(no)
+ ;;
+esac
CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
AC_MSG_CHECKING([whether to enable ipv6])
@@ -450,15 +476,32 @@ if test "$missing_includes" = "yes"; then
fi
-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
+AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup)
+AC_CHECK_FUNCS(ether_ntohost, [
+ AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
+ AC_TRY_RUN([
+ #include <netdb.h>
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+
+ int
+ main(int argc, char **argv)
+ {
+ u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
+ char name[MAXHOSTNAMELEN];
+
+ ether_ntohost(name, (struct ether_addr *)ea);
+ exit(0);
+ }
+ ], [ac_cv_buggy_ether_ntohost=no],
+ [ac_cv_buggy_ether_ntohost=yes],
+ [ac_cv_buggy_ether_ntohost=not while cross-compiling])])
+ if test "$ac_cv_buggy_ether_ntohost" = "no"; then
+ AC_DEFINE(USE_ETHER_NTOHOST)
+ fi
+])
+AC_CHECK_FUNCS(setlinebuf)
needsnprintf=no
AC_CHECK_FUNCS(vsnprintf snprintf,,
@@ -467,19 +510,18 @@ 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_LBL_TYPE_SIGNAL
+
+AC_CHECK_LIB(dnet, dnet_htoa)
+
+AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
+
+dnl HP/UX may need -lnsl for getrpcbynumber.
+AC_SEARCH_LIBS(getrpcbynumber, nsl)
-AC_CHECK_LIB(dnet, main)
-AC_CHECK_LIB(rpc, main)
-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
@@ -488,7 +530,7 @@ V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
fi
-case "$target_os" in
+case "$host_os" in
aix*)
dnl Workaround to enable certain features
@@ -535,11 +577,7 @@ 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/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
+ if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
incdir="-I$dir/include"
fi
if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
diff --git a/contrib/tcpdump/dhcp6.h b/contrib/tcpdump/dhcp6.h
index a451bbfacf41..8381b11f9195 100644
--- a/contrib/tcpdump/dhcp6.h
+++ b/contrib/tcpdump/dhcp6.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6.h,v 1.4 2000/12/17 23:07:48 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6.h,v 1.4 2000/12/17 23:07:48 guy Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
diff --git a/contrib/tcpdump/dhcp6opt.h b/contrib/tcpdump/dhcp6opt.h
index b4ec2e47751c..fc6534dd1bb9 100644
--- a/contrib/tcpdump/dhcp6opt.h
+++ b/contrib/tcpdump/dhcp6opt.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6opt.h,v 1.3 2000/12/17 23:07:49 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6opt.h,v 1.4 2001/09/17 21:57:51 fenner Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -47,7 +47,7 @@
struct dhcp6_opt {
u_int code;
int len;
- char *name;
+ const char *name;
int type;
};
diff --git a/contrib/tcpdump/extract.h b/contrib/tcpdump/extract.h
index 9e5bb9b8c791..861f06f686e0 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.16 2000/10/03 02:54:55 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.17 2001/09/17 21:57:52 fenner Exp $ (LBL)
*/
/* Network to host order macros */
#ifdef LBL_ALIGN
#define EXTRACT_16BITS(p) \
- ((u_int16_t)*((u_int8_t *)(p) + 0) << 8 | \
- (u_int16_t)*((u_int8_t *)(p) + 1))
+ ((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
+ (u_int16_t)*((const u_int8_t *)(p) + 1))
#define EXTRACT_32BITS(p) \
- ((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))
+ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 3))
#else
#define EXTRACT_16BITS(p) \
- ((u_int16_t)ntohs(*(u_int16_t *)(p)))
+ ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
- ((u_int32_t)ntohl(*(u_int32_t *)(p)))
+ ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
#endif
#define EXTRACT_24BITS(p) \
- ((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))
+ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 2))
/* Little endian protocol host order macros */
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
- ((u_int16_t)*((u_int8_t *)(p) + 1) << 8 | \
- (u_int16_t)*((u_int8_t *)(p) + 0))
+ ((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
+ (u_int16_t)*((const u_int8_t *)(p) + 0))
#define EXTRACT_LE_32BITS(p) \
- ((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))
+ ((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 0))
diff --git a/contrib/tcpdump/icmp6.h b/contrib/tcpdump/icmp6.h
index 7f66c2e59976..49b8cfa8048a 100644
--- a/contrib/tcpdump/icmp6.h
+++ b/contrib/tcpdump/icmp6.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.4 2000/12/17 23:13:32 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.11 2001/06/01 23:01:04 itojun 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 $ */
@@ -198,6 +198,19 @@ struct nd_router_advert { /* router advertisement */
#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_FLAG_HOME_AGENT 0x20
+
+/*
+ * Router preference values based on draft-draves-ipngwg-router-selection-01.
+ * These are non-standard definitions.
+ */
+#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
+
+#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
+#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
+#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
+#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
+
#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
struct nd_neighbor_solicit { /* neighbor solicitation */
@@ -249,7 +262,10 @@ struct nd_opt_hdr { /* Neighbor discovery option header */
#define ND_OPT_PREFIX_INFORMATION 3
#define ND_OPT_REDIRECTED_HEADER 4
#define ND_OPT_MTU 5
-#define ND_OPT_ADVINT 7
+#define ND_OPT_ADVINTERVAL 7
+#define ND_OPT_HOMEAGENT_INFO 8
+#define ND_OPT_ROUTE_INFO 9 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
+
struct nd_opt_prefix_info { /* prefix information */
u_int8_t nd_opt_pi_type;
@@ -281,11 +297,28 @@ struct nd_opt_mtu { /* MTU option */
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;
+struct nd_opt_advinterval { /* Advertisement interval option */
+ u_int8_t nd_opt_adv_type;
+ u_int8_t nd_opt_adv_len;
+ u_int16_t nd_opt_adv_reserved;
+ u_int32_t nd_opt_adv_interval;
+};
+
+struct nd_opt_homeagent_info { /* Home Agent info */
+ u_int8_t nd_opt_hai_type;
+ u_int8_t nd_opt_hai_len;
+ u_int16_t nd_opt_hai_reserved;
+ int16_t nd_opt_hai_preference;
+ u_int16_t nd_opt_hai_lifetime;
+};
+
+struct nd_opt_route_info { /* route info */
+ u_int8_t nd_opt_rti_type;
+ u_int8_t nd_opt_rti_len;
+ u_int8_t nd_opt_rti_prefixlen;
+ u_int8_t nd_opt_rti_flags;
+ u_int32_t nd_opt_rti_lifetime;
+ /* prefix follows */
};
/*
@@ -356,7 +389,7 @@ struct icmp6_router_renum { /* router renumbering header */
};
#define ICMP6_RR_FLAGS_TEST 0x80
#define ICMP6_RR_FLAGS_REQRESULT 0x40
-#define ICMP6_RR_FLAGS_ALLIF 0x20
+#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
#define ICMP6_RR_FLAGS_SPECSITE 0x10
#define ICMP6_RR_FLAGS_PREVDONE 0x08
diff --git a/contrib/tcpdump/ieee802_11.h b/contrib/tcpdump/ieee802_11.h
new file mode 100644
index 000000000000..cecd0d7ddd67
--- /dev/null
+++ b/contrib/tcpdump/ieee802_11.h
@@ -0,0 +1,244 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.3 2001/06/14 09:50:01 guy Exp $ (LBL) */
+/*
+ * Copyright (c) 2001
+ * Fortress Technologies
+ * Charlie Lenahan ( clenahan@fortresstech.com )
+ *
+ * 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 IEEE802_11_FC_LEN 2
+
+#define T_MGMT 0x0 /* management */
+#define T_CTRL 0x1 /* control */
+#define T_DATA 0x2 /* data */
+#define T_RESV 0x3 /* reserved */
+
+#define ST_ASSOC_REQUEST 0x0
+#define ST_ASSOC_RESPONSE 0x1
+#define ST_REASSOC_REQUEST 0x2
+#define ST_REASSOC_RESPONSE 0x3
+#define ST_PROBE_REQUEST 0x4
+#define ST_PROBE_RESPONSE 0x5
+/* RESERVED 0x6 */
+/* RESERVED 0x7 */
+#define ST_BEACON 0x8
+#define ST_ATIM 0x9
+#define ST_DISASSOC 0xA
+#define ST_AUTH 0xB
+#define ST_DEAUTH 0xC
+/* RESERVED 0xD */
+/* RESERVED 0xE */
+/* RESERVED 0xF */
+
+
+#define CTRL_PS_POLL 0xA
+#define CTRL_RTS 0xB
+#define CTRL_CTS 0xC
+#define CTRL_ACK 0xD
+#define CTRL_CF_END 0xE
+#define CTRL_END_ACK 0xF
+
+/*
+ * Bits in the frame control field.
+ */
+#define FC_VERSION(fc) ((fc) & 0x3)
+#define FC_TYPE(fc) (((fc) >> 2) & 0x3)
+#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
+#define FC_TO_DS(fc) ((fc) & 0x0100)
+#define FC_FROM_DS(fc) ((fc) & 0x0200)
+#define FC_MORE_FLAG(fc) ((fc) & 0x0400)
+#define FC_RETRY(fc) ((fc) & 0x0800)
+#define FC_POWER_MGMT(fc) ((fc) & 0x1000)
+#define FC_MORE_DATA(fc) ((fc) & 0x2000)
+#define FC_WEP(fc) ((fc) & 0x4000)
+#define FC_ORDER(fc) ((fc) & 0x8000)
+
+struct mgmt_header_t {
+ u_int16_t fc;
+ u_int16_t duration;
+ u_int8_t da[6];
+ u_int8_t sa[6];
+ u_int8_t bssid[6];
+ u_int16_t seq_ctrl;
+};
+
+#define MGMT_HEADER_LEN (2+2+6+6+6+2)
+
+#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
+#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
+#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
+#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
+#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
+
+struct ssid_t {
+ u_int8_t element_id;
+ u_int8_t length;
+ u_char ssid[33]; /* 32 + 1 for null */
+} ;
+
+struct rates_t {
+ u_int8_t element_id;
+ u_int8_t length;
+ u_int8_t rate[8];
+};
+
+struct challenge_t {
+ u_int8_t element_id;
+ u_int8_t length;
+ u_int8_t text[254]; /* 1-253 + 1 for null */
+};
+struct fh_t {
+ u_int8_t element_id;
+ u_int8_t length;
+ u_int16_t dwell_time;
+ u_int8_t hop_set;
+ u_int8_t hop_pattern;
+ u_int8_t hop_index;
+};
+
+struct ds_t {
+ u_int8_t element_id;
+ u_int8_t length;
+ u_int8_t channel;
+};
+
+struct cf_t {
+ u_int8_t element_id;
+ u_int8_t length;
+ u_int8_t count;
+ u_int8_t period;
+ u_int16_t max_duration;
+ u_int16_t dur_remaing;
+};
+
+struct tim_t {
+ u_int8_t element_id;
+ u_int8_t length;
+ u_int8_t count;
+ u_int8_t period;
+ u_int8_t bitmap_control;
+ u_int8_t bitmap[251];
+};
+
+#define E_SSID 0
+#define E_RATES 1
+#define E_FH 2
+#define E_DS 3
+#define E_CF 4
+#define E_TIM 5
+#define E_IBSS 6
+/* reserved 7 */
+/* reserved 8 */
+/* reserved 9 */
+/* reserved 10 */
+/* reserved 11 */
+/* reserved 12 */
+/* reserved 13 */
+/* reserved 14 */
+/* reserved 15 */
+/* reserved 16 */
+
+#define E_CHALLENGE 16
+/* reserved 17 */
+/* reserved 18 */
+/* reserved 19 */
+/* reserved 16 */
+/* reserved 16 */
+
+
+struct mgmt_body_t {
+ u_int8_t timestamp[8];
+ u_int16_t beacon_interval;
+ u_int16_t listen_interval;
+ u_int16_t status_code;
+ u_int16_t aid;
+ u_char ap[6];
+ u_int16_t reason_code;
+ u_int16_t auth_alg;
+ u_int16_t auth_trans_seq_num;
+ struct challenge_t challenge;
+ u_int16_t capability_info;
+ struct ssid_t ssid;
+ struct rates_t rates;
+ struct ds_t ds;
+ struct cf_t cf;
+ struct fh_t fh;
+ struct tim_t tim;
+};
+
+struct ctrl_rts_t {
+ u_int16_t fc;
+ u_int16_t duration;
+ u_int8_t ra[6];
+ u_int8_t ta[6];
+ u_int8_t fcs[4];
+};
+
+#define CTRL_RTS_LEN (2+2+6+6+4)
+
+struct ctrl_cts_t {
+ u_int16_t fc;
+ u_int16_t duration;
+ u_int8_t ra[6];
+ u_int8_t fcs[4];
+};
+
+#define CTRL_CTS_LEN (2+2+6+4)
+
+struct ctrl_ack_t {
+ u_int16_t fc;
+ u_int16_t duration;
+ u_int8_t ra[6];
+ u_int8_t fcs[4];
+};
+
+#define CTRL_ACK_LEN (2+2+6+4)
+
+struct ctrl_ps_poll_t {
+ u_int16_t fc;
+ u_int16_t aid;
+ u_int8_t bssid[6];
+ u_int8_t ta[6];
+ u_int8_t fcs[4];
+};
+
+#define CTRL_PS_POLL_LEN (2+2+6+6+4)
+
+struct ctrl_end_t {
+ u_int16_t fc;
+ u_int16_t duration;
+ u_int8_t ra[6];
+ u_int8_t bssid[6];
+ u_int8_t fcs[4];
+};
+
+#define CTRL_END_LEN (2+2+6+6+4)
+
+struct ctrl_end_ack_t {
+ u_int16_t fc;
+ u_int16_t duration;
+ u_int8_t ra[6];
+ u_int8_t bssid[6];
+ u_int8_t fcs[4];
+};
+
+#define CTRL_END_ACK_LEN (2+2+6+6+4)
+
+#define IV_IV(iv) ((iv) & 0xFFFFFF)
+#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
+#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
diff --git a/contrib/tcpdump/ipx.h b/contrib/tcpdump/ipx.h
index c65582a2f761..a0dca0c55bf9 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.2 2000/10/03 02:54:56 itojun Exp $
+ * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.4 2001/01/15 03:23:59 guy Exp $
*/
/* well-known sockets */
@@ -10,6 +10,8 @@
#define IPX_SKT_RIP 0x0453
#define IPX_SKT_NETBIOS 0x0455
#define IPX_SKT_DIAGNOSTICS 0x0456
+#define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */
+#define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */
/* IPX transport header */
struct ipxHdr {
diff --git a/contrib/tcpdump/l2tp.h b/contrib/tcpdump/l2tp.h
index 5c8f98dbe212..156888347f56 100644
--- a/contrib/tcpdump/l2tp.h
+++ b/contrib/tcpdump/l2tp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001/11/05 10:03:27 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -55,29 +55,8 @@
#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
-#define L2TP_AUTHEN_TYPE_MSCHAP 0x0005 /* MSCHAPv1 */
+#define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */
#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
-struct l2tp_avp_vec {
- const char *name;
- void (*print)(const u_char *, u_int32_t);
-};
-
-struct l2tp_call_errors {
- 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_int16_t reserved;
- u_int32_t send_accm;
- u_int32_t recv_accm;
-};
-
diff --git a/contrib/tcpdump/llc.h b/contrib/tcpdump/llc.h
index 5f0b9815975d..6485d771c87c 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.8 2000/12/18 07:55:36 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.13 2001/06/04 05:47:13 guy Exp $ (LBL)
*/
/*
@@ -51,8 +51,8 @@ struct llc {
#define llcui ctl.snap.snap_ui
#define llcpi ctl.snap.snap_pi
-#define orgcode ctl.snap_ether.snap_orgcode
-#define ethertype ctl.snap_ether.snap_ethertype
+#define llc_orgcode ctl.snap_ether.snap_orgcode
+#define llc_ethertype ctl.snap_ether.snap_ethertype
#define llcis ctl.is_ctl
#define llcu ctl.u_ctl
@@ -88,10 +88,10 @@ struct llc {
#ifndef LLCSAP_GLOBAL
#define LLCSAP_GLOBAL 0xff
#endif
-#ifndef LLCSAP_8021B
+#ifndef LLCSAP_8021B_I
#define LLCSAP_8021B_I 0x02
#endif
-#ifndef LLCSAP_8021B
+#ifndef LLCSAP_8021B_G
#define LLCSAP_8021B_G 0x03
#endif
#ifndef LLCSAP_IP
@@ -115,6 +115,18 @@ struct llc {
#ifndef LLCSAP_SNAP
#define LLCSAP_SNAP 0xaa
#endif
+#ifndef LLCSAP_IPX
+#define LLCSAP_IPX 0xe0
+#endif
+#ifndef LLCSAP_NETBEUI
+#define LLCSAP_NETBEUI 0xf0
+#endif
#ifndef LLCSAP_ISONS
#define LLCSAP_ISONS 0xfe
#endif
+
+#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
+#define OUI_CISCO 0x00000c /* Cisco protocols */
+#define ETHERTYPE_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */
+#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
+#define OUI_APPLETALK 0x080007 /* Appletalk */
diff --git a/contrib/tcpdump/machdep.c b/contrib/tcpdump/machdep.c
index 3080f85ad03f..e86a84d0b49f 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.6 2000/01/17 06:24:23 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.7 2001/06/27 05:42:04 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,7 +32,16 @@ static const char rcsid[] =
#ifdef __osf__
#include <sys/sysinfo.h>
#include <sys/proc.h>
-#endif
+
+#if !defined(HAVE_SNPRINTF)
+#ifndef HAVE___ATTRIBUTE__
+#define __attribute__(x)
+#endif /* HAVE___ATTRIBUTE__ */
+
+int snprintf(char *, size_t, const char *, ...)
+ __attribute__((format(printf, 3, 4)));
+#endif /* !defined(HAVE_SNPRINTF) */
+#endif /* __osf__ */
#include "machdep.h"
diff --git a/contrib/tcpdump/makemib b/contrib/tcpdump/makemib
index 85162637c596..2c80bef05832 100755
--- a/contrib/tcpdump/makemib
+++ b/contrib/tcpdump/makemib
@@ -1,20 +1,33 @@
#!/bin/sh
#
-# Copyright (c) 1990, 1996, by John Robert LoVerso.
-# All rights reserved.
-# SMIv2 parsing copyright (c) 1999 by William C. Fenner.
-#
-# 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 John Robert LoVerso.
-# 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.
-#
-# @(#) $Id: makemib,v 1.2 1999/11/21 17:24:15 fenner Exp $ (jlv)
+# Copyright (c) 1990, 1996
+# John Robert LoVerso. All rights reserved.
+# SMIv2 parsing copyright (c) 1999
+# William C. Fenner.
+#
+# 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
+# notices, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notices, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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: makemib,v 1.3 2001/09/17 22:16:52 fenner Exp $ (jlv)
#
# This script will read either ASN.1-style MIB files or the ".defs" files
diff --git a/contrib/tcpdump/missing/snprintf.c b/contrib/tcpdump/missing/snprintf.c
index 176636fa9ac7..1d4ab713c06e 100644
--- a/contrib/tcpdump/missing/snprintf.c
+++ b/contrib/tcpdump/missing/snprintf.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-/* $Id: snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $ */
+/* $Id: snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -39,7 +39,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $";
#endif
#include <stdio.h>
@@ -93,6 +93,7 @@ sn_append_char (struct state *state, unsigned char c)
}
#endif
+#if 0
static int
as_reserve (struct state *state, size_t n)
{
@@ -126,6 +127,7 @@ as_append_char (struct state *state, unsigned char c)
return 0;
}
}
+#endif
static int
append_number(struct state *state,
@@ -490,6 +492,7 @@ snprintf (char *str, size_t sz, const char *format, ...)
}
#endif
+#if 0
#ifndef HAVE_ASPRINTF
int
asprintf (char **ret, const char *format, ...)
@@ -600,6 +603,7 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
}
}
#endif
+#endif
#ifndef HAVE_VSNPRINTF
int
diff --git a/contrib/tcpdump/missing/strdup.c b/contrib/tcpdump/missing/strdup.c
new file mode 100644
index 000000000000..103c3b26f6f3
--- /dev/null
+++ b/contrib/tcpdump/missing/strdup.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1988, 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 defined(LIBC_SCCS) && !defined(lint)
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/missing/strdup.c,v 1.1 2001/01/20 07:26:08 guy Exp $ (LBL)";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "interface.h"
+
+char *
+strdup(str)
+ const char *str;
+{
+ size_t len;
+ char *copy;
+
+ len = strlen(str) + 1;
+ if ((copy = malloc(len)) == NULL)
+ return (NULL);
+ memcpy(copy, str, len);
+ return (copy);
+}
diff --git a/contrib/tcpdump/nameser.h b/contrib/tcpdump/nameser.h
index 9963dd03c1b6..b8e157d0e507 100644
--- a/contrib/tcpdump/nameser.h
+++ b/contrib/tcpdump/nameser.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.5 2000/12/28 20:30:41 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.9 2001/06/27 05:40:16 guy Exp $ (LBL) */
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -96,6 +96,23 @@
#define ZONEREF 0xf /* incremental zone referesh */
/*
+ * Undefine various #defines from various System V-flavored OSes (Solaris,
+ * SINIX, HP-UX) so the compiler doesn't whine that we redefine them.
+ */
+#ifdef T_NULL
+#undef T_NULL
+#endif
+#ifdef T_OPT
+#undef T_OPT
+#endif
+#ifdef T_UNSPEC
+#undef T_UNSPEC
+#endif
+#ifdef NOERROR
+#undef NOERROR
+#endif
+
+/*
* Currently defined response codes
*/
#define NOERROR 0 /* no error */
@@ -128,14 +145,36 @@
#define T_TXT 16 /* text strings */
#define T_RP 17 /* responsible person */
#define T_AFSDB 18 /* AFS cell database */
+#define T_X25 19 /* X_25 calling address */
+#define T_ISDN 20 /* ISDN calling address */
+#define T_RT 21 /* router */
#define T_NSAP 22 /* NSAP address */
#define T_NSAP_PTR 23 /* reverse lookup for NSAP */
+#define T_SIG 24 /* security signature */
+#define T_KEY 25 /* security key */
+#define T_PX 26 /* X.400 mail mapping */
+#define T_GPOS 27 /* geographical position (withdrawn) */
+#define T_AAAA 28 /* IP6 Address */
+#define T_LOC 29 /* Location Information */
+#define T_NXT 30 /* Next Valid Name in Zone */
+#define T_EID 31 /* Endpoint identifier */
+#define T_NIMLOC 32 /* Nimrod locator */
+#define T_SRV 33 /* Server selection */
+#define T_ATMA 34 /* ATM Address */
+#define T_NAPTR 35 /* Naming Authority PoinTeR */
+#define T_A6 38 /* IP6 address */
+#define T_DNAME 39 /* non-terminal redirection */
+#define T_OPT 41 /* EDNS0 option (meta-RR) */
/* 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) */
+#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
/* Query type values which do not appear in resource records */
+#define T_TKEY 249 /* Transaction Key [RFC2930] */
+#define T_TSIG 250 /* Transaction Signature [RFC2845] */
+#define T_IXFR 251 /* incremental transfer [RFC1995] */
#define T_AXFR 252 /* transfer zone of authority */
#define T_MAILB 253 /* transfer mailbox records */
#define T_MAILA 254 /* transfer mail agent records */
diff --git a/contrib/tcpdump/print-802_11.c b/contrib/tcpdump/print-802_11.c
new file mode 100644
index 000000000000..b9c2bb84d946
--- /dev/null
+++ b/contrib/tcpdump/print-802_11.c
@@ -0,0 +1,858 @@
+/*
+ * Copyright (c) 2001
+ * Fortress Technologies, Inc. All rights reserved.
+ * Charlie Lenahan (clenahan@fortresstech.com)
+ *
+ * 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-802_11.c,v 1.6 2001/09/17 21:57:53 fenner Exp $ (LBL)";
+#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 <stdio.h>
+#include <pcap.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "ethertype.h"
+
+#include "extract.h"
+
+#include "ieee802_11.h"
+
+#define RATEStoBUF(p, buf) \
+do { \
+ int z = 0; \
+ for (z = 0 ; z < p.rates.length ; z++) \
+ snprintf(buf, sizeof(buf), "%s %2.1f", buf, (.5 * (p.rates.rate[z] & 0x7f))); \
+} while (0)
+
+static const char *auth_alg_text[]={"Open System","Shared Key","EAP"};
+static const char *subtype_text[]={
+ "Assoc Request",
+ "Assoc Response",
+ "ReAssoc Request",
+ "ReAssoc Response",
+ "Probe Request",
+ "Probe Response",
+ "RESERVED",
+ "RESERVED",
+ "Beacon",
+ "ATIM",
+ "Disassociation",
+ "Authentication",
+ "DeAuthentication",
+ "RESERVED",
+ "RESERVED"
+};
+
+static const char *status_text[] = {
+ "Succesful", /* 0 */
+ "Unspecified failure", /* 1 */
+ "Reserved", /* 2 */
+ "Reserved", /* 3 */
+ "Reserved", /* 4 */
+ "Reserved", /* 5 */
+ "Reserved", /* 6 */
+ "Reserved", /* 7 */
+ "Reserved", /* 8 */
+ "Reserved", /* 9 */
+ "Cannot Support all requested capabilities in the Capability Information field", /* 10 */
+ "Reassociation denied due to inability to confirm that association exists", /* 11 */
+ "Association denied due to reason outside the scope of the standard", /* 12 */
+ "Responding station does not support the specified authentication algorithm ", /* 13 */
+ "Received an Authentication frame with authentication transaction " \
+ "sequence number out of expected sequence", /* 14 */
+ "Authentication rejected because of challenge failure", /* 15 */
+ "Authentication rejected due to timeout waiting for next frame in sequence", /* 16 */
+ "Association denied because AP is unable to handle additional associated stations", /* 17 */
+ "Association denied due to requesting station not supporting all of the " \
+ "data rates in BSSBasicRateSet parameter", /* 18 */
+ NULL
+};
+
+static const char *reason_text[] = {
+ "Reserved", /* 0 */
+ "Unspecified reason", /* 1 */
+ "Previous authentication no longer valid", /* 2 */
+ "Deauthenticated because sending station is leaving (or has left) IBSS or ESS", /* 3 */
+ "Disassociated due to inactivity", /* 4 */
+ "Disassociated because AP is unable to handle all currently associated stations", /* 5 */
+ "Class 2 frame receivedfrom nonauthenticated station", /* 6 */
+ "Class 3 frame received from nonassociated station", /* 7 */
+ "Disassociated because sending station is leaving (or has left) BSS", /* 8 */
+ "Station requesting (re)association is not authenticated with responding station", /* 9 */
+ NULL
+};
+
+static int wep_print(const u_char *p,u_int length)
+{
+ u_int32_t iv;
+
+ if (!TTEST2(*p, 4))
+ return 0;
+ iv = EXTRACT_LE_32BITS(p);
+
+ printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
+ IV_KEYID(iv));
+
+ return 1;
+}
+
+
+static int parse_elements(struct mgmt_body_t *pbody,const u_char *p,int offset)
+{
+ for (;;) {
+ if (!TTEST2(*(p + offset), 1))
+ return 0;
+ if (*(p + offset) == 0xff)
+ break;
+ switch (*(p + offset)) {
+ case E_SSID:
+ if (!TTEST2(*(p+offset), 2))
+ return 0;
+ memcpy(&(pbody->ssid),p+offset,2); offset += 2;
+ if (pbody->ssid.length > 0)
+ {
+ if (!TTEST2(*(p+offset), pbody->ssid.length))
+ return 0;
+ memcpy(&(pbody->ssid.ssid),p+offset,pbody->ssid.length); offset += pbody->ssid.length;
+ pbody->ssid.ssid[pbody->ssid.length]='\0';
+ }
+ break;
+ case E_CHALLENGE:
+ if (!TTEST2(*(p+offset), 2))
+ return 0;
+ memcpy(&(pbody->challenge),p+offset,2); offset += 2;
+ if (pbody->challenge.length > 0)
+ {
+ if (!TTEST2(*(p+offset), pbody->challenge.length))
+ return 0;
+ memcpy(&(pbody->challenge.text),p+offset,pbody->challenge.length); offset += pbody->challenge.length;
+ pbody->challenge.text[pbody->challenge.length]='\0';
+ }
+ break;
+ case E_RATES:
+ if (!TTEST2(*(p+offset), 2))
+ return 0;
+ memcpy(&(pbody->rates),p+offset,2); offset += 2;
+ if (pbody->rates.length > 0) {
+ if (!TTEST2(*(p+offset), pbody->rates.length))
+ return 0;
+ memcpy(&(pbody->rates.rate),p+offset,pbody->rates.length); offset += pbody->rates.length;
+ }
+ break;
+ case E_DS:
+ if (!TTEST2(*(p+offset), 3))
+ return 0;
+ memcpy(&(pbody->ds),p+offset,3); offset +=3;
+ break;
+ case E_CF:
+ if (!TTEST2(*(p+offset), 8))
+ return 0;
+ memcpy(&(pbody->cf),p+offset,8); offset +=8;
+ break;
+ case E_TIM:
+ if (!TTEST2(*(p+offset), 2))
+ return 0;
+ memcpy(&(pbody->tim),p+offset,2); offset +=2;
+ if (!TTEST2(*(p+offset), 3))
+ return 0;
+ memcpy(&(pbody->tim.count),p+offset,3); offset +=3;
+
+ if ((pbody->tim.length -3) > 0)
+ {
+ if (!TTEST2(*(p+offset), pbody->tim.length -3))
+ return 0;
+ memcpy((pbody->tim.bitmap),p+(pbody->tim.length -3),(pbody->tim.length -3));
+ offset += pbody->tim.length -3;
+ }
+
+ break;
+ default:
+#if 0
+ printf("(1) unhandled element_id (%d) ", *(p+offset) );
+#endif
+ offset+= *(p+offset+1) + 2;
+ break;
+ }
+ }
+ return 1;
+}
+
+/*********************************************************************************
+ * Print Handle functions for the management frame types
+ *********************************************************************************/
+
+static int handle_beacon(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+ char buf[128];
+
+ memset(buf, 0, sizeof(buf));
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 12))
+ return 0;
+ memcpy(&pbody.timestamp, p, 8);
+ offset += 8;
+ pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+ pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+
+ if (!parse_elements(&pbody,p,offset))
+ return 0;
+
+ RATEStoBUF(pbody, buf);
+
+ printf("%s (%s) [%s Mbit] %s CH: %x %s",
+ subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid, buf,
+ CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS",
+ pbody.ds.channel,
+ CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" );
+
+ return 1;
+}
+
+static int handle_assoc_request(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+ char buf[128];
+
+ memset(buf, 0, sizeof(buf));
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 4))
+ return 0;
+ pbody.capability_info = EXTRACT_LE_16BITS(p);
+ offset += 2;
+ pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+
+ if (!parse_elements(&pbody,p,offset))
+ return 0;
+
+ RATEStoBUF(pbody,buf);
+
+ printf("%s (%s) [%s Mbit] ",
+ subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid,buf);
+ return 1;
+}
+
+static int handle_assoc_response(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 6))
+ return 0;
+ pbody.capability_info = EXTRACT_LE_16BITS(p);
+ offset += 2;
+ pbody.status_code = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+ pbody.aid = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+
+ if (!parse_elements(&pbody,p,offset))
+ return 0;
+
+ printf("%s AID(%x) :%s: %s ", subtype_text[FC_SUBTYPE(fc)],
+ ((u_int16_t)(pbody.aid << 2 )) >> 2 ,
+ CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
+ (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a"));
+
+ return 1;
+}
+
+
+static int handle_reassoc_request(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 10))
+ return 0;
+ pbody.capability_info = EXTRACT_LE_16BITS(p);
+ offset += 2;
+ pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+ memcpy(&pbody.ap,p+offset,6);
+ offset += 6;
+
+ if (!parse_elements(&pbody,p,offset))
+ return 0;
+
+ printf("%s (%s) AP : %s",subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid, etheraddr_string( pbody.ap ));
+
+ return 1;
+}
+
+static int handle_reassoc_response(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ /* Same as a Association Reponse */
+ return handle_assoc_response(fc,pmh,p);
+}
+
+static int handle_probe_request(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+ char buf[128];
+
+ memset(buf, 0, sizeof(buf));
+
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!parse_elements(&pbody, p, offset))
+ return 0;
+
+ RATEStoBUF(pbody, buf);
+
+ printf("%s (%s) [%s Mbit] ", subtype_text[FC_SUBTYPE(fc)],
+ pbody.ssid.ssid,buf);
+
+ return 1;
+}
+
+static int handle_probe_response(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+ char buf[128];
+
+ memset(buf, 0, sizeof(buf));
+
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 12))
+ return 0;
+ memcpy(&pbody.timestamp,p,8);
+ offset += 8;
+ pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+ pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
+ offset += 2;
+
+ if (!parse_elements(&pbody, p, offset))
+ return 0;
+
+ printf("%s (%s) CH: %x %s", subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid,pbody.ds.channel,
+ CAPABILITY_PRIVACY(pbody.capability_info) ? ",PRIVACY " : "" );
+
+ return 1;
+}
+
+static int handle_atim(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ /* the frame body for ATIM is null. */
+ printf("ATIM");
+ return 1;
+}
+
+static int handle_disassoc(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 2))
+ return 0;
+ pbody.reason_code = EXTRACT_LE_16BITS(p);
+ offset += 2;
+
+ printf("%s: %s ", subtype_text[FC_SUBTYPE(fc)],
+ pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" );
+
+ return 1;
+}
+
+static int handle_auth(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 6))
+ return 0;
+ pbody.auth_alg = EXTRACT_LE_16BITS(p);
+ offset += 2;
+ pbody.auth_trans_seq_num = EXTRACT_LE_16BITS(p + offset);
+ offset += 2;
+ pbody.status_code = EXTRACT_LE_16BITS(p + offset);
+ offset += 2;
+
+ if (!parse_elements(&pbody,p,offset))
+ return 0;
+
+ if ((pbody.auth_alg == 1) &&
+ ((pbody.auth_trans_seq_num == 2) || (pbody.auth_trans_seq_num == 3))) {
+ printf("%s (%s)-%x [Challenge Text] %s",
+ subtype_text[FC_SUBTYPE(fc)],
+ pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" ,
+ pbody.auth_trans_seq_num,
+ ((pbody.auth_trans_seq_num % 2) ?
+ (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : "" ));
+ } else {
+ printf("%s (%s)-%x: %s",
+ subtype_text[FC_SUBTYPE(fc)],
+ pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" ,
+ pbody.auth_trans_seq_num,
+ ((pbody.auth_trans_seq_num % 2) ? (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : ""));
+ }
+
+ return 1;
+}
+
+static int handle_deauth(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p)
+{
+ struct mgmt_body_t pbody;
+ int offset = 0;
+
+ memset(&pbody, 0, sizeof(pbody));
+
+ if (!TTEST2(*p, 2))
+ return 0;
+ pbody.reason_code = EXTRACT_LE_16BITS(p);
+ offset += 2;
+
+ if (eflag) {
+ printf("%s: %s",
+ subtype_text[FC_SUBTYPE(fc)],
+ pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" );
+ } else {
+ printf("%s (%s): %s",
+ subtype_text[FC_SUBTYPE(fc)], etheraddr_string(pmh->sa),
+ pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" );
+ }
+
+ return 1;
+}
+
+
+/*********************************************************************************
+ * Print Body funcs
+ *********************************************************************************/
+
+
+static int mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p, u_int length)
+{
+ switch (FC_SUBTYPE(fc)) {
+ case ST_ASSOC_REQUEST:
+ return (handle_assoc_request(fc, pmh, p));
+ case ST_ASSOC_RESPONSE:
+ return (handle_assoc_response(fc, pmh, p));
+ case ST_REASSOC_REQUEST:
+ return (handle_reassoc_request(fc, pmh, p));
+ case ST_REASSOC_RESPONSE:
+ return (handle_reassoc_response(fc, pmh, p));
+ case ST_PROBE_REQUEST:
+ return (handle_probe_request(fc, pmh, p));
+ case ST_PROBE_RESPONSE:
+ return (handle_probe_response(fc, pmh, p));
+ case ST_BEACON:
+ return (handle_beacon(fc, pmh, p));
+ case ST_ATIM:
+ return (handle_atim(fc, pmh, p));
+ case ST_DISASSOC:
+ return (handle_disassoc(fc, pmh, p));
+ case ST_AUTH:
+ if (!TTEST2(*p, 3))
+ return 0;
+ if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
+ printf("Authentication (Shared-Key)-3 ");
+ return (wep_print(p, length));
+ }
+ else
+ return (handle_auth(fc, pmh, p));
+ case ST_DEAUTH:
+ return (handle_deauth(fc, pmh, p));
+ break;
+ default:
+ printf("Unhandled Managment subtype(%x)",
+ FC_SUBTYPE(fc));
+ return 1;
+ }
+}
+
+
+/*********************************************************************************
+ * Handles printing all the control frame types
+ *********************************************************************************/
+
+static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
+{
+ switch (FC_SUBTYPE(fc)) {
+ case CTRL_PS_POLL:
+ if (!TTEST2(*p, CTRL_PS_POLL_LEN))
+ return 0;
+ printf("Power Save-Poll AID(%x)",
+ EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid)));
+ break;
+ case CTRL_RTS:
+ if (!TTEST2(*p, CTRL_RTS_LEN))
+ return 0;
+ if (eflag)
+ printf("Request-To-Send");
+ else
+ printf("Request-To-Send TA:%s ",
+ etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+ break;
+ case CTRL_CTS:
+ if (!TTEST2(*p, CTRL_CTS_LEN))
+ return 0;
+ if (eflag)
+ printf("Clear-To-Send");
+ else
+ printf("Clear-To-Send RA:%s ",
+ etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+ break;
+ case CTRL_ACK:
+ if (!TTEST2(*p, CTRL_ACK_LEN))
+ return 0;
+ if (eflag)
+ printf("Acknowledgment");
+ else
+ printf("Acknowledgment RA:%s ",
+ etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+ break;
+ case CTRL_CF_END:
+ if (!TTEST2(*p, CTRL_END_LEN))
+ return 0;
+ if (eflag)
+ printf("CF-End");
+ else
+ printf("CF-End RA:%s ",
+ etheraddr_string(((const struct ctrl_end_t *)p)->ra));
+ break;
+ case CTRL_END_ACK:
+ if (!TTEST2(*p, CTRL_END_ACK_LEN))
+ return 0;
+ if (eflag)
+ printf("CF-End+CF-Ack");
+ else
+ printf("CF-End+CF-Ack RA:%s ",
+ etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra));
+ break;
+ default:
+ printf("(B) Unknown Ctrl Subtype");
+ }
+ return 1;
+}
+
+
+
+/*
+ * Print Header funcs
+ */
+
+/*
+ * Data Frame - Address field contents
+ *
+ * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
+ * 0 | 0 | DA | SA | BSSID | n/a
+ * 0 | 1 | DA | BSSID | SA | n/a
+ * 1 | 0 | BSSID | SA | DA | n/a
+ * 1 | 1 | RA | TA | DA | SA
+ */
+
+static void data_header_print(u_int16_t fc,const u_char *p, u_int length)
+{
+#define ADDR1 (p + 4)
+#define ADDR2 (p + 10)
+#define ADDR3 (p + 16)
+#define ADDR4 (p + 24)
+
+ if (!FC_TO_DS(fc)) {
+ if (!FC_FROM_DS(fc))
+ printf("DA:%s SA:%s BSSID:%s ",
+ etheraddr_string(ADDR1), etheraddr_string(ADDR2),
+ etheraddr_string(ADDR3));
+ else
+ printf("DA:%s BSSID:%s SA:%s ",
+ etheraddr_string(ADDR1), etheraddr_string(ADDR2),
+ etheraddr_string(ADDR3));
+ } else {
+ if (!FC_FROM_DS(fc))
+ printf("BSSID:%s SA:%s DA:%s ",
+ etheraddr_string(ADDR1), etheraddr_string(ADDR2),
+ etheraddr_string(ADDR3));
+ else
+ printf("RA:%s TA:%s DA:%s SA:%s ",
+ etheraddr_string(ADDR1), etheraddr_string(ADDR2),
+ etheraddr_string(ADDR3), etheraddr_string(ADDR4));
+ }
+
+#undef ADDR1
+#undef ADDR2
+#undef ADDR3
+#undef ADDR4
+}
+
+
+static void mgmt_header_print(const u_char *p, u_int length)
+{
+ const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
+
+ printf("BSSID:%s DA:%s SA:%s ",
+ etheraddr_string((hp)->bssid), etheraddr_string((hp)->da),
+ etheraddr_string((hp)->sa));
+}
+
+static void ctrl_header_print(u_int16_t fc,const u_char *p, u_int length)
+{
+ switch (FC_SUBTYPE(fc)) {
+ case CTRL_PS_POLL:
+ printf("BSSID:%s TA:%s ",
+ etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
+ etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta));
+ break;
+ case CTRL_RTS:
+ printf("RA:%s TA:%s ",
+ etheraddr_string(((const struct ctrl_rts_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+ break;
+ case CTRL_CTS:
+ printf("RA:%s ",
+ etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+ break;
+ case CTRL_ACK:
+ printf("RA:%s ",
+ etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+ break;
+ case CTRL_CF_END:
+ printf("RA:%s BSSID:%s ",
+ etheraddr_string(((const struct ctrl_end_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_end_t *)p)->bssid));
+ break;
+ case CTRL_END_ACK:
+ printf("RA:%s BSSID:%s ",
+ etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid));
+ break;
+ default:
+ printf("(H) Unknown Ctrl Subtype");
+ }
+}
+
+static int GetHeaderLength(u_int16_t fc)
+{
+ int iLength=0;
+
+ switch (FC_TYPE(fc)) {
+ case T_MGMT:
+ iLength = MGMT_HEADER_LEN;
+ break;
+ case T_CTRL:
+ switch (FC_SUBTYPE(fc)) {
+ case CTRL_PS_POLL:
+ iLength = CTRL_PS_POLL_LEN;
+ break;
+ case CTRL_RTS:
+ iLength = CTRL_RTS_LEN;
+ break;
+ case CTRL_CTS:
+ iLength = CTRL_CTS_LEN;
+ break;
+ case CTRL_ACK:
+ iLength = CTRL_ACK_LEN;
+ break;
+ case CTRL_CF_END:
+ iLength = CTRL_END_LEN;
+ break;
+ case CTRL_END_ACK:
+ iLength = CTRL_END_ACK_LEN;
+ break;
+ default:
+ iLength = 0;
+ break;
+ }
+ break;
+ case T_DATA:
+ if (FC_TO_DS(fc) && FC_FROM_DS(fc))
+ iLength = 30;
+ else
+ iLength = 24;
+ break;
+ default:
+ printf("unknown IEEE802.11 frame type (%d)",
+ FC_TYPE(fc));
+ break;
+ }
+
+ return iLength;
+}
+
+/*
+ * Print the 802.11 MAC header
+ */
+static inline void
+ieee_802_11_print(u_int16_t fc, const u_char *p, u_int length)
+{
+ switch (FC_TYPE(fc)) {
+ case T_MGMT:
+ mgmt_header_print(p, length);
+ break;
+
+ case T_CTRL:
+ ctrl_header_print(fc, p, length);
+ break;
+
+ case T_DATA:
+ data_header_print(fc, p, length);
+ break;
+
+ default:
+ printf("(header) unknown IEEE802.11 frame type (%d)",
+ FC_TYPE(fc));
+ break;
+ }
+}
+
+/*
+ * 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
+ieee802_11_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+ u_int caplen = h->caplen;
+ u_int length = h->len;
+ u_int16_t fc;
+ u_int HEADER_LENGTH;
+ u_short extracted_ethertype;
+
+ ++infodelay;
+ ts_print(&h->ts);
+
+ if (caplen < IEEE802_11_FC_LEN) {
+ printf("[|802.11]");
+ goto out;
+ }
+
+ fc=EXTRACT_LE_16BITS(p);
+
+ if (eflag)
+ ieee_802_11_print(fc, p, 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.
+ */
+ packetp = p;
+ snapend = p + caplen;
+
+ HEADER_LENGTH=GetHeaderLength(fc);
+
+ length -= HEADER_LENGTH;
+ caplen -= HEADER_LENGTH;
+ p += HEADER_LENGTH;
+
+ switch (FC_TYPE(fc)) {
+ case T_MGMT:
+ if (!mgmt_body_print(fc, (const struct mgmt_header_t *)packetp,
+ p, length)) {
+ printf("[|802.11]");
+ goto out;
+ }
+ break;
+
+ case T_CTRL:
+ if (!ctrl_body_print(fc, p - HEADER_LENGTH,
+ length + HEADER_LENGTH)) {
+ printf("[|802.11]");
+ goto out;
+ }
+ break;
+
+ case T_DATA:
+ /* There may be a problem w/ AP not having this bit set */
+ if (FC_WEP(fc)) {
+ if (!wep_print(p,length)) {
+ printf("[|802.11]");
+ goto out;
+ }
+ } else {
+ if (llc_print(p, length, caplen, packetp + 10,
+ packetp + 4, &extracted_ethertype) == 0) {
+ /*
+ * Some kinds of LLC packet we cannot
+ * handle intelligently
+ */
+ if (!eflag)
+ ieee_802_11_print(fc, p - HEADER_LENGTH,
+ length + HEADER_LENGTH);
+ if (extracted_ethertype) {
+ printf("(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype)));
+ }
+ if (!xflag && !qflag)
+ default_print(p, caplen);
+ }
+ }
+ break;
+
+ default:
+ printf("(body) unhandled IEEE802.11 frame type (%d)",
+ FC_TYPE(fc));
+ break;
+ }
+
+ if (xflag)
+ default_print(p, caplen);
+ out:
+ putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
+}
diff --git a/contrib/tcpdump/print-ah.c b/contrib/tcpdump/print-ah.c
index c7a4fab8d58d..50af4d412333 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.14 2000/12/12 09:58:40 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.15 2001/09/17 21:57:54 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,11 +52,10 @@ ah_print(register const u_char *bp, register const u_char *bp2)
int sumlen;
u_int32_t spi;
- ah = (struct ah *)bp;
+ ah = (const struct ah *)bp;
ep = snapend; /* 'ep' points to the end of available data. */
- if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
- goto trunc;
+ TCHECK(*ah);
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
@@ -64,7 +63,7 @@ ah_print(register const u_char *bp, register const u_char *bp2)
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)));
+ printf(",seq=0x%x", (u_int32_t)ntohl(*(const u_int32_t *)(ah + 1)));
if (bp + sizeof(struct ah) + sumlen > ep)
fputs("[truncated]", stdout);
fputs("): ", stdout);
diff --git a/contrib/tcpdump/print-arcnet.c b/contrib/tcpdump/print-arcnet.c
new file mode 100644
index 000000000000..3b6ea90f4993
--- /dev/null
+++ b/contrib/tcpdump/print-arcnet.c
@@ -0,0 +1,248 @@
+/*
+ * 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.
+ *
+ * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
+ */
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.6 2001/09/17 21:57:54 fenner 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 <pcap.h>
+
+#include "interface.h"
+#include "arcnet.h"
+
+int arcnet_encap_print(u_char arctype, const u_char *p,
+ u_int length, u_int caplen);
+
+struct tok arctypemap[] = {
+ { ARCTYPE_IP_OLD, "oldip" },
+ { ARCTYPE_ARP_OLD, "oldarp" },
+ { ARCTYPE_IP, "ip" },
+ { ARCTYPE_ARP, "arp" },
+ { ARCTYPE_REVARP, "rarp" },
+ { ARCTYPE_ATALK, "atalk" },
+ { ARCTYPE_BANIAN, "banyan" },
+ { ARCTYPE_IPX, "ipx" },
+ { ARCTYPE_INET6, "ipv6" },
+ { ARCTYPE_DIAGNOSE, "diag" },
+ { 0, 0 }
+};
+
+static inline void
+arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
+{
+ const struct arc_header *ap;
+ const char *arctypename;
+
+
+ ap = (const struct arc_header *)bp;
+
+
+ if (qflag) {
+ (void)printf("%02x %02x %d: ",
+ ap->arc_shost,
+ ap->arc_dhost,
+ length);
+ return;
+ }
+
+ arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
+
+ if (!phds) {
+ (void)printf("%02x %02x %s %d: ",
+ ap->arc_shost, ap->arc_dhost, arctypename,
+ length);
+ return;
+ }
+
+ if (flag == 0) {
+ (void)printf("%02x %02x %s seqid %04x %d: ",
+ ap->arc_shost, ap->arc_dhost, arctypename, seqid,
+ length);
+ return;
+ }
+
+ if (flag & 1)
+ (void)printf("%02x %02x %s seqid %04x "
+ "(first of %d fragments) %d: ",
+ ap->arc_shost, ap->arc_dhost, arctypename, seqid,
+ (flag + 3) / 2, length);
+ else
+ (void)printf("%02x %02x %s seqid %04x "
+ "(fragment %d) %d: ",
+ ap->arc_shost, ap->arc_dhost, arctypename, seqid,
+ flag/2 + 1, length);
+}
+
+/*
+ * This is the top level routine of the printer. 'p' is the points
+ * to the ether 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.
+ */
+void
+arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+ u_int caplen = h->caplen;
+ u_int length = h->len;
+ const struct arc_header *ap;
+
+ int phds, flag = 0, archdrlen = 0;
+ u_int seqid = 0;
+ u_char arc_type;
+
+ ++infodelay;
+ ts_print(&h->ts);
+
+ if (caplen < ARC_HDRLEN) {
+ printf("[|arcnet]");
+ goto out;
+ }
+
+ ap = (const struct arc_header *)p;
+ arc_type = ap->arc_type;
+
+ switch (arc_type) {
+ default:
+ phds = 1;
+ break;
+ case ARCTYPE_IP_OLD:
+ case ARCTYPE_ARP_OLD:
+ case ARCTYPE_DIAGNOSE:
+ phds = 0;
+ archdrlen = ARC_HDRLEN;
+ break;
+ }
+
+ if (phds) {
+ if (caplen < ARC_HDRNEWLEN) {
+ arcnet_print(p, length, 0, 0, 0);
+ printf("[|phds]");
+ goto out;
+ }
+
+ if (ap->arc_flag == 0xff) {
+ if (caplen < ARC_HDRNEWLEN_EXC) {
+ arcnet_print(p, length, 0, 0, 0);
+ printf("[|phds extended]");
+ goto out;
+ }
+ flag = ap->arc_flag2;
+ seqid = ap->arc_seqid2;
+ archdrlen = ARC_HDRNEWLEN_EXC;
+ } else {
+ flag = ap->arc_flag;
+ seqid = ap->arc_seqid;
+ archdrlen = ARC_HDRNEWLEN;
+ }
+ }
+
+
+ if (eflag)
+ arcnet_print(p, length, phds, flag, seqid);
+
+ /*
+ * 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.
+ */
+ packetp = p;
+ snapend = p + caplen;
+
+ length -= archdrlen;
+ caplen -= archdrlen;
+ p += archdrlen;
+
+ if (phds && flag && (flag & 1) == 0)
+ goto out2;
+
+ if (!arcnet_encap_print(arc_type, p, length, caplen)) {
+ default_print(p, caplen);
+ goto out;
+ }
+
+ out2:
+ if (xflag)
+ default_print(p, caplen);
+
+ out:
+ putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
+}
+
+/*
+ * Prints the packet encapsulated in an ARCnet data field,
+ * given the ARCnet system code.
+ *
+ * Returns non-zero if it can do so, zero if the system code is unknown.
+ */
+
+
+int
+arcnet_encap_print(u_char arctype, const u_char *p,
+ u_int length, u_int caplen)
+{
+ switch (arctype) {
+
+ case ARCTYPE_IP_OLD:
+ case ARCTYPE_IP:
+ ip_print(p, length);
+ return (1);
+
+#ifdef INET6
+ case ARCTYPE_INET6:
+ ip6_print(p, length);
+ return (1);
+#endif /*INET6*/
+
+ case ARCTYPE_ARP_OLD:
+ case ARCTYPE_ARP:
+ case ARCTYPE_REVARP:
+ arp_print(p, length, caplen);
+ return (1);
+
+ case ARCTYPE_ATALK: /* XXX was this ever used? */
+ if (vflag)
+ fputs("et1 ", stdout);
+ atalk_print(p, length);
+ return (1);
+
+ default:
+ return (0);
+ }
+}
diff --git a/contrib/tcpdump/print-beep.c b/contrib/tcpdump/print-beep.c
new file mode 100644
index 000000000000..51c1295aef32
--- /dev/null
+++ b/contrib/tcpdump/print-beep.c
@@ -0,0 +1,73 @@
+/*
+ * 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-beep.c
+ *
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.1 2001/12/10 08:21:24 guy 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 ...
+ */
+
+static int l_strnstart(const char *, u_int, const char *, u_int);
+
+static int
+l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
+{
+
+ if (tl1 > l2)
+ return 0;
+
+ return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
+}
+
+void
+beep_print(const u_char *bp, u_int length)
+{
+
+ if (l_strnstart("MSG", 4, bp, length)) /* A REQuest */
+ printf(" BEEP MSG");
+ else if (l_strnstart("RPY ", 4, bp, length))
+ printf(" BEEP RPY");
+ else if (l_strnstart("ERR ", 4, bp, length))
+ printf(" BEEP ERR");
+ else if (l_strnstart("ANS ", 4, bp, length))
+ printf(" BEEP ANS");
+ else if (l_strnstart("NUL ", 4, bp, length))
+ printf(" BEEP NUL");
+ else if (l_strnstart("SEQ ", 4, bp, length))
+ printf(" BEEP SEQ");
+ else if (l_strnstart("END", 4, bp, length))
+ printf(" BEEP END");
+ else
+ printf(" BEEP (payload or undecoded)");
+}
diff --git a/contrib/tcpdump/print-bgp.c b/contrib/tcpdump/print-bgp.c
index 71f20c3eaea1..342292bb442c 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.21 2000/12/05 05:48:35 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.27 2001/10/18 09:52:17 itojun Exp $";
#endif
#include <sys/param.h>
@@ -75,12 +75,14 @@ struct bgp_open {
u_int8_t bgpo_optlen;
/* options should follow */
};
+#define BGP_OPEN_SIZE 29 /* unaligned */
struct bgp_opt {
u_int8_t bgpopt_type;
u_int8_t bgpopt_len;
/* variable length */
};
+#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
struct bgp_notification {
u_int8_t bgpn_marker[16];
@@ -90,6 +92,7 @@ struct bgp_notification {
u_int8_t bgpn_minor;
/* data should follow */
};
+#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
struct bgp_attr {
u_int8_t bgpa_flags;
@@ -128,7 +131,7 @@ static const char *bgptype[] = {
#define bgp_type(x) num_or_str(bgptype, sizeof(bgptype)/sizeof(bgptype[0]), (x))
static const char *bgpopt_type[] = {
- NULL, "Authentication Information",
+ NULL, "Authentication Information", "Capabilities Advertisement",
};
#define bgp_opttype(x) \
num_or_str(bgpopt_type, sizeof(bgpopt_type)/sizeof(bgpopt_type[0]), (x))
@@ -192,7 +195,7 @@ static const char *bgpattr_type[] = {
/* Subsequent address family identifier, RFC2283 section 7 */
static const char *bgpattr_nlri_safi[] = {
- "Reserved", "Unicast", "Multicast", "Unicast+Multicast",
+ "Reserved", "Unicast", "Multicast", "Unicast+Multicast",
};
#define bgp_attr_nlri_safi(x) \
num_or_str(bgpattr_nlri_safi, \
@@ -270,10 +273,10 @@ bgp_notify_minor(int major, int minor)
}
static int
-decode_prefix4(const u_char *pd, char *buf, int buflen)
+decode_prefix4(const u_char *pd, char *buf, u_int buflen)
{
struct in_addr addr;
- int plen;
+ u_int plen;
plen = pd[0];
if (plen < 0 || 32 < plen)
@@ -291,10 +294,10 @@ decode_prefix4(const u_char *pd, char *buf, int buflen)
#ifdef INET6
static int
-decode_prefix6(const u_char *pd, char *buf, int buflen)
+decode_prefix6(const u_char *pd, char *buf, u_int buflen)
{
struct in6_addr addr;
- int plen;
+ u_int plen;
plen = pd[0];
if (plen < 0 || 128 < plen)
@@ -306,7 +309,7 @@ decode_prefix6(const u_char *pd, char *buf, int buflen)
addr.s6_addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname6((char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
#endif
@@ -346,9 +349,9 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
if (p[0] == 3 || p[0] == 4)
printf("confed");
printf("%s", (p[0] & 1) ? "{" : "");
- for (i = 0; i < p[1]; i += 2) {
+ for (i = 0; i < p[1] * 2; i += 2) {
printf("%s%u", i == 0 ? "" : " ",
- ntohs(*(u_int16_t *)&p[2 + i]));
+ EXTRACT_16BITS(&p[2 + i]));
}
printf("%s", (p[0] & 1) ? "}" : "");
p += 2 + p[1] * 2;
@@ -365,7 +368,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
if (len != 4)
printf(" invalid len");
else
- printf(" %u", (u_int32_t)ntohl(*(u_int32_t *)p));
+ printf(" %u", EXTRACT_32BITS(p));
break;
case BGPTYPE_ATOMIC_AGGREGATE:
if (len != 0)
@@ -376,7 +379,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf(" invalid len");
break;
}
- printf(" AS #%u, origin %s", ntohs(*(u_int16_t *)p),
+ printf(" AS #%u, origin %s", EXTRACT_16BITS(p),
getname(p + 2));
break;
case BGPTYPE_COMMUNITIES:
@@ -386,7 +389,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
}
for (i = 0; i < len; i += 4) {
u_int32_t comm;
- comm = (u_int32_t)ntohl(*(u_int32_t *)&p[i]);
+ comm = EXTRACT_32BITS(&p[i]);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
printf(" NO_EXPORT");
@@ -405,7 +408,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
}
break;
case BGPTYPE_MP_REACH_NLRI:
- af = ntohs(*(u_int16_t *)p);
+ af = EXTRACT_16BITS(p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
@@ -487,7 +490,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
break;
case BGPTYPE_MP_UNREACH_NLRI:
- af = ntohs(*(u_int16_t *)p);
+ af = EXTRACT_16BITS(p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
@@ -534,8 +537,8 @@ 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));
+ TCHECK2(dat[0], BGP_OPEN_SIZE);
+ memcpy(&bgpo, dat, BGP_OPEN_SIZE);
hlen = ntohs(bgpo.bgpo_len);
printf(": Version %d,", bgpo.bgpo_version);
@@ -545,11 +548,13 @@ bgp_open_print(const u_char *dat, int length)
printf(" Option length %u", bgpo.bgpo_optlen);
/* ugly! */
- opt = &((struct bgp_open *)dat)->bgpo_optlen;
+ opt = &((const struct bgp_open *)dat)->bgpo_optlen;
opt++;
- for (i = 0; i < bgpo.bgpo_optlen; i++) {
- memcpy(&bgpopt, &opt[i], sizeof(bgpopt));
+ i = 0;
+ while (i < bgpo.bgpo_optlen) {
+ TCHECK2(opt[i], BGP_OPT_SIZE);
+ memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE);
if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type);
break;
@@ -557,7 +562,7 @@ bgp_open_print(const u_char *dat, int length)
printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type),
bgpopt.bgpopt_len);
- i += sizeof(bgpopt) + bgpopt.bgpopt_len;
+ i += BGP_OPT_SIZE + bgpopt.bgpopt_len;
}
return;
trunc:
@@ -575,8 +580,8 @@ bgp_update_print(const u_char *dat, int length)
int i;
int newline;
- TCHECK2(dat[0], sizeof(bgp));
- memcpy(&bgp, dat, sizeof(bgp));
+ TCHECK2(dat[0], BGP_SIZE);
+ memcpy(&bgp, dat, BGP_SIZE);
hlen = ntohs(bgp.bgp_len);
p = dat + BGP_SIZE; /*XXX*/
printf(":");
@@ -584,9 +589,10 @@ bgp_update_print(const u_char *dat, int length)
/* Unfeasible routes */
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.
+ /*
+ * 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);
@@ -680,8 +686,8 @@ 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));
+ TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
+ memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
hlen = ntohs(bgpn.bgpn_len);
printf(": error %s,", bgp_notify_major(bgpn.bgpn_major));
@@ -697,8 +703,8 @@ bgp_header_print(const u_char *dat, int length)
{
struct bgp bgp;
- TCHECK2(dat[0], sizeof(bgp));
- memcpy(&bgp, dat, sizeof(bgp));
+ TCHECK2(dat[0], BGP_SIZE);
+ memcpy(&bgp, dat, BGP_SIZE);
printf("(%s", bgp_type(bgp.bgp_type)); /* ) */
switch (bgp.bgp_type) {
@@ -759,8 +765,8 @@ bgp_print(const u_char *dat, int length)
}
/* found BGP header */
- TCHECK2(p[0], sizeof(bgp)); /*XXX*/
- memcpy(&bgp, p, sizeof(bgp));
+ TCHECK2(p[0], BGP_SIZE); /*XXX*/
+ memcpy(&bgp, p, BGP_SIZE);
if (start != p)
printf(" [|BGP]");
diff --git a/contrib/tcpdump/print-cdp.c b/contrib/tcpdump/print-cdp.c
index 53eff989930e..a73fc3fe14bb 100644
--- a/contrib/tcpdump/print-cdp.c
+++ b/contrib/tcpdump/print-cdp.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.4 2000/07/29 07:27:54 assar Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.11 2001/09/17 21:57:56 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -47,141 +47,216 @@ static const char rcsid[] =
#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 );
+static int cdp_print_addr(const u_char *, int);
+static int cdp_print_prefixes(const u_char *, int);
-/*
- * 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;
+ u_int i;
int type, len;
/* Cisco Discovery Protocol */
-
- if ( caplen < 12 ) {
+ if (caplen < 4) {
(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 */
+ i = 0; /* CDP data starts at offset 0 */
+ printf("CDP v%u, ttl=%us", 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 (i + 4 > caplen)
+ goto trunc;
+ 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 (vflag > 1)
+ 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;
+ if (vflag)
+ printf(" %02x/%02x", type, len);
+
+ if (i + len > caplen)
+ goto trunc;
+
+ switch (type) {
+ case 0x00:
+ printf(" Goodbye");
+ break;
+ case 0x01:
+ printf(" DevID '%.*s'", len - 4, p + i + 4);
+ break;
+ case 0x02:
+ printf(" Addr");
+ if (cdp_print_addr(p + i + 4, len - 4) < 0)
+ goto trunc;
+ 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 > 1)
+ 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:
+ if (cdp_print_prefixes(p + i + 4, len - 4) < 0)
+ goto trunc;
+ 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);
+ break;
+ }
+
+ /* avoid infinite loop */
+ if (len == 0)
+ break;
+ i += len;
}
+
+ return;
+
+trunc:
+ printf("[|cdp]");
}
-static void
-cdp_print_addr( const u_char * p, int l )
+/*
+ * Protocol type values.
+ *
+ * PT_NLPID means that the protocol type field contains an OSI NLPID.
+ *
+ * PT_IEEE_802_2 means that the protocol type field contains an IEEE 802.2
+ * LLC header that specifies that the payload is for that protocol.
+ */
+#define PT_NLPID 1 /* OSI NLPID */
+#define PT_IEEE_802_2 2 /* IEEE 802.2 LLC header */
+
+static int
+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++);
+ int pt, pl, al, num;
+ const u_char *endp = p + l;
+#ifdef INET6
+ static u_char prot_ipv6[] = {
+ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
+ };
+#endif
+
+ num = EXTRACT_32BITS(p);
+ p += 4;
+
+ printf(" (%d): ", num);
+
+ while (p < endp && num >= 0) {
+ if (p + 2 > endp)
+ goto trunc;
+ pt = p[0]; /* type of "protocol" field */
+ pl = p[1]; /* length of "protocol" field */
+ p += 2;
+
+ if (p + pl + 2 > endp)
+ goto trunc;
+ al = EXTRACT_16BITS(&p[pl]); /* address length */
+
+ if (pt == PT_NLPID && pl == 1 && *p == 0xcc && al == 4) {
+ /*
+ * IPv4: protocol type = NLPID, protocol length = 1
+ * (1-byte NLPID), protocol = 0xcc (NLPID for IPv4),
+ * address length = 4
+ */
+ p += 3;
+
+ if (p + 4 > endp)
+ goto trunc;
+ printf("IPv4 %u.%u.%u.%u", p[0], p[1], p[2], p[3]);
+ p += 4;
+ }
+#ifdef INET6
+ else if (pt == PT_IEEE_802_2 && pl == 8 &&
+ memcmp(p, prot_ipv6, 8) == 0 && al == 16) {
+ /*
+ * IPv6: protocol type = IEEE 802.2 header,
+ * protocol length = 8 (size of LLC+SNAP header),
+ * protocol = LLC+SNAP header with the IPv6
+ * Ethertype, address length = 16
+ */
+ p += 10;
+ if (p + al > endp)
+ goto trunc;
+
+ printf("IPv6 %s", ip6addr_string(p));
+ p += al;
+ }
+#endif
+ else {
+ /*
+ * Generic case: just print raw data
+ */
+ if (p + pl > endp)
+ goto trunc;
+ printf("pt=0x%02x, pl=%d, pb=", *(p - 2), pl);
+ while (pl-- > 0)
+ printf(" %02x", *p++);
+ if (p + 2 > endp)
+ goto trunc;
+ al = (*p << 8) + *(p + 1);
+ printf(", al=%d, a=", al);
+ p += 2;
+ if (p + al > endp)
+ goto trunc;
+ while (al-- > 0)
+ printf(" %02x", *p++);
}
- printf(" ");
num--;
+ if (num)
+ printf(" ");
}
+
+ return 0;
+
+trunc:
+ return -1;
}
-static void
-cdp_print_prefixes( const u_char * p, int l )
+static int
+cdp_print_prefixes(const u_char * p, int l)
{
- printf( " IPv4 Prefixes (%d):", l/5 );
+ if (l % 5)
+ goto trunc;
+
+ printf(" IPv4 Prefixes (%d):", l / 5);
+
+ while (l > 0) {
+ printf(" %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]);
+ l -= 5;
+ p += 5;
+ }
+
+ return 0;
- while(l > 0) {
- printf( " %d.%d.%d.%d/%d", p[0], p[1], p[2], p[3], p[4] );
- l-=5; p+=5;
- }
+trunc:
+ return -1;
}
diff --git a/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c
index 09c58abb41f4..f6ff53378686 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.11 2000/10/09 01:53:19 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.13 2001/09/17 21:57:57 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,6 +42,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "extract.h"
#include "ppp.h"
#include "chdlc.h"
@@ -54,25 +55,38 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- const struct ip *ip;
- u_int proto;
+ ++infodelay;
ts_print(&h->ts);
- if (caplen < CHDLC_HDRLEN) {
- printf("[|chdlc]");
- 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;
+ chdlc_print(p, length, caplen);
+
+ putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
+}
+
+void
+chdlc_print(register const u_char *p, u_int length, u_int caplen)
+{
+ const struct ip *ip;
+ u_int proto;
+
+ if (caplen < CHDLC_HDRLEN) {
+ printf("[|chdlc]");
+ return;
+ }
+
+ proto = EXTRACT_16BITS(&p[2]);
if (eflag) {
switch (p[0]) {
case CHDLC_UNICAST:
@@ -89,7 +103,7 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
}
length -= CHDLC_HDRLEN;
- ip = (struct ip *)(p + CHDLC_HDRLEN);
+ ip = (const struct ip *)(p + CHDLC_HDRLEN);
switch (proto) {
case ETHERTYPE_IP:
ip_print((const u_char *)ip, length);
@@ -110,8 +124,6 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
}
if (xflag)
default_print((const u_char *)ip, caplen - CHDLC_HDRLEN);
-out:
- putchar('\n');
}
struct cisco_slarp {
@@ -140,14 +152,14 @@ struct cisco_slarp {
static void
chdlc_slarp_print(const u_char *cp, u_int length)
{
- struct cisco_slarp *slarp;
+ const struct cisco_slarp *slarp;
if (length < SLARP_LEN) {
printf("[|slarp]");
return;
}
- slarp = (struct cisco_slarp *)cp;
+ slarp = (const struct cisco_slarp *)cp;
switch (ntohl(slarp->code)) {
case SLARP_REQUEST:
printf("slarp-request");
diff --git a/contrib/tcpdump/print-cip.c b/contrib/tcpdump/print-cip.c
index 1d244c27912b..40228cd5930d 100644
--- a/contrib/tcpdump/print-cip.c
+++ b/contrib/tcpdump/print-cip.c
@@ -22,13 +22,15 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.11 2000/12/22 22:45:10 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.16 2001/09/23 21:52:38 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <string.h>
+
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -45,9 +47,6 @@ static const char rcsid[] =
#include "ethertype.h"
#include "ether.h"
-const u_char *packetp;
-const u_char *snapend;
-
#define RFC1483LLC_LEN 8
static unsigned char rfcllc[] = {
@@ -61,25 +60,10 @@ static unsigned char rfcllc[] = {
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);
- }
- }
+ /*
+ * There is no MAC-layer header, so just print the length.
+ */
+ printf("%d: ", length);
}
/*
@@ -91,12 +75,11 @@ cip_print(register const u_char *bp, int length)
void
cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
- int caplen = h->caplen;
- int length = h->len;
- u_short ether_type;
+ u_int caplen = h->caplen;
+ u_int length = h->len;
u_short extracted_ethertype;
- u_short *bp;
+ ++infodelay;
ts_print(&h->ts);
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
@@ -115,28 +98,15 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
packetp = 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;
- bp = (u_short *)p;
- }
-
- /*
- * Is it (gag) an 802.3 encapsulation?
- */
- extracted_ethertype = 0;
- if (ether_type < ETHERMTU) {
- /* Try to print the LLC-layer header & higher layers */
+ if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
+ /*
+ * LLC header is present. Try to print it & higher layers.
+ */
if (llc_print(p, length, caplen, NULL, NULL,
- &extracted_ethertype)==0) {
+ &extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- cip_print((u_char *)bp, length + RFC1483LLC_LEN);
+ cip_print(p, length);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@@ -144,16 +114,18 @@ 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,
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- cip_print((u_char *)bp, length + RFC1483LLC_LEN);
- if (!xflag && !qflag)
- default_print(p, caplen);
+ } else {
+ /*
+ * LLC header is absent; treat it as just IP.
+ */
+ ip_print(p, length);
}
+
if (xflag)
default_print(p, caplen);
out:
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
}
diff --git a/contrib/tcpdump/print-cnfp.c b/contrib/tcpdump/print-cnfp.c
index 265599ce9d39..206438e2b82d 100644
--- a/contrib/tcpdump/print-cnfp.c
+++ b/contrib/tcpdump/print-cnfp.c
@@ -34,7 +34,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.6 2000/09/23 08:26:32 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.8 2001/09/17 21:57:58 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -78,8 +78,8 @@ struct nfrec {
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 */
-
+ u_int32_t masks; /* src,dst addr prefix; v6: encaps */
+ struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/
};
void
@@ -92,10 +92,10 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
int nrecs, ver;
time_t t;
- ip = (struct ip *)bp;
- nh = (struct nfhdr *)cp;
+ ip = (const struct ip *)bp;
+ nh = (const struct nfhdr *)cp;
- if ((u_char *)(nh + 1) > snapend)
+ if ((const u_char *)(nh + 1) > snapend)
return;
nrecs = ntohl(nh->ver_cnt) & 0xffff;
@@ -108,18 +108,18 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
(unsigned)ntohl(nh->msys_uptime)%1000,
(unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec));
- if (ver == 5) {
+ if (ver == 5 || ver == 6) {
printf("#%u, ", (unsigned)htonl(nh->sequence));
- nr = (struct nfrec *)&nh[1];
+ nr = (const struct nfrec *)&nh[1];
snaplen -= 24;
} else {
- nr = (struct nfrec *)&nh->sequence;
+ nr = (const struct nfrec *)&nh->sequence;
snaplen -= 16;
}
printf("%2u recs", nrecs);
- for (; nrecs-- && (u_char *)(nr + 1) <= snapend; nr++) {
+ for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) {
char buf[20];
char asbuf[20];
@@ -130,19 +130,19 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
(unsigned)ntohl(nr->last_time)%1000);
asbuf[0] = buf[0] = '\0';
- if (ver == 5) {
+ if (ver == 5 || ver == 6) {
snprintf(buf, sizeof(buf), "/%u",
(unsigned)(ntohl(nr->masks) >> 24) & 0xff);
- snprintf(asbuf, sizeof(asbuf), "%u:",
+ 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) {
+ if (ver == 5 || ver ==6) {
snprintf(buf, sizeof(buf), "/%d",
(unsigned)(ntohl(nr->masks) >> 16) & 0xff);
- snprintf(asbuf, sizeof(asbuf), "%u:",
+ snprintf(asbuf, sizeof(asbuf), ":%u",
(unsigned)ntohl(nr->asses) & 0xffff);
}
printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf,
@@ -173,9 +173,16 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
if (flags)
putchar(' ');
}
- printf("tos %u, %u (%u octets)",
+
+ buf[0]='\0';
+ if (ver == 6) {
+ snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
+ (unsigned)(ntohl(nr->masks) >> 8) & 0xff,
+ (unsigned)(ntohl(nr->masks)) & 0xff);
+ }
+ printf("tos %u, %u (%u octets) %s",
(unsigned)ntohl(nr->proto_tos) & 0xff,
(unsigned)ntohl(nr->packets),
- (unsigned)ntohl(nr->octets));
+ (unsigned)ntohl(nr->octets), buf);
}
}
diff --git a/contrib/tcpdump/print-decnet.c b/contrib/tcpdump/print-decnet.c
index d589bc94564b..8c51a6747e1f 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.30 2000/09/28 06:42:57 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.33 2001/09/17 21:57:59 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -730,7 +730,7 @@ print_reason(register int reason)
printf("%s ", tok2str(reason2str, "reason-%d", reason));
}
-char *
+const char *
dnnum_string(u_short dnaddr)
{
char *str;
@@ -745,7 +745,7 @@ dnnum_string(u_short dnaddr)
return(str);
}
-char *
+const char *
dnname_string(u_short dnaddr)
{
#ifdef HAVE_LIBDNET
@@ -753,7 +753,7 @@ dnname_string(u_short dnaddr)
dna.a_len = sizeof(short);
memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
- return (savestr(dnet_htoa(&dna)));
+ return (strdup(dnet_htoa(&dna)));
#else
return(dnnum_string(dnaddr)); /* punt */
#endif
@@ -768,10 +768,7 @@ pdata(u_char *dp, u_int maxlen)
while (x-- > 0) {
c = *dp++;
- if (isprint(c))
- putchar(c);
- else
- printf("\\%o", c & 0xFF);
+ safeputchar(c);
}
}
#endif
diff --git a/contrib/tcpdump/print-dhcp6.c b/contrib/tcpdump/print-dhcp6.c
index c9848f06bcbc..e42febf072b2 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.12 2000/10/24 00:56:50 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.14 2001/09/17 21:57:59 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -56,12 +56,12 @@ struct rtentry;
#include "dhcp6opt.h"
#if 0
-static void dhcp6opttab_init (void);
-static struct dhcp6_opt *dhcp6opttab_byname (char *);
+static void dhcp6opttab_init(void);
+static struct dhcp6_opt *dhcp6opttab_byname(char *);
#endif
-static struct dhcp6_opt *dhcp6opttab_bycode (u_int);
+static struct dhcp6_opt *dhcp6opttab_bycode(u_int);
-static char tstr[] = " [|dhcp6]";
+static const char tstr[] = " [|dhcp6]";
static struct dhcp6_opt dh6opttab[] = {
/* IP Address Extension */
diff --git a/contrib/tcpdump/print-dvmrp.c b/contrib/tcpdump/print-dvmrp.c
index 04abc2c907ef..273c7d635585 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.20 2000/09/29 04:58:36 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.21 2001/05/10 05:30:20 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -50,9 +50,7 @@ static const char rcsid[] =
#define DVMRP_PROBE 1 /* for finding neighbors */
#define DVMRP_REPORT 2 /* for reporting some or all routes */
#define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */
- /*
- * of this router's neighbors
- */
+ /* of this router's neighbors */
#define DVMRP_NEIGHBORS 4 /* response to such a request */
#define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */
#define DVMRP_NEIGHBORS2 6
@@ -90,11 +88,9 @@ dvmrp_print(register const u_char *bp, register u_int len)
return;
type = bp[1];
- bp += 8;
- /*
- * Skip IGMP header
- */
+ /* Skip IGMP header */
+ bp += 8;
len -= 8;
switch (type) {
@@ -107,7 +103,7 @@ dvmrp_print(register const u_char *bp, register u_int len)
case DVMRP_REPORT:
printf(" Report");
- if (vflag)
+ if (vflag > 1)
print_report(bp, ep, len);
break;
@@ -222,7 +218,13 @@ print_probe(register const u_char *bp, register const u_char *ep,
genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
bp += 4;
len -= 4;
- printf("\n\tgenid %u", genid);
+ if (vflag > 1)
+ printf("\n\t");
+ else
+ printf(" ");
+ printf("genid %u", genid);
+ if (vflag < 2)
+ return;
while ((len > 0) && (bp < ep)) {
TCHECK2(bp[0], 4);
diff --git a/contrib/tcpdump/print-egp.c b/contrib/tcpdump/print-egp.c
index 5adb9ee3c4c8..56dfb26f3633 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.26 2000/09/29 04:58:36 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.28 2001/09/17 21:58:01 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -99,7 +99,7 @@ struct egp_packet {
#define egp_sourcenet egp_pands.egpu_sourcenet
};
-char *egp_acquire_codes[] = {
+const char *egp_acquire_codes[] = {
"request",
"confirm",
"refuse",
@@ -107,7 +107,7 @@ char *egp_acquire_codes[] = {
"cease_ack"
};
-char *egp_acquire_status[] = {
+const char *egp_acquire_status[] = {
"unspecified",
"active_mode",
"passive_mode",
@@ -118,18 +118,18 @@ char *egp_acquire_status[] = {
"protocol_violation"
};
-char *egp_reach_codes[] = {
+const char *egp_reach_codes[] = {
"hello",
"i-h-u"
};
-char *egp_status_updown[] = {
+const char *egp_status_updown[] = {
"indeterminate",
"up",
"down"
};
-char *egp_reasons[] = {
+const char *egp_reasons[] = {
"unspecified",
"bad_EGP_header_format",
"bad_EGP_data_field_format",
@@ -230,9 +230,7 @@ egp_print(register const u_char *bp, register u_int length,
egp = (struct egp_packet *)bp;
ip = (struct ip *)bp2;
- (void)printf("%s > %s: egp: ",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ (void)printf("egp: ");
if (egp->egp_version != EGP_VERSION) {
printf("[version %d]", egp->egp_version);
diff --git a/contrib/tcpdump/print-esp.c b/contrib/tcpdump/print-esp.c
index 7ebad59559b3..1bdf76a8697d 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.17 2000/12/12 09:58:41 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.20 2002/01/21 11:39:59 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -39,13 +39,13 @@ static const char rcsid[] =
#include <netinet/in.h>
#ifdef HAVE_LIBCRYPTO
-#include <des.h>
-#include <blowfish.h>
+#include <openssl/des.h>
+#include <openssl/blowfish.h>
#ifdef HAVE_RC5_H
-#include <rc5.h>
+#include <openssl/rc5.h>
#endif
#ifdef HAVE_CAST_H
-#include <cast.h>
+#include <openssl/cast.h>
#endif
#endif
@@ -57,28 +57,153 @@ static const char rcsid[] =
#include "ip6.h"
#endif
+#define AVOID_CHURN 1
#include "interface.h"
#include "addrtoname.h"
+static struct esp_algorithm *espsecret_xform=NULL; /* cache of decoded alg. */
+static char *espsecret_key=NULL;
+
+
+enum cipher { NONE,
+ DESCBC,
+ BLOWFISH,
+ RC5,
+ CAST128,
+ DES3CBC};
+
+
+
+struct esp_algorithm {
+ char *name;
+ enum cipher algo;
+ int ivlen;
+ int authlen;
+ int replaysize;
+};
+
+struct esp_algorithm esp_xforms[]={
+ {"none", NONE, 0, 0, 0},
+ {"des-cbc", DESCBC, 8, 0, 0},
+ {"des-cbc-hmac96", DESCBC, 8, 12, 4},
+ {"blowfish-cbc", BLOWFISH,8, 0, 0},
+ {"blowfish-cbc-hmac96", BLOWFISH,8, 12, 4},
+ {"rc5-cbc", RC5, 8, 0, 0},
+ {"rc5-cbc-hmac96", RC5, 8, 12, 4},
+ {"cast128-cbc", CAST128, 8, 0, 0},
+ {"cast128-cbc-hmac96", CAST128, 8, 12, 4},
+ {"3des-cbc-hmac96", DES3CBC, 8, 12, 4},
+};
+
+static int hexdigit(char hex)
+{
+ if(hex >= '0' && hex <= '9') {
+ return (hex - '0');
+ } else if(hex >= 'A' && hex <= 'F') {
+ return (hex - 'A' + 10);
+ } else if(hex >= 'a' && hex <= 'f') {
+ return (hex - 'a' + 10);
+ } else {
+ printf("invalid hex digit %c in espsecret\n", hex);
+ return 0;
+ }
+}
+
+static int hex2byte(char *hexstring)
+{
+ int byte;
+
+ byte = (hexdigit(hexstring[0]) << 4) +
+ hexdigit(hexstring[1]);
+ return byte;
+}
+
+
+void esp_print_decodesecret()
+{
+ char *colon;
+ int len, i;
+ struct esp_algorithm *xf;
+
+ if(espsecret == NULL) {
+ /* set to NONE transform */
+ espsecret_xform = esp_xforms;
+ return;
+ }
+
+ if(espsecret_key != NULL) {
+ return;
+ }
+
+ colon = strchr(espsecret, ':');
+ if(colon == NULL) {
+ printf("failed to decode espsecret: %s\n",
+ espsecret);
+ /* set to NONE transform */
+ espsecret_xform = esp_xforms;
+ }
+
+ len = colon - espsecret;
+ xf = esp_xforms;
+ while(xf->name && strncasecmp(espsecret, xf->name, len)!=0) {
+ xf++;
+ }
+ if(xf->name == NULL) {
+ printf("failed to find cipher algo %s\n",
+ espsecret);
+ espsecret_xform = esp_xforms;
+ return;
+ }
+ espsecret_xform = xf;
+
+ colon++;
+ if(colon[0]=='0' && colon[1]=='x') {
+ /* decode some hex! */
+ colon+=2;
+ len = strlen(colon) / 2;
+ espsecret_key = (char *)malloc(len);
+ if(espsecret_key == NULL) {
+ fprintf(stderr, "%s: ran out of memory (%d) to allocate secret key\n",
+ program_name, len);
+ exit(2);
+ }
+ i = 0;
+ while(colon[0] != '\0' && colon[1]!='\0') {
+ espsecret_key[i]=hex2byte(colon);
+ colon+=2;
+ i++;
+ }
+ } else {
+ espsecret_key = colon;
+ }
+}
+
int
-esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
+esp_print(register const u_char *bp, register const u_char *bp2,
+ int *nhdr, int *padlen)
{
register const struct esp *esp;
register const u_char *ep;
u_int32_t spi;
- enum { NONE, DESCBC, BLOWFISH, RC5, CAST128, DES3CBC } algo = NONE;
struct ip *ip = NULL;
#ifdef INET6
struct ip6_hdr *ip6 = NULL;
#endif
int advance;
int len;
- char *secret = NULL;
+ char *secret;
int ivlen = 0;
u_char *ivoff;
-
+ u_char *p;
+
esp = (struct esp *)bp;
spi = (u_int32_t)ntohl(esp->esp_spi);
+ secret = NULL;
+
+#if 0
+ /* keep secret out of a register */
+ p = (u_char *)&secret;
+#endif
/* 'ep' points to the end of available data. */
ep = snapend;
@@ -95,40 +220,11 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
if (!espsecret)
goto fail;
- if (strncmp(espsecret, "des-cbc:", 8) == 0
- && strlen(espsecret + 8) == 8) {
- algo = DESCBC;
- ivlen = 8;
- secret = espsecret + 8;
- } else if (strncmp(espsecret, "blowfish-cbc:", 13) == 0) {
- algo = BLOWFISH;
- ivlen = 8;
- secret = espsecret + 13;
- } else if (strncmp(espsecret, "rc5-cbc:", 8) == 0) {
- algo = RC5;
- ivlen = 8;
- secret = espsecret + 8;
- } else if (strncmp(espsecret, "cast128-cbc:", 12) == 0) {
- algo = CAST128;
- ivlen = 8;
- secret = espsecret + 12;
- } else if (strncmp(espsecret, "3des-cbc:", 9) == 0
- && strlen(espsecret + 9) == 24) {
- algo = DES3CBC;
- ivlen = 8;
- secret = espsecret + 9;
- } else if (strncmp(espsecret, "none:", 5) == 0) {
- algo = NONE;
- ivlen = 0;
- secret = espsecret + 5;
- } else if (strlen(espsecret) == 8) {
- algo = DESCBC;
- ivlen = 8;
- secret = espsecret;
- } else {
- algo = NONE;
- ivlen = 0;
- secret = espsecret;
+ if(!espsecret_xform) {
+ esp_print_decodesecret();
+ }
+ if(espsecret_xform->algo == NONE) {
+ goto fail;
}
ip = (struct ip *)bp2;
@@ -145,6 +241,9 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
break;
#endif /*INET6*/
case 4:
+ /* nexthdr & padding are in the last fragment */
+ if (ntohs(ip->ip_off) & IP_MF)
+ goto fail;
#ifdef INET6
ip6 = NULL;
#endif
@@ -158,18 +257,16 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
if (ep - bp2 < len)
goto fail;
- if (Rflag)
- ivoff = (u_char *)(esp + 1) + sizeof(u_int32_t);
- else
- ivoff = (u_char *)(esp + 1);
+ ivoff = (u_char *)(esp + 1) + espsecret_xform->replaysize;
+ ivlen = espsecret_xform->ivlen;
+ secret = espsecret_key;
- switch (algo) {
+ switch (espsecret_xform->algo) {
case DESCBC:
#ifdef HAVE_LIBCRYPTO
{
u_char iv[8];
des_key_schedule schedule;
- u_char *p;
switch (ivlen) {
case 4:
@@ -206,7 +303,6 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#ifdef HAVE_LIBCRYPTO
{
BF_KEY schedule;
- u_char *p;
BF_set_key(&schedule, strlen(secret), secret);
@@ -224,7 +320,6 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_RC5_H)
{
RC5_32_KEY schedule;
- u_char *p;
RC5_32_set_key(&schedule, strlen(secret), secret,
RC5_16_ROUNDS);
@@ -243,7 +338,6 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
{
CAST_KEY schedule;
- u_char *p;
CAST_set_key(&schedule, strlen(secret), secret);
@@ -261,16 +355,26 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#if defined(HAVE_LIBCRYPTO)
{
des_key_schedule s1, s2, s3;
- u_char *p;
- des_check_key = 0;
- des_set_key((void *)secret, s1);
- des_set_key((void *)(secret + 8), s2);
- des_set_key((void *)(secret + 16), s3);
+ des_check_key = 1;
+ des_set_odd_parity((void *)secret);
+ des_set_odd_parity((void *)secret+8);
+ des_set_odd_parity((void *)secret+16);
+ if(des_set_key((void *)secret, s1) != 0) {
+ printf("failed to schedule key 1\n");
+ }
+ if(des_set_key((void *)(secret + 8), s2)!=0) {
+ printf("failed to schedule key 2\n");
+ }
+ if(des_set_key((void *)(secret + 16), s3)!=0) {
+ printf("failed to schedule key 3\n");
+ }
p = ivoff + ivlen;
des_ede3_cbc_encrypt((void *)p, (void *)p,
- (long)(ep - p), s1, s2, s3, (void *)ivoff, DES_DECRYPT);
+ (long)(ep - p),
+ s1, s2, s3,
+ (void *)ivoff, DES_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
@@ -280,17 +384,18 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
case NONE:
default:
- if (Rflag)
- advance = sizeof(struct esp) + sizeof(u_int32_t);
- else
- advance = sizeof(struct esp);
+ advance = sizeof(struct esp) + espsecret_xform->replaysize;
break;
}
+ ep = ep - espsecret_xform->authlen;
/* sanity check for pad length */
if (ep - bp < *(ep - 2))
goto fail;
+ if (padlen)
+ *padlen = *(ep - 2) + 2;
+
if (nhdr)
*nhdr = *(ep - 1);
diff --git a/contrib/tcpdump/print-frag6.c b/contrib/tcpdump/print-frag6.c
index abf0cc6ca717..4553505a0c0a 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.12 2000/10/07 05:53:10 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.13 2001/09/17 21:58:02 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,12 +52,8 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
register const struct ip6_hdr *ip6;
register const u_char *ep;
-#if 0
-#define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
-#endif
-
- dp = (struct ip6_frag *)bp;
- ip6 = (struct ip6_hdr *)bp2;
+ dp = (const struct ip6_frag *)bp;
+ ip6 = (const struct ip6_hdr *)bp2;
/* 'ep' points to the end of available data. */
ep = snapend;
diff --git a/contrib/tcpdump/print-gre.c b/contrib/tcpdump/print-gre.c
index e79d300419ec..ebadb0e6f145 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.9 2000/12/18 05:41:59 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.13 2001/06/15 22:17:31 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -45,38 +45,31 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
-#define GRE_SIZE (20)
-
struct gre {
- u_short flags;
- u_short proto;
- union {
- struct gre_ckof {
- u_short cksum;
- u_short offset;
- } gre_ckof;
- u_int32_t key;
- u_int32_t seq;
- } gre_void1;
- union {
- u_int32_t key;
- u_int32_t seq;
- u_int32_t routing;
- } gre_void2;
- union {
- u_int32_t seq;
- u_int32_t routing;
- } gre_void3;
- union {
- u_int32_t routing;
- } gre_void4;
+ u_int16_t flags;
+ u_int16_t proto;
};
+/* RFC 2784 - GRE */
#define GRE_CP 0x8000 /* Checksum Present */
-#define GRE_RP 0x4000 /* Routing Present */
+#define GRE_VER_MASK 0x0007 /* Version */
+
+/* RFC 2890 - Key and Sequence extensions to GRE */
#define GRE_KP 0x2000 /* Key Present */
#define GRE_SP 0x1000 /* Sequence Present */
+/* Legacy from RFC 1700 */
+#define GRE_RP 0x4000 /* Routing Present */
+#define GRE_sP 0x0800 /* strict source route present */
+#define GRE_RECUR_MASK 0x0700 /* Recursion Control */
+#define GRE_RECUR_SHIFT 8
+
+#define GRE_COP (GRE_RP|GRE_CP) /* Checksum & Offset Present */
+
+/* "Enhanced GRE" from RFC2637 - PPTP */
+#define GRE_AP 0x0080 /* Ack present */
+
+#define GRE_MBZ_MASK 0x0078 /* not defined */
/*
* Deencapsulate and print a GRE-tunneled IP datagram
@@ -86,17 +79,18 @@ gre_print(const u_char *bp, u_int length)
{
const u_char *cp = bp + 4;
const struct gre *gre;
- u_short flags, proto, extracted_ethertype;
+ u_int16_t flags, proto;
+ u_short ver=0;
+ u_short extracted_ethertype;
gre = (const struct gre *)bp;
- if (length < GRE_SIZE) {
- goto trunc;
- }
+ TCHECK(gre->proto);
flags = EXTRACT_16BITS(&gre->flags);
proto = EXTRACT_16BITS(&gre->proto);
+ (void)printf("gre ");
- if (vflag) {
+ if (flags) {
/* Decode the flags */
putchar('[');
if (flags & GRE_CP)
@@ -107,20 +101,68 @@ gre_print(const u_char *bp, u_int length)
putchar('K');
if (flags & GRE_SP)
putchar('S');
+ if (flags & GRE_sP)
+ putchar('s');
+ if (flags & GRE_AP)
+ putchar('A');
+ if (flags & GRE_RECUR_MASK)
+ printf("R%x", (flags & GRE_RECUR_MASK) >> GRE_RECUR_SHIFT);
+ ver = flags & GRE_VER_MASK;
+ printf("v%u", ver);
+
+ if (flags & GRE_MBZ_MASK)
+ printf("!%x", flags & GRE_MBZ_MASK);
fputs("] ", stdout);
}
- /* Checksum & Offset are present */
- if ((flags & GRE_CP) | (flags & GRE_RP))
- cp += 4;
+ if (flags & GRE_COP) {
+ int checksum, offset;
+
+ TCHECK2(*cp, 4);
+ checksum = EXTRACT_16BITS(cp);
+ offset = EXTRACT_16BITS(cp + 2);
+
+ if (flags & GRE_CP) {
+ /* Checksum present */
+
+ /* todo: check checksum */
+ if (vflag > 1)
+ printf("C:%04x ", checksum);
+ }
+ if (flags & GRE_RP) {
+ /* Offset present */
+
+ if (vflag > 1)
+ printf("O:%04x ", offset);
+ }
+ cp += 4; /* skip checksum and offset */
+ }
+ if (flags & GRE_KP) {
+ TCHECK2(*cp, 4);
+ if (ver == 1) { /* PPTP */
+ if (vflag > 1)
+ printf("PL:%u ", EXTRACT_16BITS(cp));
+ printf("ID:%04x ", EXTRACT_16BITS(cp+2));
+ }
+ else
+ printf("K:%08x ", EXTRACT_32BITS(cp));
+ cp += 4; /* skip key */
+ }
+ if (flags & GRE_SP) {
+ TCHECK2(*cp, 4);
+ printf("S:%u ", EXTRACT_32BITS(cp));
+ cp += 4; /* skip seq */
+ }
+ if (flags & GRE_AP && ver >= 1) {
+ TCHECK2(*cp, 4);
+ printf("A:%u ", EXTRACT_32BITS(cp));
+ cp += 4; /* skip ack */
+ }
/* We don't support routing fields (variable length) now. Punt. */
if (flags & GRE_RP)
return;
- if (flags & GRE_KP)
- cp += 4;
- if (flags & GRE_SP)
- cp += 4;
+ TCHECK(cp[0]);
length -= cp - bp;
if (ether_encap_print(proto, cp, length, length,
diff --git a/contrib/tcpdump/print-hsrp.c b/contrib/tcpdump/print-hsrp.c
new file mode 100644
index 000000000000..a7a1c821bdb1
--- /dev/null
+++ b/contrib/tcpdump/print-hsrp.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2001 Julian Cowley
+ * 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.
+ */
+
+/* Cisco Hot Standby Router Protocol (HSRP). */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.2 2001/10/08 16:12:37 fenner Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <netinet/in.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+/* HSRP op code types. */
+static const char *op_code_str[] = {
+ "hello",
+ "coup",
+ "resign"
+};
+
+/* HSRP states and associated names. */
+static struct tok states[] = {
+ { 0, "initial" },
+ { 1, "learn" },
+ { 2, "listen" },
+ { 4, "speak" },
+ { 8, "standby" },
+ { 16, "active" },
+ { 0, NULL }
+};
+
+/*
+ * RFC 2281:
+ *
+ * 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 | Op Code | State | Hellotime |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Holdtime | Priority | Group | Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Authentication Data |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Authentication Data |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Virtual IP Address |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define HSRP_AUTH_SIZE 8
+
+/* HSRP protocol header. */
+struct hsrp {
+ u_char hsrp_version;
+ u_char hsrp_op_code;
+ u_char hsrp_state;
+ u_char hsrp_hellotime;
+ u_char hsrp_holdtime;
+ u_char hsrp_priority;
+ u_char hsrp_group;
+ u_char hsrp_reserved;
+ u_char hsrp_authdata[HSRP_AUTH_SIZE];
+ struct in_addr hsrp_virtaddr;
+};
+
+void
+hsrp_print(register const u_char *bp, register u_int len)
+{
+ struct hsrp *hp = (struct hsrp *) bp;
+
+ TCHECK(hp->hsrp_version);
+ printf("HSRPv%d", hp->hsrp_version);
+ if (hp->hsrp_version != 0)
+ return;
+ TCHECK(hp->hsrp_op_code);
+ printf("-");
+ printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code));
+ printf("%d: ", len);
+ TCHECK(hp->hsrp_state);
+ printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state));
+ TCHECK(hp->hsrp_group);
+ printf("group=%d ", hp->hsrp_group);
+ TCHECK(hp->hsrp_reserved);
+ if (hp->hsrp_reserved != 0) {
+ printf("[reserved=%d!] ", hp->hsrp_reserved);
+ }
+ TCHECK2(hp->hsrp_virtaddr, sizeof(hp->hsrp_virtaddr));
+ printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr));
+ if (vflag) {
+ printf(" hellotime=");
+ relts_print(hp->hsrp_hellotime);
+ printf(" holdtime=");
+ relts_print(hp->hsrp_holdtime);
+ printf(" priority=%d", hp->hsrp_priority);
+ printf(" auth=\"");
+ fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), NULL);
+ printf("\"");
+ }
+ return;
+trunc:
+ printf("[|hsrp]");
+}
diff --git a/contrib/tcpdump/print-icmp6.c b/contrib/tcpdump/print-icmp6.c
index a983bbb8e4fc..73e78a306906 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.42 2000/12/13 07:57:05 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.56 2001/06/27 02:48:43 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -43,6 +43,7 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <stdio.h>
+#include <string.h>
#include <netdb.h>
#include "ip6.h"
@@ -54,6 +55,9 @@ static const char rcsid[] =
#include "udp.h"
#include "ah.h"
+static const char *get_rtpref(u_int);
+static const char *get_lifetime(u_int32_t);
+static void print_lladdr(const u_char *, size_t);
void icmp6_opt_print(const u_char *, int);
void mld6_print(const u_char *);
static struct udphdr *get_upperlayer(u_char *, int *);
@@ -65,23 +69,60 @@ void icmp6_rrenum_print(int, const u_char *, const u_char *);
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
+static const char *
+get_rtpref(u_int v)
+{
+ static const char *rtpref_str[] = {
+ "medium", /* 00 */
+ "high", /* 01 */
+ "rsv", /* 10 */
+ "low" /* 11 */
+ };
+
+ return rtpref_str[((v & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff];
+}
+
+static const char *
+get_lifetime(u_int32_t v)
+{
+ static char buf[20];
+
+ if (v == (u_int32_t)~0UL)
+ return "infinity";
+ else {
+ snprintf(buf, sizeof(buf), "%u", v);
+ return buf;
+ }
+}
+
+static void
+print_lladdr(const u_int8_t *p, size_t l)
+{
+ const u_int8_t *ep, *q;
+
+ q = p;
+ ep = p + l;
+ while (l > 0 && q < ep) {
+ if (q > p)
+ printf(":");
+ printf("%02x", *q++);
+ l--;
+ }
+}
+
void
-icmp6_print(register const u_char *bp, register const u_char *bp2)
+icmp6_print(const u_char *bp, const u_char *bp2)
{
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 dport;
- register const u_char *ep;
+ const struct ip6_hdr *ip;
+ const char *str;
+ const struct ip6_hdr *oip;
+ const struct udphdr *ouh;
+ int dport;
+ const u_char *ep;
char buf[256];
int icmp6len, prot;
-#if 0
-#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
-#endif
-
dp = (struct icmp6_hdr *)bp;
ip = (struct ip6_hdr *)bp2;
oip = (struct ip6_hdr *)(dp + 1);
@@ -94,12 +135,6 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
else /* XXX: jumbo payload case... */
icmp6len = snapend - bp;
-#if 0
- (void)printf("%s > %s: ",
- ip6addr_string(&ip->ip6_src),
- ip6addr_string(&ip->ip6_dst));
-#endif
-
TCHECK(dp->icmp6_code);
switch (dp->icmp6_type) {
case ICMP6_DST_UNREACH:
@@ -155,7 +190,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
break;
case ICMP6_PACKET_TOO_BIG:
TCHECK(dp->icmp6_mtu);
- printf("icmp6: too big %u\n", (u_int32_t)ntohl(dp->icmp6_mtu));
+ printf("icmp6: too big %u", (u_int32_t)ntohl(dp->icmp6_mtu));
break;
case ICMP6_TIME_EXCEEDED:
TCHECK(oip->ip6_dst);
@@ -177,15 +212,15 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_PARAMPROB_HEADER:
- printf("icmp6: parameter problem errorneous - octet %u\n",
+ printf("icmp6: parameter problem errorneous - octet %u",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_NEXTHEADER:
- printf("icmp6: parameter problem next header - octet %u\n",
+ printf("icmp6: parameter problem next header - octet %u",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_OPTION:
- printf("icmp6: parameter problem option - octet %u\n",
+ printf("icmp6: parameter problem option - octet %u",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
default:
@@ -232,13 +267,16 @@ 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)
+ if (p->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT)
printf("H");
- if (p->nd_ra_flags_reserved != 0)
+
+ if ((p->nd_ra_flags_reserved & ~ND_RA_FLAG_RTPREF_MASK)
+ != 0)
printf(" ");
+
+ printf("pref=%s, ",
+ get_rtpref(p->nd_ra_flags_reserved));
+
printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime));
printf("reachable_time=%u, ",
(u_int32_t)ntohl(p->nd_ra_reachable));
@@ -325,15 +363,12 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
return;
trunc:
fputs("[|icmp6]", stdout);
-#if 0
-#undef TCHECK
-#endif
}
static struct udphdr *
-get_upperlayer(register u_char *bp, int *prot)
+get_upperlayer(u_char *bp, int *prot)
{
- register const u_char *ep;
+ const u_char *ep;
struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
struct udphdr *uh;
struct ip6_hbh *hbh;
@@ -404,149 +439,151 @@ get_upperlayer(register u_char *bp, int *prot)
}
void
-icmp6_opt_print(register const u_char *bp, int resid)
+icmp6_opt_print(const u_char *bp, int resid)
{
- register const struct nd_opt_hdr *op;
- register const struct nd_opt_hdr *opl; /* why there's no struct? */
- 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
- 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;
- char buf[256];
-#endif
+ const struct nd_opt_hdr *op;
+ const struct nd_opt_hdr *opl; /* why there's no struct? */
+ const struct nd_opt_prefix_info *opp;
+ const struct icmp6_opts_redirect *opr;
+ const struct nd_opt_mtu *opm;
+ const struct nd_opt_advinterval *opa;
+ const struct nd_opt_route_info *opri;
+ const u_char *cp, *ep;
+ struct in6_addr in6, *in6p;
+ size_t l;
#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
- op = (struct nd_opt_hdr *)bp;
-#if 0
- ip = (struct ip6_hdr *)bp2;
- oip = &dp->icmp6_ip6;
- str = buf;
-#endif
+ cp = bp;
/* 'ep' points to the end of available data. */
ep = snapend;
- ECHECK(op->nd_opt_len);
- if (resid <= 0)
- return;
- switch (op->nd_opt_type) {
- case ND_OPT_SOURCE_LINKADDR:
- opl = (struct nd_opt_hdr *)op;
-#if 1
- if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
+ while (cp < ep) {
+ op = (struct nd_opt_hdr *)cp;
+
+ ECHECK(op->nd_opt_len);
+ if (resid <= 0)
+ return;
+ if (op->nd_opt_len == 0)
goto trunc;
-#else
- TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
-#endif
- 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));
- break;
- case ND_OPT_TARGET_LINKADDR:
- opl = (struct nd_opt_hdr *)op;
-#if 1
- if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
+ if (cp + (op->nd_opt_len << 3) > ep)
goto trunc;
-#else
- TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
-#endif
- 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));
- break;
- case ND_OPT_PREFIX_INFORMATION:
- opp = (struct nd_opt_prefix_info *)op;
- TCHECK(opp->nd_opt_pi_prefix);
- printf("(prefix info: "); /*)*/
- if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
- printf("L");
- if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
- 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=");
- if ((u_int32_t)ntohl(opp->nd_opt_pi_valid_time) == ~0U)
- printf("infinity");
- else {
- printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_valid_time));
- }
- printf(", ");
- printf("preffered_ltime=");
- if ((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time) == ~0U)
- printf("infinity");
- else {
- printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_preferred_time));
+
+ switch (op->nd_opt_type) {
+ case ND_OPT_SOURCE_LINKADDR:
+ opl = (struct nd_opt_hdr *)op;
+ printf("(src lladdr: ");
+ l = (op->nd_opt_len << 3) - 2;
+ print_lladdr(cp + 2, l);
+ /*(*/
+ printf(")");
+ break;
+ case ND_OPT_TARGET_LINKADDR:
+ opl = (struct nd_opt_hdr *)op;
+ printf("(tgt lladdr: ");
+ l = (op->nd_opt_len << 3) - 2;
+ print_lladdr(cp + 2, l);
+ /*(*/
+ printf(")");
+ break;
+ case ND_OPT_PREFIX_INFORMATION:
+ opp = (struct nd_opt_prefix_info *)op;
+ TCHECK(opp->nd_opt_pi_prefix);
+ printf("(prefix info: "); /*)*/
+ if (op->nd_opt_len != 4) {
+ printf("badlen");
+ /*(*/
+ printf(")");
+ break;
+ }
+ if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
+ printf("L");
+ if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
+ 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=%s,",
+ get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_valid_time)));
+ printf("preferred_ltime=%s,",
+ get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time)));
+ printf("prefix=%s/%d",
+ ip6addr_string(&opp->nd_opt_pi_prefix),
+ opp->nd_opt_pi_prefix_len);
+ if (opp->nd_opt_pi_len != 4)
+ printf("!");
+ /*(*/
+ printf(")");
+ break;
+ case ND_OPT_REDIRECTED_HEADER:
+ opr = (struct icmp6_opts_redirect *)op;
+ printf("(redirect)");
+ /* xxx */
+ break;
+ case ND_OPT_MTU:
+ opm = (struct nd_opt_mtu *)op;
+ TCHECK(opm->nd_opt_mtu_mtu);
+ printf("(mtu:"); /*)*/
+ if (op->nd_opt_len != 1) {
+ printf("badlen");
+ /*(*/
+ printf(")");
+ break;
+ }
+ printf(" mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
+ if (opm->nd_opt_mtu_len != 1)
+ printf("!");
+ printf(")");
+ break;
+ case ND_OPT_ADVINTERVAL:
+ opa = (struct nd_opt_advinterval *)op;
+ TCHECK(opa->nd_opt_adv_interval);
+ printf("(advint:"); /*)*/
+ printf(" advint=%u",
+ (u_int32_t)ntohl(opa->nd_opt_adv_interval));
+ /*(*/
+ printf(")");
+ break;
+ case ND_OPT_ROUTE_INFO:
+ opri = (struct nd_opt_route_info *)op;
+ TCHECK(opri->nd_opt_rti_lifetime);
+ memset(&in6, 0, sizeof(in6));
+ in6p = (struct in6_addr *)(opri + 1);
+ switch (op->nd_opt_len) {
+ case 1:
+ break;
+ case 2:
+ TCHECK2(*in6p, 8);
+ memcpy(&in6, opri + 1, 8);
+ break;
+ case 3:
+ TCHECK(*in6p);
+ memcpy(&in6, opri + 1, sizeof(in6));
+ break;
+ default:
+ goto trunc;
+ }
+ printf("(rtinfo:"); /*)*/
+ printf(" %s/%u", ip6addr_string(&in6),
+ opri->nd_opt_rti_prefixlen);
+ printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags));
+ printf(", lifetime=%s",
+ get_lifetime((u_int32_t)ntohl(opri->nd_opt_rti_lifetime)));
+ /*(*/
+ printf(")");
+ break;
+ default:
+ printf("(unknwon opt_type=%d, opt_len=%d)",
+ op->nd_opt_type, op->nd_opt_len);
+ break;
}
- printf(", ");
- printf("prefix=%s/%d", ip6addr_string(&opp->nd_opt_pi_prefix),
- 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));
- break;
- case ND_OPT_REDIRECTED_HEADER:
- opr = (struct icmp6_opts_redirect *)op;
- printf("(redirect)");
- /* xxx */
- icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
- resid - (op->nd_opt_len << 3));
- break;
- case ND_OPT_MTU:
- opm = (struct nd_opt_mtu *)op;
- TCHECK(opm->nd_opt_mtu_mtu);
- printf("(mtu: "); /*)*/
- printf("mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
- if (opm->nd_opt_mtu_len != 1)
- printf("!");
- printf(")");
- 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)",
- op->nd_opt_type, opts_len);
- if (opts_len == 0)
- opts_len = 1; /* XXX */
- icmp6_opt_print((const u_char *)op + (opts_len << 3),
- resid - (opts_len << 3));
- break;
+
+ cp += op->nd_opt_len << 3;
+ resid -= op->nd_opt_len << 3;
}
return;
+
trunc:
fputs("[ndp opt]", stdout);
return;
@@ -554,10 +591,10 @@ icmp6_opt_print(register const u_char *bp, int resid)
}
void
-mld6_print(register const u_char *bp)
+mld6_print(const u_char *bp)
{
- register struct mld6_hdr *mp = (struct mld6_hdr *)bp;
- register const u_char *ep;
+ struct mld6_hdr *mp = (struct mld6_hdr *)bp;
+ const u_char *ep;
/* 'ep' points to the end of available data. */
ep = snapend;
@@ -820,7 +857,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
break;
printf(" %s", getname6(bp + i));
i += sizeof(struct in6_addr);
- printf("(%d)", ntohl(*(int32_t *)(bp + i)));
+ printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp + i)));
i += sizeof(int32_t);
}
i = ni6->ni_flags;
@@ -893,7 +930,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
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_FORCEAPPLY, "A"),
F(ICMP6_RR_FLAGS_SPECSITE, "S"),
F(ICMP6_RR_FLAGS_PREVDONE, "P"));
}
@@ -912,7 +949,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
TCHECK(match->rpm_prefix);
- if (vflag)
+ if (vflag > 1)
printf("\n\t");
else
printf(" ");
@@ -946,7 +983,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
TCHECK(use->rpu_prefix);
- if (vflag)
+ if (vflag > 1)
printf("\n\t");
else
printf(" ");
diff --git a/contrib/tcpdump/print-igmp.c b/contrib/tcpdump/print-igmp.c
index c79244e2fecb..07ace7defbf5 100644
--- a/contrib/tcpdump/print-igmp.c
+++ b/contrib/tcpdump/print-igmp.c
@@ -21,7 +21,7 @@
#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)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.5 2001/09/17 21:58:02 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -114,7 +114,7 @@ static struct tok igmpv3report2str[] = {
static void
print_mtrace(register const u_char *bp, register u_int len)
{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
+ register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mtrace %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
@@ -127,7 +127,7 @@ print_mtrace(register const u_char *bp, register u_int len)
static void
print_mresp(register const u_char *bp, register u_int len)
{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
+ register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mresp %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
@@ -138,11 +138,10 @@ print_mresp(register const u_char *bp, register u_int len)
}
static void
-print_igmpv3_report(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+print_igmpv3_report(register const u_char *bp, register u_int len)
{
- int group, nsrcs, ngroups;
- register int i, j;
+ u_int group, nsrcs, ngroups;
+ register u_int i, j;
/* Minimum len is 16, and should be a multiple of 4 */
if (len < 16 || len & 0x03) {
@@ -193,11 +192,12 @@ trunc:
}
static void
-print_igmpv3_query(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+print_igmpv3_query(register const u_char *bp, register u_int len)
{
- int nsrcs;
- register int i;
+ u_int mrc;
+ int mrt;
+ u_int nsrcs;
+ register u_int i;
(void)printf(" v3");
/* Minimum len is 12, and should be a multiple of 4 */
@@ -205,6 +205,17 @@ print_igmpv3_query(register const u_char *bp, register u_int len,
(void)printf(" [invalid len %d]", len);
return;
}
+ mrc = bp[1];
+ if (mrc < 128) {
+ mrt = mrc;
+ } else {
+ mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3);
+ }
+ if (mrc != 100) {
+ (void)printf(" [max resp time ");
+ relts_print(mrt);
+ (void)printf("]");
+ }
TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]) == 0)
return;
@@ -232,8 +243,7 @@ trunc:
}
void
-igmp_print(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+igmp_print(register const u_char *bp, register u_int len)
{
if (qflag) {
(void)printf("igmp");
@@ -245,7 +255,7 @@ igmp_print(register const u_char *bp, register u_int len,
case 0x11:
(void)printf("igmp query");
if (len >= 12)
- print_igmpv3_query(bp, len, bp2);
+ print_igmpv3_query(bp, len);
else {
if (bp[1]) {
(void)printf(" v2");
@@ -269,7 +279,7 @@ igmp_print(register const u_char *bp, register u_int len,
break;
case 0x22:
(void)printf("igmp v3 report");
- print_igmpv3_report(bp, len, bp2);
+ print_igmpv3_report(bp, len);
break;
case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));
diff --git a/contrib/tcpdump/print-igrp.c b/contrib/tcpdump/print-igrp.c
index cecee14a443e..19f4c832978e 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.15 2000/09/29 04:58:40 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.16 2001/06/15 22:17:32 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -92,9 +92,7 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
hdr = (struct igrphdr *)bp;
ip = (struct ip *)bp2;
cp = (u_char *)(hdr + 1);
- (void)printf("%s > %s: igrp: ",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ (void)printf("igrp:");
/* Header */
TCHECK(*hdr);
@@ -126,7 +124,7 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
igrp_entry_print((struct igrprte *)cp, 0, 1);
--next;
} else {
- (void)printf("[extra bytes %d]", length);
+ (void)printf(" [extra bytes %d]", length);
break;
}
cp += IGRP_RTE_SIZE;
@@ -135,5 +133,5 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
if (nint == 0 && nsys == 0 && next == 0)
return;
trunc:
- fputs("[|igrp]", stdout);
+ fputs(" [|igrp]", stdout);
}
diff --git a/contrib/tcpdump/print-ip6opts.c b/contrib/tcpdump/print-ip6opts.c
index 22d017e9d105..3d78a08e6aec 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.8 2000/12/13 07:57:05 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.9 2001/05/09 02:47:26 itojun Exp $";
#endif
#ifdef INET6
@@ -78,10 +78,20 @@ ip6_sopt_print(const u_char *bp, int len)
int optlen;
for (i = 0; i < len; i += optlen) {
+ if (bp[i] == IP6OPT_PAD1)
+ optlen = 1;
+ else {
+ if (i + 1 < len)
+ optlen = bp[i + 1] + 2;
+ else
+ goto trunc;
+ }
+ if (i + optlen > len)
+ goto trunc;
+
switch (bp[i]) {
case IP6OPT_PAD1:
printf(", pad1");
- optlen = 1;
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
@@ -89,7 +99,6 @@ ip6_sopt_print(const u_char *bp, int len)
goto trunc;
}
printf(", padn");
- optlen = bp[i + 1] + 2;
break;
case IP6SOPT_ALTCOA:
if (len - i < IP6SOPT_ALTCOA_MINLEN) {
@@ -97,7 +106,6 @@ ip6_sopt_print(const u_char *bp, int len)
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) {
@@ -105,7 +113,6 @@ ip6_sopt_print(const u_char *bp, int len)
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) {
@@ -113,7 +120,6 @@ ip6_sopt_print(const u_char *bp, int len)
goto trunc;
}
printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
- optlen = bp[i + 1] + 2;
break;
}
}
@@ -130,10 +136,20 @@ ip6_opt_print(const u_char *bp, int len)
int optlen;
for (i = 0; i < len; i += optlen) {
+ if (bp[i] == IP6OPT_PAD1)
+ optlen = 1;
+ else {
+ if (i + 1 < len)
+ optlen = bp[i + 1] + 2;
+ else
+ goto trunc;
+ }
+ if (i + optlen > len)
+ goto trunc;
+
switch (bp[i]) {
case IP6OPT_PAD1:
printf("(pad1)");
- optlen = 1;
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
@@ -141,7 +157,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
printf("(padn)");
- optlen = bp[i + 1] + 2;
break;
case IP6OPT_ROUTER_ALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
@@ -153,7 +168,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
printf("(rtalert: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2]));
- optlen = IP6OPT_RTALERT_LEN;
break;
case IP6OPT_JUMBO:
if (len - i < IP6OPT_JUMBO_LEN) {
@@ -165,7 +179,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
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) {
@@ -179,10 +192,9 @@ ip6_opt_print(const u_char *bp, int len)
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));
+ (optlen - IP6OPT_HOMEADDR_MINLEN));
}
printf(")");
- optlen = bp[i + 1] + 2;
break;
case IP6OPT_BINDING_UPDATE:
if (len - i < IP6OPT_BU_MINLEN) {
@@ -210,7 +222,6 @@ ip6_opt_print(const u_char *bp, int len)
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));
@@ -237,10 +248,9 @@ ip6_opt_print(const u_char *bp, int len)
if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
- (optlen-IP6OPT_BA_MINLEN));
+ (optlen - IP6OPT_BA_MINLEN));
}
printf(")");
- optlen = bp[i + 1] + 2;
break;
case IP6OPT_BINDING_REQ:
if (len - i < IP6OPT_BR_MINLEN) {
@@ -250,10 +260,9 @@ ip6_opt_print(const u_char *bp, int len)
printf("(br");
if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
- (optlen-IP6OPT_BR_MINLEN));
+ (optlen - IP6OPT_BR_MINLEN));
}
printf(")");
- optlen = bp[i + 1] + 2;
break;
default:
if (len - i < IP6OPT_MINLEN) {
@@ -261,7 +270,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
printf("(opt_type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
- optlen = bp[i + 1] + 2;
break;
}
}
diff --git a/contrib/tcpdump/print-isakmp.c b/contrib/tcpdump/print-isakmp.c
index 66df93ac0614..909f0b95615b 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.26 2000/12/12 09:20:26 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.29 2001/10/26 03:41:29 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -702,12 +702,8 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
{
int i;
printf(" len=%d ", len);
- for (i = 0; i < len; i++) {
- if (isprint(data[i]))
- printf("%c", data[i]);
- else
- printf("\\%03o", data[i]);
- }
+ for (i = 0; i < len; i++)
+ safeputchar(data[i]);
len = 0;
break;
}
@@ -759,7 +755,6 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
}
}
if (data && len) {
- len -= sizeof(*p);
printf(" len=%d", len);
if (2 < vflag) {
printf(" ");
@@ -1188,7 +1183,7 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
* encrypted, nothing we can do right now.
* we hope to decrypt the packet in the future...
*/
- printf(" [|%s]", NPSTR(base.np));
+ printf(" [encrypted %s]", NPSTR(base.np));
goto done;
}
diff --git a/contrib/tcpdump/print-l2tp.c b/contrib/tcpdump/print-l2tp.c
index d054308af27e..973c942490b7 100644
--- a/contrib/tcpdump/print-l2tp.c
+++ b/contrib/tcpdump/print-l2tp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.8 2000/08/18 07:44:46 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.10 2001/11/10 21:37:58 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -49,111 +49,145 @@ static char tstr[] = " [|l2tp]";
#define FALSE 0
#endif
-static char *l2tp_message_type_string[] = {
- "RESERVED_0", /* 0 Reserved */
- "SCCRQ", /* 1 Start-Control-Connection-Request */
- "SCCRP", /* 2 Start-Control-Connection-Reply */
- "SCCCN", /* 3 Start-Control-Connection-Connected */
- "StopCCN", /* 4 Stop-Control-Connection-Notification */
- "RESERVED_5", /* 5 Reserved */
- "HELLO", /* 6 Hello */
- "OCRQ", /* 7 Outgoing-Call-Request */
- "OCRP", /* 8 Outgoing-Call-Reply */
- "OCCN", /* 9 Outgoing-Call-Connected */
- "ICRQ", /* 10 Incoming-Call-Request */
- "ICRP", /* 11 Incoming-Call-Reply */
- "ICCN", /* 12 Incoming-Call-Connected */
- "RESERVED_13", /* 13 Reserved */
- "CDN", /* 14 Call-Disconnect-Notify */
- "WEN", /* 15 WAN-Error-Notify */
- "SLI" /* 16 Set-Link-Info */
-#define L2TP_MAX_MSGTYPE_INDEX 17
+#define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
+#define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
+#define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */
+#define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */
+#define L2TP_MSGTYPE_HELLO 6 /* Hello */
+#define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */
+#define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */
+#define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */
+#define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */
+#define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */
+#define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */
+#define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */
+#define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */
+#define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
+
+static struct tok l2tp_msgtype2str[] = {
+ { L2TP_MSGTYPE_SCCRQ, "SCCRQ" },
+ { L2TP_MSGTYPE_SCCRP, "SCCRP" },
+ { L2TP_MSGTYPE_SCCCN, "SCCCN" },
+ { L2TP_MSGTYPE_STOPCCN, "StopCCN" },
+ { L2TP_MSGTYPE_HELLO, "HELLO" },
+ { L2TP_MSGTYPE_OCRQ, "OCRQ" },
+ { L2TP_MSGTYPE_OCRP, "OCRP" },
+ { L2TP_MSGTYPE_OCCN, "OCCN" },
+ { L2TP_MSGTYPE_ICRQ, "ICRQ" },
+ { L2TP_MSGTYPE_ICRP, "ICRP" },
+ { L2TP_MSGTYPE_ICCN, "ICCN" },
+ { L2TP_MSGTYPE_CDN, "CDN" },
+ { L2TP_MSGTYPE_WEN, "WEN" },
+ { L2TP_MSGTYPE_SLI, "SLI" },
+ { 0, NULL }
};
-static void l2tp_msgtype_print(const u_char *dat, u_int length);
-static void l2tp_result_code_print(const u_char *dat, u_int length);
-static void l2tp_proto_ver_print(const u_char *dat, u_int length);
-static void l2tp_framing_cap_print(const u_char *dat, u_int length);
-static void l2tp_bearer_cap_print(const u_char *dat, u_int length);
-static void l2tp_tie_breaker_print(const u_char *dat, u_int length);
-static void l2tp_firm_ver_print(const u_char *dat, u_int length);
-static void l2tp_host_name_print(const u_char *dat, u_int length);
-static void l2tp_vendor_name_print(const u_char *dat, u_int length);
-static void l2tp_assnd_tun_id_print(const u_char *dat, u_int length);
-static void l2tp_recv_win_size_print(const u_char *dat, u_int length);
-static void l2tp_challenge_print(const u_char *dat, u_int length);
-static void l2tp_q931_cc_print(const u_char *dat, u_int length);
-static void l2tp_challenge_resp_print(const u_char *dat, u_int length);
-static void l2tp_assnd_sess_id_print(const u_char *dat, u_int length);
-static void l2tp_call_ser_num_print(const u_char *dat, u_int length);
-static void l2tp_minimum_bps_print(const u_char *dat, u_int length);
-static void l2tp_maximum_bps_print(const u_char *dat, u_int length);
-static void l2tp_bearer_type_print(const u_char *dat, u_int length);
-static void l2tp_framing_type_print(const u_char *dat, u_int length);
-static void l2tp_packet_proc_delay_print(const u_char *dat, u_int length);
-static void l2tp_called_number_print(const u_char *dat, u_int length);
-static void l2tp_calling_number_print(const u_char *dat, u_int length);
-static void l2tp_sub_address_print(const u_char *dat, u_int length);
-static void l2tp_tx_conn_speed_print(const u_char *dat, u_int length);
-static void l2tp_phy_channel_id_print(const u_char *dat, u_int length);
-static void l2tp_ini_recv_lcp_print(const u_char *dat, u_int length);
-static void l2tp_last_sent_lcp_print(const u_char *dat, u_int length);
-static void l2tp_last_recv_lcp_print(const u_char *dat, u_int length);
-static void l2tp_proxy_auth_type_print(const u_char *dat, u_int length);
-static void l2tp_proxy_auth_name_print(const u_char *dat, u_int length);
-static void l2tp_proxy_auth_chal_print(const u_char *dat, u_int length);
-static void l2tp_proxy_auth_id_print(const u_char *dat, u_int length);
-static void l2tp_proxy_auth_resp_print(const u_char *dat, u_int length);
-static void l2tp_call_errors_print(const u_char *dat, u_int length);
-static void l2tp_accm_print(const u_char *dat, u_int length);
-static void l2tp_random_vector_print(const u_char *dat, u_int length);
-static void l2tp_private_grp_id_print(const u_char *dat, u_int length);
-static void l2tp_rx_conn_speed_print(const u_char *dat, u_int length);
-static void l2tp_seq_required_print(const u_char *dat, u_int length);
-static void l2tp_avp_print(const u_char *dat, u_int length);
-
-static struct l2tp_avp_vec l2tp_avp[] = {
- {"MSGTYPE", l2tp_msgtype_print}, /* 0 Message Type */
- {"RESULT_CODE", l2tp_result_code_print}, /* 1 Result Code */
- {"PROTO_VER", l2tp_proto_ver_print}, /* 2 Protocol Version */
- {"FRAMING_CAP", l2tp_framing_cap_print}, /* 3 Framing Capabilities */
- {"BEARER_CAP", l2tp_bearer_cap_print}, /* 4 Bearer Capabilities */
- {"TIE_BREAKER", l2tp_tie_breaker_print}, /* 5 Tie Breaker */
- {"FIRM_VER", l2tp_firm_ver_print}, /* 6 Firmware Revision */
- {"HOST_NAME", l2tp_host_name_print}, /* 7 Host Name */
- {"VENDOR_NAME", l2tp_vendor_name_print}, /* 8 Vendor Name */
- {"ASSND_TUN_ID", l2tp_assnd_tun_id_print}, /* 9 Assigned Tunnel ID */
- {"RECV_WIN_SIZE", l2tp_recv_win_size_print}, /* 10 Receive Window Size */
- {"CHALLENGE", l2tp_challenge_print}, /* 11 Challenge */
- {"Q931_CC", l2tp_q931_cc_print}, /* 12 Q.931 Cause Code */
- {"CHALLENGE_RESP", l2tp_challenge_resp_print},/* 13 Challenge Response */
- {"ASSND_SESS_ID", l2tp_assnd_sess_id_print}, /* 14 Assigned Session ID */
- {"CALL_SER_NUM", l2tp_call_ser_num_print}, /* 15 Call Serial Number */
- {"MINIMUM_BPS", l2tp_minimum_bps_print},/* 16 Minimum BPS */
- {"MAXIMUM_BPS", l2tp_maximum_bps_print}, /* 17 Maximum BPS */
- {"BEARER_TYPE", l2tp_bearer_type_print},/* 18 Bearer Type */
- {"FRAMING_TYPE", l2tp_framing_type_print}, /* 19 Framing Type */
- {"PACKET_PROC_DELAY", l2tp_packet_proc_delay_print}, /* 20 Packet Processing Delay (OBSOLETE) */
- {"CALLED_NUMBER", l2tp_called_number_print}, /* 21 Called Number */
- {"CALLING_NUMBER", l2tp_calling_number_print},/* 22 Calling Number */
- {"SUB_ADDRESS", l2tp_sub_address_print},/* 23 Sub-Address */
- {"TX_CONN_SPEED", l2tp_tx_conn_speed_print}, /* 24 (Tx) Connect Speed */
- {"PHY_CHANNEL_ID", l2tp_phy_channel_id_print},/* 25 Physical Channel ID */
- {"INI_RECV_LCP", l2tp_ini_recv_lcp_print}, /* 26 Initial Received LCP CONFREQ */
- {"LAST_SENT_LCP", l2tp_last_sent_lcp_print}, /* 27 Last Sent LCP CONFREQ */
- {"LAST_RECV_LCP", l2tp_last_recv_lcp_print}, /* 28 Last Received LCP CONFREQ */
- {"PROXY_AUTH_TYPE", l2tp_proxy_auth_type_print},/* 29 Proxy Authen Type */
- {"PROXY_AUTH_NAME", l2tp_proxy_auth_name_print},/* 30 Proxy Authen Name */
- {"PROXY_AUTH_CHAL", l2tp_proxy_auth_chal_print},/* 31 Proxy Authen Challenge */
- {"PROXY_AUTH_ID", l2tp_proxy_auth_id_print}, /* 32 Proxy Authen ID */
- {"PROXY_AUTH_RESP", l2tp_proxy_auth_resp_print},/* 33 Proxy Authen Response */
- {"CALL_ERRORS", l2tp_call_errors_print}, /* 34 Call Errors */
- {"ACCM", l2tp_accm_print}, /* 35 ACCM */
- {"RANDOM_VECTOR", l2tp_random_vector_print}, /* 36 Random Vector */
- {"PRIVATE_GRP_ID", l2tp_private_grp_id_print},/* 37 Private Group ID */
- {"RX_CONN_SPEED", l2tp_rx_conn_speed_print}, /* 38 (Rx) Connect Speed */
- {"SEQ_REQUIRED", l2tp_seq_required_print}, /* 39 Sequencing Required */
-#define L2TP_MAX_AVP_INDEX 40
+#define L2TP_AVP_MSGTYPE 0 /* Message Type */
+#define L2TP_AVP_RESULT_CODE 1 /* Result Code */
+#define L2TP_AVP_PROTO_VER 2 /* Protocol Version */
+#define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */
+#define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */
+#define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */
+#define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */
+#define L2TP_AVP_HOST_NAME 7 /* Host Name */
+#define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */
+#define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */
+#define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */
+#define L2TP_AVP_CHALLENGE 11 /* Challenge */
+#define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */
+#define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */
+#define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */
+#define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */
+#define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */
+#define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */
+#define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */
+#define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */
+#define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */
+#define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */
+#define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */
+#define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */
+#define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */
+#define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */
+#define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */
+#define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */
+#define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */
+#define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */
+#define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */
+#define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */
+#define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */
+#define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */
+#define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */
+#define L2TP_AVP_ACCM 35 /* ACCM */
+#define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */
+#define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */
+#define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */
+#define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */
+#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */
+
+static struct tok l2tp_avp2str[] = {
+ { L2TP_AVP_MSGTYPE, "MSGTYPE" },
+ { L2TP_AVP_RESULT_CODE, "RESULT_CODE" },
+ { L2TP_AVP_PROTO_VER, "PROTO_VER" },
+ { L2TP_AVP_FRAMING_CAP, "FRAMING_CAP" },
+ { L2TP_AVP_BEARER_CAP, "BEARER_CAP" },
+ { L2TP_AVP_TIE_BREAKER, "TIE_BREAKER" },
+ { L2TP_AVP_FIRM_VER, "FIRM_VER" },
+ { L2TP_AVP_HOST_NAME, "HOST_NAME" },
+ { L2TP_AVP_VENDOR_NAME, "VENDOR_NAME" },
+ { L2TP_AVP_ASSND_TUN_ID, "ASSND_TUN_ID" },
+ { L2TP_AVP_RECV_WIN_SIZE, "RECV_WIN_SIZE" },
+ { L2TP_AVP_CHALLENGE, "CHALLENGE" },
+ { L2TP_AVP_Q931_CC, "Q931_CC", },
+ { L2TP_AVP_CHALLENGE_RESP, "CHALLENGE_RESP" },
+ { L2TP_AVP_ASSND_SESS_ID, "ASSND_SESS_ID" },
+ { L2TP_AVP_CALL_SER_NUM, "CALL_SER_NUM" },
+ { L2TP_AVP_MINIMUM_BPS, "MINIMUM_BPS" },
+ { L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" },
+ { L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" },
+ { L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" },
+ { L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" },
+ { L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" },
+ { L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" },
+ { L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" },
+ { L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" },
+ { L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" },
+ { L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" },
+ { L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" },
+ { L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" },
+ { L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" },
+ { L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" },
+ { L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" },
+ { L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" },
+ { L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" },
+ { L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" },
+ { L2TP_AVP_ACCM, "ACCM" },
+ { L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" },
+ { L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" },
+ { L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" },
+ { L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" },
+ { L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" },
+ { 0, NULL }
+};
+
+static struct tok l2tp_authentype2str[] = {
+ { L2TP_AUTHEN_TYPE_RESERVED, "Reserved" },
+ { L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" },
+ { L2TP_AUTHEN_TYPE_CHAP, "CHAP" },
+ { L2TP_AUTHEN_TYPE_PAP, "PAP" },
+ { L2TP_AUTHEN_TYPE_NO_AUTH, "No Auth" },
+ { L2TP_AUTHEN_TYPE_MSCHAPv1, "MS-CHAPv1" },
+ { 0, NULL }
+};
+
+#define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0
+#define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1
+#define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2
+
+static struct tok l2tp_cc_direction2str[] = {
+ { L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" },
+ { L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" },
+ { L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" },
+ { 0, NULL }
};
#if 0
@@ -227,57 +261,53 @@ print_octets(const u_char *dat, u_int length)
}
static void
-print_short(const u_short *dat)
+print_16bits_val(const u_int16_t *dat)
{
printf("%u", ntohs(*dat));
}
static void
-print_int(const u_int *dat)
+print_32bits_val(const u_int32_t *dat)
{
printf("%lu", (u_long)ntohl(*dat));
}
-/**********************************/
-/* AVP-specific print out routines*/
-/**********************************/
+/***********************************/
+/* AVP-specific print out routines */
+/***********************************/
static void
-l2tp_msgtype_print(const u_char *dat, u_int length)
+l2tp_msgtype_print(const u_char *dat)
{
- u_short *ptr = (u_short *)dat;
+ u_int16_t *ptr = (u_int16_t*)dat;
- if (ntohs(*ptr) < L2TP_MAX_MSGTYPE_INDEX) {
- printf("%s", l2tp_message_type_string[ntohs(*ptr)]);
- }
+ printf("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u", ntohs(*ptr)));
}
static void
l2tp_result_code_print(const u_char *dat, u_int length)
{
- /* we just print out the result and error code number */
- u_short *ptr = (u_short *)dat;
+ u_int16_t *ptr = (u_int16_t *)dat;
- if (length == 2) { /* result code */
- printf("%u", ntohs(*ptr));
- } else if (length == 4) { /* result & error code */
- printf("%u/%u", ntohs(*ptr), ntohs(*(ptr+1)));
- } else if (length > 4) { /* result & error code & msg */
- printf("%u/%u ", ntohs(*ptr), ntohs(*(ptr+1)));
- print_string((u_char *)(ptr+2), length - 4);
+ printf("%u", ntohs(*ptr++)); /* Result Code */
+ if (length > 2) { /* Error Code (opt) */
+ printf("/%u", ntohs(*ptr++));
+ }
+ if (length > 4) { /* Error Message (opt) */
+ printf(" ");
+ print_string((u_char *)ptr, length - 4);
}
}
static void
-l2tp_proto_ver_print(const u_char *dat, u_int length)
+l2tp_proto_ver_print(const u_int16_t *dat)
{
- printf("%d.%d", *dat, *(dat+1));
+ printf("%u.%u", (ntohs(*dat) >> 8), (ntohs(*dat) & 0xff));
}
-
static void
-l2tp_framing_cap_print(const u_char *dat, u_int length)
+l2tp_framing_cap_print(const u_char *dat)
{
- u_int *ptr = (u_int *)dat;
+ u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
printf("A");
@@ -288,9 +318,9 @@ l2tp_framing_cap_print(const u_char *dat, u_int length)
}
static void
-l2tp_bearer_cap_print(const u_char *dat, u_int length)
+l2tp_bearer_cap_print(const u_char *dat)
{
- u_int *ptr = (u_int *)dat;
+ u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
printf("A");
@@ -301,51 +331,9 @@ l2tp_bearer_cap_print(const u_char *dat, u_int length)
}
static void
-l2tp_tie_breaker_print(const u_char *dat, u_int length)
-{
- print_octets(dat, 8); /* Tie Break Value is 64bits long */
-}
-
-static void
-l2tp_firm_ver_print(const u_char *dat, u_int length)
-{
- print_short((u_short *)dat);
-}
-
-static void
-l2tp_host_name_print(const u_char *dat, u_int length)
-{
- print_string(dat, length);
-}
-
-static void
-l2tp_vendor_name_print(const u_char *dat, u_int length)
-{
- print_string(dat, length);
-}
-
-static void
-l2tp_assnd_tun_id_print(const u_char *dat, u_int length)
-{
- print_short((u_short *)dat);
-}
-
-static void
-l2tp_recv_win_size_print(const u_char *dat, u_int length)
-{
- print_short((u_short *)dat);
-}
-
-static void
-l2tp_challenge_print(const u_char *dat, u_int length)
-{
- print_octets(dat, length);
-}
-
-static void
l2tp_q931_cc_print(const u_char *dat, u_int length)
{
- print_short((u_short *)dat);
+ print_16bits_val((u_int16_t *)dat);
printf(", %02x", dat[2]);
if (length > 3) {
printf(" ");
@@ -354,39 +342,9 @@ l2tp_q931_cc_print(const u_char *dat, u_int length)
}
static void
-l2tp_challenge_resp_print(const u_char *dat, u_int length)
-{
- print_octets(dat, 16); /* XXX length should be 16? */
-}
-
-static void
-l2tp_assnd_sess_id_print(const u_char *dat, u_int length)
-{
- print_short((u_short *)dat);
-}
-
-static void
-l2tp_call_ser_num_print(const u_char *dat, u_int length)
-{
- print_int((u_int *)dat);
-}
-
-static void
-l2tp_minimum_bps_print(const u_char *dat, u_int length)
-{
- print_int((u_int *)dat);
-}
-
-static void
-l2tp_maximum_bps_print(const u_char *dat, u_int length)
-{
- print_int((u_int *)dat);
-}
-
-static void
-l2tp_bearer_type_print(const u_char *dat, u_int length)
+l2tp_bearer_type_print(const u_char *dat)
{
- u_int *ptr = (u_int *)dat;
+ u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
printf("A");
@@ -397,9 +355,9 @@ l2tp_bearer_type_print(const u_char *dat, u_int length)
}
static void
-l2tp_framing_type_print(const u_char *dat, u_int length)
+l2tp_framing_type_print(const u_char *dat)
{
- u_int *ptr = (u_int *)dat;
+ u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
printf("A");
@@ -410,241 +368,251 @@ l2tp_framing_type_print(const u_char *dat, u_int length)
}
static void
-l2tp_packet_proc_delay_print(const u_char *dat, u_int length)
+l2tp_packet_proc_delay_print(void)
{
printf("obsolete");
}
static void
-l2tp_called_number_print(const u_char *dat, u_int length)
+l2tp_proxy_auth_type_print(const u_char *dat)
{
- print_string(dat, length);
-}
+ u_int16_t *ptr = (u_int16_t *)dat;
-static void
-l2tp_calling_number_print(const u_char *dat, u_int length)
-{
- print_string(dat, length);
+ printf("%s", tok2str(l2tp_authentype2str,
+ "AuthType-#%u", ntohs(*ptr)));
}
static void
-l2tp_sub_address_print(const u_char *dat, u_int length)
+l2tp_proxy_auth_id_print(const u_char *dat)
{
- print_string(dat, length);
-}
+ u_int16_t *ptr = (u_int16_t *)dat;
-static void
-l2tp_tx_conn_speed_print(const u_char *dat, u_int length)
-{
- print_int((u_int *)dat);
+ printf("%u", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
}
static void
-l2tp_phy_channel_id_print(const u_char *dat, u_int length)
+l2tp_call_errors_print(const u_char *dat)
{
- print_int((u_int *)dat);
-}
+ u_int16_t *ptr = (u_int16_t *)dat;
+ u_int16_t val_h, val_l;
+
+ ptr++; /* skip "Reserved" */
-static void
-l2tp_ini_recv_lcp_print(const u_char *dat, u_int length)
-{
- print_octets(dat, length);
-}
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("CRCErr=%u ", (val_h<<16) + val_l);
-static void
-l2tp_last_sent_lcp_print(const u_char *dat, u_int length)
-{
- print_octets(dat, length);
-}
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("FrameErr=%u ", (val_h<<16) + val_l);
-static void
-l2tp_last_recv_lcp_print(const u_char *dat, u_int length)
-{
- print_octets(dat, length);
-}
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("HardOver=%u ", (val_h<<16) + val_l);
-static void
-l2tp_proxy_auth_type_print(const u_char *dat, u_int length)
-{
- u_short *ptr = (u_short *)dat;
-
- switch (ntohs(*ptr)) {
- case L2TP_AUTHEN_TYPE_RESERVED:
- printf("Reserved");
- break;
- case L2TP_AUTHEN_TYPE_TEXTUAL:
- printf("Textual");
- break;
- case L2TP_AUTHEN_TYPE_CHAP:
- printf("CHAP");
- break;
- case L2TP_AUTHEN_TYPE_PAP:
- printf("PAP");
- break;
- case L2TP_AUTHEN_TYPE_NO_AUTH:
- printf("No Auth");
- break;
- case L2TP_AUTHEN_TYPE_MSCHAP:
- printf("MS-CHAP");
- break;
- default:
- printf("unknown");
- }
-}
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("BufOver=%u ", (val_h<<16) + val_l);
-static void
-l2tp_proxy_auth_name_print(const u_char *dat, u_int length)
-{
- print_octets(dat, length);
-}
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("Timeout=%u ", (val_h<<16) + val_l);
-static void
-l2tp_proxy_auth_chal_print(const u_char *dat, u_int length)
-{
- print_octets(dat, length);
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("AlignErr=%u ", (val_h<<16) + val_l);
}
static void
-l2tp_proxy_auth_id_print(const u_char *dat, u_int length)
+l2tp_accm_print(const u_char *dat)
{
- u_short *ptr = (u_short *)dat;
+ u_int16_t *ptr = (u_int16_t *)dat;
+ u_int16_t val_h, val_l;
- printf("%u", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
-}
-
-static void
-l2tp_proxy_auth_resp_print(const u_char *dat, u_int length)
-{
- print_octets(dat, length);
-}
+ ptr++; /* skip "Reserved" */
-static void
-l2tp_call_errors_print(const u_char *dat, u_int length)
-{
- struct l2tp_call_errors *ptr = (struct l2tp_call_errors *)dat;
-
- printf("CRCErr=%d FrameErr=%d HardOver=%d BufOver=%d ",
- ptr->crc_errs,
- ptr->framing_errs,
- ptr->hardware_overruns,
- ptr->buffer_overruns);
- printf("Timeout=%d AlingErr=%d",
- ptr->timeout_errs,
- ptr->alignment_errs);
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("send=%08x ", (val_h<<16) + val_l);
+
+ val_h = ntohs(*ptr++);
+ val_l = ntohs(*ptr++);
+ printf("recv=%08x ", (val_h<<16) + val_l);
}
static void
-l2tp_accm_print(const u_char *dat, u_int length)
+l2tp_ppp_discon_cc_print(const u_char *dat, u_int length)
{
- struct l2tp_accm *ptr = (struct l2tp_accm *)dat;
+ u_int16_t *ptr = (u_int16_t *)dat;
+
+ printf("%04x, ", ntohs(*ptr++)); /* Disconnect Code */
+ printf("%04x ", ntohs(*ptr++)); /* Control Protocol Number */
+ printf("%s", tok2str(l2tp_cc_direction2str,
+ "Direction-#%u", *((u_char *)ptr++)));
- printf("send=%x recv=%x", ptr->send_accm, ptr->recv_accm);
+ if (length > 5) {
+ printf(" ");
+ print_string((const u_char *)ptr, length-5);
+ }
}
static void
-l2tp_random_vector_print(const u_char *dat, u_int length)
+l2tp_avp_print(const u_char *dat, int length)
{
- print_octets(dat, length);
-}
+ u_int len;
+ const u_int16_t *ptr = (u_int16_t *)dat;
+ u_int16_t attr_type;
+ int hidden = FALSE;
-static void
-l2tp_private_grp_id_print(const u_char *dat, u_int length)
-{
- print_string(dat, length);
- /* XXX print_octets is more appropriate?? */
-}
+ if (length <= 0) {
+ return;
+ }
-static void
-l2tp_rx_conn_speed_print(const u_char *dat, u_int length)
-{
- print_int((u_int *)dat);
-}
+ printf(" ");
-static void
-l2tp_seq_required_print(const u_char *dat, u_int length)
-{
- return;
-}
+ TCHECK(*ptr); /* Flags & Length */
+ len = ntohs(*ptr) & L2TP_AVP_HDR_LEN_MASK;
-static void
-l2tp_avp_print(const u_char *dat, u_int length)
-{
- u_int len;
- const u_short *ptr = (u_short *)dat;
- int hidden = FALSE;
+ /* If it is not long enough to decode the entire AVP, we'll
+ abandon. */
+ TCHECK2(*ptr, len);
+ /* After this point, no need to worry about truncation */
- printf(" ");
- if (length > 0 && (snapend - dat) >= 2) {
- /* there must be at least two octets for the length
- to be decoded */
- if ((len = (ntohs(*ptr) & L2TP_AVP_HDR_LEN_MASK)) <=
- (snapend - dat)) {
- if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
- printf("*");
- }
- if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
- hidden = TRUE;
- printf("?");
- }
- } else {
- printf("|...");
- return;
- }
- ptr++;
+ if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
+ printf("*");
+ }
+ if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
+ hidden = TRUE;
+ printf("?");
+ }
+ ptr++;
- if (ntohs(*ptr)) {
- /* Vendor Specific Attribute */
- printf("VENDOR%04x:", ntohs(*ptr));
- ptr++;
- printf("ATTR%04x", ntohs(*ptr));
- printf("(");
- print_octets((u_char *)ptr+2, len-6);
- printf(")");
+ if (ntohs(*ptr)) {
+ /* Vendor Specific Attribute */
+ printf("VENDOR%04x:", ntohs(*ptr++));
+ printf("ATTR%04x", ntohs(*ptr++));
+ printf("(");
+ print_octets((u_char *)ptr, len-6);
+ printf(")");
+ } else {
+ /* IETF-defined Attributes */
+ ptr++;
+ attr_type = ntohs(*ptr++);
+ printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type));
+ printf("(");
+ if (hidden) {
+ printf("???");
} else {
- /* 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));
+ switch (attr_type) {
+ case L2TP_AVP_MSGTYPE:
+ l2tp_msgtype_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_RESULT_CODE:
+ l2tp_result_code_print((u_char *)ptr, len-6);
+ break;
+ case L2TP_AVP_PROTO_VER:
+ l2tp_proto_ver_print(ptr);
+ break;
+ case L2TP_AVP_FRAMING_CAP:
+ l2tp_framing_cap_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_BEARER_CAP:
+ l2tp_bearer_cap_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_TIE_BREAKER:
+ print_octets((u_char *)ptr, 8);
+ break;
+ case L2TP_AVP_FIRM_VER:
+ case L2TP_AVP_ASSND_TUN_ID:
+ case L2TP_AVP_RECV_WIN_SIZE:
+ case L2TP_AVP_ASSND_SESS_ID:
+ print_16bits_val(ptr);
+ break;
+ case L2TP_AVP_HOST_NAME:
+ case L2TP_AVP_VENDOR_NAME:
+ case L2TP_AVP_CALLING_NUMBER:
+ case L2TP_AVP_CALLED_NUMBER:
+ case L2TP_AVP_SUB_ADDRESS:
+ case L2TP_AVP_PROXY_AUTH_NAME:
+ case L2TP_AVP_PRIVATE_GRP_ID:
+ print_string((u_char *)ptr, len-6);
+ break;
+ case L2TP_AVP_CHALLENGE:
+ case L2TP_AVP_INI_RECV_LCP:
+ case L2TP_AVP_LAST_SENT_LCP:
+ case L2TP_AVP_LAST_RECV_LCP:
+ case L2TP_AVP_PROXY_AUTH_CHAL:
+ case L2TP_AVP_PROXY_AUTH_RESP:
+ case L2TP_AVP_RANDOM_VECTOR:
+ print_octets((u_char *)ptr, len-6);
+ break;
+ case L2TP_AVP_Q931_CC:
+ l2tp_q931_cc_print((u_char *)ptr, len-6);
+ break;
+ case L2TP_AVP_CHALLENGE_RESP:
+ print_octets((u_char *)ptr, 16);
+ break;
+ case L2TP_AVP_CALL_SER_NUM:
+ case L2TP_AVP_MINIMUM_BPS:
+ case L2TP_AVP_MAXIMUM_BPS:
+ case L2TP_AVP_TX_CONN_SPEED:
+ case L2TP_AVP_PHY_CHANNEL_ID:
+ case L2TP_AVP_RX_CONN_SPEED:
+ print_32bits_val((u_int32_t *)ptr);
+ break;
+ case L2TP_AVP_BEARER_TYPE:
+ l2tp_bearer_type_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_FRAMING_TYPE:
+ l2tp_framing_type_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_PACKET_PROC_DELAY:
+ l2tp_packet_proc_delay_print();
+ break;
+ case L2TP_AVP_PROXY_AUTH_TYPE:
+ l2tp_proxy_auth_type_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_PROXY_AUTH_ID:
+ l2tp_proxy_auth_id_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_CALL_ERRORS:
+ l2tp_call_errors_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_ACCM:
+ l2tp_accm_print((u_char *)ptr);
+ break;
+ case L2TP_AVP_SEQ_REQUIRED:
+ break; /* No Attribute Value */
+ case L2TP_AVP_PPP_DISCON_CC:
+ l2tp_ppp_discon_cc_print((u_char *)ptr, len-6);
+ break;
+ default:
+ break;
}
}
-
- l2tp_avp_print(dat + len, length - len);
- } else if (length == 0) {
- return;
- } else {
- printf("|...");
+ printf(")");
}
+
+ l2tp_avp_print(dat+len, length-len);
+ return;
+
+ trunc:
+ printf("|...");
}
void
l2tp_print(const u_char *dat, u_int length)
{
- const u_short *ptr = (u_short *)dat;
+ const u_int16_t *ptr = (u_int16_t *)dat;
u_int cnt = 0; /* total octets consumed */
- u_short pad;
+ u_int16_t pad;
int flag_t, flag_l, flag_s, flag_o, flag_p;
- u_short l2tp_len;
+ u_int16_t l2tp_len;
flag_t = flag_l = flag_s = flag_o = flag_p = FALSE;
- if (min(length, snapend - dat) - 6 < 0) {
- /* flag/ver, tunnel_id, session_id must be present for
- this packet to be properly decoded */
- printf("%s", tstr);
- return;
- }
-
+ TCHECK(*ptr); /* Flags & Version */
if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
printf(" l2tp:");
} else if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
@@ -682,24 +650,31 @@ l2tp_print(const u_char *dat, u_int length)
cnt += 2;
if (flag_l) {
- l2tp_len = ntohs(*ptr++); /* XXX need to consider
- truncation ?? */
+ TCHECK(*ptr); /* Length */
+ l2tp_len = ntohs(*ptr++);
cnt += 2;
} else {
l2tp_len = 0;
}
- printf("(%u/", ntohs(*ptr++)); /* Tunnel ID */
- printf("%u)", ntohs(*ptr++)); /* Session ID */
- cnt += 4;
+ TCHECK(*ptr); /* Tunnel ID */
+ printf("(%u/", ntohs(*ptr++));
+ cnt += 2;
+ TCHECK(*ptr); /* Session ID */
+ printf("%u)", ntohs(*ptr++));
+ cnt += 2;
if (flag_s) {
+ TCHECK(*ptr); /* Ns */
printf("Ns=%u,", ntohs(*ptr++));
+ cnt += 2;
+ TCHECK(*ptr); /* Nr */
printf("Nr=%u", ntohs(*ptr++));
- cnt += 4;
+ cnt += 2;
}
if (flag_o) {
+ TCHECK(*ptr); /* Offset Size */
pad = ntohs(*ptr++);
ptr += pad / sizeof(*ptr);
cnt += (2 + pad);
@@ -716,4 +691,9 @@ l2tp_print(const u_char *dat, u_int length)
ppp_print((u_char *)ptr, length - cnt);
printf("}");
}
+
+ return;
+
+ trunc:
+ printf("%s", tstr);
}
diff --git a/contrib/tcpdump/print-lane.c b/contrib/tcpdump/print-lane.c
index db38ef707214..e697dba268be 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.11 2000/12/22 22:45:11 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.12 2001/07/05 18:54:15 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -81,6 +81,7 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_short ether_type;
u_short extracted_ethertype;
+ ++infodelay;
ts_print(&h->ts);
if (caplen < sizeof(struct lecdatahdr_8023)) {
@@ -136,4 +137,7 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print(p, caplen);
out:
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
}
diff --git a/contrib/tcpdump/print-lwres.c b/contrib/tcpdump/print-lwres.c
new file mode 100644
index 000000000000..82ec5aed9ad5
--- /dev/null
+++ b/contrib/tcpdump/print-lwres.c
@@ -0,0 +1,599 @@
+/*
+ * Copyright (C) 2001 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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.5 2001/06/26 06:19:05 guy Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+
+#include "nameser.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
+
+/* BIND9 lib/lwres/include/lwres */
+typedef u_int32_t lwres_uint32_t;
+typedef u_int16_t lwres_uint16_t;
+typedef u_int8_t lwres_uint8_t;
+
+struct lwres_lwpacket {
+ lwres_uint32_t length;
+ lwres_uint16_t version;
+ lwres_uint16_t pktflags;
+ lwres_uint32_t serial;
+ lwres_uint32_t opcode;
+ lwres_uint32_t result;
+ lwres_uint32_t recvlength;
+ lwres_uint16_t authtype;
+ lwres_uint16_t authlength;
+};
+
+#define LWRES_LWPACKETFLAG_RESPONSE 0x0001U /* if set, pkt is a response */
+
+#define LWRES_LWPACKETVERSION_0 0
+
+#define LWRES_FLAG_TRUSTNOTREQUIRED 0x00000001U
+#define LWRES_FLAG_SECUREDATA 0x00000002U
+
+/*
+ * no-op
+ */
+#define LWRES_OPCODE_NOOP 0x00000000U
+
+typedef struct {
+ /* public */
+ lwres_uint16_t datalength;
+ /* data follows */
+} lwres_nooprequest_t;
+
+typedef struct {
+ /* public */
+ lwres_uint16_t datalength;
+ /* data follows */
+} lwres_noopresponse_t;
+
+/*
+ * get addresses by name
+ */
+#define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
+
+typedef struct lwres_addr lwres_addr_t;
+
+struct lwres_addr {
+ lwres_uint32_t family;
+ lwres_uint16_t length;
+ /* address folows */
+};
+
+typedef struct {
+ /* public */
+ lwres_uint32_t flags;
+ lwres_uint32_t addrtypes;
+ lwres_uint16_t namelen;
+ /* name follows */
+} lwres_gabnrequest_t;
+
+typedef struct {
+ /* public */
+ lwres_uint32_t flags;
+ lwres_uint16_t naliases;
+ lwres_uint16_t naddrs;
+ lwres_uint16_t realnamelen;
+ /* aliases follows */
+ /* addrs follows */
+ /* realname follows */
+} lwres_gabnresponse_t;
+
+/*
+ * get name by address
+ */
+#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
+typedef struct {
+ /* public */
+ lwres_uint32_t flags;
+ lwres_addr_t addr;
+ /* addr body follows */
+} lwres_gnbarequest_t;
+
+typedef struct {
+ /* public */
+ lwres_uint32_t flags;
+ lwres_uint16_t naliases;
+ lwres_uint16_t realnamelen;
+ /* aliases follows */
+ /* realname follows */
+} lwres_gnbaresponse_t;
+
+/*
+ * get rdata by name
+ */
+#define LWRES_OPCODE_GETRDATABYNAME 0x00010003U
+
+typedef struct {
+ /* public */
+ lwres_uint32_t flags;
+ lwres_uint16_t rdclass;
+ lwres_uint16_t rdtype;
+ lwres_uint16_t namelen;
+ /* name follows */
+} lwres_grbnrequest_t;
+
+typedef struct {
+ /* public */
+ lwres_uint32_t flags;
+ lwres_uint16_t rdclass;
+ lwres_uint16_t rdtype;
+ lwres_uint32_t ttl;
+ lwres_uint16_t nrdatas;
+ lwres_uint16_t nsigs;
+ /* realname here (len + name) */
+ /* rdata here (len + name) */
+ /* signatures here (len + name) */
+} lwres_grbnresponse_t;
+
+#define LWRDATA_VALIDATED 0x00000001
+
+#define LWRES_ADDRTYPE_V4 0x00000001U /* ipv4 */
+#define LWRES_ADDRTYPE_V6 0x00000002U /* ipv6 */
+
+#define LWRES_MAX_ALIASES 16 /* max # of aliases */
+#define LWRES_MAX_ADDRS 64 /* max # of addrs */
+
+struct tok opcode[] = {
+ { LWRES_OPCODE_NOOP, "noop", },
+ { LWRES_OPCODE_GETADDRSBYNAME, "getaddrsbyname", },
+ { LWRES_OPCODE_GETNAMEBYADDR, "getnamebyaddr", },
+ { LWRES_OPCODE_GETRDATABYNAME, "getrdatabyname", },
+ { 0, NULL, },
+};
+
+/* print-domain.c */
+extern struct tok ns_type2str[];
+extern struct tok ns_class2str[];
+
+static int lwres_printname(size_t, const char *);
+static int lwres_printnamelen(const char *);
+static int lwres_printbinlen(const char *);
+static int lwres_printaddr(lwres_addr_t *);
+
+static int
+lwres_printname(size_t l, const char *p0)
+{
+ const char *p;
+ int i;
+
+ p = p0;
+ /* + 1 for terminating \0 */
+ if (p + l + 1 > (const char *)snapend)
+ goto trunc;
+
+ printf(" ");
+ for (i = 0; i < l; i++)
+ safeputchar(*p++);
+ p++; /* skip terminating \0 */
+
+ return p - p0;
+
+ trunc:
+ return -1;
+}
+
+static int
+lwres_printnamelen(const char *p)
+{
+ u_int16_t l;
+ int advance;
+
+ if (p + 2 > (const char *)snapend)
+ goto trunc;
+ l = EXTRACT_16BITS(p);
+ advance = lwres_printname(l, p + 2);
+ if (advance < 0)
+ goto trunc;
+ return 2 + advance;
+
+ trunc:
+ return -1;
+}
+
+static int
+lwres_printbinlen(const char *p0)
+{
+ const char *p;
+ u_int16_t l;
+ int i;
+
+ p = p0;
+ if (p + 2 > (const char *)snapend)
+ goto trunc;
+ l = EXTRACT_16BITS(p);
+ if (p + 2 + l > (const char *)snapend)
+ goto trunc;
+ p += 2;
+ for (i = 0; i < l; i++)
+ printf("%02x", *p++);
+ return p - p0;
+
+ trunc:
+ return -1;
+}
+
+static int
+lwres_printaddr(lwres_addr_t *ap)
+{
+ u_int16_t l;
+ const char *p;
+ int i;
+
+ TCHECK(ap->length);
+ l = ntohs(ap->length);
+ /* XXX ap points to packed struct */
+ p = (const char *)&ap->length + sizeof(ap->length);
+ if (p + l > (const char *)snapend)
+ goto trunc;
+
+ switch (ntohl(ap->family)) {
+ case 1: /* IPv4 */
+ printf(" %s", ipaddr_string(p));
+ p += sizeof(struct in_addr);
+ break;
+#ifdef INET6
+ case 2: /* IPv6 */
+ printf(" %s", ip6addr_string(p));
+ p += sizeof(struct in6_addr);
+ break;
+#endif
+ default:
+ printf(" %lu/", (unsigned long)ntohl(ap->family));
+ for (i = 0; i < l; i++)
+ printf("%02x", *p++);
+ }
+
+ return p - (const char *)ap;
+
+ trunc:
+ return -1;
+}
+
+void
+lwres_print(register const u_char *bp, u_int length)
+{
+ const struct lwres_lwpacket *np;
+ u_int32_t v;
+ const char *s;
+ int response;
+ int advance;
+ int unsupported = 0;
+
+ np = (const struct lwres_lwpacket *)bp;
+ TCHECK(np->authlength);
+
+ printf(" lwres");
+ v = ntohs(np->version);
+ if (vflag || v != LWRES_LWPACKETVERSION_0)
+ printf(" v%u", v);
+ if (v != LWRES_LWPACKETVERSION_0) {
+ s = (const char *)np + ntohl(np->length);
+ goto tail;
+ }
+
+ response = ntohs(np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE;
+
+ /* opcode and pktflags */
+ v = (u_int32_t)ntohl(np->opcode);
+ s = tok2str(opcode, "#0x%x", v);
+ printf(" %s%s", s, response ? "" : "?");
+
+ /* pktflags */
+ v = ntohs(np->pktflags);
+ if (v & ~LWRES_LWPACKETFLAG_RESPONSE)
+ printf("[0x%x]", v);
+
+ if (vflag > 1) {
+ printf(" ("); /*)*/
+ printf("serial:0x%lx", (unsigned long)ntohl(np->serial));
+ printf(" result:0x%lx", (unsigned long)ntohl(np->result));
+ printf(" recvlen:%lu", (unsigned long)ntohl(np->recvlength));
+ /* BIND910: not used */
+ if (vflag > 2) {
+ printf(" authtype:0x%x", ntohs(np->authtype));
+ printf(" authlen:%u", ntohs(np->authlength));
+ }
+ /*(*/
+ printf(")");
+ }
+
+ /* per-opcode content */
+ if (!response) {
+ /*
+ * queries
+ */
+ lwres_gabnrequest_t *gabn;
+ lwres_gnbarequest_t *gnba;
+ lwres_grbnrequest_t *grbn;
+ u_int32_t l;
+
+ gabn = NULL;
+ gnba = NULL;
+ grbn = NULL;
+
+ switch (ntohl(np->opcode)) {
+ case LWRES_OPCODE_NOOP:
+ break;
+ case LWRES_OPCODE_GETADDRSBYNAME:
+ gabn = (lwres_gabnrequest_t *)(np + 1);
+ TCHECK(gabn->namelen);
+ /* XXX gabn points to packed struct */
+ s = (const char *)&gabn->namelen +
+ sizeof(gabn->namelen);
+ l = ntohs(gabn->namelen);
+
+ /* BIND910: not used */
+ if (vflag > 2) {
+ printf(" flags:0x%lx",
+ (unsigned long)ntohl(gabn->flags));
+ }
+
+ v = (u_int32_t)ntohl(gabn->addrtypes);
+ switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) {
+ case LWRES_ADDRTYPE_V4:
+ printf(" IPv4");
+ break;
+ case LWRES_ADDRTYPE_V6:
+ printf(" IPv6");
+ break;
+ case LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6:
+ printf(" IPv4/6");
+ break;
+ }
+ if (v & ~(LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6))
+ printf("[0x%x]", v);
+
+ advance = lwres_printname(l, s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ break;
+ case LWRES_OPCODE_GETNAMEBYADDR:
+ gnba = (lwres_gnbarequest_t *)(np + 1);
+ TCHECK(gnba->addr);
+
+ /* BIND910: not used */
+ if (vflag > 2) {
+ printf(" flags:0x%lx",
+ (unsigned long)ntohl(gnba->flags));
+ }
+
+ s = (const char *)&gnba->addr;
+
+ advance = lwres_printaddr(&gnba->addr);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ break;
+ case LWRES_OPCODE_GETRDATABYNAME:
+ /* XXX no trace, not tested */
+ grbn = (lwres_grbnrequest_t *)(np + 1);
+ TCHECK(grbn->namelen);
+
+ /* BIND910: not used */
+ if (vflag > 2) {
+ printf(" flags:0x%lx",
+ (unsigned long)ntohl(grbn->flags));
+ }
+
+ printf(" %s", tok2str(ns_type2str, "Type%d",
+ ntohs(grbn->rdtype)));
+ if (ntohs(grbn->rdclass) != C_IN);
+ printf(" %s", tok2str(ns_class2str, "Class%d",
+ ntohs(grbn->rdclass)));
+
+ /* XXX grbn points to packed struct */
+ s = (const char *)&grbn->namelen +
+ sizeof(grbn->namelen);
+ l = ntohs(gabn->namelen);
+
+ advance = lwres_printname(l, s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ break;
+ default:
+ unsupported++;
+ break;
+ }
+ } else {
+ /*
+ * responses
+ */
+ lwres_gabnresponse_t *gabn;
+ lwres_gnbaresponse_t *gnba;
+ lwres_grbnresponse_t *grbn;
+ u_int32_t l, na;
+ int i;
+
+ gabn = NULL;
+ gnba = NULL;
+ grbn = NULL;
+
+ switch (ntohl(np->opcode)) {
+ case LWRES_OPCODE_NOOP:
+ break;
+ case LWRES_OPCODE_GETADDRSBYNAME:
+ gabn = (lwres_gabnresponse_t *)(np + 1);
+ TCHECK(gabn->realnamelen);
+ /* XXX gabn points to packed struct */
+ s = (const char *)&gabn->realnamelen +
+ sizeof(gabn->realnamelen);
+ l = ntohs(gabn->realnamelen);
+
+ /* BIND910: not used */
+ if (vflag > 2) {
+ printf(" flags:0x%lx",
+ (unsigned long)ntohl(gabn->flags));
+ }
+
+ printf(" %u/%u", ntohs(gabn->naliases),
+ ntohs(gabn->naddrs));
+
+ advance = lwres_printname(l, s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+
+ /* aliases */
+ na = ntohs(gabn->naliases);
+ for (i = 0; i < na; i++) {
+ advance = lwres_printnamelen(s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ }
+
+ /* addrs */
+ na = ntohs(gabn->naddrs);
+ for (i = 0; i < na; i++) {
+ advance = lwres_printaddr((lwres_addr_t *)s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ }
+ break;
+ case LWRES_OPCODE_GETNAMEBYADDR:
+ gnba = (lwres_gnbaresponse_t *)(np + 1);
+ TCHECK(gnba->realnamelen);
+ /* XXX gnba points to packed struct */
+ s = (const char *)&gnba->realnamelen +
+ sizeof(gnba->realnamelen);
+ l = ntohs(gnba->realnamelen);
+
+ /* BIND910: not used */
+ if (vflag > 2) {
+ printf(" flags:0x%lx",
+ (unsigned long)ntohl(gnba->flags));
+ }
+
+ printf(" %u", ntohs(gnba->naliases));
+
+ advance = lwres_printname(l, s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+
+ /* aliases */
+ na = ntohs(gnba->naliases);
+ for (i = 0; i < na; i++) {
+ advance = lwres_printnamelen(s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ }
+ break;
+ case LWRES_OPCODE_GETRDATABYNAME:
+ /* XXX no trace, not tested */
+ grbn = (lwres_grbnresponse_t *)(np + 1);
+ TCHECK(grbn->nsigs);
+
+ /* BIND910: not used */
+ if (vflag > 2) {
+ printf(" flags:0x%lx",
+ (unsigned long)ntohl(grbn->flags));
+ }
+
+ printf(" %s", tok2str(ns_type2str, "Type%d",
+ ntohs(grbn->rdtype)));
+ if (ntohs(grbn->rdclass) != C_IN);
+ printf(" %s", tok2str(ns_class2str, "Class%d",
+ ntohs(grbn->rdclass)));
+ printf(" TTL ");
+ relts_print(ntohl(grbn->ttl));
+ printf(" %u/%u", ntohs(grbn->nrdatas),
+ ntohs(grbn->nsigs));
+
+ /* XXX grbn points to packed struct */
+ s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs);
+
+ advance = lwres_printnamelen(s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+
+ /* rdatas */
+ na = ntohs(grbn->nrdatas);
+ for (i = 0; i < na; i++) {
+ /* XXX should decode resource data */
+ advance = lwres_printbinlen(s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ }
+
+ /* sigs */
+ na = ntohs(grbn->nsigs);
+ for (i = 0; i < na; i++) {
+ /* XXX how should we print it? */
+ advance = lwres_printbinlen(s);
+ if (advance < 0)
+ goto trunc;
+ s += advance;
+ }
+ break;
+ default:
+ unsupported++;
+ break;
+ }
+ }
+
+ tail:
+ /* length mismatch */
+ if (ntohl(np->length) != length) {
+ printf(" [len: %lu != %u]", (unsigned long)ntohl(np->length),
+ length);
+ }
+ if (!unsupported && s < (const char *)np + ntohl(np->length))
+ printf("[extra]");
+ return;
+
+ trunc:
+ printf("[|lwres]");
+ return;
+}
diff --git a/contrib/tcpdump/print-mobile.c b/contrib/tcpdump/print-mobile.c
index a6116f66f095..bc4f3cb98ee5 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.5 2000/09/29 04:58:43 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.7 2001/08/20 17:53:54 fenner Exp $";
#endif
#include <sys/param.h>
@@ -70,8 +70,6 @@ struct mobile_ip {
#define OSRC_PRES 0x0080 /* old source is present */
-static u_int16_t mob_in_cksum(u_short *p, int len);
-
/*
* Deencapsulate and print a mobile-tunneled IP datagram
*/
@@ -89,6 +87,7 @@ mobile_print(const u_char *bp, u_int length)
fputs("[|mobile]", stdout);
return;
}
+ fputs("mobile: ", stdout);
proto = EXTRACT_16BITS(&mob->proto);
crc = EXTRACT_16BITS(&mob->hcheck);
@@ -108,34 +107,9 @@ mobile_print(const u_char *bp, u_int length)
(void)printf("> %s ",ipaddr_string(&mob->odst));
(void)printf("(oproto=%d)",proto>>8);
}
- if (mob_in_cksum((u_short *)mob, osp ? 12 : 8)!=0) {
+ if (in_cksum((u_short *)mob, osp ? 12 : 8, 0)!=0) {
(void)printf(" (bad checksum %d)",crc);
}
return;
}
-
-static u_int16_t mob_in_cksum(u_short *p, int len)
-{
- u_int32_t sum = 0;
- int nwords = len >> 1;
-
- while (nwords-- != 0)
- sum += *p++;
-
- if (len & 1) {
- union {
- u_int16_t w;
- u_int8_t c[2];
- } u;
- u.c[0] = *(u_char *)p;
- u.c[1] = 0;
- sum += u.w;
- }
-
- /* end-around-carry */
- sum = (sum >> 16) + (sum & 0xffff);
- sum += (sum >> 16);
- return (~sum);
-}
-
diff --git a/contrib/tcpdump/print-mpls.c b/contrib/tcpdump/print-mpls.c
new file mode 100644
index 000000000000..eb03705a473c
--- /dev/null
+++ b/contrib/tcpdump/print-mpls.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2001 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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.2 2001/06/26 06:24:57 guy Exp $ (LBL)";
+#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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "addrtoname.h"
+#include "interface.h"
+#include "extract.h" /* must come after interface.h */
+
+#define LABEL_MASK 0xfffff000
+#define LABEL_SHIFT 12
+#define EXP_MASK 0x00000e00
+#define EXP_SHIFT 9
+#define STACK_MASK 0x00000100
+#define STACK_SHIFT 8
+#define TTL_MASK 0x000000ff
+#define TTL_SHIFT 0
+
+#define MPLS_LABEL(x) (((x) & LABEL_MASK) >> LABEL_SHIFT)
+#define MPLS_EXP(x) (((x) & EXP_MASK) >> EXP_SHIFT)
+#define MPLS_STACK(x) (((x) & STACK_MASK) >> STACK_SHIFT)
+#define MPLS_TTL(x) (((x) & TTL_MASK) >> TTL_SHIFT)
+
+static const char *mpls_labelname[] = {
+/*0*/ "IPv4 explicit NULL", "router alert", "IPv6 explicit NULL",
+ "implicit NULL", "rsvd",
+/*5*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd",
+/*10*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd",
+/*15*/ "rsvd",
+};
+
+/*
+ * RFC3032: MPLS label stack encoding
+ */
+void
+mpls_print(const u_char *bp, u_int length)
+{
+ const u_char *p;
+ u_int32_t v;
+
+ p = bp;
+ printf("MPLS");
+ TCHECK2(*p, sizeof(v));
+ memcpy(&v, p, sizeof(v));
+ v = (u_int32_t)ntohl(v);
+ printf(" ("); /*)*/
+ printf("label 0x%x", MPLS_LABEL(v));
+ if (vflag &&
+ MPLS_LABEL(v) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
+ printf("(%s)", mpls_labelname[MPLS_LABEL(v)]);
+ if (MPLS_EXP(v))
+ printf(" exp 0x%x", MPLS_EXP(v));
+ if (MPLS_STACK(v))
+ printf("[S]");
+ printf(" TTL %u", MPLS_TTL(v));
+ /*(*/
+ printf(")");
+
+ p += sizeof(v);
+
+ switch (MPLS_LABEL(v)) {
+ case 0: /* IPv4 explicit NULL label */
+ ip_print(p, length - (p - bp));
+ break;
+#ifdef INET6
+ case 2: /* IPv6 explicit NULL label */
+ ip6_print(p, length - (p - bp));
+ break;
+#endif
+ default:
+ /*
+ * Since there's no indication of protocol in MPLS label
+ * encoding, we can print nothing further.
+ */
+ return;
+ }
+
+trunc:
+ printf("[|MPLS]");
+}
diff --git a/contrib/tcpdump/print-msdp.c b/contrib/tcpdump/print-msdp.c
new file mode 100644
index 000000000000..2ffc34f2f220
--- /dev/null
+++ b/contrib/tcpdump/print-msdp.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2001 William C. Fenner.
+ * 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, 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-msdp.c,v 1.2 2001/12/10 08:06:40 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 "addrtoname.h"
+#include "extract.h"
+
+#define MSDP_TYPE_MAX 7
+
+void
+msdp_print(const unsigned char *sp, u_int length)
+{
+ unsigned int type, len;
+
+ TCHECK2(*sp, 3);
+ /* See if we think we're at the beginning of a compound packet */
+ type = *sp;
+ len = EXTRACT_16BITS(sp + 1);
+ if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX)
+ goto trunc; /* not really truncated, but still not decodable */
+ (void)printf(" msdp:");
+ while (length > 0) {
+ TCHECK2(*sp, 3);
+ type = *sp;
+ len = EXTRACT_16BITS(sp + 1);
+ if (len > 1400 || vflag)
+ printf(" [len %d]", len);
+ if (len < 3)
+ goto trunc;
+ sp += 3;
+ length -= 3;
+ switch (type) {
+ case 1: /* IPv4 Source-Active */
+ case 3: /* IPv4 Source-Active Response */
+ if (type == 1)
+ (void)printf(" SA");
+ else
+ (void)printf(" SA-Response");
+ TCHECK(*sp);
+ (void)printf(" %d entries", *sp);
+ if (*sp * 12 + 8 < len) {
+ (void)printf(" [w/data]");
+ if (vflag > 1) {
+ (void)printf(" ");
+ ip_print(sp + *sp * 12 + 8 - 3,
+ len - (*sp * 12 + 8));
+ }
+ }
+ break;
+ case 2:
+ (void)printf(" SA-Request");
+ TCHECK2(*sp, 5);
+ (void)printf(" for %s", ipaddr_string(sp + 1));
+ break;
+ case 4:
+ (void)printf(" Keepalive");
+ if (len != 3)
+ (void)printf("[len=%d] ", len);
+ break;
+ case 5:
+ (void)printf(" Notification");
+ break;
+ default:
+ (void)printf(" [type=%d len=%d]", type, len);
+ break;
+ }
+ sp += (len - 3);
+ length -= (len - 3);
+ }
+ return;
+trunc:
+ (void)printf(" [|msdp]");
+}
diff --git a/contrib/tcpdump/print-ospf.c b/contrib/tcpdump/print-ospf.c
index f5e452f8250d..800a44d44c0f 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.29 2000/09/29 04:58:45 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.31 2001/06/28 04:34:51 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -403,8 +403,9 @@ ospf_decode_v2(register const struct ospfhdr *op,
printf(" bdr %s",
ipaddr_string(&op->ospf_hello.hello_bdr));
if (vflag) {
- printf(" nbrs");
ap = op->ospf_hello.hello_neighbor;
+ if ((u_char *)ap < dataend)
+ printf(" nbrs");
while ((u_char *)ap < dataend) {
TCHECK(*ap);
printf(" %s", ipaddr_string(ap));
@@ -509,12 +510,6 @@ ospf_print(register const u_char *bp, register u_int length,
op = (struct ospfhdr *)bp;
ip = (struct ip *)bp2;
- /* Print the source and destination address */
-#if 0
- (void) printf("%s > %s:",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
-#endif
/* XXX Before we do anything else, strip off the MD5 trailer */
TCHECK(op->ospf_authtype);
@@ -527,7 +522,7 @@ ospf_print(register const u_char *bp, register u_int length,
/* value. If it's not valid, say so and return */
TCHECK(op->ospf_type);
cp = tok2str(type2str, "type%d", op->ospf_type);
- printf(" OSPFv%d-%s %d:", op->ospf_version, cp, length);
+ printf("OSPFv%d-%s %d:", op->ospf_version, cp, length);
if (*cp == 't')
return;
diff --git a/contrib/tcpdump/print-ospf6.c b/contrib/tcpdump/print-ospf6.c
index f52b462c8b71..5f6deb19724e 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.6 2000/09/29 04:58:45 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.7 2001/05/09 01:08:03 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -359,7 +359,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
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) &
+ (u_int32_t)ntohl(lsap->lsa_un.un_asla.asla_metric) &
ASLA_MASK_METRIC);
lsapp = lsap->lsa_un.un_asla.asla_prefix;
k = ospf6_print_lsaprefix(lsapp);
diff --git a/contrib/tcpdump/print-pppoe.c b/contrib/tcpdump/print-pppoe.c
index 81475cdfdabc..0cb94536689d 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.12 2000/10/09 02:59:40 guy Exp $ (LBL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.15 2001/07/05 18:54:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -45,178 +45,175 @@ static const char rcsid[] =
#include "extract.h" /* must come after interface.h */
/* Codes */
-enum {
- PPPOE_PADI = 0x09,
- PPPOE_PADO = 0x07,
- PPPOE_PADR = 0x19,
- PPPOE_PADS = 0x65,
- PPPOE_PADT = 0xa7
+enum {
+ PPPOE_PADI = 0x09,
+ PPPOE_PADO = 0x07,
+ PPPOE_PADR = 0x19,
+ PPPOE_PADS = 0x65,
+ PPPOE_PADT = 0xa7
};
static struct tok pppoecode2str[] = {
- { PPPOE_PADI, "PADI"},
- { PPPOE_PADO, "PADO"},
- { PPPOE_PADR, "PADR"},
- { PPPOE_PADS, "PADS"},
- { PPPOE_PADT, "PADT"},
- { 0, ""}, /* PPP Data */
- { 0, NULL }
+ { PPPOE_PADI, "PADI" },
+ { PPPOE_PADO, "PADO" },
+ { PPPOE_PADR, "PADR" },
+ { PPPOE_PADS, "PADS" },
+ { PPPOE_PADT, "PADT" },
+ { 0, "" }, /* PPP Data */
+ { 0, NULL }
};
/* Tags */
enum {
- PPPOE_EOL = 0,
- PPPOE_SERVICE_NAME = 0x0101,
- PPPOE_AC_NAME = 0x0102,
- PPPOE_HOST_UNIQ = 0x0103,
- PPPOE_AC_COOKIE = 0x0104,
- PPPOE_VENDOR = 0x0105,
- PPPOE_RELAY_SID = 0x0110,
- PPPOE_SERVICE_NAME_ERROR = 0x0201,
- PPPOE_AC_SYSTEM_ERROR = 0x0202,
- PPPOE_GENERIC_ERROR = 0x0203
+ PPPOE_EOL = 0,
+ PPPOE_SERVICE_NAME = 0x0101,
+ PPPOE_AC_NAME = 0x0102,
+ PPPOE_HOST_UNIQ = 0x0103,
+ PPPOE_AC_COOKIE = 0x0104,
+ PPPOE_VENDOR = 0x0105,
+ PPPOE_RELAY_SID = 0x0110,
+ PPPOE_SERVICE_NAME_ERROR = 0x0201,
+ PPPOE_AC_SYSTEM_ERROR = 0x0202,
+ PPPOE_GENERIC_ERROR = 0x0203
};
static struct tok pppoetag2str[] = {
- { PPPOE_EOL, "EOL"},
- { PPPOE_SERVICE_NAME, "Service-Name" },
- { PPPOE_AC_NAME, "AC-Name" },
- { PPPOE_HOST_UNIQ, "Host-Uniq" },
- { PPPOE_AC_COOKIE, "AC-Cookie" },
- { PPPOE_VENDOR, "Vendor-Specific" },
- { PPPOE_RELAY_SID, "Relay-Session-ID" },
- { PPPOE_SERVICE_NAME_ERROR, "Service-Name-Error" },
- { PPPOE_AC_SYSTEM_ERROR, "AC-System-Error" },
- { PPPOE_GENERIC_ERROR, "Generic-Error" },
- { 0, NULL}
+ { PPPOE_EOL, "EOL" },
+ { PPPOE_SERVICE_NAME, "Service-Name" },
+ { PPPOE_AC_NAME, "AC-Name" },
+ { PPPOE_HOST_UNIQ, "Host-Uniq" },
+ { PPPOE_AC_COOKIE, "AC-Cookie" },
+ { PPPOE_VENDOR, "Vendor-Specific" },
+ { PPPOE_RELAY_SID, "Relay-Session-ID" },
+ { PPPOE_SERVICE_NAME_ERROR, "Service-Name-Error" },
+ { PPPOE_AC_SYSTEM_ERROR, "AC-System-Error" },
+ { PPPOE_GENERIC_ERROR, "Generic-Error" },
+ { 0, NULL }
};
#define PPPOE_HDRLEN 6
void
+pppoe_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;
+
+ ++infodelay;
+ ts_print(&h->ts);
+
+ /*
+ * 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;
+
+ pppoe_print(p, length);
+ putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
+}
+
+void
pppoe_print(register const u_char *bp, u_int length)
{
- register const struct ether_header *eh;
- register u_short pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid, pppoe_length;
- const u_char *pppoe_packet, *pppoe_payload;
-
- eh = (struct ether_header *)packetp;
- pppoe_packet = packetp+ETHER_HDRLEN;
- if (pppoe_packet > snapend) {
- printf("[|pppoe]");
- return;
- }
-
- pppoe_ver = (pppoe_packet[0]&0xF0)>>4;
- pppoe_type = (pppoe_packet[0]&0x0F);
- pppoe_code = (pppoe_packet[1]);
- pppoe_sessionid = (EXTRACT_16BITS(pppoe_packet+2));
- pppoe_length = (EXTRACT_16BITS(pppoe_packet+4));
- pppoe_payload = pppoe_packet+6;
-
- if (snapend < pppoe_payload) {
- printf(" truncated PPPoE");
- return;
- }
-
- if (pppoe_ver != 1) {
- printf(" [ver %d]",pppoe_ver);
- }
- if (pppoe_type != 1) {
- printf(" [type %d]",pppoe_type);
- }
-
- printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
- if (pppoe_code == PPPOE_PADI && pppoe_length > 1484-PPPOE_HDRLEN) {
- printf(" [len %d!]",pppoe_length);
- }
- if (pppoe_sessionid) {
- printf(" [ses 0x%x]",pppoe_sessionid);
- }
-
- if (pppoe_payload + pppoe_length < snapend) {
- /*
- printf(" [length %d (%d extra bytes)]", pppoe_length, snapend-pppoe_payload-pppoe_length);
- {
- const u_char *x = pppoe_payload+pppoe_length;
- default_print(x, snapend - x);
- }
- */
- snapend = pppoe_payload+pppoe_length;
- }
-
-
- if (pppoe_code) {
- /* PPP session packets don't contain tags */
- 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 0xffff for first iteration
- */
- while (tag_type &&
- p+4 < pppoe_payload + length &&
- p+4 < snapend) {
- tag_type = EXTRACT_16BITS(p);
- tag_len = EXTRACT_16BITS(p+2);
- p += 4;
- /* p points to tag_value */
-
- if (tag_len) {
- int isascii = 1;
- const u_char *v = p;
-
- for (v=p; v<p+tag_len; v++)
- if (*v >= 127 || *v < 32) {
- isascii = 0;
- break;
- }
-
- /* TODO print UTF8 decoded text */
- if (isascii)
- printf(" [%s \"%*.*s\"]",
- tok2str(pppoetag2str, "TAG-0x%x", tag_type),
- tag_len < 80 ? tag_len : 80,
- tag_len < 80 ? tag_len : 80,
- p
- );
- else
- printf(" [%s UTF8]", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
- } else
- printf(" [%s]", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
-
- p += tag_len;
- /* p points to next tag */
- }
- } else {
+ u_short pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid, pppoe_length;
+ const u_char *pppoe_packet, *pppoe_payload;
+
+ pppoe_packet = bp;
+ if (pppoe_packet > snapend) {
+ printf("[|pppoe]");
+ return;
+ }
+
+ pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4;
+ pppoe_type = (pppoe_packet[0] & 0x0F);
+ pppoe_code = pppoe_packet[1];
+ pppoe_sessionid = EXTRACT_16BITS(pppoe_packet + 2);
+ pppoe_length = EXTRACT_16BITS(pppoe_packet + 4);
+ pppoe_payload = pppoe_packet + PPPOE_HDRLEN;
+
+ if (snapend < pppoe_payload) {
+ printf(" truncated PPPoE");
+ return;
+ }
+
+ if (pppoe_ver != 1) {
+ printf(" [ver %d]",pppoe_ver);
+ }
+ if (pppoe_type != 1) {
+ printf(" [type %d]",pppoe_type);
+ }
+
+ printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
+ if (pppoe_code == PPPOE_PADI && pppoe_length > 1484 - PPPOE_HDRLEN) {
+ printf(" [len %d!]",pppoe_length);
+ }
+ if (pppoe_sessionid) {
+ printf(" [ses 0x%x]", pppoe_sessionid);
+ }
+
+ if (pppoe_payload + pppoe_length < snapend) {
#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];
- pppoe_payload +=1;
- pppoe_length -=1;
- } else if (pppoe_payload[1] & 0x1) {
- ptype = ntohs(*(u_short *)pppoe_payload);
- pppoe_payload +=2;
- pppoe_length -=2;
- } else {
- printf(" Invalid PPP protocol ID: %x %x", pppoe_payload[0],pppoe_payload[1]);
- return;
- }
- printf(" ");
- if (ptype == PPP_IP)
- ip_print(pppoe_payload, pppoe_length);
- else if (ptype == PPP_LCP)
- lcp_print(pppoe_payload, pppoe_length);
- else
- printf("%s ", tok2str(ppptype2str, "proto-0x%x", ptype));
+ const u_char *x = pppoe_payload + pppoe_length;
+ printf(" [length %d (%d extra bytes)]",
+ pppoe_length, snapend - pppoe_payload - pppoe_length);
+ default_print(x, snapend - x);
#endif
- printf(" ");
- ppp_print(pppoe_payload, pppoe_length);
- }
- return;
+ snapend = pppoe_payload+pppoe_length;
+ }
+
+ if (pppoe_code) {
+ /* PPP session packets don't contain tags */
+ 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 0xffff for first iteration
+ */
+ while (tag_type && p + 4 < pppoe_payload + length &&
+ p + 4 < snapend) {
+ tag_type = EXTRACT_16BITS(p);
+ tag_len = EXTRACT_16BITS(p + 2);
+ p += 4;
+ /* p points to tag_value */
+
+ if (tag_len) {
+ int isascii = 1;
+ const u_char *v = p;
+ u_short l;
+
+ for (v = p; v < p + tag_len; v++)
+ if (*v >= 127 || *v < 32) {
+ isascii = 0;
+ break;
+ }
+
+ /* TODO print UTF8 decoded text */
+ if (isascii) {
+ l = (tag_len < 80 ? tag_len : 80);
+ printf(" [%s \"%*.*s\"]",
+ tok2str(pppoetag2str, "TAG-0x%x", tag_type),
+ l, l, p);
+ } else
+ printf(" [%s UTF8]",
+ tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+ } else
+ printf(" [%s]", tok2str(pppoetag2str,
+ "TAG-0x%x", tag_type));
+
+ p += tag_len;
+ /* p points to next tag */
+ }
+ } else {
+ printf(" ");
+ ppp_print(pppoe_payload, pppoe_length);
+ }
+ return;
}
diff --git a/contrib/tcpdump/print-pptp.c b/contrib/tcpdump/print-pptp.c
new file mode 100644
index 000000000000..1798fd3449d0
--- /dev/null
+++ b/contrib/tcpdump/print-pptp.c
@@ -0,0 +1,1070 @@
+/*
+ * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
+ */
+
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.3 2001/10/31 08:54:31 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "interface.h"
+
+static char tstr[] = " [|pptp]";
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
+#define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
+#define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
+
+#define PPTP_CTRL_MSG_TYPE_SCCRQ 1
+#define PPTP_CTRL_MSG_TYPE_SCCRP 2
+#define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
+#define PPTP_CTRL_MSG_TYPE_StopCCRP 4
+#define PPTP_CTRL_MSG_TYPE_ECHORQ 5
+#define PPTP_CTRL_MSG_TYPE_ECHORP 6
+#define PPTP_CTRL_MSG_TYPE_OCRQ 7
+#define PPTP_CTRL_MSG_TYPE_OCRP 8
+#define PPTP_CTRL_MSG_TYPE_ICRQ 9
+#define PPTP_CTRL_MSG_TYPE_ICRP 10
+#define PPTP_CTRL_MSG_TYPE_ICCN 11
+#define PPTP_CTRL_MSG_TYPE_CCRQ 12
+#define PPTP_CTRL_MSG_TYPE_CDN 13
+#define PPTP_CTRL_MSG_TYPE_WEN 14
+#define PPTP_CTRL_MSG_TYPE_SLI 15
+
+#define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */
+#define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
+
+#define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
+#define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
+
+static char *pptp_message_type_string[] = {
+ "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
+ "SCCRQ", /* 1 Start-Control-Connection-Request */
+ "SCCRP", /* 2 Start-Control-Connection-Reply */
+ "StopCCRQ", /* 3 Stop-Control-Connection-Request */
+ "StopCCRP", /* 4 Stop-Control-Connection-Reply */
+ "ECHORQ", /* 5 Echo Request */
+ "ECHORP", /* 6 Echo Reply */
+
+ "OCRQ", /* 7 Outgoing-Call-Request */
+ "OCRP", /* 8 Outgoing-Call-Reply */
+ "ICRQ", /* 9 Incoming-Call-Request */
+ "ICRP", /* 10 Incoming-Call-Reply */
+ "ICCN", /* 11 Incoming-Call-Connected */
+ "CCRQ", /* 12 Call-Clear-Request */
+ "CDN", /* 13 Call-Disconnect-Notify */
+
+ "WEN", /* 14 WAN-Error-Notify */
+
+ "SLI" /* 15 Set-Link-Info */
+#define PPTP_MAX_MSGTYPE_INDEX 16
+};
+
+/* common for all PPTP control messages */
+struct pptp_hdr {
+ u_int16_t length;
+ u_int16_t msg_type;
+ u_int32_t magic_cookie;
+ u_int16_t ctrl_msg_type;
+ u_int16_t reserved0;
+};
+
+struct pptp_msg_sccrq {
+ u_int16_t proto_ver;
+ u_int16_t reserved1;
+ u_int32_t framing_cap;
+ u_int32_t bearer_cap;
+ u_int16_t max_channel;
+ u_int16_t firm_rev;
+ u_char hostname[64];
+ u_char vendor[64];
+};
+
+struct pptp_msg_sccrp {
+ u_int16_t proto_ver;
+ u_int8_t result_code;
+ u_int8_t err_code;
+ u_int32_t framing_cap;
+ u_int32_t bearer_cap;
+ u_int16_t max_channel;
+ u_int16_t firm_rev;
+ u_char hostname[64];
+ u_char vendor[64];
+};
+
+struct pptp_msg_stopccrq {
+ u_int8_t reason;
+ u_int8_t reserved1;
+ u_int16_t reserved2;
+};
+
+struct pptp_msg_stopccrp {
+ u_int8_t result_code;
+ u_int8_t err_code;
+ u_int16_t reserved1;
+};
+
+struct pptp_msg_echorq {
+ u_int32_t id;
+};
+
+struct pptp_msg_echorp {
+ u_int32_t id;
+ u_int8_t result_code;
+ u_int8_t err_code;
+ u_int16_t reserved1;
+};
+
+struct pptp_msg_ocrq {
+ u_int16_t call_id;
+ u_int16_t call_ser;
+ u_int32_t min_bps;
+ u_int32_t max_bps;
+ u_int32_t bearer_type;
+ u_int32_t framing_type;
+ u_int16_t recv_winsiz;
+ u_int16_t pkt_proc_delay;
+ u_int16_t phone_no_len;
+ u_int16_t reserved1;
+ u_char phone_no[64];
+ u_char subaddr[64];
+};
+
+struct pptp_msg_ocrp {
+ u_int16_t call_id;
+ u_int16_t peer_call_id;
+ u_int8_t result_code;
+ u_int8_t err_code;
+ u_int16_t cause_code;
+ u_int32_t conn_speed;
+ u_int16_t recv_winsiz;
+ u_int16_t pkt_proc_delay;
+ u_int32_t phy_chan_id;
+};
+
+struct pptp_msg_icrq {
+ u_int16_t call_id;
+ u_int16_t call_ser;
+ u_int32_t bearer_type;
+ u_int32_t phy_chan_id;
+ u_int16_t dialed_no_len;
+ u_int16_t dialing_no_len;
+ u_char dialed_no[64]; /* DNIS */
+ u_char dialing_no[64]; /* CLID */
+ u_char subaddr[64];
+};
+
+struct pptp_msg_icrp {
+ u_int16_t call_id;
+ u_int16_t peer_call_id;
+ u_int8_t result_code;
+ u_int8_t err_code;
+ u_int16_t recv_winsiz;
+ u_int16_t pkt_proc_delay;
+ u_int16_t reserved1;
+};
+
+struct pptp_msg_iccn {
+ u_int16_t peer_call_id;
+ u_int16_t reserved1;
+ u_int32_t conn_speed;
+ u_int16_t recv_winsiz;
+ u_int16_t pkt_proc_delay;
+ u_int32_t framing_type;
+};
+
+struct pptp_msg_ccrq {
+ u_int16_t call_id;
+ u_int16_t reserved1;
+};
+
+struct pptp_msg_cdn {
+ u_int16_t call_id;
+ u_int8_t result_code;
+ u_int8_t err_code;
+ u_int16_t cause_code;
+ u_int16_t reserved1;
+ u_char call_stats[128];
+};
+
+struct pptp_msg_wen {
+ u_int16_t peer_call_id;
+ u_int16_t reserved1;
+ u_int32_t crc_err;
+ u_int32_t framing_err;
+ u_int32_t hardware_overrun;
+ u_int32_t buffer_overrun;
+ u_int32_t timeout_err;
+ u_int32_t align_err;
+};
+
+struct pptp_msg_sli {
+ u_int16_t peer_call_id;
+ u_int16_t reserved1;
+ u_int32_t send_accm;
+ u_int32_t recv_accm;
+};
+
+/* attributes that appear more than once in above messages:
+
+ Number of
+ occurence attributes
+ --------------------------------------
+ 2 u_int32_t bearer_cap;
+ 2 u_int32_t bearer_type;
+ 6 u_int16_t call_id;
+ 2 u_int16_t call_ser;
+ 2 u_int16_t cause_code;
+ 2 u_int32_t conn_speed;
+ 6 u_int8_t err_code;
+ 2 u_int16_t firm_rev;
+ 2 u_int32_t framing_cap;
+ 2 u_int32_t framing_type;
+ 2 u_char hostname[64];
+ 2 u_int32_t id;
+ 2 u_int16_t max_channel;
+ 5 u_int16_t peer_call_id;
+ 2 u_int32_t phy_chan_id;
+ 4 u_int16_t pkt_proc_delay;
+ 2 u_int16_t proto_ver;
+ 4 u_int16_t recv_winsiz;
+ 2 u_int8_t reserved1;
+ 9 u_int16_t reserved1;
+ 6 u_int8_t result_code;
+ 2 u_char subaddr[64];
+ 2 u_char vendor[64];
+
+ so I will prepare print out functions for these attributes (except for
+ reserved*).
+*/
+
+/******************************************/
+/* Attribute-specific print out functions */
+/******************************************/
+
+/* In these attribute-specific print-out functions, it't not necessary
+ to do TCHECK because they are already checked in the caller of
+ these functions. */
+
+static void
+pptp_bearer_cap_print(const u_int32_t *bearer_cap)
+{
+ printf(" BEARER_CAP(");
+ if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) {
+ printf("D");
+ }
+ if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) {
+ printf("A");
+ }
+ printf(")");
+}
+
+static void
+pptp_bearer_type_print(const u_int32_t *bearer_type)
+{
+ printf(" BEARER_TYPE(");
+ switch (ntohl(*bearer_type)) {
+ case 1:
+ printf("A"); /* Analog */
+ break;
+ case 2:
+ printf("D"); /* Digital */
+ break;
+ case 3:
+ printf("Any");
+ break;
+ default:
+ printf("?");
+ break;
+ }
+ printf(")");
+}
+
+static void
+pptp_call_id_print(const u_int16_t *call_id)
+{
+ printf(" CALL_ID(%u)", ntohs(*call_id));
+}
+
+static void
+pptp_call_ser_print(const u_int16_t *call_ser)
+{
+ printf(" CALL_SER_NUM(%u)", ntohs(*call_ser));
+}
+
+static void
+pptp_cause_code_print(const u_int16_t *cause_code)
+{
+ printf(" CAUSE_CODE(%u)", ntohs(*cause_code));
+}
+
+static void
+pptp_conn_speed_print(const u_int32_t *conn_speed)
+{
+ printf(" CONN_SPEED(%lu)", (unsigned long)ntohl(*conn_speed));
+}
+
+static void
+pptp_err_code_print(const u_int8_t *err_code)
+{
+ printf(" ERR_CODE(%u", *err_code);
+ if (vflag) {
+ switch (*err_code) {
+ case 0:
+ printf(":None");
+ break;
+ case 1:
+ printf(":Not-Connected");
+ break;
+ case 2:
+ printf(":Bad-Format");
+ break;
+ case 3:
+ printf(":Bad-Valude");
+ break;
+ case 4:
+ printf(":No-Resource");
+ break;
+ case 5:
+ printf(":Bad-Call-ID");
+ break;
+ case 6:
+ printf(":PAC-Error");
+ break;
+ default:
+ printf(":?");
+ break;
+ }
+ }
+ printf(")");
+}
+
+static void
+pptp_firm_rev_print(const u_int16_t *firm_rev)
+{
+ printf(" FIRM_REV(%u)", ntohs(*firm_rev));
+}
+
+static void
+pptp_framing_cap_print(const u_int32_t *framing_cap)
+{
+ printf(" FRAME_CAP(");
+ if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
+ printf("A"); /* Async */
+ }
+ if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
+ printf("S"); /* Sync */
+ }
+ printf(")");
+}
+
+static void
+pptp_framing_type_print(const u_int32_t *framing_type)
+{
+ printf(" FRAME_TYPE(");
+ switch (ntohl(*framing_type)) {
+ case 1:
+ printf("A"); /* Async */
+ break;
+ case 2:
+ printf("S"); /* Sync */
+ break;
+ case 3:
+ printf("E"); /* Either */
+ break;
+ default:
+ printf("?");
+ break;
+ }
+ printf(")");
+}
+
+static void
+pptp_hostname_print(const u_char *hostname)
+{
+ printf(" HOSTNAME(%.64s)", hostname);
+}
+
+static void
+pptp_id_print(const u_int32_t *id)
+{
+ printf(" ID(%lu)", (unsigned long)ntohl(*id));
+}
+
+static void
+pptp_max_channel_print(const u_int16_t *max_channel)
+{
+ printf(" MAX_CHAN(%u)", ntohs(*max_channel));
+}
+
+static void
+pptp_peer_call_id_print(const u_int16_t *peer_call_id)
+{
+ printf(" PEER_CALL_ID(%u)", ntohs(*peer_call_id));
+}
+
+static void
+pptp_phy_chan_id_print(const u_int32_t *phy_chan_id)
+{
+ printf(" PHY_CHAN_ID(%lu)", (unsigned long)ntohl(*phy_chan_id));
+}
+
+static void
+pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay)
+{
+ printf(" PROC_DELAY(%u)", ntohs(*pkt_proc_delay));
+}
+
+static void
+pptp_proto_ver_print(const u_int16_t *proto_ver)
+{
+ printf(" PROTO_VER(%u.%u)", /* Version.Revision */
+ ntohs(*proto_ver) >> 8, ntohs(*proto_ver) & 0xff);
+}
+
+static void
+pptp_recv_winsiz_print(const u_int16_t *recv_winsiz)
+{
+ printf(" RECV_WIN(%u)", ntohs(*recv_winsiz));
+}
+
+static void
+pptp_result_code_print(const u_int8_t *result_code, int ctrl_msg_type)
+{
+ printf(" RESULT_CODE(%u", *result_code);
+ if (vflag) {
+ switch (ctrl_msg_type) {
+ case PPTP_CTRL_MSG_TYPE_SCCRP:
+ switch (*result_code) {
+ case 1:
+ printf(":Successful channel establishment");
+ break;
+ case 2:
+ printf(":General error");
+ break;
+ case 3:
+ printf(":Command channel already exists");
+ break;
+ case 4:
+ printf(":Requester is not authorized to establish a command channel");
+ break;
+ case 5:
+ printf(":The protocol version of the requester is not supported");
+ break;
+ default:
+ printf(":?");
+ break;
+ }
+ break;
+ case PPTP_CTRL_MSG_TYPE_StopCCRP:
+ case PPTP_CTRL_MSG_TYPE_ECHORP:
+ switch (*result_code) {
+ case 1:
+ printf(":OK");
+ break;
+ case 2:
+ printf(":General Error");
+ break;
+ default:
+ printf(":?");
+ break;
+ }
+ break;
+ case PPTP_CTRL_MSG_TYPE_OCRP:
+ switch (*result_code) {
+ case 1:
+ printf(":Connected");
+ break;
+ case 2:
+ printf(":General Error");
+ break;
+ case 3:
+ printf(":No Carrier");
+ break;
+ case 4:
+ printf(":Busy");
+ break;
+ case 5:
+ printf(":No Dial Tone");
+ break;
+ case 6:
+ printf(":Time-out");
+ break;
+ case 7:
+ printf(":Do Not Accept");
+ break;
+ default:
+ printf(":?");
+ break;
+ }
+ break;
+ case PPTP_CTRL_MSG_TYPE_ICRP:
+ switch (*result_code) {
+ case 1:
+ printf(":Connect");
+ break;
+ case 2:
+ printf(":General Error");
+ break;
+ case 3:
+ printf(":Do Not Accept");
+ break;
+ default:
+ printf(":?");
+ break;
+ }
+ break;
+ case PPTP_CTRL_MSG_TYPE_CDN:
+ switch (*result_code) {
+ case 1:
+ printf(":Lost Carrier");
+ break;
+ case 2:
+ printf(":General Error");
+ break;
+ case 3:
+ printf(":Admin Shutdown");
+ break;
+ case 4:
+ printf(":Request");
+ default:
+ printf(":?");
+ break;
+ break;
+ }
+ default:
+ /* assertion error */
+ break;
+ }
+ }
+ printf(")");
+}
+
+static void
+pptp_subaddr_print(const u_char *subaddr)
+{
+ printf(" SUB_ADDR(%.64s)", subaddr);
+}
+
+static void
+pptp_vendor_print(const u_char *vendor)
+{
+ printf(" VENDOR(%.64s)", vendor);
+}
+
+/************************************/
+/* PPTP message print out functions */
+/************************************/
+static void
+pptp_sccrq_print(const u_char *dat)
+{
+ struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
+
+ TCHECK(ptr->proto_ver);
+ pptp_proto_ver_print(&ptr->proto_ver);
+ TCHECK(ptr->reserved1);
+ TCHECK(ptr->framing_cap);
+ pptp_framing_cap_print(&ptr->framing_cap);
+ TCHECK(ptr->bearer_cap);
+ pptp_bearer_cap_print(&ptr->bearer_cap);
+ TCHECK(ptr->max_channel);
+ pptp_max_channel_print(&ptr->max_channel);
+ TCHECK(ptr->firm_rev);
+ pptp_firm_rev_print(&ptr->firm_rev);
+ TCHECK(ptr->hostname);
+ pptp_hostname_print(&ptr->hostname[0]);
+ TCHECK(ptr->vendor);
+ pptp_vendor_print(&ptr->vendor[0]);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_sccrp_print(const u_char *dat)
+{
+ struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
+
+ TCHECK(ptr->proto_ver);
+ pptp_proto_ver_print(&ptr->proto_ver);
+ TCHECK(ptr->result_code);
+ pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
+ TCHECK(ptr->err_code);
+ pptp_err_code_print(&ptr->err_code);
+ TCHECK(ptr->framing_cap);
+ pptp_framing_cap_print(&ptr->framing_cap);
+ TCHECK(ptr->bearer_cap);
+ pptp_bearer_cap_print(&ptr->bearer_cap);
+ TCHECK(ptr->max_channel);
+ pptp_max_channel_print(&ptr->max_channel);
+ TCHECK(ptr->firm_rev);
+ pptp_firm_rev_print(&ptr->firm_rev);
+ TCHECK(ptr->hostname);
+ pptp_hostname_print(&ptr->hostname[0]);
+ TCHECK(ptr->vendor);
+ pptp_vendor_print(&ptr->vendor[0]);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_stopccrq_print(const u_char *dat)
+{
+ struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
+
+ TCHECK(ptr->reason);
+ printf(" REASON(%u", ptr->reason);
+ if (vflag) {
+ switch (ptr->reason) {
+ case 1:
+ printf(":None");
+ break;
+ case 2:
+ printf(":Stop-Protocol");
+ break;
+ case 3:
+ printf(":Stop-Local-Shutdown");
+ break;
+ default:
+ printf(":?");
+ break;
+ }
+ }
+ printf(")");
+ TCHECK(ptr->reserved1);
+ TCHECK(ptr->reserved2);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_stopccrp_print(const u_char *dat)
+{
+ struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
+
+ TCHECK(ptr->result_code);
+ pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
+ TCHECK(ptr->err_code);
+ pptp_err_code_print(&ptr->err_code);
+ TCHECK(ptr->reserved1);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_echorq_print(const u_char *dat)
+{
+ struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
+
+ TCHECK(ptr->id);
+ pptp_id_print(&ptr->id);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_echorp_print(const u_char *dat)
+{
+ struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
+
+ TCHECK(ptr->id);
+ pptp_id_print(&ptr->id);
+ TCHECK(ptr->result_code);
+ pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
+ TCHECK(ptr->err_code);
+ pptp_err_code_print(&ptr->err_code);
+ TCHECK(ptr->reserved1);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_ocrq_print(const u_char *dat)
+{
+ struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
+
+ TCHECK(ptr->call_id);
+ pptp_call_id_print(&ptr->call_id);
+ TCHECK(ptr->call_ser);
+ pptp_call_ser_print(&ptr->call_ser);
+ TCHECK(ptr->min_bps);
+ printf(" MIN_BPS(%lu)", (unsigned long)ntohl(ptr->min_bps));
+ TCHECK(ptr->max_bps);
+ printf(" MAX_BPS(%lu)", (unsigned long)ntohl(ptr->max_bps));
+ TCHECK(ptr->bearer_type);
+ pptp_bearer_type_print(&ptr->bearer_type);
+ TCHECK(ptr->framing_type);
+ pptp_framing_type_print(&ptr->framing_type);
+ TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(&ptr->recv_winsiz);
+ TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
+ TCHECK(ptr->phone_no_len);
+ printf(" PHONE_NO_LEN(%u)", ntohs(ptr->phone_no_len));
+ TCHECK(ptr->reserved1);
+ TCHECK(ptr->phone_no);
+ printf(" PHONE_NO(%.64s)", ptr->phone_no);
+ TCHECK(ptr->subaddr);
+ pptp_subaddr_print(&ptr->subaddr[0]);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_ocrp_print(const u_char *dat)
+{
+ struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
+
+ TCHECK(ptr->call_id);
+ pptp_call_id_print(&ptr->call_id);
+ TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(&ptr->peer_call_id);
+ TCHECK(ptr->result_code);
+ pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
+ TCHECK(ptr->err_code);
+ pptp_err_code_print(&ptr->err_code);
+ TCHECK(ptr->cause_code);
+ pptp_cause_code_print(&ptr->cause_code);
+ TCHECK(ptr->conn_speed);
+ pptp_conn_speed_print(&ptr->conn_speed);
+ TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(&ptr->recv_winsiz);
+ TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
+ TCHECK(ptr->phy_chan_id);
+ pptp_phy_chan_id_print(&ptr->phy_chan_id);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_icrq_print(const u_char *dat)
+{
+ struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
+
+ TCHECK(ptr->call_id);
+ pptp_call_id_print(&ptr->call_id);
+ TCHECK(ptr->call_ser);
+ pptp_call_ser_print(&ptr->call_ser);
+ TCHECK(ptr->bearer_type);
+ pptp_bearer_type_print(&ptr->bearer_type);
+ TCHECK(ptr->phy_chan_id);
+ pptp_phy_chan_id_print(&ptr->phy_chan_id);
+ TCHECK(ptr->dialed_no_len);
+ printf(" DIALED_NO_LEN(%u)", ntohs(ptr->dialed_no_len));
+ TCHECK(ptr->dialing_no_len);
+ printf(" DIALING_NO_LEN(%u)", ntohs(ptr->dialing_no_len));
+ TCHECK(ptr->dialed_no);
+ printf(" DIALED_NO(%.64s)", ptr->dialed_no);
+ TCHECK(ptr->dialing_no);
+ printf(" DIALING_NO(%.64s)", ptr->dialing_no);
+ TCHECK(ptr->subaddr);
+ pptp_subaddr_print(&ptr->subaddr[0]);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_icrp_print(const u_char *dat)
+{
+ struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
+
+ TCHECK(ptr->call_id);
+ pptp_call_id_print(&ptr->call_id);
+ TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(&ptr->peer_call_id);
+ TCHECK(ptr->result_code);
+ pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
+ TCHECK(ptr->err_code);
+ pptp_err_code_print(&ptr->err_code);
+ TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(&ptr->recv_winsiz);
+ TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
+ TCHECK(ptr->reserved1);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_iccn_print(const u_char *dat)
+{
+ struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
+
+ TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(&ptr->peer_call_id);
+ TCHECK(ptr->reserved1);
+ TCHECK(ptr->conn_speed);
+ pptp_conn_speed_print(&ptr->conn_speed);
+ TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(&ptr->recv_winsiz);
+ TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
+ TCHECK(ptr->framing_type);
+ pptp_framing_type_print(&ptr->framing_type);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_ccrq_print(const u_char *dat)
+{
+ struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
+
+ TCHECK(ptr->call_id);
+ pptp_call_id_print(&ptr->call_id);
+ TCHECK(ptr->reserved1);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_cdn_print(const u_char *dat)
+{
+ struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
+
+ TCHECK(ptr->call_id);
+ pptp_call_id_print(&ptr->call_id);
+ TCHECK(ptr->result_code);
+ pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
+ TCHECK(ptr->err_code);
+ pptp_err_code_print(&ptr->err_code);
+ TCHECK(ptr->cause_code);
+ pptp_cause_code_print(&ptr->cause_code);
+ TCHECK(ptr->reserved1);
+ TCHECK(ptr->call_stats);
+ printf(" CALL_STATS(%.128s)", ptr->call_stats);
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_wen_print(const u_char *dat)
+{
+ struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
+
+ TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(&ptr->peer_call_id);
+ TCHECK(ptr->reserved1);
+ TCHECK(ptr->crc_err);
+ printf(" CRC_ERR(%lu)", (unsigned long)ntohl(ptr->crc_err));
+ TCHECK(ptr->framing_err);
+ printf(" FRAMING_ERR(%lu)", (unsigned long)ntohl(ptr->framing_err));
+ TCHECK(ptr->hardware_overrun);
+ printf(" HARDWARE_OVERRUN(%lu)",
+ (unsigned long)ntohl(ptr->hardware_overrun));
+ TCHECK(ptr->buffer_overrun);
+ printf(" BUFFER_OVERRUN(%lu)",
+ (unsigned long)ntohl(ptr->buffer_overrun));
+ TCHECK(ptr->timeout_err);
+ printf(" TIMEOUT_ERR(%lu)", (unsigned long)ntohl(ptr->timeout_err));
+ TCHECK(ptr->align_err);
+ printf(" ALIGN_ERR(%lu)", (unsigned long)ntohl(ptr->align_err));
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+static void
+pptp_sli_print(const u_char *dat)
+{
+ struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
+
+ TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(&ptr->peer_call_id);
+ TCHECK(ptr->reserved1);
+ TCHECK(ptr->send_accm);
+ printf(" SEND_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->send_accm));
+ TCHECK(ptr->recv_accm);
+ printf(" RECV_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->recv_accm));
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
+
+void
+pptp_print(const u_char *dat, u_int length)
+{
+ const struct pptp_hdr *hdr;
+ u_int32_t mc;
+ u_int16_t ctrl_msg_type;
+
+ printf(": pptp");
+
+ hdr = (struct pptp_hdr *)dat;
+
+ TCHECK(hdr->length);
+ if (vflag) {
+ printf(" Length=%u", ntohs(hdr->length));
+ }
+ TCHECK(hdr->msg_type);
+ if (vflag) {
+ switch(ntohs(hdr->msg_type)) {
+ case PPTP_MSG_TYPE_CTRL:
+ printf(" CTRL-MSG");
+ break;
+ case PPTP_MSG_TYPE_MGMT:
+ printf(" MGMT-MSG");
+ break;
+ default:
+ printf(" UNKNOWN-MSG-TYPE");
+ break;
+ }
+ }
+
+ TCHECK(hdr->magic_cookie);
+ mc = ntohl(hdr->magic_cookie);
+ if (mc != PPTP_MAGIC_COOKIE) {
+ printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
+ }
+ if (vflag || mc != PPTP_MAGIC_COOKIE) {
+ printf(" Magic-Cookie=%08x", mc);
+ }
+ TCHECK(hdr->ctrl_msg_type);
+ ctrl_msg_type = ntohs(hdr->ctrl_msg_type);
+ if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
+ printf(" CTRL_MSGTYPE=%s",
+ pptp_message_type_string[ctrl_msg_type]);
+ } else {
+ printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
+ }
+ TCHECK(hdr->reserved0);
+
+ dat += 12;
+
+ switch(ctrl_msg_type) {
+ case PPTP_CTRL_MSG_TYPE_SCCRQ:
+ pptp_sccrq_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_SCCRP:
+ pptp_sccrp_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_StopCCRQ:
+ pptp_stopccrq_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_StopCCRP:
+ pptp_stopccrp_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_ECHORQ:
+ pptp_echorq_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_ECHORP:
+ pptp_echorp_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_OCRQ:
+ pptp_ocrq_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_OCRP:
+ pptp_ocrp_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_ICRQ:
+ pptp_icrq_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_ICRP:
+ pptp_icrp_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_ICCN:
+ pptp_iccn_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_CCRQ:
+ pptp_ccrq_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_CDN:
+ pptp_cdn_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_WEN:
+ pptp_wen_print(dat);
+ break;
+ case PPTP_CTRL_MSG_TYPE_SLI:
+ pptp_sli_print(dat);
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
diff --git a/contrib/tcpdump/print-radius.c b/contrib/tcpdump/print-radius.c
index 32c8575817a6..a3c84035c5b6 100644
--- a/contrib/tcpdump/print-radius.c
+++ b/contrib/tcpdump/print-radius.c
@@ -1,4 +1,25 @@
/*
+ * Copyright (C) 2000 Alfredo Andres Omella. 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 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.
+ */
+/*
* Radius printer routines as specified on:
*
* RFC 2865:
@@ -23,13 +44,15 @@
#ifndef lint
static const char rcsid[] =
- "$Id: print-radius.c,v 1.5 2000/12/18 08:16:58 guy Exp $";
+ "$Id: print-radius.c,v 1.10 2001/10/22 06:58:33 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <string.h>
+
#include <sys/param.h>
#include <netinet/in.h>
@@ -115,6 +138,7 @@ struct radius_hdr { u_int8_t code; /* Radius packet code */
u_int8_t auth[16]; /* Authenticator */
};
+#define MIN_RADIUS_LEN 20
struct radius_attr { u_int8_t type; /* Attribute type */
u_int8_t len; /* Attribute length */
@@ -495,7 +519,6 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
}
else
{
- data++;
data_value = EXTRACT_32BITS(data);
}
if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 +
@@ -638,7 +661,7 @@ static void print_attr_time(register u_char *data, u_int length, u_short attr_co
TCHECK2(data[0],4);
attr_time = EXTRACT_32BITS(data);
- strcpy(string, ctime(&attr_time));
+ strlcpy(string, ctime(&attr_time), sizeof(string));
/* Get rid of the newline */
string[24] = '\0';
printf("{%.24s}", string);
@@ -730,7 +753,7 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
static void
-radius_attr_print(register u_char *attr, u_int length)
+radius_attr_print(register const u_char *attr, u_int length)
{
register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
@@ -743,6 +766,11 @@ radius_attr_print(register u_char *attr, u_int length)
printf(" Attr[ ");
while (length > 0)
{
+ if (rad_attr->len == 0)
+ {
+ printf("(zero-length attribute)");
+ return;
+ }
if ( rad_attr->len <= length )
{
if ( !rad_attr->type || (rad_attr->type > (TAM_SIZE(attr_type)-1)) )
@@ -778,17 +806,30 @@ radius_print(const u_char *dat, u_int length)
{
register const struct radius_hdr *rad;
register int i;
+ int len;
- i = min(length, snapend - dat) - sizeof(*rad);
+ i = min(length, snapend - dat);
- if (i < 0)
+ if (i < MIN_RADIUS_LEN)
{
printf(" [|radius]");
return;
}
rad = (struct radius_hdr *)dat;
-
+ len = ntohs(rad->len);
+
+ if (len < MIN_RADIUS_LEN)
+ {
+ printf(" [|radius]");
+ return;
+ }
+
+ if (len < i)
+ i = len;
+
+ i -= MIN_RADIUS_LEN;
+
switch (rad->code)
{
case RADCMD_ACCESS_REQ:
@@ -834,5 +875,5 @@ radius_print(const u_char *dat, u_int length)
printf(" [id %d]", rad->id);
if (i)
- radius_attr_print( ((u_char *)(rad+1)), i);
+ radius_attr_print( dat + MIN_RADIUS_LEN, i);
}
diff --git a/contrib/tcpdump/print-raw.c b/contrib/tcpdump/print-raw.c
index b6e421c2ceeb..f6ffc411be2a 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.33 2000/10/06 04:23:13 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.34 2001/07/05 18:54:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -53,6 +53,7 @@ raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_int length = h->len;
u_int caplen = h->caplen;
+ ++infodelay;
ts_print(&h->ts);
/*
@@ -71,4 +72,7 @@ raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (xflag)
default_print(p, caplen);
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
}
diff --git a/contrib/tcpdump/print-rip.c b/contrib/tcpdump/print-rip.c
index 1f02c233a2eb..bb3d53aa4509 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.47 2000/10/03 04:19:07 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.49 2001/05/10 05:30:22 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -181,7 +181,7 @@ rip_print(const u_char *dat, u_int length)
*
* 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,
@@ -215,7 +215,7 @@ rip_print(const u_char *dat, u_int length)
case RIPCMD_TRACEON:
printf(" RIPv%d-traceon %d: \"", rp->rip_vers, length);
(void)fn_print((const u_char *)(rp + 1), snapend);
- fputs("\"\n", stdout);
+ fputs("\"", stdout);
break;
case RIPCMD_TRACEOFF:
printf(" RIPv%d-traceoff %d", rp->rip_vers, length);
@@ -231,5 +231,5 @@ rip_print(const u_char *dat, u_int length)
length);
break;
}
- }
+ }
}
diff --git a/contrib/tcpdump/print-ripng.c b/contrib/tcpdump/print-ripng.c
index e4d11a464cac..ad6d3f8db3b0 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.7 2000/10/07 05:46:21 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.10 2001/11/16 08:59:22 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -57,7 +57,7 @@ rip6_entry_print(register const struct netinfo6 *ni, int metric)
}
void
-ripng_print(const u_char *dat, int length)
+ripng_print(const u_char *dat, unsigned int length)
{
register const struct rip6 *rp = (struct rip6 *)dat;
register const struct netinfo6 *ni;
@@ -81,12 +81,12 @@ ripng_print(const u_char *dat, int length)
break;
}
if (j * sizeof(*ni) != length - 4)
- printf(" ripng-req %d[%d]:", j, length);
+ printf(" ripng-req %d[%u]:", j, length);
else
printf(" ripng-req %d:", j);
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
- if (vflag)
+ if (vflag > 1)
printf("\n\t");
else
printf(" ");
@@ -96,22 +96,22 @@ ripng_print(const u_char *dat, int length)
case RIP6_RESPONSE:
j = length / sizeof(*ni);
if (j * sizeof(*ni) != length - 4)
- printf(" ripng-resp %d[%d]:", j, length);
+ printf(" ripng-resp %d[%u]:", j, length);
else
printf(" ripng-resp %d:", j);
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
- if (vflag)
+ if (vflag > 1)
printf("\n\t");
else
printf(" ");
rip6_entry_print(ni, ni->rip6_metric);
}
if (trunc)
- printf("[|rip]");
+ printf("[|ripng]");
break;
default:
- printf(" ripng-%d ?? %d", rp->rip6_cmd, length);
+ printf(" ripng-%d ?? %u", rp->rip6_cmd, length);
break;
}
if (rp->rip6_vers != RIP6_VERSION)
diff --git a/contrib/tcpdump/print-rt6.c b/contrib/tcpdump/print-rt6.c
index ea464e2a8d79..dc5f0f397f46 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.17 2000/12/13 07:57:05 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.18 2001/06/15 22:17:34 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -62,12 +62,6 @@ rt6_print(register const u_char *bp, register const u_char *bp2)
/* 'ep' points to the end of available data. */
ep = snapend;
-#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); /*)*/
diff --git a/contrib/tcpdump/print-rx.c b/contrib/tcpdump/print-rx.c
index af3cf1bc5e4e..530965d704f4 100644
--- a/contrib/tcpdump/print-rx.c
+++ b/contrib/tcpdump/print-rx.c
@@ -1,4 +1,26 @@
/*
+ * Copyright: (c) 2000 United States Government as represented by the
+ * Secretary of the Navy. 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 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.
+ */
+/*
* This code unmangles RX packets. RX is the mutant form of RPC that AFS
* uses to communicate between clients and servers.
*
@@ -8,12 +30,11 @@
* Bah. If I never look at rx_packet.h again, it will be too soon.
*
* Ken Hornstein <kenh@cmf.nrl.navy.mil>
- *
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.20.2.1 2001/07/09 01:40:59 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.27 2001/10/20 07:41:55 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,9 +56,6 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "extract.h"
-#undef NOERROR /* Solaris sucks */
-#include <arpa/nameser.h>
-
#include "rx.h"
#include "ip.h"
@@ -56,12 +74,18 @@ static struct tok rx_types[] = {
{ 0, NULL },
};
-static struct tok rx_flags[] = {
- { RX_CLIENT_INITIATED, "client-init" },
- { RX_REQUEST_ACK, "req-ack" },
- { RX_LAST_PACKET, "last-pckt" },
- { RX_MORE_PACKETS, "more-pckts" },
- { RX_FREE_PACKET, "free-pckt" }
+static struct double_tok {
+ int flag; /* Rx flag */
+ int packetType; /* Packet type */
+ char *s; /* Flag string */
+} rx_flags[] = {
+ { RX_CLIENT_INITIATED, 0, "client-init" },
+ { RX_REQUEST_ACK, 0, "req-ack" },
+ { RX_LAST_PACKET, 0, "last-pckt" },
+ { RX_MORE_PACKETS, 0, "more-pckts" },
+ { RX_FREE_PACKET, 0, "free-pckt" },
+ { RX_SLOW_START_OK, RX_PACKET_TYPE_ACK, "slow-start" },
+ { RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" }
};
static struct tok fs_req[] = {
@@ -99,6 +123,7 @@ static struct tok fs_req[] = {
{ 161, "dfs-lookup" },
{ 162, "dfs-flushcps" },
{ 163, "dfs-symlink" },
+ { 220, "residency" },
{ 0, NULL },
};
@@ -114,6 +139,10 @@ static struct tok cb_req[] = {
{ 212, "whoareyou" },
{ 213, "initcb3" },
{ 214, "probeuuid" },
+ { 215, "getsrvprefs" },
+ { 216, "getcellservdb" },
+ { 217, "getlocalcell" },
+ { 218, "getcacheconf" },
{ 0, NULL },
};
@@ -139,6 +168,7 @@ static struct tok pt_req[] = {
{ 518, "get-cps2" },
{ 519, "get-host-cps" },
{ 520, "update-entry" },
+ { 521, "list-entries" },
{ 0, NULL },
};
@@ -176,6 +206,7 @@ static struct tok vldb_req[] = {
{ 531, "linked-list-u" },
{ 532, "regaddr" },
{ 533, "get-addrs-u" },
+ { 534, "list-attrib-n2" },
{ 0, NULL },
};
@@ -270,6 +301,8 @@ static struct tok bos_req[] = {
{ 112, "start-bozo-log" },
{ 113, "wait-all" },
{ 114, "get-instance-strings" },
+ { 115, "get-restricted" },
+ { 116, "set-restricted" },
{ 0, NULL },
};
@@ -439,7 +472,9 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
if (vflag > 1)
for (i = 0; i < NUM_RX_FLAGS; i++) {
- if (rxh->flags & rx_flags[i].v) {
+ if (rxh->flags & rx_flags[i].flag &&
+ (!rx_flags[i].packetType ||
+ rxh->type == rx_flags[i].packetType)) {
if (!firstflag) {
firstflag = 1;
printf(" ");
@@ -638,7 +673,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
#define STROUT(MAX) { unsigned int i; \
TCHECK2(bp[0], sizeof(int32_t)); \
i = EXTRACT_32BITS(bp); \
- if (i > MAX) \
+ if (i > (MAX)) \
goto trunc; \
bp += sizeof(int32_t); \
printf(" \""); \
@@ -721,14 +756,17 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*/
#define VECOUT(MAX) { char *sp; \
+ char s[AFSNAMEMAX]; \
int k; \
- TCHECK2(bp[0], MAX * sizeof(int32_t)); \
+ if ((MAX) + 1 > sizeof(s)) \
+ goto trunc; \
+ TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
sp = s; \
- for (k = 0; k < MAX; k++) { \
+ for (k = 0; k < (MAX); k++) { \
*sp++ = (char) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
} \
- s[MAX] = '\0'; \
+ s[(MAX)] = '\0'; \
printf(" \""); \
fn_print(s, NULL); \
printf("\""); \
@@ -812,7 +850,6 @@ fs_print(register const u_char *bp, int length)
{
int fs_op;
unsigned long i;
- char s[AFSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;
@@ -963,7 +1000,6 @@ static void
fs_reply_print(register const u_char *bp, int length, int32_t opcode)
{
unsigned long i;
- char s[AFSNAMEMAX];
struct rx_header *rxh;
if (length <= sizeof(struct rx_header))
@@ -1259,7 +1295,6 @@ static void
prot_print(register const u_char *bp, int length)
{
unsigned long i;
- char s[AFSNAMEMAX];
int pt_op;
if (length <= sizeof(struct rx_header))
@@ -1403,7 +1438,6 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
unsigned long i;
- char s[AFSNAMEMAX];
if (length < sizeof(struct rx_header))
return;
@@ -1516,7 +1550,6 @@ vldb_print(register const u_char *bp, int length)
{
int vldb_op;
unsigned long i;
- char s[AFSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;
@@ -1610,7 +1643,6 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
unsigned long i;
- char s[AFSNAMEMAX];
if (length < sizeof(struct rx_header))
return;
@@ -1797,7 +1829,6 @@ static void
kauth_print(register const u_char *bp, int length)
{
int kauth_op;
- char s[AFSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;
@@ -2024,7 +2055,6 @@ static void
bos_print(register const u_char *bp, int length)
{
int bos_op;
- char s[BOSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;
diff --git a/contrib/tcpdump/print-sctp.c b/contrib/tcpdump/print-sctp.c
new file mode 100644
index 000000000000..8bf45ca701a8
--- /dev/null
+++ b/contrib/tcpdump/print-sctp.c
@@ -0,0 +1,351 @@
+/* Copyright (c) 2001 NETLAB, Temple University
+ * Copyright (c) 2001 Protocol Engineering Lab, University of Delaware
+ *
+ * Jerry Heinz <gheinz@astro.temple.edu>
+ * John Fiore <jfiore@joda.cis.temple.edu>
+ * Armando L. Caro Jr. <acaro@cis.udel.edu>
+ *
+ * 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 University nor of the Laboratory 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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.7 2001/12/12 07:16:40 guy Exp $ (NETLAB/PEL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#include <unistd.h>
+#include "sctpHeader.h"
+#include "sctpConstants.h"
+#include <assert.h>
+
+#include <netinet/in.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
+void sctp_print(const u_char *bp, /* beginning of sctp packet */
+ const u_char *bp2, /* beginning of enclosing */
+ u_int sctpPacketLength) /* ip packet */
+{
+ const struct sctpHeader *sctpPktHdr;
+ const struct ip *ip;
+#ifdef INET6
+ const struct ip6_hdr *ip6;
+#endif
+ const u_char *cp;
+ void *endPacketPtr;
+ u_short sourcePort, destPort;
+ int chunkCount;
+ struct sctpChunkDesc *chunkDescPtr;
+ void *nextChunk;
+
+ sctpPktHdr = (struct sctpHeader*) bp;
+ endPacketPtr = ((u_char*)((u_char*)sctpPktHdr+sctpPacketLength));
+
+ if( (u_long) endPacketPtr > (u_long) snapend)
+ endPacketPtr = (void *) snapend;
+ ip = (struct ip *)bp2;
+#ifdef INET6
+ if (IP_V(ip) == 6)
+ ip6 = (struct ip6_hdr *)bp2;
+ else
+ ip6 = NULL;
+#endif /*INET6*/
+ cp = (u_char *)(sctpPktHdr + 1);
+ if (cp > snapend)
+ {
+ printf("[|sctp]");
+ return;
+ }
+
+ if (sctpPacketLength < sizeof(struct sctpHeader))
+ {
+ (void)printf("truncated-sctp - %ld bytes missing!",
+ (long)sctpPacketLength-sizeof(struct sctpHeader));
+ return;
+ }
+
+ /* sctpPacketLength -= sizeof(struct sctpHeader); packet length */
+ /* is now only as long as the payload */
+
+ sourcePort = ntohs(sctpPktHdr->source);
+ destPort = ntohs(sctpPktHdr->destination);
+
+#ifdef INET6
+ if (ip6) {
+ if (ip6->ip6_nxt == IPPROTO_SCTP) {
+ (void)printf("%s.%d > %s.%d: sctp",
+ ip6addr_string(&ip6->ip6_src),
+ sourcePort,
+ ip6addr_string(&ip6->ip6_dst),
+ destPort);
+ } else {
+ (void)printf("%d > %d: sctp",
+ sourcePort, destPort);
+ }
+ } else
+#endif /*INET6*/
+ {
+ if (ip->ip_p == IPPROTO_SCTP) {
+ (void)printf("%s.%d > %s.%d: sctp",
+ ipaddr_string(&ip->ip_src),
+ sourcePort,
+ ipaddr_string(&ip->ip_dst),
+ destPort);
+ } else {
+ (void)printf("%d > %d: sctp",
+ sourcePort, destPort);
+ }
+ }
+ fflush(stdout);
+
+ if (vflag < 2)
+ return;
+
+ /* cycle through all chunks, printing information on each one */
+ for (chunkCount = 0,
+ chunkDescPtr = (struct sctpChunkDesc *) ( (u_char*) sctpPktHdr +
+ sizeof(struct sctpHeader));
+ chunkDescPtr != NULL &&
+ ( (void *) ((u_char *) chunkDescPtr + sizeof(struct sctpChunkDesc))
+ <= endPacketPtr);
+
+ chunkDescPtr = (struct sctpChunkDesc *) nextChunk, chunkCount++)
+ {
+ u_short align;
+ u_char *chunkEnd;
+
+ chunkEnd = ((u_char*)chunkDescPtr + ntohs(chunkDescPtr->chunkLength));
+
+ align=ntohs(chunkDescPtr->chunkLength) % 4;
+ if (align != 0)
+ align = 4 - align;
+
+ nextChunk = (void *) (chunkEnd + align);
+
+ printf("\n\t%d) ", chunkCount+1);
+ switch (chunkDescPtr->chunkID)
+ {
+ case SCTP_DATA :
+ {
+ struct sctpDataPart *dataHdrPtr;
+
+ printf("[DATA] ");
+
+ if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
+ == SCTP_DATA_UNORDERED)
+ printf("(U)");
+
+ if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG)
+ == SCTP_DATA_FIRST_FRAG)
+ printf("(B)");
+
+ if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
+ == SCTP_DATA_LAST_FRAG)
+ printf("(E)");
+
+ if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
+ == SCTP_DATA_UNORDERED)
+ ||
+ ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG)
+ == SCTP_DATA_FIRST_FRAG)
+ ||
+ ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
+ == SCTP_DATA_LAST_FRAG) )
+ printf(" ");
+
+ dataHdrPtr=(struct sctpDataPart*)(chunkDescPtr+1);
+
+ printf("[TSN: %u] ", (u_int32_t)ntohl(dataHdrPtr->TSN));
+ printf("[SID: %u] ", ntohs(dataHdrPtr->streamId));
+ printf("[SSEQ %u] ", ntohs(dataHdrPtr->sequence));
+ printf("[PPID 0x%x] ", (u_int32_t)ntohl(dataHdrPtr->payloadtype));
+ fflush(stdout);
+
+ if (vflag) /* if verbose output is specified */
+ { /* at the command line */
+ char *payloadPtr;
+
+ printf("[Payload");
+
+ if (!xflag && !qflag) {
+ payloadPtr = (char *) (++dataHdrPtr);
+ printf(":");
+ default_print(payloadPtr,
+ htons(chunkDescPtr->chunkLength)-1 -
+ sizeof(struct sctpDataPart)-sizeof(struct sctpChunkDesc));
+ } else
+ printf("]");
+ }
+ break;
+ }
+ case SCTP_INITIATION :
+ {
+ struct sctpInitiation *init;
+
+ printf("[INIT] ");
+ init=(struct sctpInitiation*)(chunkDescPtr+1);
+ printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag));
+ printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit));
+ printf("[OS: %u] ", ntohs(init->NumPreopenStreams));
+ printf("[MIS: %u] ", ntohs(init->MaxInboundStreams));
+ printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN));
+
+#if(0) /* ALC you can add code for optional params here */
+ if( (init+1) < chunkEnd )
+ printf(" @@@@@ UNFINISHED @@@@@@%s\n",
+ "Optional params present, but not printed.");
+#endif
+ break;
+ }
+ case SCTP_INITIATION_ACK :
+ {
+ struct sctpInitiation *init;
+
+ printf("[INIT ACK] ");
+ init=(struct sctpInitiation*)(chunkDescPtr+1);
+ printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag));
+ printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit));
+ printf("[OS: %u] ", ntohs(init->NumPreopenStreams));
+ printf("[MIS: %u] ", ntohs(init->MaxInboundStreams));
+ printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN));
+
+#if(0) /* ALC you can add code for optional params here */
+ if( (init+1) < chunkEnd )
+ printf(" @@@@@ UNFINISHED @@@@@@%s\n",
+ "Optional params present, but not printed.");
+#endif
+ break;
+ }
+ case SCTP_SELECTIVE_ACK:
+ {
+ struct sctpSelectiveAck *sack;
+ struct sctpSelectiveFrag *frag;
+ int fragNo, tsnNo;
+ u_long *dupTSN;
+
+ printf("[SACK] ");
+ sack=(struct sctpSelectiveAck*)(chunkDescPtr+1);
+ printf("[cum ack %u] ", (u_int32_t)ntohl(sack->highestConseqTSN));
+ printf("[a_rwnd %u] ", (u_int32_t)ntohl(sack->updatedRwnd));
+ printf("[#gap acks %u] ", ntohs(sack->numberOfdesc));
+ printf("[#dup tsns %u] ", ntohs(sack->numDupTsns));
+
+
+ /* print gaps */
+ for (frag = ( (struct sctpSelectiveFrag *)
+ ((struct sctpSelectiveAck *) sack+1)),
+ fragNo=0;
+ (void *)frag < nextChunk && fragNo < ntohs(sack->numberOfdesc);
+ frag++, fragNo++)
+ printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ",
+ fragNo+1,
+ (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentStart)),
+ (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentEnd)));
+
+
+ /* print duplicate TSNs */
+ for (dupTSN = (u_long*)frag, tsnNo=0;
+ (void *) dupTSN < nextChunk && tsnNo<ntohs(sack->numDupTsns);
+ dupTSN++, tsnNo++)
+ printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
+ (u_int32_t)ntohl(*dupTSN));
+
+ break;
+ }
+ case SCTP_HEARTBEAT_REQUEST :
+ {
+ struct sctpHBsender *hb;
+
+ hb=(struct sctpHBsender*)chunkDescPtr;
+
+ printf("[HB REQ] ");
+
+ break;
+ }
+ case SCTP_HEARTBEAT_ACK :
+ printf("[HB ACK] ");
+ break;
+ case SCTP_ABORT_ASSOCIATION :
+ printf("[ABORT] ");
+ break;
+ case SCTP_SHUTDOWN :
+ printf("[SHUTDOWN] ");
+ break;
+ case SCTP_SHUTDOWN_ACK :
+ printf("[SHUTDOWN ACK] ");
+ break;
+ case SCTP_OPERATION_ERR :
+ printf("[OP ERR] ");
+ break;
+ case SCTP_COOKIE_ECHO :
+ printf("[COOKIE ECHO] ");
+ break;
+ case SCTP_COOKIE_ACK :
+ printf("[COOKIE ACK] ");
+ break;
+ case SCTP_ECN_ECHO :
+ printf("[ECN ECHO] ");
+ break;
+ case SCTP_ECN_CWR :
+ printf("[ECN CWR] ");
+ break;
+ case SCTP_SHUTDOWN_COMPLETE :
+ printf("[SHUTDOWN COMPLETE] ");
+ break;
+ case SCTP_FORWARD_CUM_TSN :
+ printf("[FOR CUM TSN] ");
+ break;
+ case SCTP_RELIABLE_CNTL :
+ printf("[REL CTRL] ");
+ break;
+ case SCTP_RELIABLE_CNTL_ACK :
+ printf("[REL CTRL ACK] ");
+ break;
+ default :
+ printf("[Unknown chunk type: 0x%x]", chunkDescPtr->chunkID);
+ return;
+ }
+ }
+}
diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c
index 8f2803a9e43c..0b284c86d2f4 100644
--- a/contrib/tcpdump/print-sll.c
+++ b/contrib/tcpdump/print-sll.c
@@ -20,7 +20,7 @@
*/
#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)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.6 2001/07/05 18:54:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -47,9 +47,6 @@ struct rtentry;
#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)
{
@@ -113,6 +110,7 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_short ether_type;
u_short extracted_ethertype;
+ ++infodelay;
ts_print(&h->ts);
if (caplen < SLL_HDR_LEN) {
@@ -200,6 +198,13 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
*/
switch (ether_type) {
+ case LINUX_SLL_P_802_3:
+ /*
+ * Ethernet_802.3 IPX frame.
+ */
+ ipx_print(p, length);
+ break;
+
case LINUX_SLL_P_802_2:
/*
* 802.2.
@@ -235,4 +240,7 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print(p, caplen);
out:
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
}
diff --git a/contrib/tcpdump/print-smb.c b/contrib/tcpdump/print-smb.c
index e5a3da544fdf..eb7df5702d99 100644
--- a/contrib/tcpdump/print-smb.c
+++ b/contrib/tcpdump/print-smb.c
@@ -1,9 +1,10 @@
-/*
- Copyright (C) Andrew Tridgell 1995-1999
-
- This software may be distributed either under the terms of the
- BSD-style license that accompanies tcpdump or the GNU GPL version 2
- or later */
+/*
+ * Copyright (C) Andrew Tridgell 1995-1999
+ *
+ * This software may be distributed either under the terms of the
+ * BSD-style license that accompanies tcpdump or the GNU GPL version 2
+ * or later
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -11,7 +12,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.7 2000/12/05 06:42:47 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.20 2002/01/17 04:38:29 guy Exp $";
#endif
#include <stdio.h>
@@ -19,1027 +20,1277 @@ static const char rcsid[] =
#include <sys/types.h>
#include "interface.h"
+#include "extract.h"
#include "smb.h"
-static int request=0;
+static int request = 0;
-const uchar *startbuf=NULL;
+const u_char *startbuf = NULL;
-struct smbdescript
-{
- char *req_f1;
- char *req_f2;
- char *rep_f1;
- char *rep_f2;
- void (*fn)(); /* sometimes (u_char *, u_char *, u_char *, u_char *)
- and sometimes (u_char *, u_char *, int, int) */
+struct smbdescript {
+ const char *req_f1;
+ const char *req_f2;
+ const char *rep_f1;
+ const char *rep_f2;
+ void (*fn)(const u_char *, const u_char *, const u_char *, const u_char *);
+};
+
+struct smbdescriptint {
+ const char *req_f1;
+ const char *req_f2;
+ const char *rep_f1;
+ const char *rep_f2;
+ void (*fn)(const u_char *, const u_char *, int, int);
};
struct smbfns
{
- int id;
- char *name;
- int flags;
- struct smbdescript descript;
+ int id;
+ const char *name;
+ int flags;
+ struct smbdescript descript;
};
-#define DEFDESCRIPT {NULL,NULL,NULL,NULL,NULL}
-
-#define FLG_CHAIN (1<<0)
-
-static struct smbfns *smbfind(int id,struct smbfns *list)
+struct smbfnsint
{
- int sindex;
-
- for (sindex=0;list[sindex].name;sindex++)
- if (list[sindex].id == id) return(&list[sindex]);
+ int id;
+ const char *name;
+ int flags;
+ struct smbdescriptint descript;
+};
- return(&list[0]);
-}
+#define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL }
-static void trans2_findfirst(uchar *param,uchar *data,int pcnt,int dcnt)
-{
- char *fmt;
-
- if (request) {
- fmt = "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP5]\nFile=[S]\n";
- } else {
- fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
- }
-
- fdata(param,fmt,param+pcnt);
- if (dcnt) {
- printf("data:\n");
- print_data(data,dcnt);
- }
-}
+#define FLG_CHAIN (1 << 0)
-static void trans2_qfsinfo(uchar *param,uchar *data,int pcnt,int dcnt)
+static struct smbfns *
+smbfind(int id, struct smbfns *list)
{
- static int level=0;
- char *fmt="";
-
- if (request) {
- level = SVAL(param,0);
- fmt = "InfoLevel=[d]\n";
- fdata(param,fmt,param+pcnt);
- } else {
- switch (level) {
- case 1:
- fmt = "idFileSystem=[W]\nSectorUnit=[D]\nUnit=[D]\nAvail=[D]\nSectorSize=[d]\n";
- break;
- case 2:
- fmt = "CreationTime=[T2]VolNameLength=[B]\nVolumeLabel=[s12]\n";
- break;
- case 0x105:
- fmt = "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[D]\nVolume=[S]\n";
- break;
- default:
- fmt = "UnknownLevel\n";
- }
- fdata(data,fmt,data+dcnt);
- }
- if (dcnt) {
- printf("data:\n");
- print_data(data,dcnt);
- }
-}
-
-struct smbfns trans2_fns[] = {
-{0,"TRANSACT2_OPEN",0,
- {"Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w,w,w,w,w])\nPath=[S]",NULL,
- "Handle=[d]\nAttrib=[A]\nTime=[T2]\nSize=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nInode=[W]\nOffErr=[d]\n|EALength=[d]\n",NULL,NULL}},
+ int sindex;
-{1,"TRANSACT2_FINDFIRST",0,
- {NULL,NULL,NULL,NULL,trans2_findfirst}},
+ for (sindex = 0; list[sindex].name; sindex++)
+ if (list[sindex].id == id)
+ return(&list[sindex]);
-{2,"TRANSACT2_FINDNEXT",0,DEFDESCRIPT},
-
-{3,"TRANSACT2_QFSINFO",0,
- {NULL,NULL,NULL,NULL,trans2_qfsinfo}},
+ return(&list[0]);
+}
-{4,"TRANSACT2_SETFSINFO",0,DEFDESCRIPT},
-{5,"TRANSACT2_QPATHINFO",0,DEFDESCRIPT},
-{6,"TRANSACT2_SETPATHINFO",0,DEFDESCRIPT},
-{7,"TRANSACT2_QFILEINFO",0,DEFDESCRIPT},
-{8,"TRANSACT2_SETFILEINFO",0,DEFDESCRIPT},
-{9,"TRANSACT2_FSCTL",0,DEFDESCRIPT},
-{10,"TRANSACT2_IOCTL",0,DEFDESCRIPT},
-{11,"TRANSACT2_FINDNOTIFYFIRST",0,DEFDESCRIPT},
-{12,"TRANSACT2_FINDNOTIFYNEXT",0,DEFDESCRIPT},
-{13,"TRANSACT2_MKDIR",0,DEFDESCRIPT},
-{-1,NULL,0,DEFDESCRIPT}};
+static struct smbfnsint *
+smbfindint(int id, struct smbfnsint *list)
+{
+ int sindex;
+ for (sindex = 0; list[sindex].name; sindex++)
+ if (list[sindex].id == id)
+ return(&list[sindex]);
-static void print_trans2(uchar *words,uchar *dat,uchar *buf,uchar *maxbuf)
-{
- static struct smbfns *fn = &trans2_fns[0];
- uchar *data,*param;
- uchar *f1=NULL,*f2=NULL;
- int pcnt,dcnt;
-
- if (request) {
- fn = smbfind(SVAL(words+1,14*2),trans2_fns);
- data = buf+SVAL(words+1,12*2);
- param = buf+SVAL(words+1,10*2);
- pcnt = SVAL(words+1,9*2);
- dcnt = SVAL(words+1,11*2);
- } else {
- data = buf+SVAL(words+1,7*2);
- param = buf+SVAL(words+1,4*2);
- pcnt = SVAL(words+1,3*2);
- dcnt = SVAL(words+1,6*2);
- }
-
- printf("%s param_length=%d data_length=%d\n",
- fn->name,pcnt,dcnt);
-
- if (request) {
- if (CVAL(words,0) == 8) {
- fdata(words+1,"Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",maxbuf);
- return;
- } else {
- fdata(words+1,"TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[d]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[d]\n",words+1+14*2);
- fdata(data+1,"TransactionName=[S]\n%",maxbuf);
- }
- f1 = fn->descript.req_f1;
- f2 = fn->descript.req_f2;
- } else {
- if (CVAL(words,0) == 0) {
- printf("Trans2Interim\n");
- return;
- } else {
- fdata(words+1,"TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[d]\n",words+1+10*2);
- }
- f1 = fn->descript.rep_f1;
- f2 = fn->descript.rep_f2;
- }
-
- if (fn->descript.fn) {
- fn->descript.fn(param,data,pcnt,dcnt);
- } else {
- fdata(param,f1?f1:(uchar*)"Paramaters=\n",param+pcnt);
- fdata(data,f2?f2:(uchar*)"Data=\n",data+dcnt);
- }
+ return(&list[0]);
}
-
-static void print_browse(uchar *param,int paramlen,const uchar *data,int datalen)
+static void
+trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt)
{
- const uchar *maxbuf = data + datalen;
- int command = CVAL(data,0);
-
- fdata(param,"BROWSE PACKET\n|Param ",param+paramlen);
-
- switch (command) {
- case 0xF:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",maxbuf);
- break;
-
- case 0x1:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",maxbuf);
- break;
-
- case 0x2:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",maxbuf);
- break;
-
- case 0xc:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",maxbuf);
- break;
-
- case 0x8:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W,W)]\nServerName=[S]\n",maxbuf);
- break;
-
- case 0xb:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",maxbuf);
- break;
-
- case 0x9:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken?=[B]\n",maxbuf);
- break;
-
- case 0xa:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken?=[B]*Name=[S]\n",maxbuf);
- break;
-
- case 0xd:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",maxbuf);
- break;
-
- case 0xe:
- data = fdata(data,"BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n",maxbuf);
- break;
-
- default:
- data = fdata(data,"Unknown Browser Frame ",maxbuf);
- break;
- }
-}
+ const char *fmt;
+ if (request)
+ fmt = "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP5]\nFile=[S]\n";
+ else
+ fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
-static void print_ipc(uchar *param,int paramlen,uchar *data,int datalen)
-{
- if (paramlen)
- fdata(param,"Command=[w]\nStr1=[S]\nStr2=[S]\n",param+paramlen);
- if (datalen)
- fdata(data,"IPC ",data+datalen);
+ smb_fdata(param, fmt, param + pcnt);
+ if (dcnt) {
+ printf("data:\n");
+ print_data(data, dcnt);
+ }
}
-
-static void print_trans(uchar *words,uchar *data1,uchar *buf,uchar *maxbuf)
+static void
+trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt)
{
- uchar *f1,*f2,*f3,*f4;
- uchar *data,*param;
- int datalen,paramlen;
-
- if (request) {
- paramlen = SVAL(words+1,9*2);
- param = buf + SVAL(words+1,10*2);
- datalen = SVAL(words+1,11*2);
- data = buf + SVAL(words+1,12*2);
- f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n";
- f2 = "|Name=[S]\n";
- f3 = "|Param ";
- f4 = "|Data ";
- } else {
- paramlen = SVAL(words+1,3*2);
- param = buf + SVAL(words+1,4*2);
- datalen = SVAL(words+1,6*2);
- data = buf + SVAL(words+1,7*2);
- f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n";
- f2 = "|Unknown ";
- f3 = "|Param ";
- f4 = "|Data ";
- }
-
- fdata(words+1,f1,MIN(words+1+2*CVAL(words,0),maxbuf));
- fdata(data1+2,f2,maxbuf - (paramlen + datalen));
-
- if (!strcmp(data1+2,"\\MAILSLOT\\BROWSE")) {
- print_browse(param,paramlen,data,datalen);
+ static int level = 0;
+ const char *fmt="";
+
+ if (request) {
+ TCHECK2(*param, 2);
+ level = EXTRACT_LE_16BITS(param);
+ fmt = "InfoLevel=[d]\n";
+ smb_fdata(param, fmt, param + pcnt);
+ } else {
+ switch (level) {
+ case 1:
+ fmt = "idFileSystem=[W]\nSectorUnit=[D]\nUnit=[D]\nAvail=[D]\nSectorSize=[d]\n";
+ break;
+ case 2:
+ fmt = "CreationTime=[T2]VolNameLength=[B]\nVolumeLabel=[s12]\n";
+ break;
+ case 0x105:
+ fmt = "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[D]\nVolume=[S]\n";
+ break;
+ default:
+ fmt = "UnknownLevel\n";
+ break;
+ }
+ smb_fdata(data, fmt, data + dcnt);
+ }
+ if (dcnt) {
+ printf("data:\n");
+ print_data(data, dcnt);
+ }
return;
- }
-
- if (!strcmp(data1+2,"\\PIPE\\LANMAN")) {
- print_ipc(param,paramlen,data,datalen);
+trunc:
+ printf("[|SMB]");
return;
- }
-
- if (paramlen) fdata(param,f3,MIN(param+paramlen,maxbuf));
- if (datalen) fdata(data,f4,MIN(data+datalen,maxbuf));
}
+struct smbfnsint trans2_fns[] = {
+ { 0, "TRANSACT2_OPEN", 0,
+ { "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]",
+ NULL,
+ "Handle=[d]\nAttrib=[A]\nTime=[T2]\nSize=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nInode=[W]\nOffErr=[d]\n|EALength=[d]\n",
+ NULL, NULL }},
+ { 1, "TRANSACT2_FINDFIRST", 0,
+ { NULL, NULL, NULL, NULL, trans2_findfirst }},
+ { 2, "TRANSACT2_FINDNEXT", 0, DEFDESCRIPT },
+ { 3, "TRANSACT2_QFSINFO", 0,
+ { NULL, NULL, NULL, NULL, trans2_qfsinfo }},
+ { 4, "TRANSACT2_SETFSINFO", 0, DEFDESCRIPT },
+ { 5, "TRANSACT2_QPATHINFO", 0, DEFDESCRIPT },
+ { 6, "TRANSACT2_SETPATHINFO", 0, DEFDESCRIPT },
+ { 7, "TRANSACT2_QFILEINFO", 0, DEFDESCRIPT },
+ { 8, "TRANSACT2_SETFILEINFO", 0, DEFDESCRIPT },
+ { 9, "TRANSACT2_FSCTL", 0, DEFDESCRIPT },
+ { 10, "TRANSACT2_IOCTL", 0, DEFDESCRIPT },
+ { 11, "TRANSACT2_FINDNOTIFYFIRST", 0, DEFDESCRIPT },
+ { 12, "TRANSACT2_FINDNOTIFYNEXT", 0, DEFDESCRIPT },
+ { 13, "TRANSACT2_MKDIR", 0, DEFDESCRIPT },
+ { -1, NULL, 0, DEFDESCRIPT }
+};
-static void print_negprot(uchar *words,uchar *data,uchar *buf,uchar *maxbuf)
+static void
+print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
{
- uchar *f1=NULL,*f2=NULL;
-
- if (request) {
- f2 = "*|Dialect=[Z]\n";
- } else {
- if (CVAL(words,0) == 1) {
- f1 = "Core Protocol\nDialectIndex=[d]";
- } else if (CVAL(words,0) == 17) {
- f1 = "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey=";
- } else if (CVAL(words,0) == 13) {
- f1 = "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[d]\nSecMode=[w]\nMaxXMit=[d]\nMaxMux=[d]\nMaxVcs=[d]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[d]\nRes=[W]\nCryptKey=";
+ static struct smbfnsint *fn = &trans2_fns[0];
+ const u_char *data, *param;
+ const u_char *w = words + 1;
+ const u_char *f1 = NULL, *f2 = NULL;
+ int pcnt, dcnt;
+
+ TCHECK(words[0]);
+ if (request) {
+ TCHECK2(w[14 * 2], 2);
+ pcnt = EXTRACT_LE_16BITS(w + 9 * 2);
+ param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
+ dcnt = EXTRACT_LE_16BITS(w + 11 * 2);
+ data = buf + EXTRACT_LE_16BITS(w + 12 * 2);
+ fn = smbfindint(EXTRACT_LE_16BITS(w + 14 * 2), trans2_fns);
+ } else {
+ if (words[0] == 0) {
+ printf("%s\n", fn->name);
+ printf("Trans2Interim\n");
+ return;
+ }
+ TCHECK2(w[7 * 2], 2);
+ pcnt = EXTRACT_LE_16BITS(w + 3 * 2);
+ param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
+ dcnt = EXTRACT_LE_16BITS(w + 6 * 2);
+ data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
}
- }
-
- if (f1)
- fdata(words+1,f1,MIN(words + 1 + CVAL(words,0)*2,maxbuf));
- else
- print_data(words+1,MIN(CVAL(words,0)*2,PTR_DIFF(maxbuf,words+1)));
-
- if (f2)
- fdata(data+2,f2,MIN(data + 2 + SVAL(data,0),maxbuf));
- else
- print_data(data+2,MIN(SVAL(data,0),PTR_DIFF(maxbuf,data+2)));
-
-}
-static void print_sesssetup(uchar *words,uchar *data,uchar *buf,uchar *maxbuf)
-{
- int wcnt = CVAL(words,0);
- uchar *f1=NULL,*f2=NULL;
+ printf("%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt);
- if (request) {
- if (wcnt==10) {
- f1 = "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n";
+ if (request) {
+ if (words[0] == 8) {
+ smb_fdata(words + 1,
+ "Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",
+ maxbuf);
+ return;
+ } else {
+ smb_fdata(words + 1,
+ "TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[d]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[d]\n",
+ words + 1 + 14 * 2);
+ smb_fdata(data + 1, "TransactionName=[S]\n%", maxbuf);
+ }
+ f1 = fn->descript.req_f1;
+ f2 = fn->descript.req_f2;
} else {
- f1 = "Com2=[B]\nRes1=[B]\nOff2=[d]\nMaxBuffer=[d]\nMaxMpx=[d]\nVcNumber=[d]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[d]\nCaseSensitivePasswordLength=[d]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n";
+ smb_fdata(words + 1,
+ "TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[d]\n",
+ words + 1 + 10 * 2);
+ f1 = fn->descript.rep_f1;
+ f2 = fn->descript.rep_f2;
}
- } else {
- if (CVAL(words,0) == 3) {
- f1 = "Com2=[w]\nOff2=[d]\nAction=[w]\n";
- } else if (CVAL(words,0) == 13) {
- f1 = "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n";
- f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n";
+
+ if (fn->descript.fn)
+ (*fn->descript.fn)(param, data, pcnt, dcnt);
+ else {
+ smb_fdata(param, f1 ? f1 : (u_char *)"Paramaters=\n", param + pcnt);
+ smb_fdata(data, f2 ? f2 : (u_char *)"Data=\n", data + dcnt);
}
- }
-
- if (f1)
- fdata(words+1,f1,MIN(words + 1 + CVAL(words,0)*2,maxbuf));
- else
- print_data(words+1,MIN(CVAL(words,0)*2,PTR_DIFF(maxbuf,words+1)));
-
- if (f2)
- fdata(data+2,f2,MIN(data + 2 + SVAL(data,0),maxbuf));
- else
- print_data(data+2,MIN(SVAL(data,0),PTR_DIFF(maxbuf,data+2)));
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
}
-static struct smbfns smb_fns[] =
+static void
+print_browse(const u_char *param, int paramlen, const u_char *data, int datalen)
{
-{-1,"SMBunknown",0,DEFDESCRIPT},
+ const u_char *maxbuf = data + datalen;
+ int command;
-{SMBtcon,"SMBtcon",0,
- {NULL,"Path=[Z]\nPassword=[Z]\nDevice=[Z]\n",
- "MaxXmit=[d]\nTreeId=[d]\n",NULL,
- NULL}},
+ TCHECK(data[0]);
+ command = data[0];
+ smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen);
-{SMBtdis,"SMBtdis",0,DEFDESCRIPT},
-{SMBexit,"SMBexit",0,DEFDESCRIPT},
-{SMBioctl,"SMBioctl",0,DEFDESCRIPT},
+ switch (command) {
+ case 0xF:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
+ maxbuf);
+ break;
-{SMBecho,"SMBecho",0,
- {"ReverbCount=[d]\n",NULL,
- "SequenceNum=[d]\n",NULL,
- NULL}},
+ case 0x1:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
+ maxbuf);
+ break;
-{SMBulogoffX, "SMBulogoffX",FLG_CHAIN,DEFDESCRIPT},
+ case 0x2:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
+ maxbuf);
+ break;
-{SMBgetatr,"SMBgetatr",0,
- {NULL,"Path=[Z]\n",
- "Attribute=[A]\nTime=[T2]Size=[D]\nRes=([w,w,w,w,w])\n",NULL,
- NULL}},
+ case 0xc:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",
+ maxbuf);
+ break;
-{SMBsetatr,"SMBsetatr",0,
- {"Attribute=[A]\nTime=[T2]Res=([w,w,w,w,w])\n","Path=[Z]\n",
- NULL,NULL,NULL}},
+ case 0x8:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
+ maxbuf);
+ break;
-{SMBchkpth,"SMBchkpth",0,
- {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
+ case 0xb:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
+ maxbuf);
+ break;
-{SMBsearch,"SMBsearch",0,
-{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\n",
-"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+ case 0x9:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken?=[B]\n",
+ maxbuf);
+ break;
+ case 0xa:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken?=[B]*Name=[S]\n",
+ maxbuf);
+ break;
-{SMBopen,"SMBopen",0,
- {"Mode=[w]\nAttribute=[A]\n","Path=[Z]\n",
- "Handle=[d]\nOAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\n",NULL,
- NULL}},
+ case 0xd:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
+ maxbuf);
+ break;
-{SMBcreate,"SMBcreate",0,
- {"Attrib=[A]\nTime=[T2]","Path=[Z]\n",
- "Handle=[d]\n",NULL,
- NULL}},
+ case 0xe:
+ data = smb_fdata(data,
+ "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf);
+ break;
-{SMBmknew,"SMBmknew",0,
- {"Attrib=[A]\nTime=[T2]","Path=[Z]\n",
- "Handle=[d]\n",NULL,
- NULL}},
+ default:
+ data = smb_fdata(data, "Unknown Browser Frame ", maxbuf);
+ break;
+ }
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
+}
-{SMBunlink,"SMBunlink",0,
- {"Attrib=[A]\n","Path=[Z]\n",NULL,NULL,NULL}},
-{SMBread,"SMBread",0,
- {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
- "Count=[d]\nRes=([w,w,w,w])\n",NULL,NULL}},
+static void
+print_ipc(const u_char *param, int paramlen, const u_char *data, int datalen)
+{
+ if (paramlen)
+ smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen);
+ if (datalen)
+ smb_fdata(data, "IPC ", data + datalen);
+}
-{SMBwrite,"SMBwrite",0,
- {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
- "Count=[d]\n",NULL,NULL}},
-{SMBclose,"SMBclose",0,
- {"Handle=[d]\nTime=[T2]",NULL,NULL,NULL,NULL}},
+static void
+print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
+{
+ const u_char *f1, *f2, *f3, *f4;
+ const u_char *data, *param;
+ const u_char *w = words + 1;
+ int datalen, paramlen;
+
+ if (request) {
+ TCHECK2(w[12 * 2], 2);
+ paramlen = EXTRACT_LE_16BITS(w + 9 * 2);
+ param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
+ datalen = EXTRACT_LE_16BITS(w + 11 * 2);
+ data = buf + EXTRACT_LE_16BITS(w + 12 * 2);
+ f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n";
+ f2 = "|Name=[S]\n";
+ f3 = "|Param ";
+ f4 = "|Data ";
+ } else {
+ TCHECK2(w[7 * 2], 2);
+ paramlen = EXTRACT_LE_16BITS(w + 3 * 2);
+ param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
+ datalen = EXTRACT_LE_16BITS(w + 6 * 2);
+ data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
+ f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n";
+ f2 = "|Unknown ";
+ f3 = "|Param ";
+ f4 = "|Data ";
+ }
-{SMBmkdir,"SMBmkdir",0,
- {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
+ smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf));
+ smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen));
-{SMBrmdir,"SMBrmdir",0,
- {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
+ if (!strcmp(data1 + 2, "\\MAILSLOT\\BROWSE")) {
+ print_browse(param, paramlen, data, datalen);
+ return;
+ }
-{SMBdskattr,"SMBdskattr",0,
-{NULL,NULL,
-"TotalUnits=[d]\nBlocksPerUnit=[d]\nBlockSize=[d]\nFreeUnits=[d]\nMedia=[w]\n",
-NULL,NULL}},
+ if (!strcmp(data1 + 2, "\\PIPE\\LANMAN")) {
+ print_ipc(param, paramlen, data, datalen);
+ return;
+ }
-{SMBmv,"SMBmv",0,
- {"Attrib=[A]\n","OldPath=[Z]\nNewPath=[Z]\n",NULL,NULL,NULL}},
+ if (paramlen)
+ smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf));
+ if (datalen)
+ smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf));
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
+}
-/* this is a Pathworks specific call, allowing the
- changing of the root path */
-{pSETDIR,"SMBsetdir",0,
- {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
-{SMBlseek,"SMBlseek",0,
- {"Handle=[d]\nMode=[w]\nOffset=[D]\n","Offset=[D]\n",NULL,NULL}},
+static void
+print_negprot(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf)
+{
+ u_char *f1 = NULL, *f2 = NULL;
+
+ TCHECK(words[0]);
+ if (request)
+ f2 = "*|Dialect=[Z]\n";
+ else {
+ if (words[0] == 1)
+ f1 = "Core Protocol\nDialectIndex=[d]";
+ else if (words[0] == 17)
+ f1 = "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey=";
+ else if (words[0] == 13)
+ f1 = "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[d]\nSecMode=[w]\nMaxXMit=[d]\nMaxMux=[d]\nMaxVcs=[d]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[d]\nRes=[W]\nCryptKey=";
+ }
-{SMBflush,"SMBflush",0,
- {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+ if (f1)
+ smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf));
+ else
+ print_data(words + 1, SMBMIN(words[0] * 2,
+ PTR_DIFF(maxbuf, words + 1)));
-{SMBsplopen,"SMBsplopen",0,
- {"SetupLen=[d]\nMode=[w]\n","Ident=[Z]\n","Handle=[d]\n",NULL,NULL}},
+ TCHECK2(*data, 2);
+ if (f2)
+ smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf));
+ else
+ print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
+}
-{SMBsplclose,"SMBsplclose",0,
- {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+static void
+print_sesssetup(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf)
+{
+ int wcnt;
+ u_char *f1 = NULL, *f2 = NULL;
+
+ TCHECK(words[0]);
+ wcnt = words[0];
+ if (request) {
+ if (wcnt == 10)
+ f1 = "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n";
+ else
+ f1 = "Com2=[B]\nRes1=[B]\nOff2=[d]\nMaxBuffer=[d]\nMaxMpx=[d]\nVcNumber=[d]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[d]\nCaseSensitivePasswordLength=[d]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n";
+ } else {
+ if (words[0] == 3) {
+ f1 = "Com2=[w]\nOff2=[d]\nAction=[w]\n";
+ } else if (words[0] == 13) {
+ f1 = "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n";
+ f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n";
+ }
+ }
-{SMBsplretq,"SMBsplretq",0,
- {"MaxCount=[d]\nStartIndex=[d]\n",NULL,
- "Count=[d]\nIndex=[d]\n",
- "*Time=[T2]Status=[B]\nJobID=[d]\nSize=[D]\nRes=[B]Name=[s16]\n",
- NULL}},
+ if (f1)
+ smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf));
+ else
+ print_data(words + 1, SMBMIN(words[0] * 2,
+ PTR_DIFF(maxbuf, words + 1)));
-{SMBsplwr,"SMBsplwr",0,
- {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+ TCHECK2(*data, 2);
+ if (f2)
+ smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf));
+ else
+ print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
+}
+
+
+static struct smbfns smb_fns[] = {
+ { -1, "SMBunknown", 0, DEFDESCRIPT },
+
+ { SMBtcon, "SMBtcon", 0,
+ { NULL, "Path=[Z]\nPassword=[Z]\nDevice=[Z]\n",
+ "MaxXmit=[d]\nTreeId=[d]\n", NULL,
+ NULL } },
-{SMBlock,"SMBlock",0,
- {"Handle=[d]\nCount=[D]\nOffset=[D]\n",NULL,NULL,NULL,NULL}},
+ { SMBtdis, "SMBtdis", 0, DEFDESCRIPT },
+ { SMBexit, "SMBexit", 0, DEFDESCRIPT },
+ { SMBioctl, "SMBioctl", 0, DEFDESCRIPT },
-{SMBunlock,"SMBunlock",0,
- {"Handle=[d]\nCount=[D]\nOffset=[D]\n",NULL,NULL,NULL,NULL}},
+ { SMBecho, "SMBecho", 0,
+ { "ReverbCount=[d]\n", NULL,
+ "SequenceNum=[d]\n", NULL,
+ NULL } },
-/* CORE+ PROTOCOL FOLLOWS */
+ { SMBulogoffX, "SMBulogoffX", FLG_CHAIN, DEFDESCRIPT },
-{SMBreadbraw,"SMBreadbraw",0,
-{"Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[d]\n",
- NULL,NULL,NULL,NULL}},
+ { SMBgetatr, "SMBgetatr", 0,
+ { NULL, "Path=[Z]\n",
+ "Attribute=[A]\nTime=[T2]Size=[D]\nRes=([w,w,w,w,w])\n", NULL,
+ NULL } },
-{SMBwritebraw,"SMBwritebraw",0,
-{"Handle=[d]\nTotalCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\n|DataSize=[d]\nDataOff=[d]\n",
-NULL,"WriteRawAck",NULL,NULL}},
+ { SMBsetatr, "SMBsetatr", 0,
+ { "Attribute=[A]\nTime=[T2]Res=([w,w,w,w,w])\n", "Path=[Z]\n",
+ NULL, NULL, NULL } },
-{SMBwritec,"SMBwritec",0,
- {NULL,NULL,"Count=[d]\n",NULL,NULL}},
+ { SMBchkpth, "SMBchkpth", 0,
+ { NULL, "Path=[Z]\n", NULL, NULL, NULL } },
-{SMBwriteclose,"SMBwriteclose",0,
- {"Handle=[d]\nCount=[d]\nOffset=[D]\nTime=[T2]Res=([w,w,w,w,w,w])",NULL,
- "Count=[d]\n",NULL,NULL}},
+ { SMBsearch, "SMBsearch", 0,
+ { "Count=[d]\nAttrib=[A]\n",
+ "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\n",
+ "Count=[d]\n",
+ "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
+ NULL } },
-{SMBlockread,"SMBlockread",0,
- {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
- "Count=[d]\nRes=([w,w,w,w])\n",NULL,NULL}},
+ { SMBopen, "SMBopen", 0,
+ { "Mode=[w]\nAttribute=[A]\n", "Path=[Z]\n",
+ "Handle=[d]\nOAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\n",
+ NULL, NULL } },
-{SMBwriteunlock,"SMBwriteunlock",0,
- {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
- "Count=[d]\n",NULL,NULL}},
+ { SMBcreate, "SMBcreate", 0,
+ { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL, NULL } },
-{SMBreadBmpx,"SMBreadBmpx",0,
-{"Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[w]\n",
-NULL,
-"Offset=[D]\nTotCount=[d]\nRemaining=[d]\nRes=([w,w])\nDataSize=[d]\nDataOff=[d]\n",
-NULL,NULL}},
+ { SMBmknew, "SMBmknew", 0,
+ { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL, NULL } },
-{SMBwriteBmpx,"SMBwriteBmpx",0,
-{"Handle=[d]\nTotCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\nDataSize=[d]\nDataOff=[d]\n",NULL,
-"Remaining=[d]\n",NULL,NULL}},
+ { SMBunlink, "SMBunlink", 0,
+ { "Attrib=[A]\n", "Path=[Z]\n", NULL, NULL, NULL } },
-{SMBwriteBs,"SMBwriteBs",0,
- {"Handle=[d]\nTotCount=[d]\nOffset=[D]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\n",NULL,
- "Count=[d]\n",NULL,NULL}},
+ { SMBread, "SMBread", 0,
+ { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL,
+ "Count=[d]\nRes=([w,w,w,w])\n", NULL, NULL } },
-{SMBsetattrE,"SMBsetattrE",0,
- {"Handle=[d]\nCreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]",NULL,
- NULL,NULL,NULL}},
+ { SMBwrite, "SMBwrite", 0,
+ { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL,
+ "Count=[d]\n", NULL, NULL } },
-{SMBgetattrE,"SMBgetattrE",0,
-{"Handle=[d]\n",NULL,
- "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D]\nAllocSize=[D]\nAttribute=[A]\n",NULL,NULL}},
+ { SMBclose, "SMBclose", 0,
+ { "Handle=[d]\nTime=[T2]", NULL, NULL, NULL, NULL } },
-{SMBtranss,"SMBtranss",0,DEFDESCRIPT},
-{SMBioctls,"SMBioctls",0,DEFDESCRIPT},
+ { SMBmkdir, "SMBmkdir", 0,
+ { NULL, "Path=[Z]\n", NULL, NULL, NULL } },
-{SMBcopy,"SMBcopy",0,
- {"TreeID2=[d]\nOFun=[w]\nFlags=[w]\n","Path=[S]\nNewPath=[S]\n",
- "CopyCount=[d]\n","|ErrStr=[S]\n",NULL}},
+ { SMBrmdir, "SMBrmdir", 0,
+ { NULL, "Path=[Z]\n", NULL, NULL, NULL } },
-{SMBmove,"SMBmove",0,
- {"TreeID2=[d]\nOFun=[w]\nFlags=[w]\n","Path=[S]\nNewPath=[S]\n",
- "MoveCount=[d]\n","|ErrStr=[S]\n",NULL}},
+ { SMBdskattr, "SMBdskattr", 0,
+ { NULL, NULL,
+ "TotalUnits=[d]\nBlocksPerUnit=[d]\nBlockSize=[d]\nFreeUnits=[d]\nMedia=[w]\n",
+ NULL, NULL } },
-{SMBopenX,"SMBopenX",FLG_CHAIN,
-{"Com2=[w]\nOff2=[d]\nFlags=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]OFun=[w]\nSize=[D]\nTimeOut=[D]\nRes=[W]\n","Path=[S]\n",
-"Com2=[w]\nOff2=[d]\nHandle=[d]\nAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nFileID=[W]\nRes=[w]\n",NULL,NULL}},
+ { SMBmv, "SMBmv", 0,
+ { "Attrib=[A]\n", "OldPath=[Z]\nNewPath=[Z]\n", NULL, NULL, NULL } },
-{SMBreadX,"SMBreadX",FLG_CHAIN,
-{"Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nCountLeft=[d]\n",NULL,
-"Com2=[w]\nOff2=[d]\nRemaining=[d]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\nRes=([w,w,w,w])\n",NULL,NULL}},
+ /*
+ * this is a Pathworks specific call, allowing the
+ * changing of the root path
+ */
+ { pSETDIR, "SMBsetdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } },
-{SMBwriteX,"SMBwriteX",FLG_CHAIN,
-{"Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nCountLeft=[d]\nRes=[w]\nDataSize=[d]\nDataOff=[d]\n",NULL,
-"Com2=[w]\nOff2=[d]\nCount=[d]\nRemaining=[d]\nRes=[W]\n",NULL,NULL}},
+ { SMBlseek, "SMBlseek", 0,
+ { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL } },
-{SMBlockingX,"SMBlockingX",FLG_CHAIN,
-{"Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n",
-"*Process=[d]\nOffset=[D]\nLength=[D]\n",
-"Com2=[w]\nOff2=[d]\n"}},
+ { SMBflush, "SMBflush", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } },
-{SMBffirst,"SMBffirst",0,
-{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
-"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+ { SMBsplopen, "SMBsplopen", 0,
+ { "SetupLen=[d]\nMode=[w]\n", "Ident=[Z]\n", "Handle=[d]\n",
+ NULL, NULL } },
-{SMBfunique,"SMBfunique",0,
-{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
-"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+ { SMBsplclose, "SMBsplclose", 0,
+ { "Handle=[d]\n", NULL, NULL, NULL, NULL } },
-{SMBfclose,"SMBfclose",0,
-{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
-"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+ { SMBsplretq, "SMBsplretq", 0,
+ { "MaxCount=[d]\nStartIndex=[d]\n", NULL,
+ "Count=[d]\nIndex=[d]\n",
+ "*Time=[T2]Status=[B]\nJobID=[d]\nSize=[D]\nRes=[B]Name=[s16]\n",
+ NULL } },
+
+ { SMBsplwr, "SMBsplwr", 0,
+ { "Handle=[d]\n", NULL, NULL, NULL, NULL } },
+
+ { SMBlock, "SMBlock", 0,
+ { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL, NULL, NULL, NULL } },
+
+ { SMBunlock, "SMBunlock", 0,
+ { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL, NULL, NULL, NULL } },
+
+ /* CORE+ PROTOCOL FOLLOWS */
+
+ { SMBreadbraw, "SMBreadbraw", 0,
+ { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[d]\n",
+ NULL, NULL, NULL, NULL } },
+
+ { SMBwritebraw, "SMBwritebraw", 0,
+ { "Handle=[d]\nTotalCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\n|DataSize=[d]\nDataOff=[d]\n",
+ NULL, "WriteRawAck", NULL, NULL } },
+
+ { SMBwritec, "SMBwritec", 0,
+ { NULL, NULL, "Count=[d]\n", NULL, NULL } },
+
+ { SMBwriteclose, "SMBwriteclose", 0,
+ { "Handle=[d]\nCount=[d]\nOffset=[D]\nTime=[T2]Res=([w,w,w,w,w,w])",
+ NULL, "Count=[d]\n", NULL, NULL } },
+
+ { SMBlockread, "SMBlockread", 0,
+ { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL,
+ "Count=[d]\nRes=([w,w,w,w])\n", NULL, NULL } },
-{SMBfindnclose, "SMBfindnclose", 0,
- {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+ { SMBwriteunlock, "SMBwriteunlock", 0,
+ { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL,
+ "Count=[d]\n", NULL, NULL } },
-{SMBfindclose, "SMBfindclose", 0,
- {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+ { SMBreadBmpx, "SMBreadBmpx", 0,
+ { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[w]\n",
+ NULL,
+ "Offset=[D]\nTotCount=[d]\nRemaining=[d]\nRes=([w,w])\nDataSize=[d]\nDataOff=[d]\n",
+ NULL, NULL } },
-{SMBsends,"SMBsends",0,
- {NULL,"Source=[Z]\nDest=[Z]\n",NULL,NULL,NULL}},
+ { SMBwriteBmpx, "SMBwriteBmpx", 0,
+ { "Handle=[d]\nTotCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\nDataSize=[d]\nDataOff=[d]\n", NULL,
+ "Remaining=[d]\n", NULL, NULL } },
-{SMBsendstrt,"SMBsendstrt",0,
- {NULL,"Source=[Z]\nDest=[Z]\n","GroupID=[d]\n",NULL,NULL}},
-
-{SMBsendend,"SMBsendend",0,
- {"GroupID=[d]\n",NULL,NULL,NULL,NULL}},
+ { SMBwriteBs, "SMBwriteBs", 0,
+ { "Handle=[d]\nTotCount=[d]\nOffset=[D]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\n",
+ NULL, "Count=[d]\n", NULL, NULL } },
-{SMBsendtxt,"SMBsendtxt",0,
- {"GroupID=[d]\n",NULL,NULL,NULL,NULL}},
+ { SMBsetattrE, "SMBsetattrE", 0,
+ { "Handle=[d]\nCreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]", NULL,
+ NULL, NULL, NULL } },
-{SMBsendb,"SMBsendb",0,
- {NULL,"Source=[Z]\nDest=[Z]\n",NULL,NULL,NULL}},
+ { SMBgetattrE, "SMBgetattrE", 0,
+ { "Handle=[d]\n", NULL,
+ "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D]\nAllocSize=[D]\nAttribute=[A]\n",
+ NULL, NULL } },
-{SMBfwdname,"SMBfwdname",0,DEFDESCRIPT},
-{SMBcancelf,"SMBcancelf",0,DEFDESCRIPT},
-{SMBgetmac,"SMBgetmac",0,DEFDESCRIPT},
+ { SMBtranss, "SMBtranss", 0, DEFDESCRIPT },
+ { SMBioctls, "SMBioctls", 0, DEFDESCRIPT },
-{SMBnegprot,"SMBnegprot",0,
- {NULL,NULL,NULL,NULL,print_negprot}},
+ { SMBcopy, "SMBcopy", 0,
+ { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n",
+ "CopyCount=[d]\n", "|ErrStr=[S]\n", NULL } },
-{SMBsesssetupX,"SMBsesssetupX",FLG_CHAIN,
- {NULL,NULL,NULL,NULL,print_sesssetup}},
+ { SMBmove, "SMBmove", 0,
+ { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n",
+ "MoveCount=[d]\n", "|ErrStr=[S]\n", NULL } },
-{SMBtconX,"SMBtconX",FLG_CHAIN,
-{"Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n",NULL,
- "Com2=[w]\nOff2=[d]\n","ServiceType=[S]\n",NULL}},
+ { SMBopenX, "SMBopenX", FLG_CHAIN,
+ { "Com2=[w]\nOff2=[d]\nFlags=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]OFun=[w]\nSize=[D]\nTimeOut=[D]\nRes=[W]\n",
+ "Path=[S]\n",
+ "Com2=[w]\nOff2=[d]\nHandle=[d]\nAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nFileID=[W]\nRes=[w]\n",
+ NULL, NULL } },
-{SMBtrans2, "SMBtrans2",0,{NULL,NULL,NULL,NULL,print_trans2}},
+ { SMBreadX, "SMBreadX", FLG_CHAIN,
+ { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nCountLeft=[d]\n",
+ NULL,
+ "Com2=[w]\nOff2=[d]\nRemaining=[d]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\nRes=([w,w,w,w])\n",
+ NULL, NULL } },
-{SMBtranss2, "SMBtranss2", 0,DEFDESCRIPT},
-{SMBctemp,"SMBctemp",0,DEFDESCRIPT},
-{SMBreadBs,"SMBreadBs",0,DEFDESCRIPT},
-{SMBtrans,"SMBtrans",0,{NULL,NULL,NULL,NULL,print_trans}},
+ { SMBwriteX, "SMBwriteX", FLG_CHAIN,
+ { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nCountLeft=[d]\nRes=[w]\nDataSize=[d]\nDataOff=[d]\n",
+ NULL,
+ "Com2=[w]\nOff2=[d]\nCount=[d]\nRemaining=[d]\nRes=[W]\n",
+ NULL, NULL } },
-{SMBnttrans,"SMBnttrans", 0, DEFDESCRIPT},
-{SMBnttranss,"SMBnttranss", 0, DEFDESCRIPT},
+ { SMBlockingX, "SMBlockingX", FLG_CHAIN,
+ { "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n",
+ "*Process=[d]\nOffset=[D]\nLength=[D]\n",
+ "Com2=[w]\nOff2=[d]\n", NULL, NULL } },
-{SMBntcreateX,"SMBntcreateX", FLG_CHAIN,
-{"Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[d]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n","Path=[S]\n",
- "Com2=[w]\nOff2=[d]\nOplockLevel=[b]\nFid=[d]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n", NULL}},
+ { SMBffirst, "SMBffirst", 0,
+ { "Count=[d]\nAttrib=[A]\n",
+ "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
+ "Count=[d]\n",
+ "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
+ NULL } },
-{SMBntcancel,"SMBntcancel", 0, DEFDESCRIPT},
+ { SMBfunique, "SMBfunique", 0,
+ { "Count=[d]\nAttrib=[A]\n",
+ "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
+ "Count=[d]\n",
+ "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
+ NULL } },
-{-1,NULL,0,DEFDESCRIPT}};
+ { SMBfclose, "SMBfclose", 0,
+ { "Count=[d]\nAttrib=[A]\n",
+ "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
+ "Count=[d]\n",
+ "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
+ NULL } },
+
+ { SMBfindnclose, "SMBfindnclose", 0,
+ { "Handle=[d]\n", NULL, NULL, NULL, NULL } },
+
+ { SMBfindclose, "SMBfindclose", 0,
+ { "Handle=[d]\n", NULL, NULL, NULL, NULL } },
+
+ { SMBsends, "SMBsends", 0,
+ { NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } },
+
+ { SMBsendstrt, "SMBsendstrt", 0,
+ { NULL, "Source=[Z]\nDest=[Z]\n", "GroupID=[d]\n", NULL, NULL } },
+
+ { SMBsendend, "SMBsendend", 0,
+ { "GroupID=[d]\n", NULL, NULL, NULL, NULL } },
+
+ { SMBsendtxt, "SMBsendtxt", 0,
+ { "GroupID=[d]\n", NULL, NULL, NULL, NULL } },
+
+ { SMBsendb, "SMBsendb", 0,
+ { NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } },
+
+ { SMBfwdname, "SMBfwdname", 0, DEFDESCRIPT },
+ { SMBcancelf, "SMBcancelf", 0, DEFDESCRIPT },
+ { SMBgetmac, "SMBgetmac", 0, DEFDESCRIPT },
+
+ { SMBnegprot, "SMBnegprot", 0,
+ { NULL, NULL, NULL, NULL, print_negprot } },
+ { SMBsesssetupX, "SMBsesssetupX", FLG_CHAIN,
+ { NULL, NULL, NULL, NULL, print_sesssetup } },
+
+ { SMBtconX, "SMBtconX", FLG_CHAIN,
+ { "Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n",
+ NULL, "Com2=[w]\nOff2=[d]\n", "ServiceType=[S]\n", NULL } },
+
+ { SMBtrans2, "SMBtrans2", 0, { NULL, NULL, NULL, NULL, print_trans2 } },
+
+ { SMBtranss2, "SMBtranss2", 0, DEFDESCRIPT },
+ { SMBctemp, "SMBctemp", 0, DEFDESCRIPT },
+ { SMBreadBs, "SMBreadBs", 0, DEFDESCRIPT },
+ { SMBtrans, "SMBtrans", 0, { NULL, NULL, NULL, NULL, print_trans } },
+
+ { SMBnttrans, "SMBnttrans", 0, DEFDESCRIPT },
+ { SMBnttranss, "SMBnttranss", 0, DEFDESCRIPT },
-/*******************************************************************
-print a SMB message
-********************************************************************/
-static void print_smb(const uchar *buf, const uchar *maxbuf)
+ { SMBntcreateX, "SMBntcreateX", FLG_CHAIN,
+ { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[d]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n",
+ "Path=[S]\n",
+ "Com2=[w]\nOff2=[d]\nOplockLevel=[b]\nFid=[d]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n",
+ NULL } },
+
+ { SMBntcancel, "SMBntcancel", 0, DEFDESCRIPT },
+
+ { -1, NULL, 0, DEFDESCRIPT }
+};
+
+
+/*
+ * print a SMB message
+ */
+static void
+print_smb(const u_char *buf, const u_char *maxbuf)
{
- int command;
- const uchar *words, *data;
- struct smbfns *fn;
- char *fmt_smbheader =
-"[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n";
+ int command;
+ const u_char *words, *data;
+ struct smbfns *fn;
+ char *fmt_smbheader =
+ "[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n";
- request = (CVAL(buf,9)&0x80)?0:1;
- command = CVAL(buf,4);
+ TCHECK(buf[9]);
+ request = (buf[9] & 0x80) ? 0 : 1;
- fn = smbfind(command,smb_fns);
+ command = buf[4];
- printf("\nSMB PACKET: %s (%s)\n",fn->name,request?"REQUEST":"REPLY");
+ fn = smbfind(command, smb_fns);
- if (vflag == 0) return;
+ if (vflag > 1)
+ printf("\n");
- /* print out the header */
- fdata(buf,fmt_smbheader,buf+33);
+ printf("SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY");
- if (CVAL(buf,5)) {
- int class = CVAL(buf,5);
- int num = SVAL(buf,7);
- printf("SMBError = %s\n",smb_errstr(class,num));
- }
+ if (vflag < 2)
+ return;
- words = buf+32;
- data = words + 1 + CVAL(words,0)*2;
+ /* print out the header */
+ smb_fdata(buf, fmt_smbheader, buf + 33);
+ if (buf[5])
+ printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7])));
- while (words && data)
- {
- char *f1,*f2;
- int wct = CVAL(words,0);
+ words = buf + 32;
+ TCHECK(words[0]);
- if (request) {
- f1 = fn->descript.req_f1;
- f2 = fn->descript.req_f2;
- } else {
- f1 = fn->descript.rep_f1;
- f2 = fn->descript.rep_f2;
- }
-
- if (fn->descript.fn) {
- fn->descript.fn(words,data,buf,maxbuf);
- } else {
- if (f1) {
- printf("smbvwv[]=\n");
- fdata(words+1,f1,words + 1 + wct*2);
- } else if (wct) {
- int i;
- int v;
- printf("smbvwv[]=\n");
- for (i=0;i<wct;i++) {
- v = SVAL(words+1,2*i);
- printf("smb_vwv[%d]=%d (0x%X)\n",i,v,v);
- }
- }
-
- if (f2) {
- printf("smbbuf[]=\n");
- fdata(data+2,f2,maxbuf);
+ for (;;) {
+ const u_char *f1, *f2;
+ int wct;
+ int bcc;
+
+ TCHECK(words[0]);
+ wct = words[0];
+ data = words + 1 + wct * 2;
+
+ if (request) {
+ f1 = fn->descript.req_f1;
+ f2 = fn->descript.req_f2;
} else {
- int bcc = SVAL(data,0);
- printf("smb_bcc=%d\n",bcc);
- if (bcc>0) {
- printf("smb_buf[]=\n");
- print_data(data + 2, MIN(bcc,PTR_DIFF(maxbuf,data+2)));
- }
+ f1 = fn->descript.rep_f1;
+ f2 = fn->descript.rep_f2;
}
- }
- if ((fn->flags & FLG_CHAIN) && CVAL(words,0) && SVAL(words,1)!=0xFF) {
- command = SVAL(words,1);
- words = buf + SVAL(words,3);
- data = words + 1 + CVAL(words,0)*2;
+ if (fn->descript.fn)
+ (*fn->descript.fn)(words, data, buf, maxbuf);
+ else {
+ if (wct) {
+ printf("smbvwv[]=\n");
+ if (f1)
+ smb_fdata(words + 1, f1, words + 1 + wct * 2);
+ else {
+ int i;
+ int v;
+
+ for (i = 0; i < wct; i++) {
+ TCHECK2(words[1 + 2 * i], 2);
+ v = EXTRACT_LE_16BITS(words + 1 + 2 * i);
+ printf("smb_vwv[%d]=%d (0x%X)\n", i, v, v);
+ }
+ }
+ }
- fn = smbfind(command,smb_fns);
+ TCHECK2(*data, 2);
+ bcc = EXTRACT_LE_16BITS(data);
+ if (f2) {
+ if (bcc > 0) {
+ printf("smbbuf[]=\n");
+ smb_fdata(data + 2, f2, data + 2 + bcc);
+ }
+ } else {
+ printf("smb_bcc=%d\n", bcc);
+ if (bcc > 0) {
+ printf("smb_buf[]=\n");
+ print_data(data + 2, SMBMIN(bcc, PTR_DIFF(maxbuf, data + 2)));
+ }
+ }
+ }
- printf("\nSMB PACKET: %s (%s) (CHAINED)\n",fn->name,request?"REQUEST":"REPLY");
- } else {
- words = data = NULL;
- }
+ if ((fn->flags & FLG_CHAIN) == 0)
+ break;
+ if (wct == 0)
+ break;
+ TCHECK(words[1]);
+ command = EXTRACT_LE_16BITS(words + 1);
+ if (command == 0xFF)
+ break;
+ TCHECK2(words[3], 2);
+ words = buf + EXTRACT_LE_16BITS(words + 3);
+
+ fn = smbfind(command, smb_fns);
+
+ printf("\nSMB PACKET: %s (%s) (CHAINED)\n",
+ fn->name, request ? "REQUEST" : "REPLY");
}
- printf("\n");
+ printf("\n");
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
}
/*
- print a NBT packet received across tcp on port 139
-*/
-void nbt_tcp_print(const uchar *data,int length)
+ * print a NBT packet received across tcp on port 139
+ */
+void
+nbt_tcp_print(const u_char *data, int length)
{
- const uchar *maxbuf = data + length;
- int flags = CVAL(data,0);
- int nbt_len = RSVAL(data,2);
+ const u_char *maxbuf = data + length;
+ int flags;
+ int nbt_len;
- startbuf = data;
- if (maxbuf <= data) return;
+ TCHECK2(data[2], 2);
+ flags = data[0];
+ nbt_len = EXTRACT_16BITS(data + 2);
- printf("\n>>> NBT Packet\n");
+ startbuf = data;
+ if (maxbuf <= data)
+ return;
- switch (flags) {
- case 1:
- 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",
- PTR_DIFF(maxbuf,data));
- print_smb(data,maxbuf>data+nbt_len?data+nbt_len:maxbuf);
- } else {
+ if (vflag > 1)
+ printf ("\n>>> ");
+
+ printf("NBT Packet");
+
+ if (vflag < 2)
+ return;
+
+ printf("\n");
+
+ switch (flags) {
+ case 1:
+ printf("flags=0x%x\n", flags);
+ case 0:
+ data = smb_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 (%lu)\n",
+ (unsigned long)PTR_DIFF(maxbuf, data));
+ print_smb(data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
+ } else
printf("Session packet:(raw data?)\n");
- }
- break;
-
- case 0x81:
- data = fdata(data,"NBT Session Request\nFlags=[rW]\nDestination=[n1]\nSource=[n1]\n",maxbuf);
- break;
-
- case 0x82:
- data = fdata(data,"NBT Session Granted\nFlags=[rW]\n",maxbuf);
- break;
-
- case 0x83:
- {
- int ecode = CVAL(data,4);
- data = fdata(data,"NBT SessionReject\nFlags=[rW]\nReason=[B]\n",maxbuf);
- switch (ecode) {
- case 0x80:
- printf("Not listening on called name\n");
- break;
- case 0x81:
- printf("Not listening for calling name\n");
- break;
- case 0x82:
- printf("Called name not present\n");
break;
- case 0x83:
- printf("Called name present, but insufficient resources\n");
- break;
- default:
- printf("Unspecified error 0x%X\n",ecode);
- break;
- }
+
+ case 0x81:
+ data = smb_fdata(data,
+ "NBT Session Request\nFlags=[rW]\nDestination=[n1]\nSource=[n1]\n",
+ maxbuf);
+ break;
+
+ case 0x82:
+ data = smb_fdata(data, "NBT Session Granted\nFlags=[rW]\n", maxbuf);
+ break;
+
+ case 0x83:
+ {
+ int ecode;
+
+ TCHECK(data[4]);
+ ecode = data[4];
+
+ data = smb_fdata(data, "NBT SessionReject\nFlags=[rW]\nReason=[B]\n",
+ maxbuf);
+ switch (ecode) {
+ case 0x80:
+ printf("Not listening on called name\n");
+ break;
+ case 0x81:
+ printf("Not listening for calling name\n");
+ break;
+ case 0x82:
+ printf("Called name not present\n");
+ break;
+ case 0x83:
+ printf("Called name present, but insufficient resources\n");
+ break;
+ default:
+ printf("Unspecified error 0x%X\n", ecode);
+ break;
+ }
+ }
+ break;
+
+ case 0x85:
+ data = smb_fdata(data, "NBT Session Keepalive\nFlags=[rW]\n", maxbuf);
+ break;
+
+ default:
+ printf("flags=0x%x\n", flags);
+ data = smb_fdata(data, "NBT - Unknown packet type\nType=[rW]\n", maxbuf);
}
- break;
-
- case 0x85:
- data = fdata(data,"NBT Session Keepalive\nFlags=[rW]\n",maxbuf);
- break;
-
- default:
- printf("flags=0x%x\n", flags);
- data = fdata(data,"NBT - Unknown packet type\nType=[rW]\n",maxbuf);
- }
- printf("\n");
- fflush(stdout);
+ printf("\n");
+ fflush(stdout);
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
}
/*
- print a NBT packet received across udp on port 137
-*/
-void nbt_udp137_print(const uchar *data, int length)
+ * print a NBT packet received across udp on port 137
+ */
+void
+nbt_udp137_print(const u_char *data, int length)
{
- const uchar *maxbuf = data + length;
- int name_trn_id = RSVAL(data,0);
- int response = (CVAL(data,2)>>7);
- int opcode = (CVAL(data,2) >> 3) & 0xF;
- int nm_flags = ((CVAL(data,2) & 0x7) << 4) + (CVAL(data,3)>>4);
- int rcode = CVAL(data,3) & 0xF;
- int qdcount = RSVAL(data,4);
- int ancount = RSVAL(data,6);
- int nscount = RSVAL(data,8);
- int arcount = RSVAL(data,10);
- char *opcodestr;
- const char *p;
-
- startbuf = data;
-
- if (maxbuf <= data) return;
-
- printf("\n>>> NBT UDP PACKET(137): ");
-
- switch (opcode) {
- case 0: opcodestr = "QUERY"; break;
- case 5: opcodestr = "REGISTRATION"; break;
- case 6: opcodestr = "RELEASE"; break;
- case 7: opcodestr = "WACK"; break;
- case 8: opcodestr = "REFRESH(8)"; break;
- case 9: opcodestr = "REFRESH"; break;
- default: opcodestr = "OPUNKNOWN"; break;
- }
- printf("%s", opcodestr);
- if (response) {
- if (rcode)
- printf("; NEGATIVE");
+ const u_char *maxbuf = data + length;
+ int name_trn_id, response, opcode, nm_flags, rcode;
+ int qdcount, ancount, nscount, arcount;
+ char *opcodestr;
+ const char *p;
+ int total, i;
+
+ TCHECK2(data[10], 2);
+ name_trn_id = EXTRACT_16BITS(data);
+ response = (data[2] >> 7);
+ opcode = (data[2] >> 3) & 0xF;
+ nm_flags = ((data[2] & 0x7) << 4) + (data[3] >> 4);
+ rcode = data[3] & 0xF;
+ qdcount = EXTRACT_16BITS(data + 4);
+ ancount = EXTRACT_16BITS(data + 6);
+ nscount = EXTRACT_16BITS(data + 8);
+ arcount = EXTRACT_16BITS(data + 10);
+ startbuf = data;
+
+ if (maxbuf <= data)
+ return;
+
+ if (vflag > 1)
+ printf("\n>>> ");
+
+ printf("NBT UDP PACKET(137): ");
+
+ switch (opcode) {
+ case 0: opcodestr = "QUERY"; break;
+ case 5: opcodestr = "REGISTRATION"; break;
+ case 6: opcodestr = "RELEASE"; break;
+ case 7: opcodestr = "WACK"; break;
+ case 8: opcodestr = "REFRESH(8)"; break;
+ case 9: opcodestr = "REFRESH"; break;
+ case 15: opcodestr = "MULTIHOMED REGISTRATION"; break;
+ default: opcodestr = "OPUNKNOWN"; break;
+ }
+ printf("%s", opcodestr);
+ if (response) {
+ if (rcode)
+ printf("; NEGATIVE");
+ else
+ printf("; POSITIVE");
+ }
+
+ if (response)
+ printf("; RESPONSE");
else
- printf("; POSITIVE");
- }
-
- if (response)
- printf("; RESPONSE");
- else
- printf("; REQUEST");
-
- if (nm_flags&1)
- printf("; BROADCAST");
- else
- printf("; UNICAST");
-
- if (vflag == 0) return;
-
- printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
- name_trn_id,opcode,nm_flags,rcode,qdcount,ancount,nscount,arcount);
-
- p = data + 12;
-
- {
- int total = ancount+nscount+arcount;
- int i;
+ printf("; REQUEST");
+
+ if (nm_flags & 1)
+ printf("; BROADCAST");
+ else
+ printf("; UNICAST");
+
+ if (vflag < 2)
+ return;
- if (qdcount>100 || total>100) {
- printf("Corrupt packet??\n");
- return;
+ printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
+ name_trn_id, opcode, nm_flags, rcode, qdcount, ancount, nscount,
+ arcount);
+
+ p = data + 12;
+
+ total = ancount + nscount + arcount;
+
+ if (qdcount > 100 || total > 100) {
+ printf("Corrupt packet??\n");
+ return;
}
if (qdcount) {
- printf("QuestionRecords:\n");
- for (i=0;i<qdcount;i++)
- p = fdata(p,"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",maxbuf);
+ printf("QuestionRecords:\n");
+ for (i = 0; i < qdcount; i++)
+ p = smb_fdata(p,
+ "|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
+ maxbuf);
if (p == NULL)
- goto out;
+ goto out;
}
if (total) {
- printf("\nResourceRecords:\n");
- for (i=0;i<total;i++) {
- 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);
+ printf("\nResourceRecords:\n");
+ for (i = 0; i < total; i++) {
+ int rdlen;
+ int restype;
+
+ p = smb_fdata(p, "Name=[n1]\n#", maxbuf);
if (p == NULL)
- goto out;
- while (numnames--) {
- p = fdata(p,"Name=[n2]\t#",maxbuf);
- 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;
+ goto out;
+ restype = EXTRACT_16BITS(p);
+ p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8);
+ if (p == NULL)
+ goto out;
+ rdlen = EXTRACT_16BITS(p);
+ printf("ResourceLength=%d\nResourceData=\n", rdlen);
+ p += 2;
+ if (rdlen == 6) {
+ p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen);
+ if (p == NULL)
+ goto out;
+ } else {
+ if (restype == 0x21) {
+ int numnames;
+
+ TCHECK(*p);
+ numnames = p[0];
+ p = smb_fdata(p, "NumNames=[B]\n", p + 1);
+ if (p == NULL)
+ goto out;
+ while (numnames--) {
+ p = smb_fdata(p, "Name=[n2]\t#", maxbuf);
+ TCHECK(*p);
+ 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 {
+ print_data(p, min(rdlen, length - ((const u_char *)p - data)));
+ p += rdlen;
+ }
}
- } else {
- print_data(p,rdlen);
- p += rdlen;
- }
}
- }
}
- }
- if ((uchar*)p < maxbuf) {
- fdata(p,"AdditionalData:\n",maxbuf);
- }
-
+ if ((u_char*)p < maxbuf)
+ smb_fdata(p, "AdditionalData:\n", maxbuf);
+
out:
- printf("\n");
- fflush(stdout);
+ printf("\n");
+ fflush(stdout);
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
}
/*
- print a NBT packet received across udp on port 138
-*/
-void nbt_udp138_print(const uchar *data, int length)
+ * print a NBT packet received across udp on port 138
+ */
+void
+nbt_udp138_print(const u_char *data, int length)
{
- const uchar *maxbuf = data + length;
- startbuf = data;
- if (maxbuf <= data) return;
+ const u_char *maxbuf = data + 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);
+ if (maxbuf > snapend)
+ maxbuf = snapend;
+ if (maxbuf <= data)
+ return;
+ startbuf = data;
- if (data != NULL)
- print_smb(data,maxbuf);
-
- printf("\n");
- fflush(stdout);
-}
+ if (vflag < 2) {
+ printf("NBT UDP PACKET(138)");
+ return;
+ }
+ data = smb_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);
+
+ if (data != NULL) {
+ /* If there isn't enough data for "\377SMB", don't check for it. */
+ if (&data[3] >= maxbuf)
+ goto out;
+
+ if (memcmp(data, "\377SMB",4) == 0)
+ print_smb(data, maxbuf);
+ }
+out:
+ printf("\n");
+ fflush(stdout);
+}
/*
- print netbeui frames
+ print netbeui frames
*/
-void netbeui_print(u_short control, const uchar *data, const uchar *maxbuf)
+void
+netbeui_print(u_short control, const u_char *data, int length)
{
- 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;
-
- 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:
- data = fdata(data,"NameQuery:[P1]\nSessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nDestination=[n2]\nSource=[n2]\n",data2);
- break;
-
- case 0x8:
- data = fdata(data,"NetbiosDataGram:[P7]\nDestination=[n2]\nSource=[n2]\n",data2);
- break;
-
- case 0xE:
- data = fdata(data,"NameRecognise:\n[P1]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n",data2);
- break;
-
- case 0x19:
- data = fdata(data,"SessionInitialise:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
- break;
-
- case 0x17:
- data = fdata(data,"SessionConfirm:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
- break;
-
- case 0x16:
- data = fdata(data,"NetbiosDataOnlyLast:\nFlags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
- break;
-
- case 0x14:
- data = fdata(data,"NetbiosDataAck:\n[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
- break;
-
- case 0x18:
- 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);
+ const u_char *maxbuf = data + length;
+ int len;
+ int command;
+ const u_char *data2;
+ int is_truncated = 0;
+
+ if (maxbuf > snapend)
+ maxbuf = snapend;
+ TCHECK(data[4]);
+ len = EXTRACT_LE_16BITS(data);
+ command = data[4];
+ data2 = data + len;
+ if (data2 >= maxbuf) {
+ data2 = maxbuf;
+ is_truncated = 1;
+ }
+
+ startbuf = data;
+
+ if (vflag < 2) {
+ printf("NetBeui Packet");
+ return;
+ }
+
+ printf("\n>>> NetBeui Packet\nType=0x%X ", control);
+ data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf);
+ if (data == NULL)
+ goto out;
+
+ switch (command) {
+ case 0xA:
+ data = smb_fdata(data, "NameQuery:[P1]\nSessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nDestination=[n2]\nSource=[n2]\n", data2);
+ break;
+
+ case 0x8:
+ data = smb_fdata(data,
+ "NetbiosDataGram:[P7]\nDestination=[n2]\nSource=[n2]\n", data2);
+ break;
+
+ case 0xE:
+ data = smb_fdata(data,
+ "NameRecognise:\n[P1]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n",
+ data2);
+ break;
+
+ case 0x19:
+ data = smb_fdata(data,
+ "SessionInitialise:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
+ data2);
+ break;
+
+ case 0x17:
+ data = smb_fdata(data,
+ "SessionConfirm:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
+ data2);
+ break;
+
+ case 0x16:
+ data = smb_fdata(data,
+ "NetbiosDataOnlyLast:\nFlags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
+ data2);
+ break;
+
+ case 0x14:
+ data = smb_fdata(data,
+ "NetbiosDataAck:\n[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
+ data2);
+ break;
+
+ case 0x18:
+ data = smb_fdata(data,
+ "SessionEnd:\n[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
+ data2);
+ break;
+
+ case 0x1f:
+ data = smb_fdata(data, "SessionAlive\n", data2);
+ break;
+
+ default:
+ data = smb_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 there isn't enough data for "\377SMB", don't look for it. */
+ if (&data2[3] >= maxbuf)
+ goto out;
+
+ if (memcmp(data2, "\377SMB",4) == 0)
+ print_smb(data2, maxbuf);
+ else {
+ int i;
+ for (i = 0; i < 128; i++) {
+ if (&data2[i + 3] >= maxbuf)
+ break;
+ if (memcmp(&data2[i], "\377SMB", 4) == 0) {
+ printf("found SMB packet at %d\n", i);
+ print_smb(&data2[i], maxbuf);
+ break;
+ }
+ }
+ }
out:
- printf("\n");
+ printf("\n");
+ return;
+trunc:
+ printf("[|SMB]");
+ return;
}
/*
- print IPX-Netbios frames
-*/
-void ipx_netbios_print(const uchar *data, const uchar *maxbuf)
+ * print IPX-Netbios frames
+ */
+void
+ipx_netbios_print(const u_char *data, u_int length)
{
- /* this is a hack till I work out how to parse the rest of the IPX stuff */
- int i;
- startbuf = data;
- for (i=0;i<128;i++)
- if (memcmp(&data[i],"\377SMB",4)==0) {
- fdata(data,"\n>>> IPX transport ",&data[i]);
- if (data != NULL)
- print_smb(&data[i],maxbuf);
- printf("\n");
- fflush(stdout);
- break;
+ /*
+ * this is a hack till I work out how to parse the rest of the
+ * NetBIOS-over-IPX stuff
+ */
+ int i;
+ const u_char *maxbuf;
+
+ maxbuf = data + length;
+ /* Don't go past the end of the captured data in the packet. */
+ if (maxbuf > snapend)
+ maxbuf = snapend;
+ startbuf = data;
+ for (i = 0; i < 128; i++) {
+ if (&data[i + 4] > maxbuf)
+ break;
+ if (memcmp(&data[i], "\377SMB", 4) == 0) {
+ smb_fdata(data, "\n>>> IPX transport ", &data[i]);
+ if (data != NULL)
+ print_smb(&data[i], maxbuf);
+ printf("\n");
+ fflush(stdout);
+ break;
+ }
}
- if (i==128)
- fdata(data,"\n>>> Unknown IPX ",maxbuf);
+ if (i == 128)
+ smb_fdata(data, "\n>>> Unknown IPX ", maxbuf);
}
diff --git a/contrib/tcpdump/print-snmp.c b/contrib/tcpdump/print-snmp.c
index 2e2a276790b6..a2638cefd015 100644
--- a/contrib/tcpdump/print-snmp.c
+++ b/contrib/tcpdump/print-snmp.c
@@ -1,16 +1,29 @@
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
+ * John Robert LoVerso. 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.
+ *
+ * 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.
*
- * 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 John Robert LoVerso.
- * 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.
*
* This implementation has been influenced by the CMU SNMP release,
* by Steve Waldbusser. However, this shares no code with that system.
@@ -45,7 +58,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.44 2000/11/10 17:34:10 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.50 2001/09/17 22:16:53 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -428,16 +441,11 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
elem->form = form;
elem->class = class;
elem->id = id;
- 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 > 1)
- printf("|%.2x", *p);
+ for (id = 0; *p & ASN_BIT8 && len > 0; len--, hdr++, p++)
id = (id << 7) | (*p & ~ASN_BIT8);
- }
if (len == 0 && *p & ASN_BIT8) {
ifNotTruncated fputs("[Xtagfield?]", stdout);
return -1;
@@ -452,8 +460,6 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
return -1;
}
elem->asnlen = *p;
- if (vflag > 1)
- printf("|%.2x", *p);
p++; len--; hdr++;
if (elem->asnlen & ASN_BIT8) {
int noct = elem->asnlen % ASN_BIT8;
@@ -462,11 +468,8 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
ifNotTruncated printf("[asnlen? %d<%d]", len, noct);
return -1;
}
- for (; noct-- > 0; len--, hdr++) {
- if (vflag > 1)
- printf("|%.2x", *p);
+ for (; noct-- > 0; len--, hdr++)
elem->asnlen = (elem->asnlen << ASN_SHIFT8) | *p++;
- }
}
if (len < elem->asnlen) {
if (!truncated) {
@@ -720,7 +723,7 @@ asn1_print(struct be *elem)
d = elem->data.uns64.high * 4294967296.0; /* 2^32 */
if (elem->data.uns64.high <= 0x1fffff) {
d += elem->data.uns64.low;
-#if 0 /*is looks illegal, but what is the intention???*/
+#if 0 /*is looks illegal, but what is the intention?*/
printf("%.f", d);
#else
printf("%f", d);
@@ -728,7 +731,7 @@ asn1_print(struct be *elem)
break;
}
d += (elem->data.uns64.low & 0xfffff000);
-#if 0 /*is looks illegal, but what is the intention???*/
+#if 0 /*is looks illegal, but what is the intention?*/
snprintf(first, sizeof(first), "%.f", d);
#else
snprintf(first, sizeof(first), "%f", d);
@@ -837,25 +840,6 @@ 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;
@@ -878,7 +862,7 @@ static struct smi2be smi2betab[] = {
};
static void smi_decode_oid(struct be *elem, unsigned int *oid,
- unsigned int *oidlen)
+ unsigned int oidsize, unsigned int *oidlen)
{
u_char *p = (u_char *)elem->data.raw;
u_int32_t asnlen = elem->asnlen;
@@ -894,10 +878,14 @@ static void smi_decode_oid(struct be *elem, unsigned int *oid,
*/
if (first < 0) {
first = 0;
- oid[(*oidlen)++] = o/OIDMUX;
+ if (*oidlen < oidsize) {
+ oid[(*oidlen)++] = o/OIDMUX;
+ }
o %= OIDMUX;
}
- oid[(*oidlen)++] = o;
+ if (*oidlen < oidsize) {
+ oid[(*oidlen)++] = o;
+ }
o = 0;
}
}
@@ -966,37 +954,22 @@ 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
-#ifdef LIBSMI_API_V1
- && smiType->parentmodule && smiType->parentname
-#endif
- ) {
+ if (ok) {
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);
}
}
@@ -1009,18 +982,14 @@ static SmiNode *smi_print_variable(struct be *elem)
SmiNode *smiNode = NULL;
int i;
- smi_decode_oid(elem, oid, &oidlen);
+ smi_decode_oid(elem, oid, sizeof(oid)/sizeof(unsigned int), &oidlen);
smiNode = smiGetNodeByOID(oidlen, oid);
if (! smiNode) {
asn1_print(elem);
return NULL;
}
if (vflag) {
-#ifdef LIBSMI_API_V1
- fputs(smiNode->module, stdout);
-#else
fputs(smiGetNodeModule(smiNode)->name, stdout);
-#endif
fputs("::", stdout);
}
fputs(smiNode->name, stdout);
@@ -1069,26 +1038,18 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
fputs("[noAccess]", 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);
+ fputs("[outOfRange]", stdout);
}
/* resolve bits to named bits */
@@ -1104,15 +1065,13 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (smiType->basetype == SMI_BASETYPE_BITS) {
/* print bit labels */
} else {
- smi_decode_oid(elem, oid, &oidlen);
+ smi_decode_oid(elem, oid,
+ sizeof(oid)/sizeof(unsigned int),
+ &oidlen);
smiNode = smiGetNodeByOID(oidlen, oid);
if (smiNode) {
if (vflag) {
-#ifdef LIBSMI_API_V1
- fputs(smiNode->module, stdout);
-#else
fputs(smiGetNodeModule(smiNode)->name, stdout);
-#endif
fputs("::", stdout);
}
fputs(smiNode->name, stdout);
@@ -1128,15 +1087,8 @@ 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
@@ -1154,10 +1106,6 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (! done) {
asn1_print(elem);
}
-
- if (smiType) {
- smiFreeType(smiType);
- }
}
#endif
@@ -1273,7 +1221,6 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
if (elem.type != BE_NULL) {
#ifdef LIBSMI
smi_print_value(smiNode, pduid, &elem);
- smiFreeNode(smiNode);
#else
asn1_print(&elem);
#endif
diff --git a/contrib/tcpdump/print-tcp.c b/contrib/tcpdump/print-tcp.c
index 40d3f496b4e9..a5f69feea3c0 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.81 2000/12/23 20:55:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.95 2001/12/10 08:21:24 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,49 +52,12 @@ static const char rcsid[] =
#include "ip6.h"
#endif
+#include "nameser.h"
+
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) */
-#endif
-#ifndef TCPOPT_SACKOK
-#define TCPOPT_SACKOK 4 /* selective ack ok (rfc1072) */
-#endif
-#ifndef TCPOPT_SACK
-#define TCPOPT_SACK 5 /* selective ack (rfc1072) */
-#endif
-#ifndef TCPOPT_ECHO
-#define TCPOPT_ECHO 6 /* echo (rfc1072) */
-#endif
-#ifndef TCPOPT_ECHOREPLY
-#define TCPOPT_ECHOREPLY 7 /* echo (rfc1072) */
-#endif
-#ifndef TCPOPT_TIMESTAMP
-#define TCPOPT_TIMESTAMP 8 /* timestamps (rfc1323) */
-#endif
-#ifndef TCPOPT_CC
-#define TCPOPT_CC 11 /* T/TCP CC options (rfc1644) */
-#endif
-#ifndef TCPOPT_CCNEW
-#define TCPOPT_CCNEW 12 /* T/TCP CC options (rfc1644) */
-#endif
-#ifndef TCPOPT_CCECHO
-#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
@@ -129,16 +92,19 @@ 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 PPTP_PORT
+#define PPTP_PORT 1723
+#endif
+#define BEEP_PORT 10288
#ifndef NFS_PORT
#define NFS_PORT 2049
#endif
+#define MSDP_PORT 639
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;
@@ -149,34 +115,18 @@ static int tcp_cksum(register const struct ip *ip,
} 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);
+ const u_int16_t *sp;
/* pseudo-header.. */
- phu.ph.len = htons(tlen);
+ phu.ph.len = htons(len); /* XXX */
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);
+ return in_cksum((u_short *)tp, len,
+ sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]);
}
#ifdef INET6
@@ -262,7 +212,6 @@ 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;
/*
@@ -273,13 +222,13 @@ tcp_print(register const u_char *bp, register u_int length,
if (!qflag) {
if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend &&
dport == NFS_PORT) {
- nfsreq_print((u_char *)tp + hlen + 4, length-hlen,
+ 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,
+ nfsreply_print((u_char *)tp + hlen + 4, length - hlen,
(u_char *)ip);
return;
}
@@ -353,18 +302,18 @@ tcp_print(register const u_char *bp, register u_int length,
memset(&tha, 0, sizeof(tha));
rev = 0;
if (ip6) {
- if (sport > dport) {
+ if (sport > dport)
rev = 1;
- } else if (sport == dport) {
- int i;
-
- for (i = 0; i < 4; i++) {
- if (((u_int32_t *)(&ip6->ip6_src))[i] >
- ((u_int32_t *)(&ip6->ip6_dst))[i]) {
- rev = 1;
- break;
+ else if (sport == dport) {
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (((u_int32_t *)(&ip6->ip6_src))[i] >
+ ((u_int32_t *)(&ip6->ip6_dst))[i]) {
+ rev = 1;
+ break;
+ }
}
- }
}
if (rev) {
tha.src = ip6->ip6_dst;
@@ -425,7 +374,6 @@ 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 {
if (rev)
seq -= th->ack, ack -= th->seq;
@@ -469,7 +417,7 @@ tcp_print(register const u_char *bp, register u_int length,
length -= hlen;
if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
- (void)printf(" %u:%u(%d)", seq, seq + length, length);
+ (void)printf(" %u:%u(%u)", seq, seq + length, length);
if (flags & TH_ACK)
(void)printf(" ack %u", ack);
@@ -649,10 +597,24 @@ tcp_print(register const u_char *bp, register u_int length,
telnet_print(bp, length);
} else if (sport == BGP_PORT || dport == BGP_PORT)
bgp_print(bp, length);
+ else if (sport == PPTP_PORT || dport == PPTP_PORT)
+ pptp_print(bp, length);
+#ifdef TCPDUMP_DO_SMB
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);
+#endif
+ else if (sport == BEEP_PORT || dport == BEEP_PORT)
+ beep_print(bp, length);
+ else if (length > 2 &&
+ (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT)) {
+ /*
+ * TCP DNS query has 2byte length at the head.
+ * XXX packet could be unaligned, it can go strange
+ */
+ ns_print(bp + 2, length - 2);
+ } else if (sport == MSDP_PORT || dport == MSDP_PORT) {
+ msdp_print(bp, length);
+ }
}
return;
bad:
@@ -697,10 +659,7 @@ print_tcp_rst_data(register const u_char *sp, u_int length)
putchar(' ');
while (length-- && sp <= snapend) {
c = *sp++;
- if (isprint(c))
- putchar(c);
- else
- putchar('.');
+ safeputchar(c);
}
putchar(']');
}
diff --git a/contrib/tcpdump/print-telnet.c b/contrib/tcpdump/print-telnet.c
index bad4e7d02541..c070c442f95b 100644
--- a/contrib/tcpdump/print-telnet.c
+++ b/contrib/tcpdump/print-telnet.c
@@ -51,7 +51,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.12 2000/09/29 04:58:51 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.18 2001/09/10 06:40:08 fenner Exp $";
#endif
#include <sys/param.h>
@@ -61,10 +61,6 @@ static const char rcsid[] =
#include <netinet/in.h>
-#define TELCMDS
-#define TELOPTS
-#include <arpa/telnet.h>
-
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -73,110 +69,199 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
-#ifndef TELCMD_FIRST
-# define TELCMD_FIRST SE
-#endif
+#define TELCMDS
+#define TELOPTS
+#include "telnet.h"
-void
-telnet_print(register const u_char *sp, u_int length)
+/* normal */
+static const char *cmds[] = {
+ "IS", "SEND", "INFO",
+};
+
+/* 37: Authentication */
+static const char *authcmd[] = {
+ "IS", "SEND", "REPLY", "NAME",
+};
+static const char *authtype[] = {
+ "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK",
+ "SRP", "RSA", "SSL", NULL, NULL,
+ "LOKI", "SSA", "KEA_SJ", "KEA_SJ_INTEG", "DSS",
+ "NTLM",
+};
+
+/* 38: Encryption */
+static const char *enccmd[] = {
+ "IS", "SUPPORT", "REPLY", "START", "END",
+ "REQUEST-START", "REQUEST-END", "END_KEYID", "DEC_KEYID",
+};
+static const char *enctype[] = {
+ "NULL", "DES_CFB64", "DES_OFB64", "DES3_CFB64", "DES3_OFB64",
+ NULL, "CAST5_40_CFB64", "CAST5_40_OFB64", "CAST128_CFB64", "CAST128_OFB64",
+};
+
+#define STR_OR_ID(x, tab) \
+ (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x))
+
+static char *
+numstr(int x)
{
- static char tnet[128];
- register int i, c, x;
- register u_char *rcp;
- int off, first = 1;
- u_char *osp;
-
- off = 0;
- x = 0;
-
- while (length > 0 && *sp == IAC) {
- osp = (u_char *) sp;
- tnet[0] = '\0';
-
- c = *sp++;
- length--;
- switch (*sp) {
- case IAC: /* <IAC><IAC>! */
- if (length > 1 && sp[1] == IAC) {
- (void)strcpy(tnet, "IAC IAC");
- } else {
- length = 0;
- continue;
- }
+ static char buf[20];
+
+ snprintf(buf, sizeof(buf), "%#x", x);
+ return buf;
+}
+
+/* sp points to IAC byte */
+static int
+telnet_parse(const u_char *sp, u_int length, int print)
+{
+ int i, c, x;
+ const u_char *osp, *p;
+#define FETCH(c, sp, length) \
+ do { \
+ if (length < 1) \
+ goto pktend; \
+ TCHECK(*sp); \
+ c = *sp++; \
+ length--; \
+ } while (0)
+
+ osp = sp;
+
+ FETCH(c, sp, length);
+ if (c != IAC)
+ goto pktend;
+ FETCH(c, sp, length);
+ if (c == IAC) { /* <IAC><IAC>! */
+ if (print)
+ printf("IAC IAC");
+ goto done;
+ }
+
+ i = c - TELCMD_FIRST;
+ if (i < 0 || i > IAC - TELCMD_FIRST)
+ goto pktend;
+
+ switch (c) {
+ case DONT:
+ case DO:
+ case WONT:
+ case WILL:
+ case SB:
+ /* DONT/DO/WONT/WILL x */
+ FETCH(x, sp, length);
+ if (x >= 0 && x < NTELOPTS) {
+ if (print)
+ (void)printf("%s %s", telcmds[i], telopts[x]);
+ } else {
+ if (print)
+ (void)printf("%s %#x", telcmds[i], x);
+ }
+ if (c != SB)
+ break;
+ /* IAC SB .... IAC SE */
+ p = sp;
+ while (length > p + 1 - sp) {
+ if (p[0] == IAC && p[1] == SE)
+ break;
+ p++;
+ }
+ if (*p != IAC)
+ goto pktend;
+
+ switch (x) {
+ case TELOPT_AUTHENTICATION:
+ if (p <= sp)
+ break;
+ FETCH(c, sp, length);
+ if (print)
+ (void)printf(" %s", STR_OR_ID(c, authcmd));
+ if (p <= sp)
+ break;
+ FETCH(c, sp, length);
+ if (print)
+ (void)printf(" %s", STR_OR_ID(c, authtype));
+ break;
+ case TELOPT_ENCRYPT:
+ if (p <= sp)
+ break;
+ FETCH(c, sp, length);
+ if (print)
+ (void)printf(" %s", STR_OR_ID(c, enccmd));
+ if (p <= sp)
+ break;
+ FETCH(c, sp, length);
+ if (print)
+ (void)printf(" %s", STR_OR_ID(c, enctype));
break;
default:
- c = *sp++;
- length--;
- if ((i = c - TELCMD_FIRST) < 0
- || i > IAC - TELCMD_FIRST) {
- (void)printf("unknown: ff%02x\n", c);
- return;
- }
- switch (c) {
- case DONT:
- case DO:
- case WONT:
- case WILL:
- case SB:
- x = *sp++; /* option */
- length--;
- if (x >= 0 && x < NTELOPTS) {
- (void)snprintf(tnet, sizeof(tnet),
- "%s %s", telcmds[i], telopts[x]);
- } else {
- (void)snprintf(tnet, sizeof(tnet),
- "%s %#x", telcmds[i], x);
- }
+ if (p <= sp)
break;
- default:
- (void)snprintf(tnet, sizeof(tnet), "%s",
- telcmds[i]);
- }
- if (c == SB) {
- c = *sp++;
- length--;
- (void)strcat(tnet, c ? " SEND" : " IS '");
- rcp = (u_char *) sp;
- i = strlen(tnet);
- while (length > 0 && (x = *sp++) != IAC)
- --length;
- if (x == IAC) {
- if (2 < vflag
- && i + 16 + sp - rcp < sizeof(tnet)) {
- (void)strncpy(&tnet[i], rcp, sp - rcp);
- i += (sp - rcp) - 1;
- tnet[i] = '\0';
- } else if (i + 8 < sizeof(tnet)) {
- (void)strcat(&tnet[i], "...");
- }
- if (*sp++ == SE
- && i + 4 < sizeof(tnet))
- (void)strcat(tnet, c ? " SE" : "' SE");
- } else if (i + 16 < sizeof(tnet)) {
- (void)strcat(tnet, " truncated!");
- }
- }
+ FETCH(c, sp, length);
+ if (print)
+ (void)printf(" %s", STR_OR_ID(c, cmds));
break;
}
+ while (p > sp) {
+ FETCH(x, sp, length);
+ if (print)
+ (void)printf(" %#x", x);
+ }
+ /* terminating IAC SE */
+ if (print)
+ (void)printf(" SE");
+ sp += 2;
+ length -= 2;
+ break;
+ default:
+ if (print)
+ (void)printf("%s", telcmds[i]);
+ goto done;
+ }
+
+done:
+ return sp - osp;
+
+trunc:
+ (void)printf("[|telnet]");
+pktend:
+ return -1;
+#undef FETCH
+}
+
+void
+telnet_print(const u_char *sp, u_int length)
+{
+ int first = 1;
+ const u_char *osp;
+ int l;
+
+ osp = sp;
+
+ while (length > 0 && *sp == IAC) {
+ l = telnet_parse(sp, length, 0);
+ if (l < 0)
+ break;
+
/*
* now print it
*/
if (Xflag && 2 < vflag) {
if (first)
- printf("\nTelnet:\n");
- i = sp - osp;
- hex_print_with_offset(osp, i, off);
- off += i;
- if (i > 8)
+ printf("\nTelnet:");
+ hex_print_with_offset(sp, l, sp - osp);
+ if (l > 8)
printf("\n\t\t\t\t");
else
- printf("%*s\t", (8 - i) * 3, "");
- safeputs(tnet);
- } else {
+ printf("%*s\t", (8 - l) * 3, "");
+ } else
printf("%s", (first) ? " [telnet " : ", ");
- safeputs(tnet);
- }
+
+ (void)telnet_parse(sp, length, 1);
first = 0;
+
+ sp += l;
+ length -= l;
}
if (!first) {
if (Xflag && 2 < vflag)
diff --git a/contrib/tcpdump/print-timed.c b/contrib/tcpdump/print-timed.c
index d683c409534f..af73ddb6de86 100644
--- a/contrib/tcpdump/print-timed.c
+++ b/contrib/tcpdump/print-timed.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.1 2000/10/06 05:35:37 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.3 2001/05/17 18:33:23 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,20 +30,12 @@ static const char rcsid[] =
#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 "timed.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",
diff --git a/contrib/tcpdump/print-vrrp.c b/contrib/tcpdump/print-vrrp.c
index 6b7ac94d92b4..9bc29d1f8bc7 100644
--- a/contrib/tcpdump/print-vrrp.c
+++ b/contrib/tcpdump/print-vrrp.c
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.3 2000/10/10 05:05:08 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.5 2001/07/23 22:27:30 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -64,30 +64,47 @@ static const char rcsid[] =
* | Authentication Data (2) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+
+/* Type */
+#define VRRP_TYPE_ADVERTISEMENT 1
+
+static const struct tok type2str[] = {
+ { VRRP_TYPE_ADVERTISEMENT, "advertisement" },
+ { 0, NULL }
+};
+
+/* Auth Type */
+#define VRRP_AUTH_NONE 0
+#define VRRP_AUTH_SIMPLE 1
+#define VRRP_AUTH_AH 2
+
+static const struct tok auth2str[] = {
+ { VRRP_AUTH_NONE, "none" },
+ { VRRP_AUTH_SIMPLE, "simple" },
+ { VRRP_AUTH_AH, "ah" },
+ { 0, NULL }
+};
+
void
vrrp_print(register const u_char *bp, register u_int len, int ttl)
{
int version, type, auth_type;
- char *type_s;
+ const 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";
+ type_s = tok2str(type2str, "type#%d", type);
printf("VRRPv%d-%s %d: ", version, type_s, len);
if (ttl != 255)
printf("[ttl=%d!] ", ttl);
- if (version != 2 || type != 1)
+ if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT)
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(" authtype=%s", tok2str(auth2str, NULL, auth_type));
printf(" intvl=%d", bp[5]);
if (vflag) {
int naddrs = bp[3];
@@ -109,9 +126,11 @@ vrrp_print(register const u_char *bp, register u_int len, int ttl)
c = ',';
bp += 4;
}
- if (auth_type == 1) { /* simple text password */
+ if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
TCHECK(bp[7]);
- printf(" auth %.8s", bp);
+ printf(" auth \"");
+ fn_printn(bp, 8, NULL);
+ printf("\"");
}
}
return;
diff --git a/contrib/tcpdump/print-wb.c b/contrib/tcpdump/print-wb.c
index fa1054130ef5..7b0281b628fc 100644
--- a/contrib/tcpdump/print-wb.c
+++ b/contrib/tcpdump/print-wb.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.25 1999/11/21 09:37:03 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.26 2001/06/27 05:37:19 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -77,6 +77,10 @@ struct pkt_hdr {
#define PT_PREQ 5 /* page vector request */
#define PT_PREP 7 /* page vector reply */
+#ifdef PF_USER
+#undef PF_USER /* {Digital,Tru64} UNIX define this, alas */
+#endif
+
/* flags */
#define PF_USER 0x01 /* hint that packet has interactive data */
#define PF_VIS 0x02 /* only visible ops wanted */
diff --git a/contrib/tcpdump/print-zephyr.c b/contrib/tcpdump/print-zephyr.c
new file mode 100644
index 000000000000..5792e601f607
--- /dev/null
+++ b/contrib/tcpdump/print-zephyr.c
@@ -0,0 +1,311 @@
+/*
+ * Decode and print Zephyr packets.
+ *
+ * Copyright (c) 2001 Nickolai Zeldovich <kolya@MIT.EDU>
+ * 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, 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 the author(s) 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-zephyr.c,v 1.2 2001/09/11 02:37:12 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "interface.h"
+
+struct z_packet {
+ char *version;
+ int numfields;
+ int kind;
+ char *uid;
+ int port;
+ int auth;
+ int authlen;
+ char *authdata;
+ char *class;
+ char *inst;
+ char *opcode;
+ char *sender;
+ char *recipient;
+ char *format;
+ int cksum;
+ int multi;
+ char *multi_uid;
+ /* Other fields follow here.. */
+};
+
+enum {
+ Z_PACKET_UNSAFE = 0,
+ Z_PACKET_UNACKED,
+ Z_PACKET_ACKED,
+ Z_PACKET_HMACK,
+ Z_PACKET_HMCTL,
+ Z_PACKET_SERVACK,
+ Z_PACKET_SERVNAK,
+ Z_PACKET_CLIENTACK,
+ Z_PACKET_STAT
+} z_packet_type;
+
+static struct tok z_types[] = {
+ { Z_PACKET_UNSAFE, "unsafe" },
+ { Z_PACKET_UNACKED, "unacked" },
+ { Z_PACKET_ACKED, "acked" },
+ { Z_PACKET_HMACK, "hm-ack" },
+ { Z_PACKET_HMCTL, "hm-ctl" },
+ { Z_PACKET_SERVACK, "serv-ack" },
+ { Z_PACKET_SERVNAK, "serv-nak" },
+ { Z_PACKET_CLIENTACK, "client-ack" },
+ { Z_PACKET_STAT, "stat" }
+};
+
+char z_buf[256];
+
+static char *
+parse_field(char **pptr, int *len)
+{
+ char *s;
+
+ if (*len <= 0 || !pptr || !*pptr)
+ return NULL;
+ if (*pptr > (char *) snapend)
+ return NULL;
+
+ s = *pptr;
+ while (*pptr <= (char *) snapend && *len >= 0 && **pptr) {
+ (*pptr)++;
+ (*len)--;
+ }
+ (*pptr)++;
+ (*len)--;
+ if (*len < 0 || *pptr > (char *) snapend)
+ return NULL;
+ return s;
+}
+
+static const char *
+z_triple(char *class, char *inst, char *recipient)
+{
+ if (!*recipient)
+ recipient = "*";
+ snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient);
+ z_buf[sizeof(z_buf)-1] = '\0';
+ return z_buf;
+}
+
+static const char *
+str_to_lower(char *string)
+{
+ strncpy(z_buf, string, sizeof(z_buf));
+ z_buf[sizeof(z_buf)-1] = '\0';
+
+ string = z_buf;
+ while (*string) {
+ *string = tolower(*string);
+ string++;
+ }
+
+ return z_buf;
+}
+
+void
+zephyr_print(const u_char *cp, int length)
+{
+ struct z_packet z;
+ char *parse = (char *) cp;
+ int parselen = length;
+ char *s;
+ int lose = 0;
+
+#define PARSE_STRING \
+ s = parse_field(&parse, &parselen); \
+ if (!s) lose = 1;
+
+#define PARSE_FIELD_INT(field) \
+ PARSE_STRING \
+ if (!lose) field = strtol(s, 0, 16);
+
+#define PARSE_FIELD_STR(field) \
+ PARSE_STRING \
+ if (!lose) field = s;
+
+ PARSE_FIELD_STR(z.version);
+ if (lose) return;
+ if (strncmp(z.version, "ZEPH", 4))
+ return;
+
+ PARSE_FIELD_INT(z.numfields);
+ PARSE_FIELD_INT(z.kind);
+ PARSE_FIELD_STR(z.uid);
+ PARSE_FIELD_INT(z.port);
+ PARSE_FIELD_INT(z.auth);
+ PARSE_FIELD_INT(z.authlen);
+ PARSE_FIELD_STR(z.authdata);
+ PARSE_FIELD_STR(z.class);
+ PARSE_FIELD_STR(z.inst);
+ PARSE_FIELD_STR(z.opcode);
+ PARSE_FIELD_STR(z.sender);
+ PARSE_FIELD_STR(z.recipient);
+ PARSE_FIELD_STR(z.format);
+ PARSE_FIELD_INT(z.cksum);
+ PARSE_FIELD_INT(z.multi);
+ PARSE_FIELD_STR(z.multi_uid);
+
+ if (lose) {
+ printf(" [|zephyr] (%d)", length);
+ return;
+ }
+
+ printf(" zephyr");
+ if (strncmp(z.version+4, "0.2", 3)) {
+ printf(" v%s", z.version+4);
+ return;
+ }
+
+ printf(" %s", tok2str(z_types, "type %d", z.kind));
+ if (z.kind == Z_PACKET_SERVACK) {
+ /* Initialization to silence warnings */
+ char *ackdata = NULL;
+ PARSE_FIELD_STR(ackdata);
+ if (!lose && strcmp(ackdata, "SENT"))
+ printf("/%s", str_to_lower(ackdata));
+ }
+ if (*z.sender) printf(" %s", z.sender);
+
+ if (!strcmp(z.class, "USER_LOCATE")) {
+ if (!strcmp(z.opcode, "USER_HIDE"))
+ printf(" hide");
+ else if (!strcmp(z.opcode, "USER_UNHIDE"))
+ printf(" unhide");
+ else
+ printf(" locate %s", z.inst);
+ return;
+ }
+
+ if (!strcmp(z.class, "ZEPHYR_ADMIN")) {
+ printf(" zephyr-admin %s", str_to_lower(z.opcode));
+ return;
+ }
+
+ if (!strcmp(z.class, "ZEPHYR_CTL")) {
+ if (!strcmp(z.inst, "CLIENT")) {
+ if (!strcmp(z.opcode, "SUBSCRIBE") ||
+ !strcmp(z.opcode, "SUBSCRIBE_NODEFS") ||
+ !strcmp(z.opcode, "UNSUBSCRIBE")) {
+
+ printf(" %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
+ strcmp(z.opcode, "SUBSCRIBE_NODEFS") ? "" :
+ "-nodefs");
+ if (z.kind != Z_PACKET_SERVACK) {
+ /* Initialization to silence warnings */
+ char *c = NULL, *i = NULL, *r = NULL;
+ PARSE_FIELD_STR(c);
+ PARSE_FIELD_STR(i);
+ PARSE_FIELD_STR(r);
+ if (!lose) printf(" %s", z_triple(c, i, r));
+ }
+ return;
+ }
+
+ if (!strcmp(z.opcode, "GIMME")) {
+ printf(" ret");
+ return;
+ }
+
+ if (!strcmp(z.opcode, "GIMMEDEFS")) {
+ printf(" gimme-defs");
+ return;
+ }
+
+ if (!strcmp(z.opcode, "CLEARSUB")) {
+ printf(" clear-subs");
+ return;
+ }
+
+ printf(" %s", str_to_lower(z.opcode));
+ return;
+ }
+
+ if (!strcmp(z.inst, "HM")) {
+ printf(" %s", str_to_lower(z.opcode));
+ return;
+ }
+
+ if (!strcmp(z.inst, "REALM")) {
+ if (!strcmp(z.opcode, "ADD_SUBSCRIBE"))
+ printf(" realm add-subs");
+ if (!strcmp(z.opcode, "REQ_SUBSCRIBE"))
+ printf(" realm req-subs");
+ if (!strcmp(z.opcode, "RLM_SUBSCRIBE"))
+ printf(" realm rlm-sub");
+ if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE"))
+ printf(" realm rlm-unsub");
+ return;
+ }
+ }
+
+ if (!strcmp(z.class, "HM_CTL")) {
+ printf(" hm_ctl %s", str_to_lower(z.inst));
+ printf(" %s", str_to_lower(z.opcode));
+ return;
+ }
+
+ if (!strcmp(z.class, "HM_STAT")) {
+ if (!strcmp(z.inst, "HMST_CLIENT") && !strcmp(z.opcode, "GIMMESTATS")) {
+ printf(" get-client-stats");
+ return;
+ }
+ }
+
+ if (!strcmp(z.class, "WG_CTL")) {
+ printf(" wg_ctl %s", str_to_lower(z.inst));
+ printf(" %s", str_to_lower(z.opcode));
+ return;
+ }
+
+ if (!strcmp(z.class, "LOGIN")) {
+ if (!strcmp(z.opcode, "USER_FLUSH")) {
+ printf(" flush_locs");
+ return;
+ }
+
+ if (!strcmp(z.opcode, "NONE") ||
+ !strcmp(z.opcode, "OPSTAFF") ||
+ !strcmp(z.opcode, "REALM-VISIBLE") ||
+ !strcmp(z.opcode, "REALM-ANNOUNCED") ||
+ !strcmp(z.opcode, "NET-VISIBLE") ||
+ !strcmp(z.opcode, "NET-ANNOUNCED")) {
+ printf(" set-exposure %s", str_to_lower(z.opcode));
+ return;
+ }
+ }
+
+ if (!*z.recipient)
+ z.recipient = "*";
+
+ printf(" to %s", z_triple(z.class, z.inst, z.recipient));
+ if (*z.opcode)
+ printf(" op %s", z.opcode);
+ return;
+}
diff --git a/contrib/tcpdump/route6d.h b/contrib/tcpdump/route6d.h
index dba49fb9741d..2adf4098a80e 100644
--- a/contrib/tcpdump/route6d.h
+++ b/contrib/tcpdump/route6d.h
@@ -1,5 +1,33 @@
/*
- * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.2 2000/04/28 11:14:49 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.
+ */
+/*
+ * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.3 2001/10/22 04:27:47 itojun Exp $
*/
#define RIP6_VERSION 1
diff --git a/contrib/tcpdump/rx.h b/contrib/tcpdump/rx.h
index fe6f9634d54f..247be9930642 100644
--- a/contrib/tcpdump/rx.h
+++ b/contrib/tcpdump/rx.h
@@ -1,7 +1,29 @@
/*
+ * Copyright: (c) 2000 United States Government as represented by the
+ * Secretary of the Navy. 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 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.
+ */
+/*
* Rx protocol format
*
- * $Id: rx.h,v 1.3 2000/10/03 02:55:02 itojun Exp $
+ * $Id: rx.h,v 1.5 2001/10/22 04:23:37 itojun Exp $
*/
#define FS_RX_PORT 7000
@@ -57,6 +79,8 @@ struct rx_header {
#define RX_LAST_PACKET 4
#define RX_MORE_PACKETS 8
#define RX_FREE_PACKET 16
+#define RX_SLOW_START_OK 32
+#define RX_JUMBO_PACKET 32
u_int8_t userStatus;
u_int8_t securityIndex;
u_int16_t spare; /* How clever: even though the AFS */
@@ -65,7 +89,7 @@ struct rx_header {
/* encoded _after_ the spare field */
/* I wasted a day figuring that out! */
-#define NUM_RX_FLAGS 5
+#define NUM_RX_FLAGS 7
#define RX_MAXACKS 255
diff --git a/contrib/tcpdump/sctpConstants.h b/contrib/tcpdump/sctpConstants.h
new file mode 100644
index 000000000000..3267e83045e7
--- /dev/null
+++ b/contrib/tcpdump/sctpConstants.h
@@ -0,0 +1,576 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/sctpConstants.h,v 1.2 2001/06/28 10:17:22 guy Exp $ (LBL) */
+
+/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
+ *
+ * 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 Cisco nor of Motorola 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.
+ *
+ * This file is part of the SCTP reference Implementation
+ *
+ *
+ * Please send any bug reports or fixes you make to one of the following email
+ * addresses:
+ *
+ * rstewar1@email.mot.com
+ * kmorneau@cisco.com
+ * qxie1@email.mot.com
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorperated into the next SCTP release.
+ */
+
+
+#ifndef __sctpConstants_h__
+#define __sctpConstants_h__
+
+
+ /* If you wish to use MD5 instead of SLA uncomment the line
+ * below. Why you would like to do this:
+ * a) There may be IPR on SHA-1, or so the FIP-180-1 page says,
+ * b) MD5 is 3 times faster (has coded here).
+ *
+ * The disadvantage is, it is thought that MD5 has been
+ * cracked... see RFC2104.
+ */
+/*#define USE_MD5 1*/
+
+/* the SCTP protocol signature
+ * this includes the version number
+ * encoded in the last 4 bits of the
+ * signature.
+ */
+#define PROTO_SIGNATURE_A 0x30000000
+
+#define SCTP_VERSION_NUMBER 0x3
+
+#define MAX_TSN 0xffffffff
+#define MAX_SEQ 0xffff
+
+/* option:
+ * If you comment out the following you will
+ * receive the old behavior of obeying cwnd for
+ * the fast retransmit algorithm. With this defined
+ * a FR happens right away with-out waiting for the
+ * flightsize to drop below the cwnd value (which
+ * is reduced by the FR to 1/2 the inflight packets).
+ */
+#define SCTP_IGNORE_CWND_ON_FR 1
+/* default max I can burst out after a fast retransmit */
+#define SCTP_DEF_MAX_BURST 4
+
+/* Packet transmit states in the sent
+ * field in the SCTP_transmitOnQueue struct
+ */
+#define SCTP_DATAGRAM_UNSENT 0
+#define SCTP_DATAGRAM_SENT 1
+#define SCTP_DATAGRAM_RESEND1 2 /* not used */
+#define SCTP_DATAGRAM_RESEND2 3 /* not used */
+#define SCTP_DATAGRAM_RESEND3 4 /* not used */
+#define SCTP_DATAGRAM_RESEND 5
+#define SCTP_DATAGRAM_ACKED 10010
+#define SCTP_DATAGRAM_INBOUND 10011
+#define SCTP_READY_TO_TRANSMIT 10012
+#define SCTP_DATAGRAM_MARKED 20010
+
+#define MAX_FSID 64 /* debug 5 ints used for cc dynamic tracking */
+
+/* The valid defines for all message
+ * types know to SCTP. 0 is reserved
+ */
+#define SCTP_MSGTYPE_MASK 0xff
+
+#define SCTP_DATA 0x00
+#define SCTP_INITIATION 0x01
+#define SCTP_INITIATION_ACK 0x02
+#define SCTP_SELECTIVE_ACK 0x03
+#define SCTP_HEARTBEAT_REQUEST 0x04
+#define SCTP_HEARTBEAT_ACK 0x05
+#define SCTP_ABORT_ASSOCIATION 0x06
+#define SCTP_SHUTDOWN 0x07
+#define SCTP_SHUTDOWN_ACK 0x08
+#define SCTP_OPERATION_ERR 0x09
+#define SCTP_COOKIE_ECHO 0x0a
+#define SCTP_COOKIE_ACK 0x0b
+#define SCTP_ECN_ECHO 0x0c
+#define SCTP_ECN_CWR 0x0d
+#define SCTP_SHUTDOWN_COMPLETE 0x0e
+#define SCTP_FORWARD_CUM_TSN 0xc0
+#define SCTP_RELIABLE_CNTL 0xc1
+#define SCTP_RELIABLE_CNTL_ACK 0xc2
+
+/* ABORT and SHUTDOWN COMPLETE FLAG */
+#define SCTP_HAD_NO_TCB 0x01
+
+/* Data Chuck Specific Flags */
+#define SCTP_DATA_FRAG_MASK 0x03
+#define SCTP_DATA_MIDDLE_FRAG 0x00
+#define SCTP_DATA_LAST_FRAG 0x01
+#define SCTP_DATA_FIRST_FRAG 0x02
+#define SCTP_DATA_NOT_FRAG 0x03
+#define SCTP_DATA_UNORDERED 0x04
+
+#define SCTP_CRC_ENABLE_BIT 0x01 /* lower bit of reserved */
+
+#define isSCTPControl(a) (a->chunkID != SCTP_DATA)
+#define isSCTPData(a) (a->chunkID == SCTP_DATA)
+
+/* sctp parameter types for init/init-ack */
+
+#define SCTP_IPV4_PARAM_TYPE 0x0005
+#define SCTP_IPV6_PARAM_TYPE 0x0006
+#define SCTP_RESPONDER_COOKIE 0x0007
+#define SCTP_UNRECOG_PARAM 0x0008
+#define SCTP_COOKIE_PRESERVE 0x0009
+#define SCTP_HOSTNAME_VIA_DNS 0x000b
+#define SCTP_RESTRICT_ADDR_TO 0x000c
+
+#define SCTP_ECN_I_CAN_DO_ECN 0x8000
+#define SCTP_OPERATION_SUCCEED 0x4001
+#define SCTP_ERROR_NOT_EXECUTED 0x4002
+
+#define SCTP_UNRELIABLE_STRM 0xc000
+#define SCTP_ADD_IP_ADDRESS 0xc001
+#define SCTP_DEL_IP_ADDRESS 0xc002
+#define SCTP_STRM_FLOW_LIMIT 0xc003
+#define SCTP_PARTIAL_CSUM 0xc004
+#define SCTP_ERROR_CAUSE_TLV 0xc005
+#define SCTP_MIT_STACK_NAME 0xc006
+#define SCTP_SETADDRESS_PRIMARY 0xc007
+
+/* bits for TOS field */
+#define SCTP_ECT_BIT 0x02
+#define SCTP_CE_BIT 0x01
+
+/* error codes */
+#define SCTP_OP_ERROR_NO_ERROR 0x0000
+#define SCTP_OP_ERROR_INV_STRM 0x0001
+#define SCTP_OP_ERROR_MISS_PARAM 0x0002
+#define SCTP_OP_ERROR_STALE_COOKIE 0x0003
+#define SCTP_OP_ERROR_NO_RESOURCE 0x0004
+#define SCTP_OP_ERROR_DNS_FAILED 0x0005
+#define SCTP_OP_ERROR_UNK_CHUNK 0x0006
+#define SCTP_OP_ERROR_INV_PARAM 0x0007
+#define SCTP_OP_ERROR_UNK_PARAM 0x0008
+#define SCTP_OP_ERROR_NO_USERD 0x0009
+#define SCTP_OP_ERROR_COOKIE_SHUT 0x000a
+#define SCTP_OP_ERROR_DELETE_LAST 0x000b
+#define SCTP_OP_ERROR_RESOURCE_SHORT 0x000c
+
+#define SCTP_MAX_ERROR_CAUSE 12
+
+/* empty error causes i.e. nothing but the cause
+ * are SCTP_OP_ERROR_NO_RESOURCE, SCTP_OP_ERROR_INV_PARAM,
+ * SCTP_OP_ERROR_COOKIE_SHUT.
+ */
+
+/* parameter for Heart Beat */
+#define HEART_BEAT_PARAM 0x0001
+
+
+
+/* send options for SCTP
+ */
+#define SCTP_ORDERED_DELIVERY 0x01
+#define SCTP_NON_ORDERED_DELIVERY 0x02
+#define SCTP_DO_CRC16 0x08
+#define SCTP_MY_ADDRESS_ONLY 0x10
+
+/* below turns off above */
+#define SCTP_FLEXIBLE_ADDRESS 0x20
+#define SCTP_NO_HEARTBEAT 0x40
+
+/* mask to get sticky */
+#define SCTP_STICKY_OPTIONS_MASK 0x0c
+
+/* MTU discovery flags */
+#define SCTP_DONT_FRAGMENT 0x0100
+#define SCTP_FRAGMENT_OK 0x0200
+
+
+/* SCTP state defines for internal state machine */
+#define SCTP_STATE_EMPTY 0x0000
+#define SCTP_STATE_INUSE 0x0001
+#define SCTP_STATE_COOKIE_WAIT 0x0002
+#define SCTP_STATE_COOKIE_SENT 0x0004
+#define SCTP_STATE_OPEN 0x0008
+#define SCTP_STATE_SHUTDOWN 0x0010
+#define SCTP_STATE_SHUTDOWN_RECV 0x0020
+#define SCTP_STATE_SHUTDOWN_ACK_SENT 0x0040
+#define SCTP_STATE_SHUTDOWN_PEND 0x0080
+#define SCTP_STATE_MASK 0x007f
+/* SCTP reachability state for each address */
+#define SCTP_ADDR_NOT_REACHABLE 1
+#define SCTP_ADDR_REACHABLE 2
+#define SCTP_ADDR_NOHB 4
+#define SCTP_ADDR_BEING_DELETED 8
+
+/* How long a cookie lives */
+#define SCTP_DEFAULT_COOKIE_LIFE 60 /* seconds */
+
+/* resource limit of streams */
+#define MAX_SCTP_STREAMS 2048
+
+
+/* guess at how big to make the TSN mapping array */
+#define SCTP_STARTING_MAPARRAY 10000
+
+/* Here we define the timer types used
+ * by the implementation has
+ * arguments in the set/get timer type calls.
+ */
+#define SCTP_TIMER_INIT 0
+#define SCTP_TIMER_RECV 1
+#define SCTP_TIMER_SEND 2
+#define SCTP_TIMER_SHUTDOWN 3
+#define SCTP_TIMER_HEARTBEAT 4
+#define SCTP_TIMER_PMTU 5
+/* number of timer types in the base SCTP
+ * structure used in the set/get and has
+ * the base default.
+ */
+#define SCTP_NUM_TMRS 6
+
+
+
+#define SCTP_IPV4_ADDRESS 2
+#define SCTP_IPV6_ADDRESS 4
+
+/* timer types */
+#define SctpTimerTypeNone 0
+#define SctpTimerTypeSend 1
+#define SctpTimerTypeInit 2
+#define SctpTimerTypeRecv 3
+#define SctpTimerTypeShutdown 4
+#define SctpTimerTypeHeartbeat 5
+#define SctpTimerTypeCookie 6
+#define SctpTimerTypeNewCookie 7
+#define SctpTimerTypePathMtuRaise 8
+#define SctpTimerTypeShutdownAck 9
+#define SctpTimerTypeRelReq 10
+
+/* Here are the timer directives given to the
+ * user provided function
+ */
+#define SCTP_TIMER_START 1
+#define SCTP_TIMER_STOP 2
+
+/* running flag states in timer structure */
+#define SCTP_TIMER_IDLE 0x0
+#define SCTP_TIMER_EXPIRED 0x1
+#define SCTP_TIMER_RUNNING 0x2
+
+
+/* number of simultaneous timers running */
+#define SCTP_MAX_NET_TIMERS 6 /* base of where net timers start */
+#define SCTP_NUMBER_TIMERS 12 /* allows up to 6 destinations */
+
+
+/* Of course we really don't collect stale cookies, being
+ * folks of decerning taste. However we do count them, if
+ * we get to many before the association comes up.. we
+ * give up. Below is the constant that dictates when
+ * we give it up...this is a implemenation dependant
+ * treatment. In ours we do not ask for a extension of
+ * time, but just retry this many times...
+ */
+#define SCTP_MAX_STALE_COOKIES_I_COLLECT 10
+
+/* max number of TSN's dup'd that I will hold */
+#define SCTP_MAX_DUP_TSNS 20
+
+/* Here we define the types used when
+ * setting the retry ammounts.
+ */
+/* constants for type of set */
+#define SCTP_MAXATTEMPT_INIT 2
+#define SCTP_MAXATTEMPT_SEND 3
+
+/* Here we define the default timers and the
+ * default number of attemts we make for
+ * each respective side (send/init).
+ */
+
+/* init timer def = 3sec */
+#define SCTP_INIT_SEC 3
+#define SCTP_INIT_NSEC 0
+
+/* send timer def = 3 seconds */
+#define SCTP_SEND_SEC 1
+#define SCTP_SEND_NSEC 0
+
+/* recv timer def = 200ms (in nsec) */
+#define SCTP_RECV_SEC 0
+#define SCTP_RECV_NSEC 200000000
+
+/* 30 seconds + RTO */
+#define SCTP_HB_SEC 30
+#define SCTP_HB_NSEC 0
+
+
+/* 300 ms */
+#define SCTP_SHUTDOWN_SEC 0
+#define SCTP_SHUTDOWN_NSEC 300000000
+
+#define SCTP_RTO_UPPER_BOUND 60000000 /* 60 sec in micro-second's */
+#define SCTP_RTO_UPPER_BOUND_SEC 60 /* for the init timer */
+#define SCTP_RTO_LOWER_BOUND 1000000 /* 1 sec in micro-sec's */
+
+#define SCTP_DEF_MAX_INIT 8
+#define SCTP_DEF_MAX_SEND 10
+
+#define SCTP_DEF_PMTU_RAISE 600 /* 10 Minutes between raise attempts */
+#define SCTP_DEF_PMTU_MIN 600
+
+#define SCTP_MSEC_IN_A_SEC 1000
+#define SCTP_USEC_IN_A_SEC 1000000
+#define SCTP_NSEC_IN_A_SEC 1000000000
+
+
+/* Events that SCTP will look for, these
+ * are or'd together to declare what SCTP
+ * wants. Each select mask/poll list should be
+ * set for the fd, if the bit is on.
+ */
+#define SCTP_EVENT_READ 0x000001
+#define SCTP_EVENT_WRITE 0x000002
+#define SCTP_EVENT_EXCEPT 0x000004
+
+/* The following constant is a value for this
+ * particular implemenation. It is quite arbitrary and
+ * is used to limit how much data will be queued up to
+ * a sender, waiting for cwnd to be larger than flightSize.
+ * All implementations will need this protection is some
+ * way due to buffer size constraints.
+ */
+
+#define SCTP_MAX_OUTSTANDING_DG 10000
+
+
+
+/* This constant (SCTP_MAX_READBUFFER) define
+ * how big the read/write buffer is
+ * when we enter the fd event notification
+ * the buffer is put on the stack, so the bigger
+ * it is the more stack you chew up, however it
+ * has got to be big enough to handle the bigest
+ * message this O/S will send you. In solaris
+ * with sockets (not TLI) we end up at a value
+ * of 64k. In TLI we could do partial reads to
+ * get it all in with less hassel.. but we
+ * write to sockets for generality.
+ */
+#define SCTP_MAX_READBUFFER 65536
+#define SCTP_ADDRMAX 60
+
+/* amount peer is obligated to have in rwnd or
+ * I will abort
+ */
+#define SCTP_MIN_RWND 1500
+
+#define SCTP_WINDOW_MIN 1500 /* smallest rwnd can be */
+#define SCTP_WINDOW_MAX 1048576 /* biggest I can grow rwnd to
+ * My playing around suggests a
+ * value greater than 64k does not
+ * do much, I guess via the kernel
+ * limitations on the stream/socket.
+ */
+
+#define SCTP_MAX_BUNDLE_UP 256 /* max number of chunks I can bundle */
+
+/* I can handle a 1meg re-assembly */
+#define SCTP_DEFAULT_MAXMSGREASM 1048576
+
+
+#define SCTP_DEFAULT_MAXWINDOW 32768 /* default rwnd size */
+#define SCTP_DEFAULT_MAXSEGMENT 1500 /* MTU size, this is the default
+ * to which we set the smallestMTU
+ * size to. This governs what is the
+ * largest size we will use, of course
+ * PMTU will raise this up to
+ * the largest interface MTU or the
+ * ceiling below if there is no
+ * SIOCGIFMTU.
+ */
+#ifdef LYNX
+#define DEFAULT_MTU_CEILING 1500 /* Since Lynx O/S is brain dead
+ * in the way it handles the
+ * raw IP socket, insisting
+ * on makeing its own IP
+ * header, we limit the growth
+ * to that of the e-net size
+ */
+#else
+#define DEFAULT_MTU_CEILING 2048 /* If no SIOCGIFMTU, highest value
+ * to raise the PMTU to, i.e.
+ * don't try to raise above this
+ * value. Tune this per your
+ * largest MTU interface if your
+ * system does not support the
+ * SIOCGIFMTU ioctl.
+ */
+#endif
+#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */
+#define SCTP_HOW_MANY_SECRETS 2 /* how many secrets I keep */
+/* This is how long a secret lives, NOT how long a cookie lives */
+#define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* how many seconds the current secret will live */
+
+#define SCTP_NUMBER_OF_SECRETS 8 /* or 8 * 4 = 32 octets */
+#define SCTP_SECRET_SIZE 32 /* number of octets in a 256 bits */
+
+#ifdef USE_MD5
+#define SCTP_SIGNATURE_SIZE 16 /* size of a MD5 signature */
+#else
+#define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */
+#endif
+/* Here are the notification constants
+ * that the code and upper layer will get
+ */
+
+/* association is up */
+#define SCTP_NOTIFY_ASSOC_UP 1
+
+/* association is down */
+#define SCTP_NOTIFY_ASSOC_DOWN 2
+
+/* interface on a association is down
+ * and out of consideration for selection.
+ */
+#define SCTP_NOTIFY_INTF_DOWN 3
+
+/* interface on a association is up
+ * and now back in consideration for selection.
+ */
+#define SCTP_NOTIFY_INTF_UP 4
+
+/* The given datagram cannot be delivered
+ * to the peer, this will probably be followed
+ * by a SCTP_NOTFIY_ASSOC_DOWN.
+ */
+#define SCTP_NOTIFY_DG_FAIL 5
+
+/* Sent dg on non-open stream extreme code error!
+ */
+#define SCTP_NOTIFY_STRDATA_ERR 6
+
+#define SCTP_NOTIFY_ASSOC_ABORTED 7
+
+/* The stream ones are not used yet, but could
+ * be when a association opens.
+ */
+#define SCTP_NOTIFY_PEER_OPENED_STR 8
+#define SCTP_NOTIFY_STREAM_OPENED_OK 9
+
+/* association sees a restart event */
+#define SCTP_NOTIFY_ASSOC_RESTART 10
+
+/* a user requested HB returned */
+#define SCTP_NOTIFY_HB_RESP 11
+
+/* a result from a REL-REQ */
+#define SCTP_NOTIFY_RELREQ_RESULT_OK 12
+#define SCTP_NOTIFY_RELREQ_RESULT_FAILED 13
+
+/* clock variance is 10ms or 10,000 us's */
+#define SCTP_CLOCK_GRAINULARITY 10000
+
+#define IP_HDR_SIZE 40 /* we use the size of a IP6 header here
+ * this detracts a small amount for ipv4
+ * but it simplifies the ipv6 addition
+ */
+
+#define SCTP_NUM_FDS 3
+
+/* raw IP filedescriptor */
+#define SCTP_FD_IP 0
+/* raw ICMP filedescriptor */
+#define SCTP_FD_ICMP 1
+/* processes contact me for requests here */
+#define SCTP_REQUEST 2
+
+
+#define SCTP_DEAMON_PORT 9899
+
+
+#ifndef IPPROTO_SCTP
+#define IPPROTO_SCTP 132 /* the Official IANA number :-) */
+#endif
+
+/* Deamon registration message types/responses */
+#define DEAMON_REGISTER 0x01
+#define DEAMON_REGISTER_ACK 0x02
+#define DEAMON_DEREGISTER 0x03
+#define DEAMON_DEREGISTER_ACK 0x04
+#define DEAMON_CHECKADDR_LIST 0x05
+
+#define DEAMON_MAGIC_VER_LEN 0xff
+
+/* max times I will attempt to send a message to deamon */
+#define SCTP_MAX_ATTEMPTS_AT_DEAMON 5
+#define SCTP_TIMEOUT_IN_POLL_FOR_DEAMON 1500 /* 1.5 seconds */
+
+/* modular comparison */
+/* True if a > b (mod = M) */
+#define compare_with_wrap(a, b, M) ((a > b) && ((a - b) < (M >> 1))) || \
+ ((b > a) && ((b - a) > (M >> 1)))
+
+#ifndef TIMEVAL_TO_TIMESPEC
+#define TIMEVAL_TO_TIMESPEC(tv, ts) \
+{ \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#endif
+
+/* pegs */
+#define SCTP_NUMBER_OF_PEGS 21
+/* peg index's */
+#define SCTP_PEG_SACKS_SEEN 0
+#define SCTP_PEG_SACKS_SENT 1
+#define SCTP_PEG_TSNS_SENT 2
+#define SCTP_PEG_TSNS_RCVD 3
+#define SCTP_DATAGRAMS_SENT 4
+#define SCTP_DATAGRAMS_RCVD 5
+#define SCTP_RETRANTSN_SENT 6
+#define SCTP_DUPTSN_RECVD 7
+#define SCTP_HBR_RECV 8
+#define SCTP_HBA_RECV 9
+#define SCTP_HB_SENT 10
+#define SCTP_DATA_DG_SENT 11
+#define SCTP_DATA_DG_RECV 12
+#define SCTP_TMIT_TIMER 13
+#define SCTP_RECV_TIMER 14
+#define SCTP_HB_TIMER 15
+#define SCTP_FAST_RETRAN 16
+#define SCTP_PEG_TSNS_READ 17
+#define SCTP_NONE_LFT_TO 18
+#define SCTP_NONE_LFT_RWND 19
+#define SCTP_NONE_LFT_CWND 20
+
+
+
+#endif
+
diff --git a/contrib/tcpdump/sctpHeader.h b/contrib/tcpdump/sctpHeader.h
new file mode 100644
index 000000000000..b4a131a59a48
--- /dev/null
+++ b/contrib/tcpdump/sctpHeader.h
@@ -0,0 +1,323 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.3 2001/08/01 03:34:00 guy Exp $ (LBL) */
+
+/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
+ *
+ * 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.
+ *
+ * 4. Neither the name of Cisco nor of Motorola 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.
+ *
+ * This file is part of the SCTP reference Implementation
+ *
+ *
+ * Please send any bug reports or fixes you make to one of the following email
+ * addresses:
+ *
+ * rstewar1@email.mot.com
+ * kmorneau@cisco.com
+ * qxie1@email.mot.com
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorperated into the next SCTP release.
+ */
+
+
+#ifndef __sctpHeader_h__
+#define __sctpHeader_h__
+
+#include <sctpConstants.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* the sctp common header */
+
+#ifdef TRU64
+ #define _64BITS 1
+#endif
+
+struct sctpHeader{
+ u_short source;
+ u_short destination;
+ u_int verificationTag;
+ u_int adler32;
+};
+
+/* various descriptor parsers */
+
+struct sctpChunkDesc{
+ u_char chunkID;
+ u_char chunkFlg;
+ u_short chunkLength;
+};
+
+struct sctpParamDesc{
+ u_short paramType;
+ u_short paramLength;
+};
+
+
+struct sctpRelChunkDesc{
+ struct sctpChunkDesc chk;
+ u_int serialNumber;
+};
+
+struct sctpVendorSpecificParam {
+ struct sctpParamDesc p; /* type must be 0xfffe */
+ u_int vendorId; /* vendor ID from RFC 1700 */
+ u_short vendorSpecificType;
+ u_short vendorSpecificLen;
+};
+
+
+/* Structures for the control parts */
+
+
+
+/* Sctp association init request/ack */
+
+/* this is used for init ack, too */
+struct sctpInitiation{
+ u_int initTag; /* tag of mine */
+ u_int rcvWindowCredit; /* rwnd */
+ u_short NumPreopenStreams; /* OS */
+ u_short MaxInboundStreams; /* MIS */
+ u_int initialTSN;
+ /* optional param's follow in sctpParamDesc form */
+};
+
+struct sctpV4IpAddress{
+ struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
+ u_int ipAddress;
+};
+
+
+struct sctpV6IpAddress{
+ struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
+ u_char ipAddress[16];
+};
+
+struct sctpDNSName{
+ struct sctpParamDesc param;
+ u_char name[1];
+};
+
+
+struct sctpCookiePreserve{
+ struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */
+ u_int extraTime;
+};
+
+
+struct sctpTimeStamp{
+ u_int ts_sec;
+ u_int ts_usec;
+};
+
+/* wire structure of my cookie */
+struct cookieMessage{
+ u_int TieTag_curTag; /* copied from assoc if present */
+ u_int TieTag_hisTag; /* copied from assoc if present */
+ int cookieLife; /* life I will award this cookie */
+ struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
+ struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */
+ u_int addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */
+ int addrtype; /* address type */
+ u_short locScope; /* V6 local scope flag */
+ u_short siteScope; /* V6 site scope flag */
+ /* at the end is tacked on the INIT chunk sent in
+ * its entirety and of course our
+ * signature.
+ */
+};
+
+
+/* this guy is for use when
+ * I have a initiate message gloming the
+ * things together.
+
+ */
+struct sctpUnifiedInit{
+ struct sctpChunkDesc uh;
+ struct sctpInitiation initm;
+};
+
+struct sctpSendableInit{
+ struct sctpHeader mh;
+ struct sctpUnifiedInit msg;
+};
+
+
+/* Selective Acknowledgement
+ * has the following structure with
+ * a optional ammount of trailing int's
+ * on the last part (based on the numberOfDesc
+ * field).
+ */
+
+struct sctpSelectiveAck{
+ u_int highestConseqTSN;
+ u_int updatedRwnd;
+ u_short numberOfdesc;
+ u_short numDupTsns;
+};
+
+struct sctpSelectiveFrag{
+ u_short fragmentStart;
+ u_short fragmentEnd;
+};
+
+
+struct sctpUnifiedSack{
+ struct sctpChunkDesc uh;
+ struct sctpSelectiveAck sack;
+};
+
+/* for both RTT request/response the
+ * following is sent
+ */
+
+struct sctpHBrequest {
+ u_int time_value_1;
+ u_int time_value_2;
+};
+
+/* here is what I read and respond with to. */
+struct sctpHBunified{
+ struct sctpChunkDesc hdr;
+ struct sctpParamDesc hb;
+};
+
+
+/* here is what I send */
+struct sctpHBsender{
+ struct sctpChunkDesc hdr;
+ struct sctpParamDesc hb;
+ struct sctpHBrequest rtt;
+ char addrFmt[SCTP_ADDRMAX];
+ unsigned short userreq;
+};
+
+
+
+/* for the abort and shutdown ACK
+ * we must carry the init tag in the common header. Just the
+ * common header is all that is needed with a chunk descriptor.
+ */
+struct sctpUnifiedAbort{
+ struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortLight{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortHeavy{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ unsigned short causeCode;
+ unsigned short causeLen;
+};
+
+/* For the graceful shutdown we must carry
+ * the tag (in common header) and the highest consequitive acking value
+ */
+struct sctpShutdown {
+ u_int TSN_Seen;
+};
+
+struct sctpUnifiedShutdown{
+ struct sctpChunkDesc uh;
+ struct sctpShutdown shut;
+};
+
+/* in the unified message we add the trailing
+ * stream id since it is the only message
+ * that is defined as a operation error.
+ */
+struct sctpOpErrorCause{
+ u_short cause;
+ u_short causeLen;
+};
+
+struct sctpUnifiedOpError{
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+};
+
+struct sctpUnifiedStreamError{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+ u_short strmNum;
+ u_short reserved;
+};
+
+struct staleCookieMsg{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+ u_int moretime;
+};
+
+/* the following is used in all sends
+ * where nothing is needed except the
+ * chunk/type i.e. shutdownAck Abort */
+
+struct sctpUnifiedSingleMsg{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+};
+
+struct sctpDataPart{
+ u_int TSN;
+ u_short streamId;
+ u_short sequence;
+ u_int payloadtype;
+};
+
+struct sctpUnifiedDatagram{
+ struct sctpChunkDesc uh;
+ struct sctpDataPart dp;
+};
+
+struct sctpECN_echo{
+ struct sctpChunkDesc uh;
+ u_int Lowest_TSN;
+};
+
+
+struct sctpCWR{
+ struct sctpChunkDesc uh;
+ u_int TSN_reduced_at;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/contrib/tcpdump/smb.h b/contrib/tcpdump/smb.h
index 63be64bd43ab..3c5ba7d89e38 100644
--- a/contrib/tcpdump/smb.h
+++ b/contrib/tcpdump/smb.h
@@ -1,44 +1,13 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.7 2002/01/17 04:38:29 guy Exp $ (LBL) */
/*
- Copyright (C) Andrew Tridgell 1995-1999
+ * Copyright (C) Andrew Tridgell 1995-1999
+ *
+ * This software may be distributed either under the terms of the
+ * BSD-style license that accompanies tcpdump or the GNU GPL version 2
+ * or later
+ */
- This software may be distributed either under the terms of the
- BSD-style license that accompanies tcpdump or the GNU GPL version 2
- or later */
-
-#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
-#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
-#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
-
-#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
-#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
-#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
-#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
-#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
-#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
-#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
-#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
-#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
-#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
-
-/* now the reverse routines - these are used in nmb packets (mostly) */
-#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
-#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
-
-#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
-#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
-#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
-#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
-
-#define uint16 unsigned short
-#define uint32 unsigned int
-#ifndef uchar
-#define uchar unsigned char
-#endif
-
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
+#define SMBMIN(a,b) ((a)<(b)?(a):(b))
/* the complete */
#define SMBmkdir 0x00 /* create directory */
@@ -147,7 +116,7 @@
#define TRANSACT2_FINDNOTIFYNEXT 12
#define TRANSACT2_MKDIR 13
-#define PTR_DIFF(p1,p2) ((unsigned long)(((char *)(p1)) - (char *)(p2)))
+#define PTR_DIFF(p1, p2) ((size_t)(((char *)(p1)) - (char *)(p2)))
/* some protos */
-const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf);
+const u_char *smb_fdata(const u_char *, const char *, const u_char *);
diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c
index 898345d5c1ef..756a8d2f4d18 100644
--- a/contrib/tcpdump/smbutil.c
+++ b/contrib/tcpdump/smbutil.c
@@ -1,9 +1,10 @@
-/*
- Copyright (C) Andrew Tridgell 1995-1999
-
- This software may be distributed either under the terms of the
- BSD-style license that accompanies tcpdump or the GNU GPL version 2
- or later */
+/*
+ * Copyright (C) Andrew Tridgell 1995-1999
+ *
+ * This software may be distributed either under the terms of the
+ * BSD-style license that accompanies tcpdump or the GNU GPL version 2
+ * or later
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -11,7 +12,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.12 2000/12/04 00:35:45 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.18 2002/01/17 04:38:29 guy Exp $";
#endif
#include <sys/param.h>
@@ -19,7 +20,6 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
-
#include <netinet/in.h>
#include <ctype.h>
@@ -29,729 +29,815 @@ static const char rcsid[] =
#include <time.h>
#include "interface.h"
+#include "extract.h"
#include "smb.h"
-extern const uchar *startbuf;
+extern const u_char *startbuf;
-/*******************************************************************
- interpret a 32 bit dos packed date/time to some parameters
-********************************************************************/
-static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *hour,int *minute,int *second)
+/*
+ * interpret a 32 bit dos packed date/time to some parameters
+ */
+static void
+interpret_dos_date(u_int32_t date, struct tm *tp)
{
- uint32 p0,p1,p2,p3;
-
- p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
- p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
-
- *second = 2*(p0 & 0x1F);
- *minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3);
- *hour = (p1>>3)&0xFF;
- *day = (p2&0x1F);
- *month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1;
- *year = ((p3>>1)&0xFF) + 80;
+ u_int32_t p0, p1, p2, p3;
+
+ p0 = date & 0xFF;
+ p1 = ((date & 0xFF00) >> 8) & 0xFF;
+ p2 = ((date & 0xFF0000) >> 16) & 0xFF;
+ p3 = ((date & 0xFF000000) >> 24) & 0xFF;
+
+ tp->tm_sec = 2 * (p0 & 0x1F);
+ tp->tm_min = ((p0 >> 5) & 0xFF) + ((p1 & 0x7) << 3);
+ tp->tm_hour = (p1 >> 3) & 0xFF;
+ tp->tm_mday = (p2 & 0x1F);
+ tp->tm_mon = ((p2 >> 5) & 0xFF) + ((p3 & 0x1) << 3) - 1;
+ tp->tm_year = ((p3 >> 1) & 0xFF) + 80;
}
-/*******************************************************************
- create a unix date from a dos date
-********************************************************************/
-static time_t make_unix_date(const void *date_ptr)
+/*
+ * common portion:
+ * create a unix date from a dos date
+ */
+static time_t
+int_unix_date(u_int32_t dos_date)
{
- uint32 dos_date=0;
- struct tm t;
+ struct tm t;
- dos_date = IVAL(date_ptr,0);
+ if (dos_date == 0)
+ return(0);
- if (dos_date == 0) return(0);
-
- interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
- &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
- t.tm_wday = 1;
- t.tm_yday = 1;
- t.tm_isdst = 0;
+ interpret_dos_date(dos_date, &t);
+ t.tm_wday = 1;
+ t.tm_yday = 1;
+ t.tm_isdst = 0;
- return (mktime(&t));
+ return (mktime(&t));
}
-/*******************************************************************
- create a unix date from a dos date
-********************************************************************/
-static time_t make_unix_date2(const void *date_ptr)
+/*
+ * create a unix date from a dos date
+ * in network byte order
+ */
+static time_t
+make_unix_date(const u_char *date_ptr)
{
- uint32 x,x2;
+ u_int32_t dos_date = 0;
- x = IVAL(date_ptr,0);
- x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
- SIVAL(&x,0,x2);
+ dos_date = EXTRACT_LE_32BITS(date_ptr);
- return(make_unix_date((void *)&x));
+ return int_unix_date(dos_date);
}
-/****************************************************************************
-interpret an 8 byte "filetime" structure to a time_t
-It's originally in "100ns units since jan 1st 1601"
-****************************************************************************/
-static time_t interpret_long_date(const char *p)
+/*
+ * create a unix date from a dos date
+ * in halfword-swapped network byte order!
+ */
+static time_t
+make_unix_date2(const u_char *date_ptr)
{
- double d;
- time_t ret;
+ u_int32_t x, x2;
- /* this gives us seconds since jan 1st 1601 (approx) */
- d = (IVAL(p,4)*256.0 + CVAL(p,3)) * (1.0e-7 * (1<<24));
-
- /* now adjust by 369 years to make the secs since 1970 */
- d -= 369.0*365.25*24*60*60;
+ x = EXTRACT_LE_32BITS(date_ptr);
+ x2 = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16);
+ return int_unix_date(x2);
+}
- /* and a fudge factor as we got it wrong by a few days */
- d += (3*24*60*60 + 6*60*60 + 2);
+/*
+ * interpret an 8 byte "filetime" structure to a time_t
+ * It's originally in "100ns units since jan 1st 1601"
+ */
+static time_t
+interpret_long_date(const u_char *p)
+{
+ double d;
+ time_t ret;
- if (d<0)
- return(0);
+ TCHECK2(p[4], 4);
- ret = (time_t)d;
+ /* this gives us seconds since jan 1st 1601 (approx) */
+ d = (EXTRACT_LE_32BITS(p + 4) * 256.0 + p[3]) * (1.0e-7 * (1 << 24));
- return(ret);
-}
+ /* now adjust by 369 years to make the secs since 1970 */
+ d -= 369.0 * 365.25 * 24 * 60 * 60;
+ /* and a fudge factor as we got it wrong by a few days */
+ d += (3 * 24 * 60 * 60 + 6 * 60 * 60 + 2);
-/****************************************************************************
-interpret the weird netbios "name". Return the name type, or -1 if
-we run past the end of the buffer
-****************************************************************************/
-static int name_interpret(const uchar *in,const uchar *maxbuf,char *out)
-{
- int ret;
- int len;
+ if (d < 0)
+ return(0);
- if (in >= maxbuf)
- return(-1); /* name goes past the end of the buffer */
- TCHECK2(*in, 1);
- len = (*in++) / 2;
+ ret = (time_t)d;
- *out=0;
+ return(ret);
+trunc:
+ return(0);
+}
- if (len > 30 || len<1) return(0);
+/*
+ * interpret the weird netbios "name". Return the name type, or -1 if
+ * we run past the end of the buffer
+ */
+static int
+name_interpret(const u_char *in, const u_char *maxbuf, char *out)
+{
+ int ret;
+ int len;
- while (len--)
- {
- if (in + 1 >= maxbuf)
+ if (in >= 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;
+ TCHECK2(*in, 1);
+ len = (*in++) / 2;
+
+ *out=0;
+
+ if (len > 30 || len < 1)
return(0);
- }
- *out = ((in[0]-'A')<<4) + (in[1]-'A');
- in += 2;
- out++;
+
+ while (len--) {
+ TCHECK2(*in, 2);
+ if (in + 1 >= maxbuf)
+ return(-1); /* name goes past the end of the buffer */
+ if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
+ *out = 0;
+ return(0);
+ }
+ *out = ((in[0] - 'A') << 4) + (in[1] - 'A');
+ in += 2;
+ out++;
}
- *out = 0;
- ret = out[-1];
+ *out = 0;
+ ret = out[-1];
- return(ret);
+ return(ret);
trunc:
- return(-1);
+ return(-1);
}
-/****************************************************************************
-find a pointer to a netbios name
-****************************************************************************/
-static const uchar *name_ptr(const uchar *buf,int ofs,const uchar *maxbuf)
+/*
+ * find a pointer to a netbios name
+ */
+static const u_char *
+name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
{
- const uchar *p;
- uchar c;
+ const u_char *p;
+ u_char 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)
+ p = buf + ofs;
+ if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
- TCHECK2(*p, 1);
- return(buf + l);
- }
- else
- return(buf+ofs);
+ TCHECK2(*p, 1);
+
+ c = *p;
+
+ /* XXX - this should use the same code that the DNS dissector does */
+ if ((c & 0xC0) == 0xC0) {
+ u_int16_t l = EXTRACT_16BITS(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 */
-}
+ return(NULL); /* name goes past the end of the buffer */
+}
-/****************************************************************************
-extract a netbios name from a buf
-****************************************************************************/
-static int name_extract(const uchar *buf,int ofs,const uchar *maxbuf,char *name)
+/*
+ * extract a netbios name from a buf
+ */
+static int
+name_extract(const u_char *buf, int ofs, const u_char *maxbuf, char *name)
{
- 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,maxbuf,name));
-}
-
-
-/****************************************************************************
-return the total storage length of a mangled name
-****************************************************************************/
-static int name_len(const unsigned char *s, const unsigned char *maxbuf)
+ const u_char *p = name_ptr(buf, ofs, maxbuf);
+ if (p == NULL)
+ return(-1); /* error (probably name going past end of buffer) */
+ name[0] = '\0';
+ return(name_interpret(p, maxbuf, name));
+}
+
+
+/*
+ * return the total storage length of a mangled name
+ */
+static int
+name_len(const unsigned char *s, const unsigned char *maxbuf)
{
- const unsigned char *s0 = s;
- unsigned char c;
+ 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)
- {
- if (s >= maxbuf)
+ if (s >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- TCHECK2(*s, 1);
- s += (*s)+1;
+ TCHECK2(*s, 1);
+ c = *s;
+ if ((c & 0xC0) == 0xC0)
+ 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);
+ return(PTR_DIFF(s, s0) + 1);
trunc:
- return(-1); /* name goes past the end of the buffer */
+ return(-1); /* name goes past the end of the buffer */
}
-static void print_asc(const unsigned char *buf,int len)
+static void
+print_asc(const unsigned char *buf, int len)
{
- int i;
- for (i=0;i<len;i++)
- printf("%c",isprint(buf[i])?buf[i]:'.');
+ int i;
+ for (i = 0; i < len; i++)
+ safeputchar(buf[i]);
}
-static char *name_type_str(int name_type)
+static char *
+name_type_str(int name_type)
{
- static char *f = NULL;
- switch (name_type) {
- case 0: f = "Workstation"; break;
- case 0x03: f = "Client?"; break;
- case 0x20: f = "Server"; break;
- case 0x1d: f = "Master Browser"; break;
- case 0x1b: f = "Domain Controller"; break;
- case 0x1e: f = "Browser Server"; break;
- default: f = "Unknown"; break;
- }
- return(f);
+ char *f = NULL;
+
+ switch (name_type) {
+ case 0: f = "Workstation"; break;
+ case 0x03: f = "Client?"; break;
+ case 0x20: f = "Server"; break;
+ case 0x1d: f = "Master Browser"; break;
+ case 0x1b: f = "Domain Controller"; break;
+ case 0x1e: f = "Browser Server"; break;
+ default: f = "Unknown"; break;
+ }
+ return(f);
}
-void print_data(const unsigned char *buf, int len)
+void
+print_data(const unsigned char *buf, int len)
{
- int i=0;
- if (len<=0) return;
- printf("[%03X] ",i);
- for (i=0;i<len;) {
- printf("%02X ",(int)buf[i]);
- i++;
- if (i%8 == 0) printf(" ");
- if (i%16 == 0) {
- print_asc(&buf[i-16],8); printf(" ");
- print_asc(&buf[i-8],8); printf("\n");
- if (i<len) printf("[%03X] ",i);
+ int i = 0;
+
+ if (len <= 0)
+ return;
+ printf("[%03X] ", i);
+ for (i = 0; i < len; /*nothing*/) {
+ printf("%02X ", buf[i] & 0xff);
+ i++;
+ if (i%8 == 0)
+ printf(" ");
+ if (i % 16 == 0) {
+ print_asc(&buf[i - 16], 8);
+ printf(" ");
+ print_asc(&buf[i - 8], 8);
+ printf("\n");
+ if (i < len)
+ printf("[%03X] ", i);
+ }
+ }
+ if (i % 16) {
+ int n;
+
+ n = 16 - (i % 16);
+ printf(" ");
+ if (n>8)
+ printf(" ");
+ while (n--)
+ printf(" ");
+
+ n = SMBMIN(8, i % 16);
+ print_asc(&buf[i - (i % 16)], n);
+ printf(" ");
+ n = (i % 16) - n;
+ if (n > 0)
+ print_asc(&buf[i - n], n);
+ printf("\n");
}
- }
- if (i%16) {
- int n;
-
- n = 16 - (i%16);
- printf(" ");
- if (n>8) printf(" ");
- while (n--) printf(" ");
-
- n = MIN(8,i%16);
- print_asc(&buf[i-(i%16)],n); printf(" ");
- n = (i%16) - n;
- if (n>0) print_asc(&buf[i-n],n);
- printf("\n");
- }
}
-static void write_bits(unsigned int val,char *fmt)
+static void
+write_bits(unsigned int val, char *fmt)
{
- char *p = fmt;
- int i=0;
-
- while ((p=strchr(fmt,'|'))) {
- int l = PTR_DIFF(p,fmt);
- if (l && (val & (1<<i)))
- printf("%.*s ",l,fmt);
- fmt = p+1;
- i++;
- }
+ char *p = fmt;
+ int i = 0;
+
+ while ((p = strchr(fmt, '|'))) {
+ size_t l = PTR_DIFF(p, fmt);
+ if (l && (val & (1 << i)))
+ printf("%.*s ", (int)l, fmt);
+ fmt = p + 1;
+ i++;
+ }
}
-/* convert a unicode string */
-static const char *unistr(const char *s, int *len)
+/* convert a UCS2 string into iso-8859-1 string */
+static const char *
+unistr(const char *s, int *len)
{
- static char buf[1000];
- int l=0;
- static int use_unicode = -1;
-
- if (use_unicode == -1) {
- char *p = getenv("USE_UNICODE");
- if (p && (atoi(p) == 1))
- use_unicode = 1;
- else
- use_unicode = 0;
- }
+ static char buf[1000];
+ int l=0;
+ static int use_unicode = -1;
+
+ if (use_unicode == -1) {
+ char *p = getenv("USE_UNICODE");
+ if (p && (atoi(p) == 1))
+ use_unicode = 1;
+ else
+ use_unicode = 0;
+ }
- /* maybe it isn't unicode - a cheap trick */
- if (!use_unicode || (s[0] && s[1])) {
- *len = strlen(s)+1;
- return s;
- }
+ /* maybe it isn't unicode - a cheap trick */
+ if (!use_unicode || (s[0] && s[1])) {
+ *len = strlen(s) + 1;
+ return s;
+ }
- *len = 0;
+ *len = 0;
- if (s[0] == 0 && s[1] != 0) {
- s++;
- *len = 1;
- }
+ if (s[0] == 0 && s[1] != 0) {
+ s++;
+ *len = 1;
+ }
- while (l < (sizeof(buf)-1) && s[0] && s[1] == 0) {
- buf[l] = s[0];
- s += 2; l++;
- *len += 2;
- }
- buf[l] = 0;
+ while (l < (sizeof(buf) - 1) && s[0] && s[1] == 0) {
+ buf[l] = s[0];
+ s += 2;
+ l++;
*len += 2;
- return buf;
+ }
+ buf[l] = 0;
+ *len += 2;
+ return buf;
}
-static const uchar *fdata1(const uchar *buf, const char *fmt, const uchar *maxbuf)
+static const u_char *
+smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf)
{
- int reverse=0;
- char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
- int len;
-
- while (*fmt && buf<maxbuf) {
- switch (*fmt) {
- case 'a':
- write_bits(CVAL(buf,0),attrib_fmt);
- buf++; fmt++;
- break;
-
- case 'A':
- write_bits(SVAL(buf,0),attrib_fmt);
- buf+=2; fmt++;
- break;
-
- case '{':
- {
- char bitfmt[128];
- char *p = strchr(++fmt,'}');
- int l = PTR_DIFF(p,fmt);
- strncpy(bitfmt,fmt,l);
- bitfmt[l]=0;
- fmt = p+1;
- write_bits(CVAL(buf,0),bitfmt);
- buf++;
- break;
- }
-
- case 'P':
- {
- int l = atoi(fmt+1);
- buf += l;
- fmt++;
- while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'r':
- reverse = !reverse;
- fmt++;
- break;
- case 'D':
- {
- unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
- printf("%d (0x%x)",x, x);
- buf += 4;
- fmt++;
- break;
- }
- case 'L':
- {
- unsigned int x1 = reverse?RIVAL(buf,0):IVAL(buf,0);
- unsigned int x2 = reverse?RIVAL(buf,4):IVAL(buf,4);
- if (x2) {
- printf("0x%08x:%08x",x2, x1);
- } else {
- printf("%d (0x%08x%08x)",x1, x2, x1);
- }
- buf += 8;
- fmt++;
- break;
- }
- case 'd':
- {
- unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
- printf("%d (0x%x)",x, x);
- buf += 2;
- fmt++;
- break;
- }
- case 'W':
- {
- unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
- printf("0x%X",x);
- buf += 4;
- fmt++;
- break;
- }
- case 'w':
- {
- unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
- printf("0x%X",x);
- buf += 2;
- fmt++;
- break;
- }
- case 'B':
- {
- unsigned int x = CVAL(buf,0);
- printf("0x%X",x);
- buf += 1;
- fmt++;
- break;
- }
- case 'b':
- {
- unsigned int x = CVAL(buf,0);
- printf("%d (0x%x)",x, x);
- buf += 1;
- fmt++;
- break;
- }
- case 'S':
- {
- printf("%.*s",(int)PTR_DIFF(maxbuf,buf),unistr(buf, &len));
- buf += len;
- fmt++;
- break;
- }
- case 'Z':
- {
- if (*buf != 4 && *buf != 2)
- printf("Error! ASCIIZ buffer of type %d (safety=%d)\n",
- *buf,(int)PTR_DIFF(maxbuf,buf));
- printf("%.*s",(int)PTR_DIFF(maxbuf,buf+1),unistr(buf+1, &len));
- buf += len+1;
- fmt++;
- break;
- }
- case 's':
- {
- int l = atoi(fmt+1);
- printf("%-*.*s",l,l,buf);
- buf += l;
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'h':
- {
- int l = atoi(fmt+1);
- while (l--) printf("%02x",*buf++);
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'n':
- {
- 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),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;
- case 2:
- name_type = buf[15];
- printf("%-15.15s NameType=0x%02X (%s)",
- buf,name_type,name_type_str(name_type));
- buf += 16;
- break;
- }
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'T':
- {
- time_t t;
- int x = IVAL(buf,0);
- switch (atoi(fmt+1)) {
- case 1:
- if (x==0 || x==-1 || x==0xFFFFFFFF)
- t = 0;
- else
- t = make_unix_date(buf);
- buf+=4;
- break;
- case 2:
- if (x==0 || x==-1 || x==0xFFFFFFFF)
- t = 0;
- else
- t = make_unix_date2(buf);
- buf+=4;
- break;
- case 3:
- t = interpret_long_date(buf);
- buf+=8;
- break;
+ int reverse = 0;
+ char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
+ int len;
+
+ while (*fmt && buf<maxbuf) {
+ switch (*fmt) {
+ case 'a':
+ write_bits(buf[0], attrib_fmt);
+ buf++;
+ fmt++;
+ break;
+
+ case 'A':
+ write_bits(EXTRACT_LE_16BITS(buf), attrib_fmt);
+ buf += 2;
+ fmt++;
+ break;
+
+ case '{':
+ {
+ char bitfmt[128];
+ char *p = strchr(++fmt, '}');
+ int l = PTR_DIFF(p, fmt);
+ strncpy(bitfmt, fmt, l);
+ bitfmt[l] = 0;
+ fmt = p + 1;
+ write_bits(buf[0], bitfmt);
+ buf++;
+ break;
+ }
+
+ case 'P':
+ {
+ int l = atoi(fmt + 1);
+ buf += l;
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'r':
+ reverse = !reverse;
+ fmt++;
+ break;
+ case 'D':
+ {
+ unsigned int x;
+
+ TCHECK2(buf[0], 4);
+ x = reverse ? EXTRACT_32BITS(buf) : EXTRACT_LE_32BITS(buf);
+ printf("%d (0x%x)", x, x);
+ buf += 4;
+ fmt++;
+ break;
+ }
+ case 'L':
+ {
+ unsigned int x1, x2;
+
+ TCHECK2(buf[4], 4);
+ x1 = reverse ? EXTRACT_32BITS(buf) :
+ EXTRACT_LE_32BITS(buf);
+ x2 = reverse ? EXTRACT_32BITS(buf + 4) :
+ EXTRACT_LE_32BITS(buf + 4);
+ if (x2)
+ printf("0x%08x:%08x", x2, x1);
+ else
+ printf("%d (0x%08x%08x)", x1, x2, x1);
+ buf += 8;
+ fmt++;
+ break;
+ }
+ case 'd':
+ {
+ unsigned int x;
+ TCHECK2(buf[0], 2);
+ x = reverse ? EXTRACT_16BITS(buf) :
+ EXTRACT_LE_16BITS(buf);
+ printf("%d (0x%x)", x, x);
+ buf += 2;
+ fmt++;
+ break;
+ }
+ case 'W':
+ {
+ unsigned int x;
+ TCHECK2(buf[0], 4);
+ x = reverse ? EXTRACT_32BITS(buf) :
+ EXTRACT_LE_32BITS(buf);
+ printf("0x%X", x);
+ buf += 4;
+ fmt++;
+ break;
+ }
+ case 'w':
+ {
+ unsigned int x;
+ TCHECK2(buf[0], 2);
+ x = reverse ? EXTRACT_16BITS(buf) :
+ EXTRACT_LE_16BITS(buf);
+ printf("0x%X", x);
+ buf += 2;
+ fmt++;
+ break;
+ }
+ case 'B':
+ {
+ unsigned int x;
+ TCHECK(buf[0]);
+ x = buf[0];
+ printf("0x%X", x);
+ buf += 1;
+ fmt++;
+ break;
+ }
+ case 'b':
+ {
+ unsigned int x;
+ TCHECK(buf[0]);
+ x = buf[0];
+ printf("%u (0x%x)", x, x);
+ buf += 1;
+ fmt++;
+ break;
+ }
+ case 'S':
+ {
+ /*XXX unistr() */
+ printf("%.*s", (int)PTR_DIFF(maxbuf, buf), unistr(buf, &len));
+ buf += len;
+ fmt++;
+ break;
+ }
+ case 'Z':
+ {
+ if (*buf != 4 && *buf != 2)
+ printf("Error! ASCIIZ buffer of type %u (safety=%lu)\n", *buf,
+ (unsigned long)PTR_DIFF(maxbuf, buf));
+ printf("%.*s", (int)PTR_DIFF(maxbuf, buf + 1),
+ unistr(buf + 1, &len));
+ buf += len + 1;
+ fmt++;
+ break;
+ }
+ case 's':
+ {
+ int l = atoi(fmt + 1);
+ printf("%-*.*s", l, l, buf);
+ buf += l;
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'h':
+ {
+ int l = atoi(fmt + 1);
+ while (l--)
+ printf("%02x", *buf++);
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'n':
+ {
+ 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),
+ 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;
+ case 2:
+ name_type = buf[15];
+ printf("%-15.15s NameType=0x%02X (%s)", buf, name_type,
+ name_type_str(name_type));
+ buf += 16;
+ break;
+ }
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'T':
+ {
+ time_t t;
+ int x;
+ x = EXTRACT_LE_32BITS(buf);
+
+ switch (atoi(fmt + 1)) {
+ case 1:
+ if (x == 0 || x == -1 || x == 0xFFFFFFFF)
+ t = 0;
+ else
+ t = make_unix_date(buf);
+ buf += 4;
+ break;
+ case 2:
+ if (x == 0 || x == -1 || x == 0xFFFFFFFF)
+ t = 0;
+ else
+ t = make_unix_date2(buf);
+ buf += 4;
+ break;
+ case 3:
+ t = interpret_long_date(buf);
+ buf += 8;
+ break;
+ }
+ printf("%s", t ? asctime(localtime(&t)) : "NULL\n");
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ default:
+ putchar(*fmt);
+ fmt++;
+ break;
}
- printf("%s",t?asctime(localtime(&t)):"NULL\n");
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- default:
- putchar(*fmt);
- fmt++;
- break;
}
- }
- if (buf>=maxbuf && *fmt)
- printf("END OF BUFFER\n");
+ if (buf >= maxbuf && *fmt)
+ printf("END OF BUFFER\n");
- return(buf);
+ return(buf);
trunc:
- printf("\n");
- printf("WARNING: Short packet. Try increasing the snap length\n");
- return(NULL);
+ 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)
+const u_char *
+smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf)
{
- static int depth=0;
- char s[128];
- char *p;
-
- while (*fmt) {
- switch (*fmt) {
- case '*':
- fmt++;
- while (buf < maxbuf) {
- const uchar *buf2;
- depth++;
- buf2 = fdata(buf,fmt,maxbuf);
- depth--;
- if (buf2 == buf) return(buf);
- buf = buf2;
- }
- break;
-
- case '|':
- fmt++;
- if (buf>=maxbuf) return(buf);
- break;
-
- case '%':
- fmt++;
- buf=maxbuf;
- break;
-
- case '#':
- fmt++;
- return(buf);
- break;
-
- case '[':
- fmt++;
- if (buf>=maxbuf) return(buf);
- 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:
- putchar(*fmt); fmt++;
- fflush(stdout);
- break;
+ static int depth = 0;
+ char s[128];
+ char *p;
+
+ while (*fmt) {
+ switch (*fmt) {
+ case '*':
+ fmt++;
+ while (buf < maxbuf) {
+ const u_char *buf2;
+ depth++;
+ buf2 = smb_fdata(buf, fmt, maxbuf);
+ depth--;
+ if (buf2 == NULL)
+ return(NULL);
+ if (buf2 == buf)
+ return(buf);
+ buf = buf2;
+ }
+ return(buf);
+
+ case '|':
+ fmt++;
+ if (buf >= maxbuf)
+ return(buf);
+ break;
+
+ case '%':
+ fmt++;
+ buf = maxbuf;
+ break;
+
+ case '#':
+ fmt++;
+ return(buf);
+ break;
+
+ case '[':
+ fmt++;
+ if (buf >= maxbuf)
+ return(buf);
+ memset(s, 0, sizeof(s));
+ p = strchr(fmt, ']');
+ if (p - fmt + 1 > sizeof(s)) {
+ /* overrun */
+ return(buf);
+ }
+ strncpy(s, fmt, p - fmt);
+ s[p - fmt] = '\0';
+ fmt = p + 1;
+ buf = smb_fdata1(buf, s, maxbuf);
+ if (buf == NULL)
+ return(NULL);
+ break;
+
+ default:
+ putchar(*fmt);
+ fmt++;
+ fflush(stdout);
+ break;
+ }
}
- }
- if (!depth && buf<maxbuf) {
- int len = PTR_DIFF(maxbuf,buf);
- printf("Data: (%d bytes)\n",len);
- print_data(buf,len);
- return(buf+len);
- }
- return(buf);
+ if (!depth && buf < maxbuf) {
+ size_t len = PTR_DIFF(maxbuf, buf);
+ printf("Data: (%lu bytes)\n", (unsigned long)len);
+ print_data(buf, len);
+ return(buf + len);
+ }
+ return(buf);
}
-typedef struct
-{
- char *name;
- int code;
- char *message;
+typedef struct {
+ const char *name;
+ int code;
+ const char *message;
} err_code_struct;
/* Dos Error Messages */
static err_code_struct dos_msgs[] = {
- {"ERRbadfunc",1,"Invalid function."},
- {"ERRbadfile",2,"File not found."},
- {"ERRbadpath",3,"Directory invalid."},
- {"ERRnofids",4,"No file descriptors available"},
- {"ERRnoaccess",5,"Access denied."},
- {"ERRbadfid",6,"Invalid file handle."},
- {"ERRbadmcb",7,"Memory control blocks destroyed."},
- {"ERRnomem",8,"Insufficient server memory to perform the requested function."},
- {"ERRbadmem",9,"Invalid memory block address."},
- {"ERRbadenv",10,"Invalid environment."},
- {"ERRbadformat",11,"Invalid format."},
- {"ERRbadaccess",12,"Invalid open mode."},
- {"ERRbaddata",13,"Invalid data."},
- {"ERR",14,"reserved."},
- {"ERRbaddrive",15,"Invalid drive specified."},
- {"ERRremcd",16,"A Delete Directory request attempted to remove the server's current directory."},
- {"ERRdiffdevice",17,"Not same device."},
- {"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
- {"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
- {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
- {"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
- {"ERRbadpipe",230,"Pipe invalid."},
- {"ERRpipebusy",231,"All instances of the requested pipe are busy."},
- {"ERRpipeclosing",232,"Pipe close in progress."},
- {"ERRnotconnected",233,"No process on other end of pipe."},
- {"ERRmoredata",234,"There is more data to be returned."},
- {NULL,-1,NULL}};
+ { "ERRbadfunc", 1, "Invalid function." },
+ { "ERRbadfile", 2, "File not found." },
+ { "ERRbadpath", 3, "Directory invalid." },
+ { "ERRnofids", 4, "No file descriptors available" },
+ { "ERRnoaccess", 5, "Access denied." },
+ { "ERRbadfid", 6, "Invalid file handle." },
+ { "ERRbadmcb", 7, "Memory control blocks destroyed." },
+ { "ERRnomem", 8, "Insufficient server memory to perform the requested function." },
+ { "ERRbadmem", 9, "Invalid memory block address." },
+ { "ERRbadenv", 10, "Invalid environment." },
+ { "ERRbadformat", 11, "Invalid format." },
+ { "ERRbadaccess", 12, "Invalid open mode." },
+ { "ERRbaddata", 13, "Invalid data." },
+ { "ERR", 14, "reserved." },
+ { "ERRbaddrive", 15, "Invalid drive specified." },
+ { "ERRremcd", 16, "A Delete Directory request attempted to remove the server's current directory." },
+ { "ERRdiffdevice", 17, "Not same device." },
+ { "ERRnofiles", 18, "A File Search command can find no more files matching the specified criteria." },
+ { "ERRbadshare", 32, "The sharing mode specified for an Open conflicts with existing FIDs on the file." },
+ { "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." },
+ { "ERRfilexists", 80, "The file named in a Create Directory, Make New File or Link request already exists." },
+ { "ERRbadpipe", 230, "Pipe invalid." },
+ { "ERRpipebusy", 231, "All instances of the requested pipe are busy." },
+ { "ERRpipeclosing", 232, "Pipe close in progress." },
+ { "ERRnotconnected", 233, "No process on other end of pipe." },
+ { "ERRmoredata", 234, "There is more data to be returned." },
+ { NULL, -1, NULL }
+ };
/* Server Error Messages */
err_code_struct server_msgs[] = {
- {"ERRerror",1,"Non-specific error code."},
- {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
- {"ERRbadtype",3,"reserved."},
- {"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
- {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
- {"ERRinvnetname",6,"Invalid network name in tree connect."},
- {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
- {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
- {"ERRqtoobig",50,"Print queue full -- no space."},
- {"ERRqeof",51,"EOF on print queue dump."},
- {"ERRinvpfid",52,"Invalid print file FID."},
- {"ERRsmbcmd",64,"The server did not recognize the command received."},
- {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
- {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
- {"ERRreserved",68,"reserved."},
- {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
- {"ERRreserved",70,"reserved."},
- {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
- {"ERRpaused",81,"Server is paused."},
- {"ERRmsgoff",82,"Not receiving messages."},
- {"ERRnoroom",83,"No room to buffer message."},
- {"ERRrmuns",87,"Too many remote user names."},
- {"ERRtimeout",88,"Operation timed out."},
- {"ERRnoresource",89,"No resources currently available for request."},
- {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
- {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
- {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
- {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
- {"ERRcontmpx",252,"Continue in MPX mode."},
- {"ERRreserved",253,"reserved."},
- {"ERRreserved",254,"reserved."},
- {"ERRnosupport",0xFFFF,"Function not supported."},
- {NULL,-1,NULL}};
+ { "ERRerror", 1, "Non-specific error code." },
+ { "ERRbadpw", 2, "Bad password - name/password pair in a Tree Connect or Session Setup are invalid." },
+ { "ERRbadtype", 3, "reserved." },
+ { "ERRaccess", 4, "The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID." },
+ { "ERRinvnid", 5, "The tree ID (TID) specified in a command was invalid." },
+ { "ERRinvnetname", 6, "Invalid network name in tree connect." },
+ { "ERRinvdevice", 7, "Invalid device - printer request made to non-printer connection or non-printer request made to printer connection." },
+ { "ERRqfull", 49, "Print queue full (files) -- returned by open print file." },
+ { "ERRqtoobig", 50, "Print queue full -- no space." },
+ { "ERRqeof", 51, "EOF on print queue dump." },
+ { "ERRinvpfid", 52, "Invalid print file FID." },
+ { "ERRsmbcmd", 64, "The server did not recognize the command received." },
+ { "ERRsrverror", 65, "The server encountered an internal error, e.g., system file unavailable." },
+ { "ERRfilespecs", 67, "The file handle (FID) and pathname parameters contained an invalid combination of values." },
+ { "ERRreserved", 68, "reserved." },
+ { "ERRbadpermits", 69, "The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute." },
+ { "ERRreserved", 70, "reserved." },
+ { "ERRsetattrmode", 71, "The attribute mode in the Set File Attribute request is invalid." },
+ { "ERRpaused", 81, "Server is paused." },
+ { "ERRmsgoff", 82, "Not receiving messages." },
+ { "ERRnoroom", 83, "No room to buffer message." },
+ { "ERRrmuns", 87, "Too many remote user names." },
+ { "ERRtimeout", 88, "Operation timed out." },
+ { "ERRnoresource", 89, "No resources currently available for request." },
+ { "ERRtoomanyuids", 90, "Too many UIDs active on this session." },
+ { "ERRbaduid", 91, "The UID is not known as a valid ID on this session." },
+ { "ERRusempx", 250, "Temp unable to support Raw, use MPX mode." },
+ { "ERRusestd", 251, "Temp unable to support Raw, use standard read/write." },
+ { "ERRcontmpx", 252, "Continue in MPX mode." },
+ { "ERRreserved", 253, "reserved." },
+ { "ERRreserved", 254, "reserved." },
+ { "ERRnosupport", 0xFFFF, "Function not supported." },
+ { NULL, -1, NULL }
+};
/* Hard Error Messages */
err_code_struct hard_msgs[] = {
- {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
- {"ERRbadunit",20,"Unknown unit."},
- {"ERRnotready",21,"Drive not ready."},
- {"ERRbadcmd",22,"Unknown command."},
- {"ERRdata",23,"Data error (CRC)."},
- {"ERRbadreq",24,"Bad request structure length."},
- {"ERRseek",25 ,"Seek error."},
- {"ERRbadmedia",26,"Unknown media type."},
- {"ERRbadsector",27,"Sector not found."},
- {"ERRnopaper",28,"Printer out of paper."},
- {"ERRwrite",29,"Write fault."},
- {"ERRread",30,"Read fault."},
- {"ERRgeneral",31,"General failure."},
- {"ERRbadshare",32,"A open conflicts with an existing open."},
- {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
- {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
- {"ERRFCBUnavail",35,"No FCBs are available to process request."},
- {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
- {NULL,-1,NULL}};
-
-
-static struct
-{
- int code;
- char *class;
- err_code_struct *err_msgs;
-} err_classes[] = {
- {0,"SUCCESS",NULL},
- {0x01,"ERRDOS",dos_msgs},
- {0x02,"ERRSRV",server_msgs},
- {0x03,"ERRHRD",hard_msgs},
- {0x04,"ERRXOS",NULL},
- {0xE1,"ERRRMX1",NULL},
- {0xE2,"ERRRMX2",NULL},
- {0xE3,"ERRRMX3",NULL},
- {0xFF,"ERRCMD",NULL},
- {-1,NULL,NULL}};
-
-
-/****************************************************************************
-return a SMB error string from a SMB buffer
-****************************************************************************/
-char *smb_errstr(int class,int num)
+ { "ERRnowrite", 19, "Attempt to write on write-protected diskette." },
+ { "ERRbadunit", 20, "Unknown unit." },
+ { "ERRnotready", 21, "Drive not ready." },
+ { "ERRbadcmd", 22, "Unknown command." },
+ { "ERRdata", 23, "Data error (CRC)." },
+ { "ERRbadreq", 24, "Bad request structure length." },
+ { "ERRseek", 25 , "Seek error." },
+ { "ERRbadmedia", 26, "Unknown media type." },
+ { "ERRbadsector", 27, "Sector not found." },
+ { "ERRnopaper", 28, "Printer out of paper." },
+ { "ERRwrite", 29, "Write fault." },
+ { "ERRread", 30, "Read fault." },
+ { "ERRgeneral", 31, "General failure." },
+ { "ERRbadshare", 32, "A open conflicts with an existing open." },
+ { "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." },
+ { "ERRwrongdisk", 34, "The wrong disk was found in a drive." },
+ { "ERRFCBUnavail", 35, "No FCBs are available to process request." },
+ { "ERRsharebufexc", 36, "A sharing buffer has been exceeded." },
+ { NULL, -1, NULL }
+};
+
+static struct {
+ int code;
+ char *class;
+ err_code_struct *err_msgs;
+} err_classes[] = {
+ { 0, "SUCCESS", NULL },
+ { 0x01, "ERRDOS", dos_msgs },
+ { 0x02, "ERRSRV", server_msgs },
+ { 0x03, "ERRHRD", hard_msgs },
+ { 0x04, "ERRXOS", NULL },
+ { 0xE1, "ERRRMX1", NULL },
+ { 0xE2, "ERRRMX2", NULL },
+ { 0xE3, "ERRRMX3", NULL },
+ { 0xFF, "ERRCMD", NULL },
+ { -1, NULL, NULL }
+};
+
+/*
+ * return a SMB error string from a SMB buffer
+ */
+char *
+smb_errstr(int class, int num)
{
- static char ret[128];
- int i,j;
-
- ret[0]=0;
-
- for (i=0;err_classes[i].class;i++)
- if (err_classes[i].code == class)
- {
- if (err_classes[i].err_msgs)
- {
- err_code_struct *err = err_classes[i].err_msgs;
- for (j=0;err[j].name;j++)
- if (num == err[j].code)
- {
- snprintf(ret,sizeof(ret),"%s - %s (%s)",err_classes[i].class,
- err[j].name,err[j].message);
- return ret;
- }
- }
+ static char ret[128];
+ int i, j;
+
+ ret[0] = 0;
+
+ for (i = 0; err_classes[i].class; i++)
+ if (err_classes[i].code == class) {
+ if (err_classes[i].err_msgs) {
+ err_code_struct *err = err_classes[i].err_msgs;
+ for (j = 0; err[j].name; j++)
+ if (num == err[j].code) {
+ snprintf(ret, sizeof(ret), "%s - %s (%s)",
+ err_classes[i].class, err[j].name, err[j].message);
+ return ret;
+ }
+ }
+
+ snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num);
+ return ret;
+ }
- snprintf(ret,sizeof(ret),"%s - %d",err_classes[i].class,num);
- return ret;
- }
-
- snprintf(ret,sizeof(ret),"ERROR: Unknown error (%d,%d)",class,num);
- return(ret);
+ snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num);
+ return(ret);
}
diff --git a/contrib/tcpdump/tcp.h b/contrib/tcpdump/tcp.h
index a93c14f1b588..fe0e261ae606 100644
--- a/contrib/tcpdump/tcp.h
+++ b/contrib/tcpdump/tcp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.7 2000/10/03 09:17:41 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.8 2001/05/09 01:16:57 fenner Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -53,6 +53,8 @@ struct tcphdr {
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
+#define TH_ECNECHO 0x40 /* ECN Echo */
+#define TH_CWR 0x80 /* ECN Cwnd Reduced */
u_int16_t th_win; /* window */
u_int16_t th_sum; /* checksum */
u_int16_t th_urp; /* urgent pointer */
@@ -62,14 +64,17 @@ struct tcphdr {
#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 TCPOPT_WSCALE 3 /* window scale factor (rfc1323) */
+#define TCPOPT_SACKOK 4 /* selective ack ok (rfc2018) */
+#define TCPOPT_SACK 5 /* selective ack (rfc2018) */
+#define TCPOPT_ECHO 6 /* echo (rfc1072) */
+#define TCPOPT_ECHOREPLY 7 /* echo (rfc1072) */
+#define TCPOPT_TIMESTAMP 8 /* timestamp (rfc1323) */
#define TCPOLEN_TIMESTAMP 10
#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
+#define TCPOPT_CC 11 /* T/TCP CC options (rfc1644) */
+#define TCPOPT_CCNEW 12 /* T/TCP CC options (rfc1644) */
+#define TCPOPT_CCECHO 13 /* T/TCP CC options (rfc1644) */
#define TCPOPT_TSTAMP_HDR \
(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
diff --git a/contrib/tcpdump/telnet.h b/contrib/tcpdump/telnet.h
new file mode 100644
index 000000000000..c29aeac35665
--- /dev/null
+++ b/contrib/tcpdump/telnet.h
@@ -0,0 +1,348 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.3 2001/09/17 21:58:06 fenner Exp $ (LBL) */
+
+/* $NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp $ */
+
+/*
+ * 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.
+ *
+ * @(#)telnet.h 8.2 (Berkeley) 12/15/93
+ */
+
+#ifndef _ARPA_TELNET_H_
+#define _ARPA_TELNET_H_
+
+/*
+ * Definitions for the TELNET protocol.
+ */
+#define IAC 255 /* interpret as command: */
+#define DONT 254 /* you are not to use option */
+#define DO 253 /* please, you use option */
+#define WONT 252 /* I won't use option */
+#define WILL 251 /* I will use option */
+#define SB 250 /* interpret as subnegotiation */
+#define GA 249 /* you may reverse the line */
+#define EL 248 /* erase the current line */
+#define EC 247 /* erase the current character */
+#define AYT 246 /* are you there */
+#define AO 245 /* abort output--but let prog finish */
+#define IP 244 /* interrupt process--permanently */
+#define BREAK 243 /* break */
+#define DM 242 /* data mark--for connect. cleaning */
+#define NOP 241 /* nop */
+#define SE 240 /* end sub negotiation */
+#define EOR 239 /* end of record (transparent mode) */
+#define ABORT 238 /* Abort process */
+#define SUSP 237 /* Suspend process */
+#define xEOF 236 /* End of file: EOF is already used... */
+
+#define SYNCH 242 /* for telfunc calls */
+
+#ifdef TELCMDS
+const char *telcmds[] = {
+ "EOF", "SUSP", "ABORT", "EOR",
+ "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
+ "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
+};
+#else
+extern char *telcmds[];
+#endif
+
+#define TELCMD_FIRST xEOF
+#define TELCMD_LAST IAC
+#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
+ (unsigned int)(x) >= TELCMD_FIRST)
+#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
+
+/* telnet options */
+#define TELOPT_BINARY 0 /* 8-bit data path */
+#define TELOPT_ECHO 1 /* echo */
+#define TELOPT_RCP 2 /* prepare to reconnect */
+#define TELOPT_SGA 3 /* suppress go ahead */
+#define TELOPT_NAMS 4 /* approximate message size */
+#define TELOPT_STATUS 5 /* give status */
+#define TELOPT_TM 6 /* timing mark */
+#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
+#define TELOPT_NAOL 8 /* negotiate about output line width */
+#define TELOPT_NAOP 9 /* negotiate about output page size */
+#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
+#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
+#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
+#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
+#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
+#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
+#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
+#define TELOPT_XASCII 17 /* extended ascic character set */
+#define TELOPT_LOGOUT 18 /* force logout */
+#define TELOPT_BM 19 /* byte macro */
+#define TELOPT_DET 20 /* data entry terminal */
+#define TELOPT_SUPDUP 21 /* supdup protocol */
+#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
+#define TELOPT_SNDLOC 23 /* send location */
+#define TELOPT_TTYPE 24 /* terminal type */
+#define TELOPT_EOR 25 /* end or record */
+#define TELOPT_TUID 26 /* TACACS user identification */
+#define TELOPT_OUTMRK 27 /* output marking */
+#define TELOPT_TTYLOC 28 /* terminal location number */
+#define TELOPT_3270REGIME 29 /* 3270 regime */
+#define TELOPT_X3PAD 30 /* X.3 PAD */
+#define TELOPT_NAWS 31 /* window size */
+#define TELOPT_TSPEED 32 /* terminal speed */
+#define TELOPT_LFLOW 33 /* remote flow control */
+#define TELOPT_LINEMODE 34 /* Linemode option */
+#define TELOPT_XDISPLOC 35 /* X Display Location */
+#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
+#define TELOPT_AUTHENTICATION 37/* Authenticate */
+#define TELOPT_ENCRYPT 38 /* Encryption option */
+#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
+#define TELOPT_EXOPL 255 /* extended-options-list */
+
+
+#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
+#ifdef TELOPTS
+const char *telopts[NTELOPTS+1] = {
+ "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+ "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+ "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+ "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+ "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+ "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+ "TACACS UID", "OUTPUT MARKING", "TTYLOC",
+ "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
+ "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
+ "ENCRYPT", "NEW-ENVIRON",
+ 0,
+};
+#define TELOPT_FIRST TELOPT_BINARY
+#define TELOPT_LAST TELOPT_NEW_ENVIRON
+#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
+#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
+#endif
+
+/* sub-option qualifiers */
+#define TELQUAL_IS 0 /* option is... */
+#define TELQUAL_SEND 1 /* send option */
+#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
+#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
+#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
+
+#define LFLOW_OFF 0 /* Disable remote flow control */
+#define LFLOW_ON 1 /* Enable remote flow control */
+#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
+#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
+
+/*
+ * LINEMODE suboptions
+ */
+
+#define LM_MODE 1
+#define LM_FORWARDMASK 2
+#define LM_SLC 3
+
+#define MODE_EDIT 0x01
+#define MODE_TRAPSIG 0x02
+#define MODE_ACK 0x04
+#define MODE_SOFT_TAB 0x08
+#define MODE_LIT_ECHO 0x10
+
+#define MODE_MASK 0x1f
+
+/* Not part of protocol, but needed to simplify things... */
+#define MODE_FLOW 0x0100
+#define MODE_ECHO 0x0200
+#define MODE_INBIN 0x0400
+#define MODE_OUTBIN 0x0800
+#define MODE_FORCE 0x1000
+
+#define SLC_SYNCH 1
+#define SLC_BRK 2
+#define SLC_IP 3
+#define SLC_AO 4
+#define SLC_AYT 5
+#define SLC_EOR 6
+#define SLC_ABORT 7
+#define SLC_EOF 8
+#define SLC_SUSP 9
+#define SLC_EC 10
+#define SLC_EL 11
+#define SLC_EW 12
+#define SLC_RP 13
+#define SLC_LNEXT 14
+#define SLC_XON 15
+#define SLC_XOFF 16
+#define SLC_FORW1 17
+#define SLC_FORW2 18
+#define SLC_MCL 19
+#define SLC_MCR 20
+#define SLC_MCWL 21
+#define SLC_MCWR 22
+#define SLC_MCBOL 23
+#define SLC_MCEOL 24
+#define SLC_INSRT 25
+#define SLC_OVER 26
+#define SLC_ECR 27
+#define SLC_EWR 28
+#define SLC_EBOL 29
+#define SLC_EEOL 30
+
+#define NSLC 30
+
+/*
+ * For backwards compatibility, we define SLC_NAMES to be the
+ * list of names if SLC_NAMES is not defined.
+ */
+#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
+ "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
+ "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
+ "EBOL", "EEOL", \
+ 0,
+
+#ifdef SLC_NAMES
+const char *slc_names[] = {
+ SLC_NAMELIST
+};
+#else
+extern char *slc_names[];
+#define SLC_NAMES SLC_NAMELIST
+#endif
+
+#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
+#define SLC_NAME(x) slc_names[x]
+
+#define SLC_NOSUPPORT 0
+#define SLC_CANTCHANGE 1
+#define SLC_VARIABLE 2
+#define SLC_DEFAULT 3
+#define SLC_LEVELBITS 0x03
+
+#define SLC_FUNC 0
+#define SLC_FLAGS 1
+#define SLC_VALUE 2
+
+#define SLC_ACK 0x80
+#define SLC_FLUSHIN 0x40
+#define SLC_FLUSHOUT 0x20
+
+#define OLD_ENV_VAR 1
+#define OLD_ENV_VALUE 0
+#define NEW_ENV_VAR 0
+#define NEW_ENV_VALUE 1
+#define ENV_ESC 2
+#define ENV_USERVAR 3
+
+/*
+ * AUTHENTICATION suboptions
+ */
+
+/*
+ * Who is authenticating who ...
+ */
+#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
+#define AUTH_WHO_SERVER 1 /* Server authenticating client */
+#define AUTH_WHO_MASK 1
+
+/*
+ * amount of authentication done
+ */
+#define AUTH_HOW_ONE_WAY 0
+#define AUTH_HOW_MUTUAL 2
+#define AUTH_HOW_MASK 2
+
+/*
+ * should we be encrypting? (not yet formally standardized)
+ */
+#define AUTH_ENCRYPT_OFF 0
+#define AUTH_ENCRYPT_ON 4
+#define AUTH_ENCRYPT_MASK 4
+
+#define AUTHTYPE_NULL 0
+#define AUTHTYPE_KERBEROS_V4 1
+#define AUTHTYPE_KERBEROS_V5 2
+#define AUTHTYPE_SPX 3
+#define AUTHTYPE_MINK 4
+#define AUTHTYPE_CNT 5
+
+#define AUTHTYPE_TEST 99
+
+#ifdef AUTH_NAMES
+const char *authtype_names[] = {
+ "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
+#define AUTHTYPE_NAME(x) authtype_names[x]
+
+/*
+ * ENCRYPTion suboptions
+ */
+#define ENCRYPT_IS 0 /* I pick encryption type ... */
+#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
+#define ENCRYPT_REPLY 2 /* Initial setup response */
+#define ENCRYPT_START 3 /* Am starting to send encrypted */
+#define ENCRYPT_END 4 /* Am ending encrypted */
+#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
+#define ENCRYPT_REQEND 6 /* Request you send encrypting */
+#define ENCRYPT_ENC_KEYID 7
+#define ENCRYPT_DEC_KEYID 8
+#define ENCRYPT_CNT 9
+
+#define ENCTYPE_ANY 0
+#define ENCTYPE_DES_CFB64 1
+#define ENCTYPE_DES_OFB64 2
+#define ENCTYPE_CNT 3
+
+#ifdef ENCRYPT_NAMES
+const char *encrypt_names[] = {
+ "IS", "SUPPORT", "REPLY", "START", "END",
+ "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+ 0,
+};
+const char *enctype_names[] = {
+ "ANY", "DES_CFB64", "DES_OFB64", 0,
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+
+#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
+#define ENCRYPT_NAME(x) encrypt_names[x]
+
+#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
+#define ENCTYPE_NAME(x) enctype_names[x]
+
+#endif /* _ARPA_TELNET_H_ */
diff --git a/contrib/tcpdump/util.c b/contrib/tcpdump/util.c
index 57e3a031f9be..3e498acc6318 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.69 2000/07/11 00:49:03 assar Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.72 2001/10/08 16:12:13 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -178,15 +178,19 @@ 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;
+ static const char *lengths[] = {"y", "w", "d", "h", "m", "s"};
+ static const int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
+ const char **l = lengths;
+ const int *s = seconds;
- if (secs <= 0) {
+ if (secs == 0) {
(void)printf("0s");
return;
}
+ if (secs < 0) {
+ (void)printf("-");
+ secs = -secs;
+ }
while (secs > 0) {
if (secs >= *s) {
(void)printf("%d%s", secs / *s, *l);
@@ -217,6 +221,25 @@ tok2str(register const struct tok *lp, register const char *fmt,
return (buf);
}
+/*
+ * Convert a value to a string using an array; the macro
+ * tok2strary() in <interface.h> is the public interface to
+ * this function and ensures that the second argument is
+ * correct for bounds-checking.
+ */
+const char *
+tok2strary_internal(register const char **lp, int n, register const char *fmt,
+ register int v)
+{
+ static char buf[128];
+
+ if (v >= 0 && v < n && lp[v] != NULL)
+ return lp[v];
+ if (fmt == NULL)
+ fmt = "#%d";
+ (void)snprintf(buf, sizeof(buf), fmt, v);
+ return (buf);
+}
/* VARARGS */
void
@@ -303,7 +326,10 @@ read_infile(char *fname)
error("can't stat %s: %s", fname, pcap_strerror(errno));
cp = malloc((u_int)buf.st_size + 1);
- cc = read(fd, cp, (int)buf.st_size);
+ if (cp == NULL)
+ error("malloc(%d) for %s: %s", (u_int)buf.st_size + 1,
+ fname, pcap_strerror(errno));
+ cc = read(fd, cp, (u_int)buf.st_size);
if (cc < 0)
error("read %s: %s", fname, pcap_strerror(errno));
if (cc != buf.st_size)