aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES43
-rw-r--r--CREDITS27
-rw-r--r--INSTALL.txt3
-rw-r--r--Makefile-devel-adds22
-rw-r--r--Makefile.in108
-rw-r--r--README14
-rw-r--r--Readme.Win3224
-rw-r--r--VERSION2
-rw-r--r--acconfig.h43
-rw-r--r--aclocal.m4438
-rw-r--r--addrtoname.c47
-rw-r--r--af.c4
-rw-r--r--af.h4
-rw-r--r--atmuni31.h2
-rw-r--r--bootp.h5
-rw-r--r--bpf_dump.c2
-rw-r--r--checksum.c67
-rwxr-xr-xconfig.guess859
-rw-r--r--config.h.in74
-rwxr-xr-xconfig.sub319
-rwxr-xr-xconfigure627
-rwxr-xr-xconfigure.in101
-rw-r--r--ethertype.h11
-rw-r--r--forces.h679
-rw-r--r--gmpls.c18
-rw-r--r--gmpls.h18
-rw-r--r--gmt2local.h2
-rw-r--r--icmp6.h10
-rw-r--r--ieee802_11.h58
-rw-r--r--ieee802_11_radio.h70
-rw-r--r--interface.h37
-rw-r--r--ip6.h14
-rw-r--r--ipnet.h13
-rwxr-xr-xipproto.c2
-rw-r--r--ipproto.h2
-rw-r--r--isakmp.h24
-rwxr-xr-xl2vpn.c2
-rwxr-xr-xl2vpn.h2
-rw-r--r--lbl/os-sunos4.h2
-rw-r--r--lbl/os-ultrix4.h2
-rw-r--r--missing/addrinfo.h3
-rw-r--r--missing/getaddrinfo.c1115
-rw-r--r--netdissect.h68
-rw-r--r--nfs.h3
-rwxr-xr-xnlpid.c2
-rw-r--r--nlpid.h2
-rw-r--r--oui.c6
-rw-r--r--oui.h6
-rw-r--r--print-802_11.c917
-rw-r--r--print-ap1394.c18
-rw-r--r--print-arcnet.c5
-rw-r--r--print-atalk.c2
-rw-r--r--print-atm.c2
-rw-r--r--print-bfd.c14
-rw-r--r--print-bgp.c196
-rw-r--r--print-bootp.c8
-rw-r--r--print-bt.c5
-rw-r--r--print-cdp.c29
-rw-r--r--print-cfm.c4
-rw-r--r--print-dccp.c28
-rw-r--r--print-dhcp6.c266
-rw-r--r--print-domain.c2
-rw-r--r--print-enc.c7
-rw-r--r--print-esp.c397
-rw-r--r--print-ether.c193
-rw-r--r--print-forces.c1043
-rw-r--r--print-fr.c7
-rw-r--r--print-gre.c3
-rw-r--r--print-icmp6.c112
-rw-r--r--print-ip.c5
-rw-r--r--print-ip6.c31
-rw-r--r--print-ipnet.c109
-rw-r--r--print-isakmp.c259
-rw-r--r--print-isoclns.c40
-rw-r--r--print-juniper.c11
-rw-r--r--print-l2tp.c41
-rw-r--r--print-lane.c69
-rw-r--r--print-llc.c14
-rw-r--r--print-lldp.c2
-rw-r--r--print-lspping.c30
-rw-r--r--print-nfs.c35
-rw-r--r--print-ntp.c27
-rw-r--r--print-olsr.c377
-rw-r--r--print-ospf.c2
-rw-r--r--print-pflog.c5
-rw-r--r--print-pim.c12
-rw-r--r--print-ppp.c4
-rw-r--r--print-rrcp.c134
-rw-r--r--print-rsvp.c208
-rw-r--r--print-rx.c2
-rw-r--r--print-sctp.c60
-rw-r--r--print-sip.c4
-rw-r--r--print-sll.c49
-rw-r--r--print-smb.c2
-rw-r--r--print-sunrpc.c15
-rw-r--r--print-symantec.c9
-rw-r--r--print-tcp.c79
-rw-r--r--print-tftp.c2
-rw-r--r--print-token.c15
-rw-r--r--print-udp.c17
-rw-r--r--print-usb.c174
-rw-r--r--setsignal.h2
-rw-r--r--signature.c159
-rw-r--r--signature.h26
-rw-r--r--sll.h2
-rw-r--r--smbutil.c4
-rw-r--r--strcasecmp.c6
-rw-r--r--tcp.h5
-rw-r--r--tcpdump-stdinc.h16
-rw-r--r--tcpdump.1.in (renamed from tcpdump.1)73
-rw-r--r--tcpdump.c198
-rw-r--r--tests/02-sunrise-sunset-esp.puu34
-rw-r--r--tests/08-sunrise-sunset-aes.puu36
-rw-r--r--tests/08-sunrise-sunset-esp2.puu43
-rw-r--r--tests/TESTLIST51
-rwxr-xr-xtests/TESTonce46
-rwxr-xr-xtests/TESTrun.sh63
-rw-r--r--tests/bgp-infinite-loop.pcapbin0 -> 554 bytes
-rw-r--r--tests/bgp_vpn_attrset.out19
-rw-r--r--tests/bgp_vpn_attrset.pcapbin0 -> 217 bytes
-rw-r--r--tests/chdlc-slarp-short.pcapbin0 -> 58 bytes
-rw-r--r--tests/chdlc-slarp.pcapbin0 -> 62 bytes
-rw-r--r--tests/dio.out1
-rw-r--r--tests/dio.pcapbin0 -> 120 bytes
-rw-r--r--tests/e1000g.out20
-rw-r--r--tests/e1000g.pcapbin0 -> 2504 bytes
-rw-r--r--tests/eapon1.gdbinit1
-rw-r--r--tests/eapon1.out114
-rw-r--r--tests/eapon1.puu368
-rw-r--r--tests/eapon2.puu66
-rw-r--r--tests/esp-secrets.txt5
-rw-r--r--tests/esp0.out8
-rw-r--r--tests/esp1.gdbinit1
-rw-r--r--tests/esp1.out8
-rw-r--r--tests/esp2.gdbinit1
-rw-r--r--tests/esp2.out8
-rw-r--r--tests/esp3.gdbinit1
-rw-r--r--tests/esp4.gdbinit2
-rw-r--r--tests/esp5.gdbinit3
-rw-r--r--tests/esp5.out8
-rw-r--r--tests/espudp1.out8
-rw-r--r--tests/espudp1.puu35
-rw-r--r--tests/forces1.out8
-rw-r--r--tests/forces1.pcapbin0 -> 476 bytes
-rw-r--r--tests/forces1vvv.out52
-rw-r--r--tests/forces1vvvv.out67
-rw-r--r--tests/forces2.out491
-rw-r--r--tests/forces2.pcapbin0 -> 17566 bytes
-rw-r--r--tests/forces2v.out982
-rw-r--r--tests/forces2vv.out1966
-rw-r--r--tests/ikev2.puu22231
-rw-r--r--tests/ikev2four.out107
-rw-r--r--tests/ikev2four.puu134
-rw-r--r--tests/ikev2fourv.out107
-rw-r--r--tests/ikev2fourv4.out107
-rw-r--r--tests/ikev2pI2-secrets.txt2
-rw-r--r--tests/ikev2pI2.out41
-rw-r--r--tests/ikev2pI2.puu24
-rw-r--r--tests/isakmp-delete-segfault.puu20
-rw-r--r--tests/isakmp-identification-segfault.puu11
-rw-r--r--tests/isakmp-pointer-loop.puu6
-rw-r--r--tests/isakmp1.out1
-rw-r--r--tests/isakmp2.out1
-rw-r--r--tests/isakmp3.out3
-rw-r--r--tests/isakmp4.out35
-rw-r--r--tests/isakmp4500.puu155
-rw-r--r--tests/isis-infinite-loop.pcapbin0 -> 454 bytes
-rw-r--r--tests/ldp-infinite-loop.pcapbin0 -> 414 bytes
-rw-r--r--tests/lmp.out36
-rw-r--r--tests/lmp.puu42
-rwxr-xr-xtests/lmp.sh14
-rw-r--r--tests/lspping-fec-ldp.pcapbin0 -> 1190 bytes
-rw-r--r--tests/lspping-fec-rsvp.pcapbin0 -> 984 bytes
-rw-r--r--tests/mpls-ldp-hello.out10
-rw-r--r--tests/mpls-ldp-hello.puu6
-rw-r--r--tests/mpls-traceroute.pcapbin0 -> 1956 bytes
-rw-r--r--tests/ospf-gmpls.out86
-rw-r--r--tests/ospf-gmpls.puu18
-rw-r--r--tests/print-A.out193
-rw-r--r--tests/print-AA.out193
-rw-r--r--tests/print-capX.out409
-rw-r--r--tests/print-capXX.out419
-rw-r--r--tests/print-flags.puu151
-rwxr-xr-xtests/print-flags.sh12
-rw-r--r--tests/print-x.out409
-rw-r--r--tests/print-xx.out419
-rw-r--r--tests/rsvp-infinite-loop.pcapbin0 -> 384 bytes
-rw-r--r--tftp.h2
-rw-r--r--timed.h2
-rw-r--r--token.h12
-rw-r--r--util.c33
-rw-r--r--win32/Include/Arpa/tftp.h84
-rw-r--r--win32/Include/Netinet/in_systm.h56
-rw-r--r--win32/Include/Netinet/ip.h177
-rw-r--r--win32/Include/errno.h132
-rw-r--r--win32/Include/getopt.h138
-rw-r--r--win32/Include/inetprivate.h40
-rw-r--r--win32/Include/telnet.h320
-rw-r--r--win32/Include/w32_fzs.h48
-rw-r--r--win32/Src/getopt.c117
-rw-r--r--win32/prj/GNUmakefile177
-rw-r--r--win32/prj/WinDump.dsp635
-rw-r--r--win32/prj/WinDump.dsw29
203 files changed, 39178 insertions, 3340 deletions
diff --git a/CHANGES b/CHANGES
index 3f3b6759ce2e..33f453b7d528 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,45 @@
-$Header: /tcpdump/master/tcpdump/CHANGES,v 1.98.2.2 2008-10-15 23:26:30 ken Exp $
+Thu. April 1, 2010. guy@alum.mit.edu.
+ Summary for 4.1.1 tcpdump release
+ Fix build on systems with PF, such as FreeBSD and OpenBSD.
+ Don't blow up if a zero-length link-layer address is passed to
+ linkaddr_string().
+
+Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
+ Summary for 4.1.0 tcpdump release
+ Fix printing of MAC addresses for VLAN frames with a length
+ field
+ Add some additional bounds checks and use the EXTRACT_ macros
+ more
+ Add a -b flag to print the AS number in BGP packets in ASDOT
+ notation rather than ASPLAIN notation
+ Add ICMPv6 RFC 5006 support
+ Decode the access flags in NFS access requests
+ Handle the new DLT_ for memory-mapped USB captures on Linux
+ Make the default snapshot (-s) the maximum
+ Print name of device (when -L is used)
+ Support for OpenSolaris (and SXCE build 125 and later)
+ Print new TCP flags
+ Add support for RPL DIO
+ Add support for TCP User Timeout (UTO)
+ Add support for non-standard Ethertypes used by 3com PPPoE gear
+ Add support for 802.11n and 802.11s
+ Add support for Transparent Ethernet Bridge ethertype in GRE
+ Add 4 byte AS support for BGP printer
+ Add support for the MDT SAFI 66 BG printer
+ Add basic IPv6 support to print-olsr
+ Add USB printer
+ Add printer for ForCES
+ Handle frames with an FCS
+ Handle 802.11n Control Wrapper, Block Acq Req and Block Ack frames
+ Fix TCP sequence number printing
+ Report 802.2 packets as 802.2 instead of 802.3
+ Don't include -L/usr/lib in LDFLAGS
+ On x86_64 Linux, look in lib64 directory too
+ Lots of code clean ups
+ Autoconf clean ups
+ Update testcases to make output changes
+ Fix compiling with/out smi (--with{,out}-smi)
+ Fix compiling without IPv6 support (--disable-ipv6)
Mon. October 27, 2008. ken@netfunctional.ca. Summary for 4.0.0 tcpdump release
Add support for Bluetooth Sniffing
diff --git a/CREDITS b/CREDITS
index b058d67a727c..0a3b56eb238f 100644
--- a/CREDITS
+++ b/CREDITS
@@ -27,6 +27,7 @@ Additional people who have contributed patches:
Ben Byer <bushing at sourceforge dot net>
Atsushi Onoe <onoe at netbsd dot org>
Ben Smithurst <ben at scientia dot demon dot co dot uk>
+ Bert Vermeulen <bert at biot dot com>
Bjoern A. Zeeb <bzeeb at Zabbadoz dot NeT>
Brent L. Bates <blbates at vigyan dot com>
Brian Ginsbach <ginsbach at cray dot com>
@@ -44,11 +45,15 @@ Additional people who have contributed patches:
Daniel Hagerty <hag at ai dot mit dot edu>
Darren Reed <darrenr at reed dot wattle dot id dot au>
David Binderman <d dot binderman at virgin dot net>
+ David Horn <dhorn2000 at gmail dot com>
David Smith <dsmith at redhat dot com>
David Young <dyoung at ojctech dot com>
Don Ebright <Don dot Ebright at compuware dot com>
Eddie Kohler <xexd at sourceforge dot net>
+ Elmar Kirchner <elmar at juniper dot net>
+ Fang Wang <fangwang at sourceforge dot net>
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
+ Florian Forster <octo at verplant dot org>
Francis Dupont <Francis dot Dupont at enst-bretagne dot fr>
Francisco Matias Cuenca-Acuna <mcuenca at george dot rutgers dot edu>
Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
@@ -68,8 +73,10 @@ Additional people who have contributed patches:
Heinz-Ado Arnolds <Ado dot Arnolds at dhm-systems dot de>
Hendrik Scholz <hendrik at scholz dot net>
Ian McDonald <imcdnzl at gmail dot com>
- Jacek Tobiasz <Jacek dot Tobiasz at atm dot com dot pl>
+ Ilpo Järvinen <ilpo dot jarvinen at helsinki dot fi>
+ Jacek Tobiasz <Jacek dot Tobiasz at atm dot com dot pl>
Jakob Schlyter <jakob at openbsd dot org>
+ Jamal Hadi Salim <hadi at cyberus dot ca>
Jan Oravec <wsx at wsx6 dot net>
Jason R. Thorpe <thorpej at netbsd dot org>
Jefferson Ogata <jogata at nodc dot noaa dot gov>
@@ -78,10 +85,12 @@ Additional people who have contributed patches:
Jim Hutchins <jim at ca dot sandia dot gov>
Jonathan Heusser <jonny at drugphish dot ch>
Tatuya Jinmei <jinmei at kame dot net>
+ João Medeiros <ignotus21 at sourceforge dot net>
Joerg Mayer <jmayer@loplof.de>
- Jrgen Thomsen <jth at jth dot net>
+ Jørgen Thomsen <jth at jth dot net>
Julian Cowley <julian at lava dot net>
Kaarthik Sivakumar <kaarthik at torrentnet dot com>
+ Karl Norby <karl-norby at sourceforge dot net>
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
Kelly Carmichael <kcarmich at ipapp dot com>
Ken Hornstein <kenh at cmf dot nrl dot navy dot mil>
@@ -92,7 +101,8 @@ Additional people who have contributed patches:
Larry Lile <lile at stdio dot com>
Lennert Buytenhek <buytenh at gnu dot org>
Loris Degioanni <loris at netgroup-serv dot polito dot it>
- Love Hrnquist-strand <lha at stacken dot kth dot se>
+ Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
+ Lucas C. Villa Real <lucasvr at us dot ibm dot com>
Luis Martin Garcia <luis dot mgarc at gmail dot com>
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
Manu Pathak <mapathak at cisco dot com>
@@ -100,12 +110,13 @@ Additional people who have contributed patches:
Marc A. Lehmann <pcg at goof dot com>
Mark Ellzey Thomas <mark at ackers dot net>
Marko Kiiskila <carnil at cs dot tut dot fi>
- Markus Schpflin <schoepflin at sourceforge dot net>
+ Markus Schöpflin <schoepflin at sourceforge dot net>
Marshall Rose <mrose at dbc dot mtview dot ca dot us>
Martin Husemann <martin at netbsd dot org>
Max Laier <max at love2party dot net>
Michael A. Meffie III <meffie at sourceforge dot net>
Michael Madore <mmadore at turbolinux dot com>
+ Michael Riepe <too-tired at sourceforge dot net>
Michael Shalayeff <mickey at openbsd dot org>
Michael Shields <shields at msrl dot com>
Michael T. Stolarchuk <mts at off dot to>
@@ -132,13 +143,16 @@ Additional people who have contributed patches:
Peter Fales <peter at fales-lorenz dot net>
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
<pfhunt at users dot sourceforge dot net>
+ Peter Volkov <pva at gentoo dot org>
Phil Wood <cpw at lanl dot gov>
Rafal Maszkowski <rzm at icm dot edu dot pl>
+ Randy Sofia <rsofia at users dot sourceforge dot net>
Raphael Raimbault <raphael dot raimbault at netasq dot com>
Rick Cheng <rcheng at juniper dot net>
Rick Jones <rick dot jones2 at hp dot com>
Rick Watson <watsonrick at users dot sourceforge dot net>
Rob Braun <bbraun at synack dot net>
+ Robert Edmonds <stu-42 at sourceforge dot net>
Roderick Schertler <roderick at argon dot org>
Sagun Shakya <sagun dot shakya at sun dot com>
Sami Farin <safari at iki dot fi>
@@ -155,11 +169,14 @@ Additional people who have contributed patches:
Terry Kennedy <terry at tmk dot com>
Timo Koskiahde
Tony Li <tli at procket dot com>
+ Toshihiro Kanda <candy at fct dot kgc dot co dot jp>
Uns Lider <unslider at miranda dot org>
Victor Oppleman <oppleman at users dot sourceforge dot net>
Wesley Griffin <wgriffin at users dot sourceforge dot net>
+ Wesley Shields <wxs at FreeBSD dot org>
Wilbert de Graaf <wilbertdg at hetnet dot nl>
- Will Drewry <will at alum dot bu dot edu>
+ Will Drewry <will at alum dot bu dot edu>
+ William J. Hulley <bill dot hulley at gmail dot com>
Yen Yen Lim
Yoshifumi Nishida
diff --git a/INSTALL.txt b/INSTALL.txt
index e263f5368f0e..a03e2c0001b3 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -1,4 +1,4 @@
-@(#) $Header: /tcpdump/master/tcpdump/INSTALL.txt,v 1.1.2.1 2008-02-06 10:49:22 guy Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/INSTALL.txt,v 1.2 2008-02-06 10:47:53 guy Exp $ (LBL)
If you have not built libpcap, and your system does not have libpcap
installed, install libpcap first. Your system might provide a version
@@ -221,6 +221,7 @@ print-tftp.c - Trivial File Transfer Protocol printer routines
print-timed.c - BSD time daemon protocol printer routines
print-token.c - Token Ring printer routines
print-udp.c - UDP printer routines
+print-usb.c - USB printer routines
print-vjc.c - PPP Van Jacobson compression (RFC1144) printer routines
print-vrrp.c - Virtual Router Redundancy Protocol
print-wb.c - White Board printer routines
diff --git a/Makefile-devel-adds b/Makefile-devel-adds
new file mode 100644
index 000000000000..512a1199795c
--- /dev/null
+++ b/Makefile-devel-adds
@@ -0,0 +1,22 @@
+#
+# Auto-regenerate configure script or Makefile when things change.
+# From autoconf.info . Works best with GNU Make.
+#
+${srcdir}/configure: configure.in
+ cd ${srcdir} && autoconf
+
+# autoheader might not change config.h.in, so touch a stamp file.
+${srcdir}/config.h.in: ${srcdir}/stamp-h.in
+${srcdir}/stamp-h.in: configure.in acconfig.h
+ cd ${srcdir} && autoheader
+ echo timestamp > ${srcdir}/stamp-h.in
+
+config.h: stamp-h
+stamp-h: ${srcdir}/config.h.in config.status
+ ./config.status
+
+Makefile: Makefile.in config.status
+ ./config.status
+
+config.status: ${srcdir}/configure
+ ./config.status --recheck
diff --git a/Makefile.in b/Makefile.in
index e28e186a366d..8e7b73b4cf6a 100644
--- a/Makefile.in
+++ b/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.317.2.4 2008-05-27 07:14:26 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.325 2008-11-21 23:17:26 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -77,7 +77,7 @@ CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c
print-eap.c print-eigrp.c\
print-esp.c print-ether.c print-fddi.c print-fr.c \
print-gre.c print-hsrp.c print-icmp.c print-igmp.c \
- print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c \
+ print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c print-ipnet.c \
print-ipx.c print-isoclns.c print-juniper.c print-krb.c \
print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \
print-lmp.c print-lspping.c print-lwapp.c \
@@ -88,9 +88,9 @@ CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c
print-rx.c print-sctp.c print-sflow.c print-sip.c print-sl.c print-sll.c \
print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \
print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
- print-timed.c print-token.c print-udld.c print-udp.c \
- print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \
- print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c
+ print-timed.c print-token.c print-udld.c print-udp.c print-usb.c \
+ print-vjc.c print-vqp.c print-vrrp.c print-vtp.c print-forces.c \
+ print-wb.c print-zephyr.c signature.c setsignal.c tcpdump.c util.c
LIBNETDISSECT_SRC=print-isakmp.c
LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o)
@@ -128,6 +128,7 @@ HDR = \
ethertype.h \
extract.h \
fddi.h \
+ forces.h \
gmpls.h \
gmt2local.h \
icmp6.h \
@@ -139,6 +140,7 @@ HDR = \
ip.h \
ip6.h \
ipfc.h \
+ ipnet.h \
ipproto.h \
ipsec_doi.h \
ipx.h \
@@ -171,6 +173,7 @@ HDR = \
sctpConstants.h \
sctpHeader.h \
setsignal.h \
+ signature.h \
slcompress.h \
slip.h \
sll.h \
@@ -204,6 +207,7 @@ EXTRA_DIST = \
INSTALL.txt \
LICENSE \
Makefile.in \
+ Makefile-devel-adds \
README \
Readme.Win32 \
VERSION \
@@ -226,7 +230,6 @@ EXTRA_DIST = \
missing/bittypes.h \
missing/dlnames.c \
missing/datalinks.c \
- missing/getaddrinfo.c \
missing/getnameinfo.c \
missing/inet_aton.c \
missing/inet_ntop.c \
@@ -258,7 +261,83 @@ EXTRA_DIST = \
smbutil.c \
stime.awk \
strcasecmp.c \
- tcpdump.1 \
+ tcpdump.1.in \
+ tests/02-sunrise-sunset-esp.puu \
+ tests/08-sunrise-sunset-aes.puu \
+ tests/08-sunrise-sunset-esp2.puu \
+ tests/TESTLIST \
+ tests/TESTonce \
+ tests/TESTrun.sh \
+ tests/bgp-infinite-loop.pcap \
+ tests/bgp_vpn_attrset.out \
+ tests/bgp_vpn_attrset.pcap \
+ tests/chdlc-slarp-short.pcap \
+ tests/chdlc-slarp.pcap \
+ tests/dio.out \
+ tests/dio.pcap \
+ tests/e1000g.out \
+ tests/e1000g.pcap \
+ tests/eapon1.gdbinit \
+ tests/eapon1.out \
+ tests/eapon1.puu \
+ tests/eapon2.puu \
+ tests/esp-secrets.txt \
+ tests/esp0.out \
+ tests/esp1.gdbinit \
+ tests/esp1.out \
+ tests/esp2.gdbinit \
+ tests/esp2.out \
+ tests/esp3.gdbinit \
+ tests/esp4.gdbinit \
+ tests/esp5.gdbinit \
+ tests/esp5.out \
+ tests/espudp1.out \
+ tests/espudp1.puu \
+ tests/forces1.out \
+ tests/forces1.pcap \
+ tests/forces1vvv.out \
+ tests/forces1vvvv.out \
+ tests/forces2.out \
+ tests/forces2.pcap \
+ tests/forces2v.out \
+ tests/forces2vv.out \
+ tests/ikev2.puu \
+ tests/ikev2four.out \
+ tests/ikev2four.puu \
+ tests/ikev2fourv.out \
+ tests/ikev2fourv4.out \
+ tests/ikev2pI2-secrets.txt \
+ tests/ikev2pI2.out \
+ tests/ikev2pI2.puu \
+ tests/isakmp-delete-segfault.puu \
+ tests/isakmp-identification-segfault.puu \
+ tests/isakmp-pointer-loop.puu \
+ tests/isakmp1.out \
+ tests/isakmp2.out \
+ tests/isakmp3.out \
+ tests/isakmp4.out \
+ tests/isakmp4500.puu \
+ tests/isis-infinite-loop.pcap \
+ tests/ldp-infinite-loop.pcap \
+ tests/lmp.out \
+ tests/lmp.puu \
+ tests/lmp.sh \
+ tests/lspping-fec-ldp.pcap \
+ tests/lspping-fec-rsvp.pcap \
+ tests/mpls-ldp-hello.out \
+ tests/mpls-ldp-hello.puu \
+ tests/mpls-traceroute.pcap \
+ tests/ospf-gmpls.out \
+ tests/ospf-gmpls.puu \
+ tests/print-A.out \
+ tests/print-AA.out \
+ tests/print-capX.out \
+ tests/print-capXX.out \
+ tests/print-flags.puu \
+ tests/print-flags.sh \
+ tests/print-x.out \
+ tests/print-xx.out \
+ tests/rsvp-infinite-loop.pcap \
vfprintf.c \
win32/Include/Arpa/tftp.h \
win32/Include/errno.h \
@@ -312,14 +391,13 @@ version.o: version.c
version.c: $(srcdir)/VERSION
@rm -f $@
- if grep CVS ${srcdir}/VERSION >/dev/null; then \
+ if grep GIT ${srcdir}/VERSION >/dev/null; then \
read ver <${srcdir}/VERSION; \
echo $$ver | tr -d '\012'; \
date +_%Y_%m_%d; \
else \
cat ${srcdir}/VERSION; \
- fi | sed -e 's/.*/char version[] = "&";/' > $@
-
+ fi | sed -e 's/.*/const char version[] = "&";/' > $@
install: all
[ -d $(DESTDIR)$(sbindir) ] || \
@@ -328,7 +406,7 @@ install: all
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG).`cat ${srcdir}/VERSION`
[ -d $(DESTDIR)$(mandir)/man1 ] || \
(mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
- $(INSTALL_DATA) $(srcdir)/$(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1
+ $(INSTALL_DATA) $(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1
uninstall:
rm -f $(DESTDIR)$(sbindir)/$(PROG)
@@ -340,11 +418,15 @@ lint: $(GENSRC)
grep -v 'possible pointer alignment problem'
clean:
- rm -f $(CLEANFILES)
+ rm -f $(CLEANFILES) $(PROG)-`cat VERSION`.tar.gz
distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
- config.h gnuc.h os-proto.h stamp-h stamp-h.in
+ config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1
+
+check: tcpdump
+ uudecode --help || (echo "No uudecode program found, not running tests"; echo "apt-get/rpm install sharutils?"; exit 1)
+ (cd tests && ./TESTrun.sh)
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)
diff --git a/README b/README
index c2b6760aba44..ed657c1e3a01 100644
--- a/README
+++ b/README
@@ -1,19 +1,17 @@
-@(#) $Header: /tcpdump/master/tcpdump/README,v 1.66.2.1 2008-05-30 01:38:20 guy Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/README,v 1.68 2008-12-15 00:05:27 guy Exp $ (LBL)
-TCPDUMP 3.9
+TCPDUMP 4.x.y
Now maintained by "The Tcpdump Group"
See www.tcpdump.org
Please send inquiries/comments/reports to:
tcpdump-workers@lists.tcpdump.org
-Anonymous CVS is available via:
- cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master login
- (password "anoncvs")
- cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout tcpdump
+Anonymous Git is available via:
+ git clone git://bpf.tcpdump.org/tcpdump
-Version 3.9 of TCPDUMP can be retrieved with the CVS tag "tcpdump_3_9rel1":
- cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_9rel1 tcpdump
+Version 4.x.y of TCPDUMP can be retrieved with the CVS tag "tcpdump_4_xrely":
+ cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_4_xrely tcpdump
Please submit patches against the master copy to the tcpdump project on
sourceforge.net.
diff --git a/Readme.Win32 b/Readme.Win32
new file mode 100644
index 000000000000..fdf8b12bc767
--- /dev/null
+++ b/Readme.Win32
@@ -0,0 +1,24 @@
+To build tcpdump under Windows, you need:
+
+- version 6 (or higher) of Microsoft Visual Studio or the Cygnus gnu
+C compiler.
+- The November 2001 (or later) edition of Microsoft Platform
+Software Development Kit (SDK), that contains some necessary includes
+for IPv6 support. You can download it from http://www.microsoft.com/sdk
+- the WinPcap source code, that includes libpcap for win32. Download it
+from http://winpcap.polito.it or download libpcap sources from
+http://www.tcpdump.org and follow the instructions in the README.Win32
+file.
+
+First, extract tcpdump and WinPcap in the same folder, and build WinPcap.
+
+The Visual Studio project and the cygwin makefile are in the Win32\prj
+folder.
+
+From Visual Studio, open windump.dsw and build the program. The release
+version of the WinDump.exe executable file will be created in the
+windump\win32\prj\release directory . The debug version will be generated
+in windump\win32\prj\debug.
+
+From cygnus, go to windump\win32\prj\ and type "make". WinDump.exe will be
+created in the same directory. \ No newline at end of file
diff --git a/VERSION b/VERSION
index fcdb2e109f68..627a3f43a64f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.0.0
+4.1.1
diff --git a/acconfig.h b/acconfig.h
index f28d52c23043..97417969a27c 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -2,32 +2,18 @@
* make them to acconfig.h and rerun autoheader */
@TOP@
-/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
-#undef HAVE_BUGGY_CAST128
-
/* Define if you enable IPv6 support */
#undef INET6
/* Define if you enable support for the libsmi. */
#undef LIBSMI
-/* Define if you have the <smi.h> header file. */
-#undef HAVE_SMI_H
-
/* define if you have struct __res_state_ext */
#undef HAVE_RES_STATE_EXT
/* define if your struct __res_state has the nsort member */
#undef HAVE_NEW_RES_STATE
-/*
- * define if struct ether_header.ether_dhost is a struct with ether_addr_octet
- */
-#undef ETHER_HEADER_HAS_EA
-
-/* define if struct ether_arp contains arp_xsha */
-#undef ETHER_ARP_HAS_X
-
/* define if you have the addrinfo function. */
#undef HAVE_ADDRINFO
@@ -43,18 +29,9 @@
/* define if INADDRSZ is defined (XXX not used!) */
#undef HAVE_INADDRSZ
-/* define if this is a development version, to use additional prototypes. */
-#undef HAVE_OS_PROTO_H
-
-/* define if <unistd.h> defines __P() */
-#undef HAVE_PORTABLE_PROTOTYPE
-
/* define if RES_USE_INET6 is defined */
#undef HAVE_RES_USE_INET6
-/* define if struct sockaddr has the sa_len member */
-#undef HAVE_SOCKADDR_SA_LEN
-
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
@@ -91,18 +68,6 @@
/* define if you have getrpcbynumber() */
#undef HAVE_GETRPCBYNUMBER
-/* define if unaligned memory accesses fail */
-#undef LBL_ALIGN
-
-/* The successful return value from signal (?)XXX */
-#undef RETSIGVAL
-
-/* Define this on IRIX */
-#undef _BSD_SIGNALS
-
-/* For HP/UX ANSI compiler? */
-#undef _HPUX_SOURCE
-
/* AIX hack. */
#undef _SUN
@@ -115,14 +80,6 @@
/* 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
-
/* Define if you have the dnet_htoa function. */
#undef HAVE_DNET_HTOA
diff --git a/aclocal.m4 b/aclocal.m4
index 823862ee539b..40b586648d5f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.113.2.3 2008-09-25 21:50:04 guy Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.116 2008-09-25 21:45:50 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1995, 1996, 1997, 1998
dnl The Regents of the University of California. All rights reserved.
@@ -23,27 +23,23 @@ dnl LBL autoconf macros
dnl
dnl
-dnl Determine which compiler we're using (cc or gcc)
-dnl If using gcc, determine the version number
-dnl If using cc, require that it support ansi prototypes
-dnl If using gcc, use -O2 (otherwise use -O)
-dnl If using cc, explicitly specify /usr/local/include
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_C_INIT(copt, incls)
+dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
dnl
-dnl results:
+dnl It appears that newer versions of autoconf (2.64 and later) will,
+dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
+dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
+dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
+dnl in the Autoconf documentation.
dnl
-dnl $1 (copt set)
-dnl $2 (incls set)
-dnl CC
-dnl LDFLAGS
-dnl ac_cv_lbl_gcc_vers
-dnl LBL_CFLAGS
+dnl This causes a steaming heap of fail in our case, as we were, in
+dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
+dnl calling AC_PROG_CC, and then doing the tests we now do in
+dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
+dnl and AC_LBL_C_INIT at the top level.
dnl
-AC_DEFUN(AC_LBL_C_INIT,
- [AC_PREREQ(2.12)
+AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
+ [AC_PREREQ(2.50)
+ AC_BEFORE([$0], [AC_LBL_C_INIT])
AC_BEFORE([$0], [AC_PROG_CC])
AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
AC_BEFORE([$0], [AC_LBL_DEVEL])
@@ -72,7 +68,33 @@ AC_DEFUN(AC_LBL_C_INIT,
CC=cc
export CC
fi
- AC_PROG_CC
+])
+
+dnl
+dnl Determine which compiler we're using (cc or gcc)
+dnl If using gcc, determine the version number
+dnl If using cc, require that it support ansi prototypes
+dnl If using gcc, use -O2 (otherwise use -O)
+dnl If using cc, explicitly specify /usr/local/include
+dnl
+dnl usage:
+dnl
+dnl AC_LBL_C_INIT(copt, incls)
+dnl
+dnl results:
+dnl
+dnl $1 (copt set)
+dnl $2 (incls set)
+dnl CC
+dnl LDFLAGS
+dnl ac_cv_lbl_gcc_vers
+dnl LBL_CFLAGS
+dnl
+AC_DEFUN(AC_LBL_C_INIT,
+ [AC_PREREQ(2.50)
+ AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
+ AC_BEFORE([$0], [AC_LBL_DEVEL])
+ AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
if test "$GCC" = yes ; then
if test "$SHLICC2" = yes ; then
ac_cv_lbl_gcc_vers=2
@@ -117,8 +139,26 @@ AC_DEFUN(AC_LBL_C_INIT,
AC_MSG_ERROR(see the INSTALL doc for more info)
fi
CFLAGS="$savedcflags"
- V_CCOPT="-Aa $V_CCOPT"
- AC_DEFINE(_HPUX_SOURCE)
+ $1="-Aa $$1"
+ AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX])
+ ;;
+
+ osf*)
+ AC_MSG_CHECKING(for ansi mode in DEC compiler ($CC -std1))
+ savedcflags="$CFLAGS"
+ CFLAGS="-std1"
+ AC_CACHE_VAL(ac_cv_lbl_cc_osf1_cc_std1,
+ AC_TRY_COMPILE(
+ [#include <sys/types.h>],
+ [int frob(int, char *)],
+ ac_cv_lbl_cc_osf1_cc_std1=yes,
+ ac_cv_lbl_cc_osf1_cc_std1=no))
+ AC_MSG_RESULT($ac_cv_lbl_cc_osf1_cc_std1)
+ if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
+ AC_MSG_ERROR(see the INSTALL doc for more info)
+ fi
+ CFLAGS="$savedcflags"
+ $1="-std1 $$1"
;;
*)
@@ -132,11 +172,15 @@ AC_DEFUN(AC_LBL_C_INIT,
case "$host_os" in
irix*)
- V_CCOPT="$V_CCOPT -xansi -signed -O"
+ $1="$$1 -xansi -signed -O"
;;
osf*)
- V_CCOPT="$V_CCOPT -std1 -O"
+ #
+ # Presumed to be DEC OSF/1, Digital UNIX, or
+ # Tru64 UNIX.
+ #
+ $1="$$1 -O"
;;
ultrix*)
@@ -150,14 +194,14 @@ AC_DEFUN(AC_LBL_C_INIT,
ac_cv_lbl_cc_const_proto=no))
AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
if test $ac_cv_lbl_cc_const_proto = no ; then
- AC_DEFINE(const,)
+ AC_DEFINE(const,[],
+ [to handle Ultrix compilers that don't support const in prototypes])
fi
;;
esac
fi
])
-
#
# Try compiling a sample of the type of code that appears in
# gencode.c with "inline", "__inline__", and "__inline".
@@ -167,8 +211,13 @@ AC_DEFUN(AC_LBL_C_INIT,
# at least some versions of HP's C compiler can inline that, but can't
# inline a function that returns a struct pointer.
#
+# Make sure we use the V_CCOPT flags, because some of those might
+# disable inlining.
+#
AC_DEFUN(AC_LBL_C_INLINE,
[AC_MSG_CHECKING(for inline)
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$V_CCOPT"
AC_CACHE_VAL(ac_cv_lbl_inline, [
ac_cv_lbl_inline=""
ac_lbl_cc_inline=no
@@ -196,6 +245,7 @@ AC_DEFUN(AC_LBL_C_INLINE,
if test "$ac_lbl_cc_inline" = yes ; then
ac_cv_lbl_inline=$ac_lbl_inline
fi])
+ CFLAGS="$save_CFLAGS"
if test ! -z "$ac_cv_lbl_inline" ; then
AC_MSG_RESULT($ac_cv_lbl_inline)
else
@@ -238,9 +288,10 @@ AC_DEFUN(AC_LBL_LIBPCAP,
libpcap=FAIL
lastdir=FAIL
places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
- egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
+ egrep '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT)?$'`
for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do
- basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
+ basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//' | \
+ sed -e 's/-PRE-GIT$//' `
if test $lastdir = $basedir ; then
dnl skip alphas when an actual release is present
continue;
@@ -254,43 +305,60 @@ AC_DEFUN(AC_LBL_LIBPCAP,
done
if test $libpcap = FAIL ; then
AC_MSG_RESULT(not found)
- AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
- if test $libpcap = FAIL ; then
+
+ #
+ # Look for pcap-config.
+ #
+ AC_PATH_PROG(PCAP_CONFIG, pcap-config)
+ if test -n "$PCAP_CONFIG" ; then
+ #
+ # Found - use it to get the include flags for
+ # libpcap and the flags to link with libpcap.
+ #
+ $2="`\"$PCAP_CONFIG\" --cflags` $$2"
+ libpcap="`\"$PCAP_CONFIG\" --libs`"
+ else
+ #
+ # Not found; look for pcap.
+ #
+ AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
+ if test $libpcap = FAIL ; then
AC_MSG_ERROR(see the INSTALL doc for more info)
- fi
- dnl
- dnl Some versions of Red Hat Linux put "pcap.h" in
- dnl "/usr/include/pcap"; had the LBL folks done so,
- dnl that would have been a good idea, but for
- dnl the Red Hat folks to do so just breaks source
- dnl compatibility with other systems.
- dnl
- dnl We work around this by assuming that, as we didn't
- dnl find a local libpcap, libpcap is in /usr/lib or
- dnl /usr/local/lib and that the corresponding header
- dnl file is under one of those directories; if we don't
- dnl find it in either of those directories, we check to
- dnl see if it's in a "pcap" subdirectory of them and,
- dnl if so, add that subdirectory to the "-I" list.
- dnl
- dnl (We now also put pcap.h in /usr/include/pcap, but we
- dnl leave behind a /usr/include/pcap.h that includes it,
- dnl so you can still just include <pcap.h>.)
- dnl
- AC_MSG_CHECKING(for extraneous pcap header directories)
- if test \( ! -r /usr/local/include/pcap.h \) -a \
+ fi
+ dnl
+ dnl Some versions of Red Hat Linux put "pcap.h" in
+ dnl "/usr/include/pcap"; had the LBL folks done so,
+ dnl that would have been a good idea, but for
+ dnl the Red Hat folks to do so just breaks source
+ dnl compatibility with other systems.
+ dnl
+ dnl We work around this by assuming that, as we didn't
+ dnl find a local libpcap, libpcap is in /usr/lib or
+ dnl /usr/local/lib and that the corresponding header
+ dnl file is under one of those directories; if we don't
+ dnl find it in either of those directories, we check to
+ dnl see if it's in a "pcap" subdirectory of them and,
+ dnl if so, add that subdirectory to the "-I" list.
+ dnl
+ dnl (We now also put pcap.h in /usr/include/pcap, but we
+ dnl leave behind a /usr/include/pcap.h that includes it,
+ dnl so you can still just include <pcap.h>.)
+ dnl
+ AC_MSG_CHECKING(for extraneous pcap header directories)
+ if test \( ! -r /usr/local/include/pcap.h \) -a \
\( ! -r /usr/include/pcap.h \); then
- if test -r /usr/local/include/pcap/pcap.h; then
- d="/usr/local/include/pcap"
- elif test -r /usr/include/pcap/pcap.h; then
- d="/usr/include/pcap"
+ if test -r /usr/local/include/pcap/pcap.h; then
+ d="/usr/local/include/pcap"
+ elif test -r /usr/include/pcap/pcap.h; then
+ d="/usr/include/pcap"
+ fi
+ fi
+ if test -z "$d" ; then
+ AC_MSG_RESULT(not found)
+ else
+ $2="-I$d $$2"
+ AC_MSG_RESULT(found -- -I$d added)
fi
- fi
- if test -z "$d" ; then
- AC_MSG_RESULT(not found)
- else
- $2="-I$d $$2"
- AC_MSG_RESULT(found -- -I$d added)
fi
else
$1=$libpcap
@@ -304,26 +372,50 @@ AC_DEFUN(AC_LBL_LIBPCAP,
AC_MSG_ERROR(cannot find pcap.h, see INSTALL)
fi
AC_MSG_RESULT($libpcap)
+ AC_PATH_PROG(PCAP_CONFIG, pcap-config,, $d)
+ if test -n "$PCAP_CONFIG"; then
+ #
+ # The libpcap directory has a pcap-config script.
+ # Use it to get any additioal libraries needed
+ # to link with the libpcap archive library in
+ # that directory
+ #
+ libpcap="$libpcap `\"$PCAP_CONFIG\" --additional-libs --static`"
+ fi
fi
LIBS="$libpcap $LIBS"
- case "$host_os" in
+ if ! test -n "$PCAP_CONFIG" ; then
+ #
+ # We don't have pcap-config; find out any additional link flags
+ # we need. (If we have pcap-config, we assume it tells us what
+ # we need.)
+ #
+ case "$host_os" in
- aix*)
+ aix*)
+ #
+ # If libpcap is DLPI-based, we have to use /lib/pse.exp if
+ # present, as we use the STREAMS routines.
+ #
+ # (XXX - true only if we're linking with a static libpcap?)
+ #
pseexe="/lib/pse.exp"
AC_MSG_CHECKING(for $pseexe)
if test -f $pseexe ; then
AC_MSG_RESULT(yes)
LIBS="$LIBS -I:$pseexe"
fi
+
+ #
+ # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as
+ # we use them to load the BPF module.
#
- # We need "-lodm" and "-lcfg", as libpcap requires them on
- # AIX, and we just build a static libpcap.a and thus can't
- # arrange that when you link with libpcap you automatically
- # link with those libraries.
+ # (XXX - true only if we're linking with a static libpcap?)
#
LIBS="$LIBS -lodm -lcfg"
;;
- esac
+ esac
+ fi
dnl
dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
@@ -383,14 +475,14 @@ AC_DEFUN(AC_LBL_TYPE_SIGNAL,
[AC_BEFORE([$0], [AC_LBL_LIBPCAP])
AC_TYPE_SIGNAL
if test "$ac_cv_type_signal" = void ; then
- AC_DEFINE(RETSIGVAL,)
+ AC_DEFINE(RETSIGVAL,[],[return value of signal handlers])
else
- AC_DEFINE(RETSIGVAL,(0))
+ AC_DEFINE(RETSIGVAL,(0),[return value of signal handlers])
fi
case "$host_os" in
irix*)
- AC_DEFINE(_BSD_SIGNALS)
+ AC_DEFINE(_BSD_SIGNALS,1,[get BSD semantics on Irix])
;;
*)
@@ -439,65 +531,6 @@ AC_DEFUN(AC_LBL_FIXINCLUDES,
fi])
dnl
-dnl Check for flex, default to lex
-dnl Require flex 2.4 or higher
-dnl Check for bison, default to yacc
-dnl Default to lex/yacc if both flex and bison are not available
-dnl Define the yy prefix string if using flex and bison
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
-dnl
-dnl results:
-dnl
-dnl $1 (lex set)
-dnl $2 (yacc appended)
-dnl $3 (optional flex and bison -P prefix)
-dnl
-AC_DEFUN(AC_LBL_LEX_AND_YACC,
- [AC_ARG_WITH(flex, [ --without-flex don't use flex])
- AC_ARG_WITH(bison, [ --without-bison don't use bison])
- if test "$with_flex" = no ; then
- $1=lex
- else
- AC_CHECK_PROGS($1, flex, lex)
- fi
- if test "$$1" = flex ; then
- # The -V flag was added in 2.4
- AC_MSG_CHECKING(for flex 2.4 or higher)
- AC_CACHE_VAL(ac_cv_lbl_flex_v24,
- if flex -V >/dev/null 2>&1; then
- ac_cv_lbl_flex_v24=yes
- else
- ac_cv_lbl_flex_v24=no
- fi)
- AC_MSG_RESULT($ac_cv_lbl_flex_v24)
- if test $ac_cv_lbl_flex_v24 = no ; then
- s="2.4 or higher required"
- AC_MSG_WARN(ignoring obsolete flex executable ($s))
- $1=lex
- fi
- fi
- if test "$with_bison" = no ; then
- $2=yacc
- else
- AC_CHECK_PROGS($2, bison, yacc)
- fi
- if test "$$2" = bison ; then
- $2="$$2 -y"
- fi
- if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
- AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
- $1=lex
- $2=yacc
- fi
- if test "$$1" = flex -a -n "$3" ; then
- $1="$$1 -P$3"
- $2="$$2 -p $3"
- fi])
-
-dnl
dnl Checks to see if union wait is used with WEXITSTATUS()
dnl
dnl usage:
@@ -521,9 +554,9 @@ AC_DEFUN(AC_LBL_UNION_WAIT,
ac_cv_lbl_union_wait=yes))
AC_MSG_RESULT($ac_cv_lbl_union_wait)
if test $ac_cv_lbl_union_wait = yes ; then
- AC_DEFINE(DECLWAITSTATUS,union wait)
+ AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
else
- AC_DEFINE(DECLWAITSTATUS,int)
+ AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
fi])
dnl
@@ -538,7 +571,7 @@ dnl
dnl HAVE_SOCKADDR_SA_LEN (defined)
dnl
AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
- [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
+ [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
AC_TRY_COMPILE([
# include <sys/types.h>
@@ -548,7 +581,7 @@ AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
ac_cv_lbl_sockaddr_has_sa_len=no))
AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
- AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
+ AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
fi])
dnl
@@ -572,7 +605,7 @@ AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
else
ac_cv_lbl_have_run_path=no
fi
- rm -f conftest*])
+ rm -f -r conftest*])
AC_MSG_RESULT($ac_cv_lbl_have_run_path)
])
@@ -712,12 +745,12 @@ EOF
ac_cv_lbl_unaligned_fail=no
fi
fi
- rm -f conftest* core core.conftest
+ rm -f -r conftest* core core.conftest
;;
esac])
AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
if test $ac_cv_lbl_unaligned_fail = yes ; then
- AC_DEFINE(LBL_ALIGN)
+ AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
fi])
dnl
@@ -768,7 +801,8 @@ AC_DEFUN(AC_LBL_DEVEL,
name="lbl/os-$os.h"
if test -f $name ; then
ln -s $name os-proto.h
- AC_DEFINE(HAVE_OS_PROTO_H)
+ AC_DEFINE(HAVE_OS_PROTO_H, 1,
+ [if there's an os_proto.h for this platform, to use additional prototypes])
else
AC_MSG_WARN(can't find $name)
fi
@@ -954,83 +988,6 @@ AC_DEFUN(AC_CHECK_SA_LEN, [
])
dnl
-dnl Checks for portable prototype declaration macro
-AC_DEFUN(AC_CHECK_PORTABLE_PROTO, [
- AC_MSG_CHECKING(for __P)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <unistd.h>],
- [int f __P(())],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes; then
- AC_DEFINE(HAVE_PORTABLE_PROTOTYPE)
- fi
-])
-
-dnl checks for u_intXX_t
-AC_DEFUN(AC_CHECK_BITTYPES, [
- $1=yes
-dnl check for u_int8_t
- AC_MSG_CHECKING(for u_int8_t)
- AC_CACHE_VAL(ac_cv_u_int8_t,
- AC_TRY_COMPILE([
-# include <sys/types.h>],
- [u_int8_t i],
- ac_cv_u_int8_t=yes,
- ac_cv_u_int8_t=no))
- AC_MSG_RESULT($ac_cv_u_int8_t)
- if test $ac_cv_u_int8_t = yes; then
- AC_DEFINE(HAVE_U_INT8_T)
- else
- $1=no
- fi
-dnl check for u_int16_t
- AC_MSG_CHECKING(for u_int16_t)
- AC_CACHE_VAL(ac_cv_u_int16_t,
- AC_TRY_COMPILE([
-# include <sys/types.h>],
- [u_int16_t i],
- ac_cv_u_int16_t=yes,
- ac_cv_u_int16_t=no))
- AC_MSG_RESULT($ac_cv_u_int16_t)
- if test $ac_cv_u_int16_t = yes; then
- AC_DEFINE(HAVE_U_INT16_T)
- else
- $1=no
- fi
-dnl check for u_int32_t
- AC_MSG_CHECKING(for u_int32_t)
- AC_CACHE_VAL(ac_cv_u_int32_t,
- AC_TRY_COMPILE([
-# include <sys/types.h>],
- [u_int32_t i],
- ac_cv_u_int32_t=yes,
- ac_cv_u_int32_t=no))
- AC_MSG_RESULT($ac_cv_u_int32_t)
- if test $ac_cv_u_int32_t = yes; then
- AC_DEFINE(HAVE_U_INT32_T)
- else
- $1=no
- fi
-dnl check for u_int64_t
- AC_MSG_CHECKING(for u_int64_t)
- AC_CACHE_VAL(ac_cv_u_int64_t,
- AC_TRY_COMPILE([
-# include <sys/types.h>],
- [u_int64_t i],
- ac_cv_u_int64_t=yes,
- ac_cv_u_int64_t=no))
- AC_MSG_RESULT($ac_cv_u_int64_t)
- if test $ac_cv_u_int64_t = yes; then
- AC_DEFINE(HAVE_U_INT64_T)
- else
- $1=no
- fi
-])
-
-dnl
dnl Checks for addrinfo structure
AC_DEFUN(AC_STRUCT_ADDRINFO, [
AC_MSG_CHECKING(for addrinfo)
@@ -1259,9 +1216,50 @@ fi
AC_MSG_RESULT($ac_cv___attribute__)
])
+
+dnl
+dnl Test whether __attribute__((format)) can be applied to function
+dnl pointers
+dnl
+
+AC_DEFUN(AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER, [
+AC_MSG_CHECKING([whether __attribute__((format)) can be applied to function pointers])
+AC_CACHE_VAL(ac_cv___attribute___format_function_pointer, [
+AC_COMPILE_IFELSE(
+ AC_LANG_SOURCE([[
+#include <stdlib.h>
+
+extern int (*foo)(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+int
+main(int argc, char **argv)
+{
+ (*foo)("%s", "test");
+}
+ ]]),
+ac_cv___attribute___format_function_pointer=yes,
+ac_cv___attribute___format_function_pointer=no)])
+if test "$ac_cv___attribute___format_function_pointer" = "yes"; then
+ AC_DEFINE(__ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS, 1,
+ [define if your compiler allows __attribute__((format)) to be applied to function pointers])
+fi
+AC_MSG_RESULT($ac_cv___attribute___format_function_pointer)
+])
+
AC_DEFUN(AC_LBL_SSLEAY,
[
#
+ # Find the last component of $libdir; it's not necessarily
+ # "lib" - it might be "lib64" on, for example, x86-64
+ # Linux systems.
+ #
+ # We assume the directory in which we're looking for
+ # libcrypto has a subdirectory with that as its name.
+ #
+ tmplib=`echo "$libdir" | sed 's,.*/,,'`
+
+ #
# XXX - is there a better way to check if a given library is
# in a given directory than checking each of the possible
# shared library suffixes?
@@ -1271,10 +1269,10 @@ AC_DEFUN(AC_LBL_SSLEAY,
#
# Or should we just look for "libcrypto.*"?
#
- if test -d "$1/lib" -a \( -f "$1/lib/libcrypto.a" -o \
- -f "$1/lib/libcrypto.so" -o \
- -f "$1/lib/libcrypto.sl" -o \
- -f "$1/lib/libcrypto.dylib" \); then
+ if test -d "$1/$tmplib" -a \( -f "$1/$tmplib/libcrypto.a" -o \
+ -f "$1/$tmplib/libcrypto.so" -o \
+ -f "$1/$tmplib/libcrypto.sl" -o \
+ -f "$1/$tmplib/libcrypto.dylib" \); then
ac_cv_ssleay_path="$1"
fi
diff --git a/addrtoname.c b/addrtoname.c
index e67d1148c942..29826dfbc7e2 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -86,12 +86,12 @@ struct hnamemem {
struct hnamemem *nxt;
};
-struct hnamemem hnametable[HASHNAMESIZE];
-struct hnamemem tporttable[HASHNAMESIZE];
-struct hnamemem uporttable[HASHNAMESIZE];
-struct hnamemem eprototable[HASHNAMESIZE];
-struct hnamemem dnaddrtable[HASHNAMESIZE];
-struct hnamemem ipxsaptable[HASHNAMESIZE];
+static struct hnamemem hnametable[HASHNAMESIZE];
+static struct hnamemem tporttable[HASHNAMESIZE];
+static struct hnamemem uporttable[HASHNAMESIZE];
+static struct hnamemem eprototable[HASHNAMESIZE];
+static struct hnamemem dnaddrtable[HASHNAMESIZE];
+static struct hnamemem ipxsaptable[HASHNAMESIZE];
#if defined(INET6) && defined(WIN32)
/*
@@ -140,7 +140,7 @@ struct h6namemem {
struct h6namemem *nxt;
};
-struct h6namemem h6nametable[HASHNAMESIZE];
+static struct h6namemem h6nametable[HASHNAMESIZE];
#endif /* INET6 */
struct enamemem {
@@ -153,9 +153,9 @@ struct enamemem {
struct enamemem *e_nxt;
};
-struct enamemem enametable[HASHNAMESIZE];
-struct enamemem nsaptable[HASHNAMESIZE];
-struct enamemem bytestringtable[HASHNAMESIZE];
+static struct enamemem enametable[HASHNAMESIZE];
+static struct enamemem nsaptable[HASHNAMESIZE];
+static struct enamemem bytestringtable[HASHNAMESIZE];
struct protoidmem {
u_int32_t p_oui;
@@ -164,7 +164,7 @@ struct protoidmem {
struct protoidmem *p_nxt;
};
-struct protoidmem protoidtable[HASHNAMESIZE];
+static struct protoidmem protoidtable[HASHNAMESIZE];
/*
* A faster replacement for inet_ntoa().
@@ -311,7 +311,7 @@ getname6(const u_char *ap)
}
#endif /* INET6 */
-static char hex[] = "0123456789abcdef";
+static const char hex[] = "0123456789abcdef";
/* Find the hash node that corresponds the ether address 'ep' */
@@ -514,13 +514,14 @@ linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int le
register char *cp;
register struct enamemem *tp;
- if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) {
- return etheraddr_string(ep);
- }
+ if (len == 0)
+ return ("<empty>");
- if (type == LINKADDR_FRELAY) {
- return q922_string(ep);
- }
+ if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
+ return (etheraddr_string(ep));
+
+ if (type == LINKADDR_FRELAY)
+ return (q922_string(ep));
tp = lookup_bytestring(ep, len);
if (tp->e_name)
@@ -747,7 +748,7 @@ init_eprotoarray(void)
}
}
-static struct protoidlist {
+static const struct protoidlist {
const u_char protoid[5];
const char *name;
} protoidlist[] = {
@@ -768,7 +769,7 @@ init_protoidarray(void)
{
register int i;
register struct protoidmem *tp;
- struct protoidlist *pl;
+ const struct protoidlist *pl;
u_char protoid[5];
protoid[0] = 0;
@@ -792,7 +793,7 @@ init_protoidarray(void)
}
}
-static struct etherlist {
+static const struct etherlist {
const u_char addr[6];
const char *name;
} etherlist[] = {
@@ -817,7 +818,7 @@ static struct etherlist {
static void
init_etherarray(void)
{
- register struct etherlist *el;
+ register const struct etherlist *el;
register struct enamemem *tp;
#ifdef USE_ETHER_NTOHOST
char name[256];
@@ -861,7 +862,7 @@ init_etherarray(void)
}
}
-static struct tok ipxsap_db[] = {
+static const struct tok ipxsap_db[] = {
{ 0x0000, "Unknown" },
{ 0x0001, "User" },
{ 0x0002, "User Group" },
diff --git a/af.c b/af.c
index e3c77bf3c4ce..2c8a928e02ad 100644
--- a/af.c
+++ b/af.c
@@ -28,7 +28,7 @@ static const char rcsid[] _U_ =
#include "interface.h"
#include "af.h"
-struct tok af_values[] = {
+const struct tok af_values[] = {
{ 0, "Reserved"},
{ AFNUM_INET, "IPv4"},
{ AFNUM_INET6, "IPv6"},
@@ -50,7 +50,7 @@ struct tok af_values[] = {
{ 0, NULL},
};
-struct tok bsd_af_values[] = {
+const struct tok bsd_af_values[] = {
{ BSD_AFNUM_INET, "IPv4" },
{ BSD_AFNUM_NS, "NS" },
{ BSD_AFNUM_ISO, "ISO" },
diff --git a/af.h b/af.h
index c036cef9637d..679cc8e5fa18 100644
--- a/af.h
+++ b/af.h
@@ -17,8 +17,8 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-extern struct tok af_values[];
-extern struct tok bsd_af_values[];
+extern const struct tok af_values[];
+extern const struct tok bsd_af_values[];
/* RFC1700 address family numbers */
#define AFNUM_INET 1
diff --git a/atmuni31.h b/atmuni31.h
index 32acfb1ee504..ab7a03ddf54c 100644
--- a/atmuni31.h
+++ b/atmuni31.h
@@ -29,7 +29,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/atmuni31.h,v 1.2.6.1 2007-10-22 19:39:12 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/atmuni31.h,v 1.3 2007-10-22 19:37:51 guy Exp $ (LBL)
*/
/* Based on UNI3.1 standard by ATM Forum */
diff --git a/bootp.h b/bootp.h
index 8f61b13a8617..65ca3766c713 100644
--- a/bootp.h
+++ b/bootp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.18 2007-08-21 21:59:11 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.19 2008-04-22 09:46:03 hannes Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@@ -27,7 +27,8 @@ struct bootp {
u_int8_t bp_hops; /* gateway hops */
u_int32_t bp_xid; /* transaction ID */
u_int16_t bp_secs; /* seconds since boot began */
- u_int16_t bp_flags; /* flags - see bootp_flag_values[] in print-bootp.c */
+ u_int16_t bp_flags; /* flags - see bootp_flag_values[]
+ in print-bootp.c */
struct in_addr bp_ciaddr; /* client IP address */
struct in_addr bp_yiaddr; /* 'your' IP address */
struct in_addr bp_siaddr; /* server IP address */
diff --git a/bpf_dump.c b/bpf_dump.c
index f509b7edbfcb..b50d7e7b6639 100644
--- a/bpf_dump.c
+++ b/bpf_dump.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.16.4.1 2008-02-14 20:54:53 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.17 2008-02-14 20:53:49 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
diff --git a/checksum.c b/checksum.c
index f441be3d4d7a..da4718ff53bf 100644
--- a/checksum.c
+++ b/checksum.c
@@ -31,17 +31,73 @@ static const char rcsid[] _U_ =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "interface.h"
-#define CRC10_POLYNOMIAL 0x633
-static u_int16_t crc10_table[256];
+/*
+ * CRC-10 table generated using the following Python snippet:
+
+import sys
+
+crc_table = []
+for i in range(256):
+ accum = i << 2
+ for j in range(8):
+ accum <<= 1
+ if accum & 0x400:
+ accum ^= 0x633
+ crc_table.append(accum)
+
+for i in range(len(crc_table)/8):
+ for j in range(8):
+ sys.stdout.write("0x%04x, " % crc_table[i*8+j])
+ sys.stdout.write("\n")
+
+ */
+static const u_int16_t crc10_table[256] =
+{
+ 0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff,
+ 0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe,
+ 0x0031, 0x0202, 0x0264, 0x0057, 0x02a8, 0x009b, 0x00fd, 0x02ce,
+ 0x0330, 0x0103, 0x0165, 0x0356, 0x01a9, 0x039a, 0x03fc, 0x01cf,
+ 0x0062, 0x0251, 0x0237, 0x0004, 0x02fb, 0x00c8, 0x00ae, 0x029d,
+ 0x0363, 0x0150, 0x0136, 0x0305, 0x01fa, 0x03c9, 0x03af, 0x019c,
+ 0x0053, 0x0260, 0x0206, 0x0035, 0x02ca, 0x00f9, 0x009f, 0x02ac,
+ 0x0352, 0x0161, 0x0107, 0x0334, 0x01cb, 0x03f8, 0x039e, 0x01ad,
+ 0x00c4, 0x02f7, 0x0291, 0x00a2, 0x025d, 0x006e, 0x0008, 0x023b,
+ 0x03c5, 0x01f6, 0x0190, 0x03a3, 0x015c, 0x036f, 0x0309, 0x013a,
+ 0x00f5, 0x02c6, 0x02a0, 0x0093, 0x026c, 0x005f, 0x0039, 0x020a,
+ 0x03f4, 0x01c7, 0x01a1, 0x0392, 0x016d, 0x035e, 0x0338, 0x010b,
+ 0x00a6, 0x0295, 0x02f3, 0x00c0, 0x023f, 0x000c, 0x006a, 0x0259,
+ 0x03a7, 0x0194, 0x01f2, 0x03c1, 0x013e, 0x030d, 0x036b, 0x0158,
+ 0x0097, 0x02a4, 0x02c2, 0x00f1, 0x020e, 0x003d, 0x005b, 0x0268,
+ 0x0396, 0x01a5, 0x01c3, 0x03f0, 0x010f, 0x033c, 0x035a, 0x0169,
+ 0x0188, 0x03bb, 0x03dd, 0x01ee, 0x0311, 0x0122, 0x0144, 0x0377,
+ 0x0289, 0x00ba, 0x00dc, 0x02ef, 0x0010, 0x0223, 0x0245, 0x0076,
+ 0x01b9, 0x038a, 0x03ec, 0x01df, 0x0320, 0x0113, 0x0175, 0x0346,
+ 0x02b8, 0x008b, 0x00ed, 0x02de, 0x0021, 0x0212, 0x0274, 0x0047,
+ 0x01ea, 0x03d9, 0x03bf, 0x018c, 0x0373, 0x0140, 0x0126, 0x0315,
+ 0x02eb, 0x00d8, 0x00be, 0x028d, 0x0072, 0x0241, 0x0227, 0x0014,
+ 0x01db, 0x03e8, 0x038e, 0x01bd, 0x0342, 0x0171, 0x0117, 0x0324,
+ 0x02da, 0x00e9, 0x008f, 0x02bc, 0x0043, 0x0270, 0x0216, 0x0025,
+ 0x014c, 0x037f, 0x0319, 0x012a, 0x03d5, 0x01e6, 0x0180, 0x03b3,
+ 0x024d, 0x007e, 0x0018, 0x022b, 0x00d4, 0x02e7, 0x0281, 0x00b2,
+ 0x017d, 0x034e, 0x0328, 0x011b, 0x03e4, 0x01d7, 0x01b1, 0x0382,
+ 0x027c, 0x004f, 0x0029, 0x021a, 0x00e5, 0x02d6, 0x02b0, 0x0083,
+ 0x012e, 0x031d, 0x037b, 0x0148, 0x03b7, 0x0184, 0x01e2, 0x03d1,
+ 0x022f, 0x001c, 0x007a, 0x0249, 0x00b6, 0x0285, 0x02e3, 0x00d0,
+ 0x011f, 0x032c, 0x034a, 0x0179, 0x0386, 0x01b5, 0x01d3, 0x03e0,
+ 0x021e, 0x002d, 0x004b, 0x0278, 0x0087, 0x02b4, 0x02d2, 0x00e1
+};
static void
init_crc10_table(void)
{
+#define CRC10_POLYNOMIAL 0x633
register int i, j;
register u_int16_t accum;
+ u_int16_t verify_crc10_table[256];
for ( i = 0; i < 256; i++ )
{
@@ -50,9 +106,12 @@ init_crc10_table(void)
{
if ((accum <<= 1) & 0x400) accum ^= CRC10_POLYNOMIAL;
}
- crc10_table[i] = accum;
+ verify_crc10_table[i] = accum;
}
- return;
+ assert(memcmp(verify_crc10_table,
+ crc10_table,
+ sizeof(verify_crc10_table)) == 0);
+#undef CRC10_POLYNOMIAL
}
u_int16_t
diff --git a/config.guess b/config.guess
index 4c5bde8a2806..c2246a4f7f4c 100755
--- a/config.guess
+++ b/config.guess
@@ -1,9 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+# Free Software Foundation, Inc.
-timestamp='2003-10-16'
+timestamp='2009-12-30'
# 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
@@ -17,23 +18,25 @@ timestamp='2003-10-16'
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
+
+# Originally written by Per Bothner. Please send patches (context
+# diff format) to <config-patches@gnu.org> and include a ChangeLog
+# entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
me=`echo "$0" | sed -e 's,.*/,,'`
@@ -53,8 +56,9 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -66,11 +70,11 @@ Try \`$me --help' for more information."
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
- echo "$timestamp" ; exit 0 ;;
+ echo "$timestamp" ; exit ;;
--version | -v )
- echo "$version" ; exit 0 ;;
+ echo "$version" ; exit ;;
--help | --h* | -h )
- echo "$usage"; exit 0 ;;
+ echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
@@ -104,7 +108,7 @@ set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
@@ -123,7 +127,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ;'
+esac ; set_cc_for_build= ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
@@ -158,6 +162,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
@@ -166,7 +171,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep __ELF__ >/dev/null
+ | grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
@@ -196,53 +201,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
- exit 0 ;;
- amiga:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- arc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- hp300:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- macppc:OpenBSD:*:*)
- echo powerpc-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme88k:OpenBSD:*:*)
- echo m88k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvmeppc:OpenBSD:*:*)
- echo powerpc-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- pegasos:OpenBSD:*:*)
- echo powerpc-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- pmax:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sgi:OpenBSD:*:*)
- echo mipseb-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sun3:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- wgrisc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:OpenBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
alpha:OSF1:*:*)
- if test $UNAME_RELEASE = "V4.0"; then
+ case $UNAME_RELEASE in
+ *4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- fi
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
@@ -280,45 +264,49 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
+ # A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit 0 ;;
- Alpha*:OpenVMS:*:*)
- echo alpha-hp-vms
- exit 0 ;;
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
# of the specific Alpha model?
echo alpha-pc-interix
- exit 0 ;;
+ exit ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
- exit 0 ;;
+ exit ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
- exit 0;;
+ exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
- exit 0 ;;
+ exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
- exit 0 ;;
+ exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
- exit 0 ;;
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
- exit 0 ;;
+ exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
- exit 0;;
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
- exit 0;;
+ exit ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
@@ -326,32 +314,51 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
else
echo pyramid-pyramid-bsd
fi
- exit 0 ;;
+ exit ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
- exit 0 ;;
+ exit ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
- exit 0 ;;
- DRS?6000:UNIX_SV:4.2*:7*)
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7 && exit 0 ;;
+ sparc) echo sparc-icl-nx7; exit ;;
esac ;;
+ s390x:SunOS:*:*)
+ echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
+ exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
+ exit ;;
+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+ echo i386-pc-auroraux${UNAME_RELEASE}
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ eval $set_cc_for_build
+ SUN_ARCH="i386"
+ # If there is a compiler, see if it is configured for 64-bit objects.
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+ # This test works for both compilers.
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH="x86_64"
+ fi
+ fi
+ echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
+ exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
@@ -360,10 +367,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit 0 ;;
+ exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
@@ -375,10 +382,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
- exit 0 ;;
+ exit ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
@@ -389,37 +396,40 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
- exit 0 ;;
+ exit ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
@@ -443,32 +453,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
exit (-1);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c \
- && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
- && exit 0
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
echo mips-mips-riscos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
- exit 0 ;;
+ exit ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
- exit 0 ;;
+ exit ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
- exit 0 ;;
+ exit ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
- exit 0 ;;
+ exit ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
- exit 0 ;;
+ exit ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
- exit 0 ;;
+ exit ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
- exit 0 ;;
+ exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
@@ -484,29 +495,29 @@ EOF
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
- exit 0 ;;
+ exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
- exit 0 ;;
+ exit ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
- exit 0 ;;
+ exit ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
- exit 0 ;;
+ exit ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
- exit 0 ;;
+ exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit 0 ;;
+ exit ;;
????????: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 '
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
- exit 0 ;;
+ exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
@@ -514,7 +525,7 @@ EOF
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit 0 ;;
+ exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
@@ -529,15 +540,19 @@ EOF
exit(0);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
- echo rs6000-ibm-aix3.2.5
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
- exit 0 ;;
- *:AIX:*:[45])
+ exit ;;
+ *:AIX:*:[456])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
@@ -550,28 +565,28 @@ EOF
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit 0 ;;
+ exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
- exit 0 ;;
+ exit ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
- exit 0 ;;
+ exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit 0 ;; # report: romp-ibm BSD 4.3
+ exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
- exit 0 ;;
+ exit ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
- exit 0 ;;
+ exit ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
- exit 0 ;;
+ exit ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
- exit 0 ;;
+ exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
@@ -633,9 +648,19 @@ EOF
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
- # avoid double evaluation of $set_cc_for_build
- test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep -q __LP64__
then
HP_ARCH="hppa2.0w"
else
@@ -643,11 +668,11 @@ EOF
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit 0 ;;
+ exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
- exit 0 ;;
+ exit ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
@@ -675,221 +700,248 @@ EOF
exit (0);
}
EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
- exit 0 ;;
+ exit ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
- exit 0 ;;
+ exit ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
- exit 0 ;;
+ exit ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
- exit 0 ;;
+ exit ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
- exit 0 ;;
+ exit ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
- exit 0 ;;
+ exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
- exit 0 ;;
+ exit ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
- exit 0 ;;
+ exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
- exit 0 ;;
+ exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
- exit 0 ;;
+ exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
- exit 0 ;;
+ exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
- exit 0 ;;
+ exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
- exit 0 ;;
+ exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ exit ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ exit ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ exit ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ exit ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ exit ;;
*:UNICOS/mp:*:*)
- echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit 0 ;;
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
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 "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit 0 ;;
+ exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit 0 ;;
+ exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:FreeBSD:*:*)
- # Determine whether the default compiler uses glibc.
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #if __GLIBC__ >= 2
- LIBC=gnu
- #else
- LIBC=
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- # GNU/KFreeBSD systems have a "k" prefix to indicate we are using
- # FreeBSD's kernel, but not the complete OS.
- case ${LIBC} in gnu) kernel_only='k' ;; esac
- echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
- exit 0 ;;
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
- exit 0 ;;
- i*:MINGW*:*)
+ exit ;;
+ *:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
- exit 0 ;;
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
- exit 0 ;;
- x86:Interix*:[34]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
- exit 0 ;;
+ exit ;;
+ *:Interix*:*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ authenticamd | genuineintel | EM64T)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
- exit 0 ;;
+ exit ;;
+ 8664:Windows_NT:*)
+ echo x86_64-pc-mks
+ exit ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i586-pc-interix
- exit 0 ;;
+ exit ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
- exit 0 ;;
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
- exit 0 ;;
+ exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
+ exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit 0 ;;
+ exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
- exit 0 ;;
+ exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
- exit 0 ;;
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
+ exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
- exit 0 ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
- mips:Linux:*:*)
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips
- #undef mipsel
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
- #else
- CPU=
- #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
- ;;
- mips64:Linux:*:*)
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
- #undef mips64
- #undef mips64el
+ #undef ${UNAME_MACHINE}
+ #undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
+ CPU=${UNAME_MACHINE}el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
+ CPU=${UNAME_MACHINE}
#else
CPU=
#endif
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit 0 ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit 0 ;;
- alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
- EV5) UNAME_MACHINE=alphaev5 ;;
- EV56) UNAME_MACHINE=alphaev56 ;;
- PCA56) UNAME_MACHINE=alphapca56 ;;
- PCA57) UNAME_MACHINE=alphapca56 ;;
- EV6) UNAME_MACHINE=alphaev6 ;;
- EV67) UNAME_MACHINE=alphaev67 ;;
- EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit 0 ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ padre:Linux:*:*)
+ echo sparc-unknown-linux-gnu
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
@@ -897,87 +949,40 @@ EOF
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 ;;
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
- exit 0 ;;
+ exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
+ exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
+ exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit 0 ;;
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
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.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit 0 ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit 0 ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit 0 ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #ifdef __INTEL_COMPILER
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
- test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
- ;;
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
i*86:DYNIX/ptx:4*:*)
# 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.
echo i386-sequent-sysv4
- exit 0 ;;
+ exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
@@ -985,24 +990,27 @@ EOF
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit 0 ;;
+ exit ;;
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 ;;
+ exit ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
- exit 0 ;;
+ exit ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
- exit 0 ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit 0 ;;
+ exit ;;
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
@@ -1010,15 +1018,16 @@ EOF
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
- exit 0 ;;
- i*86:*:5:[78]*)
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
- exit 0 ;;
+ exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
@@ -1036,73 +1045,86 @@ EOF
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
- exit 0 ;;
+ exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i386.
- echo i386-pc-msdosdjgpp
- exit 0 ;;
+ # the processor, so we play safe by assuming i586.
+ # Note: whatever this is, it MUST be the same as what config.sub
+ # prints for the "djgpp" host, or else GDB configury will decide that
+ # this is a cross-build.
+ echo i586-pc-msdosdjgpp
+ exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
- exit 0 ;;
+ exit ;;
paragon:*:*:*)
echo i860-intel-osf1
- exit 0 ;;
+ exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
- exit 0 ;;
+ exit ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
- exit 0 ;;
+ exit ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
- exit 0 ;;
+ exit ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
- exit 0 ;;
- M68*:*:R3V[567]*:*)
- test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && echo i486-ncr-sysv4 && exit 0 ;;
+ && { echo i486-ncr-sysv4; exit; } ;;
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+ OS_REL='.3'
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
- exit 0 ;;
+ exit ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
- exit 0 ;;
+ exit ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
- exit 0 ;;
+ exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
@@ -1110,68 +1132,94 @@ EOF
else
echo ns32k-sni-sysv
fi
- exit 0 ;;
+ exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
- exit 0 ;;
+ exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
- exit 0 ;;
+ exit ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
- exit 0 ;;
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
- exit 0 ;;
+ exit ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
- exit 0 ;;
+ exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
- exit 0 ;;
+ exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
- exit 0 ;;
+ exit ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
- exit 0 ;;
+ exit ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
- exit 0 ;;
+ exit ;;
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
+ echo i586-pc-haiku
+ exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:Darwin:*:*)
- case `uname -p` in
- *86) UNAME_PROCESSOR=i686 ;;
- powerpc) UNAME_PROCESSOR=powerpc ;;
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ i386)
+ eval $set_cc_for_build
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ UNAME_PROCESSOR="x86_64"
+ fi
+ fi ;;
+ unknown) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
@@ -1179,22 +1227,25 @@ EOF
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
- exit 0 ;;
- NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*)
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
- exit 0 ;;
+ exit ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
- exit 0 ;;
+ exit ;;
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
@@ -1205,31 +1256,50 @@ EOF
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
- exit 0 ;;
+ exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
- exit 0 ;;
+ exit ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
- exit 0 ;;
+ exit ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
- exit 0 ;;
+ exit ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
- exit 0 ;;
+ exit ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
- exit 0 ;;
+ exit ;;
*:ITS:*:*)
echo pdp10-unknown-its
- exit 0 ;;
+ exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
- exit 0 ;;
- *:DRAGONFLY:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE}
- exit 0 ;;
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+ i*86:AROS:*:*)
+ echo ${UNAME_MACHINE}-pc-aros
+ exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1261,7 +1331,7 @@ main ()
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix"); exit (0);
+ printf ("arm-acorn-riscix\n"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
@@ -1350,11 +1420,12 @@ main ()
}
EOF
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
# Convex versions that predate uname can use getsysinfo(1)
@@ -1363,22 +1434,22 @@ then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
- exit 0 ;;
+ exit ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
- exit 0 ;;
+ exit ;;
c34*)
echo c34-convex-bsd
- exit 0 ;;
+ exit ;;
c38*)
echo c38-convex-bsd
- exit 0 ;;
+ exit ;;
c4*)
echo c4-convex-bsd
- exit 0 ;;
+ exit ;;
esac
fi
@@ -1389,7 +1460,9 @@ 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/
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
If the version you run ($0) is already up to date, please
send the following data and any information you think might be
diff --git a/config.h.in b/config.h.in
index 085cc936b36e..20c3fcf394a9 100644
--- a/config.h.in
+++ b/config.h.in
@@ -2,32 +2,18 @@
/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in --
* make them to acconfig.h and rerun autoheader */
-/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
-#undef HAVE_BUGGY_CAST128
-
/* Define if you enable IPv6 support */
#undef INET6
/* Define if you enable support for the libsmi. */
#undef LIBSMI
-/* Define if you have the <smi.h> header file. */
-#undef HAVE_SMI_H
-
/* define if you have struct __res_state_ext */
#undef HAVE_RES_STATE_EXT
/* define if your struct __res_state has the nsort member */
#undef HAVE_NEW_RES_STATE
-/*
- * define if struct ether_header.ether_dhost is a struct with ether_addr_octet
- */
-#undef ETHER_HEADER_HAS_EA
-
-/* define if struct ether_arp contains arp_xsha */
-#undef ETHER_ARP_HAS_X
-
/* define if you have the addrinfo function. */
#undef HAVE_ADDRINFO
@@ -43,18 +29,9 @@
/* define if INADDRSZ is defined (XXX not used!) */
#undef HAVE_INADDRSZ
-/* define if this is a development version, to use additional prototypes. */
-#undef HAVE_OS_PROTO_H
-
-/* define if <unistd.h> defines __P() */
-#undef HAVE_PORTABLE_PROTOTYPE
-
/* define if RES_USE_INET6 is defined */
#undef HAVE_RES_USE_INET6
-/* define if struct sockaddr has the sa_len member */
-#undef HAVE_SOCKADDR_SA_LEN
-
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
@@ -91,18 +68,6 @@
/* define if you have getrpcbynumber() */
#undef HAVE_GETRPCBYNUMBER
-/* define if unaligned memory accesses fail */
-#undef LBL_ALIGN
-
-/* The successful return value from signal (?)XXX */
-#undef RETSIGVAL
-
-/* Define this on IRIX */
-#undef _BSD_SIGNALS
-
-/* For HP/UX ANSI compiler? */
-#undef _HPUX_SOURCE
-
/* AIX hack. */
#undef _SUN
@@ -115,14 +80,6 @@
/* 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
-
/* Define if you have the dnet_htoa function. */
#undef HAVE_DNET_HTOA
@@ -151,9 +108,6 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
-/* Define to 1 if you have the `getaddrinfo' function. */
-#undef HAVE_GETADDRINFO
-
/* Define to 1 if you have the `getnameinfo' function. */
#undef HAVE_GETNAMEINFO
@@ -187,6 +141,9 @@
/* Define to 1 if you have the <openssl/evp.h> header file. */
#undef HAVE_OPENSSL_EVP_H
+/* if there's an os_proto.h for this platform, to use additional prototypes */
+#undef HAVE_OS_PROTO_H
+
/* Define to 1 if you have the <pcap/bluetooth.h> header file. */
#undef HAVE_PCAP_BLUETOOTH_H
@@ -208,6 +165,9 @@
/* Define to 1 if you have the `pcap_lib_version' function. */
#undef HAVE_PCAP_LIB_VERSION
+/* Define to 1 if you have the <pcap/usb.h> header file. */
+#undef HAVE_PCAP_USB_H
+
/* Define to 1 if you have the `pfopen' function. */
#undef HAVE_PFOPEN
@@ -229,6 +189,9 @@
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
+/* if struct sockaddr has the sa_len member */
+#undef HAVE_SOCKADDR_SA_LEN
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -283,6 +246,9 @@
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
+/* if unaligned access fails */
+#undef LBL_ALIGN
+
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
@@ -307,6 +273,9 @@
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
+/* return value of signal handlers */
+#undef RETSIGVAL
+
/* The size of `char', as computed by sizeof. */
#undef SIZEOF_CHAR
@@ -328,6 +297,19 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
+/* get BSD semantics on Irix */
+#undef _BSD_SIGNALS
+
+/* needed on HP-UX */
+#undef _HPUX_SOURCE
+
+/* define if your compiler allows __attribute__((format)) to be applied to
+ function pointers */
+#undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
+
+/* to handle Ultrix compilers that don't support const in prototypes */
+#undef const
+
/* Define as token for inline if inlining supported */
#undef inline
diff --git a/config.sub b/config.sub
index 56981740d6ef..85186096a9e1 100755
--- a/config.sub
+++ b/config.sub
@@ -1,9 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+# Free Software Foundation, Inc.
-timestamp='2003-11-03'
+timestamp='2009-12-31'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -21,22 +22,26 @@ timestamp='2003-11-03'
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
+
# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
+# diff and a properly formatted GNU ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
@@ -70,8 +75,9 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -83,11 +89,11 @@ Try \`$me --help' for more information."
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
- echo "$timestamp" ; exit 0 ;;
+ echo "$timestamp" ; exit ;;
--version | -v )
- echo "$version" ; exit 0 ;;
+ echo "$version" ; exit ;;
--help | --h* | -h )
- echo "$usage"; exit 0 ;;
+ echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
@@ -99,7 +105,7 @@ while test $# -gt 0 ; do
*local*)
# First pass through any local machine types.
echo $1
- exit 0;;
+ exit ;;
* )
break ;;
@@ -118,8 +124,10 @@ 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* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -145,10 +153,13 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis)
+ -apple | -axis | -knuth | -cray | -microblaze)
os=
basic_machine=$1
;;
+ -bluegene*)
+ os=-cnk
+ ;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
@@ -170,6 +181,10 @@ case $os in
-hiux*)
os=-hiuxwe2
;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -186,6 +201,10 @@ case $os in
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -230,22 +249,28 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
+ | fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
- | m32r | m68000 | m68k | m88k | mcore \
+ | lm32 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
- | mips64vr | mips64vrel \
+ | mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
@@ -254,30 +279,40 @@ case $basic_machine in
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
+ | moxie \
+ | mt \
| msp430 \
+ | nios | nios2 \
| ns16k | ns32k \
- | openrisc | or32 \
+ | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
- | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | rx \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
- | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
- | strongarm \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
+ | ubicom32 \
| v850 | v850e \
| we32k \
- | x86 | xscale | xstormy16 | xtensa \
- | z8k)
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k | z80)
basic_machine=$basic_machine-unknown
;;
- m6811 | m68hc11 | m6812 | m68hc12)
+ m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
@@ -297,28 +332,32 @@ case $basic_machine in
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bs2000-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
- | clipper-* | cydra-* \
+ | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
- | m32r-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | mcore-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
+ | mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \
+ | mips64r5900-* | mips64r5900el-* \
+ | mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
@@ -326,26 +365,35 @@ case $basic_machine in
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
| msp430-* \
- | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | romp-* | rs6000-* | rx-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
- | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \
+ | ubicom32-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
- | xtensa-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa*-* \
| ymp-* \
- | z8k-*)
+ | z8k-* | z80-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -363,6 +411,9 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
@@ -380,6 +431,9 @@ case $basic_machine in
amd64)
basic_machine=x86_64-pc
;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
amdahl)
basic_machine=580-amdahl
os=-sysv
@@ -403,6 +457,10 @@ case $basic_machine in
basic_machine=m68k-apollo
os=-bsd
;;
+ aros)
+ basic_machine=i386-pc
+ os=-aros
+ ;;
aux)
basic_machine=m68k-apple
os=-aux
@@ -411,10 +469,26 @@ case $basic_machine in
basic_machine=ns32k-sequent
os=-dynix
;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ bluegene*)
+ basic_machine=powerpc-ibm
+ os=-cnk
+ ;;
c90)
basic_machine=c90-cray
os=-unicos
;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=-cegcc
+ ;;
convex-c1)
basic_machine=c1-convex
os=-bsd
@@ -439,12 +513,27 @@ case $basic_machine in
basic_machine=j90-cray
os=-unicos
;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
crds | unos)
basic_machine=m68k-crds
;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
da30 | da30-*)
basic_machine=m68k-da30
;;
@@ -467,6 +556,14 @@ case $basic_machine in
basic_machine=m88k-motorola
os=-sysv3
;;
+ dicos)
+ basic_machine=i686-pc
+ os=-dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
@@ -617,6 +714,14 @@ case $basic_machine in
basic_machine=m68k-isi
os=-sysv
;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
m88k-omron*)
basic_machine=m88k-omron
;;
@@ -628,10 +733,17 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
+ microblaze)
+ basic_machine=microblaze-xilinx
+ ;;
mingw32)
basic_machine=i386-pc
os=-mingw32
;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
miniframe)
basic_machine=m68000-convergent
;;
@@ -645,10 +757,6 @@ case $basic_machine in
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
- mmix*)
- basic_machine=mmix-knuth
- os=-mmixware
- ;;
monitor)
basic_machine=m68k-rom68k
os=-coff
@@ -661,6 +769,9 @@ case $basic_machine in
basic_machine=i386-pc
os=-msdos
;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
mvs)
basic_machine=i370-ibm
os=-mvs
@@ -729,10 +840,6 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
- nv1)
- basic_machine=nv1-cray
- os=-unicosmp
- ;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@@ -740,9 +847,8 @@ case $basic_machine in
basic_machine=hppa1.1-oki
os=-proelf
;;
- or32 | or32-*)
+ openrisc | openrisc-*)
basic_machine=or32-unknown
- os=-coff
;;
os400)
basic_machine=powerpc-ibm
@@ -764,6 +870,14 @@ case $basic_machine in
basic_machine=i860-intel
os=-osf
;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
pbd)
basic_machine=sparc-tti
;;
@@ -773,6 +887,12 @@ case $basic_machine in
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
@@ -829,6 +949,10 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@@ -855,6 +979,10 @@ case $basic_machine in
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
sei)
basic_machine=mips-sei
os=-seiux
@@ -866,6 +994,9 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
sh64)
basic_machine=sh64-unknown
;;
@@ -955,6 +1086,10 @@ case $basic_machine in
basic_machine=tic6x-unknown
os=-coff
;;
+ tile*)
+ basic_machine=tile-unknown
+ os=-linux-gnu
+ ;;
tx39)
basic_machine=mipstx39-unknown
;;
@@ -1015,6 +1150,10 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
xps | xps100)
basic_machine=xps100-honeywell
;;
@@ -1026,6 +1165,10 @@ case $basic_machine in
basic_machine=z8k-unknown
os=-sim
;;
+ z80-*-coff)
+ basic_machine=z80-unknown
+ os=-sim
+ ;;
none)
basic_machine=none-none
os=-none
@@ -1045,6 +1188,9 @@ case $basic_machine in
romp)
basic_machine=romp-ibm
;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
rs6000)
basic_machine=rs6000-ibm
;;
@@ -1061,13 +1207,10 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
- sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparc | sparcv9 | sparcv9b)
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
@@ -1114,6 +1257,9 @@ case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
+ -auroraux)
+ os=-auroraux
+ ;;
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
@@ -1134,25 +1280,30 @@ case $os in
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+ | -sym* | -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
+ | -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
- | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
+ | -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1170,7 +1321,7 @@ case $os in
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
@@ -1215,6 +1366,9 @@ case $os in
-atheos*)
os=-atheos
;;
+ -syllable*)
+ os=-syllable
+ ;;
-386bsd)
os=-bsd
;;
@@ -1276,6 +1430,14 @@ case $os in
-kaos*)
os=-kaos
;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -dicos*)
+ os=-dicos
+ ;;
+ -nacl*)
+ ;;
-none)
;;
*)
@@ -1298,6 +1460,12 @@ else
# system, and we'll never get to this point.
case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
*-acorn)
os=-riscix1.2
;;
@@ -1307,9 +1475,9 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
@@ -1335,6 +1503,9 @@ case $basic_machine in
m68*-cisco)
os=-aout
;;
+ mep-*)
+ os=-elf
+ ;;
mips*-cisco)
os=-elf
;;
@@ -1353,9 +1524,15 @@ case $basic_machine in
*-be)
os=-beos
;;
+ *-haiku)
+ os=-haiku
+ ;;
*-ibm)
os=-aix
;;
+ *-knuth)
+ os=-mmixware
+ ;;
*-wec)
os=-proelf
;;
@@ -1458,7 +1635,7 @@ case $basic_machine in
-sunos*)
vendor=sun
;;
- -aix*)
+ -cnk*|-aix*)
vendor=ibm
;;
-beos*)
@@ -1521,7 +1698,7 @@ case $basic_machine in
esac
echo $basic_machine$os
-exit 0
+exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
diff --git a/configure b/configure
index f4b7754dce40..cb51d19c8057 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 1.196.2.6 .
+# From configure.in Revision: 1.204 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61.
#
@@ -671,6 +671,7 @@ CPP
GREP
EGREP
LIBOBJS
+PCAP_CONFIG
RANLIB
V_CCOPT
V_DEFS
@@ -678,6 +679,8 @@ V_GROUP
V_INCLS
V_PCAPDEP
LOCALSRC
+MAN_FILE_FORMATS
+MAN_MISC_INFO
INSTALL_PROGRAM
INSTALL_SCRIPT
INSTALL_DATA
@@ -1273,6 +1276,8 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--without-gcc don't use gcc
+ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. default=yes
+ --without-smi don't link with libsmi
--with-user=USERNAME drop privileges by default to USERNAME
--with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY
--with-crypto[=PATH] use SSLeay libcrypto (located in directory PATH, if
@@ -1831,6 +1836,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
# Check whether --with-gcc was given.
if test "${with_gcc+set}" = set; then
withval=$with_gcc;
@@ -1897,7 +1903,8 @@ fi
CC=cc
export CC
fi
- ac_ext=c
+
+ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -2816,6 +2823,10 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
if test "$GCC" = yes ; then
if test "$SHLICC2" = yes ; then
ac_cv_lbl_gcc_vers=2
@@ -2954,12 +2965,75 @@ echo "$as_me: error: see the INSTALL doc for more info" >&2;}
fi
CFLAGS="$savedcflags"
V_CCOPT="-Aa $V_CCOPT"
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define _HPUX_SOURCE 1
_ACEOF
;;
+ osf*)
+ { echo "$as_me:$LINENO: checking for ansi mode in DEC compiler ($CC -std1)" >&5
+echo $ECHO_N "checking for ansi mode in DEC compiler ($CC -std1)... $ECHO_C" >&6; }
+ savedcflags="$CFLAGS"
+ CFLAGS="-std1"
+ if test "${ac_cv_lbl_cc_osf1_cc_std1+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+int
+main ()
+{
+int frob(int, char *)
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_lbl_cc_osf1_cc_std1=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lbl_cc_osf1_cc_std1=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+ { echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_osf1_cc_std1" >&5
+echo "${ECHO_T}$ac_cv_lbl_cc_osf1_cc_std1" >&6; }
+ if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
+ { { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5
+echo "$as_me: error: see the INSTALL doc for more info" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ CFLAGS="$savedcflags"
+ V_CCOPT="-std1 $V_CCOPT"
+ ;;
+
*)
{ { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5
echo "$as_me: error: see the INSTALL doc for more info" >&2;}
@@ -2977,7 +3051,11 @@ echo "$as_me: error: see the INSTALL doc for more info" >&2;}
;;
osf*)
- V_CCOPT="$V_CCOPT -std1 -O"
+ #
+ # Presumed to be DEC OSF/1, Digital UNIX, or
+ # Tru64 UNIX.
+ #
+ V_CCOPT="$V_CCOPT -O"
;;
ultrix*)
@@ -3033,7 +3111,8 @@ fi
{ echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_const_proto" >&5
echo "${ECHO_T}$ac_cv_lbl_cc_const_proto" >&6; }
if test $ac_cv_lbl_cc_const_proto = no ; then
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define const
_ACEOF
@@ -3044,6 +3123,8 @@ _ACEOF
{ echo "$as_me:$LINENO: checking for inline" >&5
echo $ECHO_N "checking for inline... $ECHO_C" >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$V_CCOPT"
if test "${ac_cv_lbl_inline+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
@@ -3115,6 +3196,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
fi
+ CFLAGS="$save_CFLAGS"
if test ! -z "$ac_cv_lbl_inline" ; then
{ echo "$as_me:$LINENO: result: $ac_cv_lbl_inline" >&5
echo "${ECHO_T}$ac_cv_lbl_inline" >&6; }
@@ -3199,6 +3281,72 @@ fi
{ echo "$as_me:$LINENO: result: $ac_cv___attribute__" >&5
echo "${ECHO_T}$ac_cv___attribute__" >&6; }
+if test "$ac_cv___attribute__" = "yes"; then
+
+{ echo "$as_me:$LINENO: checking whether __attribute__((format)) can be applied to function pointers" >&5
+echo $ECHO_N "checking whether __attribute__((format)) can be applied to function pointers... $ECHO_C" >&6; }
+if test "${ac_cv___attribute___format_function_pointer+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+
+extern int (*foo)(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+int
+main(int argc, char **argv)
+{
+ (*foo)("%s", "test");
+}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv___attribute___format_function_pointer=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv___attribute___format_function_pointer=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+if test "$ac_cv___attribute___format_function_pointer" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS 1
+_ACEOF
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv___attribute___format_function_pointer" >&5
+echo "${ECHO_T}$ac_cv___attribute___format_function_pointer" >&6; }
+
+fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3660,7 +3808,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
else
ac_cv_header_stdc=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
@@ -3681,7 +3829,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
else
ac_cv_header_stdc=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
@@ -4278,6 +4426,16 @@ esac
+# Check whether --with-smi was given.
+if test "${with_smi+set}" = set; then
+ withval=$with_smi;
+else
+ with_smi=yes
+fi
+
+
+if test "x$with_smi" != "xno" ; then
+
for ac_header in smi.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -4575,6 +4733,7 @@ fi
fi
+fi
{ echo "$as_me:$LINENO: checking whether to enable the possibly-buggy SMB printer" >&5
echo $ECHO_N "checking whether to enable the possibly-buggy SMB printer... $ECHO_C" >&6; }
@@ -4629,7 +4788,7 @@ fi
{ echo "$as_me:$LINENO: checking whether to chroot" >&5
echo $ECHO_N "checking whether to chroot... $ECHO_C" >&6; }
-if test ! -z "$with_chroot" ; then
+if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
cat >>confdefs.h <<_ACEOF
#define WITH_CHROOT "$withval"
_ACEOF
@@ -4757,7 +4916,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6type=$i;
CFLAGS="-DINET6 $CFLAGS"
fi
-rm -f conftest*
+rm -f -r conftest*
;;
kame)
@@ -4780,7 +4939,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6trylibc=yes;
CFLAGS="-DINET6 $CFLAGS"
fi
-rm -f conftest*
+rm -f -r conftest*
;;
linux-glibc)
@@ -4800,7 +4959,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6type=$i;
CFLAGS="-DINET6 $CFLAGS"
fi
-rm -f conftest*
+rm -f -r conftest*
;;
linux-libinet6)
@@ -4831,7 +4990,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6libdir=/usr/local/v6/lib;
CFLAGS="-DINET6 $CFLAGS"
fi
-rm -f conftest*
+rm -f -r conftest*
;;
v6d)
@@ -4853,7 +5012,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6libdir=/usr/local/v6/lib;
CFLAGS="-I/usr/local/v6/include $CFLAGS"
fi
-rm -f conftest*
+rm -f -r conftest*
;;
zeta)
@@ -4875,7 +5034,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6libdir=/usr/local/v6/lib;
CFLAGS="-DINET6 $CFLAGS"
fi
-rm -f conftest*
+rm -f -r conftest*
;;
esac
@@ -5173,8 +5332,7 @@ echo "${ECHO_T}buggy" >&6; }
fi
-
-for ac_func in getaddrinfo getnameinfo
+for ac_func in getnameinfo
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -5297,7 +5455,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
else
td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
{ echo "$as_me:$LINENO: result: $td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&5
@@ -7336,7 +7494,6 @@ _ACEOF
-
{ echo "$as_me:$LINENO: checking for addrinfo" >&5
echo $ECHO_N "checking for addrinfo... $ECHO_C" >&6; }
if test "${ac_cv_addrinfo+set}" = set; then
@@ -7427,7 +7584,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
else
ac_cv_maxserv=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
@@ -7467,7 +7624,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
else
ac_cv_namereqd=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
@@ -8331,12 +8488,14 @@ _ACEOF
if test "$ac_cv_type_signal" = void ; then
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define RETSIGVAL
_ACEOF
else
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define RETSIGVAL (0)
_ACEOF
@@ -8344,7 +8503,8 @@ _ACEOF
case "$host_os" in
irix*)
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define _BSD_SIGNALS 1
_ACEOF
@@ -9285,9 +9445,10 @@ echo $ECHO_N "checking for local pcap library... $ECHO_C" >&6; }
libpcap=FAIL
lastdir=FAIL
places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
- egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+ egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do
- basedir=`echo $dir | sed -e 's/[ab][0-9]*$//'`
+ basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
+ sed -e 's/-PRE-GIT$//' `
if test $lastdir = $basedir ; then
continue;
fi
@@ -9300,7 +9461,62 @@ echo $ECHO_N "checking for local pcap library... $ECHO_C" >&6; }
if test $libpcap = FAIL ; then
{ echo "$as_me:$LINENO: result: not found" >&5
echo "${ECHO_T}not found" >&6; }
- { echo "$as_me:$LINENO: checking for main in -lpcap" >&5
+
+ #
+ # Look for pcap-config.
+ #
+ # Extract the first word of "pcap-config", so it can be a program name with args.
+set dummy pcap-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_PCAP_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PCAP_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PCAP_CONFIG="$PCAP_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+PCAP_CONFIG=$ac_cv_path_PCAP_CONFIG
+if test -n "$PCAP_CONFIG"; then
+ { echo "$as_me:$LINENO: result: $PCAP_CONFIG" >&5
+echo "${ECHO_T}$PCAP_CONFIG" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ if test -n "$PCAP_CONFIG" ; then
+ #
+ # Found - use it to get the include flags for
+ # libpcap and the flags to link with libpcap.
+ #
+ V_INCLS="`\"$PCAP_CONFIG\" --cflags` $V_INCLS"
+ libpcap="`\"$PCAP_CONFIG\" --libs`"
+ else
+ #
+ # Not found; look for pcap.
+ #
+ { echo "$as_me:$LINENO: checking for main in -lpcap" >&5
echo $ECHO_N "checking for main in -lpcap... $ECHO_C" >&6; }
if test "${ac_cv_lib_pcap_main+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9359,28 +9575,29 @@ if test $ac_cv_lib_pcap_main = yes; then
libpcap="-lpcap"
fi
- if test $libpcap = FAIL ; then
+ if test $libpcap = FAIL ; then
{ { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5
echo "$as_me: error: see the INSTALL doc for more info" >&2;}
{ (exit 1); exit 1; }; }
- fi
- { echo "$as_me:$LINENO: checking for extraneous pcap header directories" >&5
+ fi
+ { echo "$as_me:$LINENO: checking for extraneous pcap header directories" >&5
echo $ECHO_N "checking for extraneous pcap header directories... $ECHO_C" >&6; }
- if test \( ! -r /usr/local/include/pcap.h \) -a \
+ if test \( ! -r /usr/local/include/pcap.h \) -a \
\( ! -r /usr/include/pcap.h \); then
- if test -r /usr/local/include/pcap/pcap.h; then
- d="/usr/local/include/pcap"
- elif test -r /usr/include/pcap/pcap.h; then
- d="/usr/include/pcap"
+ if test -r /usr/local/include/pcap/pcap.h; then
+ d="/usr/local/include/pcap"
+ elif test -r /usr/include/pcap/pcap.h; then
+ d="/usr/include/pcap"
+ fi
fi
- fi
- if test -z "$d" ; then
- { echo "$as_me:$LINENO: result: not found" >&5
+ if test -z "$d" ; then
+ { echo "$as_me:$LINENO: result: not found" >&5
echo "${ECHO_T}not found" >&6; }
- else
- V_INCLS="-I$d $V_INCLS"
- { echo "$as_me:$LINENO: result: found -- -I$d added" >&5
+ else
+ V_INCLS="-I$d $V_INCLS"
+ { echo "$as_me:$LINENO: result: found -- -I$d added" >&5
echo "${ECHO_T}found -- -I$d added" >&6; }
+ fi
fi
else
V_PCAPDEP=$libpcap
@@ -9397,11 +9614,72 @@ echo "$as_me: error: cannot find pcap.h" >&2;}
fi
{ echo "$as_me:$LINENO: result: $libpcap" >&5
echo "${ECHO_T}$libpcap" >&6; }
+ # Extract the first word of "pcap-config", so it can be a program name with args.
+set dummy pcap-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_PCAP_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PCAP_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PCAP_CONFIG="$PCAP_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $d
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+PCAP_CONFIG=$ac_cv_path_PCAP_CONFIG
+if test -n "$PCAP_CONFIG"; then
+ { echo "$as_me:$LINENO: result: $PCAP_CONFIG" >&5
+echo "${ECHO_T}$PCAP_CONFIG" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ if test -n "$PCAP_CONFIG"; then
+ #
+ # The libpcap directory has a pcap-config script.
+ # Use it to get any additioal libraries needed
+ # to link with the libpcap archive library in
+ # that directory
+ #
+ libpcap="$libpcap `\"$PCAP_CONFIG\" --additional-libs --static`"
+ fi
fi
LIBS="$libpcap $LIBS"
- case "$host_os" in
+ if ! test -n "$PCAP_CONFIG" ; then
+ #
+ # We don't have pcap-config; find out any additional link flags
+ # we need. (If we have pcap-config, we assume it tells us what
+ # we need.)
+ #
+ case "$host_os" in
- aix*)
+ aix*)
+ #
+ # If libpcap is DLPI-based, we have to use /lib/pse.exp if
+ # present, as we use the STREAMS routines.
+ #
+ # (XXX - true only if we're linking with a static libpcap?)
+ #
pseexe="/lib/pse.exp"
{ echo "$as_me:$LINENO: checking for $pseexe" >&5
echo $ECHO_N "checking for $pseexe... $ECHO_C" >&6; }
@@ -9410,15 +9688,17 @@ echo $ECHO_N "checking for $pseexe... $ECHO_C" >&6; }
echo "${ECHO_T}yes" >&6; }
LIBS="$LIBS -I:$pseexe"
fi
+
#
- # We need "-lodm" and "-lcfg", as libpcap requires them on
- # AIX, and we just build a static libpcap.a and thus can't
- # arrange that when you link with libpcap you automatically
- # link with those libraries.
+ # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as
+ # we use them to load the BPF module.
+ #
+ # (XXX - true only if we're linking with a static libpcap?)
#
LIBS="$LIBS -lodm -lcfg"
;;
- esac
+ esac
+ fi
{ echo "$as_me:$LINENO: checking for pcap_list_datalinks" >&5
echo $ECHO_N "checking for pcap_list_datalinks... $ECHO_C" >&6; }
@@ -11445,6 +11725,12 @@ V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
fi
+#
+# Assume V7/BSD convention for man pages (file formats in section 5,
+# miscellaneous info in section 7).
+#
+MAN_FILE_FORMATS=5
+MAN_MISC_INFO=7
case "$host_os" in
aix*)
@@ -11454,16 +11740,42 @@ _ACEOF
;;
+hpux*)
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
+ ;;
+
irix*)
V_GROUP=sys
+
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
;;
osf*)
V_GROUP=system
+
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
;;
solaris*)
V_GROUP=sys
+
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
;;
esac
@@ -11617,6 +11929,146 @@ fi
done
+
+for ac_header in pcap/usb.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+ ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
CPPFLAGS="$savedcppflags"
@@ -11772,6 +12224,10 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif
+
typedef int8_t ac__type_new_;
int
main ()
@@ -11951,6 +12407,10 @@ cat >>confdefs.h <<\_ACEOF
#define int16_t short
_ACEOF
+ $ac_includes_default
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif
fi
{ echo "$as_me:$LINENO: checking for u_int16_t" >&5
@@ -12032,6 +12492,10 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif
+
typedef int32_t ac__type_new_;
int
main ()
@@ -12162,6 +12626,10 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif
+
typedef int64_t ac__type_new_;
int
main ()
@@ -13023,7 +13491,8 @@ rm -f os-proto.h
name="lbl/os-$os.h"
if test -f $name ; then
ln -s $name os-proto.h
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define HAVE_OS_PROTO_H 1
_ACEOF
@@ -13033,8 +13502,8 @@ echo "$as_me: WARNING: can't find $name" >&2;}
fi
fi
-{ echo "$as_me:$LINENO: checking if sockaddr struct has sa_len member" >&5
-echo $ECHO_N "checking if sockaddr struct has sa_len member... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking if sockaddr struct has the sa_len member" >&5
+echo $ECHO_N "checking if sockaddr struct has the sa_len member... $ECHO_C" >&6; }
if test "${ac_cv_lbl_sockaddr_has_sa_len+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
@@ -13086,7 +13555,8 @@ fi
{ echo "$as_me:$LINENO: result: $ac_cv_lbl_sockaddr_has_sa_len" >&5
echo "${ECHO_T}$ac_cv_lbl_sockaddr_has_sa_len" >&6; }
if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define HAVE_SOCKADDR_SA_LEN 1
_ACEOF
@@ -13174,7 +13644,7 @@ EOF
ac_cv_lbl_unaligned_fail=no
fi
fi
- rm -f conftest* core core.conftest
+ rm -f -r conftest* core core.conftest
;;
esac
fi
@@ -13182,7 +13652,8 @@ fi
{ echo "$as_me:$LINENO: result: $ac_cv_lbl_unaligned_fail" >&5
echo "${ECHO_T}$ac_cv_lbl_unaligned_fail" >&6; }
if test $ac_cv_lbl_unaligned_fail = yes ; then
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define LBL_ALIGN 1
_ACEOF
@@ -13302,6 +13773,16 @@ echo $ECHO_N "checking where SSLeay is located... $ECHO_C" >&6; }
for dir in $dirs; do
#
+ # Find the last component of $libdir; it's not necessarily
+ # "lib" - it might be "lib64" on, for example, x86-64
+ # Linux systems.
+ #
+ # We assume the directory in which we're looking for
+ # libcrypto has a subdirectory with that as its name.
+ #
+ tmplib=`echo "$libdir" | sed 's,.*/,,'`
+
+ #
# XXX - is there a better way to check if a given library is
# in a given directory than checking each of the possible
# shared library suffixes?
@@ -13311,10 +13792,10 @@ echo $ECHO_N "checking where SSLeay is located... $ECHO_C" >&6; }
#
# Or should we just look for "libcrypto.*"?
#
- if test -d "$dir/lib" -a \( -f "$dir/lib/libcrypto.a" -o \
- -f "$dir/lib/libcrypto.so" -o \
- -f "$dir/lib/libcrypto.sl" -o \
- -f "$dir/lib/libcrypto.dylib" \); then
+ if test -d "$dir/$tmplib" -a \( -f "$dir/$tmplib/libcrypto.a" -o \
+ -f "$dir/$tmplib/libcrypto.so" -o \
+ -f "$dir/$tmplib/libcrypto.sl" -o \
+ -f "$dir/$tmplib/libcrypto.dylib" \); then
ac_cv_ssleay_path="$dir"
fi
@@ -13342,6 +13823,16 @@ echo "${ECHO_T}$ac_cv_ssleay_path" >&6; }
echo $ECHO_N "checking for SSLeay in $crypto_dir... $ECHO_C" >&6; }
#
+ # Find the last component of $libdir; it's not necessarily
+ # "lib" - it might be "lib64" on, for example, x86-64
+ # Linux systems.
+ #
+ # We assume the directory in which we're looking for
+ # libcrypto has a subdirectory with that as its name.
+ #
+ tmplib=`echo "$libdir" | sed 's,.*/,,'`
+
+ #
# XXX - is there a better way to check if a given library is
# in a given directory than checking each of the possible
# shared library suffixes?
@@ -13351,10 +13842,10 @@ echo $ECHO_N "checking for SSLeay in $crypto_dir... $ECHO_C" >&6; }
#
# Or should we just look for "libcrypto.*"?
#
- if test -d "$crypto_dir/lib" -a \( -f "$crypto_dir/lib/libcrypto.a" -o \
- -f "$crypto_dir/lib/libcrypto.so" -o \
- -f "$crypto_dir/lib/libcrypto.sl" -o \
- -f "$crypto_dir/lib/libcrypto.dylib" \); then
+ if test -d "$crypto_dir/$tmplib" -a \( -f "$crypto_dir/$tmplib/libcrypto.a" -o \
+ -f "$crypto_dir/$tmplib/libcrypto.so" -o \
+ -f "$crypto_dir/$tmplib/libcrypto.sl" -o \
+ -f "$crypto_dir/$tmplib/libcrypto.dylib" \); then
ac_cv_ssleay_path="$crypto_dir"
fi
@@ -13372,7 +13863,9 @@ echo "${ECHO_T}found" >&6; }
fi
if test "$ac_cv_ssleay_path" != no; then
V_INCLS="$V_INCLS $incdir"
- LDFLAGS="-L$dir/lib $LDFLAGS"
+ if test "$dir" != "/usr"; then
+ LDFLAGS="-L$dir/lib $LDFLAGS"
+ fi
if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
LIBS="$LIBS -lRSAglue"
fi
@@ -13618,6 +14111,8 @@ fi
+
+
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
@@ -13704,7 +14199,7 @@ ac_config_headers="$ac_config_headers config.h"
ac_config_commands="$ac_config_commands default-1"
-ac_config_files="$ac_config_files Makefile"
+ac_config_files="$ac_config_files Makefile tcpdump.1"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -14271,6 +14766,7 @@ do
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "tcpdump.1") CONFIG_FILES="$CONFIG_FILES tcpdump.1" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -14390,6 +14886,7 @@ CPP!$CPP$ac_delim
GREP!$GREP$ac_delim
EGREP!$EGREP$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
+PCAP_CONFIG!$PCAP_CONFIG$ac_delim
RANLIB!$RANLIB$ac_delim
V_CCOPT!$V_CCOPT$ac_delim
V_DEFS!$V_DEFS$ac_delim
@@ -14397,13 +14894,15 @@ V_GROUP!$V_GROUP$ac_delim
V_INCLS!$V_INCLS$ac_delim
V_PCAPDEP!$V_PCAPDEP$ac_delim
LOCALSRC!$LOCALSRC$ac_delim
+MAN_FILE_FORMATS!$MAN_FILE_FORMATS$ac_delim
+MAN_MISC_INFO!$MAN_MISC_INFO$ac_delim
INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
INSTALL_DATA!$INSTALL_DATA$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 68; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 71; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.in b/configure.in
index f3528c4dd27a..eb3e5e8b1ddf 100755
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.196.2.6 2008-09-25 21:50:04 guy Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@@ -6,15 +6,29 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl
-AC_REVISION($Revision: 1.196.2.6 $)
+#
+# See
+#
+# http://ftp.gnu.org/gnu/config/README
+#
+# for the URLs to use to fetch new versions of config.guess and
+# config.sub.
+#
+
+AC_REVISION($Revision: 1.204 $)
AC_PREREQ(2.50)
AC_INIT(tcpdump.c)
AC_CANONICAL_HOST
+AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
+AC_PROG_CC
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_LBL_C_INLINE
AC_C___ATTRIBUTE__
+if test "$ac_cv___attribute__" = "yes"; then
+ AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
+fi
AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
@@ -70,6 +84,12 @@ linux*)
esac
+AC_ARG_WITH(smi,
+[ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
+ --without-smi don't link with libsmi],,
+ with_smi=yes)
+
+if test "x$with_smi" != "xno" ; then
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
@@ -111,6 +131,7 @@ dnl autoconf ever comes back to match the documentation.
libsmi=no]
)
fi
+fi
AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
AC_ARG_ENABLE(smb,
@@ -138,7 +159,7 @@ fi
AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
AC_MSG_CHECKING([whether to chroot])
-if test ! -z "$with_chroot" ; then
+if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval")
AC_MSG_RESULT(to \"$withval\")
else
@@ -434,7 +455,7 @@ main()
fi
fi
])
- AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
+ AC_REPLACE_FUNCS(getnameinfo)
fi
AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
@@ -456,13 +477,6 @@ AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 8)
dnl
-dnl Checks for u_intXX_t
-dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
-dnl if test "$ac_cv_bittypes" = no; then
-dnl missing_includes=yes
-dnl fi
-
-dnl
dnl Checks for addrinfo structure
AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
if test "$ac_cv_addrinfo" = no; then
@@ -779,6 +793,12 @@ V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
fi
+#
+# Assume V7/BSD convention for man pages (file formats in section 5,
+# miscellaneous info in section 7).
+#
+MAN_FILE_FORMATS=5
+MAN_MISC_INFO=7
case "$host_os" in
aix*)
@@ -786,16 +806,42 @@ aix*)
AC_DEFINE(_SUN)
;;
+hpux*)
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
+ ;;
+
irix*)
V_GROUP=sys
+
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
;;
osf*)
V_GROUP=system
+
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
;;
solaris*)
V_GROUP=sys
+
+ #
+ # Use System V conventions for man pages.
+ #
+ MAN_FILE_FORMATS=4
+ MAN_MISC_INFO=5
;;
esac
@@ -810,13 +856,18 @@ fi
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(pcap/bluetooth.h)
+AC_CHECK_HEADERS(pcap/usb.h)
CPPFLAGS="$savedcppflags"
AC_CHECK_HEADERS(sys/bitypes.h)
AC_CHECK_TYPE([int8_t], ,
[AC_DEFINE([int8_t], [signed char],
- [Define to `signed char' if int8_t not defined.])])
+ [Define to `signed char' if int8_t not defined.])],
+ [AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif])
AC_CHECK_TYPE([u_int8_t], ,
[AC_DEFINE([u_int8_t], [unsigned char],
[Define to `unsigned char' if u_int8_t not defined.])],
@@ -826,7 +877,11 @@ AC_CHECK_TYPE([u_int8_t], ,
#endif])
AC_CHECK_TYPE([int16_t], ,
[AC_DEFINE([int16_t], [short],
- [Define to `short' if int16_t not defined.])])
+ [Define to `short' if int16_t not defined.])]
+ [AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif])
AC_CHECK_TYPE([u_int16_t], ,
[AC_DEFINE([u_int16_t], [unsigned short],
[Define to `unsigned short' if u_int16_t not defined.])],
@@ -836,7 +891,11 @@ AC_CHECK_TYPE([u_int16_t], ,
#endif])
AC_CHECK_TYPE([int32_t], ,
[AC_DEFINE([int32_t], [int],
- [Define to `int' if int32_t not defined.])])
+ [Define to `int' if int32_t not defined.])],
+ [AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif])
AC_CHECK_TYPE([u_int32_t], ,
[AC_DEFINE([u_int32_t], [unsigned int],
[Define to `unsigned int' if u_int32_t not defined.])],
@@ -846,7 +905,11 @@ AC_CHECK_TYPE([u_int32_t], ,
#endif])
AC_CHECK_TYPE([int64_t], ,
[AC_DEFINE([int64_t], [long long],
- [Define to `long long' if int64_t not defined.])])
+ [Define to `long long' if int64_t not defined.])],
+ [AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif])
AC_CHECK_TYPE([u_int64_t], ,
[AC_DEFINE([u_int64_t], [unsigned long long],
[Define to `unsigned long long' if u_int64_t not defined.])],
@@ -989,7 +1052,9 @@ if test "$want_libcrypto" != "no"; then
fi
if test "$ac_cv_ssleay_path" != no; then
V_INCLS="$V_INCLS $incdir"
- LDFLAGS="-L$dir/lib $LDFLAGS"
+ if test "$dir" != "/usr"; then
+ LDFLAGS="-L$dir/lib $LDFLAGS"
+ fi
if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
LIBS="$LIBS -lRSAglue"
fi
@@ -1024,6 +1089,8 @@ AC_SUBST(V_GROUP)
AC_SUBST(V_INCLS)
AC_SUBST(V_PCAPDEP)
AC_SUBST(LOCALSRC)
+AC_SUBST(MAN_FILE_FORMATS)
+AC_SUBST(MAN_MISC_INFO)
AC_PROG_INSTALL
@@ -1034,5 +1101,5 @@ AC_OUTPUT_COMMANDS([if test -f .devel; then
cat Makefile-devel-adds >> Makefile
make depend
fi])
-AC_OUTPUT(Makefile)
+AC_OUTPUT(Makefile tcpdump.1)
exit 0
diff --git a/ethertype.h b/ethertype.h
index 97550c7fdc31..900bd38eec41 100644
--- a/ethertype.h
+++ b/ethertype.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.29.2.1 2008-02-06 10:49:22 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.30 2008-02-06 10:47:53 guy Exp $ (LBL)
*/
/*
@@ -76,6 +76,9 @@
#ifndef ETHERTYPE_SCA
#define ETHERTYPE_SCA 0x6007
#endif
+#ifndef ETHERTYPE_TEB
+#define ETHERTYPE_TEB 0x6558
+#endif
#ifndef ETHERTYPE_LANBRIDGE
#define ETHERTYPE_LANBRIDGE 0x8038
#endif
@@ -127,6 +130,12 @@
#ifndef ETHERTYPE_PPPOES
#define ETHERTYPE_PPPOES 0x8864
#endif
+#ifndef ETHERTYPE_PPPOED2
+#define ETHERTYPE_PPPOED2 0x3c12
+#endif
+#ifndef ETHERTYPE_PPPOES2
+#define ETHERTYPE_PPPOES2 0x3c13
+#endif
#ifndef ETHERTYPE_JUMBO
#define ETHERTYPE_JUMBO 0x8870
#endif
diff --git a/forces.h b/forces.h
new file mode 100644
index 000000000000..b9cf072fb611
--- /dev/null
+++ b/forces.h
@@ -0,0 +1,679 @@
+/*
+ * 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.
+ *
+ * Copyright (c) 2009 Mojatatu Networks, Inc
+ *
+ */
+
+/*
+ * Per draft-ietf-forces-protocol-22
+*/
+#define ForCES_VERS 1
+#define ForCES_HDRL 24
+#define ForCES_ALNL 4U
+#define TLV_HDRL 4
+#define ILV_HDRL 8
+
+#define TOM_RSVD 0x0
+#define TOM_ASSNSETUP 0x1
+#define TOM_ASSNTEARD 0x2
+#define TOM_CONFIG 0x3
+#define TOM_QUERY 0x4
+#define TOM_EVENTNOT 0x5
+#define TOM_PKTREDIR 0x6
+#define TOM_HEARTBT 0x0F
+#define TOM_ASSNSETREP 0x11
+#define TOM_CONFIGREP 0x13
+#define TOM_QUERYREP 0x14
+
+/*
+ * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
+*/
+#define ZERO_TTLV 0x01
+#define ZERO_MORE_TTLV 0x02
+#define ONE_MORE_TTLV 0x04
+#define ZERO_TLV 0x00
+#define ONE_TLV 0x10
+#define TWO_TLV 0x20
+#define MAX_TLV 0xF0
+
+#define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
+#define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
+
+struct tom_h {
+ u_int32_t v;
+ u_int16_t flags;
+ u_int16_t op_msk;
+ const char *s;
+ int (*print) (register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+};
+
+enum {
+ TOM_RSV_I,
+ TOM_ASS_I,
+ TOM_AST_I,
+ TOM_CFG_I,
+ TOM_QRY_I,
+ TOM_EVN_I,
+ TOM_RED_I,
+ TOM_HBT_I,
+ TOM_ASR_I,
+ TOM_CNR_I,
+ TOM_QRR_I,
+ _TOM_RSV_MAX
+};
+#define TOM_MAX_IND (_TOM_RSV_MAX - 1)
+
+int lfbselect_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int redirect_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int asrtlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int asttlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int gentltlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int print_metailv(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int print_metatlv(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int print_reddata(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+
+static inline int tom_valid(u_int8_t tom)
+{
+ if (tom > 0) {
+ if (tom >= 0x7 && tom <= 0xe)
+ return 0;
+ if (tom == 0x10)
+ return 0;
+ if (tom > 0x14)
+ return 0;
+ return 1;
+ } else
+ return 0;
+}
+
+static inline const char *ForCES_node(u_int32_t node)
+{
+ if (node <= 0x3FFFFFFF)
+ return "FE";
+ if (node >= 0x40000000 && node <= 0x7FFFFFFF)
+ return "CE";
+ if (node >= 0xC0000000 && node <= 0xFFFFFFEF)
+ return "AllMulticast";
+ if (node == 0xFFFFFFFD)
+ return "AllCEsBroadcast";
+ if (node == 0xFFFFFFFE)
+ return "AllFEsBroadcast";
+ if (node == 0xFFFFFFFF)
+ return "AllBroadcast";
+
+ return "ForCESreserved";
+
+}
+
+static inline const char *ForCES_ACKp(u_int32_t flg)
+{
+ if (flg == 0x0)
+ return "NoACK";
+ if (flg == 0x1)
+ return "SuccessACK";
+ if (flg == 0x2)
+ return "FailureACK";
+ if (flg == 0x3)
+ return "AlwaysACK";
+ return "ACKUnknown";
+}
+
+static inline const char *ForCES_EMp(u_int32_t flg)
+{
+ if (flg == 0x0)
+ return "EMReserved";
+ if (flg == 0x1)
+ return "execute-all-or-none";
+ if (flg == 0x2)
+ return "execute-until-failure";
+ if (flg == 0x3)
+ return "continue-execute-on-failure";
+ return "EMUnknown";
+}
+
+static inline const char *ForCES_ATp(u_int32_t flg)
+{
+ if (flg == 0x0)
+ return "Standalone";
+ if (flg == 0x1)
+ return "2PCtransaction";
+ return "ATUnknown";
+}
+
+static inline const char *ForCES_TPp(u_int32_t flg)
+{
+ if (flg == 0x0)
+ return "StartofTransaction";
+ if (flg == 0x1)
+ return "MiddleofTransaction";
+ if (flg == 0x2)
+ return "EndofTransaction";
+ if (flg == 0x3)
+ return "abort";
+ return "TPUnknown";
+}
+
+/*
+ * Structure of forces header, naked of TLVs.
+ */
+struct forcesh {
+ u_int8_t fm_vrsvd; /* version and reserved */
+#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
+ u_int8_t fm_tom; /* type of message */
+ u_int16_t fm_len; /* total length * 4 bytes */
+#define ForCES_BLN(forcesh) ((u_int32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
+ u_int32_t fm_sid; /* Source ID */
+#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
+ u_int32_t fm_did; /* Destination ID */
+#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
+ u_int8_t fm_cor[8]; /* correlator */
+ u_int32_t fm_flags; /* flags */
+#define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
+#define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
+#define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
+#define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
+#define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
+#define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
+#define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
+};
+
+#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
+ (fhl) >= ForCES_HDRL && \
+ (fhl) == (tlen))
+
+#define F_LFB_RSVD 0x0
+#define F_LFB_FEO 0x1
+#define F_LFB_FEPO 0x2
+const struct tok ForCES_LFBs[] = {
+ {F_LFB_RSVD, "Invalid TLV"},
+ {F_LFB_FEO, "FEObj LFB"},
+ {F_LFB_FEPO, "FEProtoObj LFB"},
+ {0, NULL}
+};
+
+int forces_type_print(register const u_char * pptr, const struct forcesh *fhdr,
+ register u_int mlen, const struct tom_h *tops);
+
+enum {
+ F_OP_RSV,
+ F_OP_SET,
+ F_OP_SETPROP,
+ F_OP_SETRESP,
+ F_OP_SETPRESP,
+ F_OP_DEL,
+ F_OP_DELRESP,
+ F_OP_GET,
+ F_OP_GETPROP,
+ F_OP_GETRESP,
+ F_OP_GETPRESP,
+ F_OP_REPORT,
+ F_OP_COMMIT,
+ F_OP_RCOMMIT,
+ F_OP_RTRCOMP,
+ _F_OP_MAX
+};
+
+#define F_OP_MAX (_F_OP_MAX - 1)
+enum {
+ B_OP_SET = 1 << (F_OP_SET - 1),
+ B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
+ B_OP_SETRESP = 1 << (F_OP_SETRESP - 1),
+ B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1),
+ B_OP_DEL = 1 << (F_OP_DEL - 1),
+ B_OP_DELRESP = 1 << (F_OP_DELRESP - 1),
+ B_OP_GET = 1 << (F_OP_GET - 1),
+ B_OP_GETPROP = 1 << (F_OP_GETPROP - 1),
+ B_OP_GETRESP = 1 << (F_OP_GETRESP - 1),
+ B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1),
+ B_OP_REPORT = 1 << (F_OP_REPORT - 1),
+ B_OP_COMMIT = 1 << (F_OP_COMMIT - 1),
+ B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1),
+ B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1),
+};
+
+struct optlv_h {
+ u_int16_t flags;
+ u_int16_t op_msk;
+ const char *s;
+ int (*print) (register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+};
+
+int genoptlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int recpdoptlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int invoptlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+
+#define OP_MIN_SIZ 8
+struct pathdata_h {
+ u_int16_t pflags;
+ u_int16_t pIDcnt;
+};
+
+#define B_FULLD 0x1
+#define B_SPARD 0x2
+#define B_RESTV 0x4
+#define B_KEYIN 0x8
+
+static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
+ /* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
+ /* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
+ /* F_OP_SETPROP */
+ {TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print},
+ /* F_OP_SETRESP */ {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print},
+ /* F_OP_SETPRESP */ {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print},
+ /* F_OP_DEL */ {ZERO_TTLV, 0, " Del", recpdoptlv_print},
+ /* F_OP_DELRESP */ {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print},
+ /* F_OP_GET */ {ZERO_TTLV, 0, " Get", recpdoptlv_print},
+ /* F_OP_GETPROP */ {ZERO_TTLV, 0, " GetProp", recpdoptlv_print},
+ /* F_OP_GETRESP */
+ {TTLV_T2, B_FULLD | B_RESTV, " GetResp", recpdoptlv_print},
+ /* F_OP_GETPRESP */
+ {TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print},
+ /* F_OP_REPORT */
+ {TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print},
+ /* F_OP_COMMIT */ {ZERO_TTLV, 0, " Commit", NULL},
+ /* F_OP_RCOMMIT */ {TTLV_T1, B_RESTV, " RCommit", genoptlv_print},
+ /* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
+};
+
+static inline const struct optlv_h *get_forces_optlv_h(u_int16_t opt)
+{
+ if (opt > F_OP_MAX || opt <= F_OP_RSV)
+ return &OPTLV_msg[F_OP_RSV];
+
+ return &OPTLV_msg[opt];
+}
+
+#define IND_SIZE 256
+#define IND_CHR ' '
+#define IND_PREF '\n'
+#define IND_SUF 0x0
+char ind_buf[IND_SIZE];
+
+static inline char *indent_pr(int indent, int nlpref)
+{
+ int i = 0;
+ char *r = ind_buf;
+
+ if (indent > (IND_SIZE - 1))
+ indent = IND_SIZE - 1;
+
+ if (nlpref) {
+ r[i] = IND_PREF;
+ i++;
+ indent--;
+ }
+
+ while (--indent >= 0)
+ r[i++] = IND_CHR;
+
+ r[i] = IND_SUF;
+ return r;
+}
+
+static inline int op_valid(u_int16_t op, u_int16_t mask)
+{
+ int opb = 1 << (op - 1);
+
+ if (op == 0)
+ return 0;
+ if (opb & mask)
+ return 1;
+ /* I guess we should allow vendor operations? */
+ if (op >= 0x8000)
+ return 1;
+ return 0;
+}
+
+#define F_TLV_RSVD 0x0000
+#define F_TLV_REDR 0x0001
+#define F_TLV_ASRS 0x0010
+#define F_TLV_ASRT 0x0011
+#define F_TLV_LFBS 0x1000
+#define F_TLV_PDAT 0x0110
+#define F_TLV_KEYI 0x0111
+#define F_TLV_FULD 0x0112
+#define F_TLV_SPAD 0x0113
+#define F_TLV_REST 0x0114
+#define F_TLV_METD 0x0115
+#define F_TLV_REDD 0x0116
+#define F_TLV_VNST 0x8000
+
+static const struct tok ForCES_TLV[] = {
+ {F_TLV_RSVD, "Invalid TLV"},
+ {F_TLV_REDR, "REDIRECT TLV"},
+ {F_TLV_ASRS, "ASResult TLV"},
+ {F_TLV_ASRT, "ASTreason TLV"},
+ {F_TLV_LFBS, "LFBselect TLV"},
+ {F_TLV_PDAT, "PATH-DATA TLV"},
+ {F_TLV_KEYI, "KEYINFO TLV"},
+ {F_TLV_FULD, "FULLDATA TLV"},
+ {F_TLV_SPAD, "SPARSEDATA TLV"},
+ {F_TLV_REST, "RESULT TLV"},
+ {F_TLV_METD, "METADATA TLV"},
+ {F_TLV_REDD, "REDIRECTDATA TLV"},
+ {0, NULL}
+};
+
+#define TLV_HLN 4
+static inline int ttlv_valid(u_int16_t ttlv)
+{
+ if (ttlv > 0) {
+ if (ttlv == 1 || ttlv == 0x1000)
+ return 1;
+ if (ttlv >= 0x10 && ttlv <= 0x11)
+ return 1;
+ if (ttlv >= 0x110 && ttlv <= 0x116)
+ return 1;
+ if (ttlv >= 0x8000)
+ return 0; /* XXX: */
+ }
+
+ return 0;
+}
+
+struct forces_ilv {
+ u_int32_t type;
+ u_int32_t length;
+};
+
+struct forces_tlv {
+ u_int16_t type;
+ u_int16_t length;
+};
+
+int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk, int indent);
+
+#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
+#define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
+#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
+#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
+#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
+#define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0)))
+#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
+ (struct forces_tlv*)(((char*)(tlv)) \
+ + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
+#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
+#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
+#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
+#define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0)))
+#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
+ (struct forces_ilv *)(((char*)(ilv)) \
+ + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
+#define INVALID_RLEN -1
+#define INVALID_STLN -2
+#define INVALID_LTLN -3
+#define INVALID_ALEN -4
+
+static const struct tok ForCES_TLV_err[] = {
+ {INVALID_RLEN, "Invalid total length"},
+ {INVALID_STLN, "xLV too short"},
+ {INVALID_LTLN, "xLV too long"},
+ {INVALID_ALEN, "data padding missing"},
+ {0, NULL}
+};
+
+static inline int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
+{
+ if (rlen < TLV_HDRL)
+ return INVALID_RLEN;
+ if (EXTRACT_16BITS(&tlv->length) < TLV_HDRL)
+ return INVALID_STLN;
+ if (EXTRACT_16BITS(&tlv->length) > rlen)
+ return INVALID_LTLN;
+ if (rlen < F_ALN_LEN(EXTRACT_16BITS(&tlv->length)))
+ return INVALID_ALEN;
+
+ return 0;
+}
+
+static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
+{
+ if (rlen < ILV_HDRL)
+ return INVALID_RLEN;
+ if (EXTRACT_32BITS(&ilv->length) < ILV_HDRL)
+ return INVALID_STLN;
+ if (EXTRACT_32BITS(&ilv->length) > rlen)
+ return INVALID_LTLN;
+ if (rlen < F_ALN_LEN(EXTRACT_32BITS(&ilv->length)))
+ return INVALID_ALEN;
+
+ return 0;
+}
+
+struct forces_lfbsh {
+ u_int32_t class;
+ u_int32_t instance;
+};
+
+#define ASSNS_OPS (B_OP_REPORT)
+#define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
+#define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
+#define CFG_QY (B_OP_GET|B_OP_GETPROP)
+#define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
+#define CFG_EVN (B_OP_REPORT)
+
+static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
+ /* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
+ /* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
+ "Association Setup", lfbselect_print},
+ /* TOM_AST_I */
+ {TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print},
+ /* TOM_CFG_I */ {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print},
+ /* TOM_QRY_I */ {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print},
+ /* TOM_EVN_I */ {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification",
+ lfbselect_print},
+ /* TOM_RED_I */
+ {TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print},
+ /* TOM_HBT_I */ {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL},
+ /* TOM_ASR_I */
+ {TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print},
+ /* TOM_CNR_I */ {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response",
+ lfbselect_print},
+ /* TOM_QRR_I */
+ {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
+};
+
+static inline const struct tom_h *get_forces_tom(u_int8_t tom)
+{
+ int i;
+ for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
+ const struct tom_h *th = &ForCES_msg[i];
+ if (th->v == tom)
+ return th;
+ }
+ return &ForCES_msg[TOM_RSV_I];
+}
+
+struct pdata_ops {
+ u_int32_t v;
+ u_int16_t flags;
+ u_int16_t op_msk;
+ const char *s;
+ int (*print) (register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+};
+
+enum {
+ PD_RSV_I,
+ PD_SEL_I,
+ PD_FDT_I,
+ PD_SDT_I,
+ PD_RES_I,
+ PD_PDT_I,
+ _PD_RSV_MAX
+};
+#define PD_MAX_IND (_TOM_RSV_MAX - 1)
+
+static inline int pd_valid(u_int16_t pd)
+{
+ if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
+ return 1;
+ return 0;
+}
+
+static inline void chk_op_type(u_int16_t type, u_int16_t msk, u_int16_t omsk)
+{
+ if (type != F_TLV_PDAT) {
+ if (msk & B_KEYIN) {
+ if (type != F_TLV_KEYI) {
+ printf
+ ("Based on flags expected KEYINFO TLV!\n");
+ }
+ } else {
+ if (!(msk & omsk)) {
+ printf
+ ("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
+ type, omsk, msk);
+ }
+ }
+ }
+
+}
+
+int fdatatlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int sdatailv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int sdatatlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int pdatatlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+int pkeyitlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+
+int pdatacnt_print(register const u_char * pptr, register u_int len,
+ u_int32_t IDcnt, u_int16_t op_msk, int indent);
+int pdata_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+
+int prestlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent);
+#define F_SELKEY 1
+
+struct res_val {
+ u_int8_t result;
+ u_int8_t resv1;
+ u_int16_t resv2;
+};
+
+static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
+ /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
+ /* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
+ /* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
+ /* PD_SDT_I */ {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print},
+ /* PD_RES_I */ {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print},
+ /* PD_PDT_I */
+ {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
+};
+
+static inline const struct pdata_ops *get_forces_pd(u_int16_t pd)
+{
+ int i;
+ for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
+ const struct pdata_ops *pdo = &ForCES_pdata[i];
+ if (pdo->v == pd)
+ return pdo;
+ }
+ return &ForCES_pdata[TOM_RSV_I];
+}
+
+enum {
+ E_SUCCESS,
+ E_INVALID_HEADER,
+ E_LENGTH_MISMATCH,
+ E_VERSION_MISMATCH,
+ E_INVALID_DESTINATION_PID,
+ E_LFB_UNKNOWN,
+ E_LFB_NOT_FOUND,
+ E_LFB_INSTANCE_ID_NOT_FOUND,
+ E_INVALID_PATH,
+ E_COMPONENT_DOES_NOT_EXIST,
+ E_EXISTS,
+ E_NOT_FOUND,
+ E_READ_ONLY,
+ E_INVALID_ARRAY_CREATION,
+ E_VALUE_OUT_OF_RANGE,
+ E_CONTENTS_TOO_LONG,
+ E_INVALID_PARAMETERS,
+ E_INVALID_MESSAGE_TYPE,
+ E_INVALID_FLAGS,
+ E_INVALID_TLV,
+ E_EVENT_ERROR,
+ E_NOT_SUPPORTED,
+ E_MEMORY_ERROR,
+ E_INTERNAL_ERROR,
+ /* 0x18-0xFE are reserved .. */
+ E_UNSPECIFIED_ERROR = 0XFF
+};
+
+const struct tok ForCES_errs[] = {
+ {E_SUCCESS, "SUCCESS"},
+ {E_INVALID_HEADER, "INVALID HEADER"},
+ {E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
+ {E_VERSION_MISMATCH, "VERSION MISMATCH"},
+ {E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"},
+ {E_LFB_UNKNOWN, "LFB UNKNOWN"},
+ {E_LFB_NOT_FOUND, "LFB NOT FOUND"},
+ {E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"},
+ {E_INVALID_PATH, "INVALID PATH"},
+ {E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"},
+ {E_EXISTS, "EXISTS ALREADY"},
+ {E_NOT_FOUND, "NOT FOUND"},
+ {E_READ_ONLY, "READ ONLY"},
+ {E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"},
+ {E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"},
+ {E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"},
+ {E_INVALID_PARAMETERS, "INVALID PARAMETERS"},
+ {E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"},
+ {E_INVALID_FLAGS, "INVALID FLAGS"},
+ {E_INVALID_TLV, "INVALID TLV"},
+ {E_EVENT_ERROR, "EVENT ERROR"},
+ {E_NOT_SUPPORTED, "NOT SUPPORTED"},
+ {E_MEMORY_ERROR, "MEMORY ERROR"},
+ {E_INTERNAL_ERROR, "INTERNAL ERROR"},
+ {E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"},
+ {0, NULL}
+};
diff --git a/gmpls.c b/gmpls.c
index ff9adb595005..739176798cde 100644
--- a/gmpls.c
+++ b/gmpls.c
@@ -28,7 +28,7 @@ static const char rcsid[] _U_ =
#include "gmpls.h"
/* rfc3471 */
-struct tok gmpls_link_prot_values[] = {
+const struct tok gmpls_link_prot_values[] = {
{ 0x01, "Extra Traffic"},
{ 0x02, "Unprotected"},
{ 0x04, "Shared"},
@@ -41,7 +41,7 @@ struct tok gmpls_link_prot_values[] = {
};
/* rfc3471 */
-struct tok gmpls_switch_cap_values[] = {
+const struct tok gmpls_switch_cap_values[] = {
{ GMPLS_PSC1, "Packet-Switch Capable-1"},
{ GMPLS_PSC2, "Packet-Switch Capable-2"},
{ GMPLS_PSC3, "Packet-Switch Capable-3"},
@@ -54,14 +54,14 @@ struct tok gmpls_switch_cap_values[] = {
};
/* rfc4205 */
-struct tok gmpls_switch_cap_tsc_indication_values[] = {
+const struct tok gmpls_switch_cap_tsc_indication_values[] = {
{ 0, "Standard SONET/SDH" },
{ 1, "Arbitrary SONET/SDH" },
{ 0, NULL }
};
/* rfc3471 */
-struct tok gmpls_encoding_values[] = {
+const struct tok gmpls_encoding_values[] = {
{ 1, "Packet"},
{ 2, "Ethernet V2/DIX"},
{ 3, "ANSI/ETSI PDH"},
@@ -77,7 +77,7 @@ struct tok gmpls_encoding_values[] = {
};
/* rfc3471 */
-struct tok gmpls_payload_values[] = {
+const struct tok gmpls_payload_values[] = {
{ 0, "Unknown"},
{ 1, "Reserved"},
{ 2, "Reserved"},
@@ -145,7 +145,7 @@ struct tok gmpls_payload_values[] = {
* Link Type values used by LMP Service Discovery (specifically, the Client
* Port Service Attributes Object). See UNI 1.0 section 9.4.2 for details.
*/
-struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
+const struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
{ 5, "SDH ITU-T G.707"},
{ 6, "SONET ANSI T1.105"},
{ 0, NULL}
@@ -156,7 +156,7 @@ struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
* the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
* details.
*/
-struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
+const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
{ 5, "VC-3"},
{ 6, "VC-4"},
{ 7, "STM-0"},
@@ -173,7 +173,7 @@ struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
* the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
* details.
*/
-struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
+const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
{ 5, "STS-1 SPE"},
{ 6, "STS-3c SPE"},
{ 7, "STS-1"},
@@ -189,7 +189,7 @@ struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
#define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */
#define DIFFSERV_BC_MODEL_EXTD_MAM 254 /* experimental */
-struct tok diffserv_te_bc_values[] = {
+const struct tok diffserv_te_bc_values[] = {
{ DIFFSERV_BC_MODEL_RDM, "Russian dolls"},
{ DIFFSERV_BC_MODEL_MAM, "Maximum allocation"},
{ DIFFSERV_BC_MODEL_EXTD_MAM, "Maximum allocation with E-LSP support"},
diff --git a/gmpls.h b/gmpls.h
index 6b2db230a1d5..8db99deac8c6 100644
--- a/gmpls.h
+++ b/gmpls.h
@@ -23,12 +23,12 @@
#define GMPLS_LSC 150
#define GMPLS_FSC 200
-extern struct tok gmpls_link_prot_values[];
-extern struct tok gmpls_switch_cap_values[];
-extern struct tok gmpls_switch_cap_tsc_indication_values[];
-extern struct tok gmpls_encoding_values[];
-extern struct tok gmpls_payload_values[];
-extern struct tok diffserv_te_bc_values[];
-extern struct tok lmp_sd_service_config_cpsa_link_type_values[];
-extern struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[];
-extern struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[];
+extern const struct tok gmpls_link_prot_values[];
+extern const struct tok gmpls_switch_cap_values[];
+extern const struct tok gmpls_switch_cap_tsc_indication_values[];
+extern const struct tok gmpls_encoding_values[];
+extern const struct tok gmpls_payload_values[];
+extern const struct tok diffserv_te_bc_values[];
+extern const struct tok lmp_sd_service_config_cpsa_link_type_values[];
+extern const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[];
+extern const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[];
diff --git a/gmt2local.h b/gmt2local.h
index 17120c5b785e..f7b3841e6aef 100644
--- a/gmt2local.h
+++ b/gmt2local.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2.1.1 1999-10-07 23:47:10 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2 1999-10-07 23:47:10 mcr Exp $ (LBL)
*/
#ifndef gmt2local_h
#define gmt2local_h
diff --git a/icmp6.h b/icmp6.h
index 5d272703fac0..168a70897f10 100644
--- a/icmp6.h
+++ b/icmp6.h
@@ -276,7 +276,7 @@ struct nd_opt_hdr { /* Neighbor discovery option header */
#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 */
-
+#define ND_OPT_RDNSS 25
struct nd_opt_prefix_info { /* prefix information */
u_int8_t nd_opt_pi_type;
@@ -308,6 +308,14 @@ struct nd_opt_mtu { /* MTU option */
u_int32_t nd_opt_mtu_mtu;
};
+struct nd_opt_rdnss { /* RDNSS RFC 5006 */
+ u_int8_t nd_opt_rdnss_type;
+ u_int8_t nd_opt_rdnss_len;
+ u_int16_t nd_opt_rdnss_reserved;
+ u_int32_t nd_opt_rdnss_lifetime;
+ struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */
+};
+
struct nd_opt_advinterval { /* Advertisement interval option */
u_int8_t nd_opt_adv_type;
u_int8_t nd_opt_adv_len;
diff --git a/ieee802_11.h b/ieee802_11.h
index 3bcda7d22ba1..2aa1345038a2 100644
--- a/ieee802_11.h
+++ b/ieee802_11.h
@@ -30,6 +30,7 @@
#define IEEE802_11_RA_LEN 6
#define IEEE802_11_TA_LEN 6
#define IEEE802_11_SEQ_LEN 2
+#define IEEE802_11_CTL_LEN 2
#define IEEE802_11_IV_LEN 3
#define IEEE802_11_KID_LEN 1
@@ -67,11 +68,14 @@
#define ST_DISASSOC 0xA
#define ST_AUTH 0xB
#define ST_DEAUTH 0xC
-/* RESERVED 0xD */
+#define ST_ACTION 0xD
/* RESERVED 0xE */
/* RESERVED 0xF */
+#define CTRL_CONTROL_WRAPPER 0x7
+#define CTRL_BAR 0x8
+#define CTRL_BA 0x9
#define CTRL_PS_POLL 0xA
#define CTRL_RTS 0xB
#define CTRL_CTS 0xC
@@ -140,12 +144,6 @@ struct mgmt_header_t {
#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
-typedef enum {
- NOT_PRESENT,
- PRESENT,
- TRUNCATED
-} elem_status_t;
-
struct ssid_t {
u_int8_t element_id;
u_int8_t length;
@@ -233,20 +231,20 @@ struct mgmt_body_t {
u_int16_t reason_code;
u_int16_t auth_alg;
u_int16_t auth_trans_seq_num;
- elem_status_t challenge_status;
+ int challenge_present;
struct challenge_t challenge;
u_int16_t capability_info;
- elem_status_t ssid_status;
+ int ssid_present;
struct ssid_t ssid;
- elem_status_t rates_status;
+ int rates_present;
struct rates_t rates;
- elem_status_t ds_status;
+ int ds_present;
struct ds_t ds;
- elem_status_t cf_status;
+ int cf_present;
struct cf_t cf;
- elem_status_t fh_status;
+ int fh_present;
struct fh_t fh;
- elem_status_t tim_status;
+ int tim_present;
struct tim_t tim;
};
@@ -312,6 +310,38 @@ struct ctrl_end_ack_t {
#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
+struct ctrl_ba_t {
+ u_int16_t fc;
+ u_int16_t duration;
+ u_int8_t ra[6];
+ u_int8_t fcs[4];
+};
+
+#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_bar_t {
+ u_int16_t fc;
+ u_int16_t dur;
+ u_int8_t ra[6];
+ u_int8_t ta[6];
+ u_int16_t ctl;
+ u_int16_t seq;
+ u_int8_t fcs[4];
+};
+
+#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
+ IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
+
+struct meshcntl_t {
+ u_int8_t flags;
+ u_int8_t ttl;
+ u_int8_t seq[4];
+ u_int8_t addr4[6];
+ u_int8_t addr5[6];
+ u_int8_t addr6[6];
+};
+
#define IV_IV(iv) ((iv) & 0xFFFFFF)
#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
diff --git a/ieee802_11_radio.h b/ieee802_11_radio.h
index 3f2b836f3bfa..8caeaa256153 100644
--- a/ieee802_11_radio.h
+++ b/ieee802_11_radio.h
@@ -33,11 +33,11 @@
#ifndef _NET_IF_IEEE80211RADIOTAP_H_
#define _NET_IF_IEEE80211RADIOTAP_H_
-/* A generic radio capture format is desirable. There is one for
- * Linux, but it is neither rigidly defined (there were not even
- * units given for some fields) nor easily extensible.
+/* A generic radio capture format is desirable. It must be
+ * rigidly defined (e.g., units for fields should be given),
+ * and easily extensible.
*
- * I suggest the following extensible radio capture format. It is
+ * The following is an extensible radio capture format. It is
* based on a bitmap indicating which fields are present.
*
* I am trying to describe precisely what the application programmer
@@ -47,13 +47,12 @@
* function of...") that I cannot set false expectations for lawyerly
* readers.
*/
-#if defined(__KERNEL__) || defined(_KERNEL)
-#ifndef DLT_IEEE802_11_RADIO
-#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus WLAN header */
-#endif
-#endif /* defined(__KERNEL__) || defined(_KERNEL) */
-/* The radio capture header precedes the 802.11 header. */
+/*
+ * The radio capture header precedes the 802.11 header.
+ *
+ * Note well: all radiotap fields are little-endian.
+ */
struct ieee80211_radiotap_header {
u_int8_t it_version; /* Version 0. Only increases
* for drastic changes,
@@ -73,7 +72,7 @@ struct ieee80211_radiotap_header {
* Additional extensions are made
* by setting bit 31.
*/
-} __attribute__((__packed__));
+};
/* Name Data type Units
* ---- --------- -----
@@ -87,15 +86,19 @@ struct ieee80211_radiotap_header {
* IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap
*
* Tx/Rx frequency in MHz, followed by flags (see below).
+ * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
+ * represent an HT channel as there is not enough room in
+ * the flags word.
*
* IEEE80211_RADIOTAP_FHSS u_int16_t see below
*
* For frequency-hopping radios, the hop set (first byte)
* and pattern (second byte).
*
- * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s
+ * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s or index
*
- * Tx/Rx data rate
+ * Tx/Rx data rate. If bit 0x80 is set then it represents an
+ * an MCS index and not an IEEE rate.
*
* IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
* one milliwatt (dBm)
@@ -155,9 +158,16 @@ struct ieee80211_radiotap_header {
* Unitless indication of the Rx/Tx antenna for this packet.
* The first antenna is antenna 0.
*
- * IEEE80211_RADIOTAP_FCS u_int32_t data
+ * IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap
+ * u_int16_t MHz
+ * u_int8_t channel number
+ * u_int8_t .5 dBm
*
- * FCS from frame in network byte order.
+ * Extended channel specification: flags (see below) followed by
+ * frequency in MHz, the corresponding IEEE channel number, and
+ * finally the maximum regulatory transmit power cap in .5 dBm
+ * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
+ * and only one of the two should be present.
*/
enum ieee80211_radiotap_type {
IEEE80211_RADIOTAP_TSFT = 0,
@@ -174,20 +184,27 @@ enum ieee80211_radiotap_type {
IEEE80211_RADIOTAP_ANTENNA = 11,
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
+ /* NB: gap for netbsd definitions */
+ IEEE80211_RADIOTAP_XCHANNEL = 18,
IEEE80211_RADIOTAP_EXT = 31
};
-#ifndef _KERNEL
-/* Channel flags. */
-#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
-#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
-#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
-#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
-#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
-#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
-#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
-#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
-#endif /* !_KERNEL */
+/* channel attributes */
+#define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
+#define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
+#define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
+#define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
+#define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
+#define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
+#define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
+#define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
+#define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
+#define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
+#define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
+#define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
+#define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
+#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
+#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
/* For IEEE80211_RADIOTAP_FLAGS */
#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
@@ -209,5 +226,6 @@ enum ieee80211_radiotap_type {
* (to 32-bit boundary)
*/
#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
+#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */
#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
diff --git a/interface.h b/interface.h
index 1f031231d47a..6e04b058c21c 100644
--- a/interface.h
+++ b/interface.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.280.2.4 2008-04-04 19:42:52 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.285 2008-08-16 11:36:20 hannes Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -82,21 +82,6 @@ extern char *strsep(char **, const char *);
#define max(a,b) ((b)>(a)?(b):(a))
#endif
-/*
- * The default snapshot length. This value allows most printers to print
- * useful information while keeping the amount of unwanted data down.
- */
-#ifndef INET6
-#define DEFAULT_SNAPLEN 68 /* ether + IPv4 + TCP + 14 */
-#else
-#define DEFAULT_SNAPLEN 96 /* ether + IPv6 + TCP + 22 */
-#endif
-
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN 4321
-#define LITTLE_ENDIAN 1234
-#endif
-
#define ESRC(ep) ((ep)->ether_shost)
#define EDST(ep) ((ep)->ether_dhost)
@@ -181,10 +166,10 @@ extern void hex_and_ascii_print(const char *, const u_char *, u_int);
extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
extern void hex_print(const char *, const u_char *, u_int);
extern void telnet_print(const u_char *, u_int);
-extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
+extern int ethertype_print(u_short, const u_char *, u_int, u_int);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
-extern int snap_print(const u_char *, u_int, u_int, u_short *, u_int);
+extern int snap_print(const u_char *, u_int, u_int, u_int);
extern void aarp_print(const u_char *, u_int);
extern void aodv_print(const u_char *, u_int, int);
extern void atalk_print(const u_char *, u_int);
@@ -204,7 +189,8 @@ extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void ether_print(const u_char *, u_int, u_int);
+extern void ether_print(const u_char *, u_int, u_int,
+ void (*)(const u_char *), const u_char *);
extern u_int ether_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int token_print(const u_char *, u_int, u_int);
extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
@@ -239,7 +225,7 @@ extern void ns_print(const u_char *, u_int, int);
extern void ntp_print(const u_char *, u_int);
extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
extern void ospf_print(const u_char *, u_int, const u_char *);
-extern void olsr_print (const u_char *, u_int);
+extern void olsr_print (const u_char *, u_int, int);
extern void pimv1_print(const u_char *, u_int);
extern void cisco_autorp_print(const u_char *, u_int);
extern void rsvp_print(const u_char *, u_int);
@@ -251,7 +237,7 @@ extern void lwapp_control_print(const u_char *, u_int, int);
extern void lwapp_data_print(const u_char *, u_int);
extern void eigrp_print(const u_char *, u_int);
extern void mobile_print(const u_char *, u_int);
-extern void pim_print(const u_char *, u_int);
+extern void pim_print(const u_char *, u_int, u_int);
extern u_int pppoe_print(const u_char *, u_int);
extern u_int ppp_print(register const u_char *, u_int);
extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *);
@@ -324,6 +310,7 @@ extern void lwres_print(const u_char *, u_int);
extern void pptp_print(const u_char *);
extern void dccp_print(const u_char *, const u_char *, u_int);
extern void sctp_print(const u_char *, const u_char *, u_int);
+extern void forces_print(const u_char *, u_int);
extern void mpls_print(const u_char *, u_int);
extern void mpls_lsp_ping_print(const u_char *, u_int);
extern void zephyr_print(const u_char *, int);
@@ -332,19 +319,22 @@ extern void bfd_print(const u_char *, u_int, u_int);
extern void sip_print(const u_char *, u_int);
extern void syslog_print(const u_char *, u_int);
extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
#ifdef INET6
extern void ip6_print(const u_char *, u_int);
extern void ip6_opt_print(const u_char *, int);
+extern int nextproto6_cksum(const struct ip6_hdr *, const u_short *, u_int, u_int);
extern int hbhopt_print(const u_char *);
extern int dstopt_print(const u_char *);
extern int frag6_print(const u_char *, const u_char *);
extern int mobility_print(const u_char *, const u_char *);
-extern void icmp6_print(const u_char *, u_int, const u_char *, int);
extern void ripng_print(const u_char *, unsigned int);
extern int rt6_print(const u_char *, const u_char *);
extern void ospf6_print(const u_char *, u_int);
extern void dhcp6_print(const u_char *, u_int);
+extern int mask62plen(const u_char *);
#endif /*INET6*/
extern u_short in_cksum(const u_short *, register u_int, int);
extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
@@ -363,6 +353,7 @@ extern void bpf_dump(const struct bpf_program *, int);
#ifndef NETDISSECT_REWORKED
extern netdissect_options *gndo;
+#define bflag gndo->ndo_bflag
#define eflag gndo->ndo_eflag
#define fflag gndo->ndo_fflag
#define Kflag gndo->ndo_Kflag
@@ -387,7 +378,7 @@ extern netdissect_options *gndo;
#define Iflag gndo->ndo_Iflag
#define suppress_default_print gndo->ndo_suppress_default_print
#define packettype gndo->ndo_packettype
-#define tcpmd5secret gndo->ndo_tcpmd5secret
+#define sigsecret gndo->ndo_sigsecret
#define Wflag gndo->ndo_Wflag
#define WflagChars gndo->ndo_WflagChars
#define Cflag_count gndo->ndo_Cflag_count
diff --git a/ip6.h b/ip6.h
index e4f9fe1c9e5e..a6df97aae10b 100644
--- a/ip6.h
+++ b/ip6.h
@@ -88,6 +88,20 @@ struct ip6_hdr {
struct in6_addr ip6_dst; /* destination address */
};
+/*
+ * Pseudo header, used for higher layer checksumming.
+ */
+union ip6_pseudo_hdr {
+ struct {
+ struct in6_addr ph_src;
+ struct in6_addr ph_dst;
+ u_int32_t ph_len;
+ u_int8_t ph_zero[3];
+ u_int8_t ph_nxt;
+ } ph;
+ u_int16_t pa[20];
+};
+
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
diff --git a/ipnet.h b/ipnet.h
new file mode 100644
index 000000000000..ae692842e3b8
--- /dev/null
+++ b/ipnet.h
@@ -0,0 +1,13 @@
+typedef struct ipnet_hdr {
+ uint8_t iph_version;
+ uint8_t iph_family;
+ uint16_t iph_htype;
+ uint32_t iph_pktlen;
+ uint32_t iph_ifindex;
+ uint32_t iph_grifindex;
+ uint32_t iph_zsrc;
+ uint32_t iph_zdst;
+} ipnet_hdr_t;
+
+#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
+#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
diff --git a/ipproto.c b/ipproto.c
index 7b89afb9c836..644b36427719 100755
--- a/ipproto.c
+++ b/ipproto.c
@@ -27,7 +27,7 @@ static const char rcsid[] _U_ =
#include "interface.h"
#include "ipproto.h"
-struct tok ipproto_values[] = {
+const struct tok ipproto_values[] = {
{ IPPROTO_HOPOPTS, "Options" },
{ IPPROTO_ICMP, "ICMP" },
{ IPPROTO_IGMP, "IGMP" },
diff --git a/ipproto.h b/ipproto.h
index f5257863cedd..96407541f64d 100644
--- a/ipproto.h
+++ b/ipproto.h
@@ -37,7 +37,7 @@
* $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $
*/
-extern struct tok ipproto_values[];
+extern const struct tok ipproto_values[];
#ifndef IPPROTO_IP
#define IPPROTO_IP 0 /* dummy for IP */
diff --git a/isakmp.h b/isakmp.h
index 85d383d1b3be..d628f7ae32fc 100644
--- a/isakmp.h
+++ b/isakmp.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* YIPS @(#)$Id: isakmp.h,v 1.11 2007-08-29 02:38:14 mcr Exp $ */
+/* YIPS @(#)$Id: isakmp.h,v 1.12 2007-11-24 18:13:33 mcr Exp $ */
/* refer to RFC 2408 */
@@ -127,6 +127,7 @@ struct isakmp {
#define ISAKMP_NPTYPE_N 11 /* Notification */
#define ISAKMP_NPTYPE_D 12 /* Delete */
#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
+#define ISAKMP_NPTYPE_v2E 46 /* v2 Encrypted payload */
#define IKEv1_MAJOR_VERSION 1
#define IKEv1_MINOR_VERSION 0
@@ -422,14 +423,31 @@ struct ikev2_ke {
};
+/* 3.5. Identification Payloads */
+enum ikev2_id_type {
+ ID_IPV4_ADDR=1,
+ ID_FQDN=2,
+ ID_RFC822_ADDR=3,
+ ID_IPV6_ADDR=5,
+ ID_DER_ASN1_DN=9,
+ ID_DER_ASN1_GN=10,
+ ID_KEY_ID=11,
+};
+struct ikev2_id {
+ struct isakmp_gen h;
+ u_int8_t type; /* ID type */
+ u_int8_t res1;
+ u_int16_t res2;
+ /* SPI */
+ /* Notification Data */
+};
+
/* 3.10 Notification Payload */
struct ikev2_n {
struct isakmp_gen h;
u_int8_t prot_id; /* Protocol-ID */
u_int8_t spi_size; /* SPI Size */
u_int16_t type; /* Notify Message Type */
- /* SPI */
- /* Notification Data */
};
enum ikev2_n_type {
diff --git a/l2vpn.c b/l2vpn.c
index a82219178289..021e7f0ad2bb 100755
--- a/l2vpn.c
+++ b/l2vpn.c
@@ -27,7 +27,7 @@ static const char rcsid[] _U_ =
#include "l2vpn.h"
/* draft-ietf-pwe3-iana-allocation-04 */
-struct tok l2vpn_encaps_values[] = {
+const struct tok l2vpn_encaps_values[] = {
{ 0x00, "Reserved"},
{ 0x01, "Frame Relay"},
{ 0x02, "ATM AAL5 VCC transport"},
diff --git a/l2vpn.h b/l2vpn.h
index 766cda546ae1..871eca0e0d22 100755
--- a/l2vpn.h
+++ b/l2vpn.h
@@ -14,4 +14,4 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-extern struct tok l2vpn_encaps_values[];
+extern const struct tok l2vpn_encaps_values[];
diff --git a/lbl/os-sunos4.h b/lbl/os-sunos4.h
index 51a70dd4487d..ab0a12c54131 100644
--- a/lbl/os-sunos4.h
+++ b/lbl/os-sunos4.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-sunos4.h,v 1.32.1.1 1999-10-07 23:47:13 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-sunos4.h,v 1.32 1999-10-07 23:47:13 mcr Exp $ (LBL)
*/
/* Prototypes missing in SunOS 4 */
diff --git a/lbl/os-ultrix4.h b/lbl/os-ultrix4.h
index 1b154eeec26d..347485ec530e 100644
--- a/lbl/os-ultrix4.h
+++ b/lbl/os-ultrix4.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-ultrix4.h,v 1.19.1.1 1999-10-07 23:47:13 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-ultrix4.h,v 1.19 1999-10-07 23:47:13 mcr Exp $ (LBL)
*/
/* Prototypes missing in Ultrix 4 */
diff --git a/missing/addrinfo.h b/missing/addrinfo.h
index 1b5f92ecb860..d3d63cd78bea 100644
--- a/missing/addrinfo.h
+++ b/missing/addrinfo.h
@@ -81,9 +81,6 @@ struct addrinfo {
extern void freeaddrinfo (struct addrinfo *);
extern void freehostent (struct hostent *);
-extern char *gai_strerror (int);
-extern int getaddrinfo (const char *, const char *,
- const struct addrinfo *, struct addrinfo **);
extern int getnameinfo (const struct sockaddr *, size_t, char *,
size_t, char *, size_t, int);
extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
diff --git a/missing/getaddrinfo.c b/missing/getaddrinfo.c
deleted file mode 100644
index f59b2c4ef365..000000000000
--- a/missing/getaddrinfo.c
+++ /dev/null
@@ -1,1115 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
- *
- * Issues to be discussed:
- * - Thread safe-ness must be checked.
- * - Return values. There are nonstandard return values defined and used
- * in the source code. This is because RFC2553 is silent about which error
- * code must be returned for which situation.
- * Note:
- * - We use getipnodebyname() just for thread-safeness. There's no intent
- * to let it do PF_UNSPEC (actually we never pass PF_UNSPEC to
- * getipnodebyname().
- * - The code filters out AFs that are not supported by the kernel,
- * when globbing NULL hostname (to loopback, or wildcard). Is it the right
- * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG
- * in ai_flags?
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.13 2003-11-16 09:36:48 guy Exp $";
-#endif
-
-#include <sys/types.h>
-#include <sys/param.h>
-#if 0
-#include <sys/sysctl.h>
-#endif
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-
-#ifndef HAVE_U_INT32_T
-#include "bittypes.h"
-#endif
-
-#ifndef HAVE_SOCKADDR_STORAGE
-#include "sockstorage.h"
-#endif
-
-#ifdef NEED_ADDRINFO_H
-#include "addrinfo.h"
-#endif
-
-#if defined(__KAME__) && defined(INET6)
-# define FAITH
-#endif
-
-#define SUCCESS 0
-#define ANY 0
-#define YES 1
-#define NO 0
-
-#ifdef FAITH
-static int translate = NO;
-static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
-#endif
-
-static const char in_addrany[] = { 0, 0, 0, 0 };
-static const char in6_addrany[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-static const char in_loopback[] = { 127, 0, 0, 1 };
-static const char in6_loopback[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-};
-
-struct sockinet {
- u_char si_len;
- u_char si_family;
- u_short si_port;
- u_int32_t si_scope_id;
-};
-
-static const struct afd {
- int a_af;
- int a_addrlen;
- int a_socklen;
- int a_off;
- const char *a_addrany;
- const char *a_loopback;
- int a_scoped;
-} afdl [] = {
-#ifdef INET6
- {PF_INET6, sizeof(struct in6_addr),
- sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr),
- in6_addrany, in6_loopback, 1},
-#endif
- {PF_INET, sizeof(struct in_addr),
- sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr),
- in_addrany, in_loopback, 0},
- {0, 0, 0, 0, NULL, NULL, 0},
-};
-
-struct explore {
- int e_af;
- int e_socktype;
- int e_protocol;
- const char *e_protostr;
- int e_wild;
-#define WILD_AF(ex) ((ex)->e_wild & 0x01)
-#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02)
-#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04)
-};
-
-static const struct explore explore[] = {
-#if 0
- { PF_LOCAL, 0, ANY, ANY, NULL, 0x01 },
-#endif
-#ifdef INET6
- { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
- { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
- { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
-#endif
- { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
- { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
- { PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
- { -1, 0, 0, NULL, 0 },
-};
-
-#ifdef INET6
-#define PTON_MAX 16
-#else
-#define PTON_MAX 4
-#endif
-
-
-static int str_isnumber (const char *);
-static int explore_fqdn (const struct addrinfo *, const char *,
- const char *, struct addrinfo **);
-static int explore_null (const struct addrinfo *, const char *,
- const char *, struct addrinfo **);
-static int explore_numeric (const struct addrinfo *, const char *,
- const char *, struct addrinfo **);
-static int explore_numeric_scope (const struct addrinfo *, const char *,
- const char *, struct addrinfo **);
-static int get_name (const char *, const struct afd *, struct addrinfo **,
- char *, const struct addrinfo *, const char *);
-static int get_canonname (const struct addrinfo *,
- struct addrinfo *, const char *);
-static struct addrinfo *get_ai (const struct addrinfo *,
- const struct afd *, const char *);
-static int get_portmatch (const struct addrinfo *, const char *);
-static int get_port (struct addrinfo *, const char *, int);
-static const struct afd *find_afd (int);
-
-static char *ai_errlist[] = {
- "Success",
- "Address family for hostname not supported", /* EAI_ADDRFAMILY */
- "Temporary failure in name resolution", /* EAI_AGAIN */
- "Invalid value for ai_flags", /* EAI_BADFLAGS */
- "Non-recoverable failure in name resolution", /* EAI_FAIL */
- "ai_family not supported", /* EAI_FAMILY */
- "Memory allocation failure", /* EAI_MEMORY */
- "No address associated with hostname", /* EAI_NODATA */
- "hostname nor servname provided, or not known", /* EAI_NONAME */
- "servname not supported for ai_socktype", /* EAI_SERVICE */
- "ai_socktype not supported", /* EAI_SOCKTYPE */
- "System error returned in errno", /* EAI_SYSTEM */
- "Invalid value for hints", /* EAI_BADHINTS */
- "Resolved protocol is unknown", /* EAI_PROTOCOL */
- "Unknown error", /* EAI_MAX */
-};
-
-/* XXX macros that make external reference is BAD. */
-
-#define GET_AI(ai, afd, addr) \
-do { \
- /* external reference: pai, error, and label free */ \
- (ai) = get_ai(pai, (afd), (addr)); \
- if ((ai) == NULL) { \
- error = EAI_MEMORY; \
- goto free; \
- } \
-} while (0)
-
-#define GET_PORT(ai, serv) \
-do { \
- /* external reference: error and label free */ \
- error = get_port((ai), (serv), 0); \
- if (error != 0) \
- goto free; \
-} while (0)
-
-#define GET_CANONNAME(ai, str) \
-do { \
- /* external reference: pai, error and label free */ \
- error = get_canonname(pai, (ai), (str)); \
- if (error != 0) \
- goto free; \
-} while (0)
-
-#define ERR(err) \
-do { \
- /* external reference: error, and label bad */ \
- error = (err); \
- goto bad; \
-} while (0)
-
-#define MATCH_FAMILY(x, y, w) \
- ((x) == (y) || ((w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
-#define MATCH(x, y, w) \
- ((x) == (y) || ((w) && ((x) == ANY || (y) == ANY)))
-
-char *
-gai_strerror(ecode)
- int ecode;
-{
- if (ecode < 0 || ecode > EAI_MAX)
- ecode = EAI_MAX;
- return ai_errlist[ecode];
-}
-
-void
-freeaddrinfo(ai)
- struct addrinfo *ai;
-{
- struct addrinfo *next;
-
- do {
- next = ai->ai_next;
- if (ai->ai_canonname)
- free(ai->ai_canonname);
- /* no need to free(ai->ai_addr) */
- free(ai);
- } while ((ai = next) != NULL);
-}
-
-static int
-str_isnumber(p)
- const char *p;
-{
- char *q = (char *)p;
- while (*q) {
- if (! isdigit(*q))
- return NO;
- q++;
- }
- return YES;
-}
-
-int
-getaddrinfo(hostname, servname, hints, res)
- const char *hostname, *servname;
- const struct addrinfo *hints;
- struct addrinfo **res;
-{
- struct addrinfo sentinel;
- struct addrinfo *cur;
- int error = 0;
- struct addrinfo ai;
- struct addrinfo ai0;
- struct addrinfo *pai;
- const struct afd *afd;
- const struct explore *ex;
-
-#ifdef FAITH
- static int firsttime = 1;
-
- if (firsttime) {
- /* translator hack */
- char *q = getenv("GAI");
- if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
- translate = YES;
- firsttime = 0;
- }
-#endif
-
- sentinel.ai_next = NULL;
- cur = &sentinel;
- pai = &ai;
- pai->ai_flags = 0;
- pai->ai_family = PF_UNSPEC;
- pai->ai_socktype = ANY;
- pai->ai_protocol = ANY;
- pai->ai_addrlen = 0;
- pai->ai_canonname = NULL;
- pai->ai_addr = NULL;
- pai->ai_next = NULL;
-
- if (hostname == NULL && servname == NULL)
- return EAI_NONAME;
- if (hints) {
- /* error check for hints */
- if (hints->ai_addrlen || hints->ai_canonname ||
- hints->ai_addr || hints->ai_next)
- ERR(EAI_BADHINTS); /* xxx */
- if (hints->ai_flags & ~AI_MASK)
- ERR(EAI_BADFLAGS);
- switch (hints->ai_family) {
- case PF_UNSPEC:
- case PF_INET:
-#ifdef INET6
- case PF_INET6:
-#endif
- break;
- default:
- ERR(EAI_FAMILY);
- }
- memcpy(pai, hints, sizeof(*pai));
-
- /*
- * if both socktype/protocol are specified, check if they
- * are meaningful combination.
- */
- if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) {
- for (ex = explore; ex->e_af >= 0; ex++) {
- if (pai->ai_family != ex->e_af)
- continue;
- if (ex->e_socktype == ANY)
- continue;
- if (ex->e_protocol == ANY)
- continue;
- if (pai->ai_socktype == ex->e_socktype
- && pai->ai_protocol != ex->e_protocol) {
- ERR(EAI_BADHINTS);
- }
- }
- }
- }
-
- /*
- * check for special cases. (1) numeric servname is disallowed if
- * socktype/protocol are left unspecified. (2) servname is disallowed
- * for raw and other inet{,6} sockets.
- */
- if (MATCH_FAMILY(pai->ai_family, PF_INET, 1)
-#ifdef PF_INET6
- || MATCH_FAMILY(pai->ai_family, PF_INET6, 1)
-#endif
- ) {
- ai0 = *pai;
-
- if (pai->ai_family == PF_UNSPEC) {
-#ifdef PF_INET6
- pai->ai_family = PF_INET6;
-#else
- pai->ai_family = PF_INET;
-#endif
- }
- error = get_portmatch(pai, servname);
- if (error)
- ERR(error);
-
- *pai = ai0;
- }
-
- ai0 = *pai;
-
- /* NULL hostname, or numeric hostname */
- for (ex = explore; ex->e_af >= 0; ex++) {
- *pai = ai0;
-
- if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
- continue;
- if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex)))
- continue;
- if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex)))
- continue;
-
- if (pai->ai_family == PF_UNSPEC)
- pai->ai_family = ex->e_af;
- if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
- pai->ai_socktype = ex->e_socktype;
- if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
- pai->ai_protocol = ex->e_protocol;
-
- if (hostname == NULL)
- error = explore_null(pai, hostname, servname, &cur->ai_next);
- else
- error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next);
-
- if (error)
- goto free;
-
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- }
-
- /*
- * XXX
- * If numreic representation of AF1 can be interpreted as FQDN
- * representation of AF2, we need to think again about the code below.
- */
- if (sentinel.ai_next)
- goto good;
-
- if (pai->ai_flags & AI_NUMERICHOST)
- ERR(EAI_NONAME);
- if (hostname == NULL)
- ERR(EAI_NONAME);
-
- /*
- * hostname as alphabetical name.
- * we would like to prefer AF_INET6 than AF_INET, so we'll make a
- * outer loop by AFs.
- */
- for (afd = afdl; afd->a_af; afd++) {
- *pai = ai0;
-
- if (!MATCH_FAMILY(pai->ai_family, afd->a_af, 1))
- continue;
-
- for (ex = explore; ex->e_af >= 0; ex++) {
- *pai = ai0;
-
- if (pai->ai_family == PF_UNSPEC)
- pai->ai_family = afd->a_af;
-
- if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
- continue;
- if (!MATCH(pai->ai_socktype, ex->e_socktype,
- WILD_SOCKTYPE(ex))) {
- continue;
- }
- if (!MATCH(pai->ai_protocol, ex->e_protocol,
- WILD_PROTOCOL(ex))) {
- continue;
- }
-
- if (pai->ai_family == PF_UNSPEC)
- pai->ai_family = ex->e_af;
- if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
- pai->ai_socktype = ex->e_socktype;
- if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
- pai->ai_protocol = ex->e_protocol;
-
- error = explore_fqdn(pai, hostname, servname,
- &cur->ai_next);
-
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- }
- }
-
- /* XXX */
- if (sentinel.ai_next)
- error = 0;
-
- if (error)
- goto free;
- if (error == 0) {
- if (sentinel.ai_next) {
- good:
- *res = sentinel.ai_next;
- return SUCCESS;
- } else
- error = EAI_FAIL;
- }
- free:
- bad:
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- *res = NULL;
- return error;
-}
-
-/*
- * FQDN hostname, DNS lookup
- */
-static int
-explore_fqdn(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
- struct hostent *hp;
- int h_error;
- int af;
- char **aplist = NULL, *apbuf = NULL;
- char *ap;
- struct addrinfo sentinel, *cur;
- int i;
-#ifndef USE_GETIPNODEBY
- int naddrs;
-#endif
- const struct afd *afd;
- int error;
-
- *res = NULL;
- sentinel.ai_next = NULL;
- cur = &sentinel;
-
- /*
- * Do not filter unsupported AFs here. We need to honor content of
- * databases (/etc/hosts, DNS and others). Otherwise we cannot
- * replace gethostbyname() by getaddrinfo().
- */
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
-
- /*
- * post-RFC2553: should look at (pai->ai_flags & AI_ADDRCONFIG)
- * rather than hardcoding it. we may need to add AI_ADDRCONFIG
- * handling code by ourselves in case we don't have getipnodebyname().
- */
-#ifdef USE_GETIPNODEBY
- hp = getipnodebyname(hostname, pai->ai_family, AI_ADDRCONFIG, &h_error);
-#else
-#ifdef HAVE_GETHOSTBYNAME2
- hp = gethostbyname2(hostname, pai->ai_family);
-#else
- if (pai->ai_family != AF_INET)
- return 0;
- hp = gethostbyname(hostname);
-#ifdef HAVE_H_ERRNO
- h_error = h_errno;
-#else
- h_error = EINVAL;
-#endif
-#endif /*HAVE_GETHOSTBYNAME2*/
-#endif /*USE_GETIPNODEBY*/
-
- if (hp == NULL) {
- switch (h_error) {
- case HOST_NOT_FOUND:
- case NO_DATA:
- error = EAI_NODATA;
- break;
- case TRY_AGAIN:
- error = EAI_AGAIN;
- break;
- case NO_RECOVERY:
- case NETDB_INTERNAL:
- default:
- error = EAI_FAIL;
- break;
- }
- } else if ((hp->h_name == NULL) || (hp->h_name[0] == 0)
- || (hp->h_addr_list[0] == NULL)) {
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- hp = NULL;
- error = EAI_FAIL;
- }
-
- if (hp == NULL)
- goto free;
-
-#ifdef USE_GETIPNODEBY
- aplist = hp->h_addr_list;
-#else
- /*
- * hp will be overwritten if we use gethostbyname2().
- * always deep copy for simplification.
- */
- for (naddrs = 0; hp->h_addr_list[naddrs] != NULL; naddrs++)
- ;
- naddrs++;
- aplist = (char **)malloc(sizeof(aplist[0]) * naddrs);
- apbuf = (char *)malloc(hp->h_length * naddrs);
- if (aplist == NULL || apbuf == NULL) {
- error = EAI_MEMORY;
- goto free;
- }
- memset(aplist, 0, sizeof(aplist[0]) * naddrs);
- for (i = 0; i < naddrs; i++) {
- if (hp->h_addr_list[i] == NULL) {
- aplist[i] = NULL;
- continue;
- }
- memcpy(&apbuf[i * hp->h_length], hp->h_addr_list[i],
- hp->h_length);
- aplist[i] = &apbuf[i * hp->h_length];
- }
-#endif
-
- for (i = 0; aplist[i] != NULL; i++) {
- af = hp->h_addrtype;
- ap = aplist[i];
-#ifdef AF_INET6
- if (af == AF_INET6
- && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
- af = AF_INET;
- ap = ap + sizeof(struct in6_addr)
- - sizeof(struct in_addr);
- }
-#endif
-
- if (af != pai->ai_family)
- continue;
-
- if ((pai->ai_flags & AI_CANONNAME) == 0) {
- GET_AI(cur->ai_next, afd, ap);
- GET_PORT(cur->ai_next, servname);
- } else {
- /*
- * if AI_CANONNAME and if reverse lookup
- * fail, return ai anyway to pacify
- * calling application.
- *
- * XXX getaddrinfo() is a name->address
- * translation function, and it looks
- * strange that we do addr->name
- * translation here.
- */
- get_name(ap, afd, &cur->ai_next,
- ap, pai, servname);
- }
-
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- }
-
- *res = sentinel.ai_next;
- return 0;
-
-free:
-#ifdef USE_GETIPNODEBY
- if (hp)
- freehostent(hp);
-#endif
- if (aplist)
- free(aplist);
- if (apbuf)
- free(apbuf);
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- return error;
-}
-
-/*
- * hostname == NULL.
- * passive socket -> anyaddr (0.0.0.0 or ::)
- * non-passive socket -> localhost (127.0.0.1 or ::1)
- */
-static int
-explore_null(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
- int s;
- const struct afd *afd;
- struct addrinfo *cur;
- struct addrinfo sentinel;
- int error;
-
- *res = NULL;
- sentinel.ai_next = NULL;
- cur = &sentinel;
-
- /*
- * filter out AFs that are not supported by the kernel
- * XXX errno?
- */
- s = socket(pai->ai_family, SOCK_DGRAM, 0);
- if (s < 0) {
- if (errno != EMFILE)
- return 0;
- } else
- close(s);
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
-
- if (pai->ai_flags & AI_PASSIVE) {
- GET_AI(cur->ai_next, afd, afd->a_addrany);
- /* xxx meaningless?
- * GET_CANONNAME(cur->ai_next, "anyaddr");
- */
- GET_PORT(cur->ai_next, servname);
- } else {
- GET_AI(cur->ai_next, afd, afd->a_loopback);
- /* xxx meaningless?
- * GET_CANONNAME(cur->ai_next, "localhost");
- */
- GET_PORT(cur->ai_next, servname);
- }
- cur = cur->ai_next;
-
- *res = sentinel.ai_next;
- return 0;
-
-free:
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- return error;
-}
-
-/*
- * numeric hostname
- */
-static int
-explore_numeric(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
- const struct afd *afd;
- struct addrinfo *cur;
- struct addrinfo sentinel;
- int error;
- char pton[PTON_MAX];
- int flags;
-
- *res = NULL;
- sentinel.ai_next = NULL;
- cur = &sentinel;
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
- flags = pai->ai_flags;
-
- if (inet_pton(afd->a_af, hostname, pton) == 1) {
- u_int32_t v4a;
-#ifdef INET6
- u_char pfx;
-#endif
-
- switch (afd->a_af) {
- case AF_INET:
- v4a = (u_int32_t)ntohl(((struct in_addr *)pton)->s_addr);
- if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
- flags &= ~AI_CANONNAME;
- v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0 || v4a == IN_LOOPBACKNET)
- flags &= ~AI_CANONNAME;
- break;
-#ifdef INET6
- case AF_INET6:
- pfx = ((struct in6_addr *)pton)->s6_addr[0];
- if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
- flags &= ~AI_CANONNAME;
- break;
-#endif
- }
-
- if (pai->ai_family == afd->a_af ||
- pai->ai_family == PF_UNSPEC /*?*/) {
- if ((flags & AI_CANONNAME) == 0) {
- GET_AI(cur->ai_next, afd, pton);
- GET_PORT(cur->ai_next, servname);
- } else {
- /*
- * if AI_CANONNAME and if reverse lookup
- * fail, return ai anyway to pacify
- * calling application.
- *
- * XXX getaddrinfo() is a name->address
- * translation function, and it looks
- * strange that we do addr->name
- * translation here.
- */
- get_name(pton, afd, &cur->ai_next,
- pton, pai, servname);
- }
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- } else
- ERR(EAI_FAMILY); /*xxx*/
- }
-
- *res = sentinel.ai_next;
- return 0;
-
-free:
-bad:
- if (sentinel.ai_next)
- freeaddrinfo(sentinel.ai_next);
- return error;
-}
-
-/*
- * numeric hostname with scope
- */
-static int
-explore_numeric_scope(pai, hostname, servname, res)
- const struct addrinfo *pai;
- const char *hostname;
- const char *servname;
- struct addrinfo **res;
-{
-#ifndef SCOPE_DELIMITER
- return explore_numeric(pai, hostname, servname, res);
-#else
- const struct afd *afd;
- struct addrinfo *cur;
- int error;
- char *cp, *hostname2 = NULL;
- int scope;
- struct sockaddr_in6 *sin6;
-
- /*
- * if the servname does not match socktype/protocol, ignore it.
- */
- if (get_portmatch(pai, servname) != 0)
- return 0;
-
- afd = find_afd(pai->ai_family);
- if (!afd->a_scoped)
- return explore_numeric(pai, hostname, servname, res);
-
- cp = strchr(hostname, SCOPE_DELIMITER);
- if (cp == NULL)
- return explore_numeric(pai, hostname, servname, res);
-
- /*
- * Handle special case of <scoped_address><delimiter><scope id>
- */
- hostname2 = strdup(hostname);
- if (hostname2 == NULL)
- return EAI_MEMORY;
- /* terminate at the delimiter */
- hostname2[cp - hostname] = '\0';
-
- cp++;
- switch (pai->ai_family) {
-#ifdef INET6
- case AF_INET6:
- scope = if_nametoindex(cp);
- if (scope == 0) {
- free(hostname2);
- return (EAI_NONAME);
- }
- break;
-#endif
- }
-
- error = explore_numeric(pai, hostname2, servname, res);
- if (error == 0) {
- for (cur = *res; cur; cur = cur->ai_next) {
- if (cur->ai_family != AF_INET6)
- continue;
- sin6 = (struct sockaddr_in6 *)cur->ai_addr;
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
- IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr))
- sin6->sin6_scope_id = scope;
- }
- }
-
- free(hostname2);
-
- return error;
-#endif
-}
-
-static int
-get_name(addr, afd, res, numaddr, pai, servname)
- const char *addr;
- const struct afd *afd;
- struct addrinfo **res;
- char *numaddr;
- const struct addrinfo *pai;
- const char *servname;
-{
- struct hostent *hp = NULL;
- struct addrinfo *cur = NULL;
- int error = 0;
- char *ap = NULL, *cn = NULL;
-#ifdef USE_GETIPNODEBY
- int h_error;
-
- hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
-#else
- hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#endif
- if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
-#ifdef USE_GETIPNODEBY
- GET_AI(cur, afd, hp->h_addr_list[0]);
- GET_PORT(cur, servname);
- GET_CANONNAME(cur, hp->h_name);
-#else
- /* hp will be damaged if we use gethostbyaddr() */
- if ((ap = (char *)malloc(hp->h_length)) == NULL) {
- error = EAI_MEMORY;
- goto free;
- }
- memcpy(ap, hp->h_addr_list[0], hp->h_length);
- if ((cn = strdup(hp->h_name)) == NULL) {
- error = EAI_MEMORY;
- goto free;
- }
-
- GET_AI(cur, afd, ap);
- GET_PORT(cur, servname);
- GET_CANONNAME(cur, cn);
- free(ap); ap = NULL;
- free(cn); cn = NULL;
-#endif
- } else {
- GET_AI(cur, afd, numaddr);
- GET_PORT(cur, servname);
- }
-
-#ifdef USE_GETIPNODEBY
- if (hp)
- freehostent(hp);
-#endif
- *res = cur;
- return SUCCESS;
- free:
- if (cur)
- freeaddrinfo(cur);
- if (ap)
- free(ap);
- if (cn)
- free(cn);
-#ifdef USE_GETIPNODEBY
- if (hp)
- freehostent(hp);
-#endif
- *res = NULL;
- return error;
-}
-
-static int
-get_canonname(pai, ai, str)
- const struct addrinfo *pai;
- struct addrinfo *ai;
- const char *str;
-{
- if ((pai->ai_flags & AI_CANONNAME) != 0) {
- ai->ai_canonname = (char *)malloc(strlen(str) + 1);
- if (ai->ai_canonname == NULL)
- return EAI_MEMORY;
- strcpy(ai->ai_canonname, str);
- }
- return 0;
-}
-
-static struct addrinfo *
-get_ai(pai, afd, addr)
- const struct addrinfo *pai;
- const struct afd *afd;
- const char *addr;
-{
- char *p;
- struct addrinfo *ai;
-
- ai = (struct addrinfo *)malloc(sizeof(struct addrinfo)
- + (afd->a_socklen));
- if (ai == NULL)
- return NULL;
-
- memcpy(ai, pai, sizeof(struct addrinfo));
- ai->ai_addr = (struct sockaddr *)(ai + 1);
- memset(ai->ai_addr, 0, afd->a_socklen);
-#ifdef HAVE_SOCKADDR_SA_LEN
- ai->ai_addr->sa_len = afd->a_socklen;
-#endif
- ai->ai_addrlen = afd->a_socklen;
- ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
- p = (char *)(ai->ai_addr);
- memcpy(p + afd->a_off, addr, afd->a_addrlen);
- return ai;
-}
-
-static int
-get_portmatch(ai, servname)
- const struct addrinfo *ai;
- const char *servname;
-{
-
- /* get_port does not touch first argument. when matchonly == 1. */
- return get_port((struct addrinfo *)ai, servname, 1);
-}
-
-static int
-get_port(ai, servname, matchonly)
- struct addrinfo *ai;
- const char *servname;
- int matchonly;
-{
- const char *proto;
- struct servent *sp;
- int port;
- int allownumeric;
-
- if (servname == NULL)
- return 0;
- switch (ai->ai_family) {
- case AF_INET:
-#ifdef AF_INET6
- case AF_INET6:
-#endif
- break;
- default:
- return 0;
- }
-
- switch (ai->ai_socktype) {
- case SOCK_RAW:
- return EAI_SERVICE;
- case SOCK_DGRAM:
- case SOCK_STREAM:
- allownumeric = 1;
- break;
- case ANY:
- allownumeric = 0;
- break;
- default:
- return EAI_SOCKTYPE;
- }
-
- if (str_isnumber(servname)) {
- if (!allownumeric)
- return EAI_SERVICE;
- port = htons(atoi(servname));
- if (port < 0 || port > 65535)
- return EAI_SERVICE;
- } else {
- switch (ai->ai_socktype) {
- case SOCK_DGRAM:
- proto = "udp";
- break;
- case SOCK_STREAM:
- proto = "tcp";
- break;
- default:
- proto = NULL;
- break;
- }
-
- if ((sp = getservbyname(servname, proto)) == NULL)
- return EAI_SERVICE;
- port = sp->s_port;
- }
-
- if (!matchonly) {
- switch (ai->ai_family) {
- case AF_INET:
- ((struct sockaddr_in *)ai->ai_addr)->sin_port = port;
- break;
-#ifdef INET6
- case AF_INET6:
- ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port;
- break;
-#endif
- }
- }
-
- return 0;
-}
-
-static const struct afd *
-find_afd(af)
- int af;
-{
- const struct afd *afd;
-
- if (af == PF_UNSPEC)
- return NULL;
- for (afd = afdl; afd->a_af; afd++) {
- if (afd->a_af == af)
- return afd;
- }
- return NULL;
-}
diff --git a/netdissect.h b/netdissect.h
index cd6f2f137285..e87941daf180 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -21,7 +21,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.23.2.2 2008-04-04 19:42:52 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.27 2008-08-16 11:36:20 hannes Exp $ (LBL)
*/
#ifndef netdissect_h
@@ -84,6 +84,7 @@ typedef struct netdissect_options netdissect_options;
struct netdissect_options {
int ndo_aflag; /* translate network and broadcast addresses */
+ int ndo_bflag; /* print 4 byte ASes in ASDOT notation */
int ndo_eflag; /* print ethernet header */
int ndo_fflag; /* don't translate "foreign" IP address */
int ndo_Kflag; /* don't check TCP checksums */
@@ -122,7 +123,7 @@ struct netdissect_options {
struct sa_list *ndo_sa_list_head; /* used by print-esp.c */
struct sa_list *ndo_sa_default;
- char *ndo_tcpmd5secret; /* TCP-MD5 secret key */
+ char *ndo_sigsecret; /* Signature verification secret key */
struct esp_algorithm *ndo_espsecret_xform; /* cache of decoded */
char *ndo_espsecret_key;
@@ -148,11 +149,23 @@ struct netdissect_options {
void (*ndo_info)(netdissect_options *, int verbose);
int (*ndo_printf)(netdissect_options *,
- const char *fmt, ...);
+ const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
+ __attribute__ ((format (printf, 2, 3)))
+#endif
+ ;
void (*ndo_error)(netdissect_options *,
- const char *fmt, ...);
+ const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
+ __attribute__ ((format (printf, 2, 3)))
+#endif
+ ;
void (*ndo_warning)(netdissect_options *,
- const char *fmt, ...);
+ const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
+ __attribute__ ((format (printf, 2, 3)))
+#endif
+ ;
};
#define PT_VAT 1 /* Visual Audio Tool */
@@ -170,22 +183,21 @@ struct netdissect_options {
#define max(a,b) ((b)>(a)?(b):(a))
#endif
-#ifndef INET6
/*
- * The default snapshot length. This value allows most printers to print
- * useful information while keeping the amount of unwanted data down.
- * In particular, it allows for an ethernet header, tcp/ip header, and
- * 14 bytes of data (assuming no ip options).
+ * Maximum snapshot length. This should be enough to capture the full
+ * packet on most network interfaces.
+ *
+ * XXX - could it be larger? If so, should it? Some applications might
+ * use the snapshot length in a savefile header to control the size of
+ * the buffer they allocate, so a size of, say, 2^31-1 might not work
+ * well.
*/
-#define DEFAULT_SNAPLEN 68
-#else
-#define DEFAULT_SNAPLEN 96
-#endif
+#define MAXIMUM_SNAPLEN 65535
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN 4321
-#define LITTLE_ENDIAN 1234
-#endif
+/*
+ * The default snapshot length is the maximum.
+ */
+#define DEFAULT_SNAPLEN MAXIMUM_SNAPLEN
#define ESRC(ep) ((ep)->ether_shost)
#define EDST(ep) ((ep)->ether_dhost)
@@ -257,6 +269,8 @@ extern int esp_print(netdissect_options *,
register const u_char *bp, int len, register const u_char *bp2,
int *nhdr, int *padlen);
extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
+extern void icmp6_print(netdissect_options *ndo, const u_char *,
+ u_int, const u_char *, int);
extern void isakmp_print(netdissect_options *,const u_char *,
u_int, const u_char *);
extern void isakmp_rfc3948_print(netdissect_options *,const u_char *,
@@ -277,8 +291,8 @@ extern void hex_print_with_offset(netdissect_options *,const char *,
u_int, u_int);
extern void hex_print(netdissect_options *,const char *, u_int);
extern void telnet_print(netdissect_options *,const u_char *, u_int);
-extern int ether_encap_print(netdissect_options *,u_short, const u_char *,
- u_int, u_int, u_short *);
+extern int ethertype_print(netdissect_options *,u_short, const u_char *,
+ u_int, u_int);
extern int llc_print(netdissect_options *,
const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
@@ -345,7 +359,7 @@ extern void ospf_print(netdissect_options *,const u_char *,
u_int, const u_char *);
extern void pimv1_print(netdissect_options *,const u_char *, u_int);
extern void mobile_print(netdissect_options *,const u_char *, u_int);
-extern void pim_print(netdissect_options *,const u_char *, u_int);
+extern void pim_print(netdissect_options *,const u_char *, u_int, u_int);
extern void pppoe_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
extern void pppoe_print(netdissect_options *,const u_char *, u_int);
extern void ppp_print(netdissect_options *,
@@ -416,10 +430,15 @@ extern void stp_print(netdissect_options *,const u_char *p, u_int length);
extern void radius_print(netdissect_options *,const u_char *, u_int);
extern void lwres_print(netdissect_options *,const u_char *, u_int);
extern void pptp_print(netdissect_options *,const u_char *, u_int);
+#endif
+extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
+
+#if 0
#ifdef INET6
extern void ip6_print(netdissect_options *,const u_char *, u_int);
extern void ip6_opt_print(netdissect_options *,const u_char *, int);
+extern int nextproto6_cksum(const struct ip6_hdr *, const u_short *, u_int, u_int);
extern int hbhopt_print(netdissect_options *,const u_char *);
extern int dstopt_print(netdissect_options *,const u_char *);
extern int frag6_print(netdissect_options *,const u_char *,
@@ -441,4 +460,11 @@ extern u_short in_cksum(const u_short *,
#endif
+extern void esp_print_decodesecret(netdissect_options *ndo);
+extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
+ int initiator,
+ u_char spii[8], u_char spir[8],
+ u_char *buf, u_char *end);
+
+
#endif /* netdissect_h */
diff --git a/nfs.h b/nfs.h
index bf6c9838c89c..a5b502582aeb 100644
--- a/nfs.h
+++ b/nfs.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.8.2.1 2007-11-18 03:24:55 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.9 2007-11-18 03:24:38 guy Exp $ (LBL) */
/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */
/*
@@ -215,6 +215,7 @@
#define NFSV3ACCESS_EXTEND 0x08
#define NFSV3ACCESS_DELETE 0x10
#define NFSV3ACCESS_EXECUTE 0x20
+#define NFSV3ACCESS_FULL 0x3f
#define NFSV3WRITE_UNSTABLE 0
#define NFSV3WRITE_DATASYNC 1
diff --git a/nlpid.c b/nlpid.c
index 47ebb5350493..64a359baca69 100755
--- a/nlpid.c
+++ b/nlpid.c
@@ -26,7 +26,7 @@ static const char rcsid[] _U_ =
#include "interface.h"
#include "nlpid.h"
-struct tok nlpid_values[] = {
+const struct tok nlpid_values[] = {
{ NLPID_NULLNS, "NULL" },
{ NLPID_Q933, "Q.933" },
{ NLPID_LMI, "LMI" },
diff --git a/nlpid.h b/nlpid.h
index 31f6b66da6ba..8931835a9940 100644
--- a/nlpid.h
+++ b/nlpid.h
@@ -14,7 +14,7 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-extern struct tok nlpid_values[];
+extern const struct tok nlpid_values[];
#define NLPID_NULLNS 0x00
#define NLPID_Q933 0x08 /* ANSI T1.617 Annex D or ITU-T Q.933 Annex A */
diff --git a/oui.c b/oui.c
index e6569d465405..422cd161b847 100644
--- a/oui.c
+++ b/oui.c
@@ -15,7 +15,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.8.2.1 2008-01-09 09:44:39 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.9 2008-01-09 09:40:47 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -28,7 +28,7 @@ static const char rcsid[] _U_ =
/* FIXME complete OUI list using a script */
-struct tok oui_values[] = {
+const struct tok oui_values[] = {
{ OUI_ENCAP_ETHER, "Ethernet" },
{ OUI_CISCO, "Cisco" },
{ OUI_NORTEL, "Nortel Networks SONMP" },
@@ -55,7 +55,7 @@ struct tok oui_values[] = {
*
* List taken from Ethereal's epan/sminmpec.c.
*/
-struct tok smi_values[] = {
+const struct tok smi_values[] = {
{ SMI_IETF, "IETF (reserved)"},
{ SMI_ACC, "ACC"},
{ SMI_CISCO, "Cisco"},
diff --git a/oui.h b/oui.h
index e70f82ab62ba..dc8bb01c8f1b 100644
--- a/oui.h
+++ b/oui.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.7.2.1 2008-01-09 09:44:39 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.8 2008-01-09 09:40:47 hannes Exp $ (LBL) */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -14,8 +14,8 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-extern struct tok oui_values[];
-extern struct tok smi_values[];
+extern const struct tok oui_values[];
+extern const struct tok smi_values[];
#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
#define OUI_CISCO 0x00000c /* Cisco protocols */
diff --git a/print-802_11.c b/print-802_11.c
index 835d21bd3741..088840ab1384 100644
--- a/print-802_11.c
+++ b/print-802_11.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.47.2.2 2007-12-29 23:25:28 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -47,93 +47,206 @@ static const char rcsid[] _U_ =
#include "ieee802_11_radio.h"
#define PRINT_SSID(p) \
- switch (p.ssid_status) { \
- case TRUNCATED: \
- return 0; \
- case PRESENT: \
+ if (p.ssid_present) { \
printf(" ("); \
fn_print(p.ssid.ssid, NULL); \
printf(")"); \
- break; \
- case NOT_PRESENT: \
- break; \
}
#define PRINT_RATE(_sep, _r, _suf) \
printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)
#define PRINT_RATES(p) \
- switch (p.rates_status) { \
- case TRUNCATED: \
- return 0; \
- case PRESENT: \
- do { \
- int z; \
- const char *sep = " ["; \
- for (z = 0; z < p.rates.length ; z++) { \
- PRINT_RATE(sep, p.rates.rate[z], \
- (p.rates.rate[z] & 0x80 ? "*" : "")); \
- sep = " "; \
- } \
- if (p.rates.length != 0) \
- printf(" Mbit]"); \
- } while (0); \
- break; \
- case NOT_PRESENT: \
- break; \
+ if (p.rates_present) { \
+ int z; \
+ const char *sep = " ["; \
+ for (z = 0; z < p.rates.length ; z++) { \
+ PRINT_RATE(sep, p.rates.rate[z], \
+ (p.rates.rate[z] & 0x80 ? "*" : "")); \
+ sep = " "; \
+ } \
+ if (p.rates.length != 0) \
+ printf(" Mbit]"); \
}
#define PRINT_DS_CHANNEL(p) \
- switch (p.ds_status) { \
- case TRUNCATED: \
- return 0; \
- case PRESENT: \
+ if (p.ds_present) \
printf(" CH: %u", p.ds.channel); \
- break; \
- case NOT_PRESENT: \
- break; \
- } \
printf("%s", \
CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" );
+static const int ieee80211_htrates[16] = {
+ 13, /* IFM_IEEE80211_MCS0 */
+ 26, /* IFM_IEEE80211_MCS1 */
+ 39, /* IFM_IEEE80211_MCS2 */
+ 52, /* IFM_IEEE80211_MCS3 */
+ 78, /* IFM_IEEE80211_MCS4 */
+ 104, /* IFM_IEEE80211_MCS5 */
+ 117, /* IFM_IEEE80211_MCS6 */
+ 130, /* IFM_IEEE80211_MCS7 */
+ 26, /* IFM_IEEE80211_MCS8 */
+ 52, /* IFM_IEEE80211_MCS9 */
+ 78, /* IFM_IEEE80211_MCS10 */
+ 104, /* IFM_IEEE80211_MCS11 */
+ 156, /* IFM_IEEE80211_MCS12 */
+ 208, /* IFM_IEEE80211_MCS13 */
+ 234, /* IFM_IEEE80211_MCS14 */
+ 260, /* IFM_IEEE80211_MCS15 */
+};
+#define PRINT_HT_RATE(_sep, _r, _suf) \
+ printf("%s%.1f%s", _sep, (.5 * ieee80211_htrates[(_r) & 0xf]), _suf)
+
static const char *auth_alg_text[]={"Open System","Shared Key","EAP"};
#define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
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 */
+ "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 */
+ "Association denied due to requesting station not supporting "
+ "short preamble operation", /* 19 */
+ "Association denied due to requesting station not supporting "
+ "PBCC encoding", /* 20 */
+ "Association denied due to requesting station not supporting "
+ "channel agility", /* 21 */
+ "Association request rejected because Spectrum Management "
+ "capability is required", /* 22 */
+ "Association request rejected because the information in the "
+ "Power Capability element is unacceptable", /* 23 */
+ "Association request rejected because the information in the "
+ "Supported Channels element is unacceptable", /* 24 */
+ "Association denied due to requesting station not supporting "
+ "short slot operation", /* 25 */
+ "Association denied due to requesting station not supporting "
+ "DSSS-OFDM operation", /* 26 */
+ "Association denied because the requested STA does not support HT "
+ "features", /* 27 */
+ "Reserved", /* 28 */
+ "Association denied because the requested STA does not support "
+ "the PCO transition time required by the AP", /* 29 */
+ "Reserved", /* 30 */
+ "Reserved", /* 31 */
+ "Unspecified, QoS-related failure", /* 32 */
+ "Association denied due to QAP having insufficient bandwidth "
+ "to handle another QSTA", /* 33 */
+ "Association denied due to excessive frame loss rates and/or "
+ "poor conditions on current operating channel", /* 34 */
+ "Association (with QBSS) denied due to requesting station not "
+ "supporting the QoS facility", /* 35 */
+ "Association denied due to requesting station not supporting "
+ "Block Ack", /* 36 */
+ "The request has been declined", /* 37 */
+ "The request has not been successful as one or more parameters "
+ "have invalid values", /* 38 */
+ "The TS has not been created because the request cannot be honored. "
+ "However, a suggested TSPEC is provided so that the initiating QSTA"
+ "may attempt to set another TS with the suggested changes to the "
+ "TSPEC", /* 39 */
+ "Invalid Information Element", /* 40 */
+ "Group Cipher is not valid", /* 41 */
+ "Pairwise Cipher is not valid", /* 42 */
+ "AKMP is not valid", /* 43 */
+ "Unsupported RSN IE version", /* 44 */
+ "Invalid RSN IE Capabilities", /* 45 */
+ "Cipher suite is rejected per security policy", /* 46 */
+ "The TS has not been created. However, the HC may be capable of "
+ "creating a TS, in response to a request, after the time indicated "
+ "in the TS Delay element", /* 47 */
+ "Direct Link is not allowed in the BSS by policy", /* 48 */
+ "Destination STA is not present within this QBSS.", /* 49 */
+ "The Destination STA is not a QSTA.", /* 50 */
+
};
#define NUM_STATUSES (sizeof status_text / sizeof status_text[0])
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 */
+ "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 received from 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 */
+ "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 */
+ "Disassociated because the information in the Power Capability "
+ "element is unacceptable", /* 10 */
+ "Disassociated because the information in the SupportedChannels "
+ "element is unacceptable", /* 11 */
+ "Invalid Information Element", /* 12 */
+ "Reserved", /* 13 */
+ "Michael MIC failure", /* 14 */
+ "4-Way Handshake timeout", /* 15 */
+ "Group key update timeout", /* 16 */
+ "Information element in 4-Way Handshake different from (Re)Association"
+ "Request/Probe Response/Beacon", /* 17 */
+ "Group Cipher is not valid", /* 18 */
+ "AKMP is not valid", /* 20 */
+ "Unsupported RSN IE version", /* 21 */
+ "Invalid RSN IE Capabilities", /* 22 */
+ "IEEE 802.1X Authentication failed", /* 23 */
+ "Cipher suite is rejected per security policy", /* 24 */
+ "Reserved", /* 25 */
+ "Reserved", /* 26 */
+ "Reserved", /* 27 */
+ "Reserved", /* 28 */
+ "Reserved", /* 29 */
+ "Reserved", /* 30 */
+ "TS deleted because QoS AP lacks sufficient bandwidth for this "
+ "QoS STA due to a change in BSS service characteristics or "
+ "operational mode (e.g. an HT BSS change from 40 MHz channel "
+ "to 20 MHz channel)", /* 31 */
+ "Disassociated for unspecified, QoS-related reason", /* 32 */
+ "Disassociated because QoS AP lacks sufficient bandwidth for this "
+ "QoS STA", /* 33 */
+ "Disassociated because of excessive number of frames that need to be "
+ "acknowledged, but are not acknowledged for AP transmissions "
+ "and/or poor channel conditions", /* 34 */
+ "Disassociated because STA is transmitting outside the limits "
+ "of its TXOPs", /* 35 */
+ "Requested from peer STA as the STA is leaving the BSS "
+ "(or resetting)", /* 36 */
+ "Requested from peer STA as it does not want to use the "
+ "mechanism", /* 37 */
+ "Requested from peer STA as the STA received frames using the "
+ "mechanism for which a set up is required", /* 38 */
+ "Requested from peer STA due to time out", /* 39 */
+ "Reserved", /* 40 */
+ "Reserved", /* 41 */
+ "Reserved", /* 42 */
+ "Reserved", /* 43 */
+ "Reserved", /* 44 */
+ "Peer STA does not support the requested cipher suite", /* 45 */
+ "Association denied due to requesting STA not supporting HT "
+ "features", /* 46 */
};
#define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
@@ -152,141 +265,240 @@ wep_print(const u_char *p)
return 1;
}
-static void
-parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
+static int
+parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
+ u_int length)
{
+ struct ssid_t ssid;
+ struct challenge_t challenge;
+ struct rates_t rates;
+ struct ds_t ds;
+ struct cf_t cf;
+ struct tim_t tim;
+
/*
* We haven't seen any elements yet.
*/
- pbody->challenge_status = NOT_PRESENT;
- pbody->ssid_status = NOT_PRESENT;
- pbody->rates_status = NOT_PRESENT;
- pbody->ds_status = NOT_PRESENT;
- pbody->cf_status = NOT_PRESENT;
- pbody->tim_status = NOT_PRESENT;
-
- for (;;) {
+ pbody->challenge_present = 0;
+ pbody->ssid_present = 0;
+ pbody->rates_present = 0;
+ pbody->ds_present = 0;
+ pbody->cf_present = 0;
+ pbody->tim_present = 0;
+
+ while (length != 0) {
if (!TTEST2(*(p + offset), 1))
- return;
+ return 0;
+ if (length < 1)
+ return 0;
switch (*(p + offset)) {
case E_SSID:
- /* Present, possibly truncated */
- pbody->ssid_status = TRUNCATED;
if (!TTEST2(*(p + offset), 2))
- return;
- memcpy(&pbody->ssid, p + offset, 2);
+ return 0;
+ if (length < 2)
+ return 0;
+ memcpy(&ssid, p + offset, 2);
offset += 2;
- if (pbody->ssid.length != 0) {
- if (pbody->ssid.length >
- sizeof(pbody->ssid.ssid) - 1)
- return;
- if (!TTEST2(*(p + offset), pbody->ssid.length))
- return;
- memcpy(&pbody->ssid.ssid, p + offset,
- pbody->ssid.length);
- offset += pbody->ssid.length;
+ length -= 2;
+ if (ssid.length != 0) {
+ if (ssid.length > sizeof(ssid.ssid) - 1)
+ return 0;
+ if (!TTEST2(*(p + offset), ssid.length))
+ return 0;
+ if (length < ssid.length)
+ return 0;
+ memcpy(&ssid.ssid, p + offset, ssid.length);
+ offset += ssid.length;
+ length -= ssid.length;
+ }
+ ssid.ssid[ssid.length] = '\0';
+ /*
+ * Present and not truncated.
+ *
+ * If we haven't already seen an SSID IE,
+ * copy this one, otherwise ignore this one,
+ * so we later report the first one we saw.
+ */
+ if (!pbody->ssid_present) {
+ pbody->ssid = ssid;
+ pbody->ssid_present = 1;
}
- pbody->ssid.ssid[pbody->ssid.length] = '\0';
- /* Present and not truncated */
- pbody->ssid_status = PRESENT;
break;
case E_CHALLENGE:
- /* Present, possibly truncated */
- pbody->challenge_status = TRUNCATED;
if (!TTEST2(*(p + offset), 2))
- return;
- memcpy(&pbody->challenge, p + offset, 2);
+ return 0;
+ if (length < 2)
+ return 0;
+ memcpy(&challenge, p + offset, 2);
offset += 2;
- if (pbody->challenge.length != 0) {
- if (pbody->challenge.length >
- sizeof(pbody->challenge.text) - 1)
- return;
- if (!TTEST2(*(p + offset), pbody->challenge.length))
- return;
- memcpy(&pbody->challenge.text, p + offset,
- pbody->challenge.length);
- offset += pbody->challenge.length;
+ length -= 2;
+ if (challenge.length != 0) {
+ if (challenge.length >
+ sizeof(challenge.text) - 1)
+ return 0;
+ if (!TTEST2(*(p + offset), challenge.length))
+ return 0;
+ if (length < challenge.length)
+ return 0;
+ memcpy(&challenge.text, p + offset,
+ challenge.length);
+ offset += challenge.length;
+ length -= challenge.length;
+ }
+ challenge.text[challenge.length] = '\0';
+ /*
+ * Present and not truncated.
+ *
+ * If we haven't already seen a challenge IE,
+ * copy this one, otherwise ignore this one,
+ * so we later report the first one we saw.
+ */
+ if (!pbody->challenge_present) {
+ pbody->challenge = challenge;
+ pbody->challenge_present = 1;
}
- pbody->challenge.text[pbody->challenge.length] = '\0';
- /* Present and not truncated */
- pbody->challenge_status = PRESENT;
break;
case E_RATES:
- /* Present, possibly truncated */
- pbody->rates_status = TRUNCATED;
if (!TTEST2(*(p + offset), 2))
- return;
- memcpy(&(pbody->rates), p + offset, 2);
+ return 0;
+ if (length < 2)
+ return 0;
+ memcpy(&rates, p + offset, 2);
offset += 2;
- if (pbody->rates.length != 0) {
- if (pbody->rates.length > sizeof pbody->rates.rate)
- return;
- if (!TTEST2(*(p + offset), pbody->rates.length))
- return;
- memcpy(&pbody->rates.rate, p + offset,
- pbody->rates.length);
- offset += pbody->rates.length;
+ length -= 2;
+ if (rates.length != 0) {
+ if (rates.length > sizeof rates.rate)
+ return 0;
+ if (!TTEST2(*(p + offset), rates.length))
+ return 0;
+ if (length < rates.length)
+ return 0;
+ memcpy(&rates.rate, p + offset, rates.length);
+ offset += rates.length;
+ length -= rates.length;
+ }
+ /*
+ * Present and not truncated.
+ *
+ * If we haven't already seen a rates IE,
+ * copy this one if it's not zero-length,
+ * otherwise ignore this one, so we later
+ * report the first one we saw.
+ *
+ * We ignore zero-length rates IEs as some
+ * devices seem to put a zero-length rates
+ * IE, followed by an SSID IE, followed by
+ * a non-zero-length rates IE into frames,
+ * even though IEEE Std 802.11-2007 doesn't
+ * seem to indicate that a zero-length rates
+ * IE is valid.
+ */
+ if (!pbody->rates_present && rates.length != 0) {
+ pbody->rates = rates;
+ pbody->rates_present = 1;
}
- /* Present and not truncated */
- pbody->rates_status = PRESENT;
break;
case E_DS:
- /* Present, possibly truncated */
- pbody->ds_status = TRUNCATED;
if (!TTEST2(*(p + offset), 3))
- return;
- memcpy(&pbody->ds, p + offset, 3);
+ return 0;
+ if (length < 3)
+ return 0;
+ memcpy(&ds, p + offset, 3);
offset += 3;
- /* Present and not truncated */
- pbody->ds_status = PRESENT;
+ length -= 3;
+ /*
+ * Present and not truncated.
+ *
+ * If we haven't already seen a DS IE,
+ * copy this one, otherwise ignore this one,
+ * so we later report the first one we saw.
+ */
+ if (!pbody->ds_present) {
+ pbody->ds = ds;
+ pbody->ds_present = 1;
+ }
break;
case E_CF:
- /* Present, possibly truncated */
- pbody->cf_status = TRUNCATED;
if (!TTEST2(*(p + offset), 8))
- return;
- memcpy(&pbody->cf, p + offset, 8);
+ return 0;
+ if (length < 8)
+ return 0;
+ memcpy(&cf, p + offset, 8);
offset += 8;
- /* Present and not truncated */
- pbody->cf_status = PRESENT;
+ length -= 8;
+ /*
+ * Present and not truncated.
+ *
+ * If we haven't already seen a CF IE,
+ * copy this one, otherwise ignore this one,
+ * so we later report the first one we saw.
+ */
+ if (!pbody->cf_present) {
+ pbody->cf = cf;
+ pbody->cf_present = 1;
+ }
break;
case E_TIM:
- /* Present, possibly truncated */
- pbody->tim_status = TRUNCATED;
if (!TTEST2(*(p + offset), 2))
- return;
- memcpy(&pbody->tim, p + offset, 2);
+ return 0;
+ if (length < 2)
+ return 0;
+ memcpy(&tim, p + offset, 2);
offset += 2;
+ length -= 2;
if (!TTEST2(*(p + offset), 3))
- return;
- memcpy(&pbody->tim.count, p + offset, 3);
+ return 0;
+ if (length < 3)
+ return 0;
+ memcpy(&tim.count, p + offset, 3);
offset += 3;
+ length -= 3;
- if (pbody->tim.length <= 3)
+ if (tim.length <= 3)
break;
- if (pbody->tim.length - 3 > (int)sizeof pbody->tim.bitmap)
- return;
- if (!TTEST2(*(p + offset), pbody->tim.length - 3))
- return;
- memcpy(pbody->tim.bitmap, p + (pbody->tim.length - 3),
- (pbody->tim.length - 3));
- offset += pbody->tim.length - 3;
- /* Present and not truncated */
- pbody->tim_status = PRESENT;
+ if (tim.length - 3 > (int)sizeof tim.bitmap)
+ return 0;
+ if (!TTEST2(*(p + offset), tim.length - 3))
+ return 0;
+ if (length < (u_int)(tim.length - 3))
+ return 0;
+ memcpy(tim.bitmap, p + (tim.length - 3),
+ (tim.length - 3));
+ offset += tim.length - 3;
+ length -= tim.length - 3;
+ /*
+ * Present and not truncated.
+ *
+ * If we haven't already seen a TIM IE,
+ * copy this one, otherwise ignore this one,
+ * so we later report the first one we saw.
+ */
+ if (!pbody->tim_present) {
+ pbody->tim = tim;
+ pbody->tim_present = 1;
+ }
break;
default:
#if 0
printf("(1) unhandled element_id (%d) ",
- *(p + offset) );
+ *(p + offset));
#endif
if (!TTEST2(*(p + offset), 2))
- return;
+ return 0;
+ if (length < 2)
+ return 0;
if (!TTEST2(*(p + offset + 2), *(p + offset + 1)))
- return;
+ return 0;
+ if (length < (u_int)(*(p + offset + 1) + 2))
+ return 0;
offset += *(p + offset + 1) + 2;
+ length -= *(p + offset + 1) + 2;
break;
}
}
+
+ /* No problems found. */
+ return 1;
}
/*********************************************************************************
@@ -294,24 +506,31 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
*********************************************************************************/
static int
-handle_beacon(const u_char *p)
+handle_beacon(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
+ int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
+ if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+ IEEE802_11_CAPINFO_LEN)
+ return 0;
memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN);
offset += IEEE802_11_TSTAMP_LEN;
+ length -= IEEE802_11_TSTAMP_LEN;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_BCNINT_LEN;
+ length -= IEEE802_11_BCNINT_LEN;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_CAPINFO_LEN;
+ length -= IEEE802_11_CAPINFO_LEN;
- parse_elements(&pbody, p, offset);
+ ret = parse_elements(&pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
@@ -319,50 +538,62 @@ handle_beacon(const u_char *p)
CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS");
PRINT_DS_CHANNEL(pbody);
- return 1;
+ return ret;
}
static int
-handle_assoc_request(const u_char *p)
+handle_assoc_request(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
+ int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
return 0;
+ if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)
+ return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_CAPINFO_LEN;
+ length -= IEEE802_11_CAPINFO_LEN;
pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_LISTENINT_LEN;
+ length -= IEEE802_11_LISTENINT_LEN;
- parse_elements(&pbody, p, offset);
+ ret = parse_elements(&pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
- return 1;
+ return ret;
}
static int
-handle_assoc_response(const u_char *p)
+handle_assoc_response(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
+ int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
IEEE802_11_AID_LEN))
return 0;
+ if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
+ IEEE802_11_AID_LEN)
+ return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_CAPINFO_LEN;
+ length -= IEEE802_11_CAPINFO_LEN;
pbody.status_code = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_STATUS_LEN;
+ length -= IEEE802_11_STATUS_LEN;
pbody.aid = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_AID_LEN;
+ length -= IEEE802_11_AID_LEN;
- parse_elements(&pbody, p, offset);
+ ret = parse_elements(&pbody, p, offset, length);
printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 ,
CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
@@ -370,84 +601,98 @@ handle_assoc_response(const u_char *p)
? status_text[pbody.status_code]
: "n/a"));
- return 1;
+ return ret;
}
static int
-handle_reassoc_request(const u_char *p)
+handle_reassoc_request(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
+ int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
IEEE802_11_AP_LEN))
return 0;
+ if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
+ IEEE802_11_AP_LEN)
+ return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_CAPINFO_LEN;
+ length -= IEEE802_11_CAPINFO_LEN;
pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_LISTENINT_LEN;
+ length -= IEEE802_11_LISTENINT_LEN;
memcpy(&pbody.ap, p+offset, IEEE802_11_AP_LEN);
offset += IEEE802_11_AP_LEN;
+ length -= IEEE802_11_AP_LEN;
- parse_elements(&pbody, p, offset);
+ ret = parse_elements(&pbody, p, offset, length);
PRINT_SSID(pbody);
printf(" AP : %s", etheraddr_string( pbody.ap ));
- return 1;
+ return ret;
}
static int
-handle_reassoc_response(const u_char *p)
+handle_reassoc_response(const u_char *p, u_int length)
{
/* Same as a Association Reponse */
- return handle_assoc_response(p);
+ return handle_assoc_response(p, length);
}
static int
-handle_probe_request(const u_char *p)
+handle_probe_request(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
+ int ret;
memset(&pbody, 0, sizeof(pbody));
- parse_elements(&pbody, p, offset);
+ ret = parse_elements(&pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
- return 1;
+ return ret;
}
static int
-handle_probe_response(const u_char *p)
+handle_probe_response(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
+ int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
-
+ if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+ IEEE802_11_CAPINFO_LEN)
+ return 0;
memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN);
offset += IEEE802_11_TSTAMP_LEN;
+ length -= IEEE802_11_TSTAMP_LEN;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_BCNINT_LEN;
+ length -= IEEE802_11_BCNINT_LEN;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += IEEE802_11_CAPINFO_LEN;
+ length -= IEEE802_11_CAPINFO_LEN;
- parse_elements(&pbody, p, offset);
+ ret = parse_elements(&pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
PRINT_DS_CHANNEL(pbody);
- return 1;
+ return ret;
}
static int
@@ -458,7 +703,7 @@ handle_atim(void)
}
static int
-handle_disassoc(const u_char *p)
+handle_disassoc(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
@@ -466,6 +711,8 @@ handle_disassoc(const u_char *p)
if (!TTEST2(*p, IEEE802_11_REASON_LEN))
return 0;
+ if (length < IEEE802_11_REASON_LEN)
+ return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
printf(": %s",
@@ -477,23 +724,29 @@ handle_disassoc(const u_char *p)
}
static int
-handle_auth(const u_char *p)
+handle_auth(const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
+ int ret;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 6))
return 0;
+ if (length < 6)
+ return 0;
pbody.auth_alg = EXTRACT_LE_16BITS(p);
offset += 2;
+ length -= 2;
pbody.auth_trans_seq_num = EXTRACT_LE_16BITS(p + offset);
offset += 2;
+ length -= 2;
pbody.status_code = EXTRACT_LE_16BITS(p + offset);
offset += 2;
+ length -= 2;
- parse_elements(&pbody, p, offset);
+ ret = parse_elements(&pbody, p, offset, length);
if ((pbody.auth_alg == 1) &&
((pbody.auth_trans_seq_num == 2) ||
@@ -507,7 +760,7 @@ handle_auth(const u_char *p)
? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
: "n/a") : ""));
- return 1;
+ return ret;
}
printf(" (%s)-%x: %s",
(pbody.auth_alg < NUM_AUTH_ALGS)
@@ -520,11 +773,11 @@ handle_auth(const u_char *p)
: "n/a")
: "");
- return 1;
+ return ret;
}
static int
-handle_deauth(const struct mgmt_header_t *pmh, const u_char *p)
+handle_deauth(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -534,8 +787,11 @@ handle_deauth(const struct mgmt_header_t *pmh, const u_char *p)
if (!TTEST2(*p, IEEE802_11_REASON_LEN))
return 0;
+ if (length < IEEE802_11_REASON_LEN)
+ return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_REASON_LEN;
+ length -= IEEE802_11_REASON_LEN;
reason = (pbody.reason_code < NUM_REASONS)
? reason_text[pbody.reason_code]
@@ -549,6 +805,68 @@ handle_deauth(const struct mgmt_header_t *pmh, const u_char *p)
return 1;
}
+#define PRINT_HT_ACTION(v) (\
+ (v) == 0 ? printf("TxChWidth") : \
+ (v) == 1 ? printf("MIMOPwrSave") : \
+ printf("Act#%d", (v)) \
+)
+#define PRINT_BA_ACTION(v) (\
+ (v) == 0 ? printf("ADDBA Request") : \
+ (v) == 1 ? printf("ADDBA Response") : \
+ (v) == 2 ? printf("DELBA") : \
+ printf("Act#%d", (v)) \
+)
+#define PRINT_MESHLINK_ACTION(v) (\
+ (v) == 0 ? printf("Request") : \
+ (v) == 1 ? printf("Report") : \
+ printf("Act#%d", (v)) \
+)
+#define PRINT_MESHPEERING_ACTION(v) (\
+ (v) == 0 ? printf("Open") : \
+ (v) == 1 ? printf("Confirm") : \
+ (v) == 2 ? printf("Close") : \
+ printf("Act#%d", (v)) \
+)
+#define PRINT_MESHPATH_ACTION(v) (\
+ (v) == 0 ? printf("Request") : \
+ (v) == 1 ? printf("Report") : \
+ (v) == 2 ? printf("Error") : \
+ (v) == 3 ? printf("RootAnnouncement") : \
+ printf("Act#%d", (v)) \
+)
+
+static int
+handle_action(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+{
+ if (!TTEST2(*p, 2))
+ return 0;
+ if (length < 2)
+ return 0;
+ if (eflag) {
+ printf(": ");
+ } else {
+ printf(" (%s): ", etheraddr_string(pmh->sa));
+ }
+ switch (p[0]) {
+ case 0: printf("Spectrum Management Act#%d", p[1]); break;
+ case 1: printf("QoS Act#%d", p[1]); break;
+ case 2: printf("DLS Act#%d", p[1]); break;
+ case 3: printf("BA "); PRINT_BA_ACTION(p[1]); break;
+ case 7: printf("HT "); PRINT_HT_ACTION(p[1]); break;
+ case 13: printf("MeshLMetric "); PRINT_MESHLINK_ACTION(p[1]); break;
+ case 15: printf("Interwork Act#%d", p[1]); break;
+ case 16: printf("Resource Act#%d", p[1]); break;
+ case 17: printf("Proxy Act#%d", p[1]); break;
+ case 30: printf("MeshPeering "); PRINT_MESHPEERING_ACTION(p[1]); break;
+ case 32: printf("MeshPath "); PRINT_MESHPATH_ACTION(p[1]); break;
+ case 127: printf("Vendor Act#%d", p[1]); break;
+ default:
+ printf("Reserved(%d) Act#%d", p[0], p[1]);
+ break;
+ }
+ return 1;
+}
+
/*********************************************************************************
* Print Body funcs
@@ -557,36 +875,36 @@ handle_deauth(const struct mgmt_header_t *pmh, const u_char *p)
static int
mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
- const u_char *p)
+ const u_char *p, u_int length)
{
switch (FC_SUBTYPE(fc)) {
case ST_ASSOC_REQUEST:
printf("Assoc Request");
- return handle_assoc_request(p);
+ return handle_assoc_request(p, length);
case ST_ASSOC_RESPONSE:
printf("Assoc Response");
- return handle_assoc_response(p);
+ return handle_assoc_response(p, length);
case ST_REASSOC_REQUEST:
printf("ReAssoc Request");
- return handle_reassoc_request(p);
+ return handle_reassoc_request(p, length);
case ST_REASSOC_RESPONSE:
printf("ReAssoc Response");
- return handle_reassoc_response(p);
+ return handle_reassoc_response(p, length);
case ST_PROBE_REQUEST:
printf("Probe Request");
- return handle_probe_request(p);
+ return handle_probe_request(p, length);
case ST_PROBE_RESPONSE:
printf("Probe Response");
- return handle_probe_response(p);
+ return handle_probe_response(p, length);
case ST_BEACON:
printf("Beacon");
- return handle_beacon(p);
+ return handle_beacon(p, length);
case ST_ATIM:
printf("ATIM");
return handle_atim();
case ST_DISASSOC:
printf("Disassociation");
- return handle_disassoc(p);
+ return handle_disassoc(p, length);
case ST_AUTH:
printf("Authentication");
if (!TTEST2(*p, 3))
@@ -595,10 +913,14 @@ mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
printf("Authentication (Shared-Key)-3 ");
return wep_print(p);
}
- return handle_auth(p);
+ return handle_auth(p, length);
case ST_DEAUTH:
printf("DeAuthentication");
- return handle_deauth(pmh, p);
+ return handle_deauth(pmh, p, length);
+ break;
+ case ST_ACTION:
+ printf("Action");
+ return handle_action(pmh, p, length);
break;
default:
printf("Unhandled Management subtype(%x)",
@@ -616,6 +938,29 @@ static int
ctrl_body_print(u_int16_t fc, const u_char *p)
{
switch (FC_SUBTYPE(fc)) {
+ case CTRL_CONTROL_WRAPPER:
+ printf("Control Wrapper");
+ /* XXX - requires special handling */
+ break;
+ case CTRL_BAR:
+ printf("BAR");
+ if (!TTEST2(*p, CTRL_BAR_HDRLEN))
+ return 0;
+ if (!eflag)
+ printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
+ etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+ break;
+ case CTRL_BA:
+ printf("BA");
+ if (!TTEST2(*p, CTRL_BA_HDRLEN))
+ return 0;
+ if (!eflag)
+ printf(" RA:%s ",
+ etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+ break;
case CTRL_PS_POLL:
printf("Power Save-Poll");
if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN))
@@ -789,6 +1134,17 @@ ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
return;
switch (FC_SUBTYPE(fc)) {
+ case CTRL_BAR:
+ printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
+ etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+ break;
+ case CTRL_BA:
+ printf("RA:%s ",
+ etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+ break;
case CTRL_PS_POLL:
printf("BSSID:%s TA:%s ",
etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
@@ -833,6 +1189,8 @@ extract_header_length(u_int16_t fc)
return MGMT_HDRLEN;
case T_CTRL:
switch (FC_SUBTYPE(fc)) {
+ case CTRL_BAR:
+ return CTRL_BAR_HDRLEN;
case CTRL_PS_POLL:
return CTRL_PS_POLL_HDRLEN;
case CTRL_RTS:
@@ -859,14 +1217,20 @@ extract_header_length(u_int16_t fc)
}
}
+static int
+extract_mesh_header_length(const u_char *p)
+{
+ return (p[0] &~ 3) ? 0 : 6*(1 + (p[0] & 3));
+}
+
/*
* Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
* to point to the source and destination MAC addresses in any case if
* "srcp" and "dstp" aren't null.
*/
-static inline void
-ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
- const u_int8_t **dstp)
+static void
+ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, u_int hdrlen,
+ u_int meshdrlen, const u_int8_t **srcp, const u_int8_t **dstp)
{
if (vflag) {
if (FC_MORE_DATA(fc))
@@ -886,6 +1250,21 @@ ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
EXTRACT_LE_16BITS(
&((const struct mgmt_header_t *)p)->duration));
}
+ if (meshdrlen != 0) {
+ const struct meshcntl_t *mc =
+ (const struct meshcntl_t *)&p[hdrlen - meshdrlen];
+ int ae = mc->flags & 3;
+
+ printf("MeshData (AE %d TTL %u seq %u", ae, mc->ttl,
+ EXTRACT_LE_32BITS(mc->seq));
+ if (ae > 0)
+ printf(" A4:%s", etheraddr_string(mc->addr4));
+ if (ae > 1)
+ printf(" A5:%s", etheraddr_string(mc->addr5));
+ if (ae > 2)
+ printf(" A6:%s", etheraddr_string(mc->addr6));
+ printf(") ");
+ }
switch (FC_TYPE(fc)) {
case T_MGMT:
@@ -911,29 +1290,50 @@ ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
#endif
static u_int
-ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad)
+ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
+ u_int fcslen)
{
u_int16_t fc;
- u_int hdrlen;
+ u_int caplen, hdrlen, meshdrlen;
const u_int8_t *src, *dst;
u_short extracted_ethertype;
- if (caplen < IEEE802_11_FC_LEN) {
+ caplen = orig_caplen;
+ /* Remove FCS, if present */
+ if (length < fcslen) {
printf("[|802.11]");
return caplen;
}
+ length -= fcslen;
+ if (caplen > length) {
+ /* Amount of FCS in actual packet data, if any */
+ fcslen = caplen - length;
+ caplen -= fcslen;
+ snapend -= fcslen;
+ }
+
+ if (caplen < IEEE802_11_FC_LEN) {
+ printf("[|802.11]");
+ return orig_caplen;
+ }
fc = EXTRACT_LE_16BITS(p);
hdrlen = extract_header_length(fc);
if (pad)
hdrlen = roundup2(hdrlen, 4);
+ if (FC_TYPE(fc) == T_DATA && DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
+ meshdrlen = extract_mesh_header_length(p+hdrlen);
+ hdrlen += meshdrlen;
+ } else
+ meshdrlen = 0;
+
if (caplen < hdrlen) {
printf("[|802.11]");
return hdrlen;
}
- ieee_802_11_hdr_print(fc, p, &src, &dst);
+ ieee_802_11_hdr_print(fc, p, hdrlen, meshdrlen, &src, &dst);
/*
* Go past the 802.11 header.
@@ -945,7 +1345,7 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad)
switch (FC_TYPE(fc)) {
case T_MGMT:
if (!mgmt_body_print(fc,
- (const struct mgmt_header_t *)(p - hdrlen), p)) {
+ (const struct mgmt_header_t *)(p - hdrlen), p, length)) {
printf("[|802.11]");
return hdrlen;
}
@@ -972,8 +1372,8 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad)
* handle intelligently
*/
if (!eflag)
- ieee_802_11_hdr_print(fc, p - hdrlen, NULL,
- NULL);
+ ieee_802_11_hdr_print(fc, p - hdrlen, hdrlen,
+ meshdrlen, NULL, NULL);
if (extracted_ethertype)
printf("(LLC %s) ",
etherproto_string(
@@ -999,11 +1399,69 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad)
u_int
ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p)
{
- return ieee802_11_print(p, h->len, h->caplen, 0);
+ return ieee802_11_print(p, h->len, h->caplen, 0, 0);
+}
+
+#define IEEE80211_CHAN_FHSS \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
+#define IEEE80211_CHAN_A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_PUREG \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+
+#define IS_CHAN_FHSS(flags) \
+ ((flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
+#define IS_CHAN_A(flags) \
+ ((flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
+#define IS_CHAN_B(flags) \
+ ((flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
+#define IS_CHAN_PUREG(flags) \
+ ((flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
+#define IS_CHAN_G(flags) \
+ ((flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
+#define IS_CHAN_ANYG(flags) \
+ (IS_CHAN_PUREG(flags) || IS_CHAN_G(flags))
+
+static void
+print_chaninfo(int freq, int flags)
+{
+ printf("%u MHz", freq);
+ if (IS_CHAN_FHSS(flags))
+ printf(" FHSS");
+ if (IS_CHAN_A(flags)) {
+ if (flags & IEEE80211_CHAN_HALF)
+ printf(" 11a/10Mhz");
+ else if (flags & IEEE80211_CHAN_QUARTER)
+ printf(" 11a/5Mhz");
+ else
+ printf(" 11a");
+ }
+ if (IS_CHAN_ANYG(flags)) {
+ if (flags & IEEE80211_CHAN_HALF)
+ printf(" 11g/10Mhz");
+ else if (flags & IEEE80211_CHAN_QUARTER)
+ printf(" 11g/5Mhz");
+ else
+ printf(" 11g");
+ } else if (IS_CHAN_B(flags))
+ printf(" 11b");
+ if (flags & IEEE80211_CHAN_TURBO)
+ printf(" Turbo");
+ if (flags & IEEE80211_CHAN_HT20)
+ printf(" ht/20");
+ else if (flags & IEEE80211_CHAN_HT40D)
+ printf(" ht/40-");
+ else if (flags & IEEE80211_CHAN_HT40U)
+ printf(" ht/40+");
+ printf(" ");
}
static int
-print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad)
+print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
{
union {
int8_t i8;
@@ -1012,14 +1470,13 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad)
u_int16_t u16;
u_int32_t u32;
u_int64_t u64;
- } u, u2;
+ } u, u2, u3, u4;
int rc;
switch (bit) {
case IEEE80211_RADIOTAP_FLAGS:
rc = cpack_uint8(s, &u.u8);
- if (u.u8 & IEEE80211_RADIOTAP_F_DATAPAD)
- *pad = 1;
+ *flags = u.u8;
break;
case IEEE80211_RADIOTAP_RATE:
case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
@@ -1051,12 +1508,24 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad)
case IEEE80211_RADIOTAP_TSFT:
rc = cpack_uint64(s, &u.u64);
break;
+ case IEEE80211_RADIOTAP_XCHANNEL:
+ rc = cpack_uint32(s, &u.u32);
+ if (rc != 0)
+ break;
+ rc = cpack_uint16(s, &u2.u16);
+ if (rc != 0)
+ break;
+ rc = cpack_uint8(s, &u3.u8);
+ if (rc != 0)
+ break;
+ rc = cpack_uint8(s, &u4.u8);
+ break;
default:
/* this bit indicates a field whose
* size we do not know, so we cannot
- * proceed.
+ * proceed. Just print the bit number.
*/
- printf("[0x%08x] ", bit);
+ printf("[bit %u] ", bit);
return -1;
}
@@ -1067,15 +1536,16 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad)
switch (bit) {
case IEEE80211_RADIOTAP_CHANNEL:
- printf("%u MHz ", u.u16);
- if (u2.u16 != 0)
- printf("(0x%04x) ", u2.u16);
+ print_chaninfo(u.u16, u2.u16);
break;
case IEEE80211_RADIOTAP_FHSS:
printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff);
break;
case IEEE80211_RADIOTAP_RATE:
- PRINT_RATE("", u.u8, " Mb/s ");
+ if (u.u8 & 0x80)
+ PRINT_HT_RATE("", u.u8, " Mb/s ");
+ else
+ PRINT_RATE("", u.u8, " Mb/s ");
break;
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
printf("%ddB signal ", u.i8);
@@ -1119,6 +1589,9 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad)
case IEEE80211_RADIOTAP_TSFT:
printf("%" PRIu64 "us tsft ", u.u64);
break;
+ case IEEE80211_RADIOTAP_XCHANNEL:
+ print_chaninfo(u2.u16, u.u32);
+ break;
}
return 0;
}
@@ -1131,7 +1604,7 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
#define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
#define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
#define BITNO_2(x) (((x) & 2) ? 1 : 0)
-#define BIT(n) (1 << n)
+#define BIT(n) (1U << n)
#define IS_EXTENDED(__p) \
(EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0
@@ -1143,7 +1616,9 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
int bit0;
const u_char *iter;
u_int len;
+ u_int8_t flags;
int pad;
+ u_int fcslen;
if (caplen < sizeof(*hdr)) {
printf("[|802.11]");
@@ -1177,8 +1652,12 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
return caplen;
}
+ /* Assume no flags */
+ flags = 0;
/* Assume no Atheros padding between 802.11 header and body */
pad = 0;
+ /* Assume no FCS at end of frame */
+ fcslen = 0;
for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp;
presentp++, bit0 += 32) {
for (present = EXTRACT_LE_32BITS(presentp); present;
@@ -1190,12 +1669,18 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
bit = (enum ieee80211_radiotap_type)
(bit0 + BITNO_32(present ^ next_present));
- if (print_radiotap_field(&cpacker, bit, &pad) != 0)
+ if (print_radiotap_field(&cpacker, bit, &flags) != 0)
goto out;
}
}
+
+ if (flags & IEEE80211_RADIOTAP_F_DATAPAD)
+ pad = 1; /* Atheros padding */
+ if (flags & IEEE80211_RADIOTAP_F_FCS)
+ fcslen = 4; /* FCS at end of packet */
out:
- return len + ieee802_11_print(p + len, length - len, caplen - len, pad);
+ return len + ieee802_11_print(p + len, length - len, caplen - len, pad,
+ fcslen);
#undef BITNO_32
#undef BITNO_16
#undef BITNO_8
@@ -1231,7 +1716,7 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
}
return caphdr_len + ieee802_11_print(p + caphdr_len,
- length - caphdr_len, caplen - caphdr_len, 0);
+ length - caphdr_len, caplen - caphdr_len, 0, 0);
}
#define PRISM_HDR_LEN 144
@@ -1276,7 +1761,7 @@ prism_if_print(const struct pcap_pkthdr *h, const u_char *p)
}
return PRISM_HDR_LEN + ieee802_11_print(p + PRISM_HDR_LEN,
- length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0);
+ length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0, 0);
}
/*
diff --git a/print-ap1394.c b/print-ap1394.c
index dd9bc5a6c25d..cb9d972f43b6 100644
--- a/print-ap1394.c
+++ b/print-ap1394.c
@@ -33,6 +33,7 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -57,18 +58,21 @@ static inline void
ap1394_hdr_print(register const u_char *bp, u_int length)
{
register const struct firewire_header *fp;
+ u_int16_t firewire_type;
+
fp = (const struct firewire_header *)bp;
(void)printf("%s > %s",
linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
+ firewire_type = EXTRACT_16BITS(&fp->firewire_type);
if (!qflag) {
(void)printf(", ethertype %s (0x%04x)",
- tok2str(ethertype_values,"Unknown", ntohs(fp->firewire_type)),
- ntohs(fp->firewire_type));
+ tok2str(ethertype_values,"Unknown", firewire_type),
+ firewire_type);
} else {
- (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ntohs(fp->firewire_type)));
+ (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type));
}
(void)printf(", length %u: ", length);
@@ -87,7 +91,6 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_int caplen = h->caplen;
struct firewire_header *fp;
u_short ether_type;
- u_short extracted_ether_type;
if (caplen < FIREWIRE_HDRLEN) {
printf("[|ap1394]");
@@ -102,11 +105,8 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
fp = (struct firewire_header *)p;
p += FIREWIRE_HDRLEN;
- ether_type = ntohs(fp->firewire_type);
-
- extracted_ether_type = 0;
- if (ether_encap_print(ether_type, p, length, caplen,
- &extracted_ether_type) == 0) {
+ ether_type = EXTRACT_16BITS(&fp->firewire_type);
+ if (ethertype_print(ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
diff --git a/print-arcnet.c b/print-arcnet.c
index 48a43030b4d2..a7b9f0da6bd7 100644
--- a/print-arcnet.c
+++ b/print-arcnet.c
@@ -35,6 +35,7 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include "interface.h"
+#include "extract.h"
#include "arcnet.h"
static int arcnet_encap_print(u_char arctype, const u_char *p,
@@ -151,11 +152,11 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
return (caplen);
}
flag = ap->arc_flag2;
- seqid = ntohs(ap->arc_seqid2);
+ seqid = EXTRACT_16BITS(&ap->arc_seqid2);
archdrlen = ARC_HDRNEWLEN_EXC;
} else {
flag = ap->arc_flag;
- seqid = ntohs(ap->arc_seqid);
+ seqid = EXTRACT_16BITS(&ap->arc_seqid);
archdrlen = ARC_HDRNEWLEN;
}
}
diff --git a/print-atalk.c b/print-atalk.c
index 6ea136116788..e7d6b5fdb1c4 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -213,7 +213,7 @@ aarp_print(register const u_char *bp, u_int length)
case 2: /* response */
(void)printf("reply %s is-at %s",
- AT(pdaddr), etheraddr_string(ap->hdaddr));
+ AT(psaddr), etheraddr_string(ap->hsaddr));
return;
case 3: /* probe (oy!) */
diff --git a/print-atm.c b/print-atm.c
index f50918bfb289..135898bad91a 100644
--- a/print-atm.c
+++ b/print-atm.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.48.2.1 2007-10-22 19:39:12 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.49 2007-10-22 19:37:51 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
diff --git a/print-bfd.c b/print-bfd.c
index 6406168b1b5d..f157684f075e 100644
--- a/print-bfd.c
+++ b/print-bfd.c
@@ -171,13 +171,17 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
{
const struct bfd_header_t *bfd_header;
const struct bfd_auth_header_t *bfd_auth_header;
- u_int8_t version;
+ u_int8_t version = 0;
bfd_header = (const struct bfd_header_t *)pptr;
- TCHECK(*bfd_header);
- version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
-
- switch (port << 8 | version) {
+ if (port == BFD_CONTROL_PORT) {
+ TCHECK(*bfd_header);
+ version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
+ } else if (port == BFD_ECHO_PORT) {
+ /* Echo is BFD v1 only */
+ version = 1;
+ }
+ switch ((port << 8) | version) {
/* BFDv0 */
case (BFD_CONTROL_PORT << 8):
diff --git a/print-bgp.c b/print-bgp.c
index 2dfdf52e0787..d77802dd734b 100644
--- a/print-bgp.c
+++ b/print-bgp.c
@@ -36,7 +36,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.117.2.1 2007-12-08 10:08:07 hannes Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.118 2007-12-07 15:54:52 hannes Exp $";
#endif
#include <tcpdump-stdinc.h>
@@ -346,7 +346,8 @@ static struct tok bgp_pmsi_flag_values[] = {
#define SAFNUM_MULTICAST_VPN 5
#define SAFNUM_TUNNEL 64 /* XXX */
#define SAFNUM_VPLS 65 /* XXX */
-#define SAFNUM_MDT 66 /* XXX */
+/* draft-nalawade-idr-mdt-safi-03 */
+#define SAFNUM_MDT 66
/* Section 4.3.4 of draft-rosen-rfc2547bis-03.txt */
#define SAFNUM_VPNUNICAST 128
#define SAFNUM_VPNMULTICAST 129
@@ -464,6 +465,29 @@ static struct tok bgp_extd_comm_ospf_rtype_values[] = {
{ 0, NULL },
};
+#define TOKBUFSIZE 128
+static char astostr[20];
+
+/*
+ * as_printf
+ *
+ * Convert an AS number into a string and return string pointer.
+ *
+ * Bepending on bflag is set or not, AS number is converted into ASDOT notation
+ * or plain number notation.
+ *
+ */
+static char *
+as_printf (char *str, int size, u_int asnum)
+{
+ if (!bflag || asnum <= 0xFFFF) {
+ snprintf(str, size, "%u", asnum);
+ } else {
+ snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
+ }
+ return str;
+}
+
int
decode_prefix4(const u_char *pptr, char *buf, u_int buflen)
{
@@ -656,9 +680,10 @@ bgp_vpn_rd_print (const u_char *pptr) {
/* 4-byte-AS:number fmt*/
case 2:
- snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (%u.%u.%u.%u:%u)",
- EXTRACT_32BITS(pptr+2), EXTRACT_16BITS(pptr+6),
- *(pptr+2), *(pptr+3), *(pptr+4), *(pptr+5), EXTRACT_16BITS(pptr+6));
+ snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
+ as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)),
+ EXTRACT_16BITS(pptr+6), *(pptr+2), *(pptr+3), *(pptr+4),
+ *(pptr+5), EXTRACT_16BITS(pptr+6));
break;
default:
snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format");
@@ -696,9 +721,9 @@ decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen)
((u_char *)&route_target)[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "origin AS: %u, route target %s",
- EXTRACT_32BITS(pptr+1),
- bgp_vpn_rd_print((u_char *)&route_target));
+ snprintf(buf, buflen, "origin AS: %s, route target %s",
+ as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)),
+ bgp_vpn_rd_print((u_char *)&route_target));
return 5 + (plen + 7) / 8;
@@ -744,6 +769,55 @@ trunc:
return -2;
}
+/*
+ * +-------------------------------+
+ * | |
+ * | RD:IPv4-address (12 octets) |
+ * | |
+ * +-------------------------------+
+ * | MDT Group-address (4 octets) |
+ * +-------------------------------+
+ */
+
+#define MDT_VPN_NLRI_LEN 16
+
+static int
+decode_mdt_vpn_nlri(const u_char *pptr, char *buf, u_int buflen)
+{
+
+ const u_char *rd;
+ const u_char *vpn_ip;
+
+ TCHECK(pptr[0]);
+
+ /* if the NLRI is not predefined length, quit.*/
+ if (*pptr != MDT_VPN_NLRI_LEN * NBBY)
+ return -1;
+ pptr++;
+
+ /* RD */
+ TCHECK2(pptr[0], 8);
+ rd = pptr;
+ pptr+=8;
+
+ /* IPv4 address */
+ TCHECK2(pptr[0], sizeof(struct in_addr));
+ vpn_ip = pptr;
+ pptr+=sizeof(struct in_addr);
+
+ /* MDT Group Address */
+ TCHECK2(pptr[0], sizeof(struct in_addr));
+
+ snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
+ bgp_vpn_rd_print(rd), ipaddr_string(vpn_ip), ipaddr_string(pptr));
+
+ return MDT_VPN_NLRI_LEN + 1;
+
+ trunc:
+
+return -2;
+}
+
#define BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI 1
#define BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI 2
#define BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI 3
@@ -789,9 +863,10 @@ decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen)
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI:
TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %u",
- bgp_vpn_rd_print(pptr),
- EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN));
+ snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
+ bgp_vpn_rd_print(pptr),
+ as_printf(astostr, sizeof(astostr),
+ EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
@@ -824,9 +899,10 @@ decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen)
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN:
TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
- snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %u",
- bgp_vpn_rd_print(pptr),
- EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN));
+ snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
+ bgp_vpn_rd_print(pptr),
+ as_printf(astostr, sizeof(astostr),
+ EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
pptr += BGP_VPN_RD_LEN;
bgp_vpn_sg_print(pptr, buf, buflen);
@@ -1222,9 +1298,11 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
tokbuf, sizeof(tokbuf)));
for (i = 0; i < tptr[1] * as_size; i += as_size) {
TCHECK2(tptr[2 + i], as_size);
- printf("%u ",
- as_size == 2 ? EXTRACT_16BITS(&tptr[2 + i]) :
- EXTRACT_32BITS(&tptr[2 + i]));
+ printf("%s ",
+ as_printf(astostr, sizeof(astostr),
+ as_size == 2 ?
+ EXTRACT_16BITS(&tptr[2 + i]) :
+ EXTRACT_32BITS(&tptr[2 + i])));
}
TCHECK(tptr[0]);
printf("%s", tok2strbuf(bgp_as_path_segment_close_values,
@@ -1255,23 +1333,36 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
if (len != 0)
printf("invalid len");
break;
- case BGPTYPE_AGGREGATOR:
- if (len != 6) {
- printf("invalid len");
- break;
- }
- TCHECK2(tptr[0], 6);
- printf(" AS #%u, origin %s", EXTRACT_16BITS(tptr),
+ case BGPTYPE_AGGREGATOR:
+
+ /*
+ * Depending on the AS encoded is of 2 bytes or of 4 bytes,
+ * the length of this PA can be either 6 bytes or 8 bytes.
+ */
+ if (len != 6 && len != 8) {
+ printf("invalid len");
+ break;
+ }
+ TCHECK2(tptr[0], len);
+ if (len == 6) {
+ printf(" AS #%s, origin %s",
+ as_printf(astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
getname(tptr + 2));
- break;
+ } else {
+ printf(" AS #%s, origin %s",
+ as_printf(astostr, sizeof(astostr),
+ EXTRACT_32BITS(tptr)), getname(tptr + 4));
+ }
+ break;
case BGPTYPE_AGGREGATOR4:
if (len != 8) {
printf("invalid len");
break;
}
TCHECK2(tptr[0], 8);
- printf(" AS #%u, origin %s", EXTRACT_32BITS(tptr),
- getname(tptr + 4));
+ printf(" AS #%s, origin %s",
+ as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
+ getname(tptr + 4));
break;
case BGPTYPE_COMMUNITIES:
if (len % 4) {
@@ -1349,6 +1440,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
@@ -1395,7 +1487,8 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
- if (tlen < (int)sizeof(struct in_addr)) {
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
+ if (tlen < (int)sizeof(struct in_addr)) {
printf("invalid len");
tlen = 0;
} else {
@@ -1579,6 +1672,16 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
else
printf("\n\t %s", buf);
break;
+
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
+ advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+ if (advance == -1)
+ printf("\n\t (illegal prefix length)");
+ else if (advance == -2)
+ goto trunc;
+ else
+ printf("\n\t %s", buf);
+ break;
#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
@@ -1781,6 +1884,15 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
else
printf("\n\t %s", buf);
break;
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
+ advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+ if (advance == -1)
+ printf("\n\t (illegal prefix length)");
+ else if (advance == -2)
+ goto trunc;
+ else
+ printf("\n\t %s", buf);
+ break;
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN):
advance = decode_multicast_vpn(tptr, buf, sizeof(buf));
@@ -1841,10 +1953,10 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
break;
case BGP_EXT_COM_RT_2:
case BGP_EXT_COM_RO_2:
- printf(": %u:%u",
- EXTRACT_32BITS(tptr+2),
- EXTRACT_16BITS(tptr+6));
- break;
+ printf(": %s:%u",
+ as_printf(astostr, sizeof(astostr),
+ EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6));
+ break;
case BGP_EXT_COM_LINKBAND:
bw.i = EXTRACT_32BITS(tptr+2);
printf(": bandwidth: %.3f Mbps",
@@ -1951,8 +2063,9 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
}
case BGPTYPE_ATTR_SET:
TCHECK2(tptr[0], 4);
- printf("\n\t Origin AS: %u", EXTRACT_32BITS(tptr));
- tptr+=4;
+ printf("\n\t Origin AS: %s",
+ as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)));
+ tptr+=4;
len -=4;
while (len >= 2 ) {
@@ -2022,7 +2135,8 @@ bgp_open_print(const u_char *dat, int length)
memcpy(&bgpo, dat, BGP_OPEN_SIZE);
printf("\n\t Version %d, ", bgpo.bgpo_version);
- printf("my AS %u, ", ntohs(bgpo.bgpo_myas));
+ printf("my AS %s, ",
+ as_printf(astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas)));
printf("Holdtime %us, ", ntohs(bgpo.bgpo_holdtime));
printf("ID %s", getname((u_char *)&bgpo.bgpo_id));
printf("\n\t Optional parameters, length: %u", bgpo.bgpo_optlen);
@@ -2098,6 +2212,18 @@ bgp_open_print(const u_char *dat, int length)
case BGP_CAPCODE_RR:
case BGP_CAPCODE_RR_CISCO:
break;
+ case BGP_CAPCODE_AS_NEW:
+
+ /*
+ * Extract the 4 byte AS number encoded.
+ */
+ TCHECK2(opt[i + BGP_OPT_SIZE + 2], cap_len);
+ if (cap_len == 4) {
+ printf("\n\t\t 4 Byte AS %s",
+ as_printf(astostr, sizeof(astostr),
+ EXTRACT_32BITS(opt + i + BGP_OPT_SIZE + 2)));
+ }
+ break;
default:
TCHECK2(opt[i+BGP_OPT_SIZE+2],cap_len);
printf("\n\t\tno decoder for Capability %u",
diff --git a/print-bootp.c b/print-bootp.c
index b442c18388a7..c7538ff87140 100644
--- a/print-bootp.c
+++ b/print-bootp.c
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.88 2007-09-20 15:04:45 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.89 2008-04-22 09:45:08 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -585,8 +585,6 @@ rfc1048_print(register const u_char *bp)
if (len < 1) {
printf("ERROR: option %u len %u < 1 bytes",
TAG_NETBIOS_NODE, len);
- bp += len;
- len = 0;
break;
}
tag = *bp++;
@@ -599,8 +597,6 @@ rfc1048_print(register const u_char *bp)
if (len < 1) {
printf("ERROR: option %u len %u < 1 bytes",
TAG_OPT_OVERLOAD, len);
- bp += len;
- len = 0;
break;
}
tag = *bp++;
@@ -640,8 +636,6 @@ rfc1048_print(register const u_char *bp)
if (len < 1) {
printf("ERROR: option %u len %u < 1 bytes",
TAG_CLIENT_ID, len);
- bp += len;
- len = 0;
break;
}
type = *bp++;
diff --git a/print-bt.c b/print-bt.c
index 498440cde333..259f3e5d9c76 100644
--- a/print-bt.c
+++ b/print-bt.c
@@ -19,7 +19,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c,v 1.1.2.1 2008-09-25 21:50:04 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,6 +33,7 @@ static const char rcsid[] _U_ =
#include <string.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
@@ -60,7 +61,7 @@ bt_if_print(const struct pcap_pkthdr *h, const u_char *p)
length -= BT_HDRLEN;
p += BT_HDRLEN;
if (eflag)
- (void)printf("hci length %d, direction %s, ", length, (ntohl(hdr->direction)&0x1)?"in":"out");
+ (void)printf("hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out");
if (!suppress_default_print)
default_print(p, caplen);
diff --git a/print-cdp.c b/print-cdp.c
index f8f4427c046b..bef7f5eacadd 100644
--- a/print-cdp.c
+++ b/print-cdp.c
@@ -130,16 +130,19 @@ cdp_print(const u_char *pptr, u_int length, u_int caplen)
case 0x01: /* Device-ID */
if (!vflag)
- printf(", Device-ID '%.*s'", len, tptr);
- else
- printf("'%.*s'", len, tptr);
+ printf(", Device-ID ");
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x02: /* Address */
if (cdp_print_addr(tptr, len) < 0)
goto trunc;
break;
case 0x03: /* Port-ID */
- printf("'%.*s'", len, tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x04: /* Capabilities */
printf("(0x%08x): %s",
@@ -156,7 +159,9 @@ cdp_print(const u_char *pptr, u_int length, u_int caplen)
}
break;
case 0x06: /* Platform */
- printf("'%.*s'", len, tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x07: /* Prefixes */
if (cdp_print_prefixes(tptr, len) < 0)
@@ -165,7 +170,9 @@ cdp_print(const u_char *pptr, u_int length, u_int caplen)
case 0x08: /* Protocol Hello Option - not documented */
break;
case 0x09: /* VTP Mgmt Domain - not documented */
- printf("'%.*s'", len,tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x0a: /* Native VLAN ID - not documented */
printf("%d",EXTRACT_16BITS(tptr));
@@ -195,14 +202,20 @@ cdp_print(const u_char *pptr, u_int length, u_int caplen)
printf("0x%02x", *(tptr));
break;
case 0x14: /* System Name - not documented */
- printf("'%.*s'", len, tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x16: /* System Object ID - not documented */
if (cdp_print_addr(tptr, len) < 0)
goto trunc;
break;
case 0x17: /* Physical Location - not documented */
- printf("0x%02x/%.*s", *(tptr), len - 1, tptr + 1 );
+ printf("0x%02x", *(tptr));
+ if (len > 1) {
+ printf("/");
+ fn_printn(tptr + 1, len - 1, NULL);
+ }
break;
default:
print_unknown_data(tptr,"\n\t ",len);
diff --git a/print-cfm.c b/print-cfm.c
index bd98dd26d26c..fb0476f5584c 100644
--- a/print-cfm.c
+++ b/print-cfm.c
@@ -423,6 +423,8 @@ cfm_print(register const u_char *pptr, register u_int length) {
break;
case CFM_OPCODE_LTM:
+ msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr;
+
printf(", Flags [%s]",
bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags));
@@ -437,6 +439,8 @@ cfm_print(register const u_char *pptr, register u_int length) {
break;
case CFM_OPCODE_LTR:
+ msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr;
+
printf(", Flags [%s]",
bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags));
diff --git a/print-dccp.c b/print-dccp.c
index b7377cf91540..fee4a6e50574 100644
--- a/print-dccp.c
+++ b/print-dccp.c
@@ -9,7 +9,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.7.2.1 2007-11-09 00:45:16 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -394,9 +394,6 @@ trunc2:
static int dccp_print_option(const u_char *option)
{
u_int8_t optlen, i;
- u_int32_t *ts;
- u_int16_t *var16;
- u_int32_t *var32;
TCHECK(*option);
@@ -470,22 +467,17 @@ static int dccp_print_option(const u_char *option)
for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
break;
case 41:
- ts = (u_int32_t *)(option + 2);
- printf("timestamp %u", (u_int32_t)ntohl(*ts));
+ printf("timestamp %u", EXTRACT_32BITS(option + 2));
break;
case 42:
- ts = (u_int32_t *)(option + 2);
- printf("timestamp_echo %u", (u_int32_t)ntohl(*ts));
+ printf("timestamp_echo %u", EXTRACT_32BITS(option + 2));
break;
case 43:
printf("elapsed_time ");
- if (optlen == 6){
- ts = (u_int32_t *)(option + 2);
- printf("%u", (u_int32_t)ntohl(*ts));
- } else {
- var16 = (u_int16_t *)(option + 2);
- printf("%u", ntohs(*var16));
- }
+ if (optlen == 6)
+ printf("%u", EXTRACT_32BITS(option + 2));
+ else
+ printf("%u", EXTRACT_16BITS(option + 2));
break;
case 44:
printf("data_checksum ");
@@ -496,12 +488,10 @@ static int dccp_print_option(const u_char *option)
printf("CCID option %d",*option);
switch (optlen) {
case 4:
- var16 = (u_int16_t *)(option + 2);
- printf(" %u",ntohs(*var16));
+ printf(" %u", EXTRACT_16BITS(option + 2));
break;
case 6:
- var32 = (u_int32_t *)(option + 2);
- printf(" %u",(u_int32_t)ntohl(*var32));
+ printf(" %u", EXTRACT_32BITS(option + 2));
break;
default:
break;
diff --git a/print-dhcp6.c b/print-dhcp6.c
index ec0df763c0cf..26855ccbfb18 100644
--- a/print-dhcp6.c
+++ b/print-dhcp6.c
@@ -40,7 +40,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.36.2.1 2008-02-06 10:26:27 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -177,54 +177,19 @@ struct dhcp6opt {
/* type-dependent data follows */
};
-struct dhcp6_ia {
- u_int16_t dh6opt_ia_type;
- u_int16_t dh6opt_ia_len;
- u_int32_t dh6opt_ia_iaid;
- u_int32_t dh6opt_ia_t1;
- u_int32_t dh6opt_ia_t2;
-};
-
-struct dhcp6_ia_addr {
- u_int16_t dh6opt_ia_addr_type;
- u_int16_t dh6opt_ia_addr_len;
- struct in6_addr dh6opt_ia_addr_addr;
- u_int32_t dh6opt_ia_addr_pltime;
- u_int32_t dh6opt_ia_addr_vltime;
-} __attribute__ ((__packed__));
-
-struct dhcp6_ia_prefix {
- u_int16_t dh6opt_ia_prefix_type;
- u_int16_t dh6opt_ia_prefix_len;
- u_int32_t dh6opt_ia_prefix_pltime;
- u_int32_t dh6opt_ia_prefix_vltime;
- u_int8_t dh6opt_ia_prefix_plen;
- struct in6_addr dh6opt_ia_prefix_addr;
-} __attribute__ ((__packed__));
-
-struct dhcp6_auth {
- u_int16_t dh6opt_auth_type;
- u_int16_t dh6opt_auth_len;
- u_int8_t dh6opt_auth_proto;
- u_int8_t dh6opt_auth_alg;
- u_int8_t dh6opt_auth_rdm;
- u_int8_t dh6opt_auth_rdinfo[8];
- /* authentication information follows */
-} __attribute__ ((__packed__));
-
static const char *
dhcp6opt_name(int type)
{
static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
if (type > 65535)
- return "INVALID option";
+ return "INVALID-option";
switch(type) {
case DH6OPT_CLIENTID:
- return "client ID";
+ return "client-ID";
case DH6OPT_SERVERID:
- return "server ID";
+ return "server-ID";
case DH6OPT_IA_NA:
return "IA_NA";
case DH6OPT_IA_TA:
@@ -232,87 +197,87 @@ dhcp6opt_name(int type)
case DH6OPT_IA_ADDR:
return "IA_ADDR";
case DH6OPT_ORO:
- return "option request";
+ return "option-request";
case DH6OPT_PREFERENCE:
return "preference";
case DH6OPT_ELAPSED_TIME:
- return "elapsed time";
+ return "elapsed-time";
case DH6OPT_RELAY_MSG:
- return "relay message";
+ return "relay-message";
case DH6OPT_AUTH:
return "authentication";
case DH6OPT_UNICAST:
- return "server unicast";
+ return "server-unicast";
case DH6OPT_STATUS_CODE:
- return "status code";
+ return "status-code";
case DH6OPT_RAPID_COMMIT:
- return "rapid commit";
+ return "rapid-commit";
case DH6OPT_USER_CLASS:
- return "user class";
+ return "user-class";
case DH6OPT_VENDOR_CLASS:
- return "vendor class";
+ return "vendor-class";
case DH6OPT_VENDOR_OPTS:
- return "vendor-specific info";
+ return "vendor-specific-info";
case DH6OPT_INTERFACE_ID:
- return "interface ID";
+ return "interface-ID";
case DH6OPT_RECONF_MSG:
- return "reconfigure message";
+ return "reconfigure-message";
case DH6OPT_RECONF_ACCEPT:
- return "reconfigure accept";
+ return "reconfigure-accept";
case DH6OPT_SIP_SERVER_D:
- return "SIP servers domain";
+ return "SIP-servers-domain";
case DH6OPT_SIP_SERVER_A:
- return "SIP servers address";
+ return "SIP-servers-address";
case DH6OPT_DNS:
return "DNS";
case DH6OPT_DNSNAME:
- return "DNS name";
+ return "DNS-name";
case DH6OPT_IA_PD:
return "IA_PD";
case DH6OPT_IA_PD_PREFIX:
- return "IA_PD prefix";
+ return "IA_PD-prefix";
case DH6OPT_NTP_SERVERS:
- return "NTP Server";
+ return "NTP-Server";
case DH6OPT_LIFETIME:
return "lifetime";
case DH6OPT_NIS_SERVERS:
- return "NIS server";
+ return "NIS-server";
case DH6OPT_NISP_SERVERS:
- return "NIS+ server";
+ return "NIS+-server";
case DH6OPT_NIS_NAME:
- return "NIS domain name";
+ return "NIS-domain-name";
case DH6OPT_NISP_NAME:
- return "NIS+ domain name";
+ return "NIS+-domain-name";
case DH6OPT_BCMCS_SERVER_D:
- return "BCMCS domain name";
+ return "BCMCS-domain-name";
case DH6OPT_BCMCS_SERVER_A:
- return "BCMCS server";
+ return "BCMCS-server";
case DH6OPT_GEOCONF_CIVIC:
- return "Geoconf Civic";
+ return "Geoconf-Civic";
case DH6OPT_REMOTE_ID:
- return "Remote ID";
+ return "Remote-ID";
case DH6OPT_SUBSCRIBER_ID:
- return "Subscriber ID";
+ return "Subscriber-ID";
case DH6OPT_CLIENT_FQDN:
- return "Client FQDN";
+ return "Client-FQDN";
case DH6OPT_PANA_AGENT:
- return "PANA agent";
+ return "PANA-agent";
case DH6OPT_NEW_POSIX_TIMEZONE:
- return "POSIX timezone";
+ return "POSIX-timezone";
case DH6OPT_NEW_TZDB_TIMEZONE:
- return "POSIX tz database";
+ return "POSIX-tz-database";
case DH6OPT_ERO:
- return "Echo request option";
+ return "Echo-request-option";
case DH6OPT_LQ_QUERY:
- return "Lease query";
+ return "Lease-query";
case DH6OPT_CLIENT_DATA:
- return "LQ client data";
+ return "LQ-client-data";
case DH6OPT_CLT_TIME:
- return "Clt time";
+ return "Clt-time";
case DH6OPT_LQ_RELAY_DATA:
- return "LQ relay data";
+ return "LQ-relay-data";
case DH6OPT_LQ_CLIENT_LINK:
- return "LQ client link";
+ return "LQ-client-link";
default:
snprintf(genstr, sizeof(genstr), "opt_%d", type);
return(genstr);
@@ -364,12 +329,7 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
size_t i;
u_int16_t opttype;
size_t optlen;
- u_int16_t val16;
- u_int32_t val32;
- struct dhcp6_ia ia;
- struct dhcp6_ia_prefix ia_prefix;
- struct dhcp6_ia_addr ia_addr;
- struct dhcp6_auth authopt;
+ u_int8_t auth_proto;
u_int authinfolen, authrealmlen;
if (cp == ep)
@@ -438,25 +398,19 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
}
break;
case DH6OPT_IA_ADDR:
- if (optlen < sizeof(ia_addr) - 4) {
+ if (optlen < 24) {
+ /*(*/
printf(" ?)");
break;
}
- memcpy(&ia_addr, (u_char *)dh6o, sizeof(ia_addr));
- printf(" %s",
- ip6addr_string(&ia_addr.dh6opt_ia_addr_addr));
- ia_addr.dh6opt_ia_addr_pltime =
- ntohl(ia_addr.dh6opt_ia_addr_pltime);
- ia_addr.dh6opt_ia_addr_vltime =
- ntohl(ia_addr.dh6opt_ia_addr_vltime);
- printf(" pltime:%lu vltime:%lu",
- (unsigned long)ia_addr.dh6opt_ia_addr_pltime,
- (unsigned long)ia_addr.dh6opt_ia_addr_vltime);
- if (optlen > sizeof(ia_addr) - 4) {
+ tp = (u_char *)(dh6o + 1);
+ printf(" %s", ip6addr_string(&tp[0]));
+ printf(" pltime:%u vltime:%u",
+ EXTRACT_32BITS(&tp[16]),
+ EXTRACT_32BITS(&tp[20]));
+ if (optlen > 24) {
/* there are sub-options */
- dhcp6opt_print((u_char *)dh6o +
- sizeof(ia_addr),
- (u_char *)(dh6o + 1) + optlen);
+ dhcp6opt_print(tp + 24, tp + 24 + optlen);
}
printf(")");
break;
@@ -468,10 +422,8 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
}
tp = (u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 2) {
- u_int16_t opt;
-
- memcpy(&opt, &tp[i], sizeof(opt));
- printf(" %s", dhcp6opt_name(ntohs(opt)));
+ printf(" %s",
+ dhcp6opt_name(EXTRACT_16BITS(&tp[i])));
}
printf(")");
break;
@@ -480,29 +432,31 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
printf(" ?)");
break;
}
- printf(" %d)", *((u_char *)(dh6o + 1) + 1));
+ tp = (u_char *)(dh6o + 1);
+ printf(" %d)", *tp);
break;
case DH6OPT_ELAPSED_TIME:
if (optlen != 2) {
printf(" ?)");
break;
}
- memcpy(&val16, dh6o + 1, sizeof(val16));
- val16 = ntohs(val16);
- printf(" %d)", (int)val16);
+ tp = (u_char *)(dh6o + 1);
+ printf(" %d)", EXTRACT_16BITS(tp));
break;
case DH6OPT_RELAY_MSG:
printf(" (");
- dhcp6_print((const u_char *)(dh6o + 1), optlen);
+ tp = (u_char *)(dh6o + 1);
+ dhcp6_print(tp, optlen);
printf(")");
break;
case DH6OPT_AUTH:
- if (optlen < sizeof(authopt) - sizeof(*dh6o)) {
+ if (optlen < 11) {
printf(" ?)");
break;
}
- memcpy(&authopt, dh6o, sizeof(authopt));
- switch (authopt.dh6opt_auth_proto) {
+ tp = (u_char *)(dh6o + 1);
+ auth_proto = *tp;
+ switch (auth_proto) {
case DH6OPT_AUTHPROTO_DELAYED:
printf(" proto: delayed");
break;
@@ -510,37 +464,36 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
printf(" proto: reconfigure");
break;
default:
- printf(" proto: %d",
- authopt.dh6opt_auth_proto);
+ printf(" proto: %d", auth_proto);
break;
}
- switch (authopt.dh6opt_auth_alg) {
+ tp++;
+ switch (*tp) {
case DH6OPT_AUTHALG_HMACMD5:
/* XXX: may depend on the protocol */
printf(", alg: HMAC-MD5");
break;
default:
- printf(", alg: %d", authopt.dh6opt_auth_alg);
+ printf(", alg: %d", *tp);
break;
}
- switch (authopt.dh6opt_auth_rdm) {
+ tp++;
+ switch (*tp) {
case DH6OPT_AUTHRDM_MONOCOUNTER:
printf(", RDM: mono");
break;
default:
- printf(", RDM: %d", authopt.dh6opt_auth_rdm);
+ printf(", RDM: %d", *tp);
break;
}
- tp = (u_char *)&authopt.dh6opt_auth_rdinfo;
+ tp++;
printf(", RD:");
- for (i = 0; i < 4; i++, tp += sizeof(val16))
+ for (i = 0; i < 4; i++, tp += 2)
printf(" %04x", EXTRACT_16BITS(tp));
/* protocol dependent part */
- tp = (u_char *)dh6o + sizeof(authopt);
- authinfolen =
- optlen + sizeof(*dh6o) - sizeof(authopt);
- switch (authopt.dh6opt_auth_proto) {
+ authinfolen = optlen - 11;
+ switch (auth_proto) {
case DH6OPT_AUTHPROTO_DELAYED:
if (authinfolen == 0)
break;
@@ -596,9 +549,10 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
* Since we cannot predict the encoding, print hex dump
* at most 10 characters.
*/
+ tp = (u_char *)(dh6o + 1);
printf(" ");
for (i = 0; i < optlen && i < 10; i++)
- printf("%02x", ((u_char *)(dh6o + 1))[i]);
+ printf("%02x", tp[i]);
printf("...)");
break;
case DH6OPT_RECONF_MSG:
@@ -640,28 +594,23 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
printf(" ?)");
break;
}
- memcpy(&val16, (u_char *)(dh6o + 1), sizeof(val16));
- val16 = ntohs(val16);
- printf(" %s)", dhcp6stcode(val16));
+ tp = (u_char *)(dh6o + 1);
+ printf(" %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0])));
break;
case DH6OPT_IA_NA:
case DH6OPT_IA_PD:
- if (optlen < sizeof(ia) - 4) {
+ if (optlen < 12) {
printf(" ?)");
break;
}
- memcpy(&ia, (u_char *)dh6o, sizeof(ia));
- ia.dh6opt_ia_iaid = ntohl(ia.dh6opt_ia_iaid);
- ia.dh6opt_ia_t1 = ntohl(ia.dh6opt_ia_t1);
- ia.dh6opt_ia_t2 = ntohl(ia.dh6opt_ia_t2);
- printf(" IAID:%lu T1:%lu T2:%lu",
- (unsigned long)ia.dh6opt_ia_iaid,
- (unsigned long)ia.dh6opt_ia_t1,
- (unsigned long)ia.dh6opt_ia_t2);
- if (optlen > sizeof(ia) - 4) {
+ tp = (u_char *)(dh6o + 1);
+ printf(" IAID:%u T1:%u T2:%u",
+ EXTRACT_32BITS(&tp[0]),
+ EXTRACT_32BITS(&tp[4]),
+ EXTRACT_32BITS(&tp[8]));
+ if (optlen > 12) {
/* there are sub-options */
- dhcp6opt_print((u_char *)dh6o + sizeof(ia),
- (u_char *)(dh6o + 1) + optlen);
+ dhcp6opt_print(tp + 12, tp + 12 + optlen);
}
printf(")");
break;
@@ -670,37 +619,27 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
printf(" ?)");
break;
}
- memcpy(&val32, dh6o + 1, sizeof(val32));
- val32 = ntohl(val32);
- printf(" IAID:%lu", (unsigned long)val32);
+ tp = (u_char *)(dh6o + 1);
+ printf(" IAID:%u", EXTRACT_32BITS(tp));
if (optlen > 4) {
/* there are sub-options */
- dhcp6opt_print((u_char *)(dh6o + 1) + 4,
- (u_char *)(dh6o + 1) + optlen);
+ dhcp6opt_print(tp + 4, tp + 4 + optlen);
}
printf(")");
break;
case DH6OPT_IA_PD_PREFIX:
- if (optlen < sizeof(ia_prefix) - 4) {
+ if (optlen < 25) {
printf(" ?)");
break;
}
- memcpy(&ia_prefix, (u_char *)dh6o, sizeof(ia_prefix));
- printf(" %s/%d",
- ip6addr_string(&ia_prefix.dh6opt_ia_prefix_addr),
- ia_prefix.dh6opt_ia_prefix_plen);
- ia_prefix.dh6opt_ia_prefix_pltime =
- ntohl(ia_prefix.dh6opt_ia_prefix_pltime);
- ia_prefix.dh6opt_ia_prefix_vltime =
- ntohl(ia_prefix.dh6opt_ia_prefix_vltime);
- printf(" pltime:%lu vltime:%lu",
- (unsigned long)ia_prefix.dh6opt_ia_prefix_pltime,
- (unsigned long)ia_prefix.dh6opt_ia_prefix_vltime);
- if (optlen > sizeof(ia_prefix) - 4) {
+ tp = (u_char *)(dh6o + 1);
+ printf(" %s/%d", ip6addr_string(&tp[9]), tp[8]);
+ printf(" pltime:%u vltime:%u",
+ EXTRACT_32BITS(&tp[0]),
+ EXTRACT_32BITS(&tp[4]));
+ if (optlen > 25) {
/* there are sub-options */
- dhcp6opt_print((u_char *)dh6o +
- sizeof(ia_prefix),
- (u_char *)(dh6o + 1) + optlen);
+ dhcp6opt_print(tp + 25, tp + 25 + optlen);
}
printf(")");
break;
@@ -710,9 +649,8 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
printf(" ?)");
break;
}
- memcpy(&val32, dh6o + 1, sizeof(val32));
- val32 = ntohl(val32);
- printf(" %d)", (int)val32);
+ tp = (u_char *)(dh6o + 1);
+ printf(" %d)", EXTRACT_32BITS(tp));
break;
case DH6OPT_REMOTE_ID:
if (optlen < 4) {
@@ -720,9 +658,7 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
break;
}
tp = (u_char *)(dh6o + 1);
- memcpy(&val32, &tp[0], sizeof(val32));
- val32 = ntohl(val32);
- printf(" %d ", (int)val32);
+ printf(" %d ", EXTRACT_32BITS(tp));
/*
* Print hex dump first 10 characters.
*/
@@ -755,10 +691,10 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
printf(")");
break;
case DH6OPT_CLIENT_DATA:
+ tp = (u_char *)(dh6o + 1);
if (optlen > 0) {
/* there are encapsulated options */
- dhcp6opt_print((u_char *)(dh6o + 1),
- (u_char *)(dh6o + 1) + optlen);
+ dhcp6opt_print(tp, tp + optlen);
}
printf(")");
break;
diff --git a/print-domain.c b/print-domain.c
index 80b4b33d3d29..43e8f41df45e 100644
--- a/print-domain.c
+++ b/print-domain.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.97.2.1 2007-12-09 01:51:12 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.98 2007-12-09 01:40:32 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
diff --git a/print-enc.c b/print-enc.c
index 9569534cbd70..e98f7f78215c 100644
--- a/print-enc.c
+++ b/print-enc.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.4.4.1 2008-02-06 10:34:15 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,6 +35,7 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#include "enc.h"
@@ -67,7 +68,7 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
ENC_PRINT_TYPE(flags, M_AUTH, "authentic");
ENC_PRINT_TYPE(flags, M_CONF, "confidential");
/* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */
- printf("SPI 0x%08x: ", (u_int32_t)ntohl(hdr->spi));
+ printf("SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi));
length -= ENC_HDRLEN;
caplen -= ENC_HDRLEN;
@@ -77,9 +78,11 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
case AF_INET:
ip_print(gndo, p, length);
break;
+#ifdef INET6
case AF_INET6:
ip6_print(p, length);
break;
+#endif /*INET6*/
}
out:
diff --git a/print-esp.c b/print-esp.c
index 260fe8710e89..ade654a33709 100644
--- a/print-esp.c
+++ b/print-esp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.56 2005-04-21 06:44:40 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -71,14 +71,72 @@ struct sockaddr_storage {
struct sa_list {
struct sa_list *next;
struct sockaddr_storage daddr;
- u_int32_t spi;
+ u_int32_t spi; /* if == 0, then IKEv2 */
+ int initiator;
+ u_char spii[8]; /* for IKEv2 */
+ u_char spir[8];
const EVP_CIPHER *evp;
int ivlen;
int authlen;
+ u_char authsecret[256];
+ int authsecret_len;
u_char secret[256]; /* is that big enough for all secrets? */
int secretlen;
};
+/*
+ * this will adjust ndo_packetp and ndo_snapend to new buffer!
+ */
+int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
+ int initiator,
+ u_char spii[8], u_char spir[8],
+ u_char *buf, u_char *end)
+{
+ struct sa_list *sa;
+ u_char *iv;
+ int len;
+ EVP_CIPHER_CTX ctx;
+
+ /* initiator arg is any non-zero value */
+ if(initiator) initiator=1;
+
+ /* see if we can find the SA, and if so, decode it */
+ for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
+ if (sa->spi == 0
+ && initiator == sa->initiator
+ && memcmp(spii, sa->spii, 8) == 0
+ && memcmp(spir, sa->spir, 8) == 0)
+ break;
+ }
+
+ if(sa == NULL) return 0;
+ if(sa->evp == NULL) return 0;
+
+ /*
+ * remove authenticator, and see if we still have something to
+ * work with
+ */
+ end = end - sa->authlen;
+ iv = buf;
+ buf = buf + sa->ivlen;
+ len = end-buf;
+
+ if(end <= buf) return 0;
+
+ memset(&ctx, 0, sizeof(ctx));
+ if (EVP_CipherInit(&ctx, sa->evp, sa->secret, NULL, 0) < 0)
+ (*ndo->ndo_warning)(ndo, "espkey init failed");
+ EVP_CipherInit(&ctx, NULL, NULL, iv, 0);
+ EVP_Cipher(&ctx, buf, buf, len);
+ EVP_CIPHER_CTX_cleanup(&ctx);
+
+ ndo->ndo_packetp = buf;
+ ndo->ndo_snapend = end;
+
+ return 1;
+
+}
+
static void esp_print_addsa(netdissect_options *ndo,
struct sa_list *sa, int sa_def)
{
@@ -123,13 +181,193 @@ static u_int hex2byte(netdissect_options *ndo, char *hexstring)
}
/*
+ * returns size of binary, 0 on failure.
+ */
+static
+int espprint_decode_hex(netdissect_options *ndo,
+ u_char *binbuf, unsigned int binbuf_len,
+ char *hex)
+{
+ unsigned int len;
+ int i;
+
+ len = strlen(hex) / 2;
+
+ if (len > binbuf_len) {
+ (*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len);
+ return 0;
+ }
+
+ i = 0;
+ while (hex[0] != '\0' && hex[1]!='\0') {
+ binbuf[i] = hex2byte(ndo, hex);
+ hex += 2;
+ i++;
+ }
+
+ return i;
+}
+
+/*
* decode the form: SPINUM@IP <tab> ALGONAME:0xsecret
+ */
+
+static int
+espprint_decode_encalgo(netdissect_options *ndo,
+ char *decode, struct sa_list *sa)
+{
+ int len;
+ size_t i;
+ const EVP_CIPHER *evp;
+ int authlen = 0;
+ char *colon, *p;
+
+ colon = strchr(decode, ':');
+ if (colon == NULL) {
+ (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
+ return 0;
+ }
+ *colon = '\0';
+
+ len = colon - decode;
+ if (strlen(decode) > strlen("-hmac96") &&
+ !strcmp(decode + strlen(decode) - strlen("-hmac96"),
+ "-hmac96")) {
+ p = strstr(decode, "-hmac96");
+ *p = '\0';
+ authlen = 12;
+ }
+ if (strlen(decode) > strlen("-cbc") &&
+ !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) {
+ p = strstr(decode, "-cbc");
+ *p = '\0';
+ }
+ evp = EVP_get_cipherbyname(decode);
+
+ if (!evp) {
+ (*ndo->ndo_warning)(ndo, "failed to find cipher algo %s\n", decode);
+ sa->evp = NULL;
+ sa->authlen = 0;
+ sa->ivlen = 0;
+ return 0;
+ }
+
+ sa->evp = evp;
+ sa->authlen = authlen;
+ sa->ivlen = EVP_CIPHER_iv_length(evp);
+
+ colon++;
+ if (colon[0] == '0' && colon[1] == 'x') {
+ /* decode some hex! */
+
+ colon += 2;
+ sa->secretlen = espprint_decode_hex(ndo, sa->secret, sizeof(sa->secret), colon);
+ if(sa->secretlen == 0) return 0;
+ } else {
+ i = strlen(colon);
+
+ if (i < sizeof(sa->secret)) {
+ memcpy(sa->secret, colon, i);
+ sa->secretlen = i;
+ } else {
+ memcpy(sa->secret, colon, sizeof(sa->secret));
+ sa->secretlen = sizeof(sa->secret);
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * for the moment, ignore the auth algorith, just hard code the authenticator
+ * length. Need to research how openssl looks up HMAC stuff.
+ */
+static int
+espprint_decode_authalgo(netdissect_options *ndo,
+ char *decode, struct sa_list *sa)
+{
+ char *colon;
+
+ colon = strchr(decode, ':');
+ if (colon == NULL) {
+ (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
+ return 0;
+ }
+ *colon = '\0';
+
+ if(strcasecmp(colon,"sha1") == 0 ||
+ strcasecmp(colon,"md5") == 0) {
+ sa->authlen = 12;
+ }
+ return 1;
+}
+
+static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
+ const char *file, int lineno)
+{
+ /* it's an IKEv2 secret, store it instead */
+ struct sa_list sa1;
+
+ char *init;
+ char *icookie, *rcookie;
+ int ilen, rlen;
+ char *authkey;
+ char *enckey;
+
+ init = strsep(&line, " \t");
+ icookie = strsep(&line, " \t");
+ rcookie = strsep(&line, " \t");
+ authkey = strsep(&line, " \t");
+ enckey = strsep(&line, " \t");
+
+ /* if any fields are missing */
+ if(!init || !icookie || !rcookie || !authkey || !enckey) {
+ (*ndo->ndo_warning)(ndo, "print_esp: failed to find all fields for ikev2 at %s:%u",
+ file, lineno);
+
+ return;
+ }
+
+ ilen = strlen(icookie);
+ rlen = strlen(rcookie);
+
+ if((init[0]!='I' && init[0]!='R')
+ || icookie[0]!='0' || icookie[1]!='x'
+ || rcookie[0]!='0' || rcookie[1]!='x'
+ || ilen!=18
+ || rlen!=18) {
+ (*ndo->ndo_warning)(ndo, "print_esp: line %s:%u improperly formatted.",
+ file, lineno);
+
+ (*ndo->ndo_warning)(ndo, "init=%s icookie=%s(%u) rcookie=%s(%u)",
+ init, icookie, ilen, rcookie, rlen);
+
+ return;
+ }
+
+ sa1.spi = 0;
+ sa1.initiator = (init[0] == 'I');
+ if(espprint_decode_hex(ndo, sa1.spii, sizeof(sa1.spii), icookie+2)!=8)
+ return;
+
+ if(espprint_decode_hex(ndo, sa1.spir, sizeof(sa1.spir), rcookie+2)!=8)
+ return;
+
+ if(!espprint_decode_encalgo(ndo, enckey, &sa1)) return;
+
+ if(!espprint_decode_authalgo(ndo, authkey, &sa1)) return;
+
+ esp_print_addsa(ndo, &sa1, FALSE);
+}
+
+/*
*
* special form: file /name
* causes us to go read from this file instead.
*
*/
-static void esp_print_decode_onesecret(netdissect_options *ndo, char *line)
+static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
+ const char *file, int lineno)
{
struct sa_list sa1;
int sa_def;
@@ -155,15 +393,18 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line)
/* open file and read it */
FILE *secretfile;
char fileline[1024];
+ int lineno=0;
char *nl;
+ char *filename = line;
- secretfile = fopen(line, FOPEN_READ_TXT);
+ secretfile = fopen(filename, FOPEN_READ_TXT);
if (secretfile == NULL) {
- perror(line);
+ perror(filename);
exit(3);
}
while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) {
+ lineno++;
/* remove newline from the line */
nl = strchr(fileline, '\n');
if (nl)
@@ -171,31 +412,37 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line)
if (fileline[0] == '#') continue;
if (fileline[0] == '\0') continue;
- esp_print_decode_onesecret(ndo, fileline);
+ esp_print_decode_onesecret(ndo, fileline, filename, lineno);
}
fclose(secretfile);
return;
}
+ if (spikey && strcasecmp(spikey, "ikev2") == 0) {
+ esp_print_decode_ikeline(ndo, line, file, lineno);
+ return;
+ }
+
if (spikey) {
+
char *spistr, *foo;
u_int32_t spino;
struct sockaddr_in *sin;
#ifdef INET6
struct sockaddr_in6 *sin6;
#endif
-
+
spistr = strsep(&spikey, "@");
-
+
spino = strtoul(spistr, &foo, 0);
if (spistr == foo || !spikey) {
(*ndo->ndo_warning)(ndo, "print_esp: failed to decode spi# %s\n", foo);
return;
}
-
+
sa1.spi = spino;
-
+
sin = (struct sockaddr_in *)&sa1.daddr;
#ifdef INET6
sin6 = (struct sockaddr_in6 *)&sa1.daddr;
@@ -206,122 +453,63 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line)
sin6->sin6_family = AF_INET6;
} else
#endif
- if (inet_pton(AF_INET, spikey, &sin->sin_addr) == 1) {
+ if (inet_pton(AF_INET, spikey, &sin->sin_addr) == 1) {
#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
+ sin->sin_len = sizeof(struct sockaddr_in);
#endif
- sin->sin_family = AF_INET;
- } else {
- (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
- return;
- }
+ sin->sin_family = AF_INET;
+ } else {
+ (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
+ return;
+ }
}
if (decode) {
- char *colon, *p;
- u_char espsecret_key[256];
- int len;
- size_t i;
- const EVP_CIPHER *evp;
- int authlen = 0;
-
/* skip any blank spaces */
while (isspace((unsigned char)*decode))
decode++;
-
- colon = strchr(decode, ':');
- if (colon == NULL) {
- (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
+
+ if(!espprint_decode_encalgo(ndo, decode, &sa1)) {
return;
}
- *colon = '\0';
-
- len = colon - decode;
- if (strlen(decode) > strlen("-hmac96") &&
- !strcmp(decode + strlen(decode) - strlen("-hmac96"),
- "-hmac96")) {
- p = strstr(decode, "-hmac96");
- *p = '\0';
- authlen = 12;
- }
- if (strlen(decode) > strlen("-cbc") &&
- !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) {
- p = strstr(decode, "-cbc");
- *p = '\0';
- }
- evp = EVP_get_cipherbyname(decode);
- if (!evp) {
- (*ndo->ndo_warning)(ndo, "failed to find cipher algo %s\n", decode);
- sa1.evp = NULL;
- sa1.authlen = 0;
- sa1.ivlen = 0;
- return;
- }
-
- sa1.evp = evp;
- sa1.authlen = authlen;
- sa1.ivlen = EVP_CIPHER_iv_length(evp);
-
- colon++;
- if (colon[0] == '0' && colon[1] == 'x') {
- /* decode some hex! */
- colon += 2;
- len = strlen(colon) / 2;
-
- if (len > 256) {
- (*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len);
- return;
- }
-
- i = 0;
- while (colon[0] != '\0' && colon[1]!='\0') {
- espsecret_key[i] = hex2byte(ndo, colon);
- colon += 2;
- i++;
- }
-
- memcpy(sa1.secret, espsecret_key, i);
- sa1.secretlen = i;
- } else {
- i = strlen(colon);
-
- if (i < sizeof(sa1.secret)) {
- memcpy(sa1.secret, colon, i);
- sa1.secretlen = i;
- } else {
- memcpy(sa1.secret, colon, sizeof(sa1.secret));
- sa1.secretlen = sizeof(sa1.secret);
- }
- }
}
esp_print_addsa(ndo, &sa1, sa_def);
}
-static void esp_print_decodesecret(netdissect_options *ndo)
+static void esp_init(netdissect_options *ndo _U_)
+{
+
+ OpenSSL_add_all_algorithms();
+ EVP_add_cipher_alias(SN_des_ede3_cbc, "3des");
+}
+
+void esp_print_decodesecret(netdissect_options *ndo)
{
char *line;
char *p;
+ static int initialized = 0;
+
+ if (!initialized) {
+ esp_init(ndo);
+ initialized = 1;
+ }
p = ndo->ndo_espsecret;
- while (ndo->ndo_espsecret && ndo->ndo_espsecret[0] != '\0') {
+ while (p && p[0] != '\0') {
/* pick out the first line or first thing until a comma */
- if ((line = strsep(&ndo->ndo_espsecret, "\n,")) == NULL) {
- line = ndo->ndo_espsecret;
- ndo->ndo_espsecret = NULL;
+ if ((line = strsep(&p, "\n,")) == NULL) {
+ line = p;
+ p = NULL;
}
- esp_print_decode_onesecret(ndo, line);
+ esp_print_decode_onesecret(ndo, line, "cmdline", 0);
}
-}
-static void esp_init(netdissect_options *ndo _U_)
-{
-
- OpenSSL_add_all_algorithms();
- EVP_add_cipher_alias(SN_des_ede3_cbc, "3des");
+ ndo->ndo_espsecret = NULL;
}
+
#endif
int
@@ -359,7 +547,6 @@ esp_print(netdissect_options *ndo,
u_char *p;
EVP_CIPHER_CTX ctx;
int blocksz;
- static int initialized = 0;
#endif
esp = (struct newesp *)bp;
@@ -367,11 +554,6 @@ esp_print(netdissect_options *ndo,
#ifdef HAVE_LIBCRYPTO
secret = NULL;
advance = 0;
-
- if (!initialized) {
- esp_init(ndo);
- initialized = 1;
- }
#endif
#if 0
@@ -418,7 +600,7 @@ esp_print(netdissect_options *ndo,
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa->daddr;
- if (sa->spi == ntohl(esp->esp_spi) &&
+ if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
sin6->sin6_family == AF_INET6 &&
memcmp(&sin6->sin6_addr, &ip6->ip6_dst,
sizeof(struct in6_addr)) == 0) {
@@ -436,7 +618,7 @@ esp_print(netdissect_options *ndo,
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
struct sockaddr_in *sin = (struct sockaddr_in *)&sa->daddr;
- if (sa->spi == ntohl(esp->esp_spi) &&
+ if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
sin->sin_family == AF_INET &&
sin->sin_addr.s_addr == ip->ip_dst.s_addr) {
break;
@@ -481,6 +663,7 @@ esp_print(netdissect_options *ndo,
p = ivoff;
EVP_CipherInit(&ctx, NULL, NULL, p, 0);
EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen));
+ EVP_CIPHER_CTX_cleanup(&ctx);
advance = ivoff - (u_char *)esp + ivlen;
} else
advance = sizeof(struct newesp);
diff --git a/print-ether.c b/print-ether.c
index b66e885c6bcd..e086d1660c09 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.105.2.1 2008-02-06 10:49:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,6 +33,7 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -56,6 +57,7 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_DN, "DN" },
{ ETHERTYPE_LAT, "LAT" },
{ ETHERTYPE_SCA, "SCA" },
+ { ETHERTYPE_TEB, "TEB" },
{ ETHERTYPE_LANBRIDGE, "Lanbridge" },
{ ETHERTYPE_DECDNS, "DEC DNS" },
{ ETHERTYPE_DECDTS, "DEC DTS" },
@@ -85,51 +87,67 @@ static inline void
ether_hdr_print(register const u_char *bp, u_int length)
{
register const struct ether_header *ep;
+ u_int16_t ether_type;
+
ep = (const struct ether_header *)bp;
(void)printf("%s > %s",
etheraddr_string(ESRC(ep)),
etheraddr_string(EDST(ep)));
+ ether_type = EXTRACT_16BITS(&ep->ether_type);
if (!qflag) {
- if (ntohs(ep->ether_type) <= ETHERMTU)
+ if (ether_type <= ETHERMTU)
(void)printf(", 802.3");
else
(void)printf(", ethertype %s (0x%04x)",
- tok2str(ethertype_values,"Unknown", ntohs(ep->ether_type)),
- ntohs(ep->ether_type));
+ tok2str(ethertype_values,"Unknown", ether_type),
+ ether_type);
} else {
- if (ntohs(ep->ether_type) <= ETHERMTU)
+ if (ether_type <= ETHERMTU)
(void)printf(", 802.3");
else
- (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ntohs(ep->ether_type)));
+ (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type));
}
(void)printf(", length %u: ", length);
}
+/*
+ * Print an Ethernet frame.
+ * This might be encapsulated within another frame; we might be passed
+ * a pointer to a function that can print header information for that
+ * frame's protocol, and an argument to pass to that function.
+ */
void
-ether_print(const u_char *p, u_int length, u_int caplen)
+ether_print(const u_char *p, u_int length, u_int caplen,
+ void (*print_encap_header)(const u_char *), const u_char *encap_header_arg)
{
struct ether_header *ep;
+ u_int orig_length;
u_short ether_type;
u_short extracted_ether_type;
- if (caplen < ETHER_HDRLEN) {
+ if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) {
printf("[|ether]");
return;
}
- if (eflag)
+ if (eflag) {
+ if (print_encap_header != NULL)
+ (*print_encap_header)(encap_header_arg);
ether_hdr_print(p, length);
+ }
+ orig_length = length;
length -= ETHER_HDRLEN;
caplen -= ETHER_HDRLEN;
ep = (struct ether_header *)p;
p += ETHER_HDRLEN;
- ether_type = ntohs(ep->ether_type);
+ ether_type = EXTRACT_16BITS(&ep->ether_type);
+recurse:
/*
* Is it (gag) an 802.3 encapsulation?
*/
@@ -138,21 +156,76 @@ ether_print(const u_char *p, u_int length, u_int caplen)
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN);
+ if (!eflag) {
+ if (print_encap_header != NULL)
+ (*print_encap_header)(encap_header_arg);
+ ether_hdr_print((u_char *)ep, orig_length);
+ }
+
+ if (!suppress_default_print)
+ default_print(p, caplen);
+ }
+ } else if (ether_type == ETHERTYPE_8021Q) {
+ /*
+ * Print VLAN information, and then go back and process
+ * the enclosed type field.
+ */
+ if (caplen < 4 || length < 4) {
+ printf("[|vlan]");
+ return;
+ }
+ if (eflag) {
+ u_int16_t tag = EXTRACT_16BITS(p);
+
+ printf("vlan %u, p %u%s, ",
+ tag & 0xfff,
+ tag >> 13,
+ (tag & 0x1000) ? ", CFI" : "");
+ }
+
+ ether_type = EXTRACT_16BITS(p + 2);
+ if (eflag && ether_type > ETHERMTU)
+ printf("ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type));
+ p += 4;
+ length -= 4;
+ caplen -= 4;
+ goto recurse;
+ } else if (ether_type == ETHERTYPE_JUMBO) {
+ /*
+ * Alteon jumbo frames.
+ * See
+ *
+ * http://tools.ietf.org/html/draft-ietf-isis-ext-eth-01
+ *
+ * which indicates that, following the type field,
+ * there's an LLC header and payload.
+ */
+ /* Try to print the LLC-layer header & higher layers */
+ if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
+ &extracted_ether_type) == 0) {
+ /* ether_type not known, print raw packet */
+ if (!eflag) {
+ if (print_encap_header != NULL)
+ (*print_encap_header)(encap_header_arg);
+ ether_hdr_print((u_char *)ep, orig_length);
+ }
+
+ if (!suppress_default_print)
+ default_print(p, caplen);
+ }
+ } else {
+ if (ethertype_print(ether_type, p, length, caplen) == 0) {
+ /* ether_type not known, print raw packet */
+ if (!eflag) {
+ if (print_encap_header != NULL)
+ (*print_encap_header)(encap_header_arg);
+ ether_hdr_print((u_char *)ep, orig_length);
+ }
if (!suppress_default_print)
default_print(p, caplen);
}
- } else if (ether_encap_print(ether_type, p, length, caplen,
- &extracted_ether_type) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN);
-
- if (!suppress_default_print)
- default_print(p, caplen);
- }
+ }
}
/*
@@ -164,30 +237,21 @@ ether_print(const u_char *p, u_int length, u_int caplen)
u_int
ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
{
- ether_print(p, h->len, h->caplen);
+ ether_print(p, h->len, h->caplen, NULL, NULL);
return (ETHER_HDRLEN);
}
/*
- * Prints the packet encapsulated in an Ethernet data segment
- * (or an equivalent encapsulation), given the Ethernet type code.
+ * Prints the packet payload, given an Ethernet type code for the payload's
+ * protocol.
*
* Returns non-zero if it can do so, zero if the ethertype is unknown.
- *
- * The Ethernet type code is passed through a pointer; if it was
- * ETHERTYPE_8021Q, it gets updated to be the Ethernet type of
- * the 802.1Q payload, for the benefit of lower layers that might
- * want to know what it is.
*/
int
-ether_encap_print(u_short ether_type, const u_char *p,
- u_int length, u_int caplen, u_short *extracted_ether_type)
+ethertype_print(u_short ether_type, const u_char *p, u_int length, u_int caplen)
{
- recurse:
- *extracted_ether_type = ether_type;
-
switch (ether_type) {
case ETHERTYPE_IP:
@@ -224,71 +288,14 @@ ether_encap_print(u_short ether_type, const u_char *p,
ipx_print(p, length);
return (1);
- case ETHERTYPE_8021Q:
- if (eflag)
- printf("vlan %u, p %u%s, ",
- ntohs(*(u_int16_t *)p) & 0xfff,
- ntohs(*(u_int16_t *)p) >> 13,
- (ntohs(*(u_int16_t *)p) & 0x1000) ? ", CFI" : "");
-
- ether_type = ntohs(*(u_int16_t *)(p + 2));
- p += 4;
- length -= 4;
- caplen -= 4;
-
- if (ether_type > ETHERMTU) {
- if (eflag)
- printf("ethertype %s, ",
- tok2str(ethertype_values,"0x%04x", ether_type));
- goto recurse;
- }
-
- *extracted_ether_type = 0;
-
- if (llc_print(p, length, caplen, p - 18, p - 12,
- extracted_ether_type) == 0) {
- ether_hdr_print(p - 18, length + 4);
-
- if (!suppress_default_print) {
- default_print(p - 18, caplen + 4);
- }
- }
-
-
- return (1);
-
- case ETHERTYPE_JUMBO:
- ether_type = ntohs(*(u_int16_t *)(p));
- p += 2;
- length -= 2;
- caplen -= 2;
-
- if (ether_type > ETHERMTU) {
- if (eflag)
- printf("ethertype %s, ",
- tok2str(ethertype_values,"0x%04x", ether_type));
- goto recurse;
- }
-
- *extracted_ether_type = 0;
-
- if (llc_print(p, length, caplen, p - 16, p - 10,
- extracted_ether_type) == 0) {
- ether_hdr_print(p - 16, length + 2);
-
- if (!suppress_default_print) {
- default_print(p - 16, caplen + 2);
- }
- }
-
- return (1);
-
case ETHERTYPE_ISO:
isoclns_print(p+1, length-1, length-1);
return(1);
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
+ case ETHERTYPE_PPPOED2:
+ case ETHERTYPE_PPPOES2:
pppoe_print(p, length);
return (1);
diff --git a/print-forces.c b/print-forces.c
new file mode 100644
index 000000000000..26e83d3167c7
--- /dev/null
+++ b/print-forces.c
@@ -0,0 +1,1043 @@
+/*
+ * 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.
+ * 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.
+ *
+ * Copyright (c) 2009 Mojatatu Networks, Inc
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "interface.h"
+#include "extract.h"
+
+#include "forces.h"
+
+#define RESLEN 4
+
+int
+prestlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ register const u_char *tdp = (u_char *) TLV_DATA(tlv);
+ struct res_val *r = (struct res_val *)tdp;
+ u_int dlen;
+
+ /*
+ * pdatacnt_print() has ensured that len (the TLV length)
+ * >= TLV_HDRL.
+ */
+ dlen = len - TLV_HDRL;
+ if (dlen != RESLEN) {
+ printf("illegal RESULT-TLV: %d bytes!\n", dlen);
+ return -1;
+ }
+
+ TCHECK(*r);
+ if (r->result >= 0x18 && r->result <= 0xFE) {
+ printf("illegal reserved result code: 0x%x!\n", r->result);
+ return -1;
+ }
+
+ if (vflag >= 3) {
+ char *ib = indent_pr(indent, 0);
+ printf("%s Result: %s (code 0x%x)\n", ib,
+ tok2str(ForCES_errs, NULL, r->result), r->result);
+ }
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+fdatatlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ u_int rlen;
+ register const u_char *tdp = (u_char *) TLV_DATA(tlv);
+ u_int16_t type;
+
+ /*
+ * pdatacnt_print() or pkeyitlv_print() has ensured that len
+ * (the TLV length) >= TLV_HDRL.
+ */
+ rlen = len - TLV_HDRL;
+ TCHECK(*tlv);
+ type = EXTRACT_16BITS(&tlv->type);
+ if (type != F_TLV_FULD) {
+ printf("Error: expecting FULLDATA!\n");
+ return -1;
+ }
+
+ if (vflag >= 3) {
+ char *ib = indent_pr(indent + 2, 1);
+ printf("%s[", &ib[1]);
+ hex_print_with_offset(ib, tdp, rlen, 0);
+ printf("\n%s]\n", &ib[1]);
+ }
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+sdatailv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ u_int rlen;
+ const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+ int invilv;
+
+ if (len < ILV_HDRL) {
+ printf("Error: BAD SPARSEDATA-TLV!\n");
+ return -1;
+ }
+ rlen = len - ILV_HDRL;
+ indent += 1;
+ while (rlen != 0) {
+ TCHECK(*ilv);
+ invilv = ilv_valid(ilv, rlen);
+ if (invilv) {
+ printf("Error: BAD ILV!\n");
+ return -1;
+ }
+ if (vflag >= 3) {
+ register const u_char *tdp = (u_char *) ILV_DATA(ilv);
+ char *ib = indent_pr(indent, 1);
+ printf("\n%s SPARSEDATA: type %x length %d\n", &ib[1],
+ EXTRACT_32BITS(&ilv->type),
+ EXTRACT_32BITS(&ilv->length));
+ printf("%s[", &ib[1]);
+ hex_print_with_offset(ib, tdp, rlen, 0);
+ printf("\n%s]\n", &ib[1]);
+ }
+
+ ilv = GO_NXT_ILV(ilv, rlen);
+ }
+
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+sdatatlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent)
+{
+ const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ u_int rlen;
+ register const u_char *tdp = (u_char *) TLV_DATA(tlv);
+ u_int16_t type;
+
+ /*
+ * pdatacnt_print() has ensured that len (the TLV length)
+ * >= TLV_HDRL.
+ */
+ rlen = len - TLV_HDRL;
+ TCHECK(*tlv);
+ type = EXTRACT_16BITS(&tlv->type);
+ if (type != F_TLV_SPAD) {
+ printf("Error: expecting SPARSEDATA!\n");
+ return -1;
+ }
+
+ return sdatailv_print(tdp, rlen, op_msk, indent);
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+pkeyitlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent)
+{
+ const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ register const u_char *tdp = (u_char *) TLV_DATA(tlv);
+ register const u_char *dp = tdp + 4;
+ const struct forces_tlv *kdtlv = (struct forces_tlv *)dp;
+ u_int32_t id;
+ char *ib = indent_pr(indent, 0);
+ u_int16_t type, tll;
+ int invtlv;
+
+ TCHECK(*tdp);
+ id = EXTRACT_32BITS(tdp);
+ printf("%sKeyinfo: Key 0x%x\n", ib, id);
+ TCHECK(*kdtlv);
+ type = EXTRACT_16BITS(&kdtlv->type);
+ invtlv = tlv_valid(kdtlv, len);
+
+ if (invtlv) {
+ printf("%s TLV type 0x%x len %d\n",
+ tok2str(ForCES_TLV_err, NULL, invtlv), type,
+ EXTRACT_16BITS(&kdtlv->length));
+ return -1;
+ }
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ tll = EXTRACT_16BITS(&kdtlv->length);
+ dp = (u_char *) TLV_DATA(kdtlv);
+ return fdatatlv_print(dp, tll, op_msk, indent);
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+pdatacnt_print(register const u_char * pptr, register u_int len,
+ u_int32_t IDcnt, u_int16_t op_msk, int indent)
+{
+ u_int i;
+ int rc;
+ u_int32_t id;
+ char *ib = indent_pr(indent, 0);
+
+ for (i = 0; i < IDcnt; i++) {
+ TCHECK2(*pptr, 4);
+ if (len < 4)
+ goto trunc;
+ id = EXTRACT_32BITS(pptr);
+ if (vflag >= 3)
+ printf("%s ID#%02u: %d\n", ib, i + 1, id);
+ len -= 4;
+ pptr += 4;
+ }
+ if (len) {
+ const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+ u_int16_t type;
+ u_int16_t tll;
+ int pad = 0;
+ u_int aln;
+ int invtlv;
+
+ TCHECK(*pdtlv);
+ type = EXTRACT_16BITS(&pdtlv->type);
+ invtlv = tlv_valid(pdtlv, len);
+ if (invtlv) {
+ printf
+ ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
+ tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
+ EXTRACT_16BITS(&pdtlv->length));
+ goto pd_err;
+ }
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
+ aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length));
+ if (aln > EXTRACT_16BITS(&pdtlv->length)) {
+ if (aln > len) {
+ printf
+ ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
+ type, EXTRACT_16BITS(&pdtlv->length), aln - len);
+ } else {
+ pad = aln - EXTRACT_16BITS(&pdtlv->length);
+ }
+ }
+ if (pd_valid(type)) {
+ const struct pdata_ops *ops = get_forces_pd(type);
+
+ if (vflag >= 3 && ops->v != F_TLV_PDAT) {
+ if (pad)
+ printf
+ ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
+ ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
+ tll, pad);
+ else
+ printf
+ ("%s %s (Length %d DataLen %d Bytes)\n",
+ ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
+ tll);
+ }
+
+ chk_op_type(type, op_msk, ops->op_msk);
+
+ rc = ops->print((const u_char *)pdtlv,
+ tll + pad + TLV_HDRL, op_msk,
+ indent + 2);
+ } else {
+ printf("Invalid path data content type 0x%x len %d\n",
+ type, EXTRACT_16BITS(&pdtlv->length));
+pd_err:
+ if (EXTRACT_16BITS(&pdtlv->length)) {
+ hex_print_with_offset("Bad Data val\n\t [",
+ pptr, len, 0);
+ printf("]\n");
+
+ return -1;
+ }
+ }
+ }
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+pdata_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent)
+{
+ const struct pathdata_h *pdh = (struct pathdata_h *)pptr;
+ char *ib = indent_pr(indent, 0);
+ u_int minsize = 0;
+
+ TCHECK(*pdh);
+ if (len < sizeof(struct pathdata_h))
+ goto trunc;
+ if (vflag >= 3) {
+ printf("\n%sPathdata: Flags 0x%x ID count %d\n",
+ ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt));
+ }
+
+ if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) {
+ op_msk |= B_KEYIN;
+ }
+ pptr += sizeof(struct pathdata_h);
+ len -= sizeof(struct pathdata_h);
+ minsize = EXTRACT_16BITS(&pdh->pIDcnt) * 4;
+ if (len < minsize) {
+ printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
+ len);
+ hex_print_with_offset("\t\t\tID Data[", pptr, len, 0);
+ printf("]\n");
+ return -1;
+ }
+ return pdatacnt_print(pptr, len, EXTRACT_16BITS(&pdh->pIDcnt), op_msk, indent);
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+genoptlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent)
+{
+ const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+ u_int16_t type;
+ int tll;
+ int invtlv;
+ char *ib = indent_pr(indent, 0);
+
+ TCHECK(*pdtlv);
+ type = EXTRACT_16BITS(&pdtlv->type);
+ tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
+ invtlv = tlv_valid(pdtlv, len);
+ printf("genoptlvprint - %s TLV type 0x%x len %d\n",
+ tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length));
+ if (!invtlv) {
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ register const u_char *dp = (u_char *) TLV_DATA(pdtlv);
+ if (!ttlv_valid(type)) {
+ printf("%s TLV type 0x%x len %d\n",
+ tok2str(ForCES_TLV_err, NULL, invtlv), type,
+ EXTRACT_16BITS(&pdtlv->length));
+ return -1;
+ }
+ if (vflag >= 3)
+ printf("%s%s, length %d (data length %d Bytes)",
+ ib, tok2str(ForCES_TLV, NULL, type),
+ EXTRACT_16BITS(&pdtlv->length), tll);
+
+ return pdata_print(dp, tll, op_msk, indent + 1);
+ } else {
+ printf("\t\t\tInvalid ForCES TLV type=%x", type);
+ return -1;
+ }
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+recpdoptlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent)
+{
+ const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+ int tll;
+ int rc = 0;
+ int invtlv;
+ u_int16_t type;
+ register const u_char *dp;
+ char *ib;
+
+ while (len != 0) {
+ TCHECK(*pdtlv);
+ invtlv = tlv_valid(pdtlv, len);
+ if (invtlv) {
+ break;
+ }
+
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ ib = indent_pr(indent, 0);
+ type = EXTRACT_16BITS(&pdtlv->type);
+ dp = (u_char *) TLV_DATA(pdtlv);
+ tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
+
+ if (vflag >= 3)
+ printf
+ ("%s%s, length %d (data encapsulated %d Bytes)",
+ ib, tok2str(ForCES_TLV, NULL, type),
+ EXTRACT_16BITS(&pdtlv->length),
+ EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL);
+
+ rc = pdata_print(dp, tll, op_msk, indent + 1);
+ pdtlv = GO_NXT_TLV(pdtlv, len);
+ }
+
+ if (len) {
+ printf
+ ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length));
+ return -1;
+ }
+
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+invoptlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ char *ib = indent_pr(indent, 1);
+
+ if (vflag >= 3) {
+ printf("%sData[", &ib[1]);
+ hex_print_with_offset(ib, pptr, len, 0);
+ printf("%s]\n", ib);
+ }
+ return -1;
+}
+
+int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
+{
+ int rc = 0;
+ register const u_char *dp = (u_char *) TLV_DATA(otlv);
+ u_int16_t type;
+ int tll;
+ char *ib = indent_pr(indent, 0);
+ const struct optlv_h *ops;
+
+ /*
+ * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
+ * >= TLV_HDRL.
+ */
+ TCHECK(*otlv);
+ type = EXTRACT_16BITS(&otlv->type);
+ tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
+ ops = get_forces_optlv_h(type);
+ if (vflag >= 3) {
+ printf("%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
+ EXTRACT_16BITS(&otlv->length));
+ }
+ /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
+ if (!ops->flags & ZERO_TTLV) {
+ if (tll != 0) /* instead of "if (tll)" - for readability .. */
+ printf("%s: Illegal - MUST be empty\n", ops->s);
+ return rc;
+ }
+ /* rest of ops must at least have 12B {pathinfo} */
+ if (tll < OP_MIN_SIZ) {
+ printf("\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
+ EXTRACT_16BITS(&otlv->length));
+ printf("\t\tTruncated data size %d minimum required %d\n", tll,
+ OP_MIN_SIZ);
+ return invoptlv_print(dp, tll, ops->op_msk, indent);
+
+ }
+
+ rc = ops->print(dp, tll, ops->op_msk, indent + 1);
+ return rc;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+#define ASTDLN 4
+#define ASTMCD 255
+int
+asttlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ u_int32_t rescode;
+ u_int dlen;
+ char *ib = indent_pr(indent, 0);
+
+ /*
+ * forces_type_print() has ensured that len (the TLV length)
+ * >= TLV_HDRL.
+ */
+ dlen = len - TLV_HDRL;
+ if (dlen != ASTDLN) {
+ printf("illegal ASTresult-TLV: %d bytes!\n", dlen);
+ return -1;
+ }
+ TCHECK2(*pptr, 4);
+ rescode = EXTRACT_32BITS(pptr);
+ if (rescode > ASTMCD) {
+ printf("illegal ASTresult result code: %d!\n", rescode);
+ return -1;
+ }
+
+ if (vflag >= 3) {
+ printf("Teardown reason:\n%s", ib);
+ switch (rescode) {
+ case 0:
+ printf("Normal Teardown");
+ break;
+ case 1:
+ printf("Loss of Heartbeats");
+ break;
+ case 2:
+ printf("Out of bandwidth");
+ break;
+ case 3:
+ printf("Out of Memory");
+ break;
+ case 4:
+ printf("Application Crash");
+ break;
+ default:
+ printf("Unknown Teardown reason");
+ break;
+ }
+ printf("(%x)\n%s", rescode, ib);
+ }
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+#define ASRDLN 4
+#define ASRMCD 3
+int
+asrtlv_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ u_int32_t rescode;
+ u_int dlen;
+ char *ib = indent_pr(indent, 0);
+
+ /*
+ * forces_type_print() has ensured that len (the TLV length)
+ * >= TLV_HDRL.
+ */
+ dlen = len - TLV_HDRL;
+ if (dlen != ASRDLN) { /* id, instance, oper tlv */
+ printf("illegal ASRresult-TLV: %d bytes!\n", dlen);
+ return -1;
+ }
+ TCHECK2(*pptr, 4);
+ rescode = EXTRACT_32BITS(pptr);
+
+ if (rescode > ASRMCD) {
+ printf("illegal ASRresult result code: %d!\n", rescode);
+ return -1;
+ }
+
+ if (vflag >= 3) {
+ printf("\n%s", ib);
+ switch (rescode) {
+ case 0:
+ printf("Success ");
+ break;
+ case 1:
+ printf("FE ID invalid ");
+ break;
+ case 2:
+ printf("permission denied ");
+ break;
+ default:
+ printf("Unknown ");
+ break;
+ }
+ printf("(%x)\n%s", rescode, ib);
+ }
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+/*
+ * XXX - not used.
+ */
+int
+gentltlv_print(register const u_char * pptr _U_, register u_int len,
+ u_int16_t op_msk _U_, int indent _U_)
+{
+ u_int dlen = len - TLV_HDRL;
+
+ if (dlen < 4) { /* at least 32 bits must exist */
+ printf("truncated TLV: %d bytes missing! ", 4 - dlen);
+ return -1;
+ }
+ return 0;
+}
+
+#define RD_MIN 8
+int
+print_metailv(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ u_int dlen;
+ u_int rlen;
+ char *ib = indent_pr(indent, 0);
+ /* XXX: check header length */
+ const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+
+ /*
+ * print_metatlv() has ensured that len (what remains in the
+ * ILV) >= ILV_HDRL.
+ */
+ dlen = len - ILV_HDRL;
+ rlen = dlen;
+ TCHECK(*ilv);
+ printf("\n%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
+ EXTRACT_32BITS(&ilv->length));
+ hex_print_with_offset("\n\t\t\t\t[", ILV_DATA(ilv), rlen, 0);
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+print_metatlv(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ u_int dlen;
+ char *ib = indent_pr(indent, 0);
+ u_int rlen;
+ const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+ int invilv;
+
+ /*
+ * redirect_print() has ensured that len (what remains in the
+ * TLV) >= TLV_HDRL.
+ */
+ dlen = len - TLV_HDRL;
+ rlen = dlen;
+ printf("\n%s METADATA\n", ib);
+ while (rlen != 0) {
+ TCHECK(*ilv);
+ invilv = ilv_valid(ilv, rlen);
+ if (invilv)
+ break;
+
+ /*
+ * At this point, ilv_valid() has ensured that the ILV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ print_metailv((u_char *) ilv, rlen, 0, indent + 1);
+
+ ilv = GO_NXT_ILV(ilv, rlen);
+ }
+
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+/*
+*/
+int
+print_reddata(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent _U_)
+{
+ u_int dlen;
+ u_int rlen;
+ int invtlv;
+ const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+
+ /*
+ * redirect_print() has ensured that len (what remains in the
+ * TLV) >= TLV_HDRL.
+ */
+ dlen = len - TLV_HDRL;
+ printf("\n\t\t Redirect DATA\n");
+ if (dlen <= RD_MIN) {
+ printf("\n\t\ttruncated Redirect data: %d bytes missing! ",
+ RD_MIN - dlen);
+ return -1;
+ }
+
+ rlen = dlen;
+ TCHECK(*tlv);
+ invtlv = tlv_valid(tlv, rlen);
+
+ if (invtlv) {
+ printf("Redir data type 0x%x len %d\n", EXTRACT_16BITS(&tlv->type),
+ EXTRACT_16BITS(&tlv->length));
+ return -1;
+ }
+
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ rlen -= TLV_HDRL;
+ hex_print_with_offset("\n\t\t\t[", TLV_DATA(tlv), rlen, 0);
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+redirect_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk _U_, int indent)
+{
+ const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ u_int dlen;
+ u_int rlen;
+ int invtlv;
+
+ /*
+ * forces_type_print() has ensured that len (the TLV length)
+ * >= TLV_HDRL.
+ */
+ dlen = len - TLV_HDRL;
+ if (dlen <= RD_MIN) {
+ printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
+ RD_MIN - dlen);
+ return -1;
+ }
+
+ rlen = dlen;
+ indent += 1;
+ while (rlen != 0) {
+ TCHECK(*tlv);
+ invtlv = tlv_valid(tlv, rlen);
+ if (invtlv)
+ break;
+
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) {
+ print_metatlv((u_char *) TLV_DATA(tlv), rlen, 0, indent);
+ } else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) {
+ print_reddata((u_char *) TLV_DATA(tlv), rlen, 0, indent);
+ } else {
+ printf("Unknown REDIRECT TLV 0x%x len %d\n",
+ EXTRACT_16BITS(&tlv->type), EXTRACT_16BITS(&tlv->length));
+ }
+
+ tlv = GO_NXT_TLV(tlv, rlen);
+ }
+
+ if (rlen) {
+ printf
+ ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&tlv->type), rlen - EXTRACT_16BITS(&tlv->length));
+ return -1;
+ }
+
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+#define OP_OFF 8
+#define OP_MIN 12
+
+int
+lfbselect_print(register const u_char * pptr, register u_int len,
+ u_int16_t op_msk, int indent)
+{
+ const struct forces_lfbsh *lfbs;
+ const struct forces_tlv *otlv;
+ char *ib = indent_pr(indent, 0);
+ u_int dlen;
+ u_int rlen;
+ int invtlv;
+
+ /*
+ * forces_type_print() has ensured that len (the TLV length)
+ * >= TLV_HDRL.
+ */
+ dlen = len - TLV_HDRL;
+ if (dlen <= OP_MIN) { /* id, instance, oper tlv header .. */
+ printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
+ OP_MIN - dlen);
+ return -1;
+ }
+
+ /*
+ * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so
+ * we also know that it's > OP_OFF.
+ */
+ rlen = dlen - OP_OFF;
+
+ lfbs = (const struct forces_lfbsh *)pptr;
+ TCHECK(*lfbs);
+ if (vflag >= 3) {
+ printf("\n%s%s(Classid %x) instance %x\n",
+ ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)),
+ EXTRACT_32BITS(&lfbs->class),
+ EXTRACT_32BITS(&lfbs->instance));
+ }
+
+ otlv = (struct forces_tlv *)(lfbs + 1);
+
+ indent += 1;
+ while (rlen != 0) {
+ TCHECK(*otlv);
+ invtlv = tlv_valid(otlv, rlen);
+ if (invtlv)
+ break;
+
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) {
+ otlv_print(otlv, 0, indent);
+ } else {
+ if (vflag < 3)
+ printf("\n");
+ printf
+ ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
+ EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length));
+ invoptlv_print((u_char *)otlv, rlen, 0, indent);
+ }
+ otlv = GO_NXT_TLV(otlv, rlen);
+ }
+
+ if (rlen) {
+ printf
+ ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length));
+ return -1;
+ }
+
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+int
+forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
+ register u_int mlen, const struct tom_h *tops)
+{
+ const struct forces_tlv *tltlv;
+ u_int rlen;
+ int invtlv;
+ int rc = 0;
+ int ttlv = 0;
+
+ /*
+ * forces_print() has already checked that mlen >= ForCES_HDRL
+ * by calling ForCES_HLN_VALID().
+ */
+ rlen = mlen - ForCES_HDRL;
+
+ if (rlen > TLV_HLN) {
+ if (tops->flags & ZERO_TTLV) {
+ printf("<0x%x>Illegal Top level TLV!\n", tops->flags);
+ return -1;
+ }
+ } else {
+ if (tops->flags & ZERO_MORE_TTLV)
+ return 0;
+ if (tops->flags & ONE_MORE_TTLV) {
+ printf("\tTop level TLV Data missing!\n");
+ return -1;
+ }
+ }
+
+ if (tops->flags & ZERO_TTLV) {
+ return 0;
+ }
+
+ ttlv = tops->flags >> 4;
+ tltlv = GET_TOP_TLV(pptr);
+
+ /*XXX: 15 top level tlvs will probably be fine
+ You are nuts if you send more ;-> */
+ while (rlen != 0) {
+ TCHECK(*tltlv);
+ invtlv = tlv_valid(tltlv, rlen);
+ if (invtlv)
+ break;
+
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the packet).
+ */
+ if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) {
+ printf("\n\tInvalid ForCES Top TLV type=0x%x",
+ EXTRACT_16BITS(&tltlv->type));
+ return -1;
+ }
+
+ if (vflag >= 3)
+ printf("\t%s, length %d (data length %d Bytes)",
+ tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)),
+ EXTRACT_16BITS(&tltlv->length),
+ EXTRACT_16BITS(&tltlv->length) - TLV_HDRL);
+
+ rc = tops->print((u_char *) TLV_DATA(tltlv),
+ EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9);
+ if (rc < 0) {
+ return -1;
+ }
+ tltlv = GO_NXT_TLV(tltlv, rlen);
+ ttlv--;
+ if (ttlv <= 0)
+ break;
+ }
+ /*
+ * XXX - if ttlv != 0, does that mean that the packet was too
+ * short, and didn't have *enough* TLVs in it?
+ */
+ if (rlen) {
+ printf("\tMess TopTLV header: min %u, total %d advertised %d ",
+ TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length));
+ return -1;
+ }
+
+ return 0;
+
+trunc:
+ fputs("[|forces]", stdout);
+ return -1;
+}
+
+void forces_print(register const u_char * pptr, register u_int len)
+{
+ const struct forcesh *fhdr;
+ u_int mlen;
+ u_int32_t flg_raw;
+ const struct tom_h *tops;
+ int rc = 0;
+
+ fhdr = (const struct forcesh *)pptr;
+ TCHECK(*fhdr);
+ if (!tom_valid(fhdr->fm_tom)) {
+ printf("Invalid ForCES message type %d\n", fhdr->fm_tom);
+ goto error;
+ }
+
+ mlen = ForCES_BLN(fhdr);
+
+ tops = get_forces_tom(fhdr->fm_tom);
+ if (tops->v == TOM_RSVD) {
+ printf("\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom);
+ goto error;
+ }
+
+ printf("\n\tForCES %s ", tops->s);
+ if (!ForCES_HLN_VALID(mlen, len)) {
+ printf
+ ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
+ ForCES_HDRL, len, ForCES_BLN(fhdr));
+ goto error;
+ }
+
+ TCHECK2(*(pptr + 20), 4);
+ flg_raw = EXTRACT_32BITS(pptr + 20);
+ if (vflag >= 1) {
+ printf("\n\tForCES Version %d len %uB flags 0x%08x ",
+ ForCES_V(fhdr), mlen, flg_raw);
+ printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIu64,
+ ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)),
+ ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)),
+ EXTRACT_64BITS(fhdr->fm_cor));
+
+ }
+ if (vflag >= 2) {
+ printf
+ ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
+ ForCES_ACKp(ForCES_ACK(fhdr)), ForCES_ACK(fhdr),
+ ForCES_PRI(fhdr),
+ ForCES_EMp(ForCES_EM(fhdr)), ForCES_EM(fhdr),
+ ForCES_ATp(ForCES_AT(fhdr)), ForCES_AT(fhdr),
+ ForCES_TPp(ForCES_TP(fhdr)), ForCES_TP(fhdr));
+ printf
+ ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
+ ForCES_RS1(fhdr), ForCES_RS2(fhdr));
+ }
+ rc = forces_type_print(pptr, fhdr, mlen, tops);
+ if (rc < 0) {
+error:
+ hex_print_with_offset("\n\t[", pptr, len, 0);
+ printf("\n\t]");
+ return;
+ }
+
+ if (vflag >= 4) {
+ printf("\n\t Raw ForCES message\n\t [");
+ hex_print_with_offset("\n\t ", pptr, len, 0);
+ printf("\n\t ]");
+ }
+ printf("\n");
+ return;
+
+trunc:
+ fputs("[|forces]", stdout);
+}
diff --git a/print-fr.c b/print-fr.c
index f71aee665273..8f1409e98592 100644
--- a/print-fr.c
+++ b/print-fr.c
@@ -256,11 +256,10 @@ fr_print(register const u_char *p, u_int length)
if (eflag)
fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
- if (ether_encap_print(extracted_ethertype,
+ if (ethertype_print(extracted_ethertype,
p+addr_len+ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
- length-addr_len-ETHERTYPE_LEN,
- &extracted_ethertype) == 0)
+ length-addr_len-ETHERTYPE_LEN) == 0)
/* ether_type not known, probably it wasn't one */
printf("UI %02x! ", p[addr_len]);
else
@@ -297,7 +296,7 @@ fr_print(register const u_char *p, u_int length)
break;
case NLPID_SNAP:
- if (snap_print(p, length, length, &extracted_ethertype, 0) == 0) {
+ if (snap_print(p, length, length, 0) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
fr_hdr_print(length + hdr_len, hdr_len,
diff --git a/print-gre.c b/print-gre.c
index 55f0e9d16b33..106e6fd3111a 100644
--- a/print-gre.c
+++ b/print-gre.c
@@ -225,6 +225,9 @@ gre_print_0(const u_char *bp, u_int length)
case ETHERTYPE_GRE_ISO:
isoclns_print(bp, len, len);
break;
+ case ETHERTYPE_TEB:
+ ether_print(bp, len, len, NULL, NULL);
+ break;
default:
printf("gre-proto-0x%x", prot);
}
diff --git a/print-icmp6.c b/print-icmp6.c
index 41d56b68da84..cc486150e32c 100644
--- a/print-icmp6.c
+++ b/print-icmp6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.85.2.1 2008-02-05 19:36:58 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -62,6 +62,9 @@ static void icmp6_rrenum_print(const u_char *, const u_char *);
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
+/* inline the various RPL definitions */
+#define ND_RPL_MESSAGE 0x9B
+
static struct tok icmp6_type_values[] = {
{ ICMP6_DST_UNREACH, "destination unreachable"},
{ ICMP6_PACKET_TOO_BIG, "packet too big"},
@@ -91,6 +94,7 @@ static struct tok icmp6_type_values[] = {
{ ICMP6_NI_REPLY, "node information reply"},
{ MLD6_MTRACE, "mtrace message"},
{ MLD6_MTRACE_RESP, "mtrace response"},
+ { ND_RPL_MESSAGE, "RPL"},
{ 0, NULL }
};
@@ -131,6 +135,7 @@ static struct tok icmp6_opt_values[] = {
{ ND_OPT_PREFIX_INFORMATION, "prefix info"},
{ ND_OPT_REDIRECTED_HEADER, "redirected header"},
{ ND_OPT_MTU, "mtu"},
+ { ND_OPT_RDNSS, "rdnss"},
{ ND_OPT_ADVINTERVAL, "advertisement interval"},
{ ND_OPT_HOMEAGENT_INFO, "homeagent information"},
{ ND_OPT_ROUTE_INFO, "route info"},
@@ -232,8 +237,87 @@ static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
return (sum);
}
+enum ND_RPL_CODE {
+ ND_RPL_DAG_IS=0x01,
+ ND_RPL_DAG_IO=0x02,
+ ND_RPL_DAO =0x04
+};
+
+enum ND_RPL_DIO_FLAGS {
+ ND_RPL_DIO_GROUNDED = 0x80,
+ ND_RPL_DIO_DATRIG = 0x40,
+ ND_RPL_DIO_DASUPPORT= 0x20,
+ ND_RPL_DIO_RES4 = 0x10,
+ ND_RPL_DIO_RES3 = 0x08,
+ ND_RPL_DIO_PRF_MASK = 0x07, /* 3-bit preference */
+};
+
+struct nd_rpl_dio {
+ u_int8_t rpl_flags;
+ u_int8_t rpl_seq;
+ u_int8_t rpl_instanceid;
+ u_int8_t rpl_dagrank;
+ u_int8_t rpl_dagid[16];
+};
+
+static void
+rpl_print(netdissect_options *ndo,
+ const struct icmp6_hdr *hdr,
+ const u_char *bp, u_int length _U_)
+{
+ struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
+
+ ND_TCHECK(dio->rpl_dagid);
+
+ switch(hdr->icmp6_code) {
+ case ND_RPL_DAG_IS:
+ ND_PRINT((ndo, ", DAG Information Solicitation"));
+ if(ndo->ndo_vflag) {
+ }
+ break;
+ case ND_RPL_DAG_IO:
+ ND_PRINT((ndo, ", DAG Information Object"));
+ if(ndo->ndo_vflag) {
+ char dagid[65];
+ char *d = dagid;
+ int i;
+ for(i=0;i<16;i++) {
+ if(isprint(dio->rpl_dagid[i])) {
+ *d++ = dio->rpl_dagid[i];
+ } else {
+ int cnt=snprintf(d,4,"0x%02x",
+ dio->rpl_dagid[i]);
+ d += cnt;
+ }
+ }
+ *d++ = '\0';
+ ND_PRINT((ndo, " [seq:%u,instance:%u,rank:%u,dagid:%s]",
+ dio->rpl_seq,
+ dio->rpl_instanceid,
+ dio->rpl_dagrank,
+ dagid));
+ }
+ break;
+ case ND_RPL_DAO:
+ ND_PRINT((ndo, ", Destination Advertisement Object"));
+ if(ndo->ndo_vflag) {
+ }
+ break;
+ default:
+ ND_PRINT((ndo, ", RPL message, unknown code %u",hdr->icmp6_code));
+ break;
+ }
+ return;
+trunc:
+ ND_PRINT((ndo," [|truncated]"));
+ return;
+
+}
+
+
void
-icmp6_print(const u_char *bp, u_int length, const u_char *bp2, int fragmented)
+icmp6_print(netdissect_options *ndo,
+ const u_char *bp, u_int length, const u_char *bp2, int fragmented)
{
const struct icmp6_hdr *dp;
const struct ip6_hdr *ip;
@@ -505,6 +589,9 @@ icmp6_print(const u_char *bp, u_int length, const u_char *bp2, int fragmented)
length - MPADVLEN);
}
break;
+ case ND_RPL_MESSAGE:
+ rpl_print(ndo, dp, &dp->icmp6_data8[0], length);
+ break;
default:
printf(", length %u", length);
if (vflag <= 1)
@@ -600,12 +687,14 @@ icmp6_opt_print(const u_char *bp, int resid)
const struct nd_opt_prefix_info *opp;
const struct icmp6_opts_redirect *opr;
const struct nd_opt_mtu *opm;
+ const struct nd_opt_rdnss *oprd;
const struct nd_opt_advinterval *opa;
const struct nd_opt_homeagent_info *oph;
const struct nd_opt_route_info *opri;
const u_char *cp, *ep;
struct in6_addr in6, *in6p;
size_t l;
+ u_int i;
#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
@@ -664,6 +753,17 @@ icmp6_opt_print(const u_char *bp, int resid)
EXTRACT_32BITS(&opm->nd_opt_mtu_mtu),
(op->nd_opt_len != 1) ? "bad option length" : "" );
break;
+ case ND_OPT_RDNSS:
+ oprd = (struct nd_opt_rdnss *)op;
+ l = (op->nd_opt_len - 1) / 2;
+ printf(" lifetime %us,",
+ EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime));
+ for (i = 0; i < l; i++) {
+ TCHECK(oprd->nd_opt_rdnss_addr[i]);
+ printf(" addr: %s",
+ ip6addr_string(&oprd->nd_opt_rdnss_addr[i]));
+ }
+ break;
case ND_OPT_ADVINTERVAL:
opa = (struct nd_opt_advinterval *)op;
TCHECK(opa->nd_opt_adv_interval);
@@ -753,7 +853,7 @@ mldv2_report_print(const u_char *bp, u_int len)
}
TCHECK(icp->icmp6_data16[1]);
- ngroups = ntohs(icp->icmp6_data16[1]);
+ ngroups = EXTRACT_16BITS(&icp->icmp6_data16[1]);
printf(", %d group record(s)", ngroups);
if (vflag > 0) {
/* Print the group records */
@@ -812,7 +912,7 @@ mldv2_query_print(const u_char *bp, u_int len)
return;
}
TCHECK(icp->icmp6_data16[0]);
- mrc = ntohs(icp->icmp6_data16[0]);
+ mrc = EXTRACT_16BITS(&icp->icmp6_data16[0]);
if (mrc < 32768) {
mrt = mrc;
} else {
@@ -841,7 +941,7 @@ mldv2_query_print(const u_char *bp, u_int len)
}
TCHECK2(bp[26], 2);
- nsrcs = ntohs(*(u_short *)&bp[26]);
+ nsrcs = EXTRACT_16BITS(&bp[26]);
if (nsrcs > 0) {
if (len < 28 + nsrcs * sizeof(struct in6_addr))
printf(" [invalid number of sources]");
@@ -863,7 +963,7 @@ trunc:
return;
}
-void
+static void
dnsname_print(const u_char *cp, const u_char *ep)
{
int i;
diff --git a/print-ip.c b/print-ip.c
index 8bdf5ebce3e2..acf3bd8be9fe 100644
--- a/print-ip.c
+++ b/print-ip.c
@@ -508,7 +508,8 @@ again:
break;
case IPPROTO_PIM:
- pim_print(ipds->cp, ipds->len);
+ pim_print(ipds->cp, ipds->len,
+ in_cksum((const u_short*)ipds->cp, ipds->len, 0));
break;
case IPPROTO_VRRP:
@@ -657,7 +658,7 @@ ip_print(netdissect_options *ndo,
printf(")");
}
- if ((u_char *)ipds->ip + hlen <= snapend) {
+ if (!Kflag && (u_char *)ipds->ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
if (sum != 0) {
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
diff --git a/print-ip6.c b/print-ip6.c
index 0758bb952ed0..1599cf28b60f 100644
--- a/print-ip6.c
+++ b/print-ip6.c
@@ -36,6 +36,7 @@ static const char rcsid[] _U_ =
#include <stdlib.h>
#include <string.h>
+#include "netdissect.h"
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -44,6 +45,31 @@ static const char rcsid[] _U_ =
#include "ipproto.h"
/*
+ * Compute a V6-style checksum by building a pseudoheader.
+ */
+int
+nextproto6_cksum(const struct ip6_hdr *ip6, const u_short *data,
+ u_int len, u_int next_proto)
+{
+ size_t i;
+ u_int32_t sum = 0;
+ union ip6_pseudo_hdr phu;
+
+ /* pseudo-header */
+ memset(&phu, 0, sizeof(phu));
+ phu.ph.ph_src = ip6->ip6_src;
+ phu.ph.ph_dst = ip6->ip6_dst;
+ phu.ph.ph_len = htonl(len);
+ phu.ph.ph_nxt = next_proto;
+
+ for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) {
+ sum += phu.pa[i];
+ }
+
+ return in_cksum(data, len, sum);
+}
+
+/*
* print an IP6 datagram.
*/
void
@@ -170,7 +196,7 @@ ip6_print(register const u_char *bp, register u_int length)
udp_print(cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_ICMPV6:
- icmp6_print(cp, len, (const u_char *)ip6, fragmented);
+ icmp6_print(gndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_AH:
advance = ah_print(cp);
@@ -193,7 +219,8 @@ ip6_print(register const u_char *bp, register u_int length)
}
case IPPROTO_PIM:
- pim_print(cp, len);
+ pim_print(cp, len, nextproto6_cksum(ip6, (u_short *)cp, len,
+ IPPROTO_PIM));
return;
case IPPROTO_OSPF:
diff --git a/print-ipnet.c b/print-ipnet.c
new file mode 100644
index 000000000000..957bd4f52341
--- /dev/null
+++ b/print-ipnet.c
@@ -0,0 +1,109 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <pcap.h>
+
+#include "netdissect.h"
+#include "interface.h"
+#include "addrtoname.h"
+#include "ipnet.h"
+
+#ifdef DLT_IPNET
+
+const struct tok ipnet_values[] = {
+ { IPH_AF_INET, "IPv4" },
+ { IPH_AF_INET6, "IPv6" },
+ { 0, NULL }
+};
+
+static inline void
+ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
+{
+ const ipnet_hdr_t *hdr;
+ hdr = (const ipnet_hdr_t *)bp;
+
+ ND_PRINT((ndo, "%d > %d", hdr->iph_zsrc, hdr->iph_zdst));
+
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo,", family %s (%d)",
+ tok2str(ipnet_values, "Unknown",
+ hdr->iph_family),
+ hdr->iph_family));
+ } else {
+ ND_PRINT((ndo,", %s",
+ tok2str(ipnet_values,
+ "Unknown Ethertype (0x%04x)",
+ hdr->iph_family)));
+ }
+
+ ND_PRINT((ndo, ", length %u: ", length));
+}
+
+static void
+ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
+{
+ ipnet_hdr_t *hdr;
+
+ if (caplen < sizeof(ipnet_hdr_t)) {
+ ND_PRINT((ndo, "[|ipnet]"));
+ return;
+ }
+
+ if (ndo->ndo_eflag)
+ ipnet_hdr_print(ndo, p, length);
+
+ length -= sizeof(ipnet_hdr_t);
+ caplen -= sizeof(ipnet_hdr_t);
+ hdr = (ipnet_hdr_t *)p;
+ p += sizeof(ipnet_hdr_t);
+
+ switch (hdr->iph_family) {
+
+ case IPH_AF_INET:
+ ip_print(ndo, p, length);
+ break;
+
+#ifdef INET6
+ case IPH_AF_INET6:
+ ip6_print(p, length);
+ break;
+#endif /*INET6*/
+
+ default:
+ if (!ndo->ndo_eflag)
+ ipnet_hdr_print(ndo, (u_char *)hdr,
+ length + sizeof(ipnet_hdr_t));
+
+ if (!ndo->ndo_suppress_default_print)
+ ndo->ndo_default_print(ndo, p, caplen);
+ break;
+ }
+}
+
+/*
+ * This is the top level routine of the printer. 'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+ipnet_if_print(struct netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
+{
+ ipnet_print(ndo, p, h->len, h->caplen);
+
+ return (sizeof(ipnet_hdr_t));
+}
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+
+#endif /* DLT_IPNET */
diff --git a/print-isakmp.c b/print-isakmp.c
index 763f58aa5eb2..4f96afe38115 100644
--- a/print-isakmp.c
+++ b/print-isakmp.c
@@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.56 2007-08-29 12:31:00 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp $ (LBL)";
#endif
#define NETDISSECT_REWORKED
@@ -94,16 +94,27 @@ DECLARE_PRINTER(v2_n);
DECLARE_PRINTER(v2_d);
DECLARE_PRINTER(v2_vid);
DECLARE_PRINTER(v2_TS);
-DECLARE_PRINTER(v2_e);
DECLARE_PRINTER(v2_cp);
DECLARE_PRINTER(v2_eap);
+static const u_char *ikev2_e_print(netdissect_options *ndo,
+ struct isakmp *base,
+ u_char tpay,
+ const struct isakmp_gen *ext,
+ u_int item_len,
+ const u_char *end_pointer,
+ u_int32_t phase,
+ u_int32_t doi0,
+ u_int32_t proto0, int depth);
+
+
static const u_char *ike_sub0_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
static const u_char *ikev1_sub_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
static const u_char *ikev2_sub_print(netdissect_options *ndo,
+ struct isakmp *base,
u_char np, const struct isakmp_gen *ext,
const u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto,
@@ -185,7 +196,7 @@ static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay,
ikev2_vid_print, /* 43 */
ikev2_TS_print, /* 44 */
ikev2_TS_print, /* 45 */
- ikev2_e_print, /* 46 */
+ NULL, /* ikev2_e_print,*/ /* 46 - special */
ikev2_cp_print, /* 47 */
ikev2_eap_print, /* 48 */
};
@@ -391,22 +402,29 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
return 0;
}
-static int
-rawprint(netdissect_options *ndo, caddr_t loc, size_t len)
+static void
+hexprint(netdissect_options *ndo, caddr_t loc, size_t len)
{
- static u_char *p;
+ u_char *p;
size_t i;
- ND_TCHECK2(*loc, len);
-
p = (u_char *)loc;
for (i = 0; i < len; i++)
ND_PRINT((ndo,"%02x", p[i] & 0xff));
+}
+
+static int
+rawprint(netdissect_options *ndo, caddr_t loc, size_t len)
+{
+ ND_TCHECK2(*loc, len);
+
+ hexprint(ndo, loc, len);
return 1;
trunc:
return 0;
}
+
/*
* returns false if we run out of data buffer
*/
@@ -1495,8 +1513,9 @@ ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
safememcpy(&prop, ext, sizeof(prop));
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical);
- ND_PRINT((ndo," #%u protoid=%s transform=%d",
- prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t));
+ ND_PRINT((ndo," #%u protoid=%s transform=%d len=%u",
+ prop.p_no, PROTOIDSTR(prop.prot_id),
+ prop.num_t, ntohs(prop.h.len)));
if (prop.spi_size) {
ND_PRINT((ndo," spi="));
if (!rawprint(ndo, (caddr_t)(p + 1), prop.spi_size))
@@ -1505,8 +1524,8 @@ ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
ND_TCHECK(*ext);
-
- cp = ikev2_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
+
+ cp = ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
prop.prot_id, depth);
return cp;
@@ -1523,21 +1542,21 @@ ikev2_sa_print(netdissect_options *ndo, u_char tpay,
u_int32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
- int osa_len, sa_len;
+ int osa_length, sa_length;
ND_TCHECK(*ext1);
safememcpy(&e, ext1, sizeof(e));
ikev2_pay_print(ndo, "sa", e.critical);
- osa_len= ntohs(e.len);
- sa_len = osa_len - 4;
- ND_PRINT((ndo," len=%d", sa_len));
+ osa_length= ntohs(e.len);
+ sa_length = osa_length - 4;
+ ND_PRINT((ndo," len=%d", sa_length));
- ikev2_sub_print(ndo, ISAKMP_NPTYPE_P,
+ ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_P,
ext1+1, ep,
0, 0, 0, depth);
- return (u_char *)ext1 + osa_len;
+ return (u_char *)ext1 + osa_length;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
@@ -1579,7 +1598,79 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
u_int32_t phase _U_, u_int32_t doi _U_,
u_int32_t proto _U_, int depth _U_)
{
- return ikev2_gen_print(ndo, tpay, ext);
+ struct ikev2_id id;
+ int id_len, idtype_len, i;
+ unsigned int dumpascii, dumphex;
+ unsigned char *typedata;
+
+ ND_TCHECK(*ext);
+ safememcpy(&id, ext, sizeof(id));
+ ikev2_pay_print(ndo, NPSTR(tpay), id.h.critical);
+
+ id_len = ntohs(id.h.len);
+
+ ND_PRINT((ndo," len=%d", id_len - 4));
+ if (2 < ndo->ndo_vflag && 4 < id_len) {
+ ND_PRINT((ndo," "));
+ if (!rawprint(ndo, (caddr_t)(ext + 1), id_len - 4))
+ goto trunc;
+ }
+
+ idtype_len =id_len - sizeof(struct ikev2_id);
+ dumpascii = 0;
+ dumphex = 0;
+ typedata = (unsigned char *)(ext)+sizeof(struct ikev2_id);
+
+ switch(id.type) {
+ case ID_IPV4_ADDR:
+ ND_PRINT((ndo, " ipv4:"));
+ dumphex=1;
+ break;
+ case ID_FQDN:
+ ND_PRINT((ndo, " fqdn:"));
+ dumpascii=1;
+ break;
+ case ID_RFC822_ADDR:
+ ND_PRINT((ndo, " rfc822:"));
+ dumpascii=1;
+ break;
+ case ID_IPV6_ADDR:
+ ND_PRINT((ndo, " ipv6:"));
+ dumphex=1;
+ break;
+ case ID_DER_ASN1_DN:
+ ND_PRINT((ndo, " dn:"));
+ dumphex=1;
+ break;
+ case ID_DER_ASN1_GN:
+ ND_PRINT((ndo, " gn:"));
+ dumphex=1;
+ break;
+ case ID_KEY_ID:
+ ND_PRINT((ndo, " keyid:"));
+ dumphex=1;
+ break;
+ }
+
+ if(dumpascii) {
+ ND_TCHECK2(*typedata, idtype_len);
+ for(i=0; i<idtype_len; i++) {
+ if(isprint(typedata[i])) {
+ ND_PRINT((ndo, "%c", typedata[i]));
+ } else {
+ ND_PRINT((ndo, "."));
+ }
+ }
+ }
+ if(dumphex) {
+ if (!rawprint(ndo, (caddr_t)typedata, idtype_len))
+ goto trunc;
+ }
+
+ return (u_char *)ext + id_len;
+trunc:
+ ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
+ return NULL;
}
static const u_char *
@@ -1609,27 +1700,30 @@ ikev2_auth_print(netdissect_options *ndo, u_char tpay,
u_int32_t phase _U_, u_int32_t doi _U_,
u_int32_t proto _U_, int depth _U_)
{
- struct ikev2_auth e;
+ struct ikev2_auth a;
const char *v2_auth[]={ "invalid", "rsasig",
"shared-secret", "dsssig" };
+ u_char *authdata = (u_char*)ext + sizeof(a);
+ unsigned int len;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
- ikev2_pay_print(ndo, NPSTR(tpay), e.h.critical);
+ safememcpy(&a, ext, sizeof(a));
+ ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical);
+ len = ntohs(a.h.len);
- ND_PRINT((ndo," len=%d method=%s", ntohs(e.h.len) - 4,
- STR_OR_ID(e.auth_method, v2_auth)));
+ ND_PRINT((ndo," len=%d method=%s", len-4,
+ STR_OR_ID(a.auth_method, v2_auth)));
- if (1 < ndo->ndo_vflag && 4 < ntohs(e.h.len)) {
+ if (1 < ndo->ndo_vflag && 4 < len) {
ND_PRINT((ndo," authdata=("));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.h.len) - 4))
+ if (!rawprint(ndo, (caddr_t)authdata, len - sizeof(a)))
goto trunc;
ND_PRINT((ndo,") "));
- } else if(ndo->ndo_vflag && 4 < ntohs(e.h.len)) {
- if(!ike_show_somedata(ndo, (const u_char *)(ext+1), ep)) goto trunc;
+ } else if(ndo->ndo_vflag && 4 < len) {
+ if(!ike_show_somedata(ndo, authdata, ep)) goto trunc;
}
- return (u_char *)ext + ntohs(e.h.len);
+ return (u_char *)ext + len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
@@ -1905,7 +1999,7 @@ ikev2_vid_print(netdissect_options *ndo, u_char tpay,
ND_TCHECK2(*vid, len);
for(i=0; i<len; i++) {
if(isprint(vid[i])) ND_PRINT((ndo, "%c", vid[i]));
- else ND_PRINT((ndo, ".", vid[i]));
+ else ND_PRINT((ndo, "."));
}
if (2 < ndo->ndo_vflag && 4 < len) {
ND_PRINT((ndo," "));
@@ -1929,13 +2023,74 @@ ikev2_TS_print(netdissect_options *ndo, u_char tpay,
}
static const u_char *
-ikev2_e_print(netdissect_options *ndo, u_char tpay,
- const struct isakmp_gen *ext,
- u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ikev2_e_print(netdissect_options *ndo,
+#ifndef HAVE_LIBCRYPTO
+ _U_
+#endif
+ struct isakmp *base,
+ u_char tpay,
+ const struct isakmp_gen *ext,
+ u_int item_len _U_, const u_char *ep _U_,
+#ifndef HAVE_LIBCRYPTO
+ _U_
+#endif
+ u_int32_t phase,
+#ifndef HAVE_LIBCRYPTO
+ _U_
+#endif
+ u_int32_t doi,
+#ifndef HAVE_LIBCRYPTO
+ _U_
+#endif
+ u_int32_t proto,
+#ifndef HAVE_LIBCRYPTO
+ _U_
+#endif
+ int depth)
{
- return ikev2_gen_print(ndo, tpay, ext);
+ struct isakmp_gen e;
+ u_char *dat;
+ volatile int dlen;
+
+ ND_TCHECK(*ext);
+ safememcpy(&e, ext, sizeof(e));
+ ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
+
+ dlen = ntohs(e.len)-4;
+
+ ND_PRINT((ndo," len=%d", dlen));
+ if (2 < ndo->ndo_vflag && 4 < dlen) {
+ ND_PRINT((ndo," "));
+ if (!rawprint(ndo, (caddr_t)(ext + 1), dlen))
+ goto trunc;
+ }
+
+ dat = (u_char *)(ext+1);
+ ND_TCHECK2(*dat, dlen);
+
+#ifdef HAVE_LIBCRYPTO
+ /* try to decypt it! */
+ if(esp_print_decrypt_buffer_by_ikev2(ndo,
+ base->flags & ISAKMP_FLAG_I,
+ base->i_ck, base->r_ck,
+ dat, dat+dlen)) {
+
+ ext = (const struct isakmp_gen *)ndo->ndo_packetp;
+
+ /* got it decrypted, print stuff inside. */
+ ikev2_sub_print(ndo, base, e.np, ext, ndo->ndo_snapend,
+ phase, doi, proto, depth+1);
+ }
+#endif
+
+
+ /* always return NULL, because E must be at end, and NP refers
+ * to what was inside.
+ */
+ return NULL;
+trunc:
+ ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
+ return NULL;
}
static const u_char *
@@ -1961,7 +2116,8 @@ ikev2_eap_print(netdissect_options *ndo, u_char tpay,
static const u_char *
ike_sub0_print(netdissect_options *ndo,
u_char np, const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+
+ u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
{
const u_char *cp;
struct isakmp_gen e;
@@ -2058,7 +2214,7 @@ safememcpy(void *p, const void *q, size_t l)
memcpy(p, q, l);
}
-void
+static void
ikev1_print(netdissect_options *ndo,
const u_char *bp, u_int length,
const u_char *bp2, struct isakmp *base)
@@ -2135,7 +2291,8 @@ done:
}
static const u_char *
-ikev2_sub0_print(netdissect_options *ndo, u_char np, int pcount,
+ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
+ u_char np, int pcount,
const struct isakmp_gen *ext, const u_char *ep,
u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
{
@@ -2163,6 +2320,9 @@ ikev2_sub0_print(netdissect_options *ndo, u_char np, int pcount,
} else if(np == ISAKMP_NPTYPE_T) {
cp = ikev2_t_print(ndo, np, pcount, ext, item_len,
ep, phase, doi, proto, depth);
+ } else if(np == ISAKMP_NPTYPE_v2E) {
+ cp = ikev2_e_print(ndo, base, np, ext, item_len,
+ ep, phase, doi, proto, depth);
} else if (NPFUNC(np)) {
/*
* XXX - what if item_len is too short, or too long,
@@ -2183,6 +2343,7 @@ trunc:
static const u_char *
ikev2_sub_print(netdissect_options *ndo,
+ struct isakmp *base,
u_char np, const struct isakmp_gen *ext, const u_char *ep,
u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
{
@@ -2206,7 +2367,7 @@ ikev2_sub_print(netdissect_options *ndo,
for (i = 0; i < depth; i++)
ND_PRINT((ndo," "));
ND_PRINT((ndo,"("));
- cp = ikev2_sub0_print(ndo, np, pcount,
+ cp = ikev2_sub0_print(ndo, base, np, pcount,
ext, ep, phase, doi, proto, depth);
ND_PRINT((ndo,")"));
depth--;
@@ -2246,7 +2407,7 @@ ikev2_print(netdissect_options *ndo,
ND_PRINT((ndo, " %s", ETYPESTR(base->etype)));
if (base->flags) {
- ND_PRINT((ndo, "[%s%s]",
+ ND_PRINT((ndo, "[%s%s%s]",
base->flags & ISAKMP_FLAG_I ? "I" : "",
base->flags & ISAKMP_FLAG_V ? "V" : "",
base->flags & ISAKMP_FLAG_R ? "R" : ""));
@@ -2273,7 +2434,7 @@ ikev2_print(netdissect_options *ndo,
np = base->np;
ext = (struct isakmp_gen *)(p + 1);
- ikev2_sub_print(ndo, np, ext, ep, phase, 0, 0, 0);
+ ikev2_sub_print(ndo, base, np, ext, ep, phase, 0, 0, 0);
}
done:
@@ -2295,6 +2456,14 @@ isakmp_print(netdissect_options *ndo,
const u_char *ep;
int major, minor;
+#ifdef HAVE_LIBCRYPTO
+ /* initialize SAs */
+ if (ndo->ndo_sa_list_head == NULL) {
+ if (ndo->ndo_espsecret)
+ esp_print_decodesecret(ndo);
+ }
+#endif
+
p = (const struct isakmp *)bp;
ep = ndo->ndo_snapend;
@@ -2317,14 +2486,14 @@ isakmp_print(netdissect_options *ndo,
if (ndo->ndo_vflag) {
ND_PRINT((ndo," msgid "));
- rawprint(ndo, (caddr_t)&base.msgid, sizeof(base.msgid));
+ hexprint(ndo, (caddr_t)&base.msgid, sizeof(base.msgid));
}
if (1 < ndo->ndo_vflag) {
ND_PRINT((ndo," cookie "));
- rawprint(ndo, (caddr_t)&base.i_ck, sizeof(base.i_ck));
+ hexprint(ndo, (caddr_t)&base.i_ck, sizeof(base.i_ck));
ND_PRINT((ndo,"->"));
- rawprint(ndo, (caddr_t)&base.r_ck, sizeof(base.r_ck));
+ hexprint(ndo, (caddr_t)&base.r_ck, sizeof(base.r_ck));
}
ND_PRINT((ndo,":"));
diff --git a/print-isoclns.c b/print-isoclns.c
index 4f8c347b8113..ea58d8a3d098 100644
--- a/print-isoclns.c
+++ b/print-isoclns.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.163 2007-03-02 09:16:19 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.165 2008-08-16 13:38:15 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -46,6 +46,7 @@ static const char rcsid[] _U_ =
#include "extract.h"
#include "gmpls.h"
#include "oui.h"
+#include "signature.h"
/*
* IS-IS is defined in ISO 10589. Look there for protocol definitions.
@@ -1764,7 +1765,7 @@ static int isis_print (const u_int8_t *p, u_int length)
const struct isis_iih_lan_header *header_iih_lan;
const struct isis_iih_ptp_header *header_iih_ptp;
- const struct isis_lsp_header *header_lsp;
+ struct isis_lsp_header *header_lsp;
const struct isis_csnp_header *header_csnp;
const struct isis_psnp_header *header_psnp;
@@ -1778,16 +1779,18 @@ static int isis_print (const u_int8_t *p, u_int length)
const u_int8_t *optr, *pptr, *tptr;
u_short packet_len,pdu_len;
u_int i,vendor_id;
+ int sigcheck;
packet_len=length;
optr = p; /* initialize the _o_riginal pointer to the packet start -
- need it for parsing the checksum TLV */
+ need it for parsing the checksum TLV and authentication
+ TLV verification */
isis_header = (const struct isis_common_header *)p;
TCHECK(*isis_header);
pptr = p+(ISIS_COMMON_HEADER_SIZE);
header_iih_lan = (const struct isis_iih_lan_header *)pptr;
header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
- header_lsp = (const struct isis_lsp_header *)pptr;
+ header_lsp = (struct isis_lsp_header *)pptr;
header_csnp = (const struct isis_csnp_header *)pptr;
header_psnp = (const struct isis_psnp_header *)pptr;
@@ -2013,6 +2016,15 @@ static int isis_print (const u_int8_t *p, u_int length)
osi_print_cksum((u_int8_t *)header_lsp->lsp_id,
EXTRACT_16BITS(header_lsp->checksum), 12, length-12);
+ /*
+ * Clear checksum and lifetime prior to signature verification.
+ */
+ header_lsp->checksum[0] = 0;
+ header_lsp->checksum[1] = 0;
+ header_lsp->remaining_lifetime[0] = 0;
+ header_lsp->remaining_lifetime[1] = 0;
+
+
printf(", PDU length: %u, Flags: [ %s",
pdu_len,
ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "");
@@ -2188,13 +2200,12 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_MT_IS_REACH:
+ mt_len = isis_print_mtid(tptr, "\n\t ");
+ if (mt_len == 0) /* did something go wrong ? */
+ goto trunctlv;
+ tptr+=mt_len;
+ tmp-=mt_len;
while (tmp >= 2+NODE_ID_LEN+3+1) {
- mt_len = isis_print_mtid(tptr, "\n\t ");
- if (mt_len == 0) /* did something go wrong ? */
- goto trunctlv;
- tptr+=mt_len;
- tmp-=mt_len;
-
ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
goto trunctlv;
@@ -2355,6 +2366,15 @@ static int isis_print (const u_int8_t *p, u_int length)
}
if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
printf(", (malformed subTLV) ");
+
+#ifdef HAVE_LIBCRYPTO
+ sigcheck = signature_verify(optr, length,
+ (unsigned char *)tptr + 1);
+#else
+ sigcheck = CANT_CHECK_SIGNATURE;
+#endif
+ printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+
break;
case ISIS_SUBTLV_AUTH_PRIVATE:
default:
diff --git a/print-juniper.c b/print-juniper.c
index 08a929f1e269..55ca1c9c6405 100644
--- a/print-juniper.c
+++ b/print-juniper.c
@@ -647,7 +647,7 @@ juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p)
p+=l2info.header_len;
/* this DLT contains nothing but raw ethernet frames */
- ether_print(p, l2info.length, l2info.caplen);
+ ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
@@ -664,7 +664,7 @@ juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p)
p+=l2info.header_len;
/* this DLT contains nothing but raw Ethernet frames */
- ether_print(p, l2info.length, l2info.caplen);
+ ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
@@ -736,11 +736,10 @@ juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
extracted_ethertype = EXTRACT_16BITS(p);
/* this DLT contains nothing but raw PPPoE frames,
* prepended with a type field*/
- if (ether_encap_print(extracted_ethertype,
+ if (ethertype_print(extracted_ethertype,
p+ETHERTYPE_LEN,
l2info.length-ETHERTYPE_LEN,
- l2info.caplen-ETHERTYPE_LEN,
- &extracted_ethertype) == 0)
+ l2info.caplen-ETHERTYPE_LEN) == 0)
/* ether_type not known, probably it wasn't one */
printf("unknown ethertype 0x%04x", extracted_ethertype);
@@ -988,7 +987,7 @@ juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
- ether_print(p, l2info.length, l2info.caplen);
+ ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
diff --git a/print-l2tp.c b/print-l2tp.c
index 55c2125174ee..2f726574e4ee 100644
--- a/print-l2tp.c
+++ b/print-l2tp.c
@@ -606,7 +606,7 @@ l2tp_avp_print(const u_char *dat, int length)
void
l2tp_print(const u_char *dat, u_int length)
{
- const u_int16_t *ptr = (u_int16_t *)dat;
+ const u_char *ptr = dat;
u_int cnt = 0; /* total octets consumed */
u_int16_t pad;
int flag_t, flag_l, flag_s, flag_o;
@@ -614,7 +614,7 @@ l2tp_print(const u_char *dat, u_int length)
flag_t = flag_l = flag_s = flag_o = FALSE;
- TCHECK(*ptr); /* Flags & Version */
+ TCHECK2(*ptr, 2); /* Flags & Version */
if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
printf(" l2tp:");
} else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
@@ -646,37 +646,42 @@ l2tp_print(const u_char *dat, u_int length)
printf("P");
printf("]");
- ptr++;
+ ptr += 2;
cnt += 2;
if (flag_l) {
- TCHECK(*ptr); /* Length */
- l2tp_len = EXTRACT_16BITS(ptr); ptr++;
+ TCHECK2(*ptr, 2); /* Length */
+ l2tp_len = EXTRACT_16BITS(ptr);
+ ptr += 2;
cnt += 2;
} else {
l2tp_len = 0;
}
- TCHECK(*ptr); /* Tunnel ID */
- printf("(%u/", EXTRACT_16BITS(ptr)); ptr++;
+ TCHECK2(*ptr, 2); /* Tunnel ID */
+ printf("(%u/", EXTRACT_16BITS(ptr));
+ ptr += 2;
cnt += 2;
- TCHECK(*ptr); /* Session ID */
- printf("%u)", EXTRACT_16BITS(ptr)); ptr++;
+ TCHECK2(*ptr, 2); /* Session ID */
+ printf("%u)", EXTRACT_16BITS(ptr));
+ ptr += 2;
cnt += 2;
if (flag_s) {
- TCHECK(*ptr); /* Ns */
- printf("Ns=%u,", EXTRACT_16BITS(ptr)); ptr++;
+ TCHECK2(*ptr, 2); /* Ns */
+ printf("Ns=%u,", EXTRACT_16BITS(ptr));
+ ptr += 2;
cnt += 2;
- TCHECK(*ptr); /* Nr */
- printf("Nr=%u", EXTRACT_16BITS(ptr)); ptr++;
+ TCHECK2(*ptr, 2); /* Nr */
+ printf("Nr=%u", EXTRACT_16BITS(ptr));
+ ptr += 2;
cnt += 2;
}
if (flag_o) {
- TCHECK(*ptr); /* Offset Size */
- pad = EXTRACT_16BITS(ptr); ptr++;
- ptr += pad / sizeof(*ptr);
+ TCHECK2(*ptr, 2); /* Offset Size */
+ pad = EXTRACT_16BITS(ptr);
+ ptr += (2 + pad);
cnt += (2 + pad);
}
@@ -699,11 +704,11 @@ l2tp_print(const u_char *dat, u_int length)
if (length - cnt == 0) {
printf(" ZLB");
} else {
- l2tp_avp_print((u_char *)ptr, length - cnt);
+ l2tp_avp_print(ptr, length - cnt);
}
} else {
printf(" {");
- ppp_print((u_char *)ptr, length - cnt);
+ ppp_print(ptr, length - cnt);
printf("}");
}
diff --git a/print-lane.c b/print-lane.c
index 33723aaa4751..54c68c82aa2b 100644
--- a/print-lane.c
+++ b/print-lane.c
@@ -60,25 +60,10 @@ static const struct tok lecop2str[] = {
{ 0, NULL }
};
-static inline void
-lane_hdr_print(register const u_char *bp, int length)
+static void
+lane_hdr_print(const u_char *bp)
{
- register const struct lecdatahdr_8023 *ep;
-
- ep = (const struct lecdatahdr_8023 *)bp;
- if (qflag)
- (void)printf("lecid:%x %s %s %d: ",
- EXTRACT_16BITS(&ep->le_header),
- etheraddr_string(ep->h_source),
- etheraddr_string(ep->h_dest),
- length);
- else
- (void)printf("lecid:%x %s %s %s %d: ",
- EXTRACT_16BITS(&ep->le_header),
- etheraddr_string(ep->h_source),
- etheraddr_string(ep->h_dest),
- etherproto_string(ep->h_type),
- length);
+ (void)printf("lecid:%x ", EXTRACT_16BITS(bp));
}
/*
@@ -93,9 +78,6 @@ void
lane_print(const u_char *p, u_int length, u_int caplen)
{
struct lane_controlhdr *lec;
- struct lecdatahdr_8023 *ep;
- u_short ether_type;
- u_short extracted_ethertype;
if (caplen < sizeof(struct lane_controlhdr)) {
printf("[|lane]");
@@ -113,49 +95,18 @@ lane_print(const u_char *p, u_int length, u_int caplen)
return;
}
- if (caplen < sizeof(struct lecdatahdr_8023)) {
- printf("[|lane]");
- return;
- }
-
- if (eflag)
- lane_hdr_print(p, length);
-
/*
- * Go past the LANE header.
+ * Go past the LE header.
*/
- length -= sizeof(struct lecdatahdr_8023);
- caplen -= sizeof(struct lecdatahdr_8023);
- ep = (struct lecdatahdr_8023 *)p;
- p += sizeof(struct lecdatahdr_8023);
-
- ether_type = EXTRACT_16BITS(&ep->h_type);
+ length -= 2;
+ caplen -= 2;
+ p += 2;
/*
- * Is it (gag) an 802.3 encapsulation?
+ * Now print the encapsulated frame, under the assumption
+ * that it's an Ethernet frame.
*/
- if (ether_type <= ETHERMTU) {
- /* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ep->h_source, ep->h_dest,
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- lane_hdr_print((u_char *)ep, length + sizeof(*ep));
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!suppress_default_print)
- 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)
- lane_hdr_print((u_char *)ep, length + sizeof(*ep));
- if (!suppress_default_print)
- default_print(p, caplen);
- }
+ ether_print(p, length, caplen, lane_hdr_print, p - 2);
}
u_int
diff --git a/print-llc.c b/print-llc.c
index 0c8259fbb6b8..d20fbdf13c36 100644
--- a/print-llc.c
+++ b/print-llc.c
@@ -309,8 +309,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* Does anybody ever bridge one form of LAN traffic
* over a networking type that uses 802.2 LLC?
*/
- ret = snap_print(p+3, length-3, caplen-3, extracted_ethertype,
- 2);
+ ret = snap_print(p+3, length-3, caplen-3, 2);
if (ret)
return (ret);
}
@@ -378,8 +377,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
int
-snap_print(const u_char *p, u_int length, u_int caplen,
- u_short *extracted_ethertype, u_int bridge_pad)
+snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
{
u_int32_t orgcode;
register u_short et;
@@ -419,8 +417,7 @@ snap_print(const u_char *p, u_int length, u_int caplen,
* Cisco hardware; the protocol ID is
* an Ethernet protocol type.
*/
- ret = ether_encap_print(et, p, length, caplen,
- extracted_ethertype);
+ ret = ethertype_print(et, p, length, caplen);
if (ret)
return (ret);
break;
@@ -435,8 +432,7 @@ snap_print(const u_char *p, u_int length, u_int caplen,
* but used 0x000000 and an Ethernet
* packet type for AARP packets.
*/
- ret = ether_encap_print(et, p, length, caplen,
- extracted_ethertype);
+ ret = ethertype_print(et, p, length, caplen);
if (ret)
return (ret);
}
@@ -483,7 +479,7 @@ snap_print(const u_char *p, u_int length, u_int caplen,
/*
* What remains is an Ethernet packet.
*/
- ether_print(p, length, caplen);
+ ether_print(p, length, caplen, NULL, NULL);
return (1);
case PID_RFC2684_802_5_FCS:
diff --git a/print-lldp.c b/print-lldp.c
index 36b99343ec82..e8f67fd23a53 100644
--- a/print-lldp.c
+++ b/print-lldp.c
@@ -20,7 +20,7 @@
#ifndef lint
static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.7.2.3 2008-03-20 09:33:52 hannes Exp $";
+"@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
#endif
#ifdef HAVE_CONFIG_H
diff --git a/print-lspping.c b/print-lspping.c
index f47a9004859c..6958bdac7e73 100644
--- a/print-lspping.c
+++ b/print-lspping.c
@@ -15,7 +15,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.18.2.1 2008-01-28 13:48:16 hannes Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.20 2008-01-28 14:20:43 hannes Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,6 +34,7 @@ static const char rcsid[] _U_ =
#include "bgp.h"
#include "l2vpn.h"
+#include "oui.h"
/*
* LSPPING common header
@@ -134,7 +135,11 @@ struct lspping_tlv_header {
#define LSPPING_TLV_TARGET_FEC_STACK 1
#define LSPPING_TLV_DOWNSTREAM_MAPPING 2
#define LSPPING_TLV_PAD 3
-#define LSPPING_TLV_ERROR_CODE 4
+#define LSPPING_TLV_VENDOR_ENTERPRISE 5
+#define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
+#define LSPPING_TLV_INTERFACE_LABEL_STACK 7
+#define LSPPING_TLV_ERROR_CODE 9
+#define LSPPING_TLV_REPLY_TOS_BYTE 10
#define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
#define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
#define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
@@ -144,8 +149,11 @@ static const struct tok lspping_tlv_values[] = {
{ LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },
{ LSPPING_TLV_PAD, "Pad" },
{ LSPPING_TLV_ERROR_CODE, "Error Code" },
+ { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" },
+ { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" },
+ { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" },
{ LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" },
- { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Enterprise Code" },
+ { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" },
{ 0, NULL}
};
@@ -566,6 +574,7 @@ lspping_print(register const u_char *pptr, register u_int len) {
tlen-=sizeof(const struct lspping_common_header);
while(tlen>(int)sizeof(struct lspping_tlv_header)) {
+
/* did we capture enough for fully decoding the tlv header ? */
if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
goto trunc;
@@ -840,11 +849,24 @@ lspping_print(register const u_char *pptr, register u_int len) {
goto trunc;
printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr));
break;
+
+ case LSPPING_TLV_VENDOR_ENTERPRISE:
+ {
+ u_int32_t vendor_id;
+
+ if (!TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN))
+ goto trunc;
+ vendor_id = EXTRACT_32BITS(tlv_tptr);
+ printf("\n\t Vendor: %s (0x%04x)",
+ tok2str(smi_values, "Unknown", vendor_id),
+ vendor_id);
+ }
+ break;
+
/*
* FIXME those are the defined TLVs that lack a decoder
* you are welcome to contribute code ;-)
*/
-
case LSPPING_TLV_PAD:
case LSPPING_TLV_ERROR_CODE:
case LSPPING_TLV_VENDOR_PRIVATE:
diff --git a/print-nfs.c b/print-nfs.c
index fb09e30843e6..4d17757f3114 100644
--- a/print-nfs.c
+++ b/print-nfs.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.110.2.1 2007-12-22 03:08:45 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.111 2007-12-22 03:08:04 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -508,6 +508,7 @@ nfsreq_print(register const u_char *bp, u_int length,
nfs_type type;
int v3;
u_int32_t proc;
+ u_int32_t access_flags;
struct nfsv3_sattr sa3;
char srcid[20], dstid[20]; /*fits 32bit*/
@@ -570,7 +571,37 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
TCHECK(dp[0]);
- printf(" %04x", EXTRACT_32BITS(&dp[0]));
+ access_flags = EXTRACT_32BITS(&dp[0]);
+ if (access_flags & ~NFSV3ACCESS_FULL) {
+ /* NFSV3ACCESS definitions aren't up to date */
+ printf(" %04x", access_flags);
+ } else if ((access_flags & NFSV3ACCESS_FULL) == NFSV3ACCESS_FULL) {
+ printf(" NFS_ACCESS_FULL");
+ } else {
+ char separator = ' ';
+ if (access_flags & NFSV3ACCESS_READ) {
+ printf(" NFS_ACCESS_READ");
+ separator = '|';
+ }
+ if (access_flags & NFSV3ACCESS_LOOKUP) {
+ printf("%cNFS_ACCESS_LOOKUP", separator);
+ separator = '|';
+ }
+ if (access_flags & NFSV3ACCESS_MODIFY) {
+ printf("%cNFS_ACCESS_MODIFY", separator);
+ separator = '|';
+ }
+ if (access_flags & NFSV3ACCESS_EXTEND) {
+ printf("%cNFS_ACCESS_EXTEND", separator);
+ separator = '|';
+ }
+ if (access_flags & NFSV3ACCESS_DELETE) {
+ printf("%cNFS_ACCESS_DELETE", separator);
+ separator = '|';
+ }
+ if (access_flags & NFSV3ACCESS_EXECUTE)
+ printf("%cNFS_ACCESS_EXECUTE", separator);
+ }
return;
}
break;
diff --git a/print-ntp.c b/print-ntp.c
index 4960dc829c50..d56f02a2624f 100644
--- a/print-ntp.c
+++ b/print-ntp.c
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.42 2005-05-06 07:56:53 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -72,6 +72,12 @@ static struct tok ntp_leapind_values[] = {
{ 0, NULL }
};
+static struct tok ntp_stratum_values[] = {
+ { UNSPECIFIED, "unspecified" },
+ { PRIM_REF, "primary reference" },
+ { 0, NULL }
+};
+
/*
* Print ntp requests
*/
@@ -106,7 +112,9 @@ ntp_print(register const u_char *cp, u_int length)
leapind);
TCHECK(bp->stratum);
- printf(", Stratum %u", bp->stratum);
+ printf(", Stratum %u (%s)",
+ bp->stratum,
+ tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum));
TCHECK(bp->ppoll);
printf(", poll %us", bp->ppoll);
@@ -174,8 +182,19 @@ ntp_print(register const u_char *cp, u_int length)
fputs("\n\t Originator - Transmit Timestamp: ", stdout);
p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp));
- /* FIXME key-id, authentication */
-
+ if ( (sizeof(struct ntpdata) - length) == 16) { /* Optional: key-id */
+ TCHECK(bp->key_id);
+ printf("\n\tKey id: %u", bp->key_id);
+ } else if ( (sizeof(struct ntpdata) - length) == 0) { /* Optional: key-id + authentication */
+ TCHECK(bp->key_id);
+ printf("\n\tKey id: %u", bp->key_id);
+ TCHECK2(bp->message_digest, sizeof (bp->message_digest));
+ printf("\n\tAuthentication: %08x%08x%08x%08x",
+ EXTRACT_32BITS(bp->message_digest),
+ EXTRACT_32BITS(bp->message_digest + 4),
+ EXTRACT_32BITS(bp->message_digest + 8),
+ EXTRACT_32BITS(bp->message_digest + 12));
+ }
return;
trunc:
diff --git a/print-olsr.c b/print-olsr.c
index 174a51eac943..ba0ed2bede8a 100644
--- a/print-olsr.c
+++ b/print-olsr.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1998-2007 The TCPDUMP project
+ * Copyright (c) 2009 Florian Forster
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -15,6 +16,7 @@
* Optimized Link State Protocl (OLSR) as per rfc3626
*
* Original code by Hannes Gredler <hannes@juniper.net>
+ * IPv6 additions by Florian Forster <octo at verplant.org>
*/
#ifdef HAVE_CONFIG_H
@@ -28,7 +30,7 @@
#include "interface.h"
#include "addrtoname.h"
-#include "extract.h"
+#include "extract.h"
#include "ip.h"
/*
@@ -88,7 +90,7 @@ static struct tok olsr_msg_values[] = {
{ 0, NULL}
};
-struct olsr_msg {
+struct olsr_msg4 {
u_int8_t msg_type;
u_int8_t vtime;
u_int8_t msg_len[2];
@@ -98,6 +100,16 @@ struct olsr_msg {
u_int8_t msg_seq[2];
};
+struct olsr_msg6 {
+ u_int8_t msg_type;
+ u_int8_t vtime;
+ u_int8_t msg_len[2];
+ u_int8_t originator[16];
+ u_int8_t ttl;
+ u_int8_t hopcount;
+ u_int8_t msg_seq[2];
+};
+
struct olsr_hello {
u_int8_t res[2];
u_int8_t htime;
@@ -115,11 +127,16 @@ struct olsr_tc {
u_int8_t res[2];
};
-struct olsr_hna {
+struct olsr_hna4 {
u_int8_t network[4];
u_int8_t mask[4];
};
+struct olsr_hna6 {
+ u_int8_t network[16];
+ u_int8_t mask[16];
+};
+
#define OLSR_EXTRACT_LINK_TYPE(link_code) (link_code & 0x3)
#define OLSR_EXTRACT_NEIGHBOR_TYPE(link_code) (link_code >> 2)
@@ -139,13 +156,20 @@ static struct tok olsr_neighbor_type_values[] = {
{ 0, NULL}
};
-struct olsr_lq_neighbor {
+struct olsr_lq_neighbor4 {
u_int8_t neighbor[4];
u_int8_t link_quality;
u_int8_t neighbor_link_quality;
u_int8_t res[2];
};
+struct olsr_lq_neighbor6 {
+ u_int8_t neighbor[16];
+ u_int8_t link_quality;
+ u_int8_t neighbor_link_quality;
+ u_int8_t res[2];
+};
+
/*
* macro to convert the 8-bit mantissa/exponent to a double float
* taken from olsr.org.
@@ -158,13 +182,13 @@ struct olsr_lq_neighbor {
* print a neighbor list with LQ extensions.
*/
static void
-olsr_print_lq_neighbor (const u_char *msg_data, u_int hello_len)
+olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len)
{
- struct olsr_lq_neighbor *lq_neighbor;
+ struct olsr_lq_neighbor4 *lq_neighbor;
- while (hello_len >= sizeof(struct olsr_lq_neighbor)) {
+ while (hello_len >= sizeof(struct olsr_lq_neighbor4)) {
- lq_neighbor = (struct olsr_lq_neighbor *)msg_data;
+ lq_neighbor = (struct olsr_lq_neighbor4 *)msg_data;
printf("\n\t neighbor %s, link-quality %.2lf%%"
", neighbor-link-quality %.2lf%%",
@@ -172,11 +196,33 @@ olsr_print_lq_neighbor (const u_char *msg_data, u_int hello_len)
((double)lq_neighbor->link_quality/2.55),
((double)lq_neighbor->neighbor_link_quality/2.55));
- msg_data += sizeof(struct olsr_lq_neighbor);
- hello_len -= sizeof(struct olsr_lq_neighbor);
+ msg_data += sizeof(struct olsr_lq_neighbor4);
+ hello_len -= sizeof(struct olsr_lq_neighbor4);
}
}
+#if INET6
+static void
+olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len)
+{
+ struct olsr_lq_neighbor6 *lq_neighbor;
+
+ while (hello_len >= sizeof(struct olsr_lq_neighbor6)) {
+
+ lq_neighbor = (struct olsr_lq_neighbor6 *)msg_data;
+
+ printf("\n\t neighbor %s, link-quality %.2lf%%"
+ ", neighbor-link-quality %.2lf%%",
+ ip6addr_string(lq_neighbor->neighbor),
+ ((double)lq_neighbor->link_quality/2.55),
+ ((double)lq_neighbor->neighbor_link_quality/2.55));
+
+ msg_data += sizeof(struct olsr_lq_neighbor6);
+ hello_len -= sizeof(struct olsr_lq_neighbor6);
+ }
+}
+#endif /* INET6 */
+
/*
* print a neighbor list.
*/
@@ -202,38 +248,41 @@ olsr_print_neighbor (const u_char *msg_data, u_int hello_len)
void
-olsr_print (const u_char *pptr, u_int length)
+olsr_print (const u_char *pptr, u_int length, int is_ipv6)
{
union {
const struct olsr_common *common;
- const struct olsr_msg *msg;
+ const struct olsr_msg4 *msg4;
+ const struct olsr_msg6 *msg6;
const struct olsr_hello *hello;
const struct olsr_hello_link *hello_link;
- const struct olsr_lq_neighbor *lq_neighbor;
const struct olsr_tc *tc;
- const struct olsr_hna *hna;
+ const struct olsr_hna4 *hna;
} ptr;
- u_int msg_type, msg_len, msg_tlen, hello_len, prefix;
+ u_int msg_type, msg_len, msg_tlen, hello_len;
+ u_int16_t name_entry_type, name_entry_len;
+ u_int name_entry_padding;
u_int8_t link_type, neighbor_type;
const u_char *tptr, *msg_data;
- tptr = pptr;
+ tptr = pptr;
if (length < sizeof(struct olsr_common)) {
goto trunc;
}
if (!TTEST2(*tptr, sizeof(struct olsr_common))) {
- goto trunc;
+ goto trunc;
}
ptr.common = (struct olsr_common *)tptr;
length = MIN(length, EXTRACT_16BITS(ptr.common->packet_len));
- printf("OLSR, seq 0x%04x, length %u",
- EXTRACT_16BITS(ptr.common->packet_seq),
- length);
+ printf("OLSRv%i, seq 0x%04x, length %u",
+ (is_ipv6 == 0) ? 4 : 6,
+ EXTRACT_16BITS(ptr.common->packet_seq),
+ length);
tptr += sizeof(struct olsr_common);
@@ -241,41 +290,81 @@ olsr_print (const u_char *pptr, u_int length)
* In non-verbose mode, just print version.
*/
if (vflag < 1) {
- return;
+ return;
}
while (tptr < (pptr+length)) {
-
- if (!TTEST2(*tptr, sizeof(struct olsr_msg)))
+ union
+ {
+ struct olsr_msg4 *v4;
+ struct olsr_msg6 *v6;
+ } msgptr;
+ int msg_len_valid = 0;
+
+ if (!TTEST2(*tptr, sizeof(struct olsr_msg4)))
goto trunc;
- ptr.msg = (struct olsr_msg *)tptr;
-
- msg_type = ptr.msg->msg_type;
- msg_len = EXTRACT_16BITS(ptr.msg->msg_len);
+#if INET6
+ if (is_ipv6)
+ {
+ msgptr.v6 = (struct olsr_msg6 *) tptr;
+ msg_type = msgptr.v6->msg_type;
+ msg_len = EXTRACT_16BITS(msgptr.v6->msg_len);
+ if ((msg_len >= sizeof (struct olsr_msg6))
+ && (msg_len <= length))
+ msg_len_valid = 1;
+
+ /* infinite loop check */
+ if (msg_type == 0 || msg_len == 0) {
+ return;
+ }
- /* infinite loop check */
- if (msg_type == 0 || msg_len == 0) {
- return;
+ printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+ "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
+ tok2str(olsr_msg_values, "Unknown", msg_type),
+ msg_type, ip6addr_string(msgptr.v6->originator),
+ msgptr.v6->ttl,
+ msgptr.v6->hopcount,
+ ME_TO_DOUBLE(msgptr.v6->vtime),
+ EXTRACT_16BITS(msgptr.v6->msg_seq),
+ msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+
+ msg_tlen = msg_len - sizeof(struct olsr_msg6);
+ msg_data = tptr + sizeof(struct olsr_msg6);
}
+ else /* (!is_ipv6) */
+#endif /* INET6 */
+ {
+ msgptr.v4 = (struct olsr_msg4 *) tptr;
+ msg_type = msgptr.v4->msg_type;
+ msg_len = EXTRACT_16BITS(msgptr.v4->msg_len);
+ if ((msg_len >= sizeof (struct olsr_msg4))
+ && (msg_len <= length))
+ msg_len_valid = 1;
+
+ /* infinite loop check */
+ if (msg_type == 0 || msg_len == 0) {
+ return;
+ }
- printf("\n\t%s Message (%u), originator %s, ttl %u, hop %u"
- "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u",
- tok2str(olsr_msg_values, "Unknown", msg_type),
- msg_type, ipaddr_string(ptr.msg->originator),
- ptr.msg->ttl,
- ptr.msg->hopcount,
- ME_TO_DOUBLE(ptr.msg->vtime),
- EXTRACT_16BITS(ptr.msg->msg_seq),
- msg_len);
-
- msg_tlen = msg_len - sizeof(struct olsr_msg);
- msg_data = tptr + sizeof(struct olsr_msg);
+ printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+ "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
+ tok2str(olsr_msg_values, "Unknown", msg_type),
+ msg_type, ipaddr_string(msgptr.v4->originator),
+ msgptr.v4->ttl,
+ msgptr.v4->hopcount,
+ ME_TO_DOUBLE(msgptr.v4->vtime),
+ EXTRACT_16BITS(msgptr.v4->msg_seq),
+ msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+
+ msg_tlen = msg_len - sizeof(struct olsr_msg4);
+ msg_data = tptr + sizeof(struct olsr_msg4);
+ }
switch (msg_type) {
case OLSR_HELLO_MSG:
case OLSR_HELLO_LQ_MSG:
- if (!TTEST2(*msg_data, sizeof(struct olsr_hello)))
+ if (!TTEST2(*msg_data, sizeof(struct olsr_hello)))
goto trunc;
ptr.hello = (struct olsr_hello *)msg_data;
@@ -285,11 +374,12 @@ olsr_print (const u_char *pptr, u_int length)
msg_tlen -= sizeof(struct olsr_hello);
while (msg_tlen >= sizeof(struct olsr_hello_link)) {
+ int hello_len_valid = 0;
/*
* link-type.
*/
- if (!TTEST2(*msg_data, sizeof(struct olsr_hello_link)))
+ if (!TTEST2(*msg_data, sizeof(struct olsr_hello_link)))
goto trunc;
ptr.hello_link = (struct olsr_hello_link *)msg_data;
@@ -298,10 +388,18 @@ olsr_print (const u_char *pptr, u_int length)
link_type = OLSR_EXTRACT_LINK_TYPE(ptr.hello_link->link_code);
neighbor_type = OLSR_EXTRACT_NEIGHBOR_TYPE(ptr.hello_link->link_code);
- printf("\n\t link-type %s, neighbor-type %s, len %u",
+ if ((hello_len <= msg_tlen)
+ && (hello_len >= sizeof(struct olsr_hello_link)))
+ hello_len_valid = 1;
+
+ printf("\n\t link-type %s, neighbor-type %s, len %u%s",
tok2str(olsr_link_type_values, "Unknown", link_type),
tok2str(olsr_neighbor_type_values, "Unknown", neighbor_type),
- hello_len);
+ hello_len,
+ (hello_len_valid == 0) ? " (invalid)" : "");
+
+ if (hello_len_valid == 0)
+ break;
msg_data += sizeof(struct olsr_hello_link);
msg_tlen -= sizeof(struct olsr_hello_link);
@@ -310,7 +408,12 @@ olsr_print (const u_char *pptr, u_int length)
if (msg_type == OLSR_HELLO_MSG) {
olsr_print_neighbor(msg_data, hello_len);
} else {
- olsr_print_lq_neighbor(msg_data, hello_len);
+#if INET6
+ if (is_ipv6)
+ olsr_print_lq_neighbor6(msg_data, hello_len);
+ else
+#endif
+ olsr_print_lq_neighbor4(msg_data, hello_len);
}
msg_data += hello_len;
@@ -320,7 +423,7 @@ olsr_print (const u_char *pptr, u_int length)
case OLSR_TC_MSG:
case OLSR_TC_LQ_MSG:
- if (!TTEST2(*msg_data, sizeof(struct olsr_tc)))
+ if (!TTEST2(*msg_data, sizeof(struct olsr_tc)))
goto trunc;
ptr.tc = (struct olsr_tc *)msg_data;
@@ -332,56 +435,182 @@ olsr_print (const u_char *pptr, u_int length)
if (msg_type == OLSR_TC_MSG) {
olsr_print_neighbor(msg_data, msg_tlen);
} else {
- olsr_print_lq_neighbor(msg_data, msg_tlen);
+#if INET6
+ if (is_ipv6)
+ olsr_print_lq_neighbor6(msg_data, msg_tlen);
+ else
+#endif
+ olsr_print_lq_neighbor4(msg_data, msg_tlen);
}
break;
case OLSR_MID_MSG:
- if (!TTEST2(*msg_data, sizeof(struct in_addr)))
- goto trunc;
+ {
+ size_t addr_size = sizeof(struct in_addr);
- while (msg_tlen >= sizeof(struct in_addr)) {
- printf("\n\t interface address %s", ipaddr_string(msg_data));
- msg_data += sizeof(struct in_addr);
- msg_tlen -= sizeof(struct in_addr);
+#if INET6
+ if (is_ipv6)
+ addr_size = sizeof(struct in6_addr);
+#endif
+
+ while (msg_tlen >= addr_size) {
+ if (!TTEST2(*msg_data, addr_size))
+ goto trunc;
+
+ printf("\n\t interface address %s",
+#if INET6
+ is_ipv6 ? ip6addr_string(msg_data) :
+#endif
+ ipaddr_string(msg_data));
+ msg_data += addr_size;
+ msg_tlen -= addr_size;
}
break;
+ }
case OLSR_HNA_MSG:
- prefix = 1;
- printf("\n\t advertised networks\n\t ");
- while (msg_tlen >= sizeof(struct olsr_hna)) {
- if (!TTEST2(*msg_data, sizeof(struct olsr_hna)))
- goto trunc;
+ printf("\n\t Advertised networks (total %u)",
+ (unsigned int) (msg_tlen / sizeof(struct olsr_hna6)));
+#if INET6
+ if (is_ipv6)
+ {
+ int i = 0;
+ while (msg_tlen >= sizeof(struct olsr_hna6)) {
+ struct olsr_hna6 *hna6;
+
+ if (!TTEST2(*msg_data, sizeof(struct olsr_hna6)))
+ goto trunc;
+
+ hna6 = (struct olsr_hna6 *)msg_data;
+
+ printf("\n\t #%i: %s/%u",
+ i, ip6addr_string(hna6->network),
+ mask62plen (hna6->mask));
+
+ msg_data += sizeof(struct olsr_hna6);
+ msg_tlen -= sizeof(struct olsr_hna6);
+ }
+ }
+ else
+#endif
+ {
+ int col = 0;
+ while (msg_tlen >= sizeof(struct olsr_hna4)) {
+ if (!TTEST2(*msg_data, sizeof(struct olsr_hna4)))
+ goto trunc;
+
+ ptr.hna = (struct olsr_hna4 *)msg_data;
- ptr.hna = (struct olsr_hna *)msg_data;
+ /* print 4 prefixes per line */
+ if (col == 0)
+ printf ("\n\t ");
+ else
+ printf (", ");
- /* print 4 prefixes per line */
+ printf("%s/%u",
+ ipaddr_string(ptr.hna->network),
+ mask2plen(EXTRACT_32BITS(ptr.hna->mask)));
- printf("%s/%u%s",
- ipaddr_string(ptr.hna->network),
- mask2plen(EXTRACT_32BITS(ptr.hna->mask)),
- prefix % 4 == 0 ? "\n\t " : " ");
+ msg_data += sizeof(struct olsr_hna4);
+ msg_tlen -= sizeof(struct olsr_hna4);
- msg_data += sizeof(struct olsr_hna);
- msg_tlen -= sizeof(struct olsr_hna);
- prefix ++;
+ col = (col + 1) % 4;
+ }
}
break;
+ case OLSR_NAMESERVICE_MSG:
+ {
+ u_int name_entries = EXTRACT_16BITS(msg_data+2);
+ u_int addr_size = 4;
+ int name_entries_valid = 0;
+ u_int i;
+
+ if (is_ipv6)
+ addr_size = 16;
+
+ if ((name_entries > 0)
+ && ((name_entries * (4 + addr_size)) <= msg_tlen))
+ name_entries_valid = 1;
+
+ if (msg_tlen < 4)
+ goto trunc;
+ if (!TTEST2(*msg_data, 4))
+ goto trunc;
+
+ printf("\n\t Version %u, Entries %u%s",
+ EXTRACT_16BITS(msg_data),
+ name_entries, (name_entries_valid == 0) ? " (invalid)" : "");
+
+ if (name_entries_valid == 0)
+ break;
+
+ msg_data += 4;
+ msg_tlen -= 4;
+
+ for (i = 0; i < name_entries; i++) {
+ int name_entry_len_valid = 0;
+
+ if (msg_tlen < 4)
+ break;
+ if (!TTEST2(*msg_data, 4))
+ goto trunc;
+
+ name_entry_type = EXTRACT_16BITS(msg_data);
+ name_entry_len = EXTRACT_16BITS(msg_data+2);
+
+ msg_data += 4;
+ msg_tlen -= 4;
+
+ if ((name_entry_len > 0) && ((addr_size + name_entry_len) <= msg_tlen))
+ name_entry_len_valid = 1;
+
+ printf("\n\t #%u: type %#06x, length %u%s",
+ (unsigned int) i, name_entry_type,
+ name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : "");
+
+ if (name_entry_len_valid == 0)
+ break;
+
+ /* 32-bit alignment */
+ name_entry_padding = 0;
+ if (name_entry_len%4 != 0)
+ name_entry_padding = 4-(name_entry_len%4);
+
+ if (msg_tlen < addr_size + name_entry_len + name_entry_padding)
+ goto trunc;
+
+ if (!TTEST2(*msg_data, addr_size + name_entry_len + name_entry_padding))
+ goto trunc;
+
+#if INET6
+ if (is_ipv6)
+ printf(", address %s, name \"",
+ ip6addr_string(msg_data));
+ else
+#endif
+ printf(", address %s, name \"",
+ ipaddr_string(msg_data));
+ fn_printn(msg_data + addr_size, name_entry_len, NULL);
+ printf("\"");
+
+ msg_data += addr_size + name_entry_len + name_entry_padding;
+ msg_tlen -= addr_size + name_entry_len + name_entry_padding;
+ } /* for (i = 0; i < name_entries; i++) */
+ break;
+ } /* case OLSR_NAMESERVICE_MSG */
+
/*
* FIXME those are the defined messages that lack a decoder
* you are welcome to contribute code ;-)
*/
-
case OLSR_POWERINFO_MSG:
- case OLSR_NAMESERVICE_MSG:
default:
- print_unknown_data(msg_data, "\n\t ", msg_tlen);
+ print_unknown_data(msg_data, "\n\t ", msg_tlen);
break;
- }
+ } /* switch (msg_type) */
tptr += msg_len;
- }
+ } /* while (tptr < (pptr+length)) */
return;
diff --git a/print-ospf.c b/print-ospf.c
index 4490496468ea..983c14f40e12 100644
--- a/print-ospf.c
+++ b/print-ospf.c
@@ -982,7 +982,7 @@ ospf_decode_v2(register const struct ospfhdr *op,
bittok2str(ospf_dd_flag_values,"none",op->ospf_db.db_flags));
TCHECK(op->ospf_db.db_ifmtu);
if (op->ospf_db.db_ifmtu) {
- printf(", MTU: %u", ntohs(op->ospf_db.db_ifmtu));
+ printf(", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu));
}
TCHECK(op->ospf_db.db_seq);
printf(", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq));
diff --git a/print-pflog.c b/print-pflog.c
index 972cb4b1328c..0cacabfc6e44 100644
--- a/print-pflog.c
+++ b/print-pflog.c
@@ -42,6 +42,7 @@ static const char rcsid[] _U_ =
#include <stdio.h>
#include <pcap.h>
+#include "extract.h"
#include "interface.h"
#include "addrtoname.h"
@@ -94,8 +95,8 @@ pflog_print(const struct pfloghdr *hdr)
{
u_int32_t rulenr, subrulenr;
- rulenr = ntohl(hdr->rulenr);
- subrulenr = ntohl(hdr->subrulenr);
+ rulenr = EXTRACT_32BITS(&hdr->rulenr);
+ subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
if (subrulenr == (u_int32_t)-1)
printf("rule %u/", rulenr);
else
diff --git a/print-pim.c b/print-pim.c
index 774096e2f934..f9fd0c69f553 100644
--- a/print-pim.c
+++ b/print-pim.c
@@ -118,7 +118,7 @@ struct pim {
#include "ip.h"
-static void pimv2_print(register const u_char *bp, register u_int len);
+static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
static void
pimv1_join_prune_print(register const u_char *bp, register u_int len)
@@ -413,7 +413,7 @@ trunc:
}
void
-pim_print(register const u_char *bp, register u_int len)
+pim_print(register const u_char *bp, register u_int len, u_int cksum)
{
register const u_char *ep;
register struct pim *pim = (struct pim *)bp;
@@ -438,7 +438,7 @@ pim_print(register const u_char *bp, register u_int len)
PIM_VER(pim->pim_typever),
len,
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
- pimv2_print(bp, len);
+ pimv2_print(bp, len, cksum);
}
break;
default:
@@ -618,7 +618,7 @@ trunc:
}
static void
-pimv2_print(register const u_char *bp, register u_int len)
+pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
{
register const u_char *ep;
register struct pim *pim = (struct pim *)bp;
@@ -638,9 +638,7 @@ pimv2_print(register const u_char *bp, register u_int len)
if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
printf("(unverified)");
} else {
- printf("(%scorrect)",
- TTEST2(bp[0], len) &&
- in_cksum((const u_short*)bp, len, 0) ? "in" : "" );
+ printf("(%scorrect)", TTEST2(bp[0], len) && cksum ? "in" : "" );
}
switch (PIM_TYPE(pim->pim_typever)) {
diff --git a/print-ppp.c b/print-ppp.c
index 708e934fd829..7f231ead9cdc 100644
--- a/print-ppp.c
+++ b/print-ppp.c
@@ -1629,7 +1629,7 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
hdrlength += 1;
} else {
/* Un-compressed protocol field */
- ptype = ntohs(*(u_int16_t *)p);
+ ptype = EXTRACT_16BITS(p);
if (eflag)
printf("%04x ", ptype);
p += 2;
@@ -1649,7 +1649,7 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
&& ph->phdr_ctl == PPP_CONTROL) {
if (eflag)
printf("%02x %02x ", q[0], q[1]);
- ptype = ntohs(ph->phdr_type);
+ ptype = EXTRACT_16BITS(&ph->phdr_type);
if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
printf("%s ", tok2str(ppptype2str,
"proto-#%d", ptype));
diff --git a/print-rrcp.c b/print-rrcp.c
index dc3045793be9..961fb87309c6 100644
--- a/print-rrcp.c
+++ b/print-rrcp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rrcp.c,v 1.1.2.2 2008-04-11 17:00:00 gianluca Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rrcp.c,v 1.2 2008-04-11 17:21:34 gianluca Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -44,33 +44,38 @@ static const char rcsid[] _U_ =
#define ETH_ALEN 6
#endif
-struct rrcp_packet_t
-{
- u_int16_t rrcp_ethertype; /* 0x8899 */
- u_int8_t rrcp_proto; /* must be 0x01 */
- u_int8_t rrcp_opcode:7; /* 0x00 = hello, 0x01 = get, 0x02 = set */
- u_int8_t rrcp_isreply:1; /* 0 = request to switch, 1 = reply from switch */
- u_int16_t rrcp_authkey; /* 0x2379 by default */
- u_int16_t rrcp_reg_addr; /* register address */
- u_int32_t rrcp_reg_data; /* register data */
- u_int32_t cookie1;
- u_int32_t cookie2;
-};
+#define RRCP_OPCODE_MASK 0x7F /* 0x00 = hello, 0x01 = get, 0x02 = set */
+#define RRCP_ISREPLY 0x80 /* 0 = request to switch, 0x80 = reply from switch */
-struct rrcp_helloreply_packet_t
-{
- u_int16_t rrcp_ethertype; /* 0x8899 */
- u_int8_t rrcp_proto; /* must be 0x01 */
- u_int8_t rrcp_opcode:7; /* 0x00 = hello, 0x01 = get, 0x02 = set */
- u_int8_t rrcp_isreply:1; /* 0 = request to switch, 1 = reply from switch */
- u_int16_t rrcp_authkey; /* 0x2379 by default */
- u_int8_t rrcp_downlink_port; /* */
- u_int8_t rrcp_uplink_port; /* */
- u_int8_t rrcp_uplink_mac[ETH_ALEN]; /* */
- u_int16_t rrcp_chip_id; /* */
- u_int32_t rrcp_vendor_id; /* */
+#define RRCP_PROTO_OFFSET 0 /* proto - 1 byte, must be 1 */
+#define RRCP_OPCODE_ISREPLY_OFFSET 1 /* opcode and isreply flag - 1 byte */
+#define RRCP_AUTHKEY_OFFSET 2 /* authorization key - 2 bytes, 0x2379 by default */
+
+/* most packets */
+#define RRCP_REG_ADDR_OFFSET 4 /* register address - 2 bytes */
+#define RRCP_REG_DATA_OFFSET 6 /* register data - 4 bytes */
+#define RRCP_COOKIE1_OFFSET 10 /* 4 bytes */
+#define RRCP_COOKIE2_OFFSET 14 /* 4 bytes */
+
+/* hello reply packets */
+#define RRCP_DOWNLINK_PORT_OFFSET 4 /* 1 byte */
+#define RRCP_UPLINK_PORT_OFFSET 5 /* 1 byte */
+#define RRCP_UPLINK_MAC_OFFSET 6 /* 6 byte MAC address */
+#define RRCP_CHIP_ID_OFFSET 12 /* 2 bytes */
+#define RRCP_VENDOR_ID_OFFSET 14 /* 4 bytes */
+
+static const struct tok proto_values[] = {
+ { 1, "RRCP" },
+ { 2, "RRCP-REP" },
+ { 0, NULL }
};
+static const struct tok opcode_values[] = {
+ { 0, "hello" },
+ { 1, "get" },
+ { 2, "set" },
+ { 0, NULL }
+};
/*
* Print RRCP requests
@@ -80,58 +85,59 @@ rrcp_print(netdissect_options *ndo,
register const u_char *cp,
u_int length _U_)
{
- const struct rrcp_packet_t *rrcp;
- const struct rrcp_helloreply_packet_t *rrcp_hello;
+ const u_char *rrcp;
+ u_int8_t rrcp_proto;
+ u_int8_t rrcp_opcode;
register const struct ether_header *ep;
char proto_str[16];
char opcode_str[32];
ep = (const struct ether_header *)cp;
- rrcp = (const struct rrcp_packet_t *)(cp+12);
- rrcp_hello = (const struct rrcp_helloreply_packet_t *)(cp+12);
-
- if (rrcp->rrcp_proto==1){
- strcpy(proto_str,"RRCP");
- }else if ( rrcp->rrcp_proto==2 ){
- strcpy(proto_str,"RRCP-REP");
- }else{
- sprintf(proto_str,"RRCP-0x%02d",rrcp->rrcp_proto);
- }
- if (rrcp->rrcp_opcode==0){
- strcpy(opcode_str,"hello");
- }else if ( rrcp->rrcp_opcode==1 ){
- strcpy(opcode_str,"get");
- }else if ( rrcp->rrcp_opcode==2 ){
- strcpy(opcode_str,"set");
- }else{
- sprintf(opcode_str,"unknown opcode (0x%02d)",rrcp->rrcp_opcode);
- }
+ rrcp = cp + ETHER_HDRLEN;
+
+ ND_TCHECK(*(rrcp + RRCP_PROTO_OFFSET));
+ rrcp_proto = *(rrcp + RRCP_PROTO_OFFSET);
+ ND_TCHECK(*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET));
+ rrcp_opcode = (*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK;
ND_PRINT((ndo, "%s > %s, %s %s",
etheraddr_string(ESRC(ep)),
etheraddr_string(EDST(ep)),
- proto_str, rrcp->rrcp_isreply ? "reply" : "query"));
- if (rrcp->rrcp_proto==1){
- ND_PRINT((ndo, ": %s", opcode_str));
+ tok2strbuf(proto_values,"RRCP-0x%02d",rrcp_proto,proto_str,sizeof(proto_str)),
+ ((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
+ if (rrcp_proto==1){
+ ND_PRINT((ndo, ": %s",
+ tok2strbuf(opcode_values,"unknown opcode (0x%02d)",rrcp_opcode,opcode_str,sizeof(opcode_str))));
}
- if (rrcp->rrcp_opcode==1 || rrcp->rrcp_opcode==2){
- ND_PRINT((ndo, " addr=0x%04x, data=0x%04x",
- rrcp->rrcp_reg_addr, rrcp->rrcp_reg_data, rrcp->rrcp_authkey));
+ if (rrcp_opcode==1 || rrcp_opcode==2){
+ ND_TCHECK2(*(rrcp + RRCP_REG_ADDR_OFFSET), 6);
+ ND_PRINT((ndo, " addr=0x%04x, data=0x%08x",
+ EXTRACT_16BITS(rrcp + RRCP_REG_ADDR_OFFSET),
+ EXTRACT_32BITS(rrcp + RRCP_REG_DATA_OFFSET)));
}
- if (rrcp->rrcp_proto==1){
+ if (rrcp_proto==1){
+ ND_TCHECK2(*(rrcp + RRCP_AUTHKEY_OFFSET), 2);
ND_PRINT((ndo, ", auth=0x%04x",
- ntohs(rrcp->rrcp_authkey)));
+ EXTRACT_16BITS(rrcp + RRCP_AUTHKEY_OFFSET)));
}
- if (rrcp->rrcp_proto==1 && rrcp->rrcp_opcode==0 && rrcp->rrcp_isreply){
- ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
- rrcp_hello->rrcp_downlink_port,
- rrcp_hello->rrcp_uplink_port,
- etheraddr_string(rrcp_hello->rrcp_uplink_mac),
- rrcp_hello->rrcp_vendor_id,
- rrcp_hello->rrcp_chip_id));
- }else if (rrcp->rrcp_opcode==1 || rrcp->rrcp_opcode==2 || rrcp->rrcp_proto==2){
- ND_PRINT((ndo, ", cookie=0x%08x%08x ",
- rrcp->cookie2, rrcp->cookie1));
+ if (rrcp_proto==1 && rrcp_opcode==0 &&
+ ((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){
+ ND_TCHECK2(*(rrcp + RRCP_VENDOR_ID_OFFSET), 4);
+ ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
+ *(rrcp + RRCP_DOWNLINK_PORT_OFFSET),
+ *(rrcp + RRCP_UPLINK_PORT_OFFSET),
+ etheraddr_string(rrcp + RRCP_UPLINK_MAC_OFFSET),
+ EXTRACT_32BITS(rrcp + RRCP_VENDOR_ID_OFFSET),
+ EXTRACT_16BITS(rrcp + RRCP_CHIP_ID_OFFSET)));
+ }else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){
+ ND_TCHECK2(*(rrcp + RRCP_COOKIE2_OFFSET), 4);
+ ND_PRINT((ndo, ", cookie=0x%08x%08x ",
+ EXTRACT_32BITS(rrcp + RRCP_COOKIE2_OFFSET),
+ EXTRACT_32BITS(rrcp + RRCP_COOKIE1_OFFSET)));
}
if (!ndo->ndo_vflag)
return;
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|rrcp]"));
}
diff --git a/print-rsvp.c b/print-rsvp.c
index 5ed731c3dec0..6aa2f6d71bd6 100644
--- a/print-rsvp.c
+++ b/print-rsvp.c
@@ -17,7 +17,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.48 2007-09-13 17:29:50 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.50 2008-08-16 11:36:20 hannes Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,6 +36,7 @@ static const char rcsid[] _U_ =
#include "ethertype.h"
#include "gmpls.h"
#include "af.h"
+#include "signature.h"
/*
* RFC 2205 common header
@@ -142,6 +143,7 @@ static const struct tok rsvp_header_flag_values[] = {
#define RSVP_OBJ_UPSTREAM_LABEL 35 /* rfc3473 */
#define RSVP_OBJ_LABEL_SET 36 /* rfc3473 */
#define RSVP_OBJ_PROTECTION 37 /* rfc3473 */
+#define RSVP_OBJ_S2L 50 /* rfc4875 */
#define RSVP_OBJ_DETOUR 63 /* draft-ietf-mpls-rsvp-lsp-fastreroute-07 */
#define RSVP_OBJ_CLASSTYPE 66 /* rfc4124 */
#define RSVP_OBJ_CLASSTYPE_OLD 125 /* draft-ietf-tewg-diff-te-proto-07 */
@@ -198,6 +200,7 @@ static const struct tok rsvp_obj_values[] = {
{ RSVP_OBJ_NOTIFY_REQ, "Notify Request" },
{ RSVP_OBJ_PROTECTION, "Protection" },
{ RSVP_OBJ_ADMIN_STATUS, "Administrative Status" },
+ { RSVP_OBJ_S2L, "Sub-LSP to LSP" },
{ 0, NULL}
};
@@ -210,6 +213,9 @@ static const struct tok rsvp_obj_values[] = {
#define RSVP_CTYPE_2 2
#define RSVP_CTYPE_3 3
#define RSVP_CTYPE_4 4
+#define RSVP_CTYPE_12 12
+#define RSVP_CTYPE_13 13
+#define RSVP_CTYPE_14 14
/*
* the ctypes are not globally unique so for
@@ -235,13 +241,19 @@ static const struct tok rsvp_ctype_values[] = {
{ 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV6, "IPv6" },
{ 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_3, "IPv6 Flow-label" },
{ 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
+ { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_12, "IPv4 P2MP LSP Tunnel" },
+ { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_13, "IPv6 P2MP LSP Tunnel" },
{ 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV4, "IPv4" },
{ 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV6, "IPv6" },
{ 256*RSVP_OBJ_SESSION+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
{ 256*RSVP_OBJ_SESSION+RSVP_CTYPE_UNI_IPV4, "UNI IPv4" },
+ { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_13, "IPv4 P2MP LSP Tunnel" },
+ { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_14, "IPv6 P2MP LSP Tunnel" },
{ 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV4, "IPv4" },
{ 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV6, "IPv6" },
{ 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
+ { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_12, "IPv4 P2MP LSP Tunnel" },
+ { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_13, "IPv6 P2MP LSP Tunnel" },
{ 256*RSVP_OBJ_MESSAGE_ID+RSVP_CTYPE_1, "1" },
{ 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_1, "Message id ack" },
{ 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_2, "Message id nack" },
@@ -282,6 +294,8 @@ static const struct tok rsvp_ctype_values[] = {
{ 256*RSVP_OBJ_CLASSTYPE_OLD+RSVP_CTYPE_1, "1" },
{ 256*RSVP_OBJ_LABEL_SET+RSVP_CTYPE_1, "1" },
{ 256*RSVP_OBJ_GENERALIZED_UNI+RSVP_CTYPE_1, "1" },
+ { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV4, "IPv4 sub-LSP" },
+ { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV6, "IPv6 sub-LSP" },
{ 0, NULL}
};
@@ -316,6 +330,7 @@ struct rsvp_obj_frr_t {
#define RSVP_OBJ_XRO_RES 0
#define RSVP_OBJ_XRO_IPV4 1
#define RSVP_OBJ_XRO_IPV6 2
+#define RSVP_OBJ_XRO_LABEL 3
#define RSVP_OBJ_XRO_ASN 32
#define RSVP_OBJ_XRO_MPLS 64
@@ -323,6 +338,7 @@ static const struct tok rsvp_obj_xro_values[] = {
{ RSVP_OBJ_XRO_RES, "Reserved" },
{ RSVP_OBJ_XRO_IPV4, "IPv4 prefix" },
{ RSVP_OBJ_XRO_IPV6, "IPv6 prefix" },
+ { RSVP_OBJ_XRO_LABEL, "Label" },
{ RSVP_OBJ_XRO_ASN, "Autonomous system number" },
{ RSVP_OBJ_XRO_MPLS, "MPLS label switched path termination" },
{ 0, NULL}
@@ -337,6 +353,12 @@ static const struct tok rsvp_obj_rro_flag_values[] = {
{ 0, NULL}
};
+/* RFC3209 */
+static const struct tok rsvp_obj_rro_label_flag_values[] = {
+ { 0x01, "Global" },
+ { 0, NULL}
+};
+
static const struct tok rsvp_resstyle_values[] = {
{ 17, "Wildcard Filter" },
{ 10, "Fixed Filter" },
@@ -369,11 +391,11 @@ static const struct tok rsvp_intserv_parameter_id_values[] = {
};
static struct tok rsvp_session_attribute_flag_values[] = {
- { 0x01, "Local Protection desired" },
- { 0x02, "Label Recording desired" },
- { 0x04, "SE Style desired" },
- { 0x08, "Bandwidth protection desired" }, /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */
- { 0x10, "Node protection desired" }, /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */
+ { 0x01, "Local Protection" },
+ { 0x02, "Label Recording" },
+ { 0x04, "SE Style" },
+ { 0x08, "Bandwidth protection" }, /* RFC4090 */
+ { 0x10, "Node protection" }, /* RFC4090 */
{ 0, NULL}
};
@@ -614,7 +636,16 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
}
static int
-rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
+rsvp_obj_print (const u_char *pptr
+#ifndef HAVE_LIBCRYPTO
+_U_
+#endif
+, u_int plen
+#ifndef HAVE_LIBCRYPTO
+_U_
+#endif
+, const u_char *tptr,
+ const char *ident, u_int tlen) {
const struct rsvp_object_header *rsvp_obj_header;
const u_char *obj_tptr;
@@ -624,7 +655,7 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
} obj_ptr;
u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen;
- int hexdump,processed,padbytes,error_code,error_value,i;
+ int hexdump,processed,padbytes,error_code,error_value,i,sigcheck;
union {
float f;
u_int32_t i;
@@ -728,7 +759,30 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
obj_tlen-=36;
obj_tptr+=36;
break;
+
+ case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */
+ if (obj_tlen < 26)
+ return -1;
+ printf("%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ident,
+ EXTRACT_32BITS(obj_tptr),
+ EXTRACT_16BITS(obj_tptr+6),
+ ip6addr_string(obj_tptr+8));
+ obj_tlen-=26;
+ obj_tptr+=26;
+ break;
#endif
+ case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
+ if (obj_tlen < 12)
+ return -1;
+ printf("%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ident,
+ ipaddr_string(obj_tptr),
+ EXTRACT_16BITS(obj_tptr+6),
+ ipaddr_string(obj_tptr+8));
+ obj_tlen-=12;
+ obj_tptr+=12;
+ break;
case RSVP_CTYPE_TUNNEL_IPV4:
case RSVP_CTYPE_UNI_IPV4:
if (obj_tlen < 12)
@@ -880,6 +934,20 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
obj_tlen-=20;
obj_tptr+=20;
break;
+ case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
+ if (obj_tlen < 40)
+ return-1;
+ printf("%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
+ ident,
+ ip6addr_string(obj_tptr),
+ EXTRACT_16BITS(obj_tptr+18),
+ ident,
+ ip6addr_string(obj_tptr+20),
+ EXTRACT_16BITS(obj_tptr+38));
+ obj_tlen-=40;
+ obj_tptr+=40;
+ break;
#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
@@ -891,6 +959,20 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
obj_tlen-=8;
obj_tptr+=8;
break;
+ case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
+ if (obj_tlen < 16)
+ return-1;
+ printf("%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
+ ident,
+ ipaddr_string(obj_tptr),
+ EXTRACT_16BITS(obj_tptr+6),
+ ident,
+ ipaddr_string(obj_tptr+8),
+ EXTRACT_16BITS(obj_tptr+12));
+ obj_tlen-=16;
+ obj_tptr+=16;
+ break;
default:
hexdump=TRUE;
}
@@ -999,6 +1081,18 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
bittok2str(rsvp_obj_rro_flag_values,
"none",
*(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */
+ break;
+ case RSVP_OBJ_XRO_LABEL:
+ printf(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
+ bittok2str(rsvp_obj_rro_label_flag_values,
+ "none",
+ *(obj_tptr+2)),
+ *(obj_tptr+2),
+ tok2str(rsvp_ctype_values,
+ "Unknown",
+ *(obj_tptr+3) + 256*RSVP_OBJ_RRO),
+ *(obj_tptr+3),
+ EXTRACT_32BITS(obj_tptr+4));
}
obj_tlen-=*(obj_tptr+1);
obj_tptr+=*(obj_tptr+1);
@@ -1055,14 +1149,14 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
printf("%s Session Name: ", ident);
for (i = 0; i < namelen; i++)
safeputchar(*(obj_tptr+4+i));
- printf("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s]",
+ printf("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
ident,
(int)*obj_tptr,
(int)*(obj_tptr+1),
- tok2str(rsvp_session_attribute_flag_values,
+ bittok2str(rsvp_session_attribute_flag_values,
"none",
- *(obj_tptr+2)));
-
+ *(obj_tptr+2)),
+ *(obj_tptr+2));
obj_tlen-=4+*(obj_tptr+3);
obj_tptr+=4+*(obj_tptr+3);
break;
@@ -1306,6 +1400,20 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
obj_tlen-=20;
obj_tptr+=20;
break;
+ case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
+ if (obj_tlen < 40)
+ return-1;
+ printf("%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
+ ident,
+ ip6addr_string(obj_tptr),
+ EXTRACT_16BITS(obj_tptr+18),
+ ident,
+ ip6addr_string(obj_tptr+20),
+ EXTRACT_16BITS(obj_tptr+38));
+ obj_tlen-=40;
+ obj_tptr+=40;
+ break;
#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
@@ -1317,6 +1425,20 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
obj_tlen-=8;
obj_tptr+=8;
break;
+ case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
+ if (obj_tlen < 16)
+ return-1;
+ printf("%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
+ ident,
+ ipaddr_string(obj_tptr),
+ EXTRACT_16BITS(obj_tptr+6),
+ ident,
+ ipaddr_string(obj_tptr+8),
+ EXTRACT_16BITS(obj_tptr+12));
+ obj_tlen-=16;
+ obj_tptr+=16;
+ break;
default:
hexdump=TRUE;
}
@@ -1544,12 +1666,21 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
bittok2str(rsvp_obj_integrity_flag_values,
"none",
obj_ptr.rsvp_obj_integrity->flags));
- printf("%s MD5-sum 0x%08x%08x%08x%08x (unverified)",
+ printf("%s MD5-sum 0x%08x%08x%08x%08x ",
ident,
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+12));
+
+#ifdef HAVE_LIBCRYPTO
+ sigcheck = signature_verify(pptr, plen, (unsigned char *)obj_ptr.\
+ rsvp_obj_integrity->digest);
+#else
+ sigcheck = CANT_CHECK_SIGNATURE;
+#endif
+ printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+
obj_tlen+=sizeof(struct rsvp_obj_integrity_t);
obj_tptr+=sizeof(struct rsvp_obj_integrity_t);
break;
@@ -1613,7 +1744,32 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
break;
}
break;
+ default:
+ hexdump=TRUE;
+ }
+ case RSVP_OBJ_S2L:
+ switch (rsvp_obj_ctype) {
+ case RSVP_CTYPE_IPV4:
+ if (obj_tlen < 4)
+ return-1;
+ printf("%s Sub-LSP destination address: %s",
+ ident, ipaddr_string(obj_tptr));
+
+ obj_tlen-=4;
+ obj_tptr+=4;
+ break;
+#ifdef INET6
+ case RSVP_CTYPE_IPV6:
+ if (obj_tlen < 16)
+ return-1;
+ printf("%s Sub-LSP destination address: %s",
+ ident, ip6addr_string(obj_tptr));
+
+ obj_tlen-=16;
+ obj_tptr+=16;
+ break;
+#endif
default:
hexdump=TRUE;
}
@@ -1650,13 +1806,13 @@ trunc:
void
rsvp_print(register const u_char *pptr, register u_int len) {
- const struct rsvp_common_header *rsvp_com_header;
+ struct rsvp_common_header *rsvp_com_header;
const u_char *tptr,*subtptr;
- u_short tlen,subtlen;
+ u_short plen, tlen, subtlen;
tptr=pptr;
- rsvp_com_header = (const struct rsvp_common_header *)pptr;
+ rsvp_com_header = (struct rsvp_common_header *)pptr;
TCHECK(*rsvp_com_header);
/*
@@ -1679,7 +1835,7 @@ rsvp_print(register const u_char *pptr, register u_int len) {
/* ok they seem to want to know everything - lets fully decode it */
- tlen=EXTRACT_16BITS(rsvp_com_header->length);
+ plen = tlen = EXTRACT_16BITS(rsvp_com_header->length);
printf("\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
@@ -1690,6 +1846,12 @@ rsvp_print(register const u_char *pptr, register u_int len) {
rsvp_com_header->ttl,
EXTRACT_16BITS(rsvp_com_header->checksum));
+ /*
+ * Clear checksum prior to signature verification.
+ */
+ rsvp_com_header->checksum[0] = 0;
+ rsvp_com_header->checksum[1] = 0;
+
if (tlen < sizeof(const struct rsvp_common_header)) {
printf("ERROR: common header too short %u < %lu", tlen,
(unsigned long)sizeof(const struct rsvp_common_header));
@@ -1704,7 +1866,7 @@ rsvp_print(register const u_char *pptr, register u_int len) {
case RSVP_MSGTYPE_AGGREGATE:
while(tlen > 0) {
subtptr=tptr;
- rsvp_com_header = (const struct rsvp_common_header *)subtptr;
+ rsvp_com_header = (struct rsvp_common_header *)subtptr;
TCHECK(*rsvp_com_header);
/*
@@ -1725,6 +1887,12 @@ rsvp_print(register const u_char *pptr, register u_int len) {
subtlen,
rsvp_com_header->ttl,
EXTRACT_16BITS(rsvp_com_header->checksum));
+
+ /*
+ * Clear checksum prior to signature verification.
+ */
+ rsvp_com_header->checksum[0] = 0;
+ rsvp_com_header->checksum[1] = 0;
if (subtlen < sizeof(const struct rsvp_common_header)) {
printf("ERROR: common header too short %u < %lu", subtlen,
@@ -1741,7 +1909,7 @@ rsvp_print(register const u_char *pptr, register u_int len) {
subtptr+=sizeof(const struct rsvp_common_header);
subtlen-=sizeof(const struct rsvp_common_header);
- if (rsvp_obj_print(subtptr,"\n\t ", subtlen) == -1)
+ if (rsvp_obj_print(pptr, plen, subtptr,"\n\t ", subtlen) == -1)
return;
tptr+=subtlen+sizeof(const struct rsvp_common_header);
@@ -1761,7 +1929,7 @@ rsvp_print(register const u_char *pptr, register u_int len) {
case RSVP_MSGTYPE_HELLO:
case RSVP_MSGTYPE_ACK:
case RSVP_MSGTYPE_SREFRESH:
- if (rsvp_obj_print(tptr,"\n\t ", tlen) == -1)
+ if (rsvp_obj_print(pptr, plen, tptr,"\n\t ", tlen) == -1)
return;
break;
diff --git a/print-rx.c b/print-rx.c
index 3812a120fc69..70393ea5cbbe 100644
--- a/print-rx.c
+++ b/print-rx.c
@@ -34,7 +34,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.39.2.3 2008-07-01 07:45:09 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.42 2008-07-01 07:44:50 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
diff --git a/print-sctp.c b/print-sctp.c
index 05c753a52e6c..0229396de66d 100644
--- a/print-sctp.c
+++ b/print-sctp.c
@@ -59,6 +59,29 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
+#define CHAN_HP 6700
+#define CHAN_MP 6701
+#define CHAN_LP 6702
+
+struct tok ForCES_channels[] = {
+ { CHAN_HP, "ForCES HP" },
+ { CHAN_MP, "ForCES MP" },
+ { CHAN_LP, "ForCES LP" },
+ { 0, NULL }
+};
+
+static inline int isForCES_port(u_short Port)
+{
+ if (Port == CHAN_HP)
+ return 1;
+ if (Port == CHAN_MP)
+ return 1;
+ if (Port == CHAN_LP)
+ return 1;
+
+ return 0;
+}
+
void sctp_print(const u_char *bp, /* beginning of sctp packet */
const u_char *bp2, /* beginning of enclosing */
u_int sctpPacketLength) /* ip packet */
@@ -74,6 +97,8 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
const struct sctpChunkDesc *chunkDescPtr;
const void *nextChunk;
const char *sep;
+ int isforces = 0;
+
sctpPktHdr = (const struct sctpHeader*) bp;
endPacketPtr = (const u_char*)sctpPktHdr+sctpPacketLength;
@@ -120,6 +145,15 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
}
fflush(stdout);
+ if (isForCES_port(sourcePort)) {
+ printf("[%s]", tok2str(ForCES_channels, NULL, sourcePort));
+ isforces = 1;
+ }
+ if (isForCES_port(destPort)) {
+ printf("[%s]", tok2str(ForCES_channels, NULL, destPort));
+ isforces = 1;
+ }
+
if (vflag >= 2)
sep = "\n\t";
else
@@ -193,9 +227,23 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
printf("[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence));
printf("[PPID 0x%x] ", EXTRACT_32BITS(&dataHdrPtr->payloadtype));
fflush(stdout);
-
- if (vflag >= 2) /* if verbose output is specified */
- { /* at the command line */
+ if (isforces) {
+ const u_char *payloadPtr;
+ u_int chunksize = sizeof(struct sctpDataPart)+
+ sizeof(struct sctpChunkDesc);
+ payloadPtr = (const u_char *) (dataHdrPtr + 1);
+ if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
+ sizeof(struct sctpDataPart)+
+ sizeof(struct sctpChunkDesc)+1) {
+ /* Less than 1 byte of chunk payload */
+ printf("bogus ForCES chunk length %u]",
+ EXTRACT_16BITS(&chunkDescPtr->chunkLength));
+ return;
+ }
+
+ forces_print(payloadPtr, EXTRACT_16BITS(&chunkDescPtr->chunkLength)- chunksize);
+ } else if (vflag >= 2) { /* if verbose output is specified */
+ /* at the command line */
const u_char *payloadPtr;
printf("[Payload");
@@ -203,16 +251,16 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
if (!suppress_default_print) {
payloadPtr = (const u_char *) (++dataHdrPtr);
printf(":");
- if (htons(chunkDescPtr->chunkLength) <
+ if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
sizeof(struct sctpDataPart)+
sizeof(struct sctpChunkDesc)+1) {
/* Less than 1 byte of chunk payload */
printf("bogus chunk length %u]",
- htons(chunkDescPtr->chunkLength));
+ EXTRACT_16BITS(&chunkDescPtr->chunkLength));
return;
}
default_print(payloadPtr,
- htons(chunkDescPtr->chunkLength) -
+ EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
(sizeof(struct sctpDataPart)+
sizeof(struct sctpChunkDesc)));
} else
diff --git a/print-sip.c b/print-sip.c
index 48562f8c38bc..c5bc8534daaa 100644
--- a/print-sip.c
+++ b/print-sip.c
@@ -44,6 +44,7 @@ sip_print(register const u_char *pptr, register u_int len)
return;
for (idx = 0; idx < len; idx++) {
+ TCHECK2(*(pptr+idx), 2);
if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */
safeputchar(*(pptr+idx));
} else {
@@ -57,4 +58,7 @@ sip_print(register const u_char *pptr, register u_int len)
print_unknown_data(pptr,"\n\t",len);
return;
+
+trunc:
+ printf("[|sip]");
}
diff --git a/print-sll.c b/print-sll.c
index d96b3de29ee2..c9546585dcb1 100644
--- a/print-sll.c
+++ b/print-sll.c
@@ -85,7 +85,7 @@ sll_print(register const struct sll_header *sllp, u_int length)
/*
* 802.2.
*/
- (void)printf("802.3");
+ (void)printf("802.2");
break;
default:
@@ -142,8 +142,9 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
- ether_type = ntohs(sllp->sll_protocol);
+ ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
+recurse:
/*
* Is it (gag) an 802.3 encapsulation, or some non-Ethernet
* packet type?
@@ -187,13 +188,43 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
default_print(p, caplen);
break;
}
- } else if (ether_encap_print(ether_type, p, length, caplen,
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- sll_print(sllp, length + SLL_HDR_LEN);
- if (!suppress_default_print)
- default_print(p, caplen);
+ } else if (ether_type == ETHERTYPE_8021Q) {
+ /*
+ * Print VLAN information, and then go back and process
+ * the enclosed type field.
+ */
+ if (caplen < 4 || length < 4) {
+ printf("[|vlan]");
+ return (SLL_HDR_LEN);
+ }
+ if (eflag) {
+ u_int16_t tag = EXTRACT_16BITS(p);
+
+ printf("vlan %u, p %u%s, ",
+ tag & 0xfff,
+ tag >> 13,
+ (tag & 0x1000) ? ", CFI" : "");
+ }
+
+ ether_type = EXTRACT_16BITS(p + 2);
+ if (ether_type <= ETHERMTU)
+ ether_type = LINUX_SLL_P_802_2;
+ if (!qflag) {
+ (void)printf("ethertype %s, ",
+ tok2str(ethertype_values, "Unknown", ether_type));
+ }
+ p += 4;
+ length -= 4;
+ caplen -= 4;
+ goto recurse;
+ } else {
+ if (ethertype_print(ether_type, p, length, caplen) == 0) {
+ /* ether_type not known, print raw packet */
+ if (!eflag)
+ sll_print(sllp, length + SLL_HDR_LEN);
+ if (!suppress_default_print)
+ default_print(p, caplen);
+ }
}
return (SLL_HDR_LEN);
diff --git a/print-smb.c b/print-smb.c
index 391f1860c6d9..68c73659f84f 100644
--- a/print-smb.c
+++ b/print-smb.c
@@ -12,7 +12,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.46.2.1 2007-12-09 00:31:35 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.47 2007-12-09 00:30:47 guy Exp $";
#endif
#include <tcpdump-stdinc.h>
diff --git a/print-sunrpc.c b/print-sunrpc.c
index bfb2fe9a7910..e33b7625e14e 100644
--- a/print-sunrpc.c
+++ b/print-sunrpc.c
@@ -28,6 +28,21 @@ static const char rcsid[] _U_ =
#include "config.h"
#endif
+/*
+ * At least on HP-UX:
+ *
+ * 1) getrpcbynumber() is declared in <netdb.h>, not any of the RPC
+ * header files
+ *
+ * and
+ *
+ * 2) if _XOPEN_SOURCE_EXTENDED is defined, <netdb.h> doesn't declare
+ * it
+ *
+ * so we undefine it.
+ */
+#undef _XOPEN_SOURCE_EXTENDED
+
#include <tcpdump-stdinc.h>
#ifdef HAVE_GETRPCBYNUMBER
diff --git a/print-symantec.c b/print-symantec.c
index ebb62cd4d135..0fba8e534de4 100644
--- a/print-symantec.c
+++ b/print-symantec.c
@@ -33,6 +33,7 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -52,7 +53,7 @@ symantec_hdr_print(register const u_char *bp, u_int length)
sp = (const struct symantec_header *)bp;
- etype = ntohs(sp->ether_type);
+ etype = EXTRACT_16BITS(&sp->ether_type);
if (!qflag) {
if (etype <= ETHERMTU)
(void)printf("invalid ethertype %u", etype);
@@ -83,7 +84,6 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_int caplen = h->caplen;
struct symantec_header *sp;
u_short ether_type;
- u_short extracted_ether_type;
if (caplen < sizeof (struct symantec_header)) {
printf("[|symantec]");
@@ -98,7 +98,7 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
sp = (struct symantec_header *)p;
p += sizeof (struct symantec_header);
- ether_type = ntohs(sp->ether_type);
+ ether_type = EXTRACT_16BITS(&sp->ether_type);
if (ether_type <= ETHERMTU) {
/* ether_type not known, print raw packet */
@@ -107,8 +107,7 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
if (!suppress_default_print)
default_print(p, caplen);
- } else if (ether_encap_print(ether_type, p, length, caplen,
- &extracted_ether_type) == 0) {
+ } else if (ethertype_print(ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
diff --git a/print-tcp.c b/print-tcp.c
index 5b0a7969a583..e2559ecf64ca 100644
--- a/print-tcp.c
+++ b/print-tcp.c
@@ -25,8 +25,8 @@
#ifndef lint
static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.130.2.3 2007-12-22 03:08:45 guy Exp $ (LBL)";
- #else
+"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.135 2008-11-09 23:35:03 mcr Exp $ (LBL)";
+#else
__RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
#endif
@@ -58,10 +58,7 @@ __RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
#ifdef HAVE_LIBCRYPTO
#include <openssl/md5.h>
-
-#define SIGNATURE_VALID 0
-#define SIGNATURE_INVALID 1
-#define CANT_CHECK_SIGNATURE 2
+#include <signature.h>
static int tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
const u_char *data, int length, const u_char *rcvsig);
@@ -124,6 +121,7 @@ struct tok tcp_option_values[] = {
{ TCPOPT_CCECHO, "" },
{ TCPOPT_SIGNATURE, "md5" },
{ TCPOPT_AUTH, "enhanced auth" },
+ { TCPOPT_UTO, "uto" },
{ 0, NULL }
};
@@ -158,37 +156,6 @@ static int tcp_cksum(register const struct ip *ip,
sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]);
}
-#ifdef INET6
-static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp,
- u_int len)
-{
- size_t i;
- u_int32_t sum = 0;
- union {
- struct {
- struct in6_addr ph_src;
- struct in6_addr ph_dst;
- u_int32_t ph_len;
- u_int8_t ph_zero[3];
- u_int8_t ph_nxt;
- } ph;
- u_int16_t pa[20];
- } phu;
-
- /* pseudo-header */
- memset(&phu, 0, sizeof(phu));
- phu.ph.ph_src = ip6->ip6_src;
- phu.ph.ph_dst = ip6->ip6_dst;
- phu.ph.ph_len = htonl(len);
- phu.ph.ph_nxt = IPPROTO_TCP;
-
- for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
- sum += phu.pa[i];
-
- return in_cksum((u_short *)tp, len, sum);
-}
-#endif
-
void
tcp_print(register const u_char *bp, register u_int length,
register const u_char *bp2, int fragmented)
@@ -200,6 +167,7 @@ tcp_print(register const u_char *bp, register u_int length,
register char ch;
u_int16_t sport, dport, win, urp;
u_int32_t seq, ack, thseq, thack;
+ u_int utoval;
int threv;
#ifdef INET6
register const struct ip6_hdr *ip6;
@@ -442,7 +410,7 @@ tcp_print(register const u_char *bp, register u_int length,
if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !Kflag && !fragmented) {
u_int16_t sum,tcp_sum;
if (TTEST2(tp->th_sport, length)) {
- sum = tcp6_cksum(ip6, tp, length);
+ sum = nextproto6_cksum(ip6, (u_short *)tp, length, IPPROTO_TCP);
(void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum));
if (sum != 0) {
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
@@ -455,7 +423,7 @@ tcp_print(register const u_char *bp, register u_int length,
#endif
length -= hlen;
- if (vflag > 1 || flags & (TH_SYN | TH_FIN | TH_RST)) {
+ if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
(void)printf(", seq %u", seq);
if (length > 0) {
@@ -613,6 +581,18 @@ tcp_print(register const u_char *bp, register u_int length,
*/
break;
+ case TCPOPT_UTO:
+ datalen = 2;
+ LENCHECK(datalen);
+ utoval = EXTRACT_16BITS(cp);
+ (void)printf("0x%x", utoval);
+ if (utoval & 0x0001)
+ utoval = (utoval >> 1) * 60;
+ else
+ utoval >>= 1;
+ (void)printf(" %u", utoval);
+ break;
+
default:
datalen = len - 2;
for (i = 0; i < datalen; ++i) {
@@ -750,10 +730,17 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
u_int8_t nxt;
#endif
+ if (data + length > snapend) {
+ printf("snaplen too short, ");
+ return (CANT_CHECK_SIGNATURE);
+ }
+
tp1 = *tp;
- if (tcpmd5secret == NULL)
+ if (sigsecret == NULL) {
+ printf("shared secret not supplied with -M, ");
return (CANT_CHECK_SIGNATURE);
+ }
MD5_Init(&ctx);
/*
@@ -772,7 +759,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
ip6 = (struct ip6_hdr *)ip;
MD5_Update(&ctx, (char *)&ip6->ip6_src, sizeof(ip6->ip6_src));
MD5_Update(&ctx, (char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst));
- len32 = htonl(ntohs(ip6->ip6_plen));
+ len32 = htonl(EXTRACT_16BITS(&ip6->ip6_plen));
MD5_Update(&ctx, (char *)&len32, sizeof(len32));
nxt = 0;
MD5_Update(&ctx, (char *)&nxt, sizeof(nxt));
@@ -781,8 +768,14 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
nxt = IPPROTO_TCP;
MD5_Update(&ctx, (char *)&nxt, sizeof(nxt));
#endif
- } else
+ } else {
+#ifdef INET6
+ printf("IP version not 4 or 6, ");
+#else
+ printf("IP version not 4, ");
+#endif
return (CANT_CHECK_SIGNATURE);
+ }
/*
* Step 2: Update MD5 hash with TCP header, excluding options.
@@ -800,7 +793,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
/*
* Step 4: Update MD5 hash with shared secret.
*/
- MD5_Update(&ctx, tcpmd5secret, strlen(tcpmd5secret));
+ MD5_Update(&ctx, sigsecret, strlen(sigsecret));
MD5_Final(sig, &ctx);
if (memcmp(rcvsig, sig, TCP_SIGLEN) == 0)
diff --git a/print-tftp.c b/print-tftp.c
index c4fc7ea2afbe..0caff4284323 100644
--- a/print-tftp.c
+++ b/print-tftp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.38.2.1 2008-04-11 16:44:17 gianluca Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.39 2008-04-11 16:47:38 gianluca Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
diff --git a/print-token.c b/print-token.c
index 04defa9921b6..4f8422b5ab1b 100644
--- a/print-token.c
+++ b/print-token.c
@@ -39,6 +39,7 @@ static const char rcsid[] _U_ =
#include <string.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -126,7 +127,16 @@ token_print(const u_char *p, u_int length, u_int caplen)
if (eflag)
token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+ if (caplen < TOKEN_HDRLEN + 2) {
+ printf("[|token-ring]");
+ return hdr_len;
+ }
route_len = RIF_LENGTH(trp);
+ hdr_len += route_len;
+ if (caplen < hdr_len) {
+ printf("[|token-ring]");
+ return hdr_len;
+ }
if (vflag) {
printf("%s ", broadcast_indicator[BROADCAST(trp)]);
printf("%s", direction[DIRECTION(trp)]);
@@ -135,10 +145,10 @@ token_print(const u_char *p, u_int length, u_int caplen)
printf(" [%d:%d]", RING_NUMBER(trp, seg),
BRIDGE_NUMBER(trp, seg));
} else {
- printf("rt = %x", ntohs(trp->token_rcf));
+ printf("rt = %x", EXTRACT_16BITS(&trp->token_rcf));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(":%x", ntohs(trp->token_rseg[seg]));
+ printf(":%x", EXTRACT_16BITS(&trp->token_rseg[seg]));
}
printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
} else {
@@ -147,7 +157,6 @@ token_print(const u_char *p, u_int length, u_int caplen)
}
/* Skip over token ring MAC header and routing information */
- hdr_len += route_len;
length -= hdr_len;
p += hdr_len;
caplen -= hdr_len;
diff --git a/print-udp.c b/print-udp.c
index f534c1bb459e..0f1528e019f1 100644
--- a/print-udp.c
+++ b/print-udp.c
@@ -568,7 +568,7 @@ udp_print(register const u_char *bp, u_int length,
}
udpipaddr_print(ip, sport, dport);
- if (IP_V(ip) == 4 && (vflag > 1) && !fragmented) {
+ if (IP_V(ip) == 4 && (vflag > 1) && !Kflag && !fragmented) {
int sum = up->uh_sum;
if (sum == 0) {
(void)printf("[no cksum] ");
@@ -581,7 +581,7 @@ udp_print(register const u_char *bp, u_int length,
}
}
#ifdef INET6
- if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) {
+ if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !Kflag && !fragmented) {
int sum = up->uh_sum;
/* for IPv6, UDP checksum is mandatory */
if (TTEST2(cp[0], length)) {
@@ -672,11 +672,16 @@ udp_print(register const u_char *bp, u_int length,
hsrp_print((const u_char *)(up + 1), length);
else if (ISPORT(LWRES_PORT))
lwres_print((const u_char *)(up + 1), length);
- else if (ISPORT(LDP_PORT))
+ else if (ISPORT(LDP_PORT))
ldp_print((const u_char *)(up + 1), length);
- else if (ISPORT(OLSR_PORT))
- olsr_print((const u_char *)(up + 1), length);
- else if (ISPORT(MPLS_LSP_PING_PORT))
+ else if (ISPORT(OLSR_PORT))
+ olsr_print((const u_char *)(up + 1), length,
+#if INET6
+ (IP_V(ip) == 6) ? 1 : 0);
+#else
+ 0);
+#endif
+ else if (ISPORT(MPLS_LSP_PING_PORT))
lspping_print((const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
dport == BFD_ECHO_PORT )
diff --git a/print-usb.c b/print-usb.c
new file mode 100644
index 000000000000..8e15e7bf39d1
--- /dev/null
+++ b/print-usb.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2009 Bert Vermeulen <bert@biot.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 Paolo Abeni.''
+ * The name of author may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Support for USB packets
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <pcap.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+
+
+#if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
+#include <pcap/usb.h>
+
+/* returns direction: 1=inbound 2=outbound -1=invalid */
+static int
+get_direction(int transfer_type, int event_type)
+{
+ int direction;
+
+ direction = -1;
+ switch(transfer_type){
+ case URB_BULK:
+ case URB_CONTROL:
+ case URB_ISOCHRONOUS:
+ switch(event_type)
+ {
+ case URB_SUBMIT:
+ direction = 2;
+ break;
+ case URB_COMPLETE:
+ case URB_ERROR:
+ direction = 1;
+ break;
+ default:
+ direction = -1;
+ }
+ break;
+ case URB_INTERRUPT:
+ switch(event_type)
+ {
+ case URB_SUBMIT:
+ direction = 1;
+ break;
+ case URB_COMPLETE:
+ case URB_ERROR:
+ direction = 2;
+ break;
+ default:
+ direction = -1;
+ }
+ break;
+ default:
+ direction = -1;
+ }
+
+ return direction;
+}
+
+static void
+usb_header_print(const pcap_usb_header *uh)
+{
+ int direction;
+
+ switch(uh->transfer_type)
+ {
+ case URB_ISOCHRONOUS:
+ printf("ISOCHRONOUS");
+ break;
+ case URB_INTERRUPT:
+ printf("INTERRUPT");
+ break;
+ case URB_CONTROL:
+ printf("CONTROL");
+ break;
+ case URB_BULK:
+ printf("BULK");
+ break;
+ default:
+ printf(" ?");
+ }
+
+ switch(uh->event_type)
+ {
+ case URB_SUBMIT:
+ printf(" SUBMIT");
+ break;
+ case URB_COMPLETE:
+ printf(" COMPLETE");
+ break;
+ case URB_ERROR:
+ printf(" ERROR");
+ break;
+ default:
+ printf(" ?");
+ }
+
+ direction = get_direction(uh->transfer_type, uh->event_type);
+ if(direction == 1)
+ printf(" from");
+ else if(direction == 2)
+ printf(" to");
+ printf(" %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f);
+}
+
+/*
+ * This is the top level routine of the printer for captures with a
+ * 48-byte header.
+ *
+ * 'p' points to the header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+{
+ if (h->caplen < sizeof(pcap_usb_header)) {
+ printf("[|usb]");
+ return(sizeof(pcap_usb_header));
+ }
+
+ usb_header_print((const pcap_usb_header *) p);
+
+ return(sizeof(pcap_usb_header));
+}
+
+#ifdef DLT_USB_LINUX_MMAPPED
+/*
+ * This is the top level routine of the printer for captures with a
+ * 64-byte header.
+ *
+ * 'p' points to the header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+usb_linux_64_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+{
+ if (h->caplen < sizeof(pcap_usb_header_mmapped)) {
+ printf("[|usb]");
+ return(sizeof(pcap_usb_header_mmapped));
+ }
+
+ usb_header_print((const pcap_usb_header *) p);
+
+ return(sizeof(pcap_usb_header_mmapped));
+}
+#endif /* DLT_USB_LINUX_MMAPPED */
+
+#endif /* defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX) */
+
diff --git a/setsignal.h b/setsignal.h
index cc8e86c24292..984c34073072 100644
--- a/setsignal.h
+++ b/setsignal.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/setsignal.h,v 1.2.1.1 1999-10-07 23:47:13 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/setsignal.h,v 1.2 1999-10-07 23:47:13 mcr Exp $ (LBL)
*/
#ifndef setsignal_h
#define setsignal_h
diff --git a/signature.c b/signature.c
new file mode 100644
index 000000000000..c55645fe2bdf
--- /dev/null
+++ b/signature.c
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ * 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.
+ *
+ * Functions for signature and digest verification.
+ *
+ * Original code by Hannes Gredler (hannes@juniper.net)
+ */
+
+#ifndef lint
+static const char rcsid[] _U_ =
+ "@(#) $Header: /tcpdump/master/tcpdump/signature.c,v 1.2 2008-09-22 20:22:10 guy Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <string.h>
+
+#include "interface.h"
+#include "signature.h"
+
+#ifdef HAVE_LIBCRYPTO
+#include <openssl/md5.h>
+#endif
+
+const struct tok signature_check_values[] = {
+ { SIGNATURE_VALID, "valid"},
+ { SIGNATURE_INVALID, "invalid"},
+ { CANT_CHECK_SIGNATURE, "unchecked"},
+ { 0, NULL }
+};
+
+
+#ifdef HAVE_LIBCRYPTO
+/*
+ * Compute a HMAC MD5 sum.
+ * Taken from rfc2104, Appendix.
+ */
+static void
+signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *key,
+ unsigned int key_len, u_int8_t *digest)
+{
+ MD5_CTX context;
+ unsigned char k_ipad[65]; /* inner padding - key XORd with ipad */
+ unsigned char k_opad[65]; /* outer padding - key XORd with opad */
+ unsigned char tk[16];
+ int i;
+
+ /* if key is longer than 64 bytes reset it to key=MD5(key) */
+ if (key_len > 64) {
+
+ MD5_CTX tctx;
+
+ MD5_Init(&tctx);
+ MD5_Update(&tctx, key, key_len);
+ MD5_Final(tk, &tctx);
+
+ key = tk;
+ key_len = 16;
+ }
+
+ /*
+ * the HMAC_MD5 transform looks like:
+ *
+ * MD5(K XOR opad, MD5(K XOR ipad, text))
+ *
+ * where K is an n byte key
+ * ipad is the byte 0x36 repeated 64 times
+ * opad is the byte 0x5c repeated 64 times
+ * and text is the data being protected
+ */
+
+ /* start out by storing key in pads */
+ memset(k_ipad, 0, sizeof k_ipad);
+ memset(k_opad, 0, sizeof k_opad);
+ memcpy(k_ipad, key, key_len);
+ memcpy(k_opad, key, key_len);
+
+ /* XOR key with ipad and opad values */
+ for (i=0; i<64; i++) {
+ k_ipad[i] ^= 0x36;
+ k_opad[i] ^= 0x5c;
+ }
+
+ /*
+ * perform inner MD5
+ */
+ MD5_Init(&context); /* init context for 1st pass */
+ MD5_Update(&context, k_ipad, 64); /* start with inner pad */
+ MD5_Update(&context, text, text_len); /* then text of datagram */
+ MD5_Final(digest, &context); /* finish up 1st pass */
+
+ /*
+ * perform outer MD5
+ */
+ MD5_Init(&context); /* init context for 2nd pass */
+ MD5_Update(&context, k_opad, 64); /* start with outer pad */
+ MD5_Update(&context, digest, 16); /* then results of 1st hash */
+ MD5_Final(digest, &context); /* finish up 2nd pass */
+}
+#endif
+
+#ifdef HAVE_LIBCRYPTO
+/*
+ * Verify a cryptographic signature of the packet.
+ * Currently only MD5 is supported.
+ */
+int
+signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
+{
+ u_int8_t rcvsig[16];
+ u_int8_t sig[16];
+ unsigned int i;
+
+ /*
+ * Save the signature before clearing it.
+ */
+ memcpy(rcvsig, sig_ptr, sizeof(rcvsig));
+ memset(sig_ptr, 0, sizeof(rcvsig));
+
+ if (!sigsecret) {
+ return (CANT_CHECK_SIGNATURE);
+ }
+
+ signature_compute_hmac_md5(pptr, plen, (unsigned char *)sigsecret,
+ strlen(sigsecret), sig);
+
+ if (memcmp(rcvsig, sig, sizeof(sig)) == 0) {
+ return (SIGNATURE_VALID);
+
+ } else {
+
+ for (i = 0; i < sizeof(sig); ++i) {
+ (void)printf("%02x", sig[i]);
+ }
+
+ return (SIGNATURE_INVALID);
+ }
+}
+#endif
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/signature.h b/signature.h
new file mode 100644
index 000000000000..e48b722988aa
--- /dev/null
+++ b/signature.h
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ * 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.
+ *
+ * Functions for signature and digest verification.
+ *
+ * Original code by Hannes Gredler (hannes@juniper.net)
+ */
+
+/* @(#) $Header: /tcpdump/master/tcpdump/signature.h,v 1.1 2008-08-16 11:36:20 hannes Exp $ (LBL) */
+
+/* signature checking result codes */
+#define SIGNATURE_VALID 0
+#define SIGNATURE_INVALID 1
+#define CANT_CHECK_SIGNATURE 2
+
+extern const struct tok signature_check_values[];
+extern int signature_verify (const u_char *, u_int, u_char *);
diff --git a/sll.h b/sll.h
index bad31e27a49f..0a34963a5300 100644
--- a/sll.h
+++ b/sll.h
@@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.7.6.1 2008-05-30 01:38:21 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.8 2008-05-30 01:37:41 guy Exp $ (LBL)
*/
/*
diff --git a/smbutil.c b/smbutil.c
index ba7ec31a9868..5eadb4fdb564 100644
--- a/smbutil.c
+++ b/smbutil.c
@@ -900,7 +900,7 @@ static const err_code_struct dos_msgs[] = {
};
/* Server Error Messages */
-err_code_struct server_msgs[] = {
+static const 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." },
@@ -937,7 +937,7 @@ err_code_struct server_msgs[] = {
};
/* Hard Error Messages */
-err_code_struct hard_msgs[] = {
+static const err_code_struct hard_msgs[] = {
{ "ERRnowrite", 19, "Attempt to write on write-protected diskette." },
{ "ERRbadunit", 20, "Unknown unit." },
{ "ERRnotready", 21, "Drive not ready." },
diff --git a/strcasecmp.c b/strcasecmp.c
index f19ccf547d1a..5504e0aff5a7 100644
--- a/strcasecmp.c
+++ b/strcasecmp.c
@@ -28,7 +28,7 @@ static const char rcsid[] _U_ =
* together for a case independent comparison. The mappings are
* based upon ascii character sequences.
*/
-static u_char charmap[] = {
+static const u_char charmap[] = {
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
@@ -67,7 +67,7 @@ int
strcasecmp(s1, s2)
const char *s1, *s2;
{
- register u_char *cm = charmap,
+ register const u_char *cm = charmap,
*us1 = (u_char *)s1,
*us2 = (u_char *)s2;
@@ -82,7 +82,7 @@ strncasecmp(s1, s2, n)
const char *s1, *s2;
register int n;
{
- register u_char *cm = charmap,
+ register const u_char *cm = charmap,
*us1 = (u_char *)s1,
*us2 = (u_char *)s2;
diff --git a/tcp.h b/tcp.h
index db7dd44775e6..ac83714fe29e 100644
--- a/tcp.h
+++ b/tcp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.13.2.1 2007-12-09 00:31:35 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.14 2007-12-09 00:30:47 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -83,6 +83,9 @@ struct tcphdr {
#define TCPOLEN_SIGNATURE 18
#define TCP_SIGLEN 16 /* length of an option 19 digest */
#define TCPOPT_AUTH 20 /* Enhanced AUTH option */
+#define TCPOPT_UTO 28 /* tcp user timeout (rfc5482) */
+#define TCPOLEN_UTO 4
+
#define TCPOPT_TSTAMP_HDR \
(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
diff --git a/tcpdump-stdinc.h b/tcpdump-stdinc.h
index 30d42fcd507b..c437cc10fe9a 100644
--- a/tcpdump-stdinc.h
+++ b/tcpdump-stdinc.h
@@ -29,7 +29,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
- * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.17 2006-05-19 17:55:34 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.18 2007-11-24 18:13:33 mcr Exp $ (LBL)
*/
/*
@@ -55,6 +55,10 @@
#include <sys/types.h>
#include <net/netdb.h> /* in wpcap's Win32/include */
+#ifndef NBBY
+#define NBBY 8
+#endif
+
#if !defined(__MINGW32__) && !defined(__WATCOMC__)
#undef toascii
#define isascii __isascii
@@ -143,21 +147,21 @@ typedef char* caddr_t;
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
-#if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl)
+#if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl)
#undef ntohl
#undef ntohs
#undef htonl
#undef htons
- extern __inline__ unsigned long __ntohl (unsigned long x);
- extern __inline__ unsigned short __ntohs (unsigned short x);
+ static __inline__ unsigned long __ntohl (unsigned long x);
+ static __inline__ unsigned short __ntohs (unsigned short x);
#define ntohl(x) __ntohl(x)
#define ntohs(x) __ntohs(x)
#define htonl(x) __ntohl(x)
#define htons(x) __ntohs(x)
- extern __inline__ unsigned long __ntohl (unsigned long x)
+ static __inline__ unsigned long __ntohl (unsigned long x)
{
__asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */
"rorl $16, %0\n\t" /* swap words */
@@ -166,7 +170,7 @@ typedef char* caddr_t;
return (x);
}
- extern __inline__ unsigned short __ntohs (unsigned short x)
+ static __inline__ unsigned short __ntohs (unsigned short x)
{
__asm__ ("xchgb %b0, %h0" /* swap bytes */
: "=q" (x) : "0" (x));
diff --git a/tcpdump.1 b/tcpdump.1.in
index 50efc31c5621..5e1a00f82848 100644
--- a/tcpdump.1
+++ b/tcpdump.1.in
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.185.2.6 2008-05-30 01:38:21 guy Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1.in,v 1.2 2008-11-09 23:35:03 mcr Exp $ (LBL)
.\"
.\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
.\"
@@ -22,14 +22,14 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "07 January 2008"
+.TH TCPDUMP 1 "05 March 2009"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
.na
.B tcpdump
[
-.B \-AdDefIKlLnNOpqRStuUvxX
+.B \-AbdDefIKlLnNOpqRStuUvxX
] [
.B \-B
.I buffer_size
@@ -191,6 +191,10 @@ special privileges.
Print each packet (minus its link level header) in ASCII. Handy for
capturing web pages.
.TP
+.B \-b
+Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN
+notation.
+.TP
.B \-B
Set the operating system capture buffer size to \fIbuffer_size\fP.
.TP
@@ -344,11 +348,21 @@ any wireless networks with that adapter. This could prevent accessing
files on a network server, or resolving host names or network addresses,
if you are capturing in monitor mode and are not connected to another
network with another adapter.
+.IP
+This flag will affect the output of the
+.B \-L
+flag. If
+.B \-I
+isn't specified, only those link-layer types available when not in
+monitor mode will be shown; if
+.B \-I
+is specified, only those link-layer types available when in monitor mode
+will be shown.
.TP
.B \-K
-Don't attempt to verify TCP checksums. This is useful for interfaces
-that perform the TCP checksum calculation in hardware; otherwise,
-all outgoing TCP checksums will be flagged as bad.
+Don't attempt to verify IP, TCP, or UDP checksums. This is useful for
+interfaces that perform some or all of those checksum calculation in
+hardware; otherwise, all outgoing TCP checksums will be flagged as bad.
.TP
.B \-l
Make stdout line buffered.
@@ -360,7 +374,15 @@ E.g.,
``tcpdump\ \ \-l \ \ > dat\ \ &\ \ tail\ \ \-f\ \ dat''.
.TP
.B \-L
-List the known data link types for the interface and exit.
+List the known data link types for the interface, in the specified mode,
+and exit. The list of known data link types may be dependent on the
+specified mode; for example, on some platforms, a Wi-Fi interface might
+support one set of data link types when not in monitor mode (for
+example, it might support only fake Ethernet headers, or might support
+802.11 headers but not support 802.11 headers with radio information)
+and another set of data link types when in monitor mode (for example, it
+might support 802.11 headers, or 802.11 headers with radio information,
+only in monitor mode).
.TP
.B \-m
Load SMI MIB module definitions from file \fImodule\fR.
@@ -414,10 +436,7 @@ Print absolute, rather than relative, TCP sequence numbers.
.TP
.B \-s
Snarf \fIsnaplen\fP bytes of data from each packet rather than the
-default of 68 (with SunOS's NIT, the minimum is actually 96).
-68 bytes is adequate for IP, ICMP, TCP
-and UDP but may truncate protocol information from name server and NFS
-packets (see below).
+default of 65535 bytes.
Packets truncated because of a limited snapshot
are indicated in the output with ``[|\fIproto\fP]'', where \fIproto\fP
is the name of the protocol level at which the truncation has occurred.
@@ -429,7 +448,9 @@ lost.
You should limit \fIsnaplen\fP to the smallest number that will
capture the protocol information you're interested in.
Setting
-\fIsnaplen\fP to 0 means use the required length to catch whole packets.
+\fIsnaplen\fP to 0 sets it to the default of 65535,
+for backwards compatibility with recent older versions of
+.IR tcpdump .
.TP
.B \-T
Force packets selected by "\fIexpression\fP" to be interpreted the
@@ -513,6 +534,9 @@ Write the raw packets to \fIfile\fR rather than parsing and printing
them out.
They can later be printed with the \-r option.
Standard output is used if \fIfile\fR is ``-''.
+See
+.BR pcap-savefile (@MAN_FILE_FORMATS@)
+for a description of the file format.
.TP
.B \-W
Used in conjunction with the
@@ -606,7 +630,7 @@ Otherwise,
only packets for which \fIexpression\fP is `true' will be dumped.
.LP
For the \fIexpression\fP syntax, see
-.BR pcap-filter (4).
+.BR pcap-filter (@MAN_MISC_INFO@).
.LP
Expression arguments can be passed to \fItcpdump\fP as either a single
argument or as multiple arguments, whichever is more convenient.
@@ -1123,6 +1147,18 @@ This points us to the \fItcpdump\fP filter expression
tcpdump -i xl0 'tcp[13] & 2 == 2'
.RE
.PP
+Some offsets and field values may be expressed as names
+rather than as numeric values. For example tcp[13] may
+be replaced with tcp[tcpflags]. The following TCP flag
+field values are also available: tcp-fin, tcp-syn, tcp-rst,
+tcp-push, tcp-act, tcp-urg.
+.PP
+This can be demonstrated as:
+.RS
+.B
+ tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0'
+.RE
+.PP
Note that you should use single quotes or a backslash
in the expression to hide the AND ('&') special character
from the shell.
@@ -1230,14 +1266,6 @@ RA, \fInot\fP set) and `|' (truncated message, TC, set).
If the
`question' section doesn't contain exactly one entry, `[\fIn\fPq]'
is printed.
-.LP
-Note that name server requests and responses tend to be large and the
-default \fIsnaplen\fP of 68 bytes may not capture enough of the packet
-to print.
-Use the \fB\-s\fP flag to increase the snaplen if you
-need to seriously investigate name server traffic.
-`\fB\-s 128\fP'
-has worked well for me.
.HD
SMB/CIFS decoding
@@ -1610,7 +1638,8 @@ is made to account for the time lag between when the
Ethernet interface removed the packet from the wire and when the kernel
serviced the `new packet' interrupt.
.SH "SEE ALSO"
-stty(1), pcap(3PCAP), pcap-filter(4), bpf(4), nit(4P)
+stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(@MAN_FILE_FORMATS@),
+pcap-filter(@MAN_MISC_INFO@)
.SH AUTHORS
The original authors are:
.LP
diff --git a/tcpdump.c b/tcpdump.c
index 4328b3049051..06683af344a4 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.271.2.11 2008-09-25 21:50:04 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.283 2008-09-25 21:45:50 guy Exp $ (LBL)";
#endif
/*
@@ -90,9 +90,9 @@ extern int SIZE_BUF;
netdissect_options Gndo;
netdissect_options *gndo = &Gndo;
-int dflag; /* print filter code */
-int Lflag; /* list available data link types and exit */
-char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */
+static int dflag; /* print filter code */
+static int Lflag; /* list available data link types and exit */
+static char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */
static int infodelay;
static int infoprint;
@@ -105,7 +105,7 @@ int32_t thiszone; /* seconds offset from gmt to local time */
static RETSIGTYPE cleanup(int);
static RETSIGTYPE child_cleanup(int);
static void usage(void) __attribute__((noreturn));
-static void show_dlts_and_exit(pcap_t *pd) __attribute__((noreturn));
+static void show_dlts_and_exit(const char *device, pcap_t *pd) __attribute__((noreturn));
static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
static void ndo_default_print(netdissect_options *, const u_char *, u_int);
@@ -131,12 +131,21 @@ static void info(int);
static u_int packets_captured;
typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
+typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
+ const struct pcap_pkthdr *, const u_char *);
struct printer {
- if_printer f;
+ if_printer f;
int type;
};
+
+struct ndo_printer {
+ if_ndo_printer f;
+ int type;
+};
+
+
static struct printer printers[] = {
{ arcnet_if_print, DLT_ARCNET },
#ifdef DLT_ARCNET_LINUX
@@ -151,7 +160,7 @@ static struct printer printers[] = {
{ cip_if_print, DLT_CIP },
#endif
#ifdef DLT_ATM_CLIP
- { cip_if_print, DLT_ATM_CLIP },
+ { cip_if_print, DLT_ATM_CLIP },
#endif
{ sl_if_print, DLT_SLIP },
#ifdef DLT_SLIP_BSDOS
@@ -178,7 +187,7 @@ static struct printer printers[] = {
{ chdlc_if_print, DLT_HDLC },
#endif
#ifdef DLT_PPP_SERIAL
- { ppp_hdlc_if_print, DLT_PPP_SERIAL },
+ { ppp_hdlc_if_print, DLT_PPP_SERIAL },
#endif
#ifdef DLT_PPP_ETHER
{ pppoe_if_print, DLT_PPP_ETHER },
@@ -193,7 +202,7 @@ static struct printer printers[] = {
{ ltalk_if_print, DLT_LTALK },
#endif
#if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
- { pflog_if_print, DLT_PFLOG },
+ { pflog_if_print, DLT_PFLOG },
#endif
#ifdef DLT_FR
{ fr_if_print, DLT_FR },
@@ -214,10 +223,10 @@ static struct printer printers[] = {
{ ieee802_11_radio_if_print, DLT_IEEE802_11_RADIO },
#endif
#ifdef DLT_ENC
- { enc_if_print, DLT_ENC },
+ { enc_if_print, DLT_ENC },
#endif
#ifdef DLT_SYMANTEC_FIREWALL
- { symantec_if_print, DLT_SYMANTEC_FIREWALL },
+ { symantec_if_print, DLT_SYMANTEC_FIREWALL },
#endif
#ifdef DLT_APPLE_IP_OVER_IEEE1394
{ ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
@@ -259,22 +268,43 @@ static struct printer printers[] = {
{ juniper_services_print, DLT_JUNIPER_SERVICES },
#endif
#ifdef DLT_JUNIPER_ETHER
- { juniper_ether_print, DLT_JUNIPER_ETHER },
+ { juniper_ether_print, DLT_JUNIPER_ETHER },
#endif
#ifdef DLT_JUNIPER_PPP
- { juniper_ppp_print, DLT_JUNIPER_PPP },
+ { juniper_ppp_print, DLT_JUNIPER_PPP },
#endif
#ifdef DLT_JUNIPER_FRELAY
- { juniper_frelay_print, DLT_JUNIPER_FRELAY },
+ { juniper_frelay_print, DLT_JUNIPER_FRELAY },
#endif
#ifdef DLT_JUNIPER_CHDLC
- { juniper_chdlc_print, DLT_JUNIPER_CHDLC },
+ { juniper_chdlc_print, DLT_JUNIPER_CHDLC },
#endif
#ifdef DLT_MFR
- { mfr_if_print, DLT_MFR },
+ { mfr_if_print, DLT_MFR },
#endif
#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
- { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+ { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#endif
+#ifdef HAVE_PCAP_USB_H
+#ifdef DLT_USB_LINUX
+ { usb_linux_48_byte_print, DLT_USB_LINUX},
+#endif /* DLT_USB_LINUX */
+#ifdef DLT_USB_LINUX_MMAPPED
+ { usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
+#endif /* DLT_USB_LINUX_MMAPPED */
+#endif /* HAVE_PCAP_USB_H */
+#ifdef DLT_IPV4
+ { raw_if_print, DLT_IPV4 },
+#endif
+#ifdef DLT_IPV6
+ { raw_if_print, DLT_IPV6 },
+#endif
+ { NULL, 0 },
+};
+
+static struct ndo_printer ndo_printers[] = {
+#ifdef DLT_IPNET
+ { ipnet_if_print, DLT_IPNET },
#endif
{ NULL, 0 },
};
@@ -292,14 +322,34 @@ lookup_printer(int type)
/* NOTREACHED */
}
+static if_ndo_printer
+lookup_ndo_printer(int type)
+{
+ struct ndo_printer *p;
+
+ for (p = ndo_printers; p->f; ++p)
+ if (type == p->type)
+ return p->f;
+
+ return NULL;
+ /* NOTREACHED */
+}
+
static pcap_t *pd;
+static int supports_monitor_mode;
+
extern int optind;
extern int opterr;
extern char *optarg;
struct print_info {
- if_printer printer;
+ netdissect_options *ndo;
+ union {
+ if_printer printer;
+ if_ndo_printer ndo_printer;
+ } p;
+ int ndo_type;
};
struct dump_info {
@@ -310,7 +360,7 @@ struct dump_info {
};
static void
-show_dlts_and_exit(pcap_t *pd)
+show_dlts_and_exit(const char *device, pcap_t *pd)
{
int n_dlts;
int *dlts = 0;
@@ -322,7 +372,21 @@ show_dlts_and_exit(pcap_t *pd)
else if (n_dlts == 0 || !dlts)
error("No data link types.");
- (void) fprintf(stderr, "Data link types (use option -y to set):\n");
+ /*
+ * If the interface is known to support monitor mode, indicate
+ * whether these are the data link types available when not in
+ * monitor mode, if -I wasn't specified, or when in monitor mode,
+ * when -I was specified (the link-layer types available in
+ * monitor mode might be different from the ones available when
+ * not in monitor mode).
+ */
+ if (supports_monitor_mode)
+ (void) fprintf(stderr, "Data link types for %s %s (use option -y to set):\n",
+ device,
+ Iflag ? "when in monitor mode" : "when not in monitor mode");
+ else
+ (void) fprintf(stderr, "Data link types for %s (use option -y to set):\n",
+ device);
while (--n_dlts >= 0) {
dlt_name = pcap_datalink_val_to_name(dlts[n_dlts]);
@@ -333,7 +397,8 @@ show_dlts_and_exit(pcap_t *pd)
/*
* OK, does tcpdump handle that type?
*/
- if (lookup_printer(dlts[n_dlts]) == NULL)
+ if (lookup_printer(dlts[n_dlts]) == NULL
+ && lookup_ndo_printer(dlts[n_dlts]) == NULL)
(void) fprintf(stderr, " (printing not supported)");
putchar('\n');
} else {
@@ -535,7 +600,7 @@ main(int argc, char **argv)
opterr = 0;
while (
- (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1)
+ (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1)
switch (op) {
case 'a':
@@ -546,6 +611,10 @@ main(int argc, char **argv)
++Aflag;
break;
+ case 'b':
+ ++bflag;
+ break;
+
#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
case 'B':
Bflag = atoi(optarg)*1024;
@@ -646,11 +715,17 @@ main(int argc, char **argv)
if (pcap_findalldevs(&devpointer, ebuf) < 0)
error("%s", ebuf);
else {
- for (i = 0; i < devnum-1; i++){
- devpointer = devpointer->next;
- if (devpointer == NULL)
- error("Invalid adapter index");
- }
+ /*
+ * Look for the devnum-th entry
+ * in the list of devices
+ * (1-based).
+ */
+ for (i = 0;
+ i < devnum-1 && devpointer != NULL;
+ i++, devpointer = devpointer->next)
+ ;
+ if (devpointer == NULL)
+ error("Invalid adapter index");
}
device = devpointer->name;
break;
@@ -708,7 +783,7 @@ main(int argc, char **argv)
#ifndef HAVE_LIBCRYPTO
warning("crypto code not compiled in");
#endif
- tcpmd5secret = optarg;
+ sigsecret = optarg;
break;
case 'n':
@@ -745,10 +820,10 @@ main(int argc, char **argv)
snaplen = strtol(optarg, &end, 0);
if (optarg == end || *end != '\0'
- || snaplen < 0 || snaplen > 65535)
+ || snaplen < 0 || snaplen > MAXIMUM_SNAPLEN)
error("invalid snaplen %s", optarg);
else if (snaplen == 0)
- snaplen = 65535;
+ snaplen = MAXIMUM_SNAPLEN;
break;
}
@@ -957,6 +1032,13 @@ main(int argc, char **argv)
pd = pcap_create(device, ebuf);
if (pd == NULL)
error("%s", ebuf);
+ /*
+ * Is this an interface that supports monitor mode?
+ */
+ if (pcap_can_set_rfmon(pd) == 1)
+ supports_monitor_mode = 1;
+ else
+ supports_monitor_mode = 0;
status = pcap_set_snaplen(pd, snaplen);
if (status != 0)
error("%s: pcap_set_snaplen failed: %s",
@@ -1035,7 +1117,7 @@ main(int argc, char **argv)
}
#endif /* !defined(HAVE_PCAP_CREATE) && defined(WIN32) */
if (Lflag)
- show_dlts_and_exit(pd);
+ show_dlts_and_exit(device, pd);
if (gndo->ndo_dlt >= 0) {
#ifdef HAVE_PCAP_SET_DATALINK
if (pcap_set_datalink(pd, gndo->ndo_dlt) < 0)
@@ -1073,6 +1155,7 @@ main(int argc, char **argv)
if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
error("%s", pcap_geterr(pd));
+ free(cmdbuf);
if (dflag) {
bpf_dump(&fcode, dflag);
pcap_close(pd);
@@ -1124,15 +1207,21 @@ main(int argc, char **argv)
}
} else {
type = pcap_datalink(pd);
- printinfo.printer = lookup_printer(type);
- if (printinfo.printer == NULL) {
- gndo->ndo_dltname = pcap_datalink_val_to_name(type);
- if (gndo->ndo_dltname != NULL)
- error("unsupported data link type %s",
- gndo->ndo_dltname);
- else
- error("unsupported data link type %d", type);
- }
+ printinfo.ndo_type = 1;
+ printinfo.ndo = gndo;
+ printinfo.p.ndo_printer = lookup_ndo_printer(type);
+ if (printinfo.p.ndo_printer == NULL) {
+ printinfo.p.printer = lookup_printer(type);
+ printinfo.ndo_type = 0;
+ if (printinfo.p.printer == NULL) {
+ gndo->ndo_dltname = pcap_datalink_val_to_name(type);
+ if (gndo->ndo_dltname != NULL)
+ error("packet printing is not supported for link type %s: use -w",
+ gndo->ndo_dltname);
+ else
+ error("packet printing is not supported for link type %d: use -w", type);
+ }
+ }
callback = print_packet;
pcap_userdata = (u_char *)&printinfo;
}
@@ -1287,6 +1376,11 @@ info(register int verbose)
{
struct pcap_stat stat;
+ /*
+ * Older versions of libpcap didn't set ps_ifdrop on some
+ * platforms; initialize it to 0 to handle that.
+ */
+ stat.ps_ifdrop = 0;
if (pcap_stats(pd, &stat) < 0) {
(void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd));
infoprint = 0;
@@ -1301,12 +1395,21 @@ info(register int verbose)
fputs(", ", stderr);
else
putc('\n', stderr);
- (void)fprintf(stderr, "%d packets received by filter", stat.ps_recv);
+ (void)fprintf(stderr, "%u packets received by filter", stat.ps_recv);
if (!verbose)
fputs(", ", stderr);
else
putc('\n', stderr);
- (void)fprintf(stderr, "%d packets dropped by kernel\n", stat.ps_drop);
+ (void)fprintf(stderr, "%u packets dropped by kernel", stat.ps_drop);
+ if (stat.ps_ifdrop != 0) {
+ if (!verbose)
+ fputs(", ", stderr);
+ else
+ putc('\n', stderr);
+ (void)fprintf(stderr, "%u packets dropped by interface\n",
+ stat.ps_ifdrop);
+ } else
+ putc('\n', stderr);
infoprint = 0;
}
@@ -1324,7 +1427,7 @@ compress_savefile(const char *filename)
#else
setpriority(PRIO_PROCESS, 0, 19);
#endif
- if (execlp(zflag, zflag, filename, NULL) == -1)
+ if (execlp(zflag, zflag, filename, (char *)NULL) == -1)
fprintf(stderr,
"compress_savefile:execlp(%s, %s): %s\n",
zflag,
@@ -1502,7 +1605,12 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
*/
snapend = sp + h->caplen;
- hdrlen = (*print_info->printer)(h, sp);
+ if(print_info->ndo_type) {
+ hdrlen = (*print_info->p.ndo_printer)(print_info->ndo, h, sp);
+ } else {
+ hdrlen = (*print_info->p.printer)(h, sp);
+ }
+
if (Xflag) {
/*
* Print the raw packet data in hex and ASCII.
@@ -1672,7 +1780,7 @@ usage(void)
#endif /* WIN32 */
#endif /* HAVE_PCAP_LIB_VERSION */
(void)fprintf(stderr,
-"Usage: %s [-aAd" D_FLAG "ef" I_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
+"Usage: %s [-aAbd" D_FLAG "ef" I_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
(void)fprintf(stderr,
"\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n");
(void)fprintf(stderr,
diff --git a/tests/02-sunrise-sunset-esp.puu b/tests/02-sunrise-sunset-esp.puu
new file mode 100644
index 000000000000..0ceffc1c1c83
--- /dev/null
+++ b/tests/02-sunrise-sunset-esp.puu
@@ -0,0 +1,34 @@
+begin 644 02-sunrise-sunset-esp.pcap
+MU,.RH0(`!``````````````&```!``````````````"6````E@```!```&1D
+M11```&1D(P@`10``B/]G``!`,O:5P`$"%\`!`BT2-%9X`````4P@12\\L)(1
+MTZ=(S>7($>.<3N@\_I:AY"K/TKAZJP719"NCKYP;PT(0+$"M%=]-X"`*8V.'
+M-'$1A]02"3N#OZI#&1R]A*1;`G8S@YFQ]<H7S))417Y9!E4:<$'CW)%VZ&_3
+M_]T`L+P1^!`PEP``````````E@```)8````0``!D9$40``!D9",(`$4``(C_
+M:```0#+VE,`!`A?``0(M$C16>`````(:<$'CW)%VZ',2KQMB@CN?'"^GJ<=:
+MD-0`+.V^J'2AK).'XQ_B"B8:[%A_+K[6KS2'XR[UN`,R"BJP?^].ZM#/[$)#
+M17^!D"8_[BZ>GU4Z*$7I"N$U*>J47?C-4;I>#`%6+#0%]D75YC']*Z\`````
+M`````)8```"6````$```9&1%$```9&0C"`!%``"(_VD``$`R]I/``0(7P`$"
+M+1(T5G@````#7?C-4;I>#`%@W%89?QJ#$TJ,4G\FO&HO=F+,,%1E(]);XI]T
+MV7W.RY$2=JZ1%!QCNX[;^.JD4W91;7)NJWV2MF4?7`=&_3OWW%V&6RIXKB75
+M#;2TWNL"A:MF!I@_5R^]L6;Z`L?E@1:T&71G``````````"6````E@```!``
+M`&1D11```&1D(P@`10``B/]J``!`,O:2P`$"%\`!`BT2-%9X````!*MF!I@_
+M5R^]%';9*Q:S_B]]O_8FV:2K1A!]/SQHI7>OS815*I?4%/:.=BBJUEGJ(X8\
+M<SZ>P1E/@&P\9MR)DP3[UCWI@,MR%A$\CR]=G(("[CFB7AUN$AENZOO&\:7%
+M2KLW<'NP,L(I=!;8=0``````````E@```)8````0``!D9$40``!D9",(`$4`
+M`(C_:P``0#+VD<`!`A?``0(M$C16>`````5NZOO&\:7%2J12,9;LOK"-S,=$
+MO0]X+J(OJQED#PLBRY[\^352UZK&57<R0L9JQ:KH6`)BUN$`5]1WU@"A!8TM
+MO^)<;`-SW;1HQO$CE\#`O[W[17GW[0G&M,^T?7>6,Z<:%73AWV3:;Y/:=@(`
+M`````````)8```"6````$```9&1%$```9&0C"`!%``"(_VP``$`R]I#``0(7
+MP`$"+1(T5G@````&M,^T?7>6,Z=>N_YZQFV[H1^6\!/I*IMAOHZE\E0M.Z!X
+M#[0EG3#>%]7`]*2F?@S4X2''TK09J@NG/.HEXCE./..K^'-@":X[\?0L+B`S
+MQA\HTK\'J]:S]N6O`]\)NQD)9;H2P\K`^NX37`R5``````````"6````E@``
+M`!```&1D11```&1D(P@`10``B/]M``!`,O:/P`$"%\`!`BT2-%9X````!^6O
+M`]\)NQD)>BYZ>`/DA=N;A2...3-7FZOK?:5KGXBN`/E?$\[-11-$G#E;(>N"
+M+<$/YP'SM$>16LU18&Q]9)$]0)/M]:2Z#A6]-,SM*>FI/`X*K-*-:KS3IW<"
+MO(>(P(K=:X::SJ;O[J>0K```````````E@```)8````0``!D9$40``!D9",(
+M`$4``(C_;@``0#+VCL`!`A?``0(M$C16>`````C3IW<"O(>(P'-43;C[`MCD
+M`BMZAX]F!?'Z$8Q"5HYMVDC9"8I^O(Z4!/)`/IVD-(ZK)_52-H2XK+,(-LR)
+MM)K#XLF">KY0>C?\[MA%3F%$?ORJ@:>O]5H>?-$OQH)J<ZFOW_+K%G=UG0"[
+"G'T`
+`
+end
diff --git a/tests/08-sunrise-sunset-aes.puu b/tests/08-sunrise-sunset-aes.puu
new file mode 100644
index 000000000000..ec8793d02238
--- /dev/null
+++ b/tests/08-sunrise-sunset-aes.puu
@@ -0,0 +1,36 @@
+begin 644 08-sunrise-sunset-aes.pcap
+MU,.RH0(`!``````````````&```!``````````````"F````I@```!```&1D
+M11```&1D(P@`10``F/SJ``!`,OD"P`$"%\`!`BW1(T5G`````>:['.C0J(%P
+MVF'>(TU6&*"9A,`,/KS\:>DH>O_L(51)_[YY"L<H#LJ/;(BQ)=[*$<APY/A1
+M-"T@(`_Q&)S!C)$*7S?G3Q4H\F=)OYF+P@S&11%^*]S)N@L*TZ@!:&&:QFZT
+ML'#7<>9?8'?J4V:_.]B+6UR\T>39D+=NA;$``````````*8```"F````$```
+M9&1%$```9&0C"`!%``"8_.L``$`R^0'``0(7P`$"+=$C16<````";K2P<-=Q
+MYE]@=^I39K\[V$1HDU9'L,6BVK.^B4]E6QY&:?3?T)G?"RSU;X!J]]7S)<`,
+M*L!SYO^RUWR?!EIJMWU=5B406YL-I`]LK`^;-3%(NEY#R`ST=W40=:*[M$*8
+M#<KX)19@.`.4_5YD^:V;G@3>`GLTK(5ZCS"BC@``````````I@```*8````0
+M``!D9$40``!D9",(`$4``)C\[```0#+Y`,`!`A?``0(MT2-%9P````,-RO@E
+M%F`X`Y3]7F3YK9N>=6-;U&'6">_4H80DMY^Z9E3ZL3[ONN*L<"Z@7(VO]XT^
+M/2JP<(/^8NTO-4\/B5AJEC4N;,\"7-&(;9AM_2G5A1C.[LBK3')P?AE;$I[)
+M!8N&RC?OTD7<V)AIU4,*E>7ELURFXRD/JD(:@RER``````````"F````I@``
+M`!```&1D11```&1D(P@`10``F/SM``!`,OC_P`$"%\`!`BW1(T5G````!(;*
+M-^_21=S8F&G50PJ5Y>5K%@R;)A(E<5YD'@86@GT"-&&MHP*.A=?%=:FDZH=4
+M*9":>]'G'CB4%2?PJ"2^H*51\8P!9T`X3#;F+H$[<GW7=?K.R30-'6'L3AO8
+MR=:M3S$GIZ>4Z$7ZL0<\S=S\%`:BW9U2'@U^@D,,:.P``````````*8```"F
+M````$```9&1%$```9&0C"`!%``"8_.X``$`R^/[``0(7P`$"+=$C16<````%
+M,2>GIY3H1?JQ!SS-W/P4!BW&*&A[$!XGK<^M^>_X193"G"1QTWG>Q"CO25$"
+MPM+1+8[6&(17\EE\P:6-WVPT=911?@'-Z,,/UVZ2!QV(X4513U9]P62CJMS>
+M^ODBGHU=%T.H2&Z<4,8(!4,2[&A4^H="L:+`=4G?*(7,2@``````````I@``
+M`*8````0``!D9$40``!D9",(`$4``)C\[P``0#+X_<`!`A?``0(MT2-%9P``
+M``870ZA(;IQ0Q@@%0Q+L:%3Z@*HQPZA]3STWDY#CYJGOJH)K<KVT9G61>>I'
+MEHMF"X!^G,H@,YWT7^=60.3/$7?AYH)G9GBD%%#,D]!EDA]B*?UE>U96+"5\
+MK=""/.LO'__^;$N<E@!.2&3^@U:P__8_'D^YC!41E,!@!6<K``````````"F
+M````I@```!```&1D11```&1D(P@`10``F/SP``!`,OC\P`$"%\`!`BW1(T5G
+M````!_YL2YR6`$Y(9/Z#5K#_]C_ZJU%7M?L23>I`L#D]@&G?Z7B2O#GI?NDK
+MF[7JPN,8V\H>%G+)'+%+FL*&\8+H2^KFWF5YQ:$4V!,1?G;=OYD;!,3YD'V(
+MW[Y!I(U=X9[\:L)(5GBJ,B!-5N$.CGV$VLD^R?Z,KL[AMI(ZC-P`````````
+M`*8```"F````$```9&1%$```9&0C"`!%``"8_/$``$`R^/O``0(7P`$"+=$C
+M16<````(PDA6>*HR($U6X0Z.?83:R;Y0<E/4SN)UX;Q:D$D%K(DZZ:^_\K$'
+MZQ81NT4KBGD#Z=_^`E^!HS*KHEJ!)!KE>&'2065/"*M'ELXD?1%3\L3TC.UK
+HKWB(C5O@78>9LQ^<0Z6]F=:<;@[>L^;/\-6WB81[GX)<MS0B=>LGD@``
+`
+end
diff --git a/tests/08-sunrise-sunset-esp2.puu b/tests/08-sunrise-sunset-esp2.puu
new file mode 100644
index 000000000000..4785f2b808c9
--- /dev/null
+++ b/tests/08-sunrise-sunset-esp2.puu
@@ -0,0 +1,43 @@
+begin 644 08-sunrise-sunset-esp2.pcap
+MU,.RH0(`!``````````````&```!``````````````#.````S@```!```&1D
+M11```&1D(P@`10``P"E-``!`,LQXP`$"%\`!`BT2-%9X`````4=!+\5+F8`+
+M[[NOU-#98*AO5\780X[VDXF@2W8<10:J!'!Z!-[7N4CFNRKIH;PUA1SL"Y9\
+M-?_3N_,W/@*T+C/"]=S[`;D!/;`SR5,3+><9K.^\9N><18TY9Z\!I\S./L8R
+MFE53,S6Y5X_Z\(T)ZIUS?X$8>&(_MT1"!SV:VPP!\XU$[3S-5L)4-O"&>]`Z
+M1:./61=%C6`6U1/65"A&KUE902]*``````````#.````S@```!```&1D11``
+M`&1D(P@`10``P"E/``!`,LQVP`$"%\`!`BT2-%9X`````CIU^SX%;G^!GUSP
+MSA<?/8FY?L/'^2]6'&3[\-NES3E]33Z$Q]#7D9$8TFS5);?S?)ZJOP4;ZD-M
+M+0_/@#*U=7A9;FYR*5&/^V%MSFEM`DAZY,8'<0.9M^'::<M+M2G0LG6*S/[3
+M?T`IIJUJ[GW,L+&PH<AR&K(]^=[K7IMGD[`8[ONL8LD3AM`N@$S!*?=;*8=>
+ML7P6FM81),N>T/1Z'"P7H5;```````````#.````S@```!```&1D11```&1D
+M(P@`10``P"E1``!`,LQTP`$"%\`!`BT2-%9X`````R4)-P&F>HPK/?_$MTFC
+M^TOO=/L#W_APTK6MIH_BC*I7\L<,9(?/0M"HK3[T3F;(Y2V70$P5?D'7GFIB
+MJZ/C",S/BD!9N8GV"\.;GVME[P!@!B1"DT=1W0_75FMI23H!T2^C);4GY>`I
+M-2T^O_0_WU&$)&+/P)%[TQUQ-T7G%\RXYJT0HO</^*)F`^2<W8KTY.W<FK4K
+M8UC+J'.*X)NH%<UTK+K+``````````#.````S@```!```&1D11```&1D(P@`
+M10``P"E3``!`,LQRP`$"%\`!`BT2-%9X````!)`9]]SHKI[EGW4M?W8>[$=<
+M`@@TL1#(Y980]E*/!^2@G`*&S9O^QMS1S?/`TL=5F9B(12?(145>Y2I+;+T?
+MKWUD@&.7U36]K-$[.%9CB*FK^E8>N:K/)4#$]ZO/:=#;MRH-)_139\,W6M4T
+M7SQ?BBX&GT,+A3#BB5^O=>+GKIC-4]5VBP)D-S<X2O)H[_/#M*T+&$\7PL.M
+M>7-)\W&;<@_J@,*!``````````#.````S@```!```&1D11```&1D(P@`10``
+MP"E5``!`,LQPP`$"%\`!`BT2-%9X````!0OIFA;,@2C4HF3>5!-C(0>5LR0"
+M='1\OQ.!-?@D(U0!453"<Q/!\*CDK.&OU'+WE:^7J8"AMS<@UYX*,<(&YA2Q
+MGQ(.3+0\#`!+`.TE,;\3:.<+F:?=T@.KOBL%VAAX9_RY$/^%$C+I*4&S<AM]
+MP*]SZ"RD'G.AJH76?SV&2HQLF+!J/QZ;.:<LB::-]+AE1+&);M^]`XZ-W2CX
+M+&CPZINP*9?>``````````#.````S@```!```&1D11```&1D(P@`10``P"E7
+M``!`,LQNP`$"%\`!`BT2-%9X````!I0M"-THEF=+!L=>A3N,\1+"'Z7(J?O0
+M.B?)(#X=/5F-.">%3.X'(=JKK:W<MZF2^8#73C[US$-O&ZZ+L:94R9E2#=J=
+M18HP?AN`5^)A+HW6EB*5P=AZ(S"\TIBZ'\.=]4A,#18'0/R_#C:4XX_?>ZMN
+M=B+^Q3"(KE\1299]=5E,'.&U(`H9N)+>9FS/`CA*>D^>AV.-C(S\)BM&)*XM
+M^BF__^<_``````````#.````S@```!```&1D11```&1D(P@`10``P"E9``!`
+M,LQLP`$"%\`!`BT2-%9X````!R"SQ'[6%(;Q>>O+]CS6D*+AD3IMC\^MMK8[
+M:T3)KM06!G^.H\>%UAT@)X6JL9\3V.HR"+_Q^_T-O$Y_S":_TP;V,LIV1O]H
+M-G@DOL'V-5)O@%<%!#O$2V,AS@W7(&$IX.YKK]\K#>FITU)<>O42T2GKFW+^
+M\/[,>E4P[Q"+7O,Y1(R22LND[H+469(%3,SN&3:U:/I`'&R@<`<TR"-4:&8+
+MQ5SX``````````#.````S@```!```&1D11```&1D(P@`10``P"E;``!`,LQJ
+MP`$"%\`!`BT2-%9X````"*',]A6A,Q(*B+]=&6X&T*L^\)Z6N%,G)(.;6X-K
+MM@&4<FRJ]#IJ%Y'-^T+4[&;0;_%7HM85LR8W(>HKGOV,^#L9,QF%)W^9!VFM
+MXG'XY]CWI5VF33?7,*P?6:.PS'&[\N$7W<*==+;P*$./4*OH&=O,6G!JIN>I
+M'ZDP*D&4K>SK-\/!7\Z&<&5J4%NU?NRM&25'*_"'UE3VH&?U]/V@932UYZT\
+`
+end
diff --git a/tests/TESTLIST b/tests/TESTLIST
new file mode 100644
index 000000000000..bbc19b62b0f4
--- /dev/null
+++ b/tests/TESTLIST
@@ -0,0 +1,51 @@
+# BGP test
+bgp_vpn_attrset bgp_vpn_attrset.pcap bgp_vpn_attrset.out -t -v
+
+# EAP tests
+eapon1 eapon1.pcap eapon1.out -t
+
+# ESP tests
+esp0 02-sunrise-sunset-esp.pcap esp0.out -t
+esp1 02-sunrise-sunset-esp.pcap esp1.out -t -E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"
+esp2 08-sunrise-sunset-esp2.pcap esp2.out -t -E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"
+esp3 02-sunrise-sunset-esp.pcap esp1.out -t -E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"
+esp4 08-sunrise-sunset-esp2.pcap esp2.out -t -E "file esp-secrets.txt"
+esp5 08-sunrise-sunset-aes.pcap esp5.out -t -E "file esp-secrets.txt"
+espudp1 espudp1.pcap espudp1.out -t -E "file esp-secrets.txt"
+
+# ISAKMP tests
+isakmp1 isakmp-delete-segfault.pcap isakmp1.out -t
+isakmp2 isakmp-pointer-loop.pcap isakmp2.out -t
+isakmp3 isakmp-identification-segfault.pcap isakmp3.out -t -v
+isakmp4 isakmp4500.pcap isakmp4.out -t -E "file esp-secrets.txt"
+
+# LMP tests (what is it?)
+# fails right now.
+#lmp lmp.pcap lmp.out -t -v -v
+
+# MPLS tests
+mpls-ldp-hello mpls-ldp-hello.pcap mpls-ldp-hello.out -t -v
+
+# OSPF tests
+ospf-gmpls ospf-gmpls.pcap ospf-gmpls.out -t -v
+
+# IKEv2 tests
+ikev2four ikev2four.pcap ikev2four.out -t -v
+ikev2fourv ikev2four.pcap ikev2fourv.out -t -v -v -v
+ikev2fourv4 ikev2four.pcap ikev2fourv4.out -t -v -v -v -v
+ikev2pI2 ikev2pI2.pcap ikev2pI2.out -t -E "file ikev2pI2-secrets.txt" -v -v -v -v
+
+# IETF ROLL RPL packets
+dio01 dio.pcap dio.out -t -v
+
+# IPNET encapsulated site
+e1000g e1000g.pcap e1000g.out -t
+
+# IETF FORCES WG packets and printer
+forces01 forces1.pcap forces1.out -t
+forces02 forces2.pcap forces2.out -t
+forces02v forces2.pcap forces2v.out -t -v
+forces02vv forces2.pcap forces2vv.out -t -v -v
+forces01vvv forces1.pcap forces1vvv.out -t -v -v -v
+forces01vvvv forces1.pcap forces1vvvv.out -t -v -v -v -v
+
diff --git a/tests/TESTonce b/tests/TESTonce
new file mode 100755
index 000000000000..40d544b04f44
--- /dev/null
+++ b/tests/TESTonce
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+system("mkdir -p NEW DIFF");
+
+if(@ARGV == 1) {
+ open(TESTLIST, "TESTLIST") || die "can not open TESTLIST: $!\n";
+ $wanted = $ARGV[0];
+ #print "Searching for test case $wanted\n";
+ while(<TESTLIST>) {
+ #print "Processing $_\n";
+ next unless (/^$wanted/);
+
+ chop;
+ ($name,$input,$output,$options)=split(/\s+/,$_, 4);
+ last;
+ }
+ close(TESTLIST);
+
+ die "Can not find test $wanted\n" unless defined($input);
+
+} elsif(@ARGV == 4) {
+ $name=$ARGV[0];
+ $input=$ARGV[1];
+ $output=$ARGV[2];
+ $options=$ARGV[3];
+} else {
+ print "Usage: TESTonce name [input output options]\n";
+ exit 20;
+}
+
+print "Running $name. \n";
+print " Input: $input, OUTPUT: $output, OPTIONS: $options\n";
+
+if (! -f $input) {
+ ($puu = $input) =~ s/\.pcap/\.puu/;
+ if( -f $puu) {
+ print "Uudecoding $puu to make $input\n";
+ system("uudecode $puu");
+ }
+}
+
+print " ";
+exec("../tcpdump -n -r $input $options | tee NEW/$output | diff -w - $output >DIFF/$output.diff");
+@cores = glob("core*");
+exit 10 if (@cores > 0);
+exit 0;
diff --git a/tests/TESTrun.sh b/tests/TESTrun.sh
new file mode 100755
index 000000000000..656974dd7c7f
--- /dev/null
+++ b/tests/TESTrun.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+mkdir -p NEW
+mkdir -p DIFF
+passed=0
+failed=0
+
+# first run any specific tests.
+for i in *.sh
+do
+ case $i in TEST*.sh) continue;; esac
+
+ if sh ./$i >DIFF/$i.result
+ then
+ echo $i: passed.
+ rm -f DIFF/$i.result
+ passed=$(($passed + 1))
+ else
+ echo $i: failed.
+ failed=$(($failed + 1))
+ fi
+done
+
+echo $passed >.passed
+echo $failed >.failed
+
+# now run typical tests
+cat TESTLIST | while read name input output options
+do
+ case $name in
+ \#*) continue;;
+ '') continue;;
+ esac
+
+ if ./TESTonce $name $input $output "$options"
+ then
+ echo $name: passed.
+ rm -f DIFF/$output.diff
+ passed=$(($passed + 1))
+ echo $passed >.passed
+ else
+ echo $name: failed.
+ failed=$(($failed + 1))
+ echo $failed >.failed
+ fi
+done
+
+# I hate shells with their stupid, useless subshells.
+passed=`cat .passed`
+failed=`cat .failed`
+
+# exit with number of failing tests.
+echo
+echo
+printf "%4u tests failed\n" $failed
+printf "%4u tests passed\n" $passed
+echo
+echo
+exit $failed
+
+
+
+
diff --git a/tests/bgp-infinite-loop.pcap b/tests/bgp-infinite-loop.pcap
new file mode 100644
index 000000000000..9f07d4122826
--- /dev/null
+++ b/tests/bgp-infinite-loop.pcap
Binary files differ
diff --git a/tests/bgp_vpn_attrset.out b/tests/bgp_vpn_attrset.out
new file mode 100644
index 000000000000..a0a9f1c097b9
--- /dev/null
+++ b/tests/bgp_vpn_attrset.out
@@ -0,0 +1,19 @@
+IP (tos 0xc0, ttl 62, id 58628, offset 0, flags [none], proto TCP (6), length 173)
+ 12.4.4.4.2051 > 12.1.1.1.179: Flags [P.], cksum 0xcf18 (correct), seq 3293077573:3293077694, ack 3348108582, win 16384, options [nop,nop,TS val 383131 ecr 890299], length 121: BGP, length: 121
+ Update Message (2), length: 121
+ Origin (1), length: 1, Flags [T]: IGP
+ AS Path (2), length: 0, Flags [T]: empty
+ Local Preference (5), length: 4, Flags [T]: 100
+ Extended Community (16), length: 8, Flags [OT]:
+ target (0x0002), Flags [none]: 300:300 (= 0.0.1.44)
+ Attribute Set (128), length: 36, Flags [OT]:
+ Origin AS: 65001
+ Origin (1), length: 1, Flags [T]: IGP
+ AS Path (2), length: 4, Flags [T]: 5555
+ Local Preference (5), length: 4, Flags [T]: 44
+ Originator ID (9), length: 4, Flags [O]: 22.5.5.5
+ Cluster List (10), length: 4, Flags [O]: 22.5.5.5
+ Multi-Protocol Reach NLRI (14), length: 30, Flags [OE]:
+ AFI: IPv4 (1), SAFI: labeled VPN Unicast (128)
+ nexthop: RD: 0:0 (= 0.0.0.0), 12.4.4.4, nh-length: 12, no SNPA
+ RD: 500:500 (= 0.0.1.244), 133.0.0.0/8, label:100208 (bottom)
diff --git a/tests/bgp_vpn_attrset.pcap b/tests/bgp_vpn_attrset.pcap
new file mode 100644
index 000000000000..e60aff5c838b
--- /dev/null
+++ b/tests/bgp_vpn_attrset.pcap
Binary files differ
diff --git a/tests/chdlc-slarp-short.pcap b/tests/chdlc-slarp-short.pcap
new file mode 100644
index 000000000000..41313dcca9bf
--- /dev/null
+++ b/tests/chdlc-slarp-short.pcap
Binary files differ
diff --git a/tests/chdlc-slarp.pcap b/tests/chdlc-slarp.pcap
new file mode 100644
index 000000000000..1521443a8f15
--- /dev/null
+++ b/tests/chdlc-slarp.pcap
Binary files differ
diff --git a/tests/dio.out b/tests/dio.out
new file mode 100644
index 000000000000..fd0846af77aa
--- /dev/null
+++ b/tests/dio.out
@@ -0,0 +1 @@
+IP6 (hlim 255, next-header ICMPv6 (58) payload length: 24) fe80::1000:ff:fe64:6423 > ff02::1: [icmp6 sum ok] ICMP6, RPL, length 24, DAG Information Object [seq:10,instance:42,rank:1,dagid:thisismynicedag1]
diff --git a/tests/dio.pcap b/tests/dio.pcap
new file mode 100644
index 000000000000..81706352a563
--- /dev/null
+++ b/tests/dio.pcap
Binary files differ
diff --git a/tests/e1000g.out b/tests/e1000g.out
new file mode 100644
index 000000000000..0cc3b9e1003e
--- /dev/null
+++ b/tests/e1000g.out
@@ -0,0 +1,20 @@
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 0, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 0, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 1, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 1, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 2, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 2, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 3, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 3, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 4, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 4, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 5, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 5, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 6, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 6, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 7, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 7, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 8, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 8, length 64
+IP 129.146.106.55 > 10.5.233.117: ICMP echo request, id 6901, seq 9, length 64
+IP 10.5.233.117 > 129.146.106.55: ICMP echo reply, id 6901, seq 9, length 64
diff --git a/tests/e1000g.pcap b/tests/e1000g.pcap
new file mode 100644
index 000000000000..11b0174504a3
--- /dev/null
+++ b/tests/e1000g.pcap
Binary files differ
diff --git a/tests/eapon1.gdbinit b/tests/eapon1.gdbinit
new file mode 100644
index 000000000000..37ad0bcd029e
--- /dev/null
+++ b/tests/eapon1.gdbinit
@@ -0,0 +1 @@
+set args -r eapon1.pcap
diff --git a/tests/eapon1.out b/tests/eapon1.out
new file mode 100644
index 000000000000..69f7537c09c9
--- /dev/null
+++ b/tests/eapon1.out
@@ -0,0 +1,114 @@
+IP 192.168.1.249.138 > 192.168.1.255.138: NBT UDP PACKET(138)
+IP 192.168.1.249.138 > 192.168.1.255.138: NBT UDP PACKET(138)
+IP 192.168.1.249.138 > 192.168.1.255.138: NBT UDP PACKET(138)
+IP 192.168.1.249.137 > 192.168.1.255.137: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
+IP 192.168.1.249.137 > 192.168.1.255.137: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
+IP 192.168.1.249.137 > 192.168.1.255.137: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
+IP 192.168.1.249.138 > 192.168.1.255.138: NBT UDP PACKET(138)
+IP 192.168.1.249.137 > 192.168.1.255.137: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
+IP 192.168.1.249.137 > 192.168.1.255.137: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
+IP 192.168.1.249.137 > 192.168.1.255.137: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
+ARP, Request who-has 192.168.1.1 tell 192.168.1.249, length 28
+ARP, Reply 192.168.1.1 is-at 00:0d:88:4f:25:91, length 46
+IP 192.168.1.249.68 > 192.168.1.1.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+EAP packet (0) v1, len 5
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+EAPOL start (1) v1, len 0
+EAP packet (0) v1, len 5
+EAP packet (0) v1, len 45
+EAP packet (0) v1, len 20
+EAP packet (0) v1, len 76
+EAP packet (0) v1, len 80
+EAP packet (0) v1, len 28
+EAP packet (0)