diff options
Diffstat (limited to 'contrib')
151 files changed, 21906 insertions, 7650 deletions
diff --git a/contrib/tcpdump/CHANGES b/contrib/tcpdump/CHANGES index e0e4cb8..e69ba22 100644 --- a/contrib/tcpdump/CHANGES +++ b/contrib/tcpdump/CHANGES @@ -1,4 +1,64 @@ -$Header: /tcpdump/master/tcpdump/CHANGES,v 1.81.2.1 2003/02/26 07:08:58 fenner Exp $ +$Header: /tcpdump/master/tcpdump/CHANGES,v 1.84.2.3 2004/03/30 14:36:24 mcr Exp $ + +Tue. March 30, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.3 release + + No changes from 3.8.2. Version bumped only to maintain consistency + with libpcap 0.8.3. + +Mon. March 29, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.2 release + + Fixes for print-isakmp.c CVE: CAN-2004-0183, CAN-2004-0184 + http://www.rapid7.com/advisories/R7-0017.html + IP-over-IEEE1394 printing. + some MINGW32 changes. + updates for autoconf 2.5 + fixes for print-aodv.c - check for too short packets + formatting changes to print-ascii for hex output. + check for too short packets: print-bgp.c, print-bootp.c, print-cdp.c, + print-chdlc.c, print-domain.c, print-icmp.c, print-icmp6.c, + print-ip.c, print-lwres.c, print-ospf.c, print-pim.c, + print-ppp.c,print-pppoe.c, print-rsvp.c, print-wb.c + print-ether.c - better handling of unknown types. + print-isoclns.c - additional decoding of types. + print-llc.c - strings for LLC names added. + print-pfloc.c - various enhancements + print-radius.c - better decoding to strings. + +Wed. November 12, 2003. mcr@sandelman.ottawa.on.ca. Summary for 3.8 release + + changed syntax of -E argument so that multiple SAs can be decrypted + fixes for Digital Unix headers and Documentation + __attribute__ fixes + CDP changes from Terry Kennedy <terry@tmk.com>. + IPv6 mobility updates from Kazushi Sugyo <sugyo@pb.jp.nec.com> + Fixes for ASN.1 decoder for 2.100.3 forms. + Added a count of packets received and processed to clarify numbers. + Incorporated WinDUMP patches for Win32 builds. + PPPoE payload length headers. + Fixes for HP C compiler builds. + Use new pcap_breakloop() and pcap_findalldevs() if we can. + BGP output split into multiple lines. + Fixes to 802.11 decoding. + Fixes to PIM decoder. + SuperH is a CPU that can't handle unaligned access. Many fixes for + unaligned access work. + Fixes to Frame-Relay decoder for Q.933/922 frames. + Clarified when Solaris can do captures as non-root. + Added tests/ subdir for examples/regression tests. + New -U flag. -flush stdout after every packet + New -A flag -print ascii only + support for decoding IS-IS inside Cisco HDLC Frames + more verbosity for tftp decoder + mDNS decoder + new BFD decoder + cross compilation patches + RFC 3561 AODV support. + UDP/TCP pseudo-checksum properly for source-route options. + sanitized all files to modified BSD license + Add support for RFC 2625 IP-over-Fibre Channel. + fixes for DECnet support. + Support RFC 2684 bridging of Ethernet, 802.5 Token Ring, and FDDI. + RFC 2684 encapsulation of BPDUs. Tuesday, February 25, 2003. fenner@research.att.com. 3.7.2 release @@ -672,5 +732,3 @@ v2.0.1 Sun Jan 26 21:10:10 PDT v2.0 Sun Jan 13 12:20:40 PST 1991 - Initial public release. - -@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.81.2.1 2003/02/26 07:08:58 fenner Exp $ (LBL) diff --git a/contrib/tcpdump/CREDITS b/contrib/tcpdump/CREDITS index 9f0d253..b5c286c 100644 --- a/contrib/tcpdump/CREDITS +++ b/contrib/tcpdump/CREDITS @@ -2,46 +2,60 @@ This file lists people who have contributed to tcpdump: The current maintainers: Bill Fenner <fenner@research.att.com> - Assar Westerlund <assar@sics.se> - Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> + Fulvio Risso <risso@polito.it> + Guy Harris <guy@alum.mit.edu> + Hannes Gredler <hannes@juniper.net> Jun-ichiro itojun Hagino <itojun@iijlab.net> - Guy Harris <guy@alum.mit.edu> - Torsten Landschoff <t.landschoff@gmx.net> - Michael Richardson <mcr@sandelman.ottawa.on.ca> - Ken Hornstein <kenh@cmf.nrl.navy.mil> + Michael Richardson <mcr@sandelman.ottawa.on.ca> Additional people who have contributed patches: + Andrew Brown <atatat@atatdot.net> Alfredo Andres <aandres@s21sec.com> Andrew Hintz <adhintz@users.sourceforge.net> Andrew Tridgell <tridge@linuxcare.com> Arkadiusz Miskiewicz <misiek@pld.org.pl> Armando L. Caro Jr. <acaro@mail.eecis.udel.edu> + Atsushi Onoe <onoe@netbsd.org> Ben Smithurst <ben@scientia.demon.co.uk> Brent L. Bates <blbates@vigyan.com> + Brian Ginsbach <ginsbach@cray.com> + Bruce M. Simpson <bms@spc.org> + Carles Kishimoto Bisbe <ckishimo@ac.upc.es> Charlie Lenahan <clenahan@fortresstech.com> + Charles M. Hannum <mycroft@netbsd.org> + Chris Cogdon <chris@cogdon.org> Chris G. Demetriou <cgd@netbsd.org> Chris Jepeway <jepeway@blasted-heath.com> Craig Rodrigues <rodrigc@mediaone.net> Crist J. Clark <cjclark@alum.mit.edu> Daniel Hagerty <hag@ai.mit.edu> + Darren Reed <darrenr@reed.wattle.id.au> + David Binderman <d.binderman@virgin.net> + David Young <dyoung@ojctech.com> Francisco Matias Cuenca-Acuna <mcuenca@george.rutgers.edu> Frank Volf <volf@oasis.IAEhv.nl> + Fulvio Risso <risso@polito.it> + George Bakos <gbakos@ists.dartmouth.edu> + Gerald Combs <gerald@ethereal.com> Gert Doering <gert@greenie.muc.de> + Greg Stark <gsstark@mit.edu> Gilbert Ramirez Jr. <gram@xiexie.org> - Gisle Vanem <gvanem@eunet.no> - Hannes Gredler <hannes@juniper.net> + Gisle Vanem <giva@bgnett.no> + Hank Leininger <tcpdump-workers@progressive-comp.com> Harry Raaymakers <harryr@connect.com.au> Heinz-Ado Arnolds <Ado.Arnolds@dhm-systems.de> Hendrik Scholz <hendrik@scholz.net> Jakob Schlyter <jakob@openbsd.org> Jan Oravec <wsx@wsx6.net> - Jason R. Thorpe <thorpej@zembu.com> + Jason R. Thorpe <thorpej@netbsd.org> Jefferson Ogata <jogata@nodc.noaa.gov> Jeffrey Hutzelman <jhutz@cmu.edu> + Jesper Peterson <jesper@endace.com> Jim Hutchins <jim@ca.sandia.gov> - JINMEI Tatuya <jinmei@kame.net> - Juergen Schoenwaelder <schoenw@ibr.cs.tu-bs.de> + Jonathan Heusser <jonny@drugphish.ch> + Tatuya Jinmei <jinmei@kame.net> + Jørgen Thomsen <jth@jth.net> Julian Cowley <julian@lava.net> Kaarthik Sivakumar <kaarthik@torrentnet.com> Kazushi Sugyo <sugyo@pb.jp.nec.com> @@ -50,38 +64,55 @@ Additional people who have contributed patches: Kevin Steves <stevesk@pobox.com> Klaus Klein <kleink@reziprozitaet.de> Kris Kennaway <kris@freebsd.org> + Krzysztof Halasa <khc@pm.waw.pl> Larry Lile <lile@stdio.com> Lennert Buytenhek <buytenh@gnu.org> + Loris Degioanni <loris@netgroup-serv.polito.it> Love Hörnquist-Åstrand <lha@stacken.kth.se> Maciej W. Rozycki <macro@ds2.pg.gda.pl> Marc A. Lehmann <pcg@goof.com> + Mark Ellzey Thomas <mark@ackers.net> Marko Kiiskila <carnil@cs.tut.fi> Marshall Rose <mrose@dbc.mtview.ca.us> Martin Husemann <martin@netbsd.org> Michael Madore <mmadore@turbolinux.com> Michael Shalayeff <mickey@openbsd.org> Michael T. Stolarchuk <mts@off.to> + Michele "mydecay" Marchetto <smarchetto1@tin.it> Monroe Williams <monroe@pobox.com> Motonori Shindo <mshindo@mshindo.net> Nathan J. Williams <nathanw@MIT.EDU> Nathaniel Couper-Noles <Nathaniel@isi1.tccisi.com> + Neil T. Spring <bluehal@users.sourceforge.net> + Niels Provos <provos@openbsd.org> Nickolai Zeldovich <kolya@MIT.EDU> Olaf Kirch <okir@caldera.de> Onno van der Linden <onno@simplex.nl> Pascal Hennequin <pascal.hennequin@int-evry.fr> Pasvorn Boonmark <boonmark@juniper.net> + Paul Mundt <lethal@linux-sh.org> + Paul S. Traina <pst@freebsd.org> + Pavlin Radoslavov <pavlin@icir.org> Pekka Savola <pekkas@netcore.fi> + Peter Fales <peter@fales-lorenz.net> Peter Jeremy <peter.jeremy@alcatel.com.au> + Phil Wood <cpw@lanl.gov> Rafal Maszkowski <rzm@icm.edu.pl> Rick Jones <raj@cup.hp.com> Rick Watson <watsonrick@users.sourceforge.net> + Rob Braun <bbraun@synack.net> Roderick Schertler <roderick@argon.org> + Sami Farin <safari@iki.fi> + Scott Rose <syberpunk@users.sourceforge.net> Sebastian Krahmer <krahmer@cs.uni-potsdam.de> Seth Webster <swebster@sst.ll.mit.edu> + Takashi Yamamoto <yamt@mwd.biglobe.ne.jp> + Terry Kennedy <terry@tmk.com> Timo Koskiahde Tony Li <tli@procket.com> Uns Lider <unslider@miranda.org> Wilbert de Graaf <wilbertdg@hetnet.nl> + Yen Yen Lim The original LBL crew: Steve McCanne diff --git a/contrib/tcpdump/FILES b/contrib/tcpdump/FILES index c65384e..0b86817 100644 --- a/contrib/tcpdump/FILES +++ b/contrib/tcpdump/FILES @@ -5,15 +5,19 @@ INSTALL LICENSE Makefile.in README +Readme.Win32 VERSION acconfig.h aclocal.m4 addrtoname.c addrtoname.h ah.h +aodv.h appletalk.h arcnet.h atime.awk +atm.h +atmuni31.h bootp.h bpf_dump.c chdlc.h @@ -23,11 +27,14 @@ config.sub configure configure.in decnet.h +enc.h esp.h ether.h ethertype.h extract.h fddi.h +gmpls.c +gmpls.h gmt2local.c gmt2local.h icmp6.h @@ -37,11 +44,14 @@ install-sh interface.h ip.h ip6.h +ipfc.h +ipproto.h ipsec_doi.h ipx.h isakmp.h l2tp.h lane.h +lbl/os-osf4.h lbl/os-solaris2.h lbl/os-sunos4.h lbl/os-ultrix4.h @@ -53,6 +63,8 @@ mib.h missing/addrinfo.h missing/addrsize.h missing/bittypes.h +missing/dlnames.c +missing/datalinks.c missing/getaddrinfo.c missing/getnameinfo.c missing/inet_aton.c @@ -65,6 +77,7 @@ missing/sockstorage.h missing/strdup.c missing/strlcat.c missing/strlcpy.c +missing/strsep.c mkdep nameser.h netbios.h @@ -76,17 +89,21 @@ ospf.h ospf6.h packetdat.awk parsenfsfh.c +pcap-missing.h ppp.h print-802_11.c +print-ap1394.c print-ah.c +print-aodv.c print-arcnet.c print-arp.c print-ascii.c print-atalk.c print-atm.c +print-beep.c +print-bfd.c print-bgp.c print-bootp.c -print-beep.c print-cdp.c print-chdlc.c print-cip.c @@ -96,9 +113,11 @@ print-dhcp6.c print-domain.c print-dvmrp.c print-egp.c +print-enc.c print-esp.c print-ether.c print-fddi.c +print-fr.c print-frag6.c print-gre.c print-hsrp.c @@ -110,16 +129,18 @@ print-ip.c print-ip6.c print-ip6opts.c print-ipcomp.c +print-ipfc.c print-ipx.c print-isakmp.c print-isoclns.c print-krb.c print-l2tp.c print-lane.c -print-lcp.c +print-ldp.c print-llc.c print-lwres.c print-mobile.c +print-mobility.c print-mpls.c print-msdp.c print-netbios.c @@ -128,6 +149,7 @@ print-ntp.c print-null.c print-ospf.c print-ospf6.c +print-pflog.c print-pim.c print-ppp.c print-pppoe.c @@ -136,6 +158,7 @@ print-radius.c print-raw.c print-rip.c print-ripng.c +print-rsvp.c print-rt6.c print-rx.c print-sctp.c @@ -144,6 +167,7 @@ print-sll.c print-smb.c print-snmp.c print-stp.c +print-sunatm.c print-sunrpc.c print-tcp.c print-telnet.c @@ -172,9 +196,23 @@ strcasecmp.c tcp.h tcpdump.1 tcpdump.c +tcpdump-stdinc.h telnet.h timed.h token.h udp.h util.c vfprintf.c +win32/Include/Arpa/tftp.h +win32/Include/errno.h +win32/Include/getopt.h +win32/Include/inetprivate.h +win32/Include/telnet.h +win32/Include/w32_fzs.h +win32/Include/Netinet/in_systm.h +win32/Include/Netinet/ip.h +win32/Include/Rpc/rpc.h +win32/Src/getopt.c +win32/prj/GNUmakefile +win32/prj/WinDump.dsp +win32/prj/WinDump.dsw diff --git a/contrib/tcpdump/INSTALL b/contrib/tcpdump/INSTALL index 80a1c4a..3593973 100644 --- a/contrib/tcpdump/INSTALL +++ b/contrib/tcpdump/INSTALL @@ -1,4 +1,4 @@ -@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.47.6.1 2002/07/16 04:41:57 guy Exp $ (LBL) +@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.56.2.3 2004/03/17 19:47:47 guy Exp $ (LBL) If you have not built libpcap, do so first. See the README file in this directory for the ftp location. @@ -39,22 +39,26 @@ Please see "PLATFORMS" for notes about tested platforms. FILES ----- -CHANGES - description of differences between releases +CHANGES - description of differences between releases CREDITS - people that have helped tcpdump along FILES - list of files exported as part of the distribution -INSTALL - this file +INSTALL - this file LICENSE - the license under which tcpdump is distributed Makefile.in - compilation rules (input to the configure script) README - description of distribution +Readme.Win32 - notes on building tcpdump on Win32 systems (with WinPcap) VERSION - version of this release acconfig.h - autoconf input aclocal.m4 - autoconf macros addrtoname.c - address to hostname routines addrtoname.h - address to hostname definitions ah.h - IPSEC Authentication Header definitions +aodv.h - AODV definitions appletalk.h - AppleTalk definitions arcnet.h - ARCNET definitions atime.awk - TCP ack awk script +atm.h - ATM traffic type definitions +atmuni31.h - ATM Q.2931 definitions bootp.h - BOOTP definitions bpf_dump.c - BPF program printing routines, in case libpcap doesn't have them @@ -65,11 +69,14 @@ config.sub - autoconf support configure - configure script (run this first) configure.in - configure script source decnet.h - DECnet definitions +enc.h - OpenBSD IPsec encapsulation BPF layer definitions esp.h - IPSEC Encapsulating Security Payload definitions ether.h - Ethernet definitions ethertype.h - Ethernet type value definitions extract.h - alignment definitions fddi.h - Fiber Distributed Data Interface definitions +gmpls.c - GMPLS definitions +gmpls.h - GMPLS declarations gmt2local.c - time conversion routines gmt2local.h - time conversion prototypes icmp6.h - ICMPv6 definitiions @@ -79,6 +86,8 @@ install-sh - BSD style install script interface.h - globals, prototypes and definitions ip.h - IP definitions ip6.h - IPv6 definitions +ipfc.h - IP-over-Fibre Channel definitions +ipproto.h - IP protocol type value definitions ipsec_doi.h - ISAKMP packet definitions - RFC2407 ipx.h - IPX definitions isakmp.h - ISAKMP packet definitions - RFC2408 @@ -102,9 +111,12 @@ ospf.h - Open Shortest Path First definitions ospf6.h - IPv6 Open Shortest Path First definitions packetdat.awk - TCP chunk summary awk script parsenfsfh.c - Network File System file parser routines +pcap-missing.h - declarations of functions possibly missing from libpcap ppp.h - Point to Point Protocol definitions print-802_11.c - IEEE 802.11 printer routines +print-ap1394.c - Apple IP-over-IEEE 1394 printer routines print-ah.c - IPSEC Authentication Header printer routines +print-aodv.c - AODV printer routines print-arcnet.c - ARCNET printer routines print-arp.c - Address Resolution Protocol printer routines print-ascii.c - ASCII packet dump routines @@ -121,10 +133,12 @@ print-decnet.c - DECnet printer routines print-dhcp6.c - IPv6 DHCP printer routines print-domain.c - Domain Name System printer routines print-dvmrp.c - Distance Vector Multicast Routing Protocol printer routines +print-enc.c - OpenBSD IPsec encapsulation BPF layer printer routines print-egp.c - External Gateway Protocol printer routines print-esp.c - IPSEC Encapsulating Security Payload printer routines print-ether.c - Ethernet printer routines print-fddi.c - Fiber Distributed Data Interface printer routines +print-fr.c - Frame Relay printer routines print-frag6.c - IPv6 fragmentation header printer routines print-gre.c - Generic Routing Encapsulation printer routines print-hsrp.c - Cisco Hot Standby Router Protocol printer routines @@ -142,10 +156,10 @@ print-isoclns.c - ISO CLNS, ESIS, and ISIS printer routines print-krb.c - Kerberos printer routines print-l2tp.c - Layer Two Tunneling Protocol printer routines print-lane.c - ATM LANE printer routines -print-lcp.c - PPP Link Control Protocol printer routines print-llc.c - IEEE 802.2 LLC printer routines print-lwres.c - Lightweight Resolver protocol printer routines print-mobile.c - IPv4 mobility printer routines +print-mobility.c - IPv6 mobility printer routines print-mpls.c - Multi-Protocol Label Switching printer routines print-msdp.c - Multicast Source Discovery Protocol printer routines print-netbios.c - NetBIOS frame protocol printer routines @@ -154,6 +168,7 @@ print-ntp.c - Network Time Protocol printer routines print-null.c - BSD loopback device printer routines print-ospf.c - Open Shortest Path First printer routines print-ospf6.c - IPv6 Open Shortest Path First printer routines +print-pflog.c - OpenBSD packet filter log file printer routines print-pim.c - Protocol Independent Multicast printer routines print-ppp.c - Point to Point Protocol printer routines print-pppoe.c - PPP-over-Ethernet printer routines @@ -162,6 +177,7 @@ print-radius.c - Radius protocol printer routines print-raw.c - Raw IP printer routines print-rip.c - Routing Information Protocol printer routines print-ripng.c - IPv6 Routing Information Protocol printer routines +print-rsvp.c - Resource reSerVation Protocol (RSVP) printer routines print-rt6.c - IPv6 routing header printer routines print-rx.c - AFS RX printer routines print-sctp.c - Stream Control Transmission Protocol printer routines @@ -170,6 +186,7 @@ print-sll.c - Linux "cooked" capture printer routines print-smb.c - SMB/CIFS printer routines print-snmp.c - Simple Network Management Protocol printer routines print-stp.c - IEEE 802.1d spanning tree protocol printer routines +print-sunatm.c - SunATM DLPI capture printer routines print-sunrpc.c - Sun Remote Procedure Call printer routines print-tcp.c - TCP printer routines print-telnet.c - Telnet option printer routines @@ -204,3 +221,4 @@ token.h - Token Ring definitions udp.h - UDP definitions util.c - utility routines vfprintf.c - emulation routine +win32 - headers and routines for building on Win32 systems diff --git a/contrib/tcpdump/Makefile.in b/contrib/tcpdump/Makefile.in index ec8750e..38fe874 100644 --- a/contrib/tcpdump/Makefile.in +++ b/contrib/tcpdump/Makefile.in @@ -17,7 +17,7 @@ # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # -# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.260 2001/12/10 08:21:23 guy Exp $ (LBL) +# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.276.2.4 2004/03/28 21:25:02 fenner Exp $ (LBL) # # Various configurable paths (remember to edit Makefile.in, not Makefile) @@ -43,7 +43,7 @@ CC = @CC@ PROG = tcpdump CCOPT = @V_CCOPT@ INCLS = -I. @V_INCLS@ -DEFS = @DEFS@ +DEFS = @DEFS@ @V_DEFS@ # Standard CFLAGS CFLAGS = $(CCOPT) $(DEFS) $(INCLS) @@ -65,25 +65,26 @@ INSTALL_DATA = @INSTALL_DATA@ @rm -f $@ $(CC) $(CFLAGS) -c $(srcdir)/$*.c -CSRC = addrtoname.c gmt2local.c machdep.c parsenfsfh.c \ - print-802_11.c print-ah.c print-arcnet.c print-arp.c \ - print-ascii.c print-atalk.c print-atm.c print-bgp.c \ - print-bootp.c print-beep.c print-cdp.c print-chdlc.c \ - print-cip.c print-cnfp.c print-decnet.c print-domain.c \ - print-dvmrp.c print-egp.c print-esp.c print-ether.c \ - print-fddi.c print-gre.c print-hsrp.c print-icmp.c \ - print-igmp.c print-igrp.c print-ip.c print-ipcomp.c \ +CSRC = addrtoname.c gmpls.c gmt2local.c machdep.c oui.c parsenfsfh.c \ + print-802_11.c print-ap1394.c print-ah.c print-arcnet.c \ + print-aodv.c print-arp.c print-ascii.c print-atalk.c print-atm.c \ + print-beep.c print-bfd.c print-bgp.c print-bootp.c print-cdp.c \ + print-chdlc.c print-cip.c print-cnfp.c print-decnet.c \ + print-domain.c print-dvmrp.c print-enc.c print-egp.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-ipx.c print-isakmp.c print-isoclns.c print-krb.c \ - print-l2tp.c print-lane.c print-lcp.c print-llc.c print-lwres.c \ - print-msdp.c print-mobile.c print-mpls.c print-nfs.c \ - print-ntp.c print-null.c print-ospf.c print-pim.c \ - print-ppp.c print-pppoe.c print-pptp.c print-radius.c \ - print-raw.c print-rip.c print-rx.c print-sctp.c \ - print-sl.c print-sll.c print-snmp.c \ - print-stp.c print-sunrpc.c print-tcp.c \ - print-telnet.c print-tftp.c print-timed.c print-token.c \ - print-udp.c print-vjc.c print-vrrp.c print-wb.c print-zephyr.c \ - setsignal.c tcpdump.c util.c + print-l2tp.c print-lane.c print-ldp.c print-llc.c \ + print-lwres.c print-mobile.c print-mpls.c print-msdp.c \ + print-nfs.c print-ntp.c print-null.c print-ospf.c \ + print-pflog.c print-pim.c print-ppp.c print-pppoe.c \ + print-pptp.c print-radius.c print-raw.c print-rip.c \ + print-rsvp.c print-rx.c print-sctp.c print-sl.c print-sll.c \ + print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \ + print-tcp.c print-telnet.c print-tftp.c print-timed.c \ + print-token.c print-udp.c print-vjc.c print-vrrp.c \ + print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c LOCALSRC = @LOCALSRC@ GENSRC = version.c @@ -99,7 +100,7 @@ HDR = addrtoname.h appletalk.h bootp.h decnet.h \ ipx.h llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h \ setsignal.h \ gnuc.h ipsec_doi.h isakmp.h l2tp.h nameser.h \ - netbios.h oakley.h ospf6.h ppp.h route6d.h + netbios.h oakley.h ospf6.h pf.h ppp.h route6d.h TAGHDR = \ /usr/include/arpa/tftp.h \ @@ -122,6 +123,10 @@ $(PROG): $(OBJ) @V_PCAPDEP@ @rm -f $@ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) +datalinks.o: $(srcdir)/missing/datalinks.c + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c +dlnames.o: $(srcdir)/missing/dlnames.c + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c getnameinfo.o: $(srcdir)/missing/getnameinfo.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c @@ -138,6 +143,8 @@ strlcat.o: $(srcdir)/missing/strlcat.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c strlcpy.o: $(srcdir)/missing/strlcpy.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c +strsep.o: $(srcdir)/missing/strsep.c + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c version.o: version.c $(CC) $(CFLAGS) -c version.c diff --git a/contrib/tcpdump/README b/contrib/tcpdump/README index b9c2596..f1e0267 100644 --- a/contrib/tcpdump/README +++ b/contrib/tcpdump/README @@ -1,6 +1,6 @@ -@(#) $Header: /tcpdump/master/tcpdump/README,v 1.60.2.3 2003/02/26 07:08:58 fenner Exp $ (LBL) +@(#) $Header: /tcpdump/master/tcpdump/README,v 1.63.2.1 2003/11/16 10:17:30 guy Exp $ (LBL) -TCPDUMP 3.7.2 +TCPDUMP 3.8 Now maintained by "The Tcpdump Group" See www.tcpdump.org @@ -11,8 +11,8 @@ Anonymous CVS is available via: (password "anoncvs") cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout tcpdump -Version 3.7.2 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_7rel2": - cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_7rel2 tcpdump +Version 3.8 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_8rel1": + cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_8rel1 tcpdump Please send patches against the master copy to patches@tcpdump.org. diff --git a/contrib/tcpdump/Readme.Win32 b/contrib/tcpdump/Readme.Win32 new file mode 100644 index 0000000..fdf8b12 --- /dev/null +++ b/contrib/tcpdump/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/contrib/tcpdump/VERSION b/contrib/tcpdump/VERSION index 752b302..269aa9c 100644 --- a/contrib/tcpdump/VERSION +++ b/contrib/tcpdump/VERSION @@ -1 +1 @@ -3.7.2+multidlt +3.8.3 diff --git a/contrib/tcpdump/acconfig.h b/contrib/tcpdump/acconfig.h index 213b833..09e8351 100644 --- a/contrib/tcpdump/acconfig.h +++ b/contrib/tcpdump/acconfig.h @@ -65,6 +65,27 @@ /* define if you have ether_ntohost() and it works */ #undef USE_ETHER_NTOHOST +/* define if libpcap has pcap_version */ +#undef HAVE_PCAP_VERSION + +/* define if libpcap has pcap_debug */ +#undef HAVE_PCAP_DEBUG + +/* define if libpcap has yydebug */ +#undef HAVE_YYDEBUG + +/* define if libpcap has pcap_list_datalinks() */ +#undef HAVE_PCAP_LIST_DATALINKS + +/* define if libpcap has pcap_set_datalink() */ +#undef HAVE_PCAP_SET_DATALINK + +/* define if libpcap has pcap_datalink_name_to_val() */ +#undef HAVE_PCAP_DATALINK_NAME_TO_VAL + +/* define if libpcap has pcap_datalink_val_to_description() */ +#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION + /* define if unaligned memory accesses fail */ #undef LBL_ALIGN @@ -82,6 +103,7 @@ /* Workaround for missing sized types */ /* XXX this should move to the more standard uint*_t */ +#undef int8_t #undef int16_t #undef int32_t #undef u_int16_t @@ -98,3 +120,9 @@ * 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 + +/* Define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>. */ +#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA diff --git a/contrib/tcpdump/aodv.h b/contrib/tcpdump/aodv.h new file mode 100644 index 0000000..335c175 --- /dev/null +++ b/contrib/tcpdump/aodv.h @@ -0,0 +1,190 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.3 2003/09/13 01:34:42 guy Exp $ (LBL) */ +/* + * Copyright (c) 2003 Bruce M. Simpson <bms@spc.org> + * 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 Bruce M. Simpson. + * 4. Neither the name of Bruce M. Simpson nor the names of co- + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bruce M. Simpson 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 Bruce M. Simpson OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _AODV_H_ +#define _AODV_H_ + +struct aodv_rreq { + u_int8_t rreq_type; /* AODV message type (1) */ + u_int8_t rreq_flags; /* various flags */ + u_int8_t rreq_zero0; /* reserved, set to zero */ + u_int8_t rreq_hops; /* number of hops from originator */ + u_int32_t rreq_id; /* request ID */ + u_int32_t rreq_da; /* destination IPv4 address */ + u_int32_t rreq_ds; /* destination sequence number */ + u_int32_t rreq_oa; /* originator IPv4 address */ + u_int32_t rreq_os; /* originator sequence number */ +}; +#ifdef INET6 +struct aodv_rreq6 { + u_int8_t rreq_type; /* AODV message type (1) */ + u_int8_t rreq_flags; /* various flags */ + u_int8_t rreq_zero0; /* reserved, set to zero */ + u_int8_t rreq_hops; /* number of hops from originator */ + u_int32_t rreq_id; /* request ID */ + struct in6_addr rreq_da; /* destination IPv6 address */ + u_int32_t rreq_ds; /* destination sequence number */ + struct in6_addr rreq_oa; /* originator IPv6 address */ + u_int32_t rreq_os; /* originator sequence number */ +}; +struct aodv_rreq6_draft_01 { + u_int8_t rreq_type; /* AODV message type (16) */ + u_int8_t rreq_flags; /* various flags */ + u_int8_t rreq_zero0; /* reserved, set to zero */ + u_int8_t rreq_hops; /* number of hops from originator */ + u_int32_t rreq_id; /* request ID */ + u_int32_t rreq_ds; /* destination sequence number */ + u_int32_t rreq_os; /* originator sequence number */ + struct in6_addr rreq_da; /* destination IPv6 address */ + struct in6_addr rreq_oa; /* originator IPv6 address */ +}; +#endif + +#define RREQ_JOIN 0x80 /* join (reserved for multicast */ +#define RREQ_REPAIR 0x40 /* repair (reserved for multicast */ +#define RREQ_GRAT 0x20 /* gratuitous RREP */ +#define RREQ_DEST 0x10 /* destination only */ +#define RREQ_UNKNOWN 0x08 /* unknown destination sequence num */ +#define RREQ_FLAGS_MASK 0xF8 /* mask for rreq_flags */ + +struct aodv_rrep { + u_int8_t rrep_type; /* AODV message type (2) */ + u_int8_t rrep_flags; /* various flags */ + u_int8_t rrep_ps; /* prefix size */ + u_int8_t rrep_hops; /* number of hops from o to d */ + u_int32_t rrep_da; /* destination IPv4 address */ + u_int32_t rrep_ds; /* destination sequence number */ + u_int32_t rrep_oa; /* originator IPv4 address */ + u_int32_t rrep_life; /* lifetime of this route */ +}; +#ifdef INET6 +struct aodv_rrep6 { + u_int8_t rrep_type; /* AODV message type (2) */ + u_int8_t rrep_flags; /* various flags */ + u_int8_t rrep_ps; /* prefix size */ + u_int8_t rrep_hops; /* number of hops from o to d */ + struct in6_addr rrep_da; /* destination IPv6 address */ + u_int32_t rrep_ds; /* destination sequence number */ + struct in6_addr rrep_oa; /* originator IPv6 address */ + u_int32_t rrep_life; /* lifetime of this route */ +}; +struct aodv_rrep6_draft_01 { + u_int8_t rrep_type; /* AODV message type (17) */ + u_int8_t rrep_flags; /* various flags */ + u_int8_t rrep_ps; /* prefix size */ + u_int8_t rrep_hops; /* number of hops from o to d */ + u_int32_t rrep_ds; /* destination sequence number */ + struct in6_addr rrep_da; /* destination IPv6 address */ + struct in6_addr rrep_oa; /* originator IPv6 address */ + u_int32_t rrep_life; /* lifetime of this route */ +}; +#endif + +#define RREP_REPAIR 0x80 /* repair (reserved for multicast */ +#define RREP_ACK 0x40 /* acknowledgement required */ +#define RREP_FLAGS_MASK 0xC0 /* mask for rrep_flags */ +#define RREP_PREFIX_MASK 0x1F /* mask for prefix size */ + +struct rerr_unreach { + u_int32_t u_da; /* IPv4 address */ + u_int32_t u_ds; /* sequence number */ +}; +#ifdef INET6 +struct rerr_unreach6 { + struct in6_addr u_da; /* IPv6 address */ + u_int32_t u_ds; /* sequence number */ +}; +struct rerr_unreach6_draft_01 { + struct in6_addr u_da; /* IPv6 address */ + u_int32_t u_ds; /* sequence number */ +}; +#endif + +struct aodv_rerr { + u_int8_t rerr_type; /* AODV message type (3 or 18) */ + u_int8_t rerr_flags; /* various flags */ + u_int8_t rerr_zero0; /* reserved, set to zero */ + u_int8_t rerr_dc; /* destination count */ + union { + struct rerr_unreach dest[1]; +#ifdef INET6 + struct rerr_unreach6 dest6[1]; + struct rerr_unreach6_draft_01 dest6_draft_01[1]; +#endif + } r; +}; + +#define RERR_NODELETE 0x80 /* don't delete the link */ +#define RERR_FLAGS_MASK 0x80 /* mask for rerr_flags */ + +struct aodv_rrep_ack { + u_int8_t ra_type; + u_int8_t ra_zero0; +}; + +union aodv { + struct aodv_rreq rreq; + struct aodv_rrep rrep; + struct aodv_rerr rerr; + struct aodv_rrep_ack rrep_ack; +#ifdef INET6 + struct aodv_rreq6 rreq6; + struct aodv_rreq6_draft_01 rreq6_draft_01; + struct aodv_rrep6 rrep6; + struct aodv_rrep6_draft_01 rrep6_draft_01; +#endif +}; + +#define AODV_RREQ 1 /* route request */ +#define AODV_RREP 2 /* route response */ +#define AODV_RERR 3 /* error report */ +#define AODV_RREP_ACK 4 /* route response acknowledgement */ + +#define AODV_V6_DRAFT_01_RREQ 16 /* IPv6 route request */ +#define AODV_V6_DRAFT_01_RREP 17 /* IPv6 route response */ +#define AODV_V6_DRAFT_01_RERR 18 /* IPv6 error report */ +#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */ + +struct aodv_ext { + u_int8_t type; /* extension type */ + u_int8_t length; /* extension length */ +}; + +struct aodv_hello { + struct aodv_ext eh; /* extension header */ + u_int32_t interval; /* expect my next hello in + * (n) ms */ +}; + +#define AODV_EXT_HELLO 1 + +#endif /* _AODV_H_ */ diff --git a/contrib/tcpdump/appletalk.h b/contrib/tcpdump/appletalk.h index 73b2e4e..83e6f70 100644 --- a/contrib/tcpdump/appletalk.h +++ b/contrib/tcpdump/appletalk.h @@ -20,7 +20,7 @@ * * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX). * - * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.13 2000/10/03 02:54:54 itojun Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.15 2002/12/11 07:13:49 guy Exp $ (LBL) */ struct LAP { diff --git a/contrib/tcpdump/arcnet.h b/contrib/tcpdump/arcnet.h index 89867e0..6e649f6 100644 --- a/contrib/tcpdump/arcnet.h +++ b/contrib/tcpdump/arcnet.h @@ -30,13 +30,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#) $Id: arcnet.h,v 1.1 2001/04/17 08:39:18 guy Exp $ (LBL) + * @(#) $Id: arcnet.h,v 1.3 2003/01/23 09:05:37 guy Exp $ (LBL) * * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp */ /* - * Structure of a 2.5MB/s Arcnet header. + * Structure of a 2.5MB/s Arcnet header on the BSDs, * as given to interface code. */ struct arc_header { @@ -56,7 +56,7 @@ struct arc_header { u_int8_t arc_type2; /* same as arc_type */ u_int8_t arc_flag2; /* real flag value */ u_int16_t arc_seqid2; /* real seqid value */ -} __attribute__((__packed__)); +}; #define ARC_HDRLEN 3 #define ARC_HDRNEWLEN 6 @@ -77,3 +77,25 @@ struct arc_header { #define ARCTYPE_INET6 0xc4 /* IPng */ #define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */ + +/* + * Structure of a 2.5MB/s Arcnet header on Linux. Linux has + * an extra "offset" field when given to interface code, and + * never presents packets that look like exception frames. + */ +struct arc_linux_header { + u_int8_t arc_shost; + u_int8_t arc_dhost; + u_int16_t arc_offset; + u_int8_t arc_type; + /* + * only present for newstyle encoding with LL fragmentation. + * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN + * instead. + */ + u_int8_t arc_flag; + u_int16_t arc_seqid; +}; + +#define ARC_LINUX_HDRLEN 5 +#define ARC_LINUX_HDRNEWLEN 8 diff --git a/contrib/tcpdump/atm.h b/contrib/tcpdump/atm.h new file mode 100644 index 0000000..4fe2021 --- /dev/null +++ b/contrib/tcpdump/atm.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2002 Guy Harris. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code + * distributions retain the above copyright notice and this paragraph + * in its entirety, and (2) distributions including binary code include + * the above copyright notice and this paragraph in its entirety in + * the documentation or other materials provided with the distribution. + * The name of Guy Harris 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. + * + * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.1 2002/07/11 09:17:22 guy Exp $ + */ + +/* + * Traffic types for ATM. + */ +#define ATM_UNKNOWN 0 /* Unknown */ +#define ATM_LANE 1 /* LANE */ +#define ATM_LLC 2 /* LLC encapsulation */ diff --git a/contrib/tcpdump/atmuni31.h b/contrib/tcpdump/atmuni31.h new file mode 100644 index 0000000..304859a --- /dev/null +++ b/contrib/tcpdump/atmuni31.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1997 Yen Yen Lim and North Dakota State University + * 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 Yen Yen Lim and + North Dakota State University + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @(#) $Header: /tcpdump/master/tcpdump/atmuni31.h,v 1.2 2002/08/05 07:47:23 guy Exp $ (LBL) + */ + +/* Based on UNI3.1 standard by ATM Forum */ + +/* ATM traffic types based on VPI=0 and (the following VCI */ +#define PPC 0x05 /* Point-to-point signal msg */ +#define BCC 0x02 /* Broadcast signal msg */ +#define OAMF4SC 0x03 /* Segment OAM F4 flow cell */ +#define OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */ +#define METAC 0x01 /* Meta signal msg */ +#define ILMIC 0x10 /* ILMI msg */ + +/* Q.2931 signalling messages */ +#define CALL_PROCEED 0x02 /* call proceeding */ +#define CONNECT 0x07 /* connect */ +#define CONNECT_ACK 0x0f /* connect_ack */ +#define SETUP 0x05 /* setup */ +#define RELEASE 0x4d /* release */ +#define RELEASE_DONE 0x5a /* release_done */ +#define RESTART 0x46 /* restart */ +#define RESTART_ACK 0x4e /* restart ack */ +#define STATUS 0x7d /* status */ +#define STATUS_ENQ 0x75 /* status ack */ +#define ADD_PARTY 0x80 /* add party */ +#define ADD_PARTY_ACK 0x81 /* add party ack */ +#define ADD_PARTY_REJ 0x82 /* add party rej */ +#define DROP_PARTY 0x83 /* drop party */ +#define DROP_PARTY_ACK 0x84 /* drop party ack */ + +/* Information Element Parameters in the signalling messages */ +#define CAUSE 0x08 /* cause */ +#define ENDPT_REF 0x54 /* endpoint reference */ +#define AAL_PARA 0x58 /* ATM adaptation layer parameters */ +#define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */ +#define CONNECT_ID 0x5a /* connection identifier */ +#define QOS_PARA 0x5c /* quality of service parameters */ +#define B_HIGHER 0x5d /* broadband higher layer information */ +#define B_BEARER 0x5e /* broadband bearer capability */ +#define B_LOWER 0x5f /* broadband lower information */ +#define CALLING_PARTY 0x6c /* calling party number */ +#define CALLED_PARTY 0x70 /* called party nmber */ + +#define Q2931 0x09 + +/* Q.2931 signalling general messages format */ +#define PROTO_POS 0 /* offset of protocol discriminator */ +#define CALL_REF_POS 2 /* offset of call reference value */ +#define MSG_TYPE_POS 5 /* offset of message type */ +#define MSG_LEN_POS 7 /* offset of mesage length */ +#define IE_BEGIN_POS 9 /* offset of first information element */ + +/* format of signalling messages */ +#define TYPE_POS 0 +#define LEN_POS 2 +#define FIELD_BEGIN_POS 4 diff --git a/contrib/tcpdump/bootp.h b/contrib/tcpdump/bootp.h index 152d251..2e5d401 100644 --- a/contrib/tcpdump/bootp.h +++ b/contrib/tcpdump/bootp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.11 2001/01/09 07:39:13 fenner Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.15 2003/07/01 19:16:06 guy Exp $ (LBL) */ /* * Bootstrap Protocol (BOOTP). RFC951 and RFC1048. * @@ -27,7 +27,7 @@ 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: 0x8000 is broadcast */ + 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 */ @@ -44,9 +44,8 @@ struct bootp { #define IPPORT_BOOTPS 67 #define IPPORT_BOOTPC 68 -#define BOOTREPLY 2 -#define BOOTREQUEST 1 - +#define BOOTPREPLY 2 +#define BOOTPREQUEST 1 /* * Vendor magic cookie (v_magic) for CMU diff --git a/contrib/tcpdump/bpf_dump.c b/contrib/tcpdump/bpf_dump.c index 4d7f81f..4f289a1 100644 --- a/contrib/tcpdump/bpf_dump.c +++ b/contrib/tcpdump/bpf_dump.c @@ -19,16 +19,15 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.13 2000/12/09 02:58:45 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.14.2.2 2003/11/16 08:51:04 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> -#include <sys/time.h> +#include <tcpdump-stdinc.h> #include <pcap.h> #include <stdio.h> diff --git a/contrib/tcpdump/config.guess b/contrib/tcpdump/config.guess index ba66165..4c5bde8 100755 --- a/contrib/tcpdump/config.guess +++ b/contrib/tcpdump/config.guess @@ -1,9 +1,9 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2001-04-20' +timestamp='2003-10-16' # 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 @@ -24,8 +24,9 @@ timestamp='2001-04-20' # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. -# Written by Per Bothner <bothner@cygnus.com>. -# Please send patches to <config-patches@gnu.org>. +# 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. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and @@ -52,7 +53,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -87,33 +88,45 @@ if test $# != 0; then exit 1 fi +trap 'exit 1' 1 2 15 -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. -# CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. +# Portable tmp directory creation inspired by the Autoconf team. + +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" ; } || + { 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 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c - for c in cc gcc c89 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 - if test $? = 0 ; then - CC_FOR_BUILD="$c"; break - fi - done - rm -f $dummy.c $dummy.o $dummy.rel + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found + CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac +esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 8/24/94.) +# (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi @@ -127,29 +140,31 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) - # Netbsd (nbsd) targets should (where applicable) match one or + # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. - # Determine the machine/vendor (is the vendor relevant). - case "${UNAME_MACHINE}" in - amiga) machine=m68k-unknown ;; - arm32) machine=arm-unknown ;; - atari*) machine=m68k-atari ;; - sun3*) machine=m68k-sun ;; - mac68k) machine=m68k-apple ;; - macppc) machine=powerpc-apple ;; - hp3[0-9][05]) machine=m68k-hp ;; - ibmrt|romp-ibm) machine=romp-ibm ;; - *) machine=${UNAME_MACHINE}-unknown ;; + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. - case "${UNAME_MACHINE}" in - i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + case "${UNAME_MACHINE_ARCH}" 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 then @@ -165,71 +180,115 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; + 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 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi + # 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 + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac # 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. - cat <<EOF >$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - esac - fi - rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; + Alpha*:OpenVMS:*:*) + echo alpha-hp-vms + exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -242,33 +301,18 @@ EOF Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; @@ -286,6 +330,13 @@ EOF NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; @@ -314,7 +365,7 @@ EOF echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) @@ -328,9 +379,6 @@ EOF aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -357,18 +405,6 @@ EOF *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; @@ -385,6 +421,7 @@ EOF echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ @@ -406,15 +443,20 @@ EOF exit (-1); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; @@ -475,6 +517,7 @@ EOF exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include <sys/systemcfg.h> @@ -486,8 +529,7 @@ EOF exit(0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 @@ -496,7 +538,7 @@ EOF fi exit 0 ;; *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + 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 else @@ -536,10 +578,8 @@ EOF 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - case "${HPUX_REV}" in - 11.[0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 @@ -548,12 +588,13 @@ EOF case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac - fi ;; - esac - if [ "${HP_ARCH}" = "" ]; then - sed 's/^ //' << EOF >$dummy.c + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include <stdlib.h> @@ -586,11 +627,21 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; 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 + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) @@ -598,6 +649,7 @@ EOF echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include <unistd.h> int @@ -623,8 +675,7 @@ EOF exit (0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) @@ -633,7 +684,7 @@ EOF 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; - *9??*:MPE/iX:*:*) + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) @@ -652,9 +703,6 @@ EOF parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; @@ -673,40 +721,37 @@ EOF C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; 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 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} + 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 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -718,10 +763,21 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # 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 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -732,11 +788,17 @@ EOF i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix + echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin @@ -748,112 +810,84 @@ EOF echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) + # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; + *: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 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux + echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) - cat >$dummy.c <<EOF -#ifdef __cplusplus -#include <stdio.h> /* for printf() prototype */ -int main (int argc, char *argv[]) { -#else -int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __MIPSEB__ - printf ("%s-unknown-linux-gnu\n", argv[1]); -#endif -#ifdef __MIPSEL__ - printf ("%sel-unknown-linux-gnu\n", argv[1]); -#endif - return 0; -} + 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 + #endif EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; - ppc:Linux:*:*) - # Determine Lib Version - cat >$dummy.c <<EOF -#include <features.h> -#if defined(__GLIBC__) -extern char __libc_version[]; -extern char __libc_release[]; -#endif -main(argc, argv) - int argc; - char *argv[]; -{ -#if defined(__GLIBC__) - printf("%s %s\n", __libc_version, __libc_release); -#else - printf("unknown\n"); -#endif - return 0; -} + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif EOF - LIBC="" - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null - if test "$?" = 0 ; then - ./$dummy | grep 1\.99 > /dev/null - if test "$?" = 0 ; then LIBC="libc1" ; fi - fi - rm -f $dummy.c $dummy - echo powerpc-unknown-linux-gnu${LIBC} + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) - cat <<EOF >$dummy.s - .data - \$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - .text - .globl main - .align 4 - .ent main - main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - LIBC="" - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) UNAME_MACHINE="alpha" ;; - 1-0) UNAME_MACHINE="alphaev5" ;; - 1-1) UNAME_MACHINE="alphaev56" ;; - 1-101) UNAME_MACHINE="alphapca56" ;; - 2-303) UNAME_MACHINE="alphaev6" ;; - 2-307) UNAME_MACHINE="alphaev67" ;; - esac - objdump --private-headers $dummy | \ - grep ld.so.1 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f $dummy.s $dummy + 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 ;; parisc:Linux:*:* | hppa:Linux:*:*) @@ -870,6 +904,9 @@ EOF s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; @@ -883,71 +920,62 @@ EOF # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. - ld_supported_emulations=`cd /; ld --help 2>&1 \ - | sed -ne '/supported emulations:/!d + # 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 emulations: *// + s/.*supported targets: *// s/ .*// p'` - case "$ld_supported_emulations" in - i*86linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 - ;; - elf_i*86) + case "$ld_supported_targets" in + elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; - i*86coff) + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 - ;; - esac - # Either a pre-BFD a.out linker (linux-gnuoldld) - # or one that does not give us useful --help. - # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. - # If ld does not provide *any* "supported emulations:" - # that means it is gnuoldld. - test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 - case "${UNAME_MACHINE}" in - i*86) - VENDOR=pc; - ;; - *) - VENDOR=unknown; - ;; + 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 - cat >$dummy.c <<EOF -#include <features.h> -#ifdef __cplusplus -#include <stdio.h> /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); -#endif - return 0; -} + 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 - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + 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 ;; -# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions -# are messed up and put the nodename in both sysname and nodename. i*86:DYNIX/ptx:4*:*) + # 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 ;; i*86:UNIX_SV:4.2MP:2.*) @@ -958,6 +986,23 @@ EOF # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -966,36 +1011,32 @@ EOF echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; - i*86:*:5:7*) - # Fixed at (any) Pentium or better - UNAME_MACHINE=i586 - if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then - echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} - fi + i*86:*:5:[78]*) + 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 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` echo ${UNAME_MACHINE}-pc-isc$UNAME_REL elif /bin/uname -X 2>/dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1019,9 +1060,15 @@ EOF # "miniframe" echo m68010-convergent-sysv exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + 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[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.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) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` @@ -1038,9 +1085,6 @@ EOF mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; @@ -1067,8 +1111,8 @@ EOF echo ns32k-sni-sysv fi exit 0 ;; - PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <Richard.M.Bartel@ccMail.Census.GOV> + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) @@ -1080,6 +1124,10 @@ EOF # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; @@ -1108,6 +1156,9 @@ EOF SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; @@ -1115,18 +1166,24 @@ EOF echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) - if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo `uname -p`-${UNAME_MACHINE}-nto-qnx + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; - NSR-[KW]:NONSTOP_KERNEL:*:*) + NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) @@ -1149,11 +1206,6 @@ EOF fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; @@ -1172,11 +1224,18 @@ EOF *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit 0 ;; + *:DRAGONFLY:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE} + exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 +eval $set_cc_for_build cat >$dummy.c <<EOF #ifdef _SEQUENT_ # include <sys/types.h> @@ -1291,8 +1350,7 @@ main () } EOF -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in index ae543f0..a8d564d 100644 --- a/contrib/tcpdump/config.h.in +++ b/contrib/tcpdump/config.h.in @@ -1,16 +1,7 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ +/* config.h.in. Generated from configure.in by autoheader. */ /* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in -- * make them to acconfig.h and rerun autoheader */ -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define as the return type of signal handlers (int or void). */ -#undef RETSIGTYPE - -/* Define if you can safely include both <sys/time.h> and <time.h>. */ -#undef TIME_WITH_SYS_TIME - /* Define if you have SSLeay 0.9.0b with the buggy cast128. */ #undef HAVE_BUGGY_CAST128 @@ -20,12 +11,24 @@ /* 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 @@ -44,6 +47,9 @@ /* 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 @@ -53,9 +59,33 @@ /* define if you have struct sockaddr_storage */ #undef HAVE_SOCKADDR_STORAGE +/* define if you have both getipnodebyname() and getipnodebyaddr() */ +#undef USE_GETIPNODEBY + /* define if you have ether_ntohost() and it works */ #undef USE_ETHER_NTOHOST +/* define if libpcap has pcap_version */ +#undef HAVE_PCAP_VERSION + +/* define if libpcap has pcap_debug */ +#undef HAVE_PCAP_DEBUG + +/* define if libpcap has yydebug */ +#undef HAVE_YYDEBUG + +/* define if libpcap has pcap_list_datalinks() */ +#undef HAVE_PCAP_LIST_DATALINKS + +/* define if libpcap has pcap_set_datalink() */ +#undef HAVE_PCAP_SET_DATALINK + +/* define if libpcap has pcap_datalink_name_to_val() */ +#undef HAVE_PCAP_DATALINK_NAME_TO_VAL + +/* define if libpcap has pcap_datalink_val_to_description() */ +#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION + /* define if unaligned memory accesses fail */ #undef LBL_ALIGN @@ -73,6 +103,7 @@ /* Workaround for missing sized types */ /* XXX this should move to the more standard uint*_t */ +#undef int8_t #undef int16_t #undef int32_t #undef u_int16_t @@ -90,105 +121,173 @@ */ #undef const -/* The number of bytes in a char. */ -#undef SIZEOF_CHAR - -/* The number of bytes in a int. */ -#undef SIZEOF_INT - -/* The number of bytes in a long. */ -#undef SIZEOF_LONG +/* Define if you have the dnet_htoa function. */ +#undef HAVE_DNET_HTOA -/* The number of bytes in a short. */ -#undef SIZEOF_SHORT +/* Define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>. */ +#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA -/* Define if you have the bpf_dump function. */ +/* Define to 1 if you have the `bpf_dump' function. */ #undef HAVE_BPF_DUMP -/* Define if you have the ether_ntohost function. */ +/* Define to 1 if you have the `ether_ntohost' function. */ #undef HAVE_ETHER_NTOHOST -/* Define if you have the getaddrinfo function. */ +/* 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 if you have the getnameinfo function. */ +/* Define to 1 if you have the `getnameinfo' function. */ #undef HAVE_GETNAMEINFO -/* Define if you have the inet_aton function. */ -#undef HAVE_INET_ATON +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#undef HAVE_LIBCRYPTO + +/* Define to 1 if you have the `rpc' library (-lrpc). */ +#undef HAVE_LIBRPC + +/* Define to 1 if you have the `smi' library (-lsmi). */ +#undef HAVE_LIBSMI + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */ +#undef HAVE_NETDNET_DNETDB_H + +/* Define to 1 if you have the <netinet/ether.h> header file. */ +#undef HAVE_NETINET_ETHER_H + +/* Define to 1 if you have the <netinet/if_ether.h> header file. */ +#undef HAVE_NETINET_IF_ETHER_H -/* Define if you have the inet_ntop function. */ -#undef HAVE_INET_NTOP +/* Define to 1 if you have the <openssl/evp.h> header file. */ +#undef HAVE_OPENSSL_EVP_H -/* Define if you have the inet_pton function. */ -#undef HAVE_INET_PTON +/* Define to 1 if you have the `pcap_breakloop' function. */ +#undef HAVE_PCAP_BREAKLOOP -/* Define if you have the pfopen function. */ +/* Define to 1 if you have the `pcap_dump_flush' function. */ +#undef HAVE_PCAP_DUMP_FLUSH + +/* Define to 1 if you have the `pcap_findalldevs' function. */ +#undef HAVE_PCAP_FINDALLDEVS + +/* Define to 1 if the system has the type `pcap_if_t'. */ +#undef HAVE_PCAP_IF_T + +/* Define to 1 if you have the `pcap_lib_version' function. */ +#undef HAVE_PCAP_LIB_VERSION + +/* Define to 1 if you have the `pfopen' function. */ #undef HAVE_PFOPEN -/* Define if you have the setlinebuf function. */ +/* Define to 1 if you have the <rpc/rpcent.h> header file. */ +#undef HAVE_RPC_RPCENT_H + +/* Define to 1 if you have the `setlinebuf' function. */ #undef HAVE_SETLINEBUF -/* Define if you have the sigaction function. */ +/* Define to 1 if you have the `sigaction' function. */ #undef HAVE_SIGACTION -/* Define if you have the sigset function. */ +/* Define to 1 if you have the `sigset' function. */ #undef HAVE_SIGSET -/* Define if you have the snprintf function. */ +/* Define to 1 if you have the <smi.h> header file. */ +#undef HAVE_SMI_H + +/* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF -/* Define if you have the strcasecmp function. */ +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP -/* Define if you have the strdup function. */ +/* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP -/* Define if you have the strlcat function. */ +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strlcat' function. */ #undef HAVE_STRLCAT -/* Define if you have the strlcpy function. */ +/* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY -/* Define if you have the vfprintf function. */ +/* Define to 1 if you have the `strsep' function. */ +#undef HAVE_STRSEP + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vfprintf' function. */ #undef HAVE_VFPRINTF -/* Define if you have the vsnprintf function. */ +/* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF -/* Define if you have the <cast.h> header file. */ -#undef HAVE_CAST_H +/* define if your compiler has __attribute__ */ +#undef HAVE___ATTRIBUTE__ -/* Define if you have the <fcntl.h> header file. */ -#undef HAVE_FCNTL_H +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT -/* Define if you have the <netinet/if_ether.h> header file. */ -#undef HAVE_NETINET_IF_ETHER_H +/* Define to the full name of this package. */ +#undef PACKAGE_NAME -/* Define if you have the <rc5.h> header file. */ -#undef HAVE_RC5_H +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING -/* Define if you have the <rpc/rpcent.h> header file. */ -#undef HAVE_RPC_RPCENT_H +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME -/* Define if you have the <smi.h> header file. */ -#undef HAVE_SMI_H +/* Define to the version of this package. */ +#undef PACKAGE_VERSION -/* Define if you have the crypto library (-lcrypto). */ -#undef HAVE_LIBCRYPTO +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE -/* Define if you have the dnet library (-ldnet). */ -#undef HAVE_LIBDNET +/* The size of a `char', as computed by sizeof. */ +#undef SIZEOF_CHAR -/* Define if you have the rpc library (-lrpc). */ -#undef HAVE_LIBRPC +/* The size of a `int', as computed by sizeof. */ +#undef SIZEOF_INT -/* Define if you have the smi library (-lsmi). */ -#undef HAVE_LIBSMI +/* The size of a `long', as computed by sizeof. */ +#undef SIZEOF_LONG -/* Define as token for inline if inlining supported */ -#undef inline +/* The size of a `short', as computed by sizeof. */ +#undef SIZEOF_SHORT -/* define if your compiler has __attribute__ */ -#undef HAVE___ATTRIBUTE__ +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#undef TIME_WITH_SYS_TIME +/* Define as token for inline if inlining supported */ +#undef inline diff --git a/contrib/tcpdump/config.sub b/contrib/tcpdump/config.sub index a06a480..5698174 100755 --- a/contrib/tcpdump/config.sub +++ b/contrib/tcpdump/config.sub @@ -1,9 +1,9 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2001-04-20' +timestamp='2003-11-03' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -29,7 +29,8 @@ timestamp='2001-04-20' # 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>. +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -117,7 +118,8 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*) + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -157,6 +159,14 @@ case $os in os=-vxworks basic_machine=$1 ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; -hiux*) os=-hiuxwe2 ;; @@ -215,26 +225,50 @@ esac case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. - tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \ - | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \ - | pyramid | mn10200 | mn10300 | tron | a29k \ - | 580 | i960 | h8300 \ - | x86 | ppcbe | mipsbe | mipsle | shbe | shle \ - | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ - | hppa64 \ - | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ - | alphaev6[78] \ - | we32k | ns16k | clipper | i370 | sh | sh[34] \ - | powerpc | powerpcle \ - | 1750a | dsp16xx | pdp10 | pdp11 \ - | mips16 | mips64 | mipsel | mips64el \ - | mips64orion | mips64orionel | mipstx39 | mipstx39el \ - | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ - | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \ - | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \ - | v850 | c4x \ - | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \ - | pj | pjl | h8500) + 1750a | 580 \ + | a29k \ + | 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 \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | msp430 \ + | ns16k | ns32k \ + | openrisc | 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 \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xstormy16 | xtensa \ + | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) @@ -242,7 +276,7 @@ case $basic_machine in basic_machine=$basic_machine-unknown os=-none ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' @@ -257,31 +291,61 @@ case $basic_machine in exit 1 ;; # Recognize the basic CPU types with company name. - # FIXME: clean up the formatting here. - vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ - | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \ - | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \ - | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ - | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ - | xmp-* | ymp-* \ - | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \ - | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ - | hppa2.0n-* | hppa64-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ - | alphaev6[78]-* \ - | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ - | clipper-* | orion-* \ - | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ - | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \ - | mips16-* | mips64-* | mipsel-* \ - | mips64el-* | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ - | mipstx39-* | mipstx39el-* | mcore-* \ - | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \ - | [cjt]90-* \ - | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ - | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \ - | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*) + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | 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-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ + | ymp-* \ + | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -313,6 +377,9 @@ case $basic_machine in basic_machine=a29k-none os=-bsd ;; + amd64) + basic_machine=x86_64-pc + ;; amdahl) basic_machine=580-amdahl os=-sysv @@ -344,6 +411,10 @@ case $basic_machine in basic_machine=ns32k-sequent os=-dynix ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -364,16 +435,8 @@ case $basic_machine in basic_machine=c38-convex os=-bsd ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [cjt]90) - basic_machine=${basic_machine}-cray + cray | j90) + basic_machine=j90-cray os=-unicos ;; crds | unos) @@ -388,6 +451,14 @@ case $basic_machine in decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola @@ -568,14 +639,6 @@ case $basic_machine in basic_machine=m68k-atari os=-mint ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; @@ -590,6 +653,10 @@ case $basic_machine in basic_machine=m68k-rom68k os=-coff ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; msdos) basic_machine=i386-pc os=-msdos @@ -662,6 +729,10 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -669,6 +740,14 @@ case $basic_machine in basic_machine=hppa1.1-oki os=-proelf ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose @@ -691,42 +770,58 @@ case $basic_machine in pbb) basic_machine=m68k-tti ;; - pc532 | pc532-*) + pc532 | pc532-*) basic_machine=ns32k-pc532 ;; - pentium | p5 | k5 | k6 | nexgen) + pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; - pentiumpro | p6 | 6x86 | athlon) + pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; - pentiumii | pentium2) + pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-*) + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - pentiumii-* | pentium2-*) + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown - ;; + ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown - ;; + ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; ps2) basic_machine=i386-ibm ;; @@ -744,10 +839,26 @@ case $basic_machine in rtpc | rtpc-*) basic_machine=romp-ibm ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; sa29200) basic_machine=a29k-amd os=-udi ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; sequent) basic_machine=i386-sequent ;; @@ -755,7 +866,10 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; - sparclite-wrs) + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -822,22 +936,42 @@ case $basic_machine in os=-dynix ;; t3e) - basic_machine=t3e-cray + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; tower | tower-32) basic_machine=m68k-ncr ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; udi29k) basic_machine=a29k-amd os=-udi @@ -859,8 +993,8 @@ case $basic_machine in os=-vms ;; vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; + basic_machine=f301-fujitsu + ;; vxworks960) basic_machine=i960-wrs os=-vxworks @@ -881,13 +1015,13 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) + xps | xps100) basic_machine=xps100-honeywell ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim @@ -908,13 +1042,6 @@ case $basic_machine in op60c) basic_machine=hppa1.1-oki ;; - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; romp) basic_machine=romp-ibm ;; @@ -934,13 +1061,16 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh3 | sh4) + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; + sh64) + basic_machine=sh64-unknown + ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; - cydra) + cydra) basic_machine=cydra-cydrome ;; orion) @@ -955,10 +1085,6 @@ case $basic_machine in pmac | pmac-mpw) basic_machine=powerpc-apple ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; @@ -1014,15 +1140,19 @@ case $os in | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*) + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1034,8 +1164,10 @@ case $os in ;; esac ;; + -nto-qnx*) + ;; -nto*) - os=-nto-qnx + os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ @@ -1044,6 +1176,9 @@ case $os in -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; @@ -1056,6 +1191,9 @@ case $os in -opened*) os=-openedition ;; + -os400*) + os=-os400 + ;; -wince*) os=-wince ;; @@ -1074,14 +1212,20 @@ case $os in -acis*) os=-aos ;; + -atheos*) + os=-atheos + ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; + -nova*) + os=-rtmk-nova + ;; -ns2 ) - os=-nextstep2 + os=-nextstep2 ;; -nsk*) os=-nsk @@ -1093,6 +1237,9 @@ case $os in -sinix*) os=-sysv4 ;; + -tpf*) + os=-tpf + ;; -triton*) os=-sysv3 ;; @@ -1120,8 +1267,14 @@ case $os in -xenix) os=-xenix ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos ;; -none) ;; @@ -1154,10 +1307,14 @@ case $basic_machine in arm*-semi) os=-aout ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; - pdp11-*) + pdp11-*) os=-none ;; *-dec | vax-*) @@ -1184,6 +1341,9 @@ case $basic_machine in mips*-*) os=-elf ;; + or32-*) + os=-coff + ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; @@ -1247,19 +1407,19 @@ case $basic_machine in *-next) os=-nextstep3 ;; - *-gould) + *-gould) os=-sysv ;; - *-highlevel) + *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; - *-sgi) + *-sgi) os=-irix ;; - *-siemens) + *-siemens) os=-sysv4 ;; *-masscomp) @@ -1328,10 +1488,16 @@ case $basic_machine in -mvs* | -opened*) vendor=ibm ;; + -os400*) + vendor=ibm + ;; -ptx*) vendor=sequent ;; - -vxsim* | -vxworks*) + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) @@ -1346,6 +1512,9 @@ case $basic_machine in -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; + -vos*) + vendor=stratus + ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure index 05b34d1..7907b87 100755 --- a/contrib/tcpdump/configure +++ b/contrib/tcpdump/configure @@ -1,109 +1,325 @@ #! /bin/sh - -# From configure.in Revision: 1.145.2.1 - - - - -# -# Try compiling a sample of the type of code that appears in -# gencode.c with "inline", "__inline__", and "__inline". -# -# Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough, -# as it just tests whether a function returning "int" can be inlined; -# at least some versions of HP's C compiler can inline that, but can't -# inline a function that returns a struct pointer. +# From configure.in Revision: 1.169.2.3 . +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.57. # +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi +as_executable_p="test -f" +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" +# CDPATH. +$as_unset CDPATH +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` +exec 6>&1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= +# Initializations. +# ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --without-gcc don't use gcc" -ac_help="$ac_help - --enable-smb enable possibly-buggy SMB printer [default=yes] - --disable-smb disable possibly-buggy SMB printer" -ac_help="$ac_help - --enable-ipv6 enable ipv6 (with ipv4) support - --disable-ipv6 disable ipv6 support" -ac_help="$ac_help - --without-crypto disable crypto support" +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="tcpdump.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#if HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#if STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# if HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#if HAVE_STRINGS_H +# include <strings.h> +#endif +#if HAVE_INTTYPES_H +# include <inttypes.h> +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif +#if HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os SHLICC2 CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBOBJS V_CCOPT V_DEFS V_GROUP V_INCLS V_PCAPDEP LOCALSRC INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LTLIBOBJS' +ac_subst_files='' # Initialize some variables set by options. +ac_init_help= +ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. -build=NONE -cache_file=./config.cache +cache_file=/dev/null exec_prefix=NONE -host=NONE no_create= -nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE @@ -112,10 +328,15 @@ program_transform_name=s,x,x, silent= site= srcdir= -target=NONE verbose= x_includes=NONE x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' @@ -129,17 +350,9 @@ oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - ac_prev= for ac_option do - # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" @@ -147,59 +360,59 @@ do continue fi - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. - case "$ac_option" in + case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; + bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) - ac_prev=build ;; + ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; + build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) - datadir="$ac_optarg" ;; + datadir=$ac_optarg ;; -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "enable_${ac_feature}='$ac_optarg'" ;; + eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -208,95 +421,47 @@ do -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; + exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; -host | --host | --hos | --ho) - ac_prev=host ;; + ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; + host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; + includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; + infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; + libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; + libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ @@ -305,19 +470,19 @@ EOF -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; + localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; + mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) + | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ @@ -331,26 +496,26 @@ EOF -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; + oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; + prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; + program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; + program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ @@ -367,7 +532,7 @@ EOF | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; + program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) @@ -377,7 +542,7 @@ EOF ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; + sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ @@ -388,58 +553,57 @@ EOF | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; + sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; + site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; + srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; + sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; + ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; + target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "with_${ac_package}='$ac_optarg'" ;; + eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. @@ -450,99 +614,110 @@ EOF ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; + x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; + x_libraries=$ac_optarg ;; - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } fi -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac done -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=tcpdump.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. @@ -552,13 +727,440 @@ else fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } fi fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-smb enable possibly-buggy SMB printer default=yes + --disable-smb disable possibly-buggy SMB printer + --enable-ipv6 enable ipv6 (with ipv4) support + --disable-ipv6 disable ipv6 support + +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 + --without-crypto disable crypto support + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have + headers in a nonstandard directory <include dir> + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +It was created by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then @@ -569,39 +1171,103 @@ if test -z "$CONFIG_SITE"; then fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi else - echo "creating cache $cache_file" - > $cache_file + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } fi ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi +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 + + + + + + + + + + + + + + + + + @@ -615,53 +1281,86 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break fi done if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:635: checking host system type" >&5 -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - - - - # Check whether --with-gcc or --without-gcc was given. + + + + +# Check whether --with-gcc or --without-gcc was given. if test "${with_gcc+set}" = set; then withval="$with_gcc" - : -fi +fi; V_CCOPT="-O" V_INCLS="" if test "${srcdir}" != "." ; then @@ -676,32 +1375,38 @@ fi bsdi*) # Extract the first word of "shlicc2", so it can be a program name with args. set dummy shlicc2; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:681: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_SHLICC2'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_SHLICC2+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$SHLICC2"; then ac_cv_prog_SHLICC2="$SHLICC2" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_SHLICC2="yes" - break - fi - done - IFS="$ac_save_ifs" +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_SHLICC2="yes" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + test -z "$ac_cv_prog_SHLICC2" && ac_cv_prog_SHLICC2="no" fi fi -SHLICC2="$ac_cv_prog_SHLICC2" +SHLICC2=$ac_cv_prog_SHLICC2 if test -n "$SHLICC2"; then - echo "$ac_t""$SHLICC2" 1>&6 + echo "$as_me:$LINENO: result: $SHLICC2" >&5 +echo "${ECHO_T}$SHLICC2" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi if test $SHLICC2 = yes ; then @@ -715,214 +1420,643 @@ fi CC=cc export CC fi - # Extract the first word of "gcc", so it can be a program name with args. + 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' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; 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_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:722: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; 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_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; 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_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC else - echo "$ac_t""no" 1>&6 + CC="$ac_cv_prog_CC" fi +fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:752: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift - if test $# -gt 0; then + if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:803: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; 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_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:835: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; 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_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -cat > conftest.$ac_ext << EOF + test -n "$ac_ct_CC" && break +done -#line 846 "configure" -#include "confdefs.h" + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ -main(){return(0);} -EOF -if { (eval echo configure:851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no else - ac_cv_prog_cc_cross=yes + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:877: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:882: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:891: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ -if test $ac_cv_prog_gcc = yes; then - GCC=yes + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done else - GCC= -fi + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:910: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else - ac_cv_prog_cc_g=no -fi -rm -f conftest* + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_prog_cc_g=no fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" + CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" @@ -936,16 +2070,233 @@ else CFLAGS= fi fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include <stdlib.h>' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +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' +ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "$GCC" = yes ; then if test "$SHLICC2" = yes ; then ac_cv_lbl_gcc_vers=2 V_CCOPT="-O2" else - echo $ac_n "checking gcc version""... $ac_c" 1>&6 -echo "configure:947: checking gcc version" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_gcc_vers'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking gcc version" >&5 +echo $ECHO_N "checking gcc version... $ECHO_C" >&6 + if test "${ac_cv_lbl_gcc_vers+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ sed -e '/^gcc version /!d' \ @@ -954,83 +2305,127 @@ else -e 's/\..*//'` fi - echo "$ac_t""$ac_cv_lbl_gcc_vers" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_gcc_vers" >&5 +echo "${ECHO_T}$ac_cv_lbl_gcc_vers" >&6 if test $ac_cv_lbl_gcc_vers -gt 1 ; then V_CCOPT="-O2" fi fi else - echo $ac_n "checking that $CC handles ansi prototypes""... $ac_c" 1>&6 -echo "configure:965: checking that $CC handles ansi prototypes" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_cc_ansi_prototypes'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 970 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking that $CC handles ansi prototypes" >&5 +echo $ECHO_N "checking that $CC handles ansi prototypes... $ECHO_C" >&6 + if test "${ac_cv_lbl_cc_ansi_prototypes+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/types.h> -int main() { +int +main () +{ int frob(int, char *) -; return 0; } -EOF -if { (eval echo configure:977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_cc_ansi_prototypes=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_cc_ansi_prototypes=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_cc_ansi_prototypes=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_cc_ansi_prototypes" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_ansi_prototypes" >&5 +echo "${ECHO_T}$ac_cv_lbl_cc_ansi_prototypes" >&6 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then case "$host_os" in hpux*) - echo $ac_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)""... $ac_c" 1>&6 -echo "configure:995: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5 + echo "$as_me:$LINENO: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5 +echo $ECHO_N "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)... $ECHO_C" >&6 savedcflags="$CFLAGS" CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" - if eval "test \"`echo '$''{'ac_cv_lbl_cc_hpux_cc_aa'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1002 "configure" -#include "confdefs.h" + if test "${ac_cv_lbl_cc_hpux_cc_aa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/types.h> -int main() { +int +main () +{ int frob(int, char *) -; return 0; } -EOF -if { (eval echo configure:1009: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_cc_hpux_cc_aa=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_cc_hpux_cc_aa=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_cc_hpux_cc_aa=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_cc_hpux_cc_aa" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_hpux_cc_aa" >&5 +echo "${ECHO_T}$ac_cv_lbl_cc_hpux_cc_aa" >&6 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then - { echo "configure: error: see the INSTALL doc for more info" 1>&2; exit 1; } + { { 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="-Aa $V_CCOPT" - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define _HPUX_SOURCE 1 -EOF +_ACEOF ;; *) - { echo "configure: error: see the INSTALL doc for more info" 1>&2; exit 1; } + { { 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; }; } ;; esac fi @@ -1048,56 +2443,79 @@ EOF ;; ultrix*) - echo $ac_n "checking that Ultrix $CC hacks const in prototypes""... $ac_c" 1>&6 -echo "configure:1053: checking that Ultrix $CC hacks const in prototypes" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_cc_const_proto'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1058 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking that Ultrix $CC hacks const in prototypes" >&5 +echo $ECHO_N "checking that Ultrix $CC hacks const in prototypes... $ECHO_C" >&6 + if test "${ac_cv_lbl_cc_const_proto+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/types.h> -int main() { +int +main () +{ struct a { int b; }; void c(const struct a *) -; return 0; } -EOF -if { (eval echo configure:1066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_cc_const_proto=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_cc_const_proto=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_cc_const_proto=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_cc_const_proto" 1>&6 + 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 <<\EOF -#define const -EOF + cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF fi ;; esac fi -echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1090: checking for inline" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_inline'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6 + if test "${ac_cv_lbl_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - + ac_cv_lbl_inline="" ac_lbl_cc_inline=no for ac_lbl_inline in inline __inline__ __inline do - cat > conftest.$ac_ext <<EOF -#line 1100 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #define inline $ac_lbl_inline static inline struct iltest *foo(void); struct iltest { @@ -1112,18 +2530,33 @@ else return &xxx; } -int main() { +int +main () +{ -; return 0; } -EOF -if { (eval echo configure:1120: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_lbl_cc_inline=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext if test "$ac_lbl_cc_inline" = yes ; then break; fi @@ -1134,28 +2567,37 @@ rm -f conftest* fi if test ! -z "$ac_cv_lbl_inline" ; then - echo "$ac_t""$ac_cv_lbl_inline" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_inline" >&5 +echo "${ECHO_T}$ac_cv_lbl_inline" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - cat >> confdefs.h <<EOF + +cat >>confdefs.h <<_ACEOF #define inline $ac_cv_lbl_inline -EOF +_ACEOF -echo $ac_n "checking for __attribute__""... $ac_c" 1>&6 -echo "configure:1148: checking for __attribute__" >&5 -if eval "test \"`echo '$''{'ac_cv___attribute__'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for __attribute__" >&5 +echo $ECHO_N "checking for __attribute__... $ECHO_C" >&6 +if test "${ac_cv___attribute__+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - -cat > conftest.$ac_ext <<EOF -#line 1154 "configure" -#include "confdefs.h" + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <stdlib.h> -int main() { +int +main () +{ static void foo(void) __attribute__ ((noreturn)); @@ -1165,181 +2607,770 @@ foo(void) exit(1); } -; return 0; } -EOF -if { (eval echo configure:1171: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv___attribute__=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv___attribute__=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv___attribute__=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi if test "$ac_cv___attribute__" = "yes"; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define HAVE___ATTRIBUTE__ 1 -EOF +_ACEOF + V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" +else + V_DEFS="$V_DEFS -D_U_=\"\"" fi -echo "$ac_t""$ac_cv___attribute__" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv___attribute__" >&5 +echo "${ECHO_T}$ac_cv___attribute__" >&6 -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1193: checking how to run the C preprocessor" >&5 +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' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&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; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&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; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 1208 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1214: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&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; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 1225 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1231: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&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; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext <<EOF -#line 1242 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +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' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp + ac_cv_header_stdc=no fi rm -f conftest* + fi -rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no fi rm -f conftest* - ac_cv_prog_CPP="$CPP" + fi - CPP="$ac_cv_prog_CPP" + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ctype.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : else - ac_cv_prog_CPP="$CPP" + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$CPP" 1>&6 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF -for ac_hdr in fcntl.h rpc/rpcent.h netinet/if_ether.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1276: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1281 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1286: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" fi -rm -f conftest* + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* 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 { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - + +done + + + + + + +for ac_header in fcntl.h rpc/rpcent.h netdnet/dnetdb.h netinet/ether.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&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 +#line $LINENO "configure" +/* 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 { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; 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 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 +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&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; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - echo "$ac_t""no" 1>&6 + ac_cpp_err=yes +fi +if test -z "$ac_cpp_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 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 preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + 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: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&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 -echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1313: checking whether time.h and sys/time.h may both be included" >&5 -if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + +for ac_header in netinet/if_ether.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <sys/socket.h> + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" else - cat > conftest.$ac_ext <<EOF -#line 1318 "configure" -#include "confdefs.h" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +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 + +echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/types.h> #include <sys/time.h> #include <time.h> -int main() { -struct tm *tp; -; return 0; } -EOF -if { (eval echo configure:1327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_header_time=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_time=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_time=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - -echo "$ac_t""$ac_cv_header_time" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 -EOF +_ACEOF fi @@ -1347,30 +3378,35 @@ fi case "$host_os" in linux*) - echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6 -echo "configure:1352: checking Linux kernel version" >&5 + echo "$as_me:$LINENO: checking Linux kernel version" >&5 +echo $ECHO_N "checking Linux kernel version... $ECHO_C" >&6 if test "$cross_compiling" = yes; then - if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + if test "${ac_cv_linux_vers+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_linux_vers=unknown fi else - if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + if test "${ac_cv_linux_vers+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_linux_vers=`uname -r 2>&1 | \ sed -n -e '$s/.* //' -e '$s/\..*//p'` fi fi - echo "$ac_t""$ac_cv_linux_vers" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_linux_vers" >&5 +echo "${ECHO_T}$ac_cv_linux_vers" >&6 if test $ac_cv_linux_vers = unknown ; then - { echo "configure: error: cannot determine linux version when cross-compiling" 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5 +echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;} + { (exit 1); exit 1; }; } fi if test $ac_cv_linux_vers -lt 2 ; then - { echo "configure: error: version 2 or higher required; see the INSTALL doc for more info" 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: version 2 or higher required; see the INSTALL doc for more info" >&5 +echo "$as_me: error: version 2 or higher required; see the INSTALL doc for more info" >&2;} + { (exit 1); exit 1; }; } fi ;; @@ -1379,112 +3415,236 @@ fi esac -for ac_hdr in smi.h + +for ac_header in smi.h do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1387: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1392 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1397: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&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 +#line $LINENO "configure" +/* 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 { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; 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 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 +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&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; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_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 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 preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + 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: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" fi -rm -f conftest* +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - -else - echo "$ac_t""no" 1>&6 +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 -echo $ac_n "checking for smiInit in -lsmi""... $ac_c" 1>&6 -echo "configure:1424: checking for smiInit in -lsmi" >&5 -ac_lib_var=`echo smi'_'smiInit | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + +echo "$as_me:$LINENO: checking for smiInit in -lsmi" >&5 +echo $ECHO_N "checking for smiInit in -lsmi... $ECHO_C" >&6 +if test "${ac_cv_lib_smi_smiInit+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-lsmi $LIBS" -cat > conftest.$ac_ext <<EOF -#line 1432 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char smiInit(); - -int main() { -smiInit() -; return 0; } -EOF -if { (eval echo configure:1443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo smi | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <<EOF -#define $ac_tr_lib 1 -EOF + builtin and then its argument prototype would still apply. */ +char smiInit (); +int +main () +{ +smiInit (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_smi_smiInit=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_smi_smiInit=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_smi_smiInit" >&5 +echo "${ECHO_T}$ac_cv_lib_smi_smiInit" >&6 +if test $ac_cv_lib_smi_smiInit = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSMI 1 +_ACEOF LIBS="-lsmi $LIBS" -else - echo "$ac_t""no" 1>&6 fi if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes then -echo $ac_n "checking whether to enable libsmi""... $ac_c" 1>&6 -echo "configure:1473: checking whether to enable libsmi" >&5 +echo "$as_me:$LINENO: checking whether to enable libsmi" >&5 +echo $ECHO_N "checking whether to enable libsmi... $ECHO_C" >&6 if test "$cross_compiling" = yes; then - echo "$ac_t""not when cross-compiling" 1>&6 + echo "$as_me:$LINENO: result: not when cross-compiling" >&5 +echo "${ECHO_T}not when cross-compiling" >&6 libsmi=no else - cat > conftest.$ac_ext <<EOF -#line 1480 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* libsmi available check */ #include <smi.h> main() { int current, revision, age, n; const int required = 2; - if (smiInit("")) + if (smiInit("")) exit(1); if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) exit(2); @@ -1496,85 +3656,109 @@ main() exit(0); } -EOF -if { (eval echo configure:1501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + cat >>confdefs.h <<\_ACEOF #define LIBSMI 1 -EOF +_ACEOF libsmi=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - case $? in - 1) echo "$ac_t""no - smiInit failed" 1>&6 ;; - 2) echo "$ac_t""no - header/library version mismatch" 1>&6 ;; - 3) echo "$ac_t""no - can't determine library version" 1>&6 ;; - 4) echo "$ac_t""no - too old" 1>&6 ;; - *) echo "$ac_t""no" 1>&6 ;; + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) + case $? in + 1) echo "$as_me:$LINENO: result: no - smiInit failed" >&5 +echo "${ECHO_T}no - smiInit failed" >&6 ;; + 2) echo "$as_me:$LINENO: result: no - header/library version mismatch" >&5 +echo "${ECHO_T}no - header/library version mismatch" >&6 ;; + 3) echo "$as_me:$LINENO: result: no - can't determine library version" >&5 +echo "${ECHO_T}no - can't determine library version" >&6 ;; + 4) echo "$as_me:$LINENO: result: no - too old" >&5 +echo "${ECHO_T}no - too old" >&6 ;; + *) echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 ;; esac libsmi=no fi -rm -fr conftest* +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi -echo $ac_n "checking whether to enable the possibly-buggy SMB printer""... $ac_c" 1>&6 -echo "configure:1528: checking whether to enable the possibly-buggy SMB printer" >&5 +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 # Check whether --enable-smb or --disable-smb was given. if test "${enable_smb+set}" = set; then enableval="$enable_smb" - : + else enableval=yes -fi - +fi; case "$enableval" in -yes) echo "$ac_t""yes" 1>&6 - echo "configure: warning: The SMB printer may have exploitable buffer overflows!!!" 1>&2 - cat >> confdefs.h <<\EOF +yes) echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + { echo "$as_me:$LINENO: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&5 +echo "$as_me: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&2;} + cat >>confdefs.h <<\_ACEOF #define TCPDUMP_DO_SMB 1 -EOF +_ACEOF LOCALSRC="print-smb.c smbutil.c $LOCALSRC" ;; -*) echo "$ac_t""no" 1>&6 +*) echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 ;; esac -CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len" -echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6 -echo "configure:1552: checking whether to enable ipv6" >&5 +echo "$as_me:$LINENO: checking whether to enable ipv6" >&5 +echo $ECHO_N "checking whether to enable ipv6... $ECHO_C" >&6 # Check whether --enable-ipv6 or --disable-ipv6 was given. if test "${enable_ipv6+set}" = set; then enableval="$enable_ipv6" case "$enableval" in -yes) echo "$ac_t""yes" 1>&6 - LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" - cat >> confdefs.h <<\EOF +yes) echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" + cat >>confdefs.h <<\_ACEOF #define INET6 1 -EOF +_ACEOF ipv6=yes ;; *) - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 ipv6=no ;; - esac + esac else if test "$cross_compiling" = yes; then - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 ipv6=no else - cat > conftest.$ac_ext <<EOF -#line 1577 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* AF_INET6 available check */ #include <sys/types.h> #include <sys/socket.h> @@ -1586,51 +3770,64 @@ main() exit(0); } -EOF -if { (eval echo configure:1591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""yes" 1>&6 - LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" - cat >> confdefs.h <<\EOF +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" + cat >>confdefs.h <<\_ACEOF #define INET6 1 -EOF +_ACEOF ipv6=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""no" 1>&6 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 ipv6=no fi -rm -fr conftest* +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - -fi - +fi; ipv6type=unknown ipv6lib=none ipv6trylibc=no if test "$ipv6" = "yes"; then - echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6 -echo "configure:1619: checking ipv6 stack type" >&5 + echo "$as_me:$LINENO: checking ipv6 stack type" >&5 +echo $ECHO_N "checking ipv6 stack type... $ECHO_C" >&6 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do case $i in inria) - cat > conftest.$ac_ext <<EOF -#line 1624 "configure" -#include "confdefs.h" -dnl + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <netinet/in.h> #ifdef IPV6_INRIA_VERSION yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i; CFLAGS="-DINET6 $CFLAGS" fi @@ -1638,18 +3835,20 @@ rm -f conftest* ;; kame) - cat > conftest.$ac_ext <<EOF -#line 1643 "configure" -#include "confdefs.h" -dnl + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <netinet/in.h> #ifdef __KAME__ yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; @@ -1660,18 +3859,20 @@ rm -f conftest* ;; linux-glibc) - cat > conftest.$ac_ext <<EOF -#line 1665 "configure" -#include "confdefs.h" -dnl + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <features.h> #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i; CFLAGS="-DINET6 $CFLAGS" fi @@ -1679,7 +3880,7 @@ rm -f conftest* ;; linux-libinet6) - if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then + if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then ipv6type=$i ipv6lib=inet6 ipv6libdir=/usr/inet6/lib @@ -1688,18 +3889,20 @@ rm -f conftest* fi ;; toshiba) - cat > conftest.$ac_ext <<EOF -#line 1693 "configure" -#include "confdefs.h" -dnl + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/param.h> #ifdef _TOSHIBA_INET6 yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; @@ -1709,18 +3912,20 @@ rm -f conftest* ;; v6d) - cat > conftest.$ac_ext <<EOF -#line 1714 "configure" -#include "confdefs.h" -dnl + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include </usr/local/v6/include/sys/v6config.h> #ifdef __V6D__ yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i; ipv6lib=v6; ipv6libdir=/usr/local/v6/lib; @@ -1730,18 +3935,20 @@ rm -f conftest* ;; zeta) - cat > conftest.$ac_ext <<EOF -#line 1735 "configure" -#include "confdefs.h" -dnl + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/param.h> #ifdef _ZETA_MINAMI_INET6 yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; @@ -1755,7 +3962,8 @@ rm -f conftest* break fi done - echo "$ac_t""$ipv6type" 1>&6 + echo "$as_me:$LINENO: result: $ipv6type" >&5 +echo "${ECHO_T}$ipv6type" >&6 fi if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then @@ -1776,73 +3984,137 @@ fi if test "$ipv6" = "yes"; then - -echo $ac_n "checking for library containing getaddrinfo""... $ac_c" 1>&6 -echo "configure:1782: checking for library containing getaddrinfo" >&5 -if eval "test \"`echo '$''{'ac_cv_search_getaddrinfo'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_func_search_save_LIBS="$LIBS" -ac_cv_search_getaddrinfo="no" -cat > conftest.$ac_ext <<EOF -#line 1789 "configure" -#include "confdefs.h" + # + # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()" + # function in libc; there are "ngetaddrinfo()" and + # "ogetaddrinfo()" functions, and <netdb.h> #defines + # "getaddrinfo" to be either "ngetaddrinfo" or + # "ogetaddrinfo", depending on whether _SOCKADDR_LEN + # or _XOPEN_SOURCE_EXTENDED are defined or not. + # + # So this test doesn't work on Tru64 5.1, and possibly + # on other 5.x releases. This causes the configure + # script to become confused, and results in libpcap + # being unbuildable. + # + echo "$as_me:$LINENO: checking for library containing getaddrinfo" >&5 +echo $ECHO_N "checking for library containing getaddrinfo... $ECHO_C" >&6 +if test "${ac_cv_search_getaddrinfo+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_getaddrinfo=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char getaddrinfo(); - -int main() { -getaddrinfo() -; return 0; } -EOF -if { (eval echo configure:1800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + builtin and then its argument prototype would still apply. */ +char getaddrinfo (); +int +main () +{ +getaddrinfo (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_search_getaddrinfo="none required" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -test "$ac_cv_search_getaddrinfo" = "no" && for i in socket; do -LIBS="-l$i $ac_func_search_save_LIBS" -cat > conftest.$ac_ext <<EOF -#line 1811 "configure" -#include "confdefs.h" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_getaddrinfo" = no; then + for ac_lib in socket; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char getaddrinfo(); - -int main() { -getaddrinfo() -; return 0; } -EOF -if { (eval echo configure:1822: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_cv_search_getaddrinfo="-l$i" + builtin and then its argument prototype would still apply. */ +char getaddrinfo (); +int +main () +{ +getaddrinfo (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_getaddrinfo="-l$ac_lib" break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -done -LIBS="$ac_func_search_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done fi - -echo "$ac_t""$ac_cv_search_getaddrinfo" 1>&6 -if test "$ac_cv_search_getaddrinfo" != "no"; then +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_getaddrinfo" >&5 +echo "${ECHO_T}$ac_cv_search_getaddrinfo" >&6 +if test "$ac_cv_search_getaddrinfo" != no; then test "$ac_cv_search_getaddrinfo" = "none required" || LIBS="$ac_cv_search_getaddrinfo $LIBS" - echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6 -echo "configure:1839: checking getaddrinfo bug" >&5 - if test "$cross_compiling" = yes; then - echo "$ac_t""buggy" 1>&6 - buggygetaddrinfo=yes + echo "$as_me:$LINENO: checking getaddrinfo bug" >&5 +echo $ECHO_N "checking getaddrinfo bug... $ECHO_C" >&6 + if test "${td_cv_buggygetaddrinfo+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1845 "configure" -#include "confdefs.h" + if test "$cross_compiling" = yes; then + td_cv_buggygetaddrinfo=yes +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/types.h> #include <netdb.h> @@ -1861,6 +4133,7 @@ main() hints.ai_family = AF_UNSPEC; hints.ai_flags = passive ? AI_PASSIVE : 0; hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { (void)gai_strerror(gaierr); goto bad; @@ -1937,573 +4210,1685 @@ main() exit(1); } -EOF -if { (eval echo configure:1942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - echo "$ac_t""good" 1>&6 - buggygetaddrinfo=no +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + td_cv_buggygetaddrinfo=no else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - echo "$ac_t""buggy" 1>&6 - buggygetaddrinfo=yes + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +td_cv_buggygetaddrinfo=yes fi -rm -fr conftest* +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - -else : - buggygetaddrinfo=yes fi - if test "$buggygetaddrinfo" = "yes"; then + if test "$td_cv_buggygetaddrinfo" = no; then + echo "$as_me:$LINENO: result: good" >&5 +echo "${ECHO_T}good" >&6 + else + echo "$as_me:$LINENO: result: buggy" >&5 +echo "${ECHO_T}buggy" >&6 + fi + + if test "$td_cv_buggygetaddrinfo" = "yes"; then + # + # XXX - it doesn't appear that "ipv6type" can ever be + # set to "linux". Should this be testing for + # "linux-glibc", or for that *or* "linux-libinet6"? + # If the latter, note that "linux-libinet6" is also + # the type given to some non-Linux OSes. + # if test "$ipv6type" != "linux"; then echo 'Fatal: You must get working getaddrinfo() function.' echo ' or you can specify "--disable-ipv6"'. exit 1 else echo 'Warning: getaddrinfo() implementation on your system seems be buggy.' - echo ' Better upgreade your system library to newest version' + echo ' Better upgrade your system library to newest version' echo ' of GNU C library (aka glibc).' fi fi - for ac_func in getaddrinfo getnameinfo -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1974: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1979 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:2002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* fi -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" -fi -done -fi -echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6 -echo "configure:2030: checking for inet_ntop" >&5 -cat > conftest.$ac_ext <<EOF -#line 2032 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -int main() { -char src[4], dst[128]; -inet_ntop(AF_INET, src, dst, sizeof(dst)); -; return 0; } -EOF -if { (eval echo configure:2043: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 - for ac_func in inet_ntop +for ac_func in getaddrinfo getnameinfo do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2054: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2059 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> #else -$ac_func(); +# include <assert.h> #endif - -; return 0; } -EOF -if { (eval echo configure:2082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" -fi -done - - -fi -rm -f conftest* -echo $ac_n "checking for inet_pton""... $ac_c" 1>&6 -echo "configure:2111: checking for inet_pton" >&5 -cat > conftest.$ac_ext <<EOF -#line 2113 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -int main() { -char src[128], dst[4]; -inet_pton(AF_INET, src, dst); -; return 0; } -EOF -if { (eval echo configure:2124: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 - for ac_func in inet_pton -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2135: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2140 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + LIBOBJS="$LIBOBJS $ac_func.$ac_objext" fi done fi -rm -f conftest* -echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 -echo "configure:2192: checking for inet_aton" >&5 -cat > conftest.$ac_ext <<EOF -#line 2194 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/inet.h> -int main() { -char src[128]; -struct in_addr dst; -inet_aton(src, &dst); -; return 0; } -EOF -if { (eval echo configure:2205: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 - for ac_func in inet_aton -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2216: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2221 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif +echo "$as_me:$LINENO: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5 +echo $ECHO_N "checking for dnet_htoa declaration in netdnet/dnetdb.h... $ECHO_C" >&6 +if test "${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <netdnet/dnetdb.h> -; return 0; } -EOF -if { (eval echo configure:2244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "dnet_htoa" >/dev/null 2>&1; then + td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" + td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no fi rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi -done - +echo "$as_me:$LINENO: result: $td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&5 +echo "${ECHO_T}$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&6 +if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1 +_ACEOF fi -rm -f conftest* - - echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 -echo "configure:2275: checking if sockaddr struct has sa_len member" >&5 - if eval "test \"`echo '$''{'ac_cv_sockaddr_has_sa_len'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for char" >&5 +echo $ECHO_N "checking for char... $ECHO_C" >&6 +if test "${ac_cv_type_char+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2280 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((char *) 0) + return 0; +if (sizeof (char)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_char=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_char=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_char" >&5 +echo "${ECHO_T}$ac_cv_type_char" >&6 + +echo "$as_me:$LINENO: checking size of char" >&5 +echo $ECHO_N "checking size of char... $ECHO_C" >&6 +if test "${ac_cv_sizeof_char+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_char" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) >= 0)]; +test_array [0] = 0 -# include <sys/types.h> -# include <sys/socket.h> -int main() { -u_int i = sizeof(((struct sockaddr *)0)->sa_len) -; return 0; } -EOF -if { (eval echo configure:2289: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_sockaddr_has_sa_len=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_sockaddr_has_sa_len=no -fi -rm -f conftest* -fi + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) <= $ac_mid)]; +test_array [0] = 0 - echo "$ac_t""$ac_cv_sockaddr_has_sa_len" 1>&6 - if test $ac_cv_sockaddr_has_sa_len = yes ; then - cat >> confdefs.h <<\EOF -#define HAVE_SOCKADDR_SA_LEN 1 -EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) < 0)]; +test_array [0] = 0 - fi + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) >= $ac_mid)]; +test_array [0] = 0 -if test "$ac_cv_sockaddr_has_sa_len" = no; then - missing_includes=yes -fi + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) <= $ac_mid)]; +test_array [0] = 0 -echo $ac_n "checking size of char""... $ac_c" 1>&6 -echo "configure:2314: checking size of char" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_char=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac else if test "$cross_compiling" = yes; then - ac_cv_sizeof_char=1 -else - cat > conftest.$ac_ext <<EOF -#line 2322 "configure" -#include "confdefs.h" + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (char)); } +unsigned long ulongval () { return (long) (sizeof (char)); } #include <stdio.h> -main() +#include <stdlib.h> +int +main () { - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(char)); - exit(0); + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (char))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (char)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (char)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; } -EOF -if { (eval echo configure:2333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_char=`cat conftestval` +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_char=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* ac_cv_sizeof_char=0 fi -rm -fr conftest* -fi - fi -echo "$ac_t""$ac_cv_sizeof_char" 1>&6 -cat >> confdefs.h <<EOF +echo "$as_me:$LINENO: result: $ac_cv_sizeof_char" >&5 +echo "${ECHO_T}$ac_cv_sizeof_char" >&6 +cat >>confdefs.h <<_ACEOF #define SIZEOF_CHAR $ac_cv_sizeof_char -EOF +_ACEOF + + +echo "$as_me:$LINENO: checking for short" >&5 +echo $ECHO_N "checking for short... $ECHO_C" >&6 +if test "${ac_cv_type_short+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((short *) 0) + return 0; +if (sizeof (short)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_short=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_short=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 +echo "${ECHO_T}$ac_cv_type_short" >&6 + +echo "$as_me:$LINENO: checking size of short" >&5 +echo $ECHO_N "checking size of short... $ECHO_C" >&6 +if test "${ac_cv_sizeof_short+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_short" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) < 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; +test_array [0] = 0 -echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:2353: checking size of short" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_short=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac else if test "$cross_compiling" = yes; then - ac_cv_sizeof_short=2 -else - cat > conftest.$ac_ext <<EOF -#line 2361 "configure" -#include "confdefs.h" + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (short)); } +unsigned long ulongval () { return (long) (sizeof (short)); } #include <stdio.h> -main() +#include <stdlib.h> +int +main () { - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(short)); - exit(0); + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (short))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (short)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (short)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; } -EOF -if { (eval echo configure:2372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_short=`cat conftestval` +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_short=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* ac_cv_sizeof_short=0 fi -rm -fr conftest* -fi - fi -echo "$ac_t""$ac_cv_sizeof_short" 1>&6 -cat >> confdefs.h <<EOF +echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 +echo "${ECHO_T}$ac_cv_sizeof_short" >&6 +cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short -EOF +_ACEOF + + +echo "$as_me:$LINENO: checking for int" >&5 +echo $ECHO_N "checking for int... $ECHO_C" >&6 +if test "${ac_cv_type_int+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((int *) 0) + return 0; +if (sizeof (int)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_int=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_int=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 +echo "${ECHO_T}$ac_cv_type_int" >&6 + +echo "$as_me:$LINENO: checking size of int" >&5 +echo $ECHO_N "checking size of int... $ECHO_C" >&6 +if test "${ac_cv_sizeof_int+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_int" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 -echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:2392: checking size of int" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done else - if test "$cross_compiling" = yes; then - ac_cv_sizeof_int=4 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done else - cat > conftest.$ac_ext <<EOF -#line 2400 "configure" -#include "confdefs.h" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_int=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (int)); } +unsigned long ulongval () { return (long) (sizeof (int)); } #include <stdio.h> -main() +#include <stdlib.h> +int +main () { - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(int)); - exit(0); + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (int))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (int)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (int)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; } -EOF -if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_int=`cat conftestval` +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_int=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* ac_cv_sizeof_int=0 fi -rm -fr conftest* -fi - fi -echo "$ac_t""$ac_cv_sizeof_int" 1>&6 -cat >> confdefs.h <<EOF +echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 +echo "${ECHO_T}$ac_cv_sizeof_int" >&6 +cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int -EOF +_ACEOF + + +echo "$as_me:$LINENO: checking for long" >&5 +echo $ECHO_N "checking for long... $ECHO_C" >&6 +if test "${ac_cv_type_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long *) 0) + return 0; +if (sizeof (long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 +echo "${ECHO_T}$ac_cv_type_long" >&6 + +echo "$as_me:$LINENO: checking size of long" >&5 +echo $ECHO_N "checking size of long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_long" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 -echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:2431: checking size of long" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done else - if test "$cross_compiling" = yes; then - ac_cv_sizeof_long=4 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac else - cat > conftest.$ac_ext <<EOF -#line 2439 "configure" -#include "confdefs.h" + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (long)); } +unsigned long ulongval () { return (long) (sizeof (long)); } #include <stdio.h> -main() +#include <stdlib.h> +int +main () { - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d\n", sizeof(long)); - exit(0); + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; } -EOF -if { (eval echo configure:2450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - ac_cv_sizeof_long=`cat conftestval` +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* ac_cv_sizeof_long=0 fi -rm -fr conftest* -fi - fi -echo "$ac_t""$ac_cv_sizeof_long" 1>&6 -cat >> confdefs.h <<EOF +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long" >&6 +cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long -EOF +_ACEOF - echo $ac_n "checking for addrinfo""... $ac_c" 1>&6 -echo "configure:2473: checking for addrinfo" >&5 - if eval "test \"`echo '$''{'ac_cv_addrinfo'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + 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 + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2478 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <netdb.h> -int main() { +int +main () +{ struct addrinfo a -; return 0; } -EOF -if { (eval echo configure:2486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_addrinfo=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_addrinfo=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_addrinfo=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_addrinfo" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_addrinfo" >&5 +echo "${ECHO_T}$ac_cv_addrinfo" >&6 if test $ac_cv_addrinfo = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_ADDRINFO 1 -EOF +_ACEOF else - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define NEED_ADDRINFO_H 1 -EOF +_ACEOF fi @@ -2512,36 +5897,39 @@ if test "$ac_cv_addrinfo" = no; then fi - echo $ac_n "checking for NI_MAXSERV""... $ac_c" 1>&6 -echo "configure:2517: checking for NI_MAXSERV" >&5 - if eval "test \"`echo '$''{'ac_cv_maxserv'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for NI_MAXSERV" >&5 +echo $ECHO_N "checking for NI_MAXSERV... $ECHO_C" >&6 + if test "${ac_cv_maxserv+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2522 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <netdb.h> #ifdef NI_MAXSERV yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ac_cv_maxserv=yes else - rm -rf conftest* ac_cv_maxserv=no fi rm -f conftest* fi - echo "$ac_t""$ac_cv_maxserv" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_maxserv" >&5 +echo "${ECHO_T}$ac_cv_maxserv" >&6 if test $ac_cv_maxserv != yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define NEED_ADDRINFO_H 1 -EOF +_ACEOF fi @@ -2550,36 +5938,39 @@ if test "$ac_cv_maxserv" = no; then fi - echo $ac_n "checking for NI_NAMEREQD""... $ac_c" 1>&6 -echo "configure:2555: checking for NI_NAMEREQD" >&5 - if eval "test \"`echo '$''{'ac_cv_namereqd'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for NI_NAMEREQD" >&5 +echo $ECHO_N "checking for NI_NAMEREQD... $ECHO_C" >&6 + if test "${ac_cv_namereqd+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2560 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <netdb.h> #ifdef NI_NOFQDN yes #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "yes" >/dev/null 2>&1; then ac_cv_namereqd=yes else - rm -rf conftest* ac_cv_namereqd=no fi rm -f conftest* fi - echo "$ac_t""$ac_cv_namereqd" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_namereqd" >&5 +echo "${ECHO_T}$ac_cv_namereqd" >&6 if test $ac_cv_namereqd != yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define NEED_ADDRINFO_H 1 -EOF +_ACEOF fi @@ -2588,38 +5979,57 @@ if test "$ac_cv_namereqd" = no; then fi - echo $ac_n "checking for sockaddr_storage""... $ac_c" 1>&6 -echo "configure:2593: checking for sockaddr_storage" >&5 - if eval "test \"`echo '$''{'ac_cv_sa_storage'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for sockaddr_storage" >&5 +echo $ECHO_N "checking for sockaddr_storage... $ECHO_C" >&6 + if test "${ac_cv_sa_storage+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2598 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <sys/types.h> # include <sys/socket.h> -int main() { +int +main () +{ struct sockaddr_storage s -; return 0; } -EOF -if { (eval echo configure:2607: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_sa_storage=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_sa_storage=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_sa_storage=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_sa_storage" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_sa_storage" >&5 +echo "${ECHO_T}$ac_cv_sa_storage" >&6 if test $ac_cv_sa_storage = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_SOCKADDR_STORAGE 1 -EOF +_ACEOF fi @@ -2629,72 +6039,110 @@ fi ac_cv_addrsz=yes - echo $ac_n "checking for INADDRSZ""... $ac_c" 1>&6 -echo "configure:2634: checking for INADDRSZ" >&5 - if eval "test \"`echo '$''{'ac_cv_inaddrsz'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2639 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking for INADDRSZ" >&5 +echo $ECHO_N "checking for INADDRSZ... $ECHO_C" >&6 + if test "${ac_cv_inaddrsz+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <arpa/nameser.h> -int main() { +int +main () +{ int a = INADDRSZ -; return 0; } -EOF -if { (eval echo configure:2647: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_inaddrsz=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_inaddrsz=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_inaddrsz=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_inaddrsz" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_inaddrsz" >&5 +echo "${ECHO_T}$ac_cv_inaddrsz" >&6 if test $ac_cv_inaddrsz = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_INADDRSZ 1 -EOF +_ACEOF else ac_cv_addrsz=no fi - echo $ac_n "checking for IN6ADDRSZ""... $ac_c" 1>&6 -echo "configure:2669: checking for IN6ADDRSZ" >&5 - if eval "test \"`echo '$''{'ac_cv_in6addrsz'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2674 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking for IN6ADDRSZ" >&5 +echo $ECHO_N "checking for IN6ADDRSZ... $ECHO_C" >&6 + if test "${ac_cv_in6addrsz+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <arpa/nameser.h> -int main() { +int +main () +{ int a = IN6ADDRSZ -; return 0; } -EOF -if { (eval echo configure:2682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_in6addrsz=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_in6addrsz=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_in6addrsz=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_in6addrsz" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_in6addrsz" >&5 +echo "${ECHO_T}$ac_cv_in6addrsz" >&6 if test $ac_cv_in6addrsz = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_IN6ADDRSZ 1 -EOF +_ACEOF else ac_cv_addrsz=no @@ -2705,39 +6153,58 @@ if test "$ac_cv_addrsz" = no; then fi - echo $ac_n "checking for RES_USE_INET6""... $ac_c" 1>&6 -echo "configure:2710: checking for RES_USE_INET6" >&5 - if eval "test \"`echo '$''{'ac_cv_res_inet6'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for RES_USE_INET6" >&5 +echo $ECHO_N "checking for RES_USE_INET6... $ECHO_C" >&6 + if test "${ac_cv_res_inet6+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2715 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <sys/types.h> # include <netinet/in.h> # include <resolv.h> -int main() { +int +main () +{ int a = RES_USE_INET6 -; return 0; } -EOF -if { (eval echo configure:2725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_res_inet6=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_res_inet6=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_res_inet6=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_res_inet6" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_res_inet6" >&5 +echo "${ECHO_T}$ac_cv_res_inet6" >&6 if test $ac_cv_res_inet6 = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_RES_USE_INET6 1 -EOF +_ACEOF fi @@ -2746,40 +6213,59 @@ if test "$ac_cv_res_inet6" = no; then fi - echo $ac_n "checking for res_state_ext""... $ac_c" 1>&6 -echo "configure:2751: checking for res_state_ext" >&5 - if eval "test \"`echo '$''{'ac_cv_res_state_ext'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for res_state_ext" >&5 +echo $ECHO_N "checking for res_state_ext... $ECHO_C" >&6 + if test "${ac_cv_res_state_ext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2756 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <sys/types.h> # include <netinet/in.h> # include <netinet6/in6.h> # include <resolv.h> -int main() { +int +main () +{ struct __res_state_ext e -; return 0; } -EOF -if { (eval echo configure:2767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_res_state_ext=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_res_state_ext=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_res_state_ext=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_res_state_ext" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_res_state_ext" >&5 +echo "${ECHO_T}$ac_cv_res_state_ext" >&6 if test $ac_cv_res_state_ext = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_RES_STATE_EXT 1 -EOF +_ACEOF fi @@ -2788,40 +6274,59 @@ if test "$ac_cv_res_state_ext" = no; then fi - echo $ac_n "checking for nsort in res_state""... $ac_c" 1>&6 -echo "configure:2793: checking for nsort in res_state" >&5 - if eval "test \"`echo '$''{'ac_cv_res_state'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for nsort in res_state" >&5 +echo $ECHO_N "checking for nsort in res_state... $ECHO_C" >&6 + if test "${ac_cv_res_state+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2798 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <sys/types.h> # include <netinet/in.h> # include <netinet6/in6.h> # include <resolv.h> -int main() { +int +main () +{ struct __res_state e; e.nsort = 0 -; return 0; } -EOF -if { (eval echo configure:2809: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_res_state=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_res_state=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_res_state=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_res_state" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_res_state" >&5 +echo "${ECHO_T}$ac_cv_res_state" >&6 if test $ac_cv_res_state = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_NEW_RES_STATE 1 -EOF +_ACEOF fi @@ -2832,125 +6337,279 @@ if test "$missing_includes" = "yes"; then fi -for ac_func in vfprintf strcasecmp strlcat strlcpy strdup + + + + + + +for ac_func in vfprintf strcasecmp strlcat strlcpy strdup strsep do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2839: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2844 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + LIBOBJS="$LIBOBJS $ac_func.$ac_objext" +fi +done + -int main() { +for ac_func in strftime +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done for ac_func in ether_ntohost do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2896: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 2901 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + + echo "$as_me:$LINENO: checking for buggy ether_ntohost" >&5 +echo $ECHO_N "checking for buggy ether_ntohost... $ECHO_C" >&6 +if test "${ac_cv_buggy_ether_ntohost+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - - echo $ac_n "checking for buggy ether_ntohost""... $ac_c" 1>&6 -echo "configure:2944: checking for buggy ether_ntohost" >&5 -if eval "test \"`echo '$''{'ac_cv_buggy_ether_ntohost'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - ac_cv_buggy_ether_ntohost=not while cross-compiling + ac_cv_buggy_ether_ntohost="not while cross-compiling" else - cat > conftest.$ac_ext <<EOF -#line 2953 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <netdb.h> #include <sys/types.h> @@ -2966,165 +6625,237 @@ else ether_ntohost(name, (struct ether_addr *)ea); exit(0); } - -EOF -if { (eval echo configure:2972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_buggy_ether_ntohost=no else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_buggy_ether_ntohost=yes + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_buggy_ether_ntohost=yes fi -rm -fr conftest* +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi - -echo "$ac_t""$ac_cv_buggy_ether_ntohost" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_buggy_ether_ntohost" >&5 +echo "${ECHO_T}$ac_cv_buggy_ether_ntohost" >&6 if test "$ac_cv_buggy_ether_ntohost" = "no"; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define USE_ETHER_NTOHOST 1 -EOF +_ACEOF fi -else - echo "$ac_t""no" 1>&6 fi done + for ac_func in setlinebuf do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3002: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3007 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:3030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 fi done needsnprintf=no + + for ac_func in vsnprintf snprintf do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3059: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3064 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:3087: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 -needsnprintf=yes +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + needsnprintf=yes fi done if test $needsnprintf = yes; then - LIBOBJS="$LIBOBJS snprintf.o" + LIBOBJS="$LIBOBJS snprintf.o.$ac_objext" fi - echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:3118: checking return type of signal handlers" >&5 -if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 3123 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <sys/types.h> #include <signal.h> #ifdef signal -#undef signal +# undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); @@ -3132,157 +6863,230 @@ extern "C" void (*signal (int, void (*)(int)))(int); void (*signal ()) (); #endif -int main() { +int +main () +{ int i; -; return 0; } -EOF -if { (eval echo configure:3140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_type_signal=void else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_type_signal=int + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_signal=int fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6 -echo "$ac_t""$ac_cv_type_signal" 1>&6 -cat >> confdefs.h <<EOF +cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal -EOF +_ACEOF if test "$ac_cv_type_signal" = void ; then - cat >> confdefs.h <<\EOF -#define RETSIGVAL -EOF + cat >>confdefs.h <<\_ACEOF +#define RETSIGVAL +_ACEOF else - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define RETSIGVAL (0) -EOF +_ACEOF fi case "$host_os" in irix*) - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define _BSD_SIGNALS 1 -EOF +_ACEOF ;; *) - for ac_func in sigset + +for ac_func in sigaction do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3182: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3187 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:3210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 fi done - if test $ac_cv_func_sigset = no ; then - for ac_func in sigaction + if test $ac_cv_func_sigaction = no ; then + +for ac_func in sigset do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3238: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3243 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:3266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 fi done @@ -3290,509 +7094,830 @@ done ;; esac -echo $ac_n "checking for dnet_htoa in -ldnet""... $ac_c" 1>&6 -echo "configure:3295: checking for dnet_htoa in -ldnet" >&5 -ac_lib_var=`echo dnet'_'dnet_htoa | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldnet $LIBS" -cat > conftest.$ac_ext <<EOF -#line 3303 "configure" -#include "confdefs.h" +echo "$as_me:$LINENO: checking for library containing dnet_htoa" >&5 +echo $ECHO_N "checking for library containing dnet_htoa... $ECHO_C" >&6 +if test "${ac_cv_search_dnet_htoa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_dnet_htoa=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dnet_htoa(); + builtin and then its argument prototype would still apply. */ +char dnet_htoa (); +int +main () +{ +dnet_htoa (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_dnet_htoa="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_dnet_htoa" = no; then + for ac_lib in dnet; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -int main() { -dnet_htoa() -; return 0; } -EOF -if { (eval echo configure:3314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dnet_htoa (); +int +main () +{ +dnet_htoa (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_dnet_htoa="-l$ac_lib" +break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo dnet | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <<EOF -#define $ac_tr_lib 1 -EOF - - LIBS="-ldnet $LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_dnet_htoa" >&5 +echo "${ECHO_T}$ac_cv_search_dnet_htoa" >&6 +if test "$ac_cv_search_dnet_htoa" != no; then + test "$ac_cv_search_dnet_htoa" = "none required" || LIBS="$ac_cv_search_dnet_htoa $LIBS" + cat >>confdefs.h <<\_ACEOF +#define HAVE_DNET_HTOA 1 +_ACEOF -else - echo "$ac_t""no" 1>&6 fi -echo $ac_n "checking for main in -lrpc""... $ac_c" 1>&6 -echo "configure:3343: checking for main in -lrpc" >&5 -ac_lib_var=`echo rpc'_'main | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + +echo "$as_me:$LINENO: checking for main in -lrpc" >&5 +echo $ECHO_N "checking for main in -lrpc... $ECHO_C" >&6 +if test "${ac_cv_lib_rpc_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-lrpc $LIBS" -cat > conftest.$ac_ext <<EOF -#line 3351 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -int main() { -main() -; return 0; } -EOF -if { (eval echo configure:3358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo rpc | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <<EOF -#define $ac_tr_lib 1 -EOF +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_rpc_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_rpc_main=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_rpc_main" >&5 +echo "${ECHO_T}$ac_cv_lib_rpc_main" >&6 +if test $ac_cv_lib_rpc_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBRPC 1 +_ACEOF LIBS="-lrpc $LIBS" -else - echo "$ac_t""no" 1>&6 fi - -echo $ac_n "checking for library containing getrpcbynumber""... $ac_c" 1>&6 -echo "configure:3387: checking for library containing getrpcbynumber" >&5 -if eval "test \"`echo '$''{'ac_cv_search_getrpcbynumber'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for library containing getrpcbynumber" >&5 +echo $ECHO_N "checking for library containing getrpcbynumber... $ECHO_C" >&6 +if test "${ac_cv_search_getrpcbynumber+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_func_search_save_LIBS="$LIBS" -ac_cv_search_getrpcbynumber="no" -cat > conftest.$ac_ext <<EOF -#line 3394 "configure" -#include "confdefs.h" + ac_func_search_save_LIBS=$LIBS +ac_cv_search_getrpcbynumber=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char getrpcbynumber(); - -int main() { -getrpcbynumber() -; return 0; } -EOF -if { (eval echo configure:3405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + builtin and then its argument prototype would still apply. */ +char getrpcbynumber (); +int +main () +{ +getrpcbynumber (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_search_getrpcbynumber="none required" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -test "$ac_cv_search_getrpcbynumber" = "no" && for i in nsl; do -LIBS="-l$i $ac_func_search_save_LIBS" -cat > conftest.$ac_ext <<EOF -#line 3416 "configure" -#include "confdefs.h" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_getrpcbynumber" = no; then + for ac_lib in nsl; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char getrpcbynumber(); - -int main() { -getrpcbynumber() -; return 0; } -EOF -if { (eval echo configure:3427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_cv_search_getrpcbynumber="-l$i" + builtin and then its argument prototype would still apply. */ +char getrpcbynumber (); +int +main () +{ +getrpcbynumber (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_getrpcbynumber="-l$ac_lib" break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -done -LIBS="$ac_func_search_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done fi - -echo "$ac_t""$ac_cv_search_getrpcbynumber" 1>&6 -if test "$ac_cv_search_getrpcbynumber" != "no"; then +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_getrpcbynumber" >&5 +echo "${ECHO_T}$ac_cv_search_getrpcbynumber" >&6 +if test "$ac_cv_search_getrpcbynumber" != no; then test "$ac_cv_search_getrpcbynumber" = "none required" || LIBS="$ac_cv_search_getrpcbynumber $LIBS" - -else : - + fi + # Most operating systems have gethostbyname() in the default searched # libraries (i.e. libc): # Some OSes (eg. Solaris) place it in libnsl # Some strange OSes (SINIX) have it in libsocket: - -echo $ac_n "checking for library containing gethostbyname""... $ac_c" 1>&6 -echo "configure:3456: checking for library containing gethostbyname" >&5 -if eval "test \"`echo '$''{'ac_cv_search_gethostbyname'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_func_search_save_LIBS="$LIBS" -ac_cv_search_gethostbyname="no" -cat > conftest.$ac_ext <<EOF -#line 3463 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5 +echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6 +if test "${ac_cv_search_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_gethostbyname=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gethostbyname(); - -int main() { -gethostbyname() -; return 0; } -EOF -if { (eval echo configure:3474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + builtin and then its argument prototype would still apply. */ +char gethostbyname (); +int +main () +{ +gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_search_gethostbyname="none required" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -test "$ac_cv_search_gethostbyname" = "no" && for i in nsl socket resolv; do -LIBS="-l$i $ac_func_search_save_LIBS" -cat > conftest.$ac_ext <<EOF -#line 3485 "configure" -#include "confdefs.h" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_gethostbyname" = no; then + for ac_lib in nsl socket resolv; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gethostbyname(); - -int main() { -gethostbyname() -; return 0; } -EOF -if { (eval echo configure:3496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_cv_search_gethostbyname="-l$i" + builtin and then its argument prototype would still apply. */ +char gethostbyname (); +int +main () +{ +gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_gethostbyname="-l$ac_lib" break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -done -LIBS="$ac_func_search_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done fi - -echo "$ac_t""$ac_cv_search_gethostbyname" 1>&6 -if test "$ac_cv_search_gethostbyname" != "no"; then +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_search_gethostbyname" >&6 +if test "$ac_cv_search_gethostbyname" != no; then test "$ac_cv_search_gethostbyname" = "none required" || LIBS="$ac_cv_search_gethostbyname $LIBS" - -else : - + fi + # Unfortunately libsocket sometimes depends on libnsl and # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. if test "$ac_cv_search_gethostbyname" = "no" then - echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6 -echo "configure:3521: checking for gethostbyname in -lsocket" >&5 -ac_lib_var=`echo socket'_'gethostbyname | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for gethostbyname in -lsocket" >&5 +echo $ECHO_N "checking for gethostbyname in -lsocket... $ECHO_C" >&6 +if test "${ac_cv_lib_socket_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket -lnsl $LIBS" -cat > conftest.$ac_ext <<EOF -#line 3529 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gethostbyname(); - -int main() { -gethostbyname() -; return 0; } -EOF -if { (eval echo configure:3540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 + builtin and then its argument prototype would still apply. */ +char gethostbyname (); +int +main () +{ +gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_socket_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_socket_gethostbyname=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_socket_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_lib_socket_gethostbyname" >&6 +if test $ac_cv_lib_socket_gethostbyname = yes; then LIBS="-lsocket -lnsl $LIBS" -else - echo "$ac_t""no" 1>&6 fi fi - -echo $ac_n "checking for library containing socket""... $ac_c" 1>&6 -echo "configure:3563: checking for library containing socket" >&5 -if eval "test \"`echo '$''{'ac_cv_search_socket'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_func_search_save_LIBS="$LIBS" -ac_cv_search_socket="no" -cat > conftest.$ac_ext <<EOF -#line 3570 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking for library containing socket" >&5 +echo $ECHO_N "checking for library containing socket... $ECHO_C" >&6 +if test "${ac_cv_search_socket+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_socket=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char socket(); - -int main() { -socket() -; return 0; } -EOF -if { (eval echo configure:3581: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + builtin and then its argument prototype would still apply. */ +char socket (); +int +main () +{ +socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_search_socket="none required" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -test "$ac_cv_search_socket" = "no" && for i in socket; do -LIBS="-l$i $ac_func_search_save_LIBS" -cat > conftest.$ac_ext <<EOF -#line 3592 "configure" -#include "confdefs.h" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_socket" = no; then + for ac_lib in socket; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char socket(); - -int main() { -socket() -; return 0; } -EOF -if { (eval echo configure:3603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_cv_search_socket="-l$i" + builtin and then its argument prototype would still apply. */ +char socket (); +int +main () +{ +socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_socket="-l$ac_lib" break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -done -LIBS="$ac_func_search_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done fi - -echo "$ac_t""$ac_cv_search_socket" 1>&6 -if test "$ac_cv_search_socket" != "no"; then +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_socket" >&5 +echo "${ECHO_T}$ac_cv_search_socket" >&6 +if test "$ac_cv_search_socket" != no; then test "$ac_cv_search_socket" = "none required" || LIBS="$ac_cv_search_socket $LIBS" - -else : - echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:3622: checking for socket in -lsocket" >&5 -ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsocket -lnsl $LIBS" -cat > conftest.$ac_ext <<EOF -#line 3630 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char socket(); -int main() { -socket() -; return 0; } -EOF -if { (eval echo configure:3641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" + echo "$as_me:$LINENO: checking for socket in -lsocket" >&5 +echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6 +if test "${ac_cv_lib_socket_socket+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket -lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char socket (); +int +main () +{ +socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_socket_socket=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_socket_socket=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5 +echo "${ECHO_T}$ac_cv_lib_socket_socket" >&6 +if test $ac_cv_lib_socket_socket = yes; then LIBS="-lsocket -lnsl $LIBS" -else - echo "$ac_t""no" 1>&6 fi fi + # DLPI needs putmsg under HPUX so test for -lstr while we're at it - -echo $ac_n "checking for library containing putmsg""... $ac_c" 1>&6 -echo "configure:3665: checking for library containing putmsg" >&5 -if eval "test \"`echo '$''{'ac_cv_search_putmsg'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_func_search_save_LIBS="$LIBS" -ac_cv_search_putmsg="no" -cat > conftest.$ac_ext <<EOF -#line 3672 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking for library containing putmsg" >&5 +echo $ECHO_N "checking for library containing putmsg... $ECHO_C" >&6 +if test "${ac_cv_search_putmsg+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_putmsg=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char putmsg(); - -int main() { -putmsg() -; return 0; } -EOF -if { (eval echo configure:3683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + builtin and then its argument prototype would still apply. */ +char putmsg (); +int +main () +{ +putmsg (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_search_putmsg="none required" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -test "$ac_cv_search_putmsg" = "no" && for i in str; do -LIBS="-l$i $ac_func_search_save_LIBS" -cat > conftest.$ac_ext <<EOF -#line 3694 "configure" -#include "confdefs.h" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_putmsg" = no; then + for ac_lib in str; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char putmsg(); - -int main() { -putmsg() -; return 0; } -EOF -if { (eval echo configure:3705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - ac_cv_search_putmsg="-l$i" + builtin and then its argument prototype would still apply. */ +char putmsg (); +int +main () +{ +putmsg (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_putmsg="-l$ac_lib" break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* -done -LIBS="$ac_func_search_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done fi - -echo "$ac_t""$ac_cv_search_putmsg" 1>&6 -if test "$ac_cv_search_putmsg" != "no"; then +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_putmsg" >&5 +echo "${ECHO_T}$ac_cv_search_putmsg" >&6 +if test "$ac_cv_search_putmsg" != no; then test "$ac_cv_search_putmsg" = "none required" || LIBS="$ac_cv_search_putmsg $LIBS" - -else : - + fi - + + LBL_LIBS="$LIBS" pfopen=/usr/examples/packetfilter/pfopen.c if test -f $pfopen ; then - for ac_func in pfopen + +for ac_func in pfopen do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3733: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3738 "configure" -#include "confdefs.h" +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:3761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - -else - echo "$ac_t""no" 1>&6 fi done if test $ac_cv_func_pfopen = "no" ; then - echo "$ac_t""Using $pfopen" 1>&6 + echo "$as_me:$LINENO: result: Using $pfopen" >&5 +echo "${ECHO_T}Using $pfopen" >&6 LIBS="$LIBS $pfopen" fi fi - echo $ac_n "checking for local pcap library""... $ac_c" 1>&6 -echo "configure:3791: checking for local pcap library" >&5 + echo "$as_me:$LINENO: checking for local pcap library" >&5 +echo $ECHO_N "checking for local pcap library... $ECHO_C" >&6 libpcap=FAIL lastdir=FAIL - places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \ + places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'` - for dir in $places ../libpcap libpcap ; do + for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do basedir=`echo $dir | sed -e 's/[ab][0-9]*$//'` if test $lastdir = $basedir ; then continue; @@ -3804,45 +7929,82 @@ echo "configure:3791: checking for local pcap library" >&5 fi done if test $libpcap = FAIL ; then - echo "$ac_t""not found" 1>&6 - echo $ac_n "checking for main in -lpcap""... $ac_c" 1>&6 -echo "configure:3810: checking for main in -lpcap" >&5 -ac_lib_var=`echo pcap'_'main | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" + echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6 + 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 +else + ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" -cat > conftest.$ac_ext <<EOF -#line 3818 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -int main() { -main() -; return 0; } -EOF -if { (eval echo configure:3825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_pcap_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_pcap_main=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_pcap_main" >&5 +echo "${ECHO_T}$ac_cv_lib_pcap_main" >&6 +if test $ac_cv_lib_pcap_main = yes; then libpcap="-lpcap" -else - echo "$ac_t""no" 1>&6 fi if test $libpcap = FAIL ; then - { echo "configure: error: see the INSTALL doc for more info" 1>&2; exit 1; } + { { 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 +echo $ECHO_N "checking for extraneous pcap header directories... $ECHO_C" >&6 + 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" + fi + fi + 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 +echo "${ECHO_T}found -- -I$d added" >&6 fi else V_PCAPDEP=$libpcap @@ -3853,81 +8015,1061 @@ fi elif test -r $places/pcap.h; then V_INCLS="-I$places $V_INCLS" else - { echo "configure: error: cannot find pcap.h" 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: cannot find pcap.h" >&5 +echo "$as_me: error: cannot find pcap.h" >&2;} + { (exit see INSTALL); exit see INSTALL; }; } fi - echo "$ac_t""$libpcap" 1>&6 + echo "$as_me:$LINENO: result: $libpcap" >&5 +echo "${ECHO_T}$libpcap" >&6 fi LIBS="$libpcap $LIBS" case "$host_os" in aix*) pseexe="/lib/pse.exp" - echo $ac_n "checking for $pseexe""... $ac_c" 1>&6 -echo "configure:3867: checking for $pseexe" >&5 + echo "$as_me:$LINENO: checking for $pseexe" >&5 +echo $ECHO_N "checking for $pseexe... $ECHO_C" >&6 if test -f $pseexe ; then - echo "$ac_t""yes" 1>&6 + echo "$as_me:$LINENO: result: yes" >&5 +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. + # + LIBS="$LIBS -lodm -lcfg" ;; esac -for ac_func in bpf_dump -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3878: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3883 "configure" -#include "confdefs.h" + echo "$as_me:$LINENO: checking for pcap_list_datalinks" >&5 +echo $ECHO_N "checking for pcap_list_datalinks... $ECHO_C" >&6 +if test "${ac_cv_func_pcap_list_datalinks+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include <assert.h> + which can conflict with char pcap_list_datalinks (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); + builtin and then its argument prototype would still apply. */ +char pcap_list_datalinks (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_pcap_list_datalinks) || defined (__stub___pcap_list_datalinks) +choke me +#else +char (*f) () = pcap_list_datalinks; +#endif +#ifdef __cplusplus +} +#endif -int main() { +int +main () +{ +return f != pcap_list_datalinks; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_pcap_list_datalinks=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_pcap_list_datalinks=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_pcap_list_datalinks" >&5 +echo "${ECHO_T}$ac_cv_func_pcap_list_datalinks" >&6 +if test $ac_cv_func_pcap_list_datalinks = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_LIST_DATALINKS 1 +_ACEOF + +else + LIBOBJS="$LIBOBJS datalinks.$ac_objext" +fi + + echo "$as_me:$LINENO: checking for pcap_set_datalink" >&5 +echo $ECHO_N "checking for pcap_set_datalink... $ECHO_C" >&6 +if test "${ac_cv_func_pcap_set_datalink+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char pcap_set_datalink (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcap_set_datalink (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_pcap_set_datalink) || defined (__stub___pcap_set_datalink) +choke me +#else +char (*f) () = pcap_set_datalink; +#endif +#ifdef __cplusplus +} +#endif +int +main () +{ +return f != pcap_set_datalink; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_pcap_set_datalink=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_pcap_set_datalink=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_pcap_set_datalink" >&5 +echo "${ECHO_T}$ac_cv_func_pcap_set_datalink" >&6 +if test $ac_cv_func_pcap_set_datalink = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_SET_DATALINK 1 +_ACEOF + +fi + + echo "$as_me:$LINENO: checking for pcap_datalink_name_to_val" >&5 +echo $ECHO_N "checking for pcap_datalink_name_to_val... $ECHO_C" >&6 +if test "${ac_cv_func_pcap_datalink_name_to_val+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char pcap_datalink_name_to_val (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcap_datalink_name_to_val (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_pcap_datalink_name_to_val) || defined (__stub___pcap_datalink_name_to_val) +choke me +#else +char (*f) () = pcap_datalink_name_to_val; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != pcap_datalink_name_to_val; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_pcap_datalink_name_to_val=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_pcap_datalink_name_to_val=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_pcap_datalink_name_to_val" >&5 +echo "${ECHO_T}$ac_cv_func_pcap_datalink_name_to_val" >&6 +if test $ac_cv_func_pcap_datalink_name_to_val = yes; then + + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1 +_ACEOF + + echo "$as_me:$LINENO: checking for pcap_datalink_val_to_description" >&5 +echo $ECHO_N "checking for pcap_datalink_val_to_description... $ECHO_C" >&6 +if test "${ac_cv_func_pcap_datalink_val_to_description+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char pcap_datalink_val_to_description (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcap_datalink_val_to_description (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_pcap_datalink_val_to_description) || defined (__stub___pcap_datalink_val_to_description) +choke me +#else +char (*f) () = pcap_datalink_val_to_description; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != pcap_datalink_val_to_description; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_pcap_datalink_val_to_description=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_pcap_datalink_val_to_description=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_pcap_datalink_val_to_description" >&5 +echo "${ECHO_T}$ac_cv_func_pcap_datalink_val_to_description" >&6 +if test $ac_cv_func_pcap_datalink_val_to_description = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1 +_ACEOF + +else + LIBOBJS="$LIBOBJS dlnames.$ac_objext" +fi + + +else + LIBOBJS="$LIBOBJS dlnames.$ac_objext" +fi + + + +for ac_func in pcap_breakloop +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:3906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +# +# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate +# libraries (e.g., "-lsocket -lnsl" on Solaris). +# +# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which +# use AC_CHECK_FUNC which doesn't let us specify the right #includes +# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8 +# resolver, and the way it defines inet_{ntop,pton} is rather strange; +# it does not ship with a libc symbol "inet_ntop()", it ships with +# "_inet_ntop()", and has a #define macro in one of the system headers +# to rename it. +# +echo "$as_me:$LINENO: checking for inet_ntop" >&5 +echo $ECHO_N "checking for inet_ntop... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +int +main () +{ +char src[4], dst[128]; +inet_ntop(AF_INET, src, dst, sizeof(dst)); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + LIBOBJS="$LIBOBJS inet_ntop.o.$ac_objext" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +echo "$as_me:$LINENO: checking for inet_pton" >&5 +echo $ECHO_N "checking for inet_pton... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +int +main () +{ +char src[128], dst[4]; +inet_pton(AF_INET, src, dst); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + LIBOBJS="$LIBOBJS inet_pton.o.$ac_objext" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +echo "$as_me:$LINENO: checking for inet_aton" >&5 +echo $ECHO_N "checking for inet_aton... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> +int +main () +{ +char src[128]; +struct in_addr dst; +inet_aton(src, &dst); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + LIBOBJS="$LIBOBJS inet_aton.o.$ac_objext" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + + + 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 + if test "${ac_cv_sockaddr_has_sa_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# include <sys/types.h> +# include <sys/socket.h> +int +main () +{ +u_int i = sizeof(((struct sockaddr *)0)->sa_len) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sockaddr_has_sa_len=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_sockaddr_has_sa_len=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 -EOF - + echo "$as_me:$LINENO: result: $ac_cv_sockaddr_has_sa_len" >&5 +echo "${ECHO_T}$ac_cv_sockaddr_has_sa_len" >&6 + if test $ac_cv_sockaddr_has_sa_len = yes ; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_SOCKADDR_SA_LEN 1 +_ACEOF + + fi + +if test "$ac_cv_sockaddr_has_sa_len" = no; then + missing_includes=yes +fi + + + + +for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +if test $ac_cv_func_pcap_findalldevs = "yes" ; then + echo "$as_me:$LINENO: checking for pcap_if_t" >&5 +echo $ECHO_N "checking for pcap_if_t... $ECHO_C" >&6 +if test "${ac_cv_type_pcap_if_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <pcap.h> + +int +main () +{ +if ((pcap_if_t *) 0) + return 0; +if (sizeof (pcap_if_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_pcap_if_t=yes else - echo "$ac_t""no" 1>&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_pcap_if_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_pcap_if_t" >&5 +echo "${ECHO_T}$ac_cv_type_pcap_if_t" >&6 +if test $ac_cv_type_pcap_if_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_PCAP_IF_T 1 +_ACEOF + + +fi + +fi +if test $ac_cv_func_pcap_lib_version = "no" ; then + echo "$as_me:$LINENO: checking whether pcap_version is defined by libpcap" >&5 +echo $ECHO_N "checking whether pcap_version is defined by libpcap... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + +char * +return_pcap_version(void) +{ + extern char pcap_version[]; + + return pcap_version; +} + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lbl_cv_pcap_version_defined=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lbl_cv_pcap_version_defined=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + if test "$ac_lbl_cv_pcap_version_defined" = yes ; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_VERSION 1 +_ACEOF + + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi +fi +echo "$as_me:$LINENO: checking whether pcap_debug is defined by libpcap" >&5 +echo $ECHO_N "checking whether pcap_debug is defined by libpcap... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + +int +return_pcap_debug(void) +{ + extern int pcap_debug; + + return pcap_debug; +} + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lbl_cv_pcap_debug_defined=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lbl_cv_pcap_debug_defined=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_DEBUG 1 +_ACEOF + +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + # + # OK, what about "yydebug"? + # + echo "$as_me:$LINENO: checking whether yydebug is defined by libpcap" >&5 +echo $ECHO_N "checking whether yydebug is defined by libpcap... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + int + return_yydebug(void) + { + extern int yydebug; + + return yydebug; + } + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lbl_cv_yydebug_defined=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lbl_cv_yydebug_defined=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + if test "$ac_lbl_cv_yydebug_defined" = yes ; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + cat >>confdefs.h <<\_ACEOF +#define HAVE_YYDEBUG 1 +_ACEOF + + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi +fi + +for ac_func in bpf_dump +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + LIBOBJS="$LIBOBJS $ac_func.$ac_objext" fi done - + V_GROUP=0 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then V_GROUP=wheel @@ -3935,9 +9077,9 @@ fi case "$host_os" in aix*) - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define _SUN 1 -EOF +_ACEOF ;; @@ -3958,14 +9100,75 @@ if test -f /dev/bpf0 ; then V_GROUP=bpf fi -echo $ac_n "checking for u_int8_t using $CC""... $ac_c" 1>&6 -echo "configure:3963: checking for u_int8_t using $CC" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int8_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for int8_t using $CC" >&5 +echo $ECHO_N "checking for int8_t using $CC... $ECHO_C" >&6 + if test "${ac_cv_lbl_have_int8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 3968 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# include "confdefs.h" +# include <sys/types.h> +# if STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +# endif +int +main () +{ +int8_t i + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lbl_have_int8_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_have_int8_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi + + echo "$as_me:$LINENO: result: $ac_cv_lbl_have_int8_t" >&5 +echo "${ECHO_T}$ac_cv_lbl_have_int8_t" >&6 + if test $ac_cv_lbl_have_int8_t = no ; then + cat >>confdefs.h <<\_ACEOF +#define int8_t signed char +_ACEOF + + fi +echo "$as_me:$LINENO: checking for u_int8_t using $CC" >&5 +echo $ECHO_N "checking for u_int8_t using $CC... $ECHO_C" >&6 + if test "${ac_cv_lbl_have_u_int8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include "confdefs.h" # include <sys/types.h> @@ -3973,37 +9176,56 @@ else # include <stdlib.h> # include <stddef.h> # endif -int main() { +int +main () +{ u_int8_t i -; return 0; } -EOF -if { (eval echo configure:3981: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_have_u_int8_t=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_have_u_int8_t=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_have_u_int8_t=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_have_u_int8_t" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int8_t" >&5 +echo "${ECHO_T}$ac_cv_lbl_have_u_int8_t" >&6 if test $ac_cv_lbl_have_u_int8_t = no ; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define u_int8_t u_char -EOF +_ACEOF fi -echo $ac_n "checking for int16_t using $CC""... $ac_c" 1>&6 -echo "configure:4001: checking for int16_t using $CC" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_have_int16_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 4006 "configure" -#include "confdefs.h" +echo "$as_me:$LINENO: checking for int16_t using $CC" >&5 +echo $ECHO_N "checking for int16_t using $CC... $ECHO_C" >&6 + if test "${ac_cv_lbl_have_int16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include "confdefs.h" # include <sys/types.h> @@ -4011,37 +9233,56 @@ else # include <stdlib.h> # include <stddef.h> # endif -int main() { +int +main () +{ int16_t i -; return 0; } -EOF -if { (eval echo configure:4019: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_have_int16_t=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_have_int16_t=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_have_int16_t=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_have_int16_t" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_have_int16_t" >&5 +echo "${ECHO_T}$ac_cv_lbl_have_int16_t" >&6 if test $ac_cv_lbl_have_int16_t = no ; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define int16_t short -EOF +_ACEOF fi -echo $ac_n "checking for u_int16_t using $CC""... $ac_c" 1>&6 -echo "configure:4039: checking for u_int16_t using $CC" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int16_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 4044 "configure" -#include "confdefs.h" +echo "$as_me:$LINENO: checking for u_int16_t using $CC" >&5 +echo $ECHO_N "checking for u_int16_t using $CC... $ECHO_C" >&6 + if test "${ac_cv_lbl_have_u_int16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include "confdefs.h" # include <sys/types.h> @@ -4049,37 +9290,56 @@ else # include <stdlib.h> # include <stddef.h> # endif -int main() { +int +main () +{ u_int16_t i -; return 0; } -EOF -if { (eval echo configure:4057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_have_u_int16_t=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_have_u_int16_t=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_have_u_int16_t=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_have_u_int16_t" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int16_t" >&5 +echo "${ECHO_T}$ac_cv_lbl_have_u_int16_t" >&6 if test $ac_cv_lbl_have_u_int16_t = no ; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define u_int16_t u_short -EOF +_ACEOF fi -echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6 -echo "configure:4077: checking for int32_t using $CC" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_have_int32_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 4082 "configure" -#include "confdefs.h" +echo "$as_me:$LINENO: checking for int32_t using $CC" >&5 +echo $ECHO_N "checking for int32_t using $CC... $ECHO_C" >&6 + if test "${ac_cv_lbl_have_int32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include "confdefs.h" # include <sys/types.h> @@ -4087,37 +9347,56 @@ else # include <stdlib.h> # include <stddef.h> # endif -int main() { +int +main () +{ int32_t i -; return 0; } -EOF -if { (eval echo configure:4095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_have_int32_t=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_have_int32_t=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_have_int32_t=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_have_int32_t" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_have_int32_t" >&5 +echo "${ECHO_T}$ac_cv_lbl_have_int32_t" >&6 if test $ac_cv_lbl_have_int32_t = no ; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define int32_t int -EOF +_ACEOF fi -echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6 -echo "configure:4115: checking for u_int32_t using $CC" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int32_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 4120 "configure" -#include "confdefs.h" +echo "$as_me:$LINENO: checking for u_int32_t using $CC" >&5 +echo $ECHO_N "checking for u_int32_t using $CC... $ECHO_C" >&6 + if test "${ac_cv_lbl_have_u_int32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include "confdefs.h" # include <sys/types.h> @@ -4125,27 +9404,42 @@ else # include <stdlib.h> # include <stddef.h> # endif -int main() { +int +main () +{ u_int32_t i -; return 0; } -EOF -if { (eval echo configure:4133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_have_u_int32_t=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_have_u_int32_t=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_have_u_int32_t=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_have_u_int32_t" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int32_t" >&5 +echo "${ECHO_T}$ac_cv_lbl_have_u_int32_t" >&6 if test $ac_cv_lbl_have_u_int32_t = no ; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define u_int32_t u_int -EOF +_ACEOF fi @@ -4161,7 +9455,7 @@ rm -f os-proto.h fi V_CCOPT="$V_CCOPT -Wall" if test $ac_cv_lbl_gcc_vers -gt 1 ; then - V_CCOPT="$V_CCOPT -Wmissing-prototypes -Wstrict-prototypes" + V_CCOPT="$V_CCOPT -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -W" fi fi else @@ -4179,59 +9473,110 @@ rm -f os-proto.h name="lbl/os-$os.h" if test -f $name ; then ln -s $name os-proto.h - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_OS_PROTO_H 1 -EOF +_ACEOF else - echo "configure: warning: can't find $name" 1>&2 + { echo "$as_me:$LINENO: WARNING: can't find $name" >&5 +echo "$as_me: WARNING: can't find $name" >&2;} fi fi -echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 -echo "configure:4193: checking if sockaddr struct has sa_len member" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +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 + if test "${ac_cv_lbl_sockaddr_has_sa_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 4198 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <sys/types.h> # include <sys/socket.h> -int main() { +int +main () +{ u_int i = sizeof(((struct sockaddr *)0)->sa_len) -; return 0; } -EOF -if { (eval echo configure:4207: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_lbl_sockaddr_has_sa_len=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_lbl_sockaddr_has_sa_len=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lbl_sockaddr_has_sa_len=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_lbl_sockaddr_has_sa_len" 1>&6 + 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 <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_SOCKADDR_SA_LEN 1 -EOF +_ACEOF fi -echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6 -echo "configure:4228: checking if unaligned accesses fail" >&5 - if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking if unaligned accesses fail" >&5 +echo $ECHO_N "checking if unaligned accesses fail... $ECHO_C" >&6 + if test "${ac_cv_lbl_unaligned_fail+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else case "$host_cpu" in + # + # These are CPU types where: + # + # the CPU faults on an unaligned access, but at least some + # OSes that support that CPU catch the fault and simulate + # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) - + # the simulation is slow, so we don't want to use it; + # + # the CPU, I infer (from the old + # # XXX: should also check that they don't do weird things (like on arm) - alpha*|arm*|hp*|mips*|sparc*|ia64) + # + # comment) doesn't fault on unaligned accesses, but doesn't + # do a normal unaligned fetch, either (e.g., presumably, ARM); + # + # for whatever reason, the test program doesn't work + # (this has been claimed to be the case for several of those + # CPUs - I don't know what the problem is; the problem + # was reported as "the test program dumps core" for SuperH, + # but that's what the test program is *supposed* to do - + # it dumps core before it writes anything, so the test + # for an empty output file should find an empty output + # file and conclude that unaligned accesses don't work). + # + # This run-time test won't work if you're cross-compiling, so + # in order to support cross-compiling for a particular CPU, + # we have to wire in the list of CPU types anyway, as far as + # I know, so perhaps we should just have a set of CPUs on + # which we know it doesn't work, a set of CPUs on which we + # know it does work, and have the script just fail on other + # cpu types and update it when such a failure occurs. + # + alpha*|arm*|hp*|mips*|sh*|sparc*|ia64|nv1) ac_cv_lbl_unaligned_fail=yes ;; @@ -4279,63 +9624,97 @@ EOF esac fi - echo "$ac_t""$ac_cv_lbl_unaligned_fail" 1>&6 + 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 <<\EOF + cat >>confdefs.h <<\_ACEOF #define LBL_ALIGN 1 -EOF +_ACEOF fi - echo $ac_n "checking for h_errno""... $ac_c" 1>&6 -echo "configure:4293: checking for h_errno" >&5 - if eval "test \"`echo '$''{'ac_cv_var_h_errno'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for h_errno" >&5 +echo $ECHO_N "checking for h_errno... $ECHO_C" >&6 + if test "${ac_cv_var_h_errno+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 4298 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ # include <sys/types.h> # include <netdb.h> -int main() { +int +main () +{ int foo = h_errno; -; return 0; } -EOF -if { (eval echo configure:4307: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_var_h_errno=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_var_h_errno=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_var_h_errno=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi - echo "$ac_t""$ac_cv_var_h_errno" 1>&6 + echo "$as_me:$LINENO: result: $ac_cv_var_h_errno" >&5 +echo "${ECHO_T}$ac_cv_var_h_errno" >&6 if test "$ac_cv_var_h_errno" = "yes"; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_H_ERRNO 1 -EOF +_ACEOF fi + # Check whether --with-crypto or --without-crypto was given. if test "${with_crypto+set}" = set; then withval="$with_crypto" - : + else - -echo $ac_n "checking for SSLeay""... $ac_c" 1>&6 -echo "configure:4335: checking for SSLeay" >&5 + +echo "$as_me:$LINENO: checking for SSLeay" >&5 +echo $ECHO_N "checking for SSLeay... $ECHO_C" >&6 ac_cv_ssleay_path=no incdir=no -for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do - if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then +for dir in /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do + # + # 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? + # + # Are there any other suffixes we need to look for? Do we have to + # worry about ".so.{version}"? + # + # 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 ac_cv_ssleay_path=$dir fi if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then @@ -4348,7 +9727,8 @@ for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do incdir=no fi done -echo "$ac_t""$ac_cv_ssleay_path" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_ssleay_path" >&5 +echo "${ECHO_T}$ac_cv_ssleay_path" >&6 if test "$ac_cv_ssleay_path" != no; then V_INCLS="$V_INCLS $incdir" LDFLAGS="-L$dir/lib $LDFLAGS" @@ -4358,191 +9738,218 @@ if test "$ac_cv_ssleay_path" != no; then if test -f $ac_cv_ssleay_path/lib/librsaref.a; then LIBS="$LIBS -lrsaref" fi - echo $ac_n "checking for des_cbc_encrypt in -lcrypto""... $ac_c" 1>&6 -echo "configure:4363: checking for des_cbc_encrypt in -lcrypto" >&5 -ac_lib_var=`echo crypto'_'des_cbc_encrypt | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + +echo "$as_me:$LINENO: checking for des_cbc_encrypt in -lcrypto" >&5 +echo $ECHO_N "checking for des_cbc_encrypt in -lcrypto... $ECHO_C" >&6 +if test "${ac_cv_lib_crypto_des_cbc_encrypt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" -cat > conftest.$ac_ext <<EOF -#line 4371 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char des_cbc_encrypt(); - -int main() { -des_cbc_encrypt() -; return 0; } -EOF -if { (eval echo configure:4382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo crypto | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <<EOF -#define $ac_tr_lib 1 -EOF + builtin and then its argument prototype would still apply. */ +char des_cbc_encrypt (); +int +main () +{ +des_cbc_encrypt (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_crypto_des_cbc_encrypt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_crypto_des_cbc_encrypt=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_crypto_des_cbc_encrypt" >&5 +echo "${ECHO_T}$ac_cv_lib_crypto_des_cbc_encrypt" >&6 +if test $ac_cv_lib_crypto_des_cbc_encrypt = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCRYPTO 1 +_ACEOF LIBS="-lcrypto $LIBS" -else - echo "$ac_t""no" 1>&6 fi - bak_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $V_INCLS" - for ac_hdr in cast.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4416: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 4421 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4426: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - - if test "$ac_cv_header_cast_h" = "yes"; then - echo $ac_n "checking for buggy CAST128""... $ac_c" 1>&6 -echo "configure:4455: checking for buggy CAST128" >&5 - if test "$cross_compiling" = yes; then - buggy_cast128="cross-compiling, assume yes" +for ac_header in openssl/evp.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&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 +#line $LINENO "configure" +/* 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 { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; 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 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 +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&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; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - cat > conftest.$ac_ext <<EOF -#line 4460 "configure" -#include "confdefs.h" - -#include <cast.h> -main() -{ - unsigned char key[] = {0x01,0x23,0x45,0x67,0x12}; - unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; - unsigned char out[sizeof(in)]; - unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}; - CAST_KEY ks; - CAST_set_key(&ks, sizeof(key), key); - CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT); - if (memcmp(out, ok, sizeof(ok)) != 0) - return 0; - else - return 1; -} -EOF -if { (eval echo configure:4479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - buggy_cast128=yes + ac_cpp_err=yes +fi +if test -z "$ac_cpp_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 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 preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + 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: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - buggy_cast128=no + eval "$as_ac_Header=$ac_header_preproc" fi -rm -fr conftest* -fi - - echo "$ac_t""$buggy_cast128" 1>&6 - if test "$buggy_cast128" != no; then - echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine." - echo "disabling CAST128 support." - cat >> confdefs.h <<\EOF -#define HAVE_BUGGY_CAST128 1 -EOF - - fi - fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - CPPFLAGS=$bak_CPPFLAGS 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 -for ac_hdr in rc5.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4511: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 4516 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4521: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi done +fi + +fi; + @@ -4557,440 +9964,1253 @@ done # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:4566: checking for a BSD compatible install" >&5 +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi done - ;; - esac - done - IFS="$ac_save_IFS" + done + ;; +esac +done + fi if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" + INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. - INSTALL="$ac_install_sh" + INSTALL=$ac_install_sh fi fi -echo "$ac_t""$INSTALL" 1>&6 +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + ac_config_headers="$ac_config_headers config.h" + ac_config_commands="$ac_config_commands default-1" -trap '' 1 2 15 -cat > confcache <<\EOF + ac_config_files="$ac_config_files Makefile" +cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. # -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. # -EOF +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' fi -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - DEFS=-DHAVE_CONFIG_H -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh -# Generated automatically by configure. +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. # Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# # Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. +# configure, is in config.log if it exists. -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi done -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi -trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS <<EOF +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@SHLICC2@%$SHLICC2%g -s%@CC@%$CC%g -s%@CPP@%$CPP%g -s%@LIBOBJS@%$LIBOBJS%g -s%@V_CCOPT@%$V_CCOPT%g -s%@V_GROUP@%$V_GROUP%g -s%@V_INCLS@%$V_INCLS%g -s%@V_PCAPDEP@%$V_PCAPDEP%g -s%@LOCALSRC@%$LOCALSRC%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -CEOF -EOF +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` + as_ln_s='ln -s' fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to <bug-autoconf@gnu.org>." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.57, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi -EOF -cat >> $CONFIG_STATUS <<EOF +_ACEOF -CONFIG_FILES=\${CONFIG_FILES-"Makefile"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + + + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; esac +done - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@SHLICC2@,$SHLICC2,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@CPP@,$CPP,;t t +s,@EGREP@,$EGREP,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@V_CCOPT@,$V_CCOPT,;t t +s,@V_DEFS@,$V_DEFS,;t t +s,@V_GROUP@,$V_GROUP,;t t +s,@V_INCLS@,$V_INCLS,;t t +s,@V_PCAPDEP@,$V_PCAPDEP,;t t +s,@LOCALSRC@,$LOCALSRC,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat fi +fi # test -n "$CONFIG_FILES" - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <<EOF - CONFIG_HEADERS="config.h" -EOF -cat >> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail -while : +while grep . conftest.undefs >/dev/null do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - fi - rm -f $ac_file - mv conftest.h $ac_file + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi -fi; done - -EOF -cat >> $CONFIG_STATUS <<EOF + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -EOF -cat >> $CONFIG_STATUS <<\EOF -if test -f .devel; then +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + default-1 ) if test -f .devel; then echo timestamp > stamp-h cat Makefile-devel-adds >> Makefile make depend -fi +fi ;; + esac +done +_ACEOF -exit 0 -EOF +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi exit 0 diff --git a/contrib/tcpdump/configure.in b/contrib/tcpdump/configure.in index 810608d..3479473 100755 --- a/contrib/tcpdump/configure.in +++ b/contrib/tcpdump/configure.in @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.145.2.1 2002/06/28 10:48:31 guy Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.169.2.3 2004/03/28 21:04:48 fenner Exp $ (LBL) dnl dnl Copyright (c) 1994, 1995, 1996, 1997 dnl The Regents of the University of California. All rights reserved. @@ -6,8 +6,8 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl -AC_REVISION($Revision: 1.145.2.1 $) -AC_PREREQ(2.13) +AC_REVISION($Revision: 1.169.2.3 $) +AC_PREREQ(2.50) AC_INIT(tcpdump.c) AC_CANONICAL_HOST @@ -16,7 +16,9 @@ AC_LBL_C_INIT(V_CCOPT, V_INCLS) AC_LBL_C_INLINE AC_C___ATTRIBUTE__ -AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h) +AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h netinet/ether.h) +AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h> +#include <sys/socket.h>]) AC_HEADER_TIME case "$host_os" in @@ -102,14 +104,13 @@ yes) AC_MSG_RESULT(yes) ;; esac -CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len" AC_MSG_CHECKING([whether to enable ipv6]) AC_ARG_ENABLE(ipv6, [ --enable-ipv6 enable ipv6 (with ipv4) support --disable-ipv6 disable ipv6 support], [ case "$enableval" in yes) AC_MSG_RESULT(yes) - LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" + LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" AC_DEFINE(INET6) ipv6=yes ;; @@ -131,7 +132,7 @@ main() } ], [ AC_MSG_RESULT(yes) - LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" + LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" AC_DEFINE(INET6) ipv6=yes], [ AC_MSG_RESULT(no) @@ -150,8 +151,8 @@ if test "$ipv6" = "yes"; then case $i in inria) dnl http://www.kame.net/ - AC_EGREP_CPP(yes, [dnl -#include <netinet/in.h> + AC_EGREP_CPP(yes, +[#include <netinet/in.h> #ifdef IPV6_INRIA_VERSION yes #endif], @@ -160,8 +161,8 @@ yes ;; kame) dnl http://www.kame.net/ - AC_EGREP_CPP(yes, [dnl -#include <netinet/in.h> + AC_EGREP_CPP(yes, +[#include <netinet/in.h> #ifdef __KAME__ yes #endif], @@ -173,8 +174,8 @@ yes ;; linux-glibc) dnl http://www.v6.linux.or.jp/ - AC_EGREP_CPP(yes, [dnl -#include <features.h> + AC_EGREP_CPP(yes, +[#include <features.h> #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 yes #endif], @@ -183,6 +184,10 @@ yes ;; linux-libinet6) dnl http://www.v6.linux.or.jp/ + dnl + dnl This also matches Solaris 8 and Tru64 UNIX 5.1, + dnl and possibly other versions of those OSes + dnl if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then ipv6type=$i ipv6lib=inet6 @@ -192,8 +197,8 @@ yes fi ;; toshiba) - AC_EGREP_CPP(yes, [dnl -#include <sys/param.h> + AC_EGREP_CPP(yes, +[#include <sys/param.h> #ifdef _TOSHIBA_INET6 yes #endif], @@ -203,8 +208,8 @@ yes CFLAGS="-DINET6 $CFLAGS"]) ;; v6d) - AC_EGREP_CPP(yes, [dnl -#include </usr/local/v6/include/sys/v6config.h> + AC_EGREP_CPP(yes, +[#include </usr/local/v6/include/sys/v6config.h> #ifdef __V6D__ yes #endif], @@ -214,8 +219,8 @@ yes CFLAGS="-I/usr/local/v6/include $CFLAGS"]) ;; zeta) - AC_EGREP_CPP(yes, [dnl -#include <sys/param.h> + AC_EGREP_CPP(yes, +[#include <sys/param.h> #ifdef _ZETA_MINAMI_INET6 yes #endif], @@ -250,9 +255,22 @@ fi if test "$ipv6" = "yes"; then + # + # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()" + # function in libc; there are "ngetaddrinfo()" and + # "ogetaddrinfo()" functions, and <netdb.h> #defines + # "getaddrinfo" to be either "ngetaddrinfo" or + # "ogetaddrinfo", depending on whether _SOCKADDR_LEN + # or _XOPEN_SOURCE_EXTENDED are defined or not. + # + # So this test doesn't work on Tru64 5.1, and possibly + # on other 5.x releases. This causes the configure + # script to become confused, and results in libpcap + # being unbuildable. + # AC_SEARCH_LIBS(getaddrinfo, socket, [dnl AC_MSG_CHECKING(getaddrinfo bug) - AC_TRY_RUN([ + AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([ #include <sys/types.h> #include <netdb.h> #include <string.h> @@ -270,6 +288,7 @@ main() hints.ai_family = AF_UNSPEC; hints.ai_flags = passive ? AI_PASSIVE : 0; hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { (void)gai_strerror(gaierr); goto bad; @@ -346,58 +365,44 @@ main() exit(1); } ], - AC_MSG_RESULT(good) - buggygetaddrinfo=no, - AC_MSG_RESULT(buggy) - buggygetaddrinfo=yes, - AC_MSG_RESULT(buggy) - buggygetaddrinfo=yes)], [buggygetaddrinfo=yes]) - - if test "$buggygetaddrinfo" = "yes"; then + td_cv_buggygetaddrinfo=no, + td_cv_buggygetaddrinfo=yes, + td_cv_buggygetaddrinfo=yes)]) + if test "$td_cv_buggygetaddrinfo" = no; then + AC_MSG_RESULT(good) + else + AC_MSG_RESULT(buggy) + fi + + if test "$td_cv_buggygetaddrinfo" = "yes"; then + # + # XXX - it doesn't appear that "ipv6type" can ever be + # set to "linux". Should this be testing for + # "linux-glibc", or for that *or* "linux-libinet6"? + # If the latter, note that "linux-libinet6" is also + # the type given to some non-Linux OSes. + # if test "$ipv6type" != "linux"; then echo 'Fatal: You must get working getaddrinfo() function.' echo ' or you can specify "--disable-ipv6"'. exit 1 else echo 'Warning: getaddrinfo() implementation on your system seems be buggy.' - echo ' Better upgreade your system library to newest version' + echo ' Better upgrade your system library to newest version' echo ' of GNU C library (aka glibc).' fi fi + ]) AC_REPLACE_FUNCS(getaddrinfo getnameinfo) fi -dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton) -AC_MSG_CHECKING(for inet_ntop) -AC_TRY_COMPILE([#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h>], [char src[4], dst[128]; -inet_ntop(AF_INET, src, dst, sizeof(dst));], - [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) - AC_REPLACE_FUNCS(inet_ntop)]) -AC_MSG_CHECKING(for inet_pton) -AC_TRY_COMPILE([#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h>], [char src[128], dst[4]; -inet_pton(AF_INET, src, dst);], - [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) - AC_REPLACE_FUNCS(inet_pton)]) -AC_MSG_CHECKING(for inet_aton) -AC_TRY_COMPILE([#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/inet.h>], [char src[128]; -struct in_addr dst; -inet_aton(src, &dst);], - [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) - AC_REPLACE_FUNCS(inet_aton)]) -dnl portability macros for getaddrinfo/getnameinfo -dnl -dnl Check for sa_len -AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len) -if test "$ac_cv_sockaddr_has_sa_len" = no; then - missing_includes=yes +AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h], +[td_cv_decl_netdnet_dnetdb_h_dnet_htoa], +[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h, + td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes, + td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)]) +if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then + AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA) fi dnl @@ -476,7 +481,8 @@ if test "$missing_includes" = "yes"; then fi -AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup) +AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep) +AC_CHECK_FUNCS(strftime) AC_CHECK_FUNCS(ether_ntohost, [ AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [ AC_TRY_RUN([ @@ -496,7 +502,7 @@ AC_CHECK_FUNCS(ether_ntohost, [ } ], [ac_cv_buggy_ether_ntohost=no], [ac_cv_buggy_ether_ntohost=yes], - [ac_cv_buggy_ether_ntohost=not while cross-compiling])]) + [ac_cv_buggy_ether_ntohost="not while cross-compiling"])]) if test "$ac_cv_buggy_ether_ntohost" = "no"; then AC_DEFINE(USE_ETHER_NTOHOST) fi @@ -507,12 +513,12 @@ needsnprintf=no AC_CHECK_FUNCS(vsnprintf snprintf,, [needsnprintf=yes]) if test $needsnprintf = yes; then - LIBOBJS="$LIBOBJS snprintf.o" + AC_LIBOBJ(snprintf.o) fi AC_LBL_TYPE_SIGNAL -AC_CHECK_LIB(dnet, dnet_htoa) +AC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA)) AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc @@ -524,6 +530,121 @@ dnl AC_CHECK_HEADERS(zlib.h) AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS) +# +# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate +# libraries (e.g., "-lsocket -lnsl" on Solaris). +# +# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which +# use AC_CHECK_FUNC which doesn't let us specify the right #includes +# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8 +# resolver, and the way it defines inet_{ntop,pton} is rather strange; +# it does not ship with a libc symbol "inet_ntop()", it ships with +# "_inet_ntop()", and has a #define macro in one of the system headers +# to rename it. +# +dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton) +AC_MSG_CHECKING(for inet_ntop) +AC_TRY_LINK([#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h>], [char src[4], dst[128]; +inet_ntop(AF_INET, src, dst, sizeof(dst));], + [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) + AC_LIBOBJ(inet_ntop.o)]) +AC_MSG_CHECKING(for inet_pton) +AC_TRY_LINK([#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h>], [char src[128], dst[4]; +inet_pton(AF_INET, src, dst);], + [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) + AC_LIBOBJ(inet_pton.o)]) +AC_MSG_CHECKING(for inet_aton) +AC_TRY_LINK([#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h>], [char src[128]; +struct in_addr dst; +inet_aton(src, &dst);], + [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) + AC_LIBOBJ(inet_aton.o)]) + +dnl portability macros for getaddrinfo/getnameinfo +dnl +dnl Check for sa_len +AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len) +if test "$ac_cv_sockaddr_has_sa_len" = no; then + missing_includes=yes +fi + +AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version) +if test $ac_cv_func_pcap_findalldevs = "yes" ; then +dnl Check for MacOS X, which may ship pcap.h from 0.6 but libpcap may +dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't +dnl have pcap_if_t. + AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>]) +fi +if test $ac_cv_func_pcap_lib_version = "no" ; then + AC_MSG_CHECKING(whether pcap_version is defined by libpcap) + AC_TRY_LINK([], + [ +char * +return_pcap_version(void) +{ + extern char pcap_version[]; + + return pcap_version; +} + ], + ac_lbl_cv_pcap_version_defined=yes, + ac_lbl_cv_pcap_version_defined=no) + if test "$ac_lbl_cv_pcap_version_defined" = yes ; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PCAP_VERSION) + else + AC_MSG_RESULT(no) + fi +fi +AC_MSG_CHECKING(whether pcap_debug is defined by libpcap) +AC_TRY_LINK([], + [ +int +return_pcap_debug(void) +{ + extern int pcap_debug; + + return pcap_debug; +} + ], + ac_lbl_cv_pcap_debug_defined=yes, + ac_lbl_cv_pcap_debug_defined=no) +if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PCAP_DEBUG) +else + AC_MSG_RESULT(no) + # + # OK, what about "yydebug"? + # + AC_MSG_CHECKING(whether yydebug is defined by libpcap) + AC_TRY_LINK([], + [ + int + return_yydebug(void) + { + extern int yydebug; + + return yydebug; + } + ], + ac_lbl_cv_yydebug_defined=yes, + ac_lbl_cv_yydebug_defined=no) + if test "$ac_lbl_cv_yydebug_defined" = yes ; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_YYDEBUG) + else + AC_MSG_RESULT(no) + fi +fi AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6 V_GROUP=0 @@ -554,6 +675,7 @@ if test -f /dev/bpf0 ; then V_GROUP=bpf fi +AC_LBL_CHECK_TYPE(int8_t, signed char) AC_LBL_CHECK_TYPE(u_int8_t, u_char) AC_LBL_CHECK_TYPE(int16_t, short) AC_LBL_CHECK_TYPE(u_int16_t, u_short) @@ -573,8 +695,21 @@ AC_ARG_WITH(crypto, [ --without-crypto disable crypto support], AC_MSG_CHECKING(for SSLeay) ac_cv_ssleay_path=no incdir=no -for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do - if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then +for dir in /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do + # + # 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? + # + # Are there any other suffixes we need to look for? Do we have to + # worry about ".so.{version}"? + # + # 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 ac_cv_ssleay_path=$dir fi if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then @@ -599,46 +734,13 @@ if test "$ac_cv_ssleay_path" != no; then fi AC_CHECK_LIB(crypto, des_cbc_encrypt) - bak_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $V_INCLS" - AC_CHECK_HEADERS(cast.h) - - if test "$ac_cv_header_cast_h" = "yes"; then - AC_MSG_CHECKING(for buggy CAST128) - AC_TRY_RUN(dnl -[ -#include <cast.h> -main() -{ - unsigned char key[] = {0x01,0x23,0x45,0x67,0x12}; - unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; - unsigned char out[sizeof(in)]; - unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}; - CAST_KEY ks; - CAST_set_key(&ks, sizeof(key), key); - CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT); - if (memcmp(out, ok, sizeof(ok)) != 0) - return 0; - else - return 1; -}], - [buggy_cast128=yes], - [buggy_cast128=no], - [buggy_cast128="cross-compiling, assume yes"]) - AC_MSG_RESULT($buggy_cast128) - if test "$buggy_cast128" != no; then - echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine." - echo "disabling CAST128 support." - AC_DEFINE(HAVE_BUGGY_CAST128) - fi - fi - - CPPFLAGS=$bak_CPPFLAGS + AC_CHECK_HEADERS(openssl/evp.h) fi ]) -AC_CHECK_HEADERS(rc5.h) AC_SUBST(V_CCOPT) +AC_SUBST(V_DEFS) AC_SUBST(V_GROUP) AC_SUBST(V_INCLS) AC_SUBST(V_PCAPDEP) diff --git a/contrib/tcpdump/decnet.h b/contrib/tcpdump/decnet.h index c356bcb..9a5c147 100644 --- a/contrib/tcpdump/decnet.h +++ b/contrib/tcpdump/decnet.h @@ -18,10 +18,18 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.7 2000/10/03 02:54:55 itojun Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.11 2002/12/11 07:13:50 guy Exp $ (LBL) */ +#ifndef WIN32 typedef u_int8_t byte[1]; /* single byte field */ +#else +/* + * the keyword 'byte' generates conflicts in Windows + */ +typedef unsigned char Byte[1]; /* single byte field */ +#define byte Byte +#endif /* WIN32 */ typedef u_int8_t word[2]; /* 2 byte field */ typedef u_int8_t longword[4]; /* 4 bytes field */ diff --git a/contrib/tcpdump/enc.h b/contrib/tcpdump/enc.h new file mode 100644 index 0000000..f54b4eb --- /dev/null +++ b/contrib/tcpdump/enc.h @@ -0,0 +1,47 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/enc.h,v 1.1 2003/03/08 08:55:33 guy Exp $ (LBL) */ +/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */ +/* + * The authors of this code are John Ioannidis (ji@tla.org), + * Angelos D. Keromytis (kermit@csd.uch.gr) and + * Niels Provos (provos@physnet.uni-hamburg.de). + * + * This code was written by John Ioannidis for BSD/OS in Athens, Greece, + * in November 1995. + * + * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, + * by Angelos D. Keromytis. + * + * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis + * and Niels Provos. + * + * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis + * and Niels Provos. + * Copyright (c) 2001, Angelos D. Keromytis. + * + * Permission to use, copy, and modify this software with or without fee + * is hereby granted, provided that this entire notice is included in + * all copies of any software which is or includes a copy or + * modification of this software. + * You may use this code under the GNU public license if you so wish. Please + * contribute changes back to the authors under this freer than GPL license + * so that we may further the use of strong encryption without limitations to + * all. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE + * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR + * PURPOSE. + */ + +#define ENC_HDRLEN 12 + +/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $ */ +#define M_CONF 0x0400 /* packet was encrypted (ESP-transport) */ +#define M_AUTH 0x0800 /* packet was authenticated (AH) */ + +struct enchdr { + u_int32_t af; + u_int32_t spi; + u_int32_t flags; +}; diff --git a/contrib/tcpdump/ether.h b/contrib/tcpdump/ether.h index 5c3dff0..3d3f3be 100644 --- a/contrib/tcpdump/ether.h +++ b/contrib/tcpdump/ether.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.6 2000/10/09 03:24:24 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.8 2002/12/11 07:13:51 guy Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. diff --git a/contrib/tcpdump/extract.h b/contrib/tcpdump/extract.h index 861f06f..25980e4 100644 --- a/contrib/tcpdump/extract.h +++ b/contrib/tcpdump/extract.h @@ -18,40 +18,81 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.17 2001/09/17 21:57:52 fenner Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.19 2002/12/11 07:13:51 guy Exp $ (LBL) */ /* Network to host order macros */ #ifdef LBL_ALIGN +/* + * The processor doesn't natively handle unaligned loads. + */ +#ifdef HAVE___ATTRIBUTE__ +/* + * We have __attribute__; we assume that means we have __attribute__((packed)). + * Declare packed structures containing a u_int16_t and a u_int32_t, + * cast the pointer to point to one of those, and fetch through it; + * the GCC manual doesn't appear to explicitly say that + * __attribute__((packed)) causes the compiler to generate unaligned-safe + * code, but it apppears to do so. + * + * We do this in case the compiler can generate, for this instruction set, + * better code to do an unaligned load and pass stuff to "ntohs()" or + * "ntohl()" than the code to fetch the bytes one at a time and + * assemble them. (That might not be the case on a little-endian platform, + * where "ntohs()" and "ntohl()" might not be done inline.) + */ +typedef struct { + u_int16_t val; +} __attribute__((packed)) unaligned_u_int16_t; + +typedef struct { + u_int32_t val; +} __attribute__((packed)) unaligned_u_int32_t; + #define EXTRACT_16BITS(p) \ - ((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ - (u_int16_t)*((const u_int8_t *)(p) + 1)) + ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val)) #define EXTRACT_32BITS(p) \ - ((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 3)) -#else + ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val)) +#else /* HAVE___ATTRIBUTE__ */ +/* + * We don't have __attribute__, so do unaligned loads of big-endian + * quantities the hard way - fetch the bytes one at a time and + * assemble them. + */ +#define EXTRACT_16BITS(p) \ + ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ + (u_int16_t)*((const u_int8_t *)(p) + 1))) +#define EXTRACT_32BITS(p) \ + ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ + (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ + (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ + (u_int32_t)*((const u_int8_t *)(p) + 3))) +#endif /* HAVE___ATTRIBUTE__ */ +#else /* LBL_ALIGN */ +/* + * The processor natively handles unaligned loads, so we can just + * cast the pointer and fetch through it. + */ #define EXTRACT_16BITS(p) \ ((u_int16_t)ntohs(*(const u_int16_t *)(p))) #define EXTRACT_32BITS(p) \ ((u_int32_t)ntohl(*(const u_int32_t *)(p))) -#endif +#endif /* LBL_ALIGN */ #define EXTRACT_24BITS(p) \ - ((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2)) + ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ + (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ + (u_int32_t)*((const u_int8_t *)(p) + 2))) /* Little endian protocol host order macros */ #define EXTRACT_LE_8BITS(p) (*(p)) #define EXTRACT_LE_16BITS(p) \ - ((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int16_t)*((const u_int8_t *)(p) + 0)) + ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ + (u_int16_t)*((const u_int8_t *)(p) + 0))) #define EXTRACT_LE_32BITS(p) \ - ((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 0)) + ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ + (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ + (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ + (u_int32_t)*((const u_int8_t *)(p) + 0))) diff --git a/contrib/tcpdump/fddi.h b/contrib/tcpdump/fddi.h index 64ebfb3..690af48 100644 --- a/contrib/tcpdump/fddi.h +++ b/contrib/tcpdump/fddi.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.9 2000/10/09 02:59:39 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.11 2002/12/11 07:13:51 guy Exp $ (LBL) */ /* diff --git a/contrib/tcpdump/gmpls.c b/contrib/tcpdump/gmpls.c new file mode 100644 index 0000000..325b53a --- /dev/null +++ b/contrib/tcpdump/gmpls.c @@ -0,0 +1,134 @@ +/* + * 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. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.2.2.2 2003/11/16 08:51:05 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include "interface.h" + +/* rfc3471 */ +struct tok gmpls_link_prot_values[] = { + { 0x01, "Extra Traffic"}, + { 0x02, "Unprotected"}, + { 0x04, "Shared"}, + { 0x08, "Dedicated 1:1"}, + { 0x10, "Dedicated 1+1"}, + { 0x20, "Enhanced"}, + { 0x40, "Reserved"}, + { 0x80, "Reserved"}, + { 0, NULL } +}; + +/* rfc3471 */ +struct tok gmpls_switch_cap_values[] = { + { 1, "Packet-Switch Capable-1"}, + { 2, "Packet-Switch Capable-2"}, + { 3, "Packet-Switch Capable-3"}, + { 4, "Packet-Switch Capable-4"}, + { 51, "Layer-2 Switch Capable"}, + { 100, "Time-Division-Multiplex"}, + { 150, "Lambda-Switch Capable"}, + { 200, "Fiber-Switch Capable"}, + { 0, NULL } +}; + +/* rfc3471 */ +struct tok gmpls_encoding_values[] = { + { 1, "Packet"}, + { 2, "Ethernet V2/DIX"}, + { 3, "ANSI/ETSI PDH"}, + { 4, "Reserved"}, + { 5, "SDH ITU-T G.707/SONET ANSI T1.105"}, + { 6, "Reserved"}, + { 7, "Digital Wrapper"}, + { 8, "Lambda (photonic)"}, + { 9, "Fiber"}, + { 10, "Reserved"}, + { 11, "FiberChannel"}, + { 0, NULL } +}; + +/* rfc3471 */ +struct tok gmpls_payload_values[] = { + { 0, "Unknown"}, + { 1, "Reserved"}, + { 2, "Reserved"}, + { 3, "Reserved"}, + { 4, "Reserved"}, + { 5, "Asynchronous mapping of E4"}, + { 6, "Asynchronous mapping of DS3/T3"}, + { 7, "Asynchronous mapping of E3"}, + { 8, "Bit synchronous mapping of E3"}, + { 9, "Byte synchronous mapping of E3"}, + { 10, "Asynchronous mapping of DS2/T2"}, + { 11, "Bit synchronous mapping of DS2/T2"}, + { 12, "Reserved"}, + { 13, "Asynchronous mapping of E1"}, + { 14, "Byte synchronous mapping of E1"}, + { 15, "Byte synchronous mapping of 31 * DS0"}, + { 16, "Asynchronous mapping of DS1/T1"}, + { 17, "Bit synchronous mapping of DS1/T1"}, + { 18, "Byte synchronous mapping of DS1/T1"}, + { 19, "VC-11 in VC-12"}, + { 20, "Reserved"}, + { 21, "Reserved"}, + { 22, "DS1 SF Asynchronous"}, + { 23, "DS1 ESF Asynchronous"}, + { 24, "DS3 M23 Asynchronous"}, + { 25, "DS3 C-Bit Parity Asynchronous"}, + { 26, "VT/LOVC"}, + { 27, "STS SPE/HOVC"}, + { 28, "POS - No Scrambling, 16 bit CRC"}, + { 29, "POS - No Scrambling, 32 bit CRC"}, + { 30, "POS - Scrambling, 16 bit CRC"}, + { 31, "POS - Scrambling, 32 bit CRC"}, + { 32, "ATM mapping"}, + { 33, "Ethernet PHY"}, + { 34, "SONET/SDH"}, + { 35, "Reserved (SONET deprecated)"}, + { 36, "Digital Wrapper"}, + { 37, "Lambda"}, + { 38, "ANSI/ETSI PDH"}, + { 39, "Reserved"}, + { 40, "Link Access Protocol SDH (X.85 and X.86)"}, + { 41, "FDDI"}, + { 42, "DQDB (ETSI ETS 300 216)"}, + { 43, "FiberChannel-3 (Services)"}, + { 44, "HDLC"}, + { 45, "Ethernet V2/DIX (only)"}, + { 46, "Ethernet 802.3 (only)"}, +/* draft-ietf-ccamp-gmpls-g709-04.txt */ + { 47, "G.709 ODUj"}, + { 48, "G.709 OTUk(v)"}, + { 49, "CBR/CBRa"}, + { 50, "CBRb"}, + { 51, "BSOT"}, + { 52, "BSNT"}, + { 53, "IP/PPP (GFP)"}, + { 54, "Ethernet MAC (framed GFP)"}, + { 55, "Ethernet PHY (transparent GFP)"}, + { 56, "ESCON"}, + { 57, "FICON"}, + { 58, "Fiber Channel"}, + { 0, NULL } +}; diff --git a/contrib/tcpdump/gmpls.h b/contrib/tcpdump/gmpls.h new file mode 100644 index 0000000..f35211f --- /dev/null +++ b/contrib/tcpdump/gmpls.h @@ -0,0 +1,20 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.2 2003/06/09 23:28:09 guy Exp $ (LBL) */ +/* + * 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. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +extern struct tok gmpls_link_prot_values[]; +extern struct tok gmpls_switch_cap_values[]; +extern struct tok gmpls_encoding_values[]; +extern struct tok gmpls_payload_values[]; diff --git a/contrib/tcpdump/gmt2local.c b/contrib/tcpdump/gmt2local.c index bcef636..978e583 100644 --- a/contrib/tcpdump/gmt2local.c +++ b/contrib/tcpdump/gmt2local.c @@ -20,18 +20,17 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.4.6.1 2002/06/01 23:43:53 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.7.2.2 2003/11/16 08:51:06 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> +#include <tcpdump-stdinc.h> #include <stdio.h> -#include <time.h> #ifdef HAVE_OS_PROTO_H #include "os-proto.h" diff --git a/contrib/tcpdump/icmp6.h b/contrib/tcpdump/icmp6.h index 49b8cfa..931de2f 100644 --- a/contrib/tcpdump/icmp6.h +++ b/contrib/tcpdump/icmp6.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.11 2001/06/01 23:01:04 itojun Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.14 2002/12/11 07:13:52 guy Exp $ (LBL) */ /* $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $ */ /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */ @@ -122,7 +122,13 @@ struct icmp6_hdr { #define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */ #define MLD6_MTRACE 142 /* mtrace messages */ -#define ICMP6_MAXTYPE 142 +/* Folloing numbers are defined in the mobile-ip draft. */ +#define ICMP6_HADISCOV_REQUEST 150 /* XXX To be authorized */ +#define ICMP6_HADISCOV_REPLY 151 /* XXX To be authorized */ +#define ICMP6_MOBILEPREFIX_SOLICIT 152 /* XXX To be authorized */ +#define ICMP6_MOBILEPREFIX_ADVERT 153 /* XXX To be authorized */ + +#define ICMP6_MAXTYPE 153 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ diff --git a/contrib/tcpdump/ieee802_11.h b/contrib/tcpdump/ieee802_11.h index cecd0d7..fa5a555 100644 --- a/contrib/tcpdump/ieee802_11.h +++ b/contrib/tcpdump/ieee802_11.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.3 2001/06/14 09:50:01 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9 2003/07/22 17:36:57 guy Exp $ (LBL) */ /* * Copyright (c) 2001 * Fortress Technologies @@ -21,52 +21,87 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define IEEE802_11_FC_LEN 2 - -#define T_MGMT 0x0 /* management */ -#define T_CTRL 0x1 /* control */ -#define T_DATA 0x2 /* data */ -#define T_RESV 0x3 /* reserved */ - -#define ST_ASSOC_REQUEST 0x0 -#define ST_ASSOC_RESPONSE 0x1 -#define ST_REASSOC_REQUEST 0x2 -#define ST_REASSOC_RESPONSE 0x3 -#define ST_PROBE_REQUEST 0x4 -#define ST_PROBE_RESPONSE 0x5 +/* Lengths of 802.11 header components. */ +#define IEEE802_11_FC_LEN 2 +#define IEEE802_11_DUR_LEN 2 +#define IEEE802_11_DA_LEN 6 +#define IEEE802_11_SA_LEN 6 +#define IEEE802_11_BSSID_LEN 6 +#define IEEE802_11_RA_LEN 6 +#define IEEE802_11_TA_LEN 6 +#define IEEE802_11_SEQ_LEN 2 +#define IEEE802_11_IV_LEN 3 +#define IEEE802_11_KID_LEN 1 + +/* Frame check sequence length. */ +#define IEEE802_11_FCS_LEN 4 + +/* Lengths of beacon components. */ +#define IEEE802_11_TSTAMP_LEN 8 +#define IEEE802_11_BCNINT_LEN 2 +#define IEEE802_11_CAPINFO_LEN 2 +#define IEEE802_11_LISTENINT_LEN 2 + +#define IEEE802_11_AID_LEN 2 +#define IEEE802_11_STATUS_LEN 2 +#define IEEE802_11_REASON_LEN 2 + +/* Length of previous AP in reassocation frame */ +#define IEEE802_11_AP_LEN 6 + +#define T_MGMT 0x0 /* management */ +#define T_CTRL 0x1 /* control */ +#define T_DATA 0x2 /* data */ +#define T_RESV 0x3 /* reserved */ + +#define ST_ASSOC_REQUEST 0x0 +#define ST_ASSOC_RESPONSE 0x1 +#define ST_REASSOC_REQUEST 0x2 +#define ST_REASSOC_RESPONSE 0x3 +#define ST_PROBE_REQUEST 0x4 +#define ST_PROBE_RESPONSE 0x5 /* RESERVED 0x6 */ /* RESERVED 0x7 */ -#define ST_BEACON 0x8 -#define ST_ATIM 0x9 -#define ST_DISASSOC 0xA -#define ST_AUTH 0xB -#define ST_DEAUTH 0xC +#define ST_BEACON 0x8 +#define ST_ATIM 0x9 +#define ST_DISASSOC 0xA +#define ST_AUTH 0xB +#define ST_DEAUTH 0xC /* RESERVED 0xD */ /* RESERVED 0xE */ /* RESERVED 0xF */ -#define CTRL_PS_POLL 0xA -#define CTRL_RTS 0xB -#define CTRL_CTS 0xC -#define CTRL_ACK 0xD -#define CTRL_CF_END 0xE -#define CTRL_END_ACK 0xF +#define CTRL_PS_POLL 0xA +#define CTRL_RTS 0xB +#define CTRL_CTS 0xC +#define CTRL_ACK 0xD +#define CTRL_CF_END 0xE +#define CTRL_END_ACK 0xF + +#define DATA_DATA 0x0 +#define DATA_DATA_CF_ACK 0x1 +#define DATA_DATA_CF_POLL 0x2 +#define DATA_DATA_CF_ACK_POLL 0x3 +#define DATA_NODATA 0x4 +#define DATA_NODATA_CF_ACK 0x5 +#define DATA_NODATA_CF_POLL 0x6 +#define DATA_NODATA_CF_ACK_POLL 0x7 /* * Bits in the frame control field. */ -#define FC_VERSION(fc) ((fc) & 0x3) -#define FC_TYPE(fc) (((fc) >> 2) & 0x3) -#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) -#define FC_TO_DS(fc) ((fc) & 0x0100) -#define FC_FROM_DS(fc) ((fc) & 0x0200) -#define FC_MORE_FLAG(fc) ((fc) & 0x0400) -#define FC_RETRY(fc) ((fc) & 0x0800) -#define FC_POWER_MGMT(fc) ((fc) & 0x1000) -#define FC_MORE_DATA(fc) ((fc) & 0x2000) -#define FC_WEP(fc) ((fc) & 0x4000) -#define FC_ORDER(fc) ((fc) & 0x8000) +#define FC_VERSION(fc) ((fc) & 0x3) +#define FC_TYPE(fc) (((fc) >> 2) & 0x3) +#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) +#define FC_TO_DS(fc) ((fc) & 0x0100) +#define FC_FROM_DS(fc) ((fc) & 0x0200) +#define FC_MORE_FLAG(fc) ((fc) & 0x0400) +#define FC_RETRY(fc) ((fc) & 0x0800) +#define FC_POWER_MGMT(fc) ((fc) & 0x1000) +#define FC_MORE_DATA(fc) ((fc) & 0x2000) +#define FC_WEP(fc) ((fc) & 0x4000) +#define FC_ORDER(fc) ((fc) & 0x8000) struct mgmt_header_t { u_int16_t fc; @@ -77,19 +112,21 @@ struct mgmt_header_t { u_int16_t seq_ctrl; }; -#define MGMT_HEADER_LEN (2+2+6+6+6+2) +#define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ + IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\ + IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN) -#define CAPABILITY_ESS(cap) ((cap) & 0x0001) -#define CAPABILITY_IBSS(cap) ((cap) & 0x0002) -#define CAPABILITY_CFP(cap) ((cap) & 0x0004) -#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) -#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) +#define CAPABILITY_ESS(cap) ((cap) & 0x0001) +#define CAPABILITY_IBSS(cap) ((cap) & 0x0002) +#define CAPABILITY_CFP(cap) ((cap) & 0x0004) +#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) +#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) struct ssid_t { u_int8_t element_id; u_int8_t length; u_char ssid[33]; /* 32 + 1 for null */ -} ; +}; struct rates_t { u_int8_t element_id; @@ -135,13 +172,13 @@ struct tim_t { u_int8_t bitmap[251]; }; -#define E_SSID 0 -#define E_RATES 1 -#define E_FH 2 -#define E_DS 3 -#define E_CF 4 -#define E_TIM 5 -#define E_IBSS 6 +#define E_SSID 0 +#define E_RATES 1 +#define E_FH 2 +#define E_DS 3 +#define E_CF 4 +#define E_TIM 5 +#define E_IBSS 6 /* reserved 7 */ /* reserved 8 */ /* reserved 9 */ @@ -153,7 +190,7 @@ struct tim_t { /* reserved 15 */ /* reserved 16 */ -#define E_CHALLENGE 16 +#define E_CHALLENGE 16 /* reserved 17 */ /* reserved 18 */ /* reserved 19 */ @@ -189,7 +226,8 @@ struct ctrl_rts_t { u_int8_t fcs[4]; }; -#define CTRL_RTS_LEN (2+2+6+6+4) +#define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ + IEEE802_11_RA_LEN+IEEE802_11_TA_LEN) struct ctrl_cts_t { u_int16_t fc; @@ -198,7 +236,7 @@ struct ctrl_cts_t { u_int8_t fcs[4]; }; -#define CTRL_CTS_LEN (2+2+6+4) +#define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN) struct ctrl_ack_t { u_int16_t fc; @@ -207,7 +245,7 @@ struct ctrl_ack_t { u_int8_t fcs[4]; }; -#define CTRL_ACK_LEN (2+2+6+4) +#define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN) struct ctrl_ps_poll_t { u_int16_t fc; @@ -217,7 +255,8 @@ struct ctrl_ps_poll_t { u_int8_t fcs[4]; }; -#define CTRL_PS_POLL_LEN (2+2+6+6+4) +#define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\ + IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN) struct ctrl_end_t { u_int16_t fc; @@ -227,7 +266,8 @@ struct ctrl_end_t { u_int8_t fcs[4]; }; -#define CTRL_END_LEN (2+2+6+6+4) +#define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ + IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN) struct ctrl_end_ack_t { u_int16_t fc; @@ -237,8 +277,9 @@ struct ctrl_end_ack_t { u_int8_t fcs[4]; }; -#define CTRL_END_ACK_LEN (2+2+6+6+4) +#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ + IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN) -#define IV_IV(iv) ((iv) & 0xFFFFFF) -#define IV_PAD(iv) (((iv) >> 24) & 0x3F) -#define IV_KEYID(iv) (((iv) >> 30) & 0x03) +#define IV_IV(iv) ((iv) & 0xFFFFFF) +#define IV_PAD(iv) (((iv) >> 24) & 0x3F) +#define IV_KEYID(iv) (((iv) >> 30) & 0x03) diff --git a/contrib/tcpdump/igrp.h b/contrib/tcpdump/igrp.h index f94ba3f..78876d3 100644 --- a/contrib/tcpdump/igrp.h +++ b/contrib/tcpdump/igrp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002/12/11 07:13:52 guy Exp $ (LBL) */ /* Cisco IGRP definitions */ /* IGRP Header */ diff --git a/contrib/tcpdump/ip.h b/contrib/tcpdump/ip.h index 77cf2f6..37ef774 100644 --- a/contrib/tcpdump/ip.h +++ b/contrib/tcpdump/ip.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.7 2000/10/03 09:17:40 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.10 2002/12/11 07:13:53 guy Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -157,3 +157,6 @@ struct ip_timestamp { #define IPTTLDEC 1 /* subtracted when forwarding */ #define IP_MSS 576 /* default maximum segment size */ + +/* in print-ip.c */ +extern u_int32_t ip_finddst(const struct ip *); diff --git a/contrib/tcpdump/ip6.h b/contrib/tcpdump/ip6.h index 6e383dd..c858a48 100644 --- a/contrib/tcpdump/ip6.h +++ b/contrib/tcpdump/ip6.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.3 2000/12/17 23:07:48 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.6 2002/12/11 22:29:21 guy Exp $ (LBL) */ /* $NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp $ */ /* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */ @@ -187,9 +187,8 @@ struct ip6_frag { u_int32_t ip6f_ident; /* identification */ }; -/* network endian */ -#define IP6F_OFF_MASK ((u_int16_t)htons(0xfff8)) /* mask out offset from _offlg */ -#define IP6F_RESERVED_MASK ((u_int16_t)htons(0x0006)) /* reserved bits in ip6f_offlg */ -#define IP6F_MORE_FRAG ((u_int16_t)htons(0x0001)) /* more-fragments flag */ +#define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */ +#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ #endif /* not _NETINET_IP6_H_ */ diff --git a/contrib/tcpdump/ipfc.h b/contrib/tcpdump/ipfc.h new file mode 100644 index 0000000..f822d4a --- /dev/null +++ b/contrib/tcpdump/ipfc.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 1992, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/tcpdump/ipfc.h,v 1.4 2002/12/11 07:13:53 guy Exp $ (LBL) + */ + +struct ipfc_header { + u_char ipfc_dhost[8]; + u_char ipfc_shost[8]; +}; + +#define IPFC_HDRLEN 16 diff --git a/contrib/tcpdump/ipproto.h b/contrib/tcpdump/ipproto.h new file mode 100644 index 0000000..b73cc20 --- /dev/null +++ b/contrib/tcpdump/ipproto.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 1982, 1986, 1990, 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. + * + * @(#) $Header: /tcpdump/master/tcpdump/ipproto.h,v 1.1.2.1 2003/11/24 20:31:22 guy Exp $ (LBL) + * + * From: + * @(#)in.h 8.3 (Berkeley) 1/3/94 + * $FreeBSD$ + */ + +#ifndef IPPROTO_IP +#define IPPROTO_IP 0 /* dummy for IP */ +#endif +#ifndef IPPROTO_HOPOPTS +#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */ +#endif +#ifndef IPPROTO_ICMP +#define IPPROTO_ICMP 1 /* control message protocol */ +#endif +#ifndef IPPROTO_IGMP +#define IPPROTO_IGMP 2 /* group mgmt protocol */ +#endif +#ifndef IPPROTO_IPV4 +#define IPPROTO_IPV4 4 +#endif +#ifndef IPPROTO_TCP +#define IPPROTO_TCP 6 /* tcp */ +#endif +#ifndef IPPROTO_EGP +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#endif +#ifndef IPPROTO_IGRP +#define IPPROTO_IGRP 9 +#endif +#ifndef IPPROTO_UDP +#define IPPROTO_UDP 17 /* user datagram protocol */ +#endif +#ifndef IPPROTO_IPV6 +#define IPPROTO_IPV6 41 +#endif +#ifndef IPPROTO_ROUTING +#define IPPROTO_ROUTING 43 /* IPv6 routing header */ +#endif +#ifndef IPPROTO_FRAGMENT +#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */ +#endif +#ifndef IPPROTO_RSVP +#define IPPROTO_RSVP 46 /* resource reservation */ +#endif +#ifndef IPPROTO_GRE +#define IPPROTO_GRE 47 /* General Routing Encap. */ +#endif +#ifndef IPPROTO_ESP +#define IPPROTO_ESP 50 /* SIPP Encap Sec. Payload */ +#endif +#ifndef IPPROTO_AH +#define IPPROTO_AH 51 /* SIPP Auth Header */ +#endif +#ifndef IPPROTO_MOBILE +#define IPPROTO_MOBILE 55 +#endif +#ifndef IPPROTO_ICMPV6 +#define IPPROTO_ICMPV6 58 /* ICMPv6 */ +#endif +#ifndef IPPROTO_NONE +#define IPPROTO_NONE 59 /* IPv6 no next header */ +#endif +#ifndef IPPROTO_DSTOPTS +#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */ +#endif +#ifndef IPPROTO_MOBILITY_OLD +/* + * The current Protocol Numbers list says that the IP protocol number for + * mobility headers is 135; it cites draft-ietf-mobileip-ipv6-24, but + * that draft doesn't actually give a number. + * + * It appears that 62 used to be used, even though that's assigned to + * a protocol called CFTP; however, the only reference for CFTP is a + * Network Message from BBN back in 1982, so, for now, we support 62, + * aas well as 135, as a protocol number for mobility headers. + */ +#define IPPROTO_MOBILITY_OLD 62 +#endif +#ifndef IPPROTO_ND +#define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ +#endif +#ifndef IPPROTO_IGRP +#define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ +#endif +#ifndef IPPROTO_OSPF +#define IPPROTO_OSPF 89 +#endif +#ifndef IPPROTO_PIM +#define IPPROTO_PIM 103 +#endif +#ifndef IPPROTO_IPCOMP +#define IPPROTO_IPCOMP 108 +#endif +#ifndef IPPROTO_VRRP +#define IPPROTO_VRRP 112 +#endif +#ifndef IPPROTO_SCTP +#define IPPROTO_SCTP 132 +#endif +#ifndef IPPROTO_MOBILITY +#define IPPROTO_MOBILITY 135 +#endif diff --git a/contrib/tcpdump/ipsec_doi.h b/contrib/tcpdump/ipsec_doi.h index f39f0dc..83d05ea 100644 --- a/contrib/tcpdump/ipsec_doi.h +++ b/contrib/tcpdump/ipsec_doi.h @@ -1,7 +1,7 @@ /* * 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: @@ -13,7 +13,7 @@ * 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 @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* YIPS @(#)$Id: ipsec_doi.h,v 1.4 2000/10/04 03:00:29 itojun Exp $ */ +/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002/12/11 07:13:53 guy Exp $ */ /* refer to RFC 2407 */ diff --git a/contrib/tcpdump/ipx.h b/contrib/tcpdump/ipx.h index a0dca0c..a8c1cd5 100644 --- a/contrib/tcpdump/ipx.h +++ b/contrib/tcpdump/ipx.h @@ -1,7 +1,7 @@ /* - * IPX protocol formats + * IPX protocol formats * - * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.4 2001/01/15 03:23:59 guy Exp $ + * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002/12/11 07:13:54 guy Exp $ */ /* well-known sockets */ @@ -25,7 +25,7 @@ struct ipxHdr { u_int16_t srcNet[2]; /* source net */ u_int8_t srcNode[6]; /* source node */ u_int16_t srcSkt; /* source socket */ -} ipx_hdr_t; +}; #define ipxSize 30 diff --git a/contrib/tcpdump/isakmp.h b/contrib/tcpdump/isakmp.h index b12145f..94fac40 100644 --- a/contrib/tcpdump/isakmp.h +++ b/contrib/tcpdump/isakmp.h @@ -1,7 +1,7 @@ /* * 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: @@ -13,7 +13,7 @@ * 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 @@ -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.7 2000/10/03 05:16:38 itojun Exp $ */ +/* YIPS @(#)$Id: isakmp.h,v 1.10 2002/12/11 07:13:54 guy Exp $ */ /* refer to RFC 2408 */ diff --git a/contrib/tcpdump/lane.h b/contrib/tcpdump/lane.h index f83e904..51b6e19 100644 --- a/contrib/tcpdump/lane.h +++ b/contrib/tcpdump/lane.h @@ -1,6 +1,6 @@ /* - * Marko Kiiskila carnil@cs.tut.fi - * + * Marko Kiiskila carnil@cs.tut.fi + * * Tampere University of Technology - Telecommunications Laboratory * * Permission to use, copy, modify and distribute this @@ -12,15 +12,15 @@ * documentation, and that the use of this software is * acknowledged in any publications resulting from using * the software. - * + * * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS * SOFTWARE. - * + * */ -/* $Id: lane.h,v 1.3 2000/10/03 02:54:56 itojun Exp $ */ +/* $Id: lane.h,v 1.7 2002/12/11 07:13:54 guy Exp $ */ #ifndef ETHER_ADDR_LEN #define ETHER_ADDR_LEN 6 @@ -32,3 +32,10 @@ struct lecdatahdr_8023 { u_int8_t h_source[ETHER_ADDR_LEN]; u_int16_t h_type; }; + +struct lane_controlhdr { + u_int16_t lec_header; + u_int8_t lec_proto; + u_int8_t lec_vers; + u_int16_t lec_opcode; +}; diff --git a/contrib/tcpdump/lbl/os-osf4.h b/contrib/tcpdump/lbl/os-osf4.h new file mode 100644 index 0000000..62866ed --- /dev/null +++ b/contrib/tcpdump/lbl/os-osf4.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-osf4.h,v 1.1 2002/12/11 05:03:13 guy Exp $ (LBL) + */ + +/* Prototypes missing in Digital UNIX 4.x */ +int snprintf(char *, size_t, const char *, ...); +int vsnprintf(char *, size_t, const char *, va_list); diff --git a/contrib/tcpdump/llc.h b/contrib/tcpdump/llc.h index 6485d77..c114326 100644 --- a/contrib/tcpdump/llc.h +++ b/contrib/tcpdump/llc.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.13 2001/06/04 05:47:13 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.16 2002/12/11 07:13:54 guy Exp $ (LBL) */ /* @@ -127,6 +127,27 @@ struct llc { #define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */ #define OUI_CISCO 0x00000c /* Cisco protocols */ -#define ETHERTYPE_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */ #define OUI_CISCO_90 0x0000f8 /* Cisco bridging */ +#define OUI_RFC2684 0x0080c2 /* RFC 2684 bridged Ethernet */ #define OUI_APPLETALK 0x080007 /* Appletalk */ + +/* + * PIDs for use with OUI_CISCO. + */ +#define PID_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */ + +/* + * PIDs for use with OUI_RFC2684. + */ +#define PID_RFC2684_ETH_FCS 0x0001 /* Ethernet, with FCS */ +#define PID_RFC2684_ETH_NOFCS 0x0007 /* Ethernet, without FCS */ +#define PID_RFC2684_802_4_FCS 0x0002 /* 802.4, with FCS */ +#define PID_RFC2684_802_4_NOFCS 0x0008 /* 802.4, without FCS */ +#define PID_RFC2684_802_5_FCS 0x0003 /* 802.5, with FCS */ +#define PID_RFC2684_802_5_NOFCS 0x0009 /* 802.5, without FCS */ +#define PID_RFC2684_FDDI_FCS 0x0004 /* FDDI, with FCS */ +#define PID_RFC2684_FDDI_NOFCS 0x000a /* FDDI, without FCS */ +#define PID_RFC2684_802_6_FCS 0x0005 /* 802.6, with FCS */ +#define PID_RFC2684_802_6_NOFCS 0x000b /* 802.6, without FCS */ +#define PID_RFC2684_BPDU 0x000e /* BPDUs */ + diff --git a/contrib/tcpdump/machdep.c b/contrib/tcpdump/machdep.c index e86a84d..6c73ee7 100644 --- a/contrib/tcpdump/machdep.c +++ b/contrib/tcpdump/machdep.c @@ -20,24 +20,31 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.7 2001/06/27 05:42:04 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.10.2.3 2003/12/15 03:53:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> -#ifdef __osf__ -#include <sys/sysinfo.h> -#include <sys/proc.h> +/* + * XXX - all we need, on platforms other than DEC OSF/1 (a/k/a Digital UNIX, + * a/k/a Tru64 UNIX), is "size_t", which is a standard C type; what do we + * need to do to get it defined? This is clearly wrong, as we shouldn't + * have to include UNIX or Windows system header files to get it. + */ +#include <tcpdump-stdinc.h> -#if !defined(HAVE_SNPRINTF) #ifndef HAVE___ATTRIBUTE__ #define __attribute__(x) #endif /* HAVE___ATTRIBUTE__ */ +#ifdef __osf__ +#include <sys/sysinfo.h> +#include <sys/proc.h> + +#if !defined(HAVE_SNPRINTF) int snprintf(char *, size_t, const char *, ...) __attribute__((format(printf, 3, 4))); #endif /* !defined(HAVE_SNPRINTF) */ @@ -46,7 +53,7 @@ int snprintf(char *, size_t, const char *, ...) #include "machdep.h" int -abort_on_misalignment(char *ebuf, size_t ebufsiz) +abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_) { #ifdef __osf__ static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS }; diff --git a/contrib/tcpdump/missing/addrinfo.h b/contrib/tcpdump/missing/addrinfo.h index 7a32937..09f6a42 100644 --- a/contrib/tcpdump/missing/addrinfo.h +++ b/contrib/tcpdump/missing/addrinfo.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ -/* $Id: addrinfo.h,v 1.3 2000/10/24 00:56:52 fenner Exp $ */ +/* $Id: addrinfo.h,v 1.4 2002/06/11 17:13:36 itojun Exp $ */ #ifndef HAVE_ADDRINFO diff --git a/contrib/tcpdump/missing/addrsize.h b/contrib/tcpdump/missing/addrsize.h index 2880956..13db4da 100644 --- a/contrib/tcpdump/missing/addrsize.h +++ b/contrib/tcpdump/missing/addrsize.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -26,11 +26,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef INADDRSZ +#ifndef INADDRSZ #define INADDRSZ 4 /* IPv4 T_A */ #endif #ifndef IN6ADDRSZ #define IN6ADDRSZ 16 /* IPv6 T_AAAA */ -#endif +#endif diff --git a/contrib/tcpdump/missing/bittypes.h b/contrib/tcpdump/missing/bittypes.h index 500f39f..577da94 100644 --- a/contrib/tcpdump/missing/bittypes.h +++ b/contrib/tcpdump/missing/bittypes.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -38,7 +38,7 @@ typedef unsigned int u_int8_t; #endif /* HAVE_U_INT8_T */ -#ifndef HAVE_U_INT16_T +#ifndef HAVE_U_INT16_T #if SIZEOF_SHORT == 2 typedef unsigned short u_int16_t; diff --git a/contrib/tcpdump/missing/datalinks.c b/contrib/tcpdump/missing/datalinks.c new file mode 100644 index 0000000..9439142 --- /dev/null +++ b/contrib/tcpdump/missing/datalinks.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 + * 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 Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/datalinks.c,v 1.1.2.3 2003/11/16 09:29:48 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <stdlib.h> +#include <stdio.h> + +#include "pcap-missing.h" + +/* + * Stub versions for platforms that don't support them. + */ +int +pcap_list_datalinks(pcap_t *p, int **dlt_buffer) +{ + /* + * This platform doesn't support changing the DLT for an + * interface. Return a list of DLTs containing only the + * DLT this device supports. + */ + *dlt_buffer = (int*)malloc(sizeof(**dlt_buffer)); + if (*dlt_buffer == NULL) + return (-1); + **dlt_buffer = pcap_datalink(p); + return (1); +} diff --git a/contrib/tcpdump/missing/dlnames.c b/contrib/tcpdump/missing/dlnames.c new file mode 100644 index 0000000..97f3788 --- /dev/null +++ b/contrib/tcpdump/missing/dlnames.c @@ -0,0 +1,175 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 + * 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 Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/dlnames.c,v 1.2.2.3 2003/11/18 23:12:12 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <string.h> + +#include "pcap-missing.h" + +struct dlt_choice { + const char *name; + const char *description; + int dlt; +}; + +#define DLT_CHOICE(code, description) { #code, description, code } +#define DLT_CHOICE_SENTINEL { NULL, NULL, 0 } + +static struct dlt_choice dlt_choices[] = { + DLT_CHOICE(DLT_NULL, "BSD loopback"), + DLT_CHOICE(DLT_EN10MB, "Ethernet"), + DLT_CHOICE(DLT_IEEE802, "Token ring"), + DLT_CHOICE(DLT_ARCNET, "ARCNET"), + DLT_CHOICE(DLT_SLIP, "SLIP"), + DLT_CHOICE(DLT_PPP, "PPP"), + DLT_CHOICE(DLT_FDDI, "FDDI"), + DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 IP-over-ATM"), + DLT_CHOICE(DLT_RAW, "Raw IP"), +#ifdef DLT_SLIP_BSDOS + DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"), +#endif +#ifdef DLT_PPP_BSDOS + DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"), +#endif +#ifdef DLT_ATM_CLIP + DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"), +#endif +#ifdef DLT_PPP_SERIAL + DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"), +#endif +#ifdef DLT_PPP_ETHER + DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"), +#endif +#ifdef DLT_C_HDLC + DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"), +#endif +#ifdef DLT_IEEE802_11 + DLT_CHOICE(DLT_IEEE802_11, "802.11"), +#endif +#ifdef DLT_FRELAY + DLT_CHOICE(DLT_FRELAY, "Frame Relay"), +#endif +#ifdef DLT_LOOP + DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"), +#endif +#ifdef DLT_ENC + DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"), +#endif +#ifdef DLT_LINUX_SLL + DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"), +#endif +#ifdef DLT_LTALK + DLT_CHOICE(DLT_LTALK, "Localtalk"), +#endif +#ifdef DLT_PFLOG + DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"), +#endif +#ifdef DLT_PRISM_HEADER + DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"), +#endif +#ifdef DLT_IP_OVER_FC + DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"), +#endif +#ifdef DLT_SUNATM + DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"), +#endif +#ifdef DLT_IEEE802_11_RADIO + DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radio information header"), +#endif +#ifdef DLT_ARCNET_LINUX + DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"), +#endif +#ifdef DLT_LINUX_IRDA + DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"), +#endif +#ifdef DLT_LANE8023 + DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"), +#endif +#ifdef DLT_CIP + DLT_CHOICE(DLT_CIP, "Linux Classical IP-over-ATM"), +#endif +#ifdef DLT_HDLC + DLT_CHOICE(DLT_HDLC, "Cisco HDLC"), +#endif + DLT_CHOICE_SENTINEL +}; + +#ifndef HAVE_PCAP_DATALINK_NAME_TO_VAL +int +pcap_datalink_name_to_val(const char *name) +{ + int i; + + for (i = 0; dlt_choices[i].name != NULL; i++) { + if (strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1, + name) == 0) + return (dlt_choices[i].dlt); + } + return (-1); +} + +const char * +pcap_datalink_val_to_name(int dlt) +{ + int i; + + for (i = 0; dlt_choices[i].name != NULL; i++) { + if (dlt_choices[i].dlt == dlt) + return (dlt_choices[i].name + sizeof("DLT_") - 1); + } + return (NULL); +} +#endif + +const char * +pcap_datalink_val_to_description(int dlt) +{ + int i; + + for (i = 0; dlt_choices[i].name != NULL; i++) { + if (dlt_choices[i].dlt == dlt) + return (dlt_choices[i].description); + } + return (NULL); +} diff --git a/contrib/tcpdump/missing/getaddrinfo.c b/contrib/tcpdump/missing/getaddrinfo.c index 89b812d..2a9e0e1 100644 --- a/contrib/tcpdump/missing/getaddrinfo.c +++ b/contrib/tcpdump/missing/getaddrinfo.c @@ -1,7 +1,7 @@ /* * 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: @@ -13,7 +13,7 @@ * 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 @@ -47,11 +47,11 @@ #ifdef HAVE_CONFIG_H #include <config.h> -#endif +#endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.10 2000/10/24 00:56:53 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.11.2.2 2003/11/16 08:52:00 guy Exp $"; #endif #include <sys/types.h> @@ -76,11 +76,11 @@ static const char rcsid[] = #ifndef HAVE_U_INT32_T #include "bittypes.h" -#endif +#endif #ifndef HAVE_SOCKADDR_STORAGE #include "sockstorage.h" -#endif +#endif #ifdef NEED_ADDRINFO_H #include "addrinfo.h" @@ -104,7 +104,7 @@ 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 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 }; @@ -122,7 +122,7 @@ static const struct afd { int a_socklen; int a_off; const char *a_addrany; - const char *a_loopback; + const char *a_loopback; int a_scoped; } afdl [] = { #ifdef INET6 @@ -323,7 +323,7 @@ getaddrinfo(hostname, servname, hints, res) pai->ai_canonname = NULL; pai->ai_addr = NULL; pai->ai_next = NULL; - + if (hostname == NULL && servname == NULL) return EAI_NONAME; if (hints) { @@ -813,7 +813,7 @@ explore_numeric(pai, hostname, servname, res) } while (cur && cur->ai_next) cur = cur->ai_next; - } else + } else ERR(EAI_FAMILY); /*xxx*/ } @@ -948,7 +948,7 @@ get_name(addr, afd, res, numaddr, pai, servname) GET_AI(cur, afd, numaddr); GET_PORT(cur, servname); } - + #ifdef USE_GETIPNODEBY if (hp) freehostent(hp); diff --git a/contrib/tcpdump/missing/getnameinfo.c b/contrib/tcpdump/missing/getnameinfo.c index 502ac7f..f39770c 100644 --- a/contrib/tcpdump/missing/getnameinfo.c +++ b/contrib/tcpdump/missing/getnameinfo.c @@ -1,7 +1,7 @@ /* * 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: @@ -13,7 +13,7 @@ * 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 @@ -39,11 +39,11 @@ #ifdef HAVE_CONFIG_H #include <config.h> -#endif +#endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.8 2000/10/24 00:56:53 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.9.2.2 2003/11/16 08:52:00 guy Exp $"; #endif #include <sys/types.h> @@ -124,7 +124,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) if (sa->sa_len != salen) return ENI_SALEN; #endif - + family = sa->sa_family; for (i = 0; afdl[i].a_af; i++) if (afdl[i].a_af == family) { @@ -132,11 +132,11 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) goto found; } return ENI_FAMILY; - + found: if (salen != afd->a_socklen) return ENI_SALEN; - + port = ((struct sockinet *)sa)->si_port; /* network byte order */ addr = (char *)sa + afd->a_off; @@ -174,7 +174,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) flags |= NI_NUMERICHOST; v4a >>= IN_CLASSA_NSHIFT; if (v4a == 0) - flags |= NI_NUMERICHOST; + flags |= NI_NUMERICHOST; break; #ifdef INET6 case AF_INET6: diff --git a/contrib/tcpdump/missing/inet_aton.c b/contrib/tcpdump/missing/inet_aton.c index 3d4ebf9..b12c105 100644 --- a/contrib/tcpdump/missing/inet_aton.c +++ b/contrib/tcpdump/missing/inet_aton.c @@ -2,27 +2,27 @@ * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Kungliga Tekniska * Högskolan and its contributors. - * + * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -36,17 +36,14 @@ * SUCH DAMAGE. */ -/* $Id: inet_aton.c,v 1.2 2000/01/09 21:35:45 fenner Exp $ */ +/* $Id: inet_aton.c,v 1.4.2.2 2003/11/16 08:52:01 guy Exp $ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.2 2000/01/09 21:35:45 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.4.2.2 2003/11/16 08:52:01 guy Exp $"; #endif -#include <sys/types.h> -#include <netinet/in.h> -#include <netdb.h> -#include <arpa/inet.h> +#include <tcpdump-stdinc.h> /* Minimal implementation of inet_aton. * Cannot distinguish between failure and a local broadcast address. */ diff --git a/contrib/tcpdump/missing/inet_ntop.c b/contrib/tcpdump/missing/inet_ntop.c index a43c429..175face 100644 --- a/contrib/tcpdump/missing/inet_ntop.c +++ b/contrib/tcpdump/missing/inet_ntop.c @@ -2,27 +2,27 @@ * Copyright (c) 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Kungliga Tekniska * Högskolan and its contributors. - * + * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -36,18 +36,17 @@ * SUCH DAMAGE. */ -/* $Id: inet_ntop.c,v 1.3 2000/01/09 21:35:45 fenner Exp $ */ +/* $Id: inet_ntop.c,v 1.5.2.2 2003/11/16 08:52:01 guy Exp $ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.3 2000/01/09 21:35:45 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.5.2.2 2003/11/16 08:52:01 guy Exp $"; #endif +#include <tcpdump-stdinc.h> + #include <stdio.h> #include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> /* * diff --git a/contrib/tcpdump/missing/inet_pton.c b/contrib/tcpdump/missing/inet_pton.c index 34ec0af..f1eecf1 100644 --- a/contrib/tcpdump/missing/inet_pton.c +++ b/contrib/tcpdump/missing/inet_pton.c @@ -2,27 +2,27 @@ * Copyright (c) 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Kungliga Tekniska * Högskolan and its contributors. - * + * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -36,17 +36,16 @@ * SUCH DAMAGE. */ -/* $Id: inet_pton.c,v 1.2 2000/01/09 21:35:46 fenner Exp $ */ +/* $Id: inet_pton.c,v 1.4.2.2 2003/11/16 08:52:01 guy Exp $ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.2 2000/01/09 21:35:46 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.4.2.2 2003/11/16 08:52:01 guy Exp $"; #endif +#include <tcpdump-stdinc.h> + #include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> int inet_pton(int af, const char *src, void *dst) diff --git a/contrib/tcpdump/missing/resolv6.h b/contrib/tcpdump/missing/resolv6.h index b1d45c0..ccee03e 100644 --- a/contrib/tcpdump/missing/resolv6.h +++ b/contrib/tcpdump/missing/resolv6.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -33,4 +33,4 @@ */ #ifndef HAVE_RES_USE_INET6 #define RES_USE_INET6 0x80000000 /* use/map IPv6 in gethostbyname() */ -#endif +#endif diff --git a/contrib/tcpdump/missing/resolv_ext.h b/contrib/tcpdump/missing/resolv_ext.h index c33ed7e..92c531d 100644 --- a/contrib/tcpdump/missing/resolv_ext.h +++ b/contrib/tcpdump/missing/resolv_ext.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -29,7 +29,7 @@ #ifndef MAXRESOLVSORT /* XXX */ #define MAXRESOLVSORT 10 /* number of net to sort on */ -#endif +#endif #ifndef HAVE_RES_STATE_EXT struct __res_state_ext { @@ -40,10 +40,10 @@ struct __res_state_ext { struct in_addr ina; #ifdef INET6 struct in6_addr in6a; -#endif +#endif } addr, mask; } sort_list[MAXRESOLVSORT]; }; -#endif +#endif extern struct __res_state_ext _res_ext; diff --git a/contrib/tcpdump/missing/snprintf.c b/contrib/tcpdump/missing/snprintf.c index 1d4ab71..c569bb8 100644 --- a/contrib/tcpdump/missing/snprintf.c +++ b/contrib/tcpdump/missing/snprintf.c @@ -2,22 +2,22 @@ * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -31,15 +31,15 @@ * SUCH DAMAGE. */ -/* $Id: snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $ */ +/* $Id: snprintf.c,v 1.6.2.2 2003/11/16 08:52:02 guy Exp $ */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.6.2.2 2003/11/16 08:52:02 guy Exp $"; #endif #include <stdio.h> @@ -214,7 +214,7 @@ append_number(struct state *state, state->s[-i-1] = state->s[-len+i]; state->s[-len+i] = c; } - + return 0; } @@ -258,13 +258,13 @@ append_char(struct state *state, while(!(flags & minus_flag) && --width > 0) if((*state->append_char) (state, ' ')) return 1; - + if((*state->append_char) (state, arg)) return 1; while((flags & minus_flag) && --width > 0) if((*state->append_char) (state, ' ')) return 1; - + return 0; } @@ -313,7 +313,7 @@ xyzprintf (struct state *state, const char *char_format, va_list ap) else break; } - + if((flags & space_flag) && (flags & plus_flag)) flags ^= space_flag; @@ -365,7 +365,7 @@ xyzprintf (struct state *state, const char *char_format, va_list ap) if (append_string(state, va_arg(ap, unsigned char*), width, - prec, + prec, flags)) return -1; break; diff --git a/contrib/tcpdump/missing/sockstorage.h b/contrib/tcpdump/missing/sockstorage.h index 557eb4d..e733328 100644 --- a/contrib/tcpdump/missing/sockstorage.h +++ b/contrib/tcpdump/missing/sockstorage.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -28,11 +28,11 @@ */ struct sockaddr_storage { #ifdef HAVE_SOCKADDR_SA_LEN - u_int8_t __ss_len; - u_int8_t __ss_family; + u_int8_t ss_len; + u_int8_t ss_family; u_int8_t fill[126]; #else - u_int8_t __ss_family; + u_int8_t ss_family; u_int8_t fill[127]; #endif /* HAVE_SOCKADDR_SA_LEN */ }; diff --git a/contrib/tcpdump/missing/strlcat.c b/contrib/tcpdump/missing/strlcat.c index 92f46a9..7e9cdba 100644 --- a/contrib/tcpdump/missing/strlcat.c +++ b/contrib/tcpdump/missing/strlcat.c @@ -29,16 +29,17 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcat.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcat.c,v 1.3.2.2 2003/11/16 08:52:03 guy Exp $ (LBL)"; #endif +#ifdef HAVE_CONFIG_H #include <config.h> +#endif -#include <sys/types.h> -#include <string.h> +#include <tcpdump-stdinc.h> -#include "interface.h" +#include <string.h> /* * Appends src to string dst of size siz (unlike strncat, siz is the @@ -47,10 +48,7 @@ static const char rcsid[] = * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t -strlcat(dst, src, siz) - char *dst; - const char *src; - size_t siz; +strlcat(char *dst, const char *src, size_t siz) { register char *d = dst; register const char *s = src; diff --git a/contrib/tcpdump/missing/strlcpy.c b/contrib/tcpdump/missing/strlcpy.c index f55121d..12747dd 100644 --- a/contrib/tcpdump/missing/strlcpy.c +++ b/contrib/tcpdump/missing/strlcpy.c @@ -29,16 +29,17 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcpy.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcpy.c,v 1.3.2.2 2003/11/16 08:52:03 guy Exp $ (LBL)"; #endif +#ifdef HAVE_CONFIG_H #include <config.h> +#endif -#include <sys/types.h> -#include <string.h> +#include <tcpdump-stdinc.h> -#include "interface.h" +#include <string.h> /* * Copy src to string dst of size siz. At most siz-1 characters @@ -46,10 +47,7 @@ static const char rcsid[] = * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t -strlcpy(dst, src, siz) - char *dst; - const char *src; - size_t siz; +strlcpy(char *dst, const char *src, size_t siz) { register char *d = dst; register const char *s = src; diff --git a/contrib/tcpdump/missing/strsep.c b/contrib/tcpdump/missing/strsep.c new file mode 100644 index 0000000..19fb6b2 --- /dev/null +++ b/contrib/tcpdump/missing/strsep.c @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[] = + "@(#) $Header: /tcpdump/master/tcpdump/missing/strsep.c,v 1.3 2003/03/25 08:33:48 guy Exp $ (LBL)"; +#endif /* LIBC_SCCS and not lint */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <tcpdump-stdinc.h> + +#include <string.h> + +/* + * Get next token from string *stringp, where tokens are possibly-empty + * strings separated by characters from delim. + * + * Writes NULs into the string at *stringp to end tokens. + * delim need not remain constant from call to call. + * On return, *stringp points past the last NUL written (if there might + * be further tokens), or is NULL (if there are definitely no more tokens). + * + * If *stringp is NULL, strsep returns NULL. + */ +char * +strsep(char **stringp, const char *delim) +{ + register char *s; + register const char *spanp; + register int c, sc; + char *tok; + + if ((s = *stringp) == NULL) + return (NULL); + for (tok = s;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + *stringp = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} diff --git a/contrib/tcpdump/nameser.h b/contrib/tcpdump/nameser.h index b8e157d..2b94ee3 100644 --- a/contrib/tcpdump/nameser.h +++ b/contrib/tcpdump/nameser.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.9 2001/06/27 05:40:16 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14 2003/11/05 06:02:59 guy Exp $ (LBL) */ /* * Copyright (c) 1983, 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -34,14 +34,14 @@ * @(#)nameser.h 8.2 (Berkeley) 2/16/94 * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. - * + * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT @@ -75,6 +75,7 @@ * Internet nameserver port number */ #define NAMESERVER_PORT 53 +#define MULTICASTDNS_PORT 5353 /* * Currently defined opcodes @@ -189,6 +190,7 @@ #define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ /* Query class values which do not appear in resource records */ #define C_ANY 255 /* wildcard match */ +#define C_CACHE_FLUSH 0x8000 /* mDNS cache flush flag */ /* * Status return codes for T_UNSPEC conversion routines @@ -231,7 +233,7 @@ typedef struct { */ #define INDIR_MASK 0xc0 /* 11.... */ #define EDNS0_MASK 0x40 /* 01.... */ -# define EDNS0_ELT_BITLABEL 0x01 +# define EDNS0_ELT_BITLABEL 0x01 /* * Structure for passing resource records around. diff --git a/contrib/tcpdump/netbios.h b/contrib/tcpdump/netbios.h index b2a1d71..34abeba 100644 --- a/contrib/tcpdump/netbios.h +++ b/contrib/tcpdump/netbios.h @@ -1,7 +1,7 @@ /* * NETBIOS protocol formats * - * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $ + * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002/12/11 07:13:55 guy Exp $ */ struct p8022Hdr { diff --git a/contrib/tcpdump/ntp.h b/contrib/tcpdump/ntp.h index 3a574ed..f195d6d 100644 --- a/contrib/tcpdump/ntp.h +++ b/contrib/tcpdump/ntp.h @@ -1,4 +1,4 @@ -/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.4 2000/10/03 02:54:57 itojun Exp $ */ +/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.7 2003/08/06 04:58:21 guy Exp $ */ /* * Based on ntp.h from the U of MD implementation @@ -8,7 +8,7 @@ /* * Definitions for the masses */ -#define JAN_1970 2208988800 /* 1970 - 1900 in seconds */ +#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */ /* * Structure definitions for NTP fixed point values diff --git a/contrib/tcpdump/oakley.h b/contrib/tcpdump/oakley.h index b2d0639..f40d607 100644 --- a/contrib/tcpdump/oakley.h +++ b/contrib/tcpdump/oakley.h @@ -1,7 +1,7 @@ /* * 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: @@ -13,7 +13,7 @@ * 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 @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* YIPS @(#)$Id: oakley.h,v 1.1 1999/10/30 05:11:10 itojun Exp $ */ +/* YIPS @(#)$Id: oakley.h,v 1.4 2002/12/11 07:13:56 guy Exp $ */ /* refer to RFC 2409 */ diff --git a/contrib/tcpdump/ospf.h b/contrib/tcpdump/ospf.h index 69e474e..40c75c9 100644 --- a/contrib/tcpdump/ospf.h +++ b/contrib/tcpdump/ospf.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.11 2003/10/22 17:08:46 hannes Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -21,25 +21,34 @@ * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ -#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */ -#define OSPF_TYPE_HELLO 1 /* Hello */ -#define OSPF_TYPE_DB 2 /* Database Description */ -#define OSPF_TYPE_LSR 3 /* Link State Request */ -#define OSPF_TYPE_LSU 4 /* Link State Update */ -#define OSPF_TYPE_LSA 5 /* Link State Ack */ -#define OSPF_TYPE_MAX 6 - -/* Options *_options */ +#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */ +#define OSPF_TYPE_HELLO 1 /* Hello */ +#define OSPF_TYPE_DD 2 /* Database Description */ +#define OSPF_TYPE_LS_REQ 3 /* Link State Request */ +#define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */ +#define OSPF_TYPE_LS_ACK 5 /* Link State Ack */ + +/* Options field + * + * +------------------------------------+ + * | * | O | DC | EA | N/P | MC | E | T | + * +------------------------------------+ + * + */ + #define OSPF_OPTION_T 0x01 /* T bit: TOS support */ #define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */ #define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */ +#define OSPF_OPTION_NP 0x08 /* N/P bit: NSSA capable */ +#define OSPF_OPTION_EA 0x10 /* EA bit: External Attribute capable */ +#define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuit capable */ +#define OSPF_OPTION_O 0x40 /* O bit: Opaque LSA capable */ /* ospf_authtype */ #define OSPF_AUTH_NONE 0 /* No auth-data */ #define OSPF_AUTH_SIMPLE 1 /* Simple password */ #define OSPF_AUTH_MD5 2 /* MD5 authentication */ -#define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ - +#define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ /* db_flags */ #define OSPF_DB_INIT 0x04 /* */ @@ -54,7 +63,33 @@ #define LS_TYPE_ASE 5 /* ASE */ #define LS_TYPE_GROUP 6 /* Group membership (multicast */ /* extensions 23 July 1991) */ -#define LS_TYPE_MAX 7 +#define LS_TYPE_NSSA 7 /* rfc1587 - Not so Stubby Areas */ +#define LS_TYPE_OPAQUE_LL 9 /* rfc2370 - Opaque Link Local */ +#define LS_TYPE_OPAQUE_AL 10 /* rfc2370 - Opaque Link Local */ +#define LS_TYPE_OPAQUE_DW 11 /* rfc2370 - Opaque Domain Wide */ + +#define LS_OPAQUE_TYPE_TE 1 /* rfc3630 */ +#define LS_OPAQUE_TYPE_GRACE 3 /* draft-ietf-ospf-hitless-restart */ + +#define LS_OPAQUE_TE_TLV_ROUTER 1 /* rfc3630 */ +#define LS_OPAQUE_TE_TLV_LINK 2 /* rfc3630 */ + +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE 1 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID 2 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP 3 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP 4 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC 5 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW 6 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW 7 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW 8 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP 9 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID 11 /* draft-ietf-ccamp-ospf-gmpls-extensions */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* draft-ietf-ccamp-ospf-gmpls-extensions */ +#define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR 15 /* draft-ietf-ccamp-ospf-gmpls-extensions */ +#define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP 16 /* draft-ietf-ccamp-ospf-gmpls-extensions */ + +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP 1 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA 2 /* rfc3630 */ /************************************************* * @@ -95,12 +130,18 @@ struct lsa_hdr { u_int16_t ls_age; u_int8_t ls_options; u_int8_t ls_type; - struct in_addr ls_stateid; + union { + struct in_addr lsa_id; + struct { /* opaque LSAs change the LSA-ID field */ + u_int8_t opaque_type; + u_int8_t opaque_id[3]; + } opaque_field; + } un_lsa_id; struct in_addr ls_router; u_int32_t ls_seq; u_int16_t ls_chksum; u_int16_t ls_length; -} ; +}; /* link state advertisement */ struct lsa { @@ -149,8 +190,21 @@ struct lsa { u_int32_t mcla_vtype; struct in_addr mcla_vid; } un_mcla[1]; + + /* Opaque TE LSA */ + struct { + u_int16_t type; + u_int16_t length; + u_int8_t data[1]; /* may repeat */ + } un_te_lsa_tlv; + + /* Unknown LSA */ + struct unknown { + u_int8_t data[1]; /* may repeat */ + } un_unknown[1]; + } lsa_un; -} ; +}; /* @@ -160,7 +214,7 @@ struct tos_metric { u_int8_t tos_type; u_int8_t tos_zero; u_int16_t tos_metric; -} ; +}; #define OSPF_AUTH_SIZE 8 @@ -201,8 +255,14 @@ struct ospfhdr { /* Link State Request */ struct lsr { - u_int32_t ls_type; - struct in_addr ls_stateid; + u_int8_t ls_type[4]; + union { + struct in_addr ls_stateid; + struct { /* opaque LSAs change the LSA-ID field */ + u_int8_t opaque_type; + u_int8_t opaque_id[3]; + } opaque_field; + } un_ls_stateid; struct in_addr ls_router; } un_lsr[1]; /* may repeat */ @@ -217,7 +277,7 @@ struct ospfhdr { struct lsa_hdr lsa_lshdr[1]; /* may repeat */ } un_lsa ; } ospf_un ; -} ; +}; #define ospf_hello ospf_un.un_hello #define ospf_db ospf_un.un_db diff --git a/contrib/tcpdump/ospf6.h b/contrib/tcpdump/ospf6.h index 3d810cf..b8298ea 100644 --- a/contrib/tcpdump/ospf6.h +++ b/contrib/tcpdump/ospf6.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.6 2002/12/11 07:13:56 guy Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -105,7 +105,7 @@ struct lsa_hdr { u_int32_t ls_seq; u_int16_t ls_chksum; u_int16_t ls_length; -} ; +}; struct lsa_prefix { u_int8_t lsa_p_len; @@ -153,7 +153,7 @@ struct lsa { /* AS external links advertisements */ struct { u_int32_t asla_metric; - struct lsa_prefix asla_prefix[1]; + struct lsa_prefix asla_prefix[1]; /* some optional fields follow */ } un_asla; @@ -195,7 +195,7 @@ struct lsa { struct lsa_prefix intra_ap_prefix[1]; } un_intra_ap; } lsa_un; -} ; +}; /* @@ -205,7 +205,7 @@ struct tos_metric { u_int8_t tos_type; u_int8_t tos_zero; u_int16_t tos_metric; -} ; +}; #define OSPF_AUTH_SIZE 8 @@ -268,7 +268,7 @@ struct ospf6hdr { struct lsa_hdr lsa_lshdr[1]; /* may repeat */ } un_lsa ; } ospf6_un ; -} ; +}; #define ospf6_hello ospf6_un.un_hello #define ospf6_db ospf6_un.un_db diff --git a/contrib/tcpdump/oui.c b/contrib/tcpdump/oui.c new file mode 100644 index 0000000..3348bd2 --- /dev/null +++ b/contrib/tcpdump/oui.c @@ -0,0 +1,62 @@ +/* + * 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. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.2.2.1 2004/02/06 14:38:51 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> +#include "interface.h" +#include "oui.h" + +/* FIXME complete OUI list using a script */ + +struct tok oui_values[] = { + { 0x009069, "Juniper"}, + { 0x00000c, "Cisco"}, +}; + +/* list taken from ethereal/packet-radius.c */ + +struct tok smi_values[] = { + { SMI_ACC, "ACC"}, + { SMI_CISCO, "Cisco"}, + { SMI_SHIVA, "Shiva"}, + { SMI_MICROSOFT, "Microsoft"}, + { SMI_LIVINGSTON, "Livingston"}, + { SMI_3COM, "3Com"}, + { SMI_ASCEND, "Ascend"}, + { SMI_BAY, "Bay Networks"}, + { SMI_FOUNDRY, "Foundry"}, + { SMI_VERSANET, "Versanet"}, + { SMI_REDBACK, "Redback"}, + { SMI_JUNIPER, "Juniper Networks"}, + { SMI_APTIS, "Aptis"}, + { SMI_COSINE, "CoSine Communications"}, + { SMI_SHASTA, "Shasta"}, + { SMI_NOMADIX, "Nomadix"}, + { SMI_UNISPHERE, "Unisphere Networks"}, + { SMI_ISSANNI, "Issanni Communications"}, + { SMI_QUINTUM, "Quintum"}, + { SMI_COLUBRIS, "Colubris"}, + { SMI_COLUMBIA_UNIVERSITY, "Columbia University"}, + { SMI_THE3GPP, "3GPP"}, + { 0, NULL } +}; diff --git a/contrib/tcpdump/oui.h b/contrib/tcpdump/oui.h new file mode 100644 index 0000000..39df977 --- /dev/null +++ b/contrib/tcpdump/oui.h @@ -0,0 +1,41 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.2.2.1 2004/02/06 14:38:50 hannes Exp $ (LBL) */ +/* + * 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. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +extern struct tok oui_values[]; +extern struct tok smi_values[]; + +#define SMI_ACC 5 +#define SMI_CISCO 9 +#define SMI_SHIVA 166 +#define SMI_LIVINGSTON 307 +#define SMI_MICROSOFT 311 +#define SMI_3COM 429 +#define SMI_ASCEND 529 +#define SMI_BAY 1584 +#define SMI_FOUNDRY 1991 +#define SMI_VERSANET 2180 +#define SMI_REDBACK 2352 +#define SMI_JUNIPER 2636 +#define SMI_APTIS 2637 +#define SMI_COSINE 3085 +#define SMI_SHASTA 3199 +#define SMI_NOMADIX 3309 +#define SMI_UNISPHERE 4874 +#define SMI_ISSANNI 5948 +#define SMI_QUINTUM 6618 +#define SMI_COLUBRIS 8744 +#define SMI_COLUMBIA_UNIVERSITY 11862 +#define SMI_THE3GPP 10415 diff --git a/contrib/tcpdump/pcap-missing.h b/contrib/tcpdump/pcap-missing.h new file mode 100644 index 0000000..adf24d8 --- /dev/null +++ b/contrib/tcpdump/pcap-missing.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1988-2002 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.1.2.1 2003/11/18 23:12:11 guy Exp $ (LBL) + */ + +#ifndef tcpdump_pcap_missing_h +#define tcpdump_pcap_missing_h + +/* + * Declarations of functions that might be missing from libpcap. + */ + +#ifndef HAVE_PCAP_LIST_DATALINKS +extern int pcap_list_datalinks(pcap_t *, int **); +#endif + +#ifndef HAVE_PCAP_DATALINK_NAME_TO_VAL +/* + * We assume no platform has one but not the other. + */ +extern int pcap_datalink_name_to_val(const char *); +extern const char *pcap_datalink_val_to_name(int); +#endif + +#ifndef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION +extern const char *pcap_datalink_val_to_description(int); +#endif + +#endif + + + + + + + + + diff --git a/contrib/tcpdump/pf.h b/contrib/tcpdump/pf.h new file mode 100644 index 0000000..314802c --- /dev/null +++ b/contrib/tcpdump/pf.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2001 Daniel Hartmeier + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @(#) $Header: /tcpdump/master/tcpdump/pf.h,v 1.1.2.1 2004/03/28 21:25:03 fenner Exp $ (LBL) + */ + +/* from $OpenBSD: pfvar.h,v 1.170 2003/08/22 21:50:34 david Exp $ */ + +enum { PF_INOUT=0, PF_IN=1, PF_OUT=2 }; +enum { PF_PASS=0, PF_DROP=1, PF_SCRUB=2, PF_NAT=3, PF_NONAT=4, + PF_BINAT=5, PF_NOBINAT=6, PF_RDR=7, PF_NORDR=8, PF_SYNPROXY_DROP=9 }; + +/* Reasons code for passing/dropping a packet */ +#define PFRES_MATCH 0 /* Explicit match of a rule */ +#define PFRES_BADOFF 1 /* Bad offset for pull_hdr */ +#define PFRES_FRAG 2 /* Dropping following fragment */ +#define PFRES_SHORT 3 /* Dropping short packet */ +#define PFRES_NORM 4 /* Dropping by normalizer */ +#define PFRES_MEMORY 5 /* Dropped due to lacking mem */ +#define PFRES_MAX 6 /* total+1 */ + +#define PFRES_NAMES { \ + "match", \ + "bad-offset", \ + "fragment", \ + "short", \ + "normalize", \ + "memory", \ + NULL \ +} + +#define PF_RULESET_NAME_SIZE 16 + +/* from $OpenBSD: if_pflog.h,v 1.9 2003/07/15 20:27:27 dhartmei Exp $ */ + +#ifndef IFNAMSIZ +#define IFNAMSIZ 16 +#endif + +struct pfloghdr { + u_int8_t length; + sa_family_t af; + u_int8_t action; + u_int8_t reason; + char ifname[IFNAMSIZ]; + char ruleset[PF_RULESET_NAME_SIZE]; + u_int32_t rulenr; + u_int32_t subrulenr; + u_int8_t dir; + u_int8_t pad[3]; +}; +#define PFLOG_HDRLEN sizeof(struct pfloghdr) diff --git a/contrib/tcpdump/print-802_11.c b/contrib/tcpdump/print-802_11.c index b8c03d8..56462c9 100644 --- a/contrib/tcpdump/print-802_11.c +++ b/contrib/tcpdump/print-802_11.c @@ -21,19 +21,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.6.4.1 2002/05/13 08:34:50 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.22.2.6 2003/12/10 09:52:33 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <pcap.h> @@ -50,9 +46,10 @@ static const char rcsid[] = #define PRINT_RATES(p) \ do { \ int z; \ - char *sep = " ["; \ + const char *sep = " ["; \ for (z = 0; z < p.rates.length ; z++) { \ printf("%s%2.1f", sep, (.5 * (p.rates.rate[z] & 0x7f))); \ + if (p.rates.rate[z] & 0x80) printf("*"); \ sep = " "; \ } \ if (p.rates.length != 0) \ @@ -67,15 +64,15 @@ static const char *subtype_text[]={ "ReAssoc Response", "Probe Request", "Probe Response", - "RESERVED", - "RESERVED", + "", + "", "Beacon", "ATIM", "Disassociation", "Authentication", "DeAuthentication", - "RESERVED", - "RESERVED" + "", + "" }; static const char *status_text[] = { @@ -117,11 +114,12 @@ static const char *reason_text[] = { NULL }; -static int wep_print(const u_char *p,u_int length) +static int +wep_print(const u_char *p) { u_int32_t iv; - if (!TTEST2(*p, 4)) + if (!TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN)) return 0; iv = EXTRACT_LE_32BITS(p); @@ -131,79 +129,90 @@ static int wep_print(const u_char *p,u_int length) return 1; } - -static int 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) { for (;;) { if (!TTEST2(*(p + offset), 1)) return 1; switch (*(p + offset)) { case E_SSID: - if (!TTEST2(*(p+offset), 2)) + if (!TTEST2(*(p + offset), 2)) return 0; - memcpy(&(pbody->ssid),p+offset,2); offset += 2; - if (pbody->ssid.length > 0) - { - if (!TTEST2(*(p+offset), pbody->ssid.length)) - return 0; - memcpy(&(pbody->ssid.ssid),p+offset,pbody->ssid.length); offset += pbody->ssid.length; - pbody->ssid.ssid[pbody->ssid.length]='\0'; - } + memcpy(&pbody->ssid, p + offset, 2); + offset += 2; + if (pbody->ssid.length <= 0) + break; + if (!TTEST2(*(p + offset), pbody->ssid.length)) + return 0; + memcpy(&pbody->ssid.ssid, p + offset, + pbody->ssid.length); + offset += pbody->ssid.length; + pbody->ssid.ssid[pbody->ssid.length] = '\0'; break; case E_CHALLENGE: - if (!TTEST2(*(p+offset), 2)) + if (!TTEST2(*(p + offset), 2)) return 0; - memcpy(&(pbody->challenge),p+offset,2); offset += 2; - if (pbody->challenge.length > 0) - { - if (!TTEST2(*(p+offset), pbody->challenge.length)) - return 0; - memcpy(&(pbody->challenge.text),p+offset,pbody->challenge.length); offset += pbody->challenge.length; - pbody->challenge.text[pbody->challenge.length]='\0'; - } + memcpy(&pbody->challenge, p + offset, 2); + offset += 2; + if (pbody->challenge.length <= 0) + break; + if (!TTEST2(*(p + offset), pbody->challenge.length)) + return 0; + memcpy(&pbody->challenge.text, p + offset, + pbody->challenge.length); + offset += pbody->challenge.length; + pbody->challenge.text[pbody->challenge.length] = '\0'; break; case E_RATES: - if (!TTEST2(*(p+offset), 2)) + if (!TTEST2(*(p + offset), 2)) return 0; - memcpy(&(pbody->rates),p+offset,2); offset += 2; - if (pbody->rates.length > 0) { - if (!TTEST2(*(p+offset), pbody->rates.length)) - return 0; - memcpy(&(pbody->rates.rate),p+offset,pbody->rates.length); offset += pbody->rates.length; - } + memcpy(&(pbody->rates), p + offset, 2); + offset += 2; + if (pbody->rates.length <= 0) + break; + if (!TTEST2(*(p + offset), pbody->rates.length)) + return 0; + memcpy(&pbody->rates.rate, p + offset, + pbody->rates.length); + offset += pbody->rates.length; break; case E_DS: - if (!TTEST2(*(p+offset), 3)) + if (!TTEST2(*(p + offset), 3)) return 0; - memcpy(&(pbody->ds),p+offset,3); offset +=3; + memcpy(&pbody->ds, p + offset, 3); + offset += 3; break; case E_CF: - if (!TTEST2(*(p+offset), 8)) + if (!TTEST2(*(p + offset), 8)) return 0; - memcpy(&(pbody->cf),p+offset,8); offset +=8; + memcpy(&pbody->cf, p + offset, 8); + offset += 8; break; case E_TIM: - if (!TTEST2(*(p+offset), 2)) + if (!TTEST2(*(p + offset), 2)) return 0; - memcpy(&(pbody->tim),p+offset,2); offset +=2; - if (!TTEST2(*(p+offset), 3)) + memcpy(&pbody->tim, p + offset, 2); + offset += 2; + if (!TTEST2(*(p + offset), 3)) return 0; - memcpy(&(pbody->tim.count),p+offset,3); offset +=3; - - if ((pbody->tim.length -3) > 0) - { - if (!TTEST2(*(p+offset), pbody->tim.length -3)) - return 0; - memcpy((pbody->tim.bitmap),p+(pbody->tim.length -3),(pbody->tim.length -3)); - offset += pbody->tim.length -3; - } + memcpy(&pbody->tim.count, p + offset, 3); + offset += 3; + if (pbody->tim.length <= 3) + break; + if (!TTEST2(*(p + offset), pbody->tim.length - 3)) + return 0; + memcpy(pbody->tim.bitmap, p + (pbody->tim.length - 3), + (pbody->tim.length - 3)); + offset += pbody->tim.length - 3; break; default: #if 0 - printf("(1) unhandled element_id (%d) ", *(p+offset) ); + printf("(1) unhandled element_id (%d) ", + *(p + offset) ); #endif - offset+= *(p+offset+1) + 2; + offset += *(p + offset + 1) + 2; break; } } @@ -214,31 +223,32 @@ static int parse_elements(struct mgmt_body_t *pbody,const u_char *p,int offset) * Print Handle functions for the management frame types *********************************************************************************/ -static int handle_beacon(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_beacon(const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); - if (!TTEST2(*p, 12)) + if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + + IEEE802_11_CAPINFO_LEN)) return 0; memcpy(&pbody.timestamp, p, 8); - offset += 8; + offset += IEEE802_11_TSTAMP_LEN; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); - offset += 2; + offset += IEEE802_11_BCNINT_LEN; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); - offset += 2; + offset += IEEE802_11_CAPINFO_LEN; - if (!parse_elements(&pbody,p,offset)) + if (!parse_elements(&pbody, p, offset)) return 0; - printf("%s (", subtype_text[FC_SUBTYPE(fc)]); + printf(" ("); fn_print(pbody.ssid.ssid, NULL); printf(")"); PRINT_RATES(pbody); - printf(" %s CH: %u %s", + printf(" %s CH: %u%s", CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS", pbody.ds.channel, CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" ); @@ -246,96 +256,96 @@ static int handle_beacon(u_int16_t fc, const struct mgmt_header_t *pmh, return 1; } -static int handle_assoc_request(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_assoc_request(const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); - if (!TTEST2(*p, 4)) + if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); - offset += 2; + offset += IEEE802_11_CAPINFO_LEN; pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); - offset += 2; + offset += IEEE802_11_LISTENINT_LEN; - if (!parse_elements(&pbody,p,offset)) + if (!parse_elements(&pbody, p, offset)) return 0; - printf("%s (", subtype_text[FC_SUBTYPE(fc)]); + printf(" ("); fn_print(pbody.ssid.ssid, NULL); printf(")"); PRINT_RATES(pbody); return 1; } -static int handle_assoc_response(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_assoc_response(const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); - if (!TTEST2(*p, 6)) + if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN + + IEEE802_11_AID_LEN)) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); - offset += 2; + offset += IEEE802_11_CAPINFO_LEN; pbody.status_code = EXTRACT_LE_16BITS(p+offset); - offset += 2; + offset += IEEE802_11_STATUS_LEN; pbody.aid = EXTRACT_LE_16BITS(p+offset); - offset += 2; + offset += IEEE802_11_AID_LEN; - if (!parse_elements(&pbody,p,offset)) + if (!parse_elements(&pbody, p, offset)) return 0; - printf("%s AID(%x) :%s: %s", subtype_text[FC_SUBTYPE(fc)], - ((u_int16_t)(pbody.aid << 2 )) >> 2 , + printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 , CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "", (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a")); return 1; } - -static int handle_reassoc_request(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_reassoc_request(const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); - if (!TTEST2(*p, 10)) + if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN + + IEEE802_11_AP_LEN)) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); - offset += 2; + offset += IEEE802_11_CAPINFO_LEN; pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); - offset += 2; - memcpy(&pbody.ap,p+offset,6); - offset += 6; + offset += IEEE802_11_LISTENINT_LEN; + memcpy(&pbody.ap, p+offset, IEEE802_11_AP_LEN); + offset += IEEE802_11_AP_LEN; - if (!parse_elements(&pbody,p,offset)) + if (!parse_elements(&pbody, p, offset)) return 0; - printf("%s (", subtype_text[FC_SUBTYPE(fc)]); + printf(" ("); fn_print(pbody.ssid.ssid, NULL); printf(") AP : %s", etheraddr_string( pbody.ap )); return 1; } -static int handle_reassoc_response(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_reassoc_response(const u_char *p) { /* Same as a Association Reponse */ - return handle_assoc_response(fc,pmh,p); + return handle_assoc_response(p); } -static int handle_probe_request(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_probe_request(const u_char *p) { struct mgmt_body_t pbody; int offset = 0; @@ -345,7 +355,7 @@ static int handle_probe_request(u_int16_t fc, const struct mgmt_header_t *pmh, if (!parse_elements(&pbody, p, offset)) return 0; - printf("%s (", subtype_text[FC_SUBTYPE(fc)]); + printf(" ("); fn_print(pbody.ssid.ssid, NULL); printf(")"); PRINT_RATES(pbody); @@ -353,27 +363,29 @@ static int handle_probe_request(u_int16_t fc, const struct mgmt_header_t *pmh, return 1; } -static int handle_probe_response(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_probe_response(const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); - if (!TTEST2(*p, 12)) + if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + + IEEE802_11_CAPINFO_LEN)) return 0; - memcpy(&pbody.timestamp,p,8); - offset += 8; + + memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); + offset += IEEE802_11_TSTAMP_LEN; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); - offset += 2; + offset += IEEE802_11_BCNINT_LEN; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); - offset += 2; + offset += IEEE802_11_CAPINFO_LEN; if (!parse_elements(&pbody, p, offset)) return 0; - printf("%s (", subtype_text[FC_SUBTYPE(fc)]); + printf(" ("); fn_print(pbody.ssid.ssid, NULL); printf(") "); PRINT_RATES(pbody); @@ -383,35 +395,33 @@ static int handle_probe_response(u_int16_t fc, const struct mgmt_header_t *pmh, return 1; } -static int handle_atim(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_atim(void) { /* the frame body for ATIM is null. */ - printf("ATIM"); return 1; } -static int handle_disassoc(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_disassoc(const u_char *p) { struct mgmt_body_t pbody; - int offset = 0; memset(&pbody, 0, sizeof(pbody)); - if (!TTEST2(*p, 2)) + if (!TTEST2(*p, IEEE802_11_REASON_LEN)) return 0; pbody.reason_code = EXTRACT_LE_16BITS(p); - offset += 2; - printf("%s: %s", subtype_text[FC_SUBTYPE(fc)], - pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" ); + printf(": %s", + (pbody.reason_code < 10) ? reason_text[pbody.reason_code] + : "Reserved" ); return 1; } -static int handle_auth(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_auth(const u_char *p) { struct mgmt_body_t pbody; int offset = 0; @@ -427,51 +437,55 @@ static int handle_auth(u_int16_t fc, const struct mgmt_header_t *pmh, pbody.status_code = EXTRACT_LE_16BITS(p + offset); offset += 2; - if (!parse_elements(&pbody,p,offset)) + if (!parse_elements(&pbody, p, offset)) return 0; if ((pbody.auth_alg == 1) && - ((pbody.auth_trans_seq_num == 2) || (pbody.auth_trans_seq_num == 3))) { - printf("%s (%s)-%x [Challenge Text] %s", - subtype_text[FC_SUBTYPE(fc)], - pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" , - pbody.auth_trans_seq_num, - ((pbody.auth_trans_seq_num % 2) ? - (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : "" )); - } else { - printf("%s (%s)-%x: %s", - subtype_text[FC_SUBTYPE(fc)], - pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" , + ((pbody.auth_trans_seq_num == 2) || + (pbody.auth_trans_seq_num == 3))) { + printf(" (%s)-%x [Challenge Text] %s", + (pbody.auth_alg < 4) ? auth_alg_text[pbody.auth_alg] + : "Reserved", pbody.auth_trans_seq_num, - ((pbody.auth_trans_seq_num % 2) ? (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : "")); + ((pbody.auth_trans_seq_num % 2) + ? ((pbody.status_code < 19) + ? status_text[pbody.status_code] + : "n/a") : "")); + return 1; } + printf(" (%s)-%x: %s", + (pbody.auth_alg < 4) ? auth_alg_text[pbody.auth_alg] : "Reserved", + pbody.auth_trans_seq_num, + (pbody.auth_trans_seq_num % 2) + ? ((pbody.status_code < 19) ? status_text[pbody.status_code] + : "n/a") + : ""); return 1; } -static int handle_deauth(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p) +static int +handle_deauth(const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; + const char *reason = NULL; memset(&pbody, 0, sizeof(pbody)); - if (!TTEST2(*p, 2)) + if (!TTEST2(*p, IEEE802_11_REASON_LEN)) return 0; pbody.reason_code = EXTRACT_LE_16BITS(p); - offset += 2; + offset += IEEE802_11_REASON_LEN; + + reason = (pbody.reason_code < 10) ? reason_text[pbody.reason_code] + : "Reserved"; if (eflag) { - printf("%s: %s", - subtype_text[FC_SUBTYPE(fc)], - pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" ); + printf(": %s", reason); } else { - printf("%s (%s): %s", - subtype_text[FC_SUBTYPE(fc)], etheraddr_string(pmh->sa), - pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" ); + printf(" (%s): %s", etheraddr_string(pmh->sa), reason); } - return 1; } @@ -481,42 +495,44 @@ static int handle_deauth(u_int16_t fc, const struct mgmt_header_t *pmh, *********************************************************************************/ -static int mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh, - const u_char *p, u_int length) +static int +mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh, + const u_char *p) { + printf("%s", subtype_text[FC_SUBTYPE(fc)]); + switch (FC_SUBTYPE(fc)) { case ST_ASSOC_REQUEST: - return (handle_assoc_request(fc, pmh, p)); + return handle_assoc_request(p); case ST_ASSOC_RESPONSE: - return (handle_assoc_response(fc, pmh, p)); + return handle_assoc_response(p); case ST_REASSOC_REQUEST: - return (handle_reassoc_request(fc, pmh, p)); + return handle_reassoc_request(p); case ST_REASSOC_RESPONSE: - return (handle_reassoc_response(fc, pmh, p)); + return handle_reassoc_response(p); case ST_PROBE_REQUEST: - return (handle_probe_request(fc, pmh, p)); + return handle_probe_request(p); case ST_PROBE_RESPONSE: - return (handle_probe_response(fc, pmh, p)); + return handle_probe_response(p); case ST_BEACON: - return (handle_beacon(fc, pmh, p)); + return handle_beacon(p); case ST_ATIM: - return (handle_atim(fc, pmh, p)); + return handle_atim(); case ST_DISASSOC: - return (handle_disassoc(fc, pmh, p)); + return handle_disassoc(p); case ST_AUTH: if (!TTEST2(*p, 3)) return 0; if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) { printf("Authentication (Shared-Key)-3 "); - return (wep_print(p, length)); + return wep_print(p); } - else - return (handle_auth(fc, pmh, p)); + return handle_auth(p); case ST_DEAUTH: - return (handle_deauth(fc, pmh, p)); + return handle_deauth(pmh, p); break; default: - printf("Unhandled Managment subtype(%x)", + printf("Unhandled Management subtype(%x)", FC_SUBTYPE(fc)); return 1; } @@ -527,68 +543,63 @@ static int mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh, * Handles printing all the control frame types *********************************************************************************/ -static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length) +static int +ctrl_body_print(u_int16_t fc, const u_char *p) { switch (FC_SUBTYPE(fc)) { case CTRL_PS_POLL: - if (!TTEST2(*p, CTRL_PS_POLL_LEN)) + printf("Power Save-Poll"); + if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN)) return 0; - printf("Power Save-Poll AID(%x)", + printf(" AID(%x)", EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))); break; case CTRL_RTS: - if (!TTEST2(*p, CTRL_RTS_LEN)) + printf("Request-To-Send"); + if (!TTEST2(*p, CTRL_RTS_HDRLEN)) return 0; - if (eflag) - printf("Request-To-Send"); - else - printf("Request-To-Send TA:%s ", + if (!eflag) + printf(" TA:%s ", etheraddr_string(((const struct ctrl_rts_t *)p)->ta)); break; case CTRL_CTS: - if (!TTEST2(*p, CTRL_CTS_LEN)) + printf("Clear-To-Send"); + if (!TTEST2(*p, CTRL_CTS_HDRLEN)) return 0; - if (eflag) - printf("Clear-To-Send"); - else - printf("Clear-To-Send RA:%s ", + if (!eflag) + printf(" RA:%s ", etheraddr_string(((const struct ctrl_cts_t *)p)->ra)); break; case CTRL_ACK: - if (!TTEST2(*p, CTRL_ACK_LEN)) + printf("Acknowledgment"); + if (!TTEST2(*p, CTRL_ACK_HDRLEN)) return 0; - if (eflag) - printf("Acknowledgment"); - else - printf("Acknowledgment RA:%s ", + if (!eflag) + printf(" RA:%s ", etheraddr_string(((const struct ctrl_ack_t *)p)->ra)); break; case CTRL_CF_END: - if (!TTEST2(*p, CTRL_END_LEN)) + printf("CF-End"); + if (!TTEST2(*p, CTRL_END_HDRLEN)) return 0; - if (eflag) - printf("CF-End"); - else - printf("CF-End RA:%s ", + if (!eflag) + printf(" RA:%s ", etheraddr_string(((const struct ctrl_end_t *)p)->ra)); break; case CTRL_END_ACK: - if (!TTEST2(*p, CTRL_END_ACK_LEN)) + printf("CF-End+CF-Ack"); + if (!TTEST2(*p, CTRL_END_ACK_HDRLEN)) return 0; - if (eflag) - printf("CF-End+CF-Ack"); - else - printf("CF-End+CF-Ack RA:%s ", + if (!eflag) + printf(" RA:%s ", etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra)); break; default: - printf("(B) Unknown Ctrl Subtype"); + printf("Unknown Ctrl Subtype"); } return 1; } - - /* * Print Header funcs */ @@ -603,31 +614,73 @@ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length) * 1 | 1 | RA | TA | DA | SA */ -static void data_header_print(u_int16_t fc,const u_char *p, u_int length) +static void +data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, + const u_int8_t **dstp) { + switch (FC_SUBTYPE(fc)) { + case DATA_DATA: + case DATA_NODATA: + break; + case DATA_DATA_CF_ACK: + case DATA_NODATA_CF_ACK: + printf("CF Ack "); + break; + case DATA_DATA_CF_POLL: + case DATA_NODATA_CF_POLL: + printf("CF Poll "); + break; + case DATA_DATA_CF_ACK_POLL: + case DATA_NODATA_CF_ACK_POLL: + printf("CF Ack/Poll "); + break; + } + #define ADDR1 (p + 4) #define ADDR2 (p + 10) #define ADDR3 (p + 16) #define ADDR4 (p + 24) - if (!FC_TO_DS(fc)) { - if (!FC_FROM_DS(fc)) - printf("DA:%s SA:%s BSSID:%s ", - etheraddr_string(ADDR1), etheraddr_string(ADDR2), - etheraddr_string(ADDR3)); - else - printf("DA:%s BSSID:%s SA:%s ", - etheraddr_string(ADDR1), etheraddr_string(ADDR2), - etheraddr_string(ADDR3)); - } else { - if (!FC_FROM_DS(fc)) - printf("BSSID:%s SA:%s DA:%s ", - etheraddr_string(ADDR1), etheraddr_string(ADDR2), - etheraddr_string(ADDR3)); - else - printf("RA:%s TA:%s DA:%s SA:%s ", - etheraddr_string(ADDR1), etheraddr_string(ADDR2), - etheraddr_string(ADDR3), etheraddr_string(ADDR4)); + if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) { + if (srcp != NULL) + *srcp = ADDR2; + if (dstp != NULL) + *dstp = ADDR1; + if (!eflag) + return; + printf("DA:%s SA:%s BSSID:%s ", + etheraddr_string(ADDR1), etheraddr_string(ADDR2), + etheraddr_string(ADDR3)); + } else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) { + if (srcp != NULL) + *srcp = ADDR3; + if (dstp != NULL) + *dstp = ADDR1; + if (!eflag) + return; + printf("DA:%s BSSID:%s SA:%s ", + etheraddr_string(ADDR1), etheraddr_string(ADDR2), + etheraddr_string(ADDR3)); + } else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) { + if (srcp != NULL) + *srcp = ADDR2; + if (dstp != NULL) + *dstp = ADDR3; + if (!eflag) + return; + printf("BSSID:%s SA:%s DA:%s ", + etheraddr_string(ADDR1), etheraddr_string(ADDR2), + etheraddr_string(ADDR3)); + } else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) { + if (srcp != NULL) + *srcp = ADDR4; + if (dstp != NULL) + *dstp = ADDR3; + if (!eflag) + return; + printf("RA:%s TA:%s DA:%s SA:%s ", + etheraddr_string(ADDR1), etheraddr_string(ADDR2), + etheraddr_string(ADDR3), etheraddr_string(ADDR4)); } #undef ADDR1 @@ -636,18 +689,35 @@ static void data_header_print(u_int16_t fc,const u_char *p, u_int length) #undef ADDR4 } - -static void mgmt_header_print(const u_char *p, u_int length) +static void +mgmt_header_print(const u_char *p, const u_int8_t **srcp, + const u_int8_t **dstp) { const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p; + if (srcp != NULL) + *srcp = hp->sa; + if (dstp != NULL) + *dstp = hp->da; + if (!eflag) + return; + printf("BSSID:%s DA:%s SA:%s ", etheraddr_string((hp)->bssid), etheraddr_string((hp)->da), etheraddr_string((hp)->sa)); } -static void ctrl_header_print(u_int16_t fc,const u_char *p, u_int length) +static void +ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, + const u_int8_t **dstp) { + if (srcp != NULL) + *srcp = NULL; + if (dstp != NULL) + *dstp = NULL; + if (!eflag) + return; + switch (FC_SUBTYPE(fc)) { case CTRL_PS_POLL: printf("BSSID:%s TA:%s ", @@ -679,180 +749,255 @@ static void ctrl_header_print(u_int16_t fc,const u_char *p, u_int length) break; default: printf("(H) Unknown Ctrl Subtype"); + break; } } -static int GetHeaderLength(u_int16_t fc) +static int +extract_header_length(u_int16_t fc) { - int iLength=0; - switch (FC_TYPE(fc)) { case T_MGMT: - iLength = MGMT_HEADER_LEN; - break; + return MGMT_HDRLEN; case T_CTRL: switch (FC_SUBTYPE(fc)) { case CTRL_PS_POLL: - iLength = CTRL_PS_POLL_LEN; - break; + return CTRL_PS_POLL_HDRLEN; case CTRL_RTS: - iLength = CTRL_RTS_LEN; - break; + return CTRL_RTS_HDRLEN; case CTRL_CTS: - iLength = CTRL_CTS_LEN; - break; + return CTRL_CTS_HDRLEN; case CTRL_ACK: - iLength = CTRL_ACK_LEN; - break; + return CTRL_ACK_HDRLEN; case CTRL_CF_END: - iLength = CTRL_END_LEN; - break; + return CTRL_END_HDRLEN; case CTRL_END_ACK: - iLength = CTRL_END_ACK_LEN; - break; + return CTRL_END_ACK_HDRLEN; default: - iLength = 0; - break; + return 0; } - break; case T_DATA: - if (FC_TO_DS(fc) && FC_FROM_DS(fc)) - iLength = 30; - else - iLength = 24; - break; + return (FC_TO_DS(fc) && FC_FROM_DS(fc)) ? 30 : 24; default: - printf("unknown IEEE802.11 frame type (%d)", - FC_TYPE(fc)); - break; + printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); + return 0; } - - return iLength; } /* - * Print the 802.11 MAC header + * 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_print(u_int16_t fc, const u_char *p, u_int length) +ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, + const u_int8_t **dstp) { + if (vflag) { + if (FC_MORE_DATA(fc)) + printf("More Data "); + if (FC_MORE_FLAG(fc)) + printf("More Fragments "); + if (FC_POWER_MGMT(fc)) + printf("Pwr Mgmt "); + if (FC_RETRY(fc)) + printf("Retry "); + if (FC_ORDER(fc)) + printf("Strictly Ordered "); + if (FC_WEP(fc)) + printf("WEP Encrypted "); + if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL) + printf("%dus ", + EXTRACT_LE_16BITS( + &((const struct mgmt_header_t *)p)->duration)); + } + switch (FC_TYPE(fc)) { case T_MGMT: - mgmt_header_print(p, length); + mgmt_header_print(p, srcp, dstp); break; - case T_CTRL: - ctrl_header_print(fc, p, length); + ctrl_header_print(fc, p, srcp, dstp); break; - case T_DATA: - data_header_print(fc, p, length); + data_header_print(fc, p, srcp, dstp); break; - default: printf("(header) unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); + *srcp = NULL; + *dstp = NULL; break; } } -/* - * This is the top level routine of the printer. 'p' is the points - * to the ether header of the packet, 'h->tv' is the timestamp, - * 'h->length' is the length of the packet off the wire, and 'h->caplen' - * is the number of bytes actually captured. - */ -void -ieee802_11_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +static u_int +ieee802_11_print(const u_char *p, u_int length, u_int caplen) { - u_int caplen = h->caplen; - u_int length = h->len; u_int16_t fc; - u_int HEADER_LENGTH; + u_int hdrlen; + const u_int8_t *src, *dst; u_short extracted_ethertype; - ++infodelay; - ts_print(&h->ts); - if (caplen < IEEE802_11_FC_LEN) { printf("[|802.11]"); - goto out; + return caplen; } - fc=EXTRACT_LE_16BITS(p); + fc = EXTRACT_LE_16BITS(p); + hdrlen = extract_header_length(fc); - if (eflag) - ieee_802_11_print(fc, p, length); + if (caplen < hdrlen) { + printf("[|802.11]"); + return hdrlen; + } + + ieee_802_11_hdr_print(fc, p, &src, &dst); /* - * Some printers want to get back at the ethernet addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. + * Go past the 802.11 header. */ - packetp = p; - snapend = p + caplen; - - HEADER_LENGTH=GetHeaderLength(fc); - - length -= HEADER_LENGTH; - caplen -= HEADER_LENGTH; - p += HEADER_LENGTH; + length -= hdrlen; + caplen -= hdrlen; + p += hdrlen; switch (FC_TYPE(fc)) { case T_MGMT: - if (!mgmt_body_print(fc, (const struct mgmt_header_t *)packetp, - p, length)) { + if (!mgmt_body_print(fc, + (const struct mgmt_header_t *)(p - hdrlen), p)) { printf("[|802.11]"); - goto out; + return hdrlen; } break; - case T_CTRL: - if (!ctrl_body_print(fc, p - HEADER_LENGTH, - length + HEADER_LENGTH)) { + if (!ctrl_body_print(fc, p - hdrlen)) { printf("[|802.11]"); - goto out; + return hdrlen; } break; - case T_DATA: /* There may be a problem w/ AP not having this bit set */ - if (FC_WEP(fc)) { - if (!wep_print(p,length)) { + if (FC_WEP(fc)) { + if (!wep_print(p)) { printf("[|802.11]"); - goto out; - } - } else { - if (llc_print(p, length, caplen, packetp + 10, - packetp + 4, &extracted_ethertype) == 0) { - /* - * Some kinds of LLC packet we cannot - * handle intelligently - */ - if (!eflag) - ieee_802_11_print(fc, p - HEADER_LENGTH, - length + HEADER_LENGTH); - if (extracted_ethertype) { - printf("(LLC %s) ", - etherproto_string(htons(extracted_ethertype))); - } - if (!xflag && !qflag) - default_print(p, caplen); + return hdrlen; } + } else if (llc_print(p, length, caplen, dst, src, + &extracted_ethertype) == 0) { + /* + * Some kinds of LLC packet we cannot + * handle intelligently + */ + if (!eflag) + ieee_802_11_hdr_print(fc, p - hdrlen, NULL, + NULL); + if (extracted_ethertype) + printf("(LLC %s) ", + etherproto_string( + htons(extracted_ethertype))); + if (!xflag && !qflag) + default_print(p, caplen); } break; - default: - printf("(body) unhandled IEEE802.11 frame type (%d)", - FC_TYPE(fc)); + printf("unknown 802.11 frame type (%d)", FC_TYPE(fc)); break; } - if (xflag) - default_print(p, caplen); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return hdrlen; +} + +/* + * This is the top level routine of the printer. 'p' points + * to the 802.11 header of the packet, 'h->ts' is the timestamp, + * 'h->length' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + return ieee802_11_print(p, h->len, h->caplen); +} + +static u_int +ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen) +{ + u_int32_t caphdr_len; + + caphdr_len = EXTRACT_32BITS(p + 4); + if (caphdr_len < 8) { + /* + * Yow! The capture header length is claimed not + * to be large enough to include even the version + * cookie or capture header length! + */ + printf("[|802.11]"); + return caplen; + } + + if (caplen < caphdr_len) { + printf("[|802.11]"); + return caplen; + } + + return caphdr_len + ieee802_11_print(p + caphdr_len, + length - caphdr_len, caplen - caphdr_len); +} + +#define PRISM_HDR_LEN 144 + +#define WLANCAP_MAGIC_COOKIE_V1 0x80211001 + +/* + * For DLT_PRISM_HEADER; like DLT_IEEE802_11, but with an extra header, + * containing information such as radio information, which we + * currently ignore. + * + * If, however, the packet begins with WLANCAP_MAGIC_COOKIE_V1, it's + * really DLT_IEEE802_11_RADIO (currently, on Linux, there's no + * ARPHRD_ type for DLT_IEEE802_11_RADIO, as there is a + * ARPHRD_IEEE80211_PRISM for DLT_PRISM_HEADER, so + * ARPHRD_IEEE80211_PRISM is used for DLT_IEEE802_11_RADIO, and + * the first 4 bytes of the header are used to indicate which it is). + */ +u_int +prism_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + u_int length = h->len; + + if (caplen < 4) { + printf("[|802.11]"); + return caplen; + } + + if (EXTRACT_32BITS(p) == WLANCAP_MAGIC_COOKIE_V1) + return ieee802_11_radio_print(p, length, caplen); + + if (caplen < PRISM_HDR_LEN) { + printf("[|802.11]"); + return caplen; + } + + return PRISM_HDR_LEN + ieee802_11_print(p + PRISM_HDR_LEN, + length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN); +} + +/* + * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra + * header, containing information such as radio information, which we + * currently ignore. + */ +u_int +ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + u_int length = h->len; + + if (caplen < 8) { + printf("[|802.11]"); + return caplen; + } + + return ieee802_11_radio_print(p, length, caplen); } diff --git a/contrib/tcpdump/print-ah.c b/contrib/tcpdump/print-ah.c index 50af4d4..4094c25 100644 --- a/contrib/tcpdump/print-ah.c +++ b/contrib/tcpdump/print-ah.c @@ -22,20 +22,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.15 2001/09/17 21:57:54 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.19.2.3 2003/11/19 00:35:43 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> @@ -43,9 +38,10 @@ static const char rcsid[] = #include "interface.h" #include "addrtoname.h" +#include "extract.h" int -ah_print(register const u_char *bp, register const u_char *bp2) +ah_print(register const u_char *bp) { register const struct ah *ah; register const u_char *ep; @@ -58,18 +54,18 @@ ah_print(register const u_char *bp, register const u_char *bp2) TCHECK(*ah); sumlen = ah->ah_len << 2; - spi = (u_int32_t)ntohl(ah->ah_spi); + spi = EXTRACT_32BITS(&ah->ah_spi); printf("AH(spi=0x%08x", spi); if (vflag) printf(",sumlen=%d", sumlen); - printf(",seq=0x%x", (u_int32_t)ntohl(*(const u_int32_t *)(ah + 1))); + printf(",seq=0x%x", EXTRACT_32BITS(ah + 1)); if (bp + sizeof(struct ah) + sumlen > ep) fputs("[truncated]", stdout); fputs("): ", stdout); - + return sizeof(struct ah) + sumlen; trunc: fputs("[|AH]", stdout); - return 65535; + return -1; } diff --git a/contrib/tcpdump/print-aodv.c b/contrib/tcpdump/print-aodv.c new file mode 100644 index 0000000..099e355 --- /dev/null +++ b/contrib/tcpdump/print-aodv.c @@ -0,0 +1,455 @@ +/* + * Copyright (c) 2003 Bruce M. Simpson <bms@spc.org> + * 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 Bruce M. Simpson. + * 4. Neither the name of Bruce M. Simpson nor the names of co- + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bruce M. Simpson 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 Bruce M. Simpson OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.8.2.3 2004/03/24 00:30:41 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stddef.h> +#include <stdio.h> +#include <ctype.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +#include "aodv.h" + +static void +aodv_extension(const struct aodv_ext *ep, u_int length) +{ + u_int i; + const struct aodv_hello *ah; + + switch (ep->type) { + case AODV_EXT_HELLO: + if (snapend < (u_char *) ep) { + printf(" [|hello]"); + return; + } + i = min(length, (u_int)(snapend - (u_char *)ep)); + if (i < sizeof(struct aodv_hello)) { + printf(" [|hello]"); + return; + } + i -= sizeof(struct aodv_hello); + ah = (void *)ep; + printf("\n\text HELLO %ld ms", + (unsigned long)EXTRACT_32BITS(&ah->interval)); + break; + + default: + printf("\n\text %u %u", ep->type, ep->length); + break; + } +} + +static void +aodv_rreq(const union aodv *ap, const u_char *dat, u_int length) +{ + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rreq)) { + printf(" [|rreq]"); + return; + } + i -= sizeof(ap->rreq); + printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n" + "\tdst %s seq %lu src %s seq %lu", length, + ap->rreq.rreq_type & RREQ_JOIN ? "[J]" : "", + ap->rreq.rreq_type & RREQ_REPAIR ? "[R]" : "", + ap->rreq.rreq_type & RREQ_GRAT ? "[G]" : "", + ap->rreq.rreq_type & RREQ_DEST ? "[D]" : "", + ap->rreq.rreq_type & RREQ_UNKNOWN ? "[U] " : " ", + ap->rreq.rreq_hops, + (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_id), + ipaddr_string(&ap->rreq.rreq_da), + (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_ds), + ipaddr_string(&ap->rreq.rreq_oa), + (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_os)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rreq + 1), i); +} + +static void +aodv_rrep(const union aodv *ap, const u_char *dat, u_int length) +{ + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rrep)) { + printf(" [|rrep]"); + return; + } + i -= sizeof(ap->rrep); + printf(" rrep %u %s%sprefix %u hops %u\n" + "\tdst %s dseq %lu src %s %lu ms", length, + ap->rrep.rrep_type & RREP_REPAIR ? "[R]" : "", + ap->rrep.rrep_type & RREP_ACK ? "[A] " : " ", + ap->rrep.rrep_ps & RREP_PREFIX_MASK, + ap->rrep.rrep_hops, + ipaddr_string(&ap->rrep.rrep_da), + (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_ds), + ipaddr_string(&ap->rrep.rrep_oa), + (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_life)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rrep + 1), i); +} + +static void +aodv_rerr(const union aodv *ap, const u_char *dat, u_int length) +{ + u_int i; + const struct rerr_unreach *dp = NULL; + int n, trunc; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < offsetof(struct aodv_rerr, r)) { + printf(" [|rerr]"); + return; + } + i -= offsetof(struct aodv_rerr, r); + dp = &ap->rerr.r.dest[0]; + n = ap->rerr.rerr_dc * sizeof(ap->rerr.r.dest[0]); + printf(" rerr %s [items %u] [%u]:", + ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "", + ap->rerr.rerr_dc, length); + trunc = n - (i/sizeof(ap->rerr.r.dest[0])); + for (; i >= sizeof(ap->rerr.r.dest[0]); + ++dp, i -= sizeof(ap->rerr.r.dest[0])) { + printf(" {%s}(%ld)", ipaddr_string(&dp->u_da), + (unsigned long)EXTRACT_32BITS(&dp->u_ds)); + } + if (trunc) + printf("[|rerr]"); +} + +static void +#ifdef INET6 +aodv_v6_rreq(const union aodv *ap, const u_char *dat, u_int length) +#else +aodv_v6_rreq(const union aodv *ap _U_, const u_char *dat _U_, u_int length) +#endif +{ +#ifdef INET6 + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rreq6)) { + printf(" [|rreq6]"); + return; + } + i -= sizeof(ap->rreq6); + printf(" v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n" + "\tdst %s seq %lu src %s seq %lu", length, + ap->rreq6.rreq_type & RREQ_JOIN ? "[J]" : "", + ap->rreq6.rreq_type & RREQ_REPAIR ? "[R]" : "", + ap->rreq6.rreq_type & RREQ_GRAT ? "[G]" : "", + ap->rreq6.rreq_type & RREQ_DEST ? "[D]" : "", + ap->rreq6.rreq_type & RREQ_UNKNOWN ? "[U] " : " ", + ap->rreq6.rreq_hops, + (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_id), + ip6addr_string(&ap->rreq6.rreq_da), + (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_ds), + ip6addr_string(&ap->rreq6.rreq_oa), + (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_os)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rreq6 + 1), i); +#else + printf(" v6 rreq %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_rrep(const union aodv *ap, const u_char *dat, u_int length) +#else +aodv_v6_rrep(const union aodv *ap _U_, const u_char *dat _U_, u_int length) +#endif +{ +#ifdef INET6 + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rrep6)) { + printf(" [|rrep6]"); + return; + } + i -= sizeof(ap->rrep6); + printf(" rrep %u %s%sprefix %u hops %u\n" + "\tdst %s dseq %lu src %s %lu ms", length, + ap->rrep6.rrep_type & RREP_REPAIR ? "[R]" : "", + ap->rrep6.rrep_type & RREP_ACK ? "[A] " : " ", + ap->rrep6.rrep_ps & RREP_PREFIX_MASK, + ap->rrep6.rrep_hops, + ip6addr_string(&ap->rrep6.rrep_da), + (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_ds), + ip6addr_string(&ap->rrep6.rrep_oa), + (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_life)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rrep6 + 1), i); +#else + printf(" rrep %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_rerr(const union aodv *ap, u_int length) +#else +aodv_v6_rerr(const union aodv *ap _U_, u_int length) +#endif +{ +#ifdef INET6 + const struct rerr_unreach6 *dp6 = NULL; + int i, j, n, trunc; + + i = length - offsetof(struct aodv_rerr, r); + j = sizeof(ap->rerr.r.dest6[0]); + dp6 = &ap->rerr.r.dest6[0]; + n = ap->rerr.rerr_dc * j; + printf(" rerr %s [items %u] [%u]:", + ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "", + ap->rerr.rerr_dc, length); + trunc = n - (i/j); + for (; i -= j >= 0; ++dp6) { + printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da), + (unsigned long)EXTRACT_32BITS(&dp6->u_ds)); + } + if (trunc) + printf("[|rerr]"); +#else + printf(" rerr %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_draft_01_rreq(const union aodv *ap, const u_char *dat, u_int length) +#else +aodv_v6_draft_01_rreq(const union aodv *ap _U_, const u_char *dat _U_, + u_int length) +#endif +{ +#ifdef INET6 + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rreq6_draft_01)) { + printf(" [|rreq6]"); + return; + } + i -= sizeof(ap->rreq6_draft_01); + printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n" + "\tdst %s seq %lu src %s seq %lu", length, + ap->rreq6_draft_01.rreq_type & RREQ_JOIN ? "[J]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_REPAIR ? "[R]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_GRAT ? "[G]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_DEST ? "[D]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_UNKNOWN ? "[U] " : " ", + ap->rreq6_draft_01.rreq_hops, + (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_id), + ip6addr_string(&ap->rreq6_draft_01.rreq_da), + (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_ds), + ip6addr_string(&ap->rreq6_draft_01.rreq_oa), + (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_os)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rreq6_draft_01 + 1), i); +#else + printf(" rreq %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_draft_01_rrep(const union aodv *ap, const u_char *dat, u_int length) +#else +aodv_v6_draft_01_rrep(const union aodv *ap _U_, const u_char *dat _U_, + u_int length) +#endif +{ +#ifdef INET6 + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rrep6_draft_01)) { + printf(" [|rrep6]"); + return; + } + i -= sizeof(ap->rrep6_draft_01); + printf(" rrep %u %s%sprefix %u hops %u\n" + "\tdst %s dseq %lu src %s %lu ms", length, + ap->rrep6_draft_01.rrep_type & RREP_REPAIR ? "[R]" : "", + ap->rrep6_draft_01.rrep_type & RREP_ACK ? "[A] " : " ", + ap->rrep6_draft_01.rrep_ps & RREP_PREFIX_MASK, + ap->rrep6_draft_01.rrep_hops, + ip6addr_string(&ap->rrep6_draft_01.rrep_da), + (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_ds), + ip6addr_string(&ap->rrep6_draft_01.rrep_oa), + (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_life)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rrep6_draft_01 + 1), i); +#else + printf(" rrep %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_draft_01_rerr(const union aodv *ap, u_int length) +#else +aodv_v6_draft_01_rerr(const union aodv *ap _U_, u_int length) +#endif +{ +#ifdef INET6 + const struct rerr_unreach6_draft_01 *dp6 = NULL; + int i, j, n, trunc; + + i = length - offsetof(struct aodv_rerr, r); + j = sizeof(ap->rerr.r.dest6_draft_01[0]); + dp6 = &ap->rerr.r.dest6_draft_01[0]; + n = ap->rerr.rerr_dc * j; + printf(" rerr %s [items %u] [%u]:", + ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "", + ap->rerr.rerr_dc, length); + trunc = n - (i/j); + for (; i -= j >= 0; ++dp6) { + printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da), + (unsigned long)EXTRACT_32BITS(&dp6->u_ds)); + } + if (trunc) + printf("[|rerr]"); +#else + printf(" rerr %u", length); +#endif +} + +void +aodv_print(const u_char *dat, u_int length, int is_ip6) +{ + const union aodv *ap; + + ap = (union aodv *)dat; + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + if (min(length, (u_int)(snapend - dat)) < sizeof(ap->rrep_ack)) { + printf(" [|aodv]"); + return; + } + printf(" aodv"); + + switch (ap->rerr.rerr_type) { + + case AODV_RREQ: + if (is_ip6) + aodv_v6_rreq(ap, dat, length); + else + aodv_rreq(ap, dat, length); + break; + + case AODV_RREP: + if (is_ip6) + aodv_v6_rrep(ap, dat, length); + else + aodv_rrep(ap, dat, length); + break; + + case AODV_RERR: + if (is_ip6) + aodv_v6_rerr(ap, length); + else + aodv_rerr(ap, dat, length); + break; + + case AODV_RREP_ACK: + printf(" rrep-ack %u", length); + break; + + case AODV_V6_DRAFT_01_RREQ: + aodv_v6_draft_01_rreq(ap, dat, length); + break; + + case AODV_V6_DRAFT_01_RREP: + aodv_v6_draft_01_rrep(ap, dat, length); + break; + + case AODV_V6_DRAFT_01_RERR: + aodv_v6_draft_01_rerr(ap, length); + break; + + case AODV_V6_DRAFT_01_RREP_ACK: + printf(" rrep-ack %u", length); + break; + + default: + printf(" %u %u", ap->rreq.rreq_type, length); + } +} diff --git a/contrib/tcpdump/print-ap1394.c b/contrib/tcpdump/print-ap1394.c new file mode 100644 index 0000000..8c07456 --- /dev/null +++ b/contrib/tcpdump/print-ap1394.c @@ -0,0 +1,119 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.1.2.1 2004/03/17 22:15:53 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ethertype.h" + +/* + * Structure of a header for Apple's IP-over-IEEE 1384 BPF header. + */ +#define FIREWIRE_EUI64_LEN 8 +struct firewire_header { + u_char firewire_dhost[FIREWIRE_EUI64_LEN]; + u_char firewire_shost[FIREWIRE_EUI64_LEN]; + u_short firewire_type; +}; + +/* + * Length of that header; note that some compilers may pad + * "struct firewire_header" to a multiple of 4 bytes, for example, so + * "sizeof (struct firewire_header)" may not give the right answer. + */ +#define FIREWIRE_HDRLEN 18 + +static inline void +ap1394_hdr_print(register const u_char *bp, u_int length) +{ + register const struct firewire_header *fp; + fp = (const struct firewire_header *)bp; + + (void)printf("%s > %s", + linkaddr_string(fp->firewire_dhost, FIREWIRE_EUI64_LEN), + linkaddr_string(fp->firewire_shost, FIREWIRE_EUI64_LEN)); + + if (!qflag) { + (void)printf(", ethertype %s (0x%04x)", + tok2str(ethertype_values,"Unknown", ntohs(fp->firewire_type)), + ntohs(fp->firewire_type)); + } else { + (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ntohs(fp->firewire_type))); + } + + (void)printf(", length %u: ", length); +} + +/* + * This is the top level routine of the printer. 'p' points + * to the ether header of the packet, 'h->ts' is the timestamp, + * 'h->length' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int length = h->len; + u_int caplen = h->caplen; + struct firewire_header *fp; + u_short ether_type; + u_short extracted_ether_type; + + if (caplen < FIREWIRE_HDRLEN) { + printf("[|ap1394]"); + return FIREWIRE_HDRLEN; + } + + if (eflag) + ap1394_hdr_print(p, length); + + length -= FIREWIRE_HDRLEN; + caplen -= FIREWIRE_HDRLEN; + 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 not known, print raw packet */ + if (!eflag) + ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN); + + if (!xflag && !qflag) + default_print(p, caplen); + } + + return FIREWIRE_HDRLEN; +} diff --git a/contrib/tcpdump/print-arcnet.c b/contrib/tcpdump/print-arcnet.c index 70b814e..32bb161 100644 --- a/contrib/tcpdump/print-arcnet.c +++ b/contrib/tcpdump/print-arcnet.c @@ -17,23 +17,19 @@ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * + * * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.6.4.1 2002/06/01 23:51:11 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.15.2.2 2003/11/16 08:51:09 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <pcap.h> @@ -41,7 +37,7 @@ static const char rcsid[] = #include "interface.h" #include "arcnet.h" -int arcnet_encap_print(u_char arctype, const u_char *p, +static int arcnet_encap_print(u_char arctype, const u_char *p, u_int length, u_int caplen); struct tok arctypemap[] = { @@ -105,13 +101,13 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid) } /* - * This is the top level routine of the printer. 'p' is the points - * to the ether header of the packet, 'tvp' is the timestamp, - * 'length' is the length of the packet off the wire, and 'caplen' + * This is the top level routine of the printer. 'p' points + * to the ARCNET header of the packet, 'h->ts' is the timestamp, + * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ -void -arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +u_int +arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; @@ -121,12 +117,9 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) u_int seqid = 0; u_char arc_type; - ++infodelay; - ts_print(&h->ts); - if (caplen < ARC_HDRLEN) { printf("[|arcnet]"); - goto out; + return (caplen); } ap = (const struct arc_header *)p; @@ -148,21 +141,21 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) if (caplen < ARC_HDRNEWLEN) { arcnet_print(p, length, 0, 0, 0); printf("[|phds]"); - goto out; + return (caplen); } if (ap->arc_flag == 0xff) { if (caplen < ARC_HDRNEWLEN_EXC) { arcnet_print(p, length, 0, 0, 0); printf("[|phds extended]"); - goto out; + return (caplen); } flag = ap->arc_flag2; - seqid = ap->arc_seqid2; + seqid = ntohs(ap->arc_seqid2); archdrlen = ARC_HDRNEWLEN_EXC; } else { flag = ap->arc_flag; - seqid = ap->arc_seqid; + seqid = ntohs(ap->arc_seqid); archdrlen = ARC_HDRNEWLEN; } } @@ -172,34 +165,82 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) arcnet_print(p, length, phds, flag, seqid); /* - * Some printers want to get back at the ethernet addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. + * Go past the ARCNET header. */ - packetp = p; - snapend = p + caplen; - length -= archdrlen; caplen -= archdrlen; p += archdrlen; - if (phds && flag && (flag & 1) == 0) - goto out2; + if (phds && flag && (flag & 1) == 0) { + /* + * This is a middle fragment. + */ + return (archdrlen); + } - if (!arcnet_encap_print(arc_type, p, length, caplen)) { + if (!arcnet_encap_print(arc_type, p, length, caplen)) default_print(p, caplen); - goto out; + + return (archdrlen); +} + +/* + * This is the top level routine of the printer. 'p' points + * to the ARCNET header of the packet, 'h->ts' is the timestamp, + * 'h->length' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. It is quite similar + * to the non-Linux style printer except that Linux doesn't ever + * supply packets that look like exception frames, it always supplies + * reassembled packets rather than raw frames, and headers have an + * extra "offset" field between the src/dest and packet type. + */ +u_int +arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + u_int length = h->len; + const struct arc_linux_header *ap; + + int archdrlen = 0; + u_char arc_type; + + if (caplen < ARC_LINUX_HDRLEN) { + printf("[|arcnet]"); + return (caplen); } - out2: - if (xflag) + ap = (const struct arc_linux_header *)p; + arc_type = ap->arc_type; + + switch (arc_type) { + default: + archdrlen = ARC_LINUX_HDRNEWLEN; + if (caplen < ARC_LINUX_HDRNEWLEN) { + printf("[|arcnet]"); + return (caplen); + } + break; + case ARCTYPE_IP_OLD: + case ARCTYPE_ARP_OLD: + case ARCTYPE_DIAGNOSE: + archdrlen = ARC_LINUX_HDRLEN; + break; + } + + if (eflag) + arcnet_print(p, length, 0, 0, 0); + + /* + * Go past the ARCNET header. + */ + length -= archdrlen; + caplen -= archdrlen; + p += archdrlen; + + if (!arcnet_encap_print(arc_type, p, length, caplen)) default_print(p, caplen); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return (archdrlen); } /* @@ -210,7 +251,7 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) */ -int +static int arcnet_encap_print(u_char arctype, const u_char *p, u_int length, u_int caplen) { @@ -239,6 +280,10 @@ arcnet_encap_print(u_char arctype, const u_char *p, atalk_print(p, length); return (1); + case ARCTYPE_IPX: + ipx_print(p, length); + return (1); + default: return (0); } diff --git a/contrib/tcpdump/print-ascii.c b/contrib/tcpdump/print-ascii.c index 8c086d2..b7f868d 100644 --- a/contrib/tcpdump/print-ascii.c +++ b/contrib/tcpdump/print-ascii.c @@ -41,78 +41,101 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.6 2000/01/29 16:47:46 itojun Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.10.2.3 2003/12/29 22:42:20 hannes Exp $"; #endif +#include <tcpdump-stdinc.h> #include <stdio.h> -#include <sys/types.h> -#include <ctype.h> #include "interface.h" +#define ASCII_LINELENGTH 300 #define HEXDUMP_BYTES_PER_LINE 16 #define HEXDUMP_SHORTS_PER_LINE (HEXDUMP_BYTES_PER_LINE / 2) #define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */ #define HEXDUMP_HEXSTUFF_PER_LINE \ (HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE) - + void -ascii_print_with_offset(register const u_char *cp, register u_int length, +ascii_print_with_offset(register const u_char *ident, register const u_char *cp, register u_int length, register u_int oset) { register u_int i; register int s1, s2; register int nshorts; char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp; - char asciistuff[HEXDUMP_BYTES_PER_LINE+1], *asp; + char asciistuff[ASCII_LINELENGTH+1], *asp; + u_int maxlength = (Aflag ? ASCII_LINELENGTH : HEXDUMP_SHORTS_PER_LINE); nshorts = length / sizeof(u_short); i = 0; hsp = hexstuff; asp = asciistuff; + if (Aflag) *(asp++) = '\n'; while (--nshorts >= 0) { s1 = *cp++; s2 = *cp++; - (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), - " %02x%02x", s1, s2); - hsp += HEXDUMP_HEXSTUFF_PER_SHORT; - *(asp++) = (isgraph(s1) ? s1 : '.'); - *(asp++) = (isgraph(s2) ? s2 : '.'); - if (++i >= HEXDUMP_SHORTS_PER_LINE) { - *hsp = *asp = '\0'; - (void)printf("\n0x%04x\t%-*s\t%s", - oset, HEXDUMP_HEXSTUFF_PER_LINE, - hexstuff, asciistuff); - i = 0; hsp = hexstuff; asp = asciistuff; - oset += HEXDUMP_BYTES_PER_LINE; + if (Aflag) { + i += 2; + *(asp++) = (isgraph(s1) ? s1 : (s1 != '\t' && s1 != ' ' && s1 != '\n' && s1 != '\r' ? '.' : s1) ); + *(asp++) = (isgraph(s2) ? s2 : (s2 != '\t' && s2 != ' ' && s2 != '\n' && s2 != '\r' ? '.' : s2) ); + if (s1 == '\n' || s2 == '\n') i = maxlength; + + } else { + (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), + " %02x%02x", s1, s2); + hsp += HEXDUMP_HEXSTUFF_PER_SHORT; + *(asp++) = (isgraph(s1) ? s1 : '.'); + *(asp++) = (isgraph(s2) ? s2 : '.'); + i++; + } + if (i >= maxlength) { + *hsp = *asp = '\0'; + if (Aflag) { + (void)printf("%s", asciistuff); + } else { + (void)printf("%s0x%04x: %-*s %s", + ident, oset, HEXDUMP_HEXSTUFF_PER_LINE, + hexstuff, asciistuff); + } + i = 0; hsp = hexstuff; asp = asciistuff; + oset += HEXDUMP_BYTES_PER_LINE; } } if (length & 1) { s1 = *cp++; - (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), - " %02x", s1); - hsp += 3; - *(asp++) = (isgraph(s1) ? s1 : '.'); + if (Aflag) { + *(asp++) = (isgraph(s1) ? s1 : (s1 != '\t' && s1 != ' ' && s1 != '\n' && s1 != '\r' ? '.' : s1) ); + } else { + (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), + " %02x", s1); + hsp += 3; + *(asp++) = (isgraph(s1) ? s1 : '.'); + } ++i; } if (i > 0) { *hsp = *asp = '\0'; - (void)printf("\n0x%04x\t%-*s\t%s", - oset, HEXDUMP_HEXSTUFF_PER_LINE, + if (Aflag) { + (void)printf("%s%s", ident, asciistuff); + } else { + (void)printf("%s0x%04x: %-*s %s", + ident, oset, HEXDUMP_HEXSTUFF_PER_LINE, hexstuff, asciistuff); + } } } void -ascii_print(register const u_char *cp, register u_int length) +ascii_print(register const u_char *ident, register const u_char *cp, register u_int length) { - ascii_print_with_offset(cp, length, 0); + ascii_print_with_offset(ident, cp, length, 0); } - + /* * telnet_print() wants this. It is essentially default_print_unaligned() */ void -hex_print_with_offset(register const u_char *cp, register u_int length, +hex_print_with_offset(register const u_char *ident, register const u_char *cp, register u_int length, register u_int oset) { register u_int i, s; @@ -122,7 +145,7 @@ hex_print_with_offset(register const u_char *cp, register u_int length, i = 0; while (--nshorts >= 0) { if ((i++ % 8) == 0) { - (void)printf("\n0x%04x\t", oset); + (void)printf("%s0x%04x: ", ident, oset); oset += HEXDUMP_BYTES_PER_LINE; } s = *cp++; @@ -130,7 +153,7 @@ hex_print_with_offset(register const u_char *cp, register u_int length, } if (length & 1) { if ((i % 8) == 0) - (void)printf("\n0x%04x\t", oset); + (void)printf("%s0x%04x: ", ident, oset); (void)printf(" %02x", *cp); } } @@ -139,9 +162,9 @@ hex_print_with_offset(register const u_char *cp, register u_int length, * just for completeness */ void -hex_print(register const u_char *cp, register u_int length) +hex_print(register const u_char *ident, register const u_char *cp, register u_int length) { - hex_print_with_offset(cp, length, 0); + hex_print_with_offset(ident, cp, length, 0); } #ifdef MAIN @@ -158,3 +181,5 @@ main(int argc, char *argv[]) exit(0); } #endif /* MAIN */ + + diff --git a/contrib/tcpdump/print-beep.c b/contrib/tcpdump/print-beep.c index 4cb6916..b566254 100644 --- a/contrib/tcpdump/print-beep.c +++ b/contrib/tcpdump/print-beep.c @@ -1,8 +1,8 @@ /* * Copyright (C) 2000, Richard Sharpe * - * This software may be distributed either under the terms of the - * BSD-style licence that accompanies tcpdump or under the GNU GPL + * This software may be distributed either under the terms of the + * BSD-style licence that accompanies tcpdump or under the GNU GPL * version 2 or later. * * print-beep.c @@ -10,16 +10,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.1.2.1 2002/07/11 07:47:01 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.4.2.2 2003/11/16 08:51:12 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> +#include <tcpdump-stdinc.h> #ifdef HAVE_MEMORY_H #include <memory.h> @@ -27,14 +26,13 @@ static const char rcsid[] = #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include "interface.h" #include "extract.h" /* Check for a string but not go beyond length * Return TRUE on match, FALSE otherwise - * + * * Looks at the first few chars up to tl1 ... */ @@ -68,6 +66,6 @@ beep_print(const u_char *bp, u_int length) printf(" BEEP SEQ"); else if (l_strnstart("END", 4, (const char *)bp, length)) printf(" BEEP END"); - else + else printf(" BEEP (payload or undecoded)"); } diff --git a/contrib/tcpdump/print-bfd.c b/contrib/tcpdump/print-bfd.c new file mode 100644 index 0000000..2c6aec4 --- /dev/null +++ b/contrib/tcpdump/print-bfd.c @@ -0,0 +1,160 @@ +/* + * 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. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.3.2.2 2003/11/16 08:51:12 guy Exp $"; +#endif + +#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 "addrtoname.h" + +#include "udp.h" + +/* + * Control packet, draft-katz-ward-bfd-01.txt + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |Vers | Diag |H|D|P|F| Rsvd | Detect Mult | Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | My Discriminator | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Your Discriminator | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Desired Min TX Interval | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Required Min RX Interval | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Required Min Echo RX Interval | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct bfd_header_t { + u_int8_t version_diag; + u_int8_t flags; + u_int8_t detect_time_multiplier; + u_int8_t length; + u_int8_t my_discriminator[4]; + u_int8_t your_discriminator[4]; + u_int8_t desired_min_tx_interval[4]; + u_int8_t required_min_rx_interval[4]; + u_int8_t required_min_echo_interval[4]; +}; + +#define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5) +#define BFD_EXTRACT_DIAG(x) ((x)&0x1f) + +static const struct tok bfd_port_values[] = { + { BFD_CONTROL_PORT, "Control" }, + { BFD_ECHO_PORT, "Echo" }, + { 0, NULL } +}; + + +static const struct tok bfd_diag_values[] = { + { 0, "No Diagnostic" }, + { 1, "Control Detection Time Expired" }, + { 2, "Echo Function Failed" }, + { 3, "Neighbor Signaled Session Down" }, + { 4, "Forwarding Plane Reset" }, + { 5, "Path Down" }, + { 6, "Concatenated Path Down" }, + { 7, "Administratively Down" }, + { 0, NULL } +}; + +static const struct tok bfd_flag_values[] = { + { 0x80, "I Hear You" }, + { 0x40, "Demand" }, + { 0x20, "Poll" }, + { 0x10, "Final" }, + { 0x08, "Reserved" }, + { 0x04, "Reserved" }, + { 0x02, "Reserved" }, + { 0x01, "Reserved" }, + { 0, NULL } +}; + +void +bfd_print(register const u_char *pptr, register u_int len, register u_int port) +{ + const struct bfd_header_t *bfd_header; + + bfd_header = (const struct bfd_header_t *)pptr; + TCHECK(*bfd_header); + + switch (port) { + + case BFD_CONTROL_PORT: + if (vflag < 1 ) + { + printf("BFDv%u, %s, Flags: [%s], length: %u", + BFD_EXTRACT_VERSION(bfd_header->version_diag), + tok2str(bfd_port_values, "unknown (%u)", port), + bittok2str(bfd_flag_values, "none", bfd_header->flags), + len); + return; + } + + printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)", + BFD_EXTRACT_VERSION(bfd_header->version_diag), + len, + tok2str(bfd_port_values, "unknown (%u)", port), + bittok2str(bfd_flag_values, "none", bfd_header->flags), + tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)), + BFD_EXTRACT_DIAG(bfd_header->version_diag)); + + printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u", + bfd_header->detect_time_multiplier, + bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000, + bfd_header->length); + + + printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)); + printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)); + printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000); + printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000); + printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000); + break; + + case BFD_ECHO_PORT: /* not yet supported - fall through */ + + default: + printf("BFD, %s, length: %u", + tok2str(bfd_port_values, "unknown (%u)", port), + len); + if (vflag >= 1) { + if(!print_unknown_data(pptr,"\n\t",len)) + return; + } + break; + } + return; + +trunc: + printf("[|BFD]"); +} diff --git a/contrib/tcpdump/print-bgp.c b/contrib/tcpdump/print-bgp.c index b14067d..bfa472a 100644 --- a/contrib/tcpdump/print-bgp.c +++ b/contrib/tcpdump/print-bgp.c @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -25,6 +25,9 @@ * 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. + * + * Extensively modified by Hannes Gredler (hannes@juniper.net) for more + * complete BGP support. */ #ifdef HAVE_CONFIG_H @@ -32,21 +35,14 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.27.2.1 2003/02/26 05:51:56 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.72.2.4 2004/03/24 00:04:04 guy Exp $"; #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <errno.h> #include <stdio.h> #include <string.h> -#include <netdb.h> #include "interface.h" #include "addrtoname.h" @@ -63,6 +59,16 @@ struct bgp { #define BGP_UPDATE 2 #define BGP_NOTIFICATION 3 #define BGP_KEEPALIVE 4 +#define BGP_ROUTE_REFRESH 5 + +static struct tok bgp_msg_values[] = { + { BGP_OPEN, "Open"}, + { BGP_UPDATE, "Update"}, + { BGP_NOTIFICATION, "Notification"}, + { BGP_KEEPALIVE, "Keepalive"}, + { BGP_ROUTE_REFRESH, "Route Refresh"}, + { 0, NULL} +}; struct bgp_open { u_int8_t bgpo_marker[16]; @@ -90,10 +96,19 @@ struct bgp_notification { u_int8_t bgpn_type; u_int8_t bgpn_major; u_int8_t bgpn_minor; - /* data should follow */ }; #define BGP_NOTIFICATION_SIZE 21 /* unaligned */ +struct bgp_route_refresh { + u_int8_t bgp_marker[16]; + u_int16_t len; + u_int8_t type; + u_int8_t afi[2]; /* the compiler messes this structure up */ + u_int8_t res; /* when doing misaligned sequences of int8 and int16 */ + u_int8_t safi; /* afi should be int16 - so we have to access it using */ +}; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */ +#define BGP_ROUTE_REFRESH_SIZE 23 + struct bgp_attr { u_int8_t bgpa_flags; u_int8_t bgpa_type; @@ -103,7 +118,7 @@ struct bgp_attr { } bgpa_len; #define bgp_attr_len(p) \ (((p)->bgpa_flags & 0x10) ? \ - ntohs((p)->bgpa_len.elen) : (p)->bgpa_len.len) + EXTRACT_16BITS(&(p)->bgpa_len.elen) : (p)->bgpa_len.len) #define bgp_attr_off(p) \ (((p)->bgpa_flags & 0x10) ? 4 : 3) }; @@ -118,88 +133,185 @@ struct bgp_attr { #define BGPTYPE_COMMUNITIES 8 /* RFC1997 */ #define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */ #define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */ -#define BGPTYPE_DPA 11 /* work in progress */ +#define BGPTYPE_DPA 11 /* draft-ietf-idr-bgp-dpa */ #define BGPTYPE_ADVERTISERS 12 /* RFC1863 */ #define BGPTYPE_RCID_PATH 13 /* RFC1863 */ #define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */ #define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */ +#define BGPTYPE_EXTD_COMMUNITIES 16 /* draft-ietf-idr-bgp-ext-communities */ + +static struct tok bgp_attr_values[] = { + { BGPTYPE_ORIGIN, "Origin"}, + { BGPTYPE_AS_PATH, "AS Path"}, + { BGPTYPE_NEXT_HOP, "Next Hop"}, + { BGPTYPE_MULTI_EXIT_DISC, "Multi Exit Discriminator"}, + { BGPTYPE_LOCAL_PREF, "Local Preference"}, + { BGPTYPE_ATOMIC_AGGREGATE, "Atomic Aggregate"}, + { BGPTYPE_AGGREGATOR, "Aggregator"}, + { BGPTYPE_COMMUNITIES, "Community"}, + { BGPTYPE_ORIGINATOR_ID, "Originator ID"}, + { BGPTYPE_CLUSTER_LIST, "Cluster List"}, + { BGPTYPE_DPA, "DPA"}, + { BGPTYPE_ADVERTISERS, "Advertisers"}, + { BGPTYPE_RCID_PATH, "RCID Path / Cluster ID"}, + { BGPTYPE_MP_REACH_NLRI, "Multi-Protocol Reach NLRI"}, + { BGPTYPE_MP_UNREACH_NLRI, "Multi-Protocol Unreach NLRI"}, + { BGPTYPE_EXTD_COMMUNITIES, "Extended Community"}, + { 255, "Reserved for development"}, + { 0, NULL} +}; +#define BGP_AS_SET 1 +#define BGP_AS_SEQUENCE 2 +#define BGP_CONFED_AS_SEQUENCE 3 /* draft-ietf-idr-rfc3065bis-01 */ +#define BGP_CONFED_AS_SET 4 /* draft-ietf-idr-rfc3065bis-01 */ + +static struct tok bgp_as_path_segment_open_values[] = { + { BGP_AS_SEQUENCE, ""}, + { BGP_AS_SET, "{ "}, + { BGP_CONFED_AS_SEQUENCE, "( "}, + { BGP_CONFED_AS_SET, "({ "}, + { 0, NULL} +}; -static const char *bgptype[] = { - NULL, "OPEN", "UPDATE", "NOTIFICATION", "KEEPALIVE", +static struct tok bgp_as_path_segment_close_values[] = { + { BGP_AS_SEQUENCE, ""}, + { BGP_AS_SET, "}"}, + { BGP_CONFED_AS_SEQUENCE, ")"}, + { BGP_CONFED_AS_SET, "})"}, + { 0, NULL} }; -#define bgp_type(x) num_or_str(bgptype, sizeof(bgptype)/sizeof(bgptype[0]), (x)) -static const char *bgpopt_type[] = { - NULL, "Authentication Information", "Capabilities Advertisement", +#define BGP_OPT_AUTH 1 +#define BGP_OPT_CAP 2 + + +static struct tok bgp_opt_values[] = { + { BGP_OPT_AUTH, "Authentication Information"}, + { BGP_OPT_CAP, "Capabilities Advertisement"}, + { 0, NULL} }; -#define bgp_opttype(x) \ - num_or_str(bgpopt_type, sizeof(bgpopt_type)/sizeof(bgpopt_type[0]), (x)) - -static const char *bgpnotify_major[] = { - NULL, "Message Header Error", - "OPEN Message Error", "UPDATE Message Error", - "Hold Timer Expired", "Finite State Machine Error", - "Cease", + +#define BGP_CAPCODE_MP 1 +#define BGP_CAPCODE_RR 2 +#define BGP_CAPCODE_RESTART 64 /* draft-ietf-idr-restart-05 */ +#define BGP_CAPCODE_RR_CISCO 128 + +static struct tok bgp_capcode_values[] = { + { BGP_CAPCODE_MP, "Multiprotocol Extensions"}, + { BGP_CAPCODE_RR, "Route Refresh"}, + { BGP_CAPCODE_RESTART, "Graceful Restart"}, + { BGP_CAPCODE_RR_CISCO, "Route Refresh (Cisco)"}, + { 0, NULL} }; -#define bgp_notify_major(x) \ - num_or_str(bgpnotify_major, \ - sizeof(bgpnotify_major)/sizeof(bgpnotify_major[0]), (x)) -static const char *bgpnotify_minor_1[] = { - NULL, "Connection Not Synchronized", - "Bad Message Length", "Bad Message Type", +#define BGP_NOTIFY_MAJOR_MSG 1 +#define BGP_NOTIFY_MAJOR_OPEN 2 +#define BGP_NOTIFY_MAJOR_UPDATE 3 +#define BGP_NOTIFY_MAJOR_HOLDTIME 4 +#define BGP_NOTIFY_MAJOR_FSM 5 +#define BGP_NOTIFY_MAJOR_CEASE 6 +#define BGP_NOTIFY_MAJOR_CAP 7 + +static struct tok bgp_notify_major_values[] = { + { BGP_NOTIFY_MAJOR_MSG, "Message Header Error"}, + { BGP_NOTIFY_MAJOR_OPEN, "OPEN Message Error"}, + { BGP_NOTIFY_MAJOR_UPDATE, "UPDATE Message Error"}, + { BGP_NOTIFY_MAJOR_HOLDTIME,"Hold Timer Expired"}, + { BGP_NOTIFY_MAJOR_FSM, "Finite State Machine Error"}, + { BGP_NOTIFY_MAJOR_CEASE, "Cease"}, + { BGP_NOTIFY_MAJOR_CAP, "Capability Message Error"}, + { 0, NULL} }; -static const char *bgpnotify_minor_2[] = { - NULL, "Unsupported Version Number", - "Bad Peer AS", "Bad BGP Identifier", - "Unsupported Optional Parameter", "Authentication Failure", - "Unacceptable Hold Time", +/* draft-ietf-idr-cease-subcode-02 */ +#define BGP_NOTIFY_MINOR_CEASE_MAXPRFX 1 +static struct tok bgp_notify_minor_cease_values[] = { + { BGP_NOTIFY_MINOR_CEASE_MAXPRFX, "Maximum Number of Prefixes Reached"}, + { 2, "Administratively Shutdown"}, + { 3, "Peer Unconfigured"}, + { 4, "Administratively Reset"}, + { 5, "Connection Rejected"}, + { 6, "Other Configuration Change"}, + { 7, "Connection Collision Resolution"}, + { 0, NULL} }; -static const char *bgpnotify_minor_3[] = { - NULL, "Malformed Attribute List", - "Unrecognized Well-known Attribute", "Missing Well-known Attribute", - "Attribute Flags Error", "Attribute Length Error", - "Invalid ORIGIN Attribute", "AS Routing Loop", - "Invalid NEXT_HOP Attribute", "Optional Attribute Error", - "Invalid Network Field", "Malformed AS_PATH", +static struct tok bgp_notify_minor_msg_values[] = { + { 1, "Connection Not Synchronized"}, + { 2, "Bad Message Length"}, + { 3, "Bad Message Type"}, + { 0, NULL} }; -static const char **bgpnotify_minor[] = { - NULL, bgpnotify_minor_1, bgpnotify_minor_2, bgpnotify_minor_3, +static struct tok bgp_notify_minor_open_values[] = { + { 1, "Unsupported Version Number"}, + { 2, "Bad Peer AS"}, + { 3, "Bad BGP Identifier"}, + { 4, "Unsupported Optional Parameter"}, + { 5, "Authentication Failure"}, + { 6, "Unacceptable Hold Time"}, + { 0, NULL} }; -static const int bgpnotify_minor_siz[] = { - 0, sizeof(bgpnotify_minor_1)/sizeof(bgpnotify_minor_1[0]), - sizeof(bgpnotify_minor_2)/sizeof(bgpnotify_minor_2[0]), - sizeof(bgpnotify_minor_3)/sizeof(bgpnotify_minor_3[0]), + +static struct tok bgp_notify_minor_update_values[] = { + { 1, "Malformed Attribute List"}, + { 2, "Unrecognized Well-known Attribute"}, + { 3, "Missing Well-known Attribute"}, + { 4, "Attribute Flags Error"}, + { 5, "Attribute Length Error"}, + { 6, "Invalid ORIGIN Attribute"}, + { 7, "AS Routing Loop"}, + { 8, "Invalid NEXT_HOP Attribute"}, + { 9, "Optional Attribute Error"}, + { 10, "Invalid Network Field"}, + { 11, "Malformed AS_PATH"}, + { 0, NULL} }; -static const char *bgpattr_origin[] = { - "IGP", "EGP", "INCOMPLETE", +static struct tok bgp_notify_minor_cap_values[] = { + { 1, "Invalid Action Value" }, + { 2, "Invalid Capability Length" }, + { 3, "Malformed Capability Value" }, + { 4, "Unsupported Capability Code" }, + { 0, NULL } }; -#define bgp_attr_origin(x) \ - num_or_str(bgpattr_origin, \ - sizeof(bgpattr_origin)/sizeof(bgpattr_origin[0]), (x)) - -static const char *bgpattr_type[] = { - NULL, "ORIGIN", "AS_PATH", "NEXT_HOP", - "MULTI_EXIT_DISC", "LOCAL_PREF", "ATOMIC_AGGREGATE", "AGGREGATOR", - "COMMUNITIES", "ORIGINATOR_ID", "CLUSTER_LIST", "DPA", - "ADVERTISERS", "RCID_PATH", "MP_REACH_NLRI", "MP_UNREACH_NLRI", + +static struct tok bgp_origin_values[] = { + { 0, "IGP"}, + { 1, "EGP"}, + { 2, "Incomplete"}, + { 0, NULL} }; -#define bgp_attr_type(x) \ - num_or_str(bgpattr_type, \ - sizeof(bgpattr_type)/sizeof(bgpattr_type[0]), (x)) /* Subsequent address family identifier, RFC2283 section 7 */ -static const char *bgpattr_nlri_safi[] = { - "Reserved", "Unicast", "Multicast", "Unicast+Multicast", +#define SAFNUM_RES 0 +#define SAFNUM_UNICAST 1 +#define SAFNUM_MULTICAST 2 +#define SAFNUM_UNIMULTICAST 3 +/* labeled BGP RFC3107 */ +#define SAFNUM_LABUNICAST 4 +/* Section 4.3.4 of draft-rosen-rfc2547bis-03.txt */ +#define SAFNUM_VPNUNICAST 128 +#define SAFNUM_VPNMULTICAST 129 +#define SAFNUM_VPNUNIMULTICAST 130 +/* draft-marques-ppvpn-rt-constrain-01.txt */ +#define SAFNUM_RT_ROUTING_INFO 132 + +#define BGP_VPN_RD_LEN 8 + +static struct tok bgp_safi_values[] = { + { SAFNUM_RES, "Reserved"}, + { SAFNUM_UNICAST, "Unicast"}, + { SAFNUM_MULTICAST, "Multicast"}, + { SAFNUM_UNIMULTICAST, "Unicast+Multicast"}, + { SAFNUM_LABUNICAST, "labeled Unicast"}, + { SAFNUM_VPNUNICAST, "labeled VPN Unicast"}, + { SAFNUM_VPNMULTICAST, "labeled VPN Multicast"}, + { SAFNUM_VPNUNIMULTICAST, "labeled VPN Unicast+Multicast"}, + { SAFNUM_RT_ROUTING_INFO, "Route Target Routing Information"}, + { 0, NULL } }; -#define bgp_attr_nlri_safi(x) \ - num_or_str(bgpattr_nlri_safi, \ - sizeof(bgpattr_nlri_safi)/sizeof(bgpattr_nlri_safi[0]), (x)) /* well-known community */ #define BGP_COMMUNITY_NO_EXPORT 0xffffff01 @@ -222,74 +334,342 @@ static const char *bgpattr_nlri_safi[] = { #define AFNUM_DECNET 13 #define AFNUM_BANYAN 14 #define AFNUM_E164NSAP 15 +/* draft-kompella-ppvpn-l2vpn */ +#define AFNUM_L2VPN 196 /* still to be approved by IANA */ + +static struct tok bgp_afi_values[] = { + { 0, "Reserved"}, + { AFNUM_INET, "IPv4"}, + { AFNUM_INET6, "IPv6"}, + { AFNUM_NSAP, "NSAP"}, + { AFNUM_HDLC, "HDLC"}, + { AFNUM_BBN1822, "BBN 1822"}, + { AFNUM_802, "802"}, + { AFNUM_E163, "E.163"}, + { AFNUM_E164, "E.164"}, + { AFNUM_F69, "F.69"}, + { AFNUM_X121, "X.121"}, + { AFNUM_IPX, "Novell IPX"}, + { AFNUM_ATALK, "Appletalk"}, + { AFNUM_DECNET, "Decnet IV"}, + { AFNUM_BANYAN, "Banyan Vines"}, + { AFNUM_E164NSAP, "E.164 with NSAP subaddress"}, + { AFNUM_L2VPN, "Layer-2 VPN"}, + { 0, NULL}, +}; + +/* Extended community type - draft-ietf-idr-bgp-ext-communities-05 */ +#define BGP_EXT_COM_RT_0 0x0002 /* Route Target,Format AS(2bytes):AN(4bytes) */ +#define BGP_EXT_COM_RT_1 0x0102 /* Route Target,Format IP address:AN(2bytes) */ +#define BGP_EXT_COM_RT_2 0x0202 /* Route Target,Format AN(4bytes):local(2bytes) */ +#define BGP_EXT_COM_RO_0 0x0003 /* Route Origin,Format AS(2bytes):AN(4bytes) */ +#define BGP_EXT_COM_RO_1 0x0103 /* Route Origin,Format IP address:AN(2bytes) */ +#define BGP_EXT_COM_RO_2 0x0203 /* Route Origin,Format AN(4bytes):local(2bytes) */ +#define BGP_EXT_COM_LINKBAND 0x4004 /* Link Bandwidth,Format AS(2B):Bandwidth(4B) */ + /* rfc2547 bgp-mpls-vpns */ + +#define BGP_EXT_COM_VPN_ORIGIN 0x0005 /* OSPF Domain ID / VPN of Origin - draft-rosen-vpns-ospf-bgp-mpls */ +#define BGP_EXT_COM_VPN_ORIGIN2 0x0105 /* duplicate - keep for backwards compatability */ +#define BGP_EXT_COM_VPN_ORIGIN3 0x0205 /* duplicate - keep for backwards compatability */ +#define BGP_EXT_COM_VPN_ORIGIN4 0x8005 /* duplicate - keep for backwards compatability */ + +#define BGP_EXT_COM_OSPF_RTYPE 0x0306 /* OSPF Route Type,Format Area(4B):RouteType(1B):Options(1B) */ +#define BGP_EXT_COM_OSPF_RTYPE2 0x8000 /* duplicate - keep for backwards compatability */ + +#define BGP_EXT_COM_OSPF_RID 0x0107 /* OSPF Router ID,Format RouterID(4B):Unused(2B) */ +#define BGP_EXT_COM_OSPF_RID2 0x8001 /* duplicate - keep for backwards compatability */ + +#define BGP_EXT_COM_L2INFO 0x800a /* draft-kompella-ppvpn-l2vpn */ + +static struct tok bgp_extd_comm_flag_values[] = { + { 0x8000, "vendor-specific"}, + { 0x4000, "non-transitive"}, + { 0, NULL}, +}; -static const char *afnumber[] = { - "Reserved", "IPv4", "IPv6", "NSAP", "HDLC", - "BBN 1822", "802", "E.163", "E.164", "F.69", - "X.121", "IPX", "Appletalk", "Decnet IV", "Banyan Vines", - "E.164 with NSAP subaddress", +static struct tok bgp_extd_comm_subtype_values[] = { + { BGP_EXT_COM_RT_0, "target"}, + { BGP_EXT_COM_RT_1, "target"}, + { BGP_EXT_COM_RT_2, "target"}, + { BGP_EXT_COM_RO_0, "origin"}, + { BGP_EXT_COM_RO_1, "origin"}, + { BGP_EXT_COM_RO_2, "origin"}, + { BGP_EXT_COM_LINKBAND, "link-BW"}, + { BGP_EXT_COM_VPN_ORIGIN, "ospf-domain"}, + { BGP_EXT_COM_VPN_ORIGIN2, "ospf-domain"}, + { BGP_EXT_COM_VPN_ORIGIN3, "ospf-domain"}, + { BGP_EXT_COM_VPN_ORIGIN4, "ospf-domain"}, + { BGP_EXT_COM_OSPF_RTYPE, "ospf-route-type"}, + { BGP_EXT_COM_OSPF_RTYPE2, "ospf-route-type"}, + { BGP_EXT_COM_OSPF_RID, "ospf-router-id"}, + { BGP_EXT_COM_OSPF_RID2, "ospf-router-id"}, + { BGP_EXT_COM_L2INFO, "layer2-info"}, + { 0, NULL}, }; -#define af_name(x) \ - (((x) == 65535) ? afnumber[0] : \ - num_or_str(afnumber, \ - sizeof(afnumber)/sizeof(afnumber[0]), (x))) +/* OSPF codes for BGP_EXT_COM_OSPF_RTYPE draft-rosen-vpns-ospf-bgp-mpls */ +#define BGP_OSPF_RTYPE_RTR 1 /* OSPF Router LSA */ +#define BGP_OSPF_RTYPE_NET 2 /* OSPF Network LSA */ +#define BGP_OSPF_RTYPE_SUM 3 /* OSPF Summary LSA */ +#define BGP_OSPF_RTYPE_EXT 5 /* OSPF External LSA, note that ASBR doesn't apply to MPLS-VPN */ +#define BGP_OSPF_RTYPE_NSSA 7 /* OSPF NSSA External*/ +#define BGP_OSPF_RTYPE_SHAM 129 /* OSPF-MPLS-VPN Sham link */ +#define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */ + +static struct tok bgp_extd_comm_ospf_rtype_values[] = { + { BGP_OSPF_RTYPE_RTR, "Router" }, + { BGP_OSPF_RTYPE_NET, "Network" }, + { BGP_OSPF_RTYPE_SUM, "Summary" }, + { BGP_OSPF_RTYPE_EXT, "External" }, + { BGP_OSPF_RTYPE_NSSA,"NSSA External" }, + { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" }, + { 0, NULL }, +}; + +static struct tok bgp_l2vpn_encaps_values[] = { + { 0, "Reserved"}, + { 1, "Frame Relay"}, + { 2, "ATM AAL5 VCC transport"}, + { 3, "ATM transparent cell transport"}, + { 4, "Ethernet VLAN"}, + { 5, "Ethernet"}, + { 6, "Cisco-HDLC"}, + { 7, "PPP"}, + { 8, "CEM"}, + { 9, "ATM VCC cell transport"}, + { 10, "ATM VPC cell transport"}, + { 11, "MPLS"}, + { 12, "VPLS"}, + { 64, "IP-interworking"}, + { 0, NULL}, +}; -static const char * -num_or_str(const char **table, size_t siz, int value) +static int +decode_prefix4(const u_char *pptr, char *buf, u_int buflen) { - static char buf[20]; - if (value < 0 || siz <= value || table[value] == NULL) { - snprintf(buf, sizeof(buf), "#%d", value); - return buf; - } else - return table[value]; + struct in_addr addr; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; + if (32 < plen) + return -1; + + memset(&addr, 0, sizeof(addr)); + TCHECK2(pptr[1], (plen + 7) / 8); + memcpy(&addr, &pptr[1], (plen + 7) / 8); + if (plen % 8) { + ((u_char *)&addr)[(plen + 7) / 8 - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen); + return 1 + (plen + 7) / 8; + +trunc: + return -2; +} + +static int +decode_labeled_prefix4(const u_char *pptr, char *buf, u_int buflen) +{ + struct in_addr addr; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + + /* this is one of the weirdnesses of rfc3107 + the label length (actually the label + COS bits) + is added to the prefix length; + we also do only read out just one label - + there is no real application for advertisement of + stacked labels in a a single BGP message + */ + + plen-=24; /* adjust prefixlen - labellength */ + + if (32 < plen) + return -1; + + memset(&addr, 0, sizeof(addr)); + TCHECK2(pptr[4], (plen + 7) / 8); + memcpy(&addr, &pptr[4], (plen + 7) / 8); + if (plen % 8) { + ((u_char *)&addr)[(plen + 7) / 8 - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + /* the label may get offsetted by 4 bits so lets shift it right */ + snprintf(buf, buflen, "%s/%d, label:%u %s", + getname((u_char *)&addr), + plen, + EXTRACT_24BITS(pptr+1)>>4, + ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); + + return 4 + (plen + 7) / 8; + +trunc: + return -2; } -static const char * -bgp_notify_minor(int major, int minor) +/* RDs and RTs share the same semantics + * we use bgp_vpn_rd_print for + * printing route targets inside a NLRI */ +static char * +bgp_vpn_rd_print (const u_char *pptr) { + + /* allocate space for the following string + * xxx.xxx.xxx.xxx:xxxxx + * 21 bytes plus one termination byte */ + static char rd[22]; + char *pos = rd; + + /* ok lets load the RD format */ + switch (EXTRACT_16BITS(pptr)) { + + /* AS:IP-address fmt*/ + case 0: + snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u.%u.%u.%u", + EXTRACT_16BITS(pptr+2), *(pptr+4), *(pptr+5), *(pptr+6), *(pptr+7)); + break; + /* IP-address:AS fmt*/ + + case 1: + snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u", + *(pptr+2), *(pptr+3), *(pptr+4), *(pptr+5), EXTRACT_16BITS(pptr+6)); + break; + + /* 4-byte-AS:number fmt*/ + case 2: + snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u", + EXTRACT_32BITS(pptr+2), EXTRACT_16BITS(pptr+6)); + break; + default: + snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format"); + break; + } + pos += strlen(pos); + *(pos) = '\0'; + return (rd); +} + +static int +decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen) { - static const char **table; - int siz; - static char buf[20]; - const char *p; - - if (0 <= major - && major < sizeof(bgpnotify_minor)/sizeof(bgpnotify_minor[0]) - && bgpnotify_minor[major]) { - table = bgpnotify_minor[major]; - siz = bgpnotify_minor_siz[major]; - if (0 <= minor && minor < siz && table[minor]) - p = table[minor]; - else - p = NULL; - } else - p = NULL; - if (p == NULL) { - snprintf(buf, sizeof(buf), "#%d", minor); - return buf; - } else - return p; + u_int8_t route_target[8]; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + + plen-=32; /* adjust prefix length */ + + if (0 < plen) + return -1; + + memset(&route_target, 0, sizeof(route_target)); + TCHECK2(pptr[1], (plen + 7) / 8); + memcpy(&route_target, &pptr[1], (plen + 7) / 8); + if (plen % 8) { + ((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)); + + return 5 + (plen + 7) / 8; + +trunc: + return -2; } static int -decode_prefix4(const u_char *pd, char *buf, u_int buflen) +decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen) { struct in_addr addr; u_int plen; - plen = pd[0]; - if (plen < 0 || 32 < plen) + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + + plen-=(24+64); /* adjust prefixlen - labellength - RD len*/ + + if (32 < plen) return -1; memset(&addr, 0, sizeof(addr)); - memcpy(&addr, &pd[1], (plen + 7) / 8); + TCHECK2(pptr[12], (plen + 7) / 8); + memcpy(&addr, &pptr[12], (plen + 7) / 8); if (plen % 8) { ((u_char *)&addr)[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen); - return 1 + (plen + 7) / 8; + /* the label may get offsetted by 4 bits so lets shift it right */ + snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s", + bgp_vpn_rd_print(pptr+4), + getname((u_char *)&addr), + plen, + EXTRACT_24BITS(pptr+1)>>4, + ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); + + return 12 + (plen + 7) / 8; + +trunc: + return -2; +} + +static int +decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen) +{ + int plen,tlen,strlen,tlv_type,tlv_len,ttlv_len; + + TCHECK2(pptr[0], 2); + plen=EXTRACT_16BITS(pptr); + tlen=plen; + pptr+=2; + TCHECK2(pptr[0],15); + strlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u", + bgp_vpn_rd_print(pptr), + EXTRACT_16BITS(pptr+8), + EXTRACT_16BITS(pptr+10), + EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */ + pptr+=15; + tlen-=15; + + /* ok now the variable part - lets read out TLVs*/ + while (tlen>0) { + if (tlen < 3) + return -1; + TCHECK2(pptr[0], 3); + tlv_type=*pptr++; + tlv_len=EXTRACT_16BITS(pptr); + ttlv_len=tlv_len; + pptr+=2; + + switch(tlv_type) { + case 1: + strlen+=snprintf(buf+strlen,buflen-strlen, "\n\t\tcircuit status vector (%u) length: %u: 0x", + tlv_type, + tlv_len); + ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */ + while (ttlv_len>0) { + TCHECK(pptr[0]); + strlen+=snprintf(buf+strlen,buflen-strlen, "%02x",*pptr++); + ttlv_len--; + } + break; + default: + snprintf(buf+strlen,buflen-strlen, "\n\t\tunknown TLV #%u, length: %u", + tlv_type, + tlv_len); + break; + } + tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it tright */ + } + return plen+2; + +trunc: + return -2; } #ifdef INET6 @@ -299,11 +679,13 @@ decode_prefix6(const u_char *pd, char *buf, u_int buflen) struct in6_addr addr; u_int plen; + TCHECK(pd[0]); plen = pd[0]; - if (plen < 0 || 128 < plen) + if (128 < plen) return -1; memset(&addr, 0, sizeof(addr)); + TCHECK2(pd[1], (plen + 7) / 8); memcpy(&addr, &pd[1], (plen + 7) / 8); if (plen % 8) { addr.s6_addr[(plen + 7) / 8 - 1] &= @@ -311,85 +693,169 @@ decode_prefix6(const u_char *pd, char *buf, u_int buflen) } snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen); return 1 + (plen + 7) / 8; + +trunc: + return -2; +} + +static int +decode_labeled_prefix6(const u_char *pptr, char *buf, u_int buflen) +{ + struct in6_addr addr; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + plen-=24; /* adjust prefixlen - labellength */ + + if (128 < plen) + return -1; + + memset(&addr, 0, sizeof(addr)); + TCHECK2(pptr[4], (plen + 7) / 8); + memcpy(&addr, &pptr[4], (plen + 7) / 8); + if (plen % 8) { + addr.s6_addr[(plen + 7) / 8 - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + /* the label may get offsetted by 4 bits so lets shift it right */ + snprintf(buf, buflen, "%s/%d, label:%u %s", + getname6((u_char *)&addr), + plen, + EXTRACT_24BITS(pptr+1)>>4, + ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); + + return 4 + (plen + 7) / 8; + +trunc: + return -2; +} + +static int +decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen) +{ + struct in6_addr addr; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + + plen-=(24+64); /* adjust prefixlen - labellength - RD len*/ + + if (128 < plen) + return -1; + + memset(&addr, 0, sizeof(addr)); + TCHECK2(pptr[12], (plen + 7) / 8); + memcpy(&addr, &pptr[12], (plen + 7) / 8); + if (plen % 8) { + addr.s6_addr[(plen + 7) / 8 - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + /* the label may get offsetted by 4 bits so lets shift it right */ + snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s", + bgp_vpn_rd_print(pptr+4), + getname6((u_char *)&addr), + plen, + EXTRACT_24BITS(pptr+1)>>4, + ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); + + return 12 + (plen + 7) / 8; + +trunc: + return -2; } #endif -static void -bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len) +static int +bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) { int i; u_int16_t af; u_int8_t safi, snpa; + union { /* copy buffer for bandwidth values */ + float f; + u_int32_t i; + } bw; int advance; int tlen; - const u_char *p; + const u_char *tptr; char buf[MAXHOSTNAMELEN + 100]; - p = dat; + tptr = pptr; + tlen=len; switch (attr->bgpa_type) { case BGPTYPE_ORIGIN: if (len != 1) - printf(" invalid len"); - else - printf(" %s", bgp_attr_origin(p[0])); + printf("invalid len"); + else { + TCHECK(*tptr); + printf("%s", tok2str(bgp_origin_values, "Unknown Origin Typecode", tptr[0])); + } break; case BGPTYPE_AS_PATH: if (len % 2) { - printf(" invalid len"); + printf("invalid len"); break; } - while (p < dat + len) { - /* - * under RFC1965, p[0] means: - * 1: AS_SET 2: AS_SEQUENCE - * 3: AS_CONFED_SET 4: AS_CONFED_SEQUENCE - */ - printf(" "); - if (p[0] == 3 || p[0] == 4) - printf("confed"); - printf("%s", (p[0] & 1) ? "{" : ""); - for (i = 0; i < p[1] * 2; i += 2) { - printf("%s%u", i == 0 ? "" : " ", - EXTRACT_16BITS(&p[2 + i])); - } - printf("%s", (p[0] & 1) ? "}" : ""); - p += 2 + p[1] * 2; + if (!len) { + printf("empty"); + break; + } + + while (tptr < pptr + len) { + TCHECK(tptr[0]); + printf("%s", tok2str(bgp_as_path_segment_open_values, "?", tptr[0])); + for (i = 0; i < tptr[1] * 2; i += 2) { + TCHECK2(tptr[2 + i], 2); + printf("%u ", EXTRACT_16BITS(&tptr[2 + i])); + } + TCHECK(tptr[0]); + printf("%s", tok2str(bgp_as_path_segment_close_values, "?", tptr[0])); + TCHECK(tptr[1]); + tptr += 2 + tptr[1] * 2; } break; case BGPTYPE_NEXT_HOP: if (len != 4) - printf(" invalid len"); - else - printf(" %s", getname(p)); + printf("invalid len"); + else { + TCHECK2(tptr[0], 4); + printf("%s", getname(tptr)); + } break; case BGPTYPE_MULTI_EXIT_DISC: case BGPTYPE_LOCAL_PREF: if (len != 4) - printf(" invalid len"); - else - printf(" %u", EXTRACT_32BITS(p)); + printf("invalid len"); + else { + TCHECK2(tptr[0], 4); + printf("%u", EXTRACT_32BITS(tptr)); + } break; case BGPTYPE_ATOMIC_AGGREGATE: if (len != 0) - printf(" invalid len"); + printf("invalid len"); break; case BGPTYPE_AGGREGATOR: if (len != 6) { - printf(" invalid len"); + printf("invalid len"); break; } - printf(" AS #%u, origin %s", EXTRACT_16BITS(p), - getname(p + 2)); + TCHECK2(tptr[0], 6); + printf(" AS #%u, origin %s", EXTRACT_16BITS(tptr), + getname(tptr + 2)); break; case BGPTYPE_COMMUNITIES: if (len % 4) { - printf(" invalid len"); + printf("invalid len"); break; } - for (i = 0; i < len; i += 4) { + while (tlen>0) { u_int32_t comm; - comm = EXTRACT_32BITS(&p[i]); + TCHECK2(tptr[0], 4); + comm = EXTRACT_32BITS(tptr); switch (comm) { case BGP_COMMUNITY_NO_EXPORT: printf(" NO_EXPORT"); @@ -401,147 +867,591 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len) printf(" NO_EXPORT_SUBCONFED"); break; default: - printf(" (AS #%d value 0x%04x)", - (comm >> 16) & 0xffff, comm & 0xffff); + printf("%u:%u%s", + (comm >> 16) & 0xffff, + comm & 0xffff, + (tlen>4) ? ", " : ""); break; } + tlen -=4; + tptr +=4; } break; - case BGPTYPE_MP_REACH_NLRI: - af = EXTRACT_16BITS(p); - safi = p[2]; - if (safi >= 128) - printf(" %s vendor specific,", af_name(af)); - else { - printf(" %s %s,", af_name(af), - bgp_attr_nlri_safi(safi)); + case BGPTYPE_ORIGINATOR_ID: + if (len != 4) { + printf("invalid len"); + break; } - p += 3; - - if (af == AFNUM_INET) + TCHECK2(tptr[0], 4); + printf("%s",getname(tptr)); + break; + case BGPTYPE_CLUSTER_LIST: + if (len % 4) { + printf("invalid len"); + break; + } + while (tlen>0) { + TCHECK2(tptr[0], 4); + printf("%s%s", + getname(tptr), + (tlen>4) ? ", " : ""); + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_MP_REACH_NLRI: + TCHECK2(tptr[0], 3); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)", + tok2str(bgp_afi_values, "Unknown AFI", af), + af, + (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, "Unknown SAFI", safi), + safi); + + if (af == AFNUM_INET || af==AFNUM_L2VPN) ; #ifdef INET6 else if (af == AFNUM_INET6) ; #endif - else - break; + else { + printf("\n\t no AFI %u decoder",af); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + break; + } + + tptr +=3; + + TCHECK(tptr[0]); + tlen = tptr[0]; + tptr++; - tlen = p[0]; if (tlen) { - printf(" nexthop"); - i = 0; - while (i < tlen) { + printf("\n\t nexthop: "); + while (tlen > 0) { switch (af) { case AFNUM_INET: - printf(" %s", getname(p + 1 + i)); - i += sizeof(struct in_addr); + switch(safi) { + case SAFNUM_UNICAST: + case SAFNUM_MULTICAST: + case SAFNUM_UNIMULTICAST: + case SAFNUM_LABUNICAST: + case SAFNUM_RT_ROUTING_INFO: + if (tlen < (int)sizeof(struct in_addr)) { + printf("invalid len"); + tlen = 0; + } else { + TCHECK2(tptr[0], sizeof(struct in_addr)); + printf("%s",getname(tptr)); + tlen -= sizeof(struct in_addr); + tptr += sizeof(struct in_addr); + } break; + case SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) { + printf("invalid len"); + tlen = 0; + } else { + TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN); + printf("RD: %s, %s", + bgp_vpn_rd_print(tptr), + getname(tptr+BGP_VPN_RD_LEN)); + tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + } + break; + default: + TCHECK2(tptr[0], tlen); + printf("no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + tptr += tlen; + tlen = 0; + break; + } + break; #ifdef INET6 case AFNUM_INET6: - printf(" %s", getname6(p + 1 + i)); - i += sizeof(struct in6_addr); - break; + switch(safi) { + case SAFNUM_UNICAST: + case SAFNUM_MULTICAST: + case SAFNUM_UNIMULTICAST: + case SAFNUM_LABUNICAST: + case SAFNUM_RT_ROUTING_INFO: + if (tlen < (int)sizeof(struct in6_addr)) { + printf("invalid len"); + tlen = 0; + } else { + TCHECK2(tptr[0], sizeof(struct in6_addr)); + printf("%s", getname6(tptr)); + tlen -= sizeof(struct in6_addr); + tptr += sizeof(struct in6_addr); + } + break; + case SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) { + printf("invalid len"); + tlen = 0; + } else { + TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + printf("RD: %s, %s", + bgp_vpn_rd_print(tptr), + getname6(tptr+BGP_VPN_RD_LEN)); + tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + } + break; + default: + TCHECK2(tptr[0], tlen); + printf("no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + tptr += tlen; + tlen = 0; + break; + } + break; #endif + case AFNUM_L2VPN: + switch(safi) { + case SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + if (tlen < (int)sizeof(struct in_addr)) { + printf("invalid len"); + tlen = 0; + } else { + TCHECK2(tptr[0], sizeof(struct in_addr)); + printf("%s", getname(tptr)); + tlen -= (sizeof(struct in_addr)); + tptr += (sizeof(struct in_addr)); + } + break; + default: + TCHECK2(tptr[0], tlen); + printf("no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + tptr += tlen; + tlen = 0; + break; + } + break; + default: - printf(" (unknown af)"); - i = tlen; /*exit loop*/ - break; + TCHECK2(tptr[0], tlen); + printf("no AFI %u decoder",af); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + tptr += tlen; + tlen = 0; + break; } } - printf(","); } - p += 1 + tlen; + tptr += tlen; + + TCHECK(tptr[0]); + snpa = tptr[0]; + tptr++; - snpa = p[0]; - p++; if (snpa) { - printf(" %u snpa", snpa); + printf("\n\t %u SNPA", snpa); for (/*nothing*/; snpa > 0; snpa--) { - printf("(%d bytes)", p[0]); - p += p[0] + 1; + TCHECK(tptr[0]); + printf("\n\t %d bytes", tptr[0]); + tptr += tptr[0] + 1; } - printf(","); - } + } else { + printf(", no SNPA"); + } - printf(" NLRI"); - while (len - (p - dat) > 0) { + while (len - (tptr - pptr) > 0) { switch (af) { case AFNUM_INET: - advance = decode_prefix4(p, buf, sizeof(buf)); - if (advance < 0) { - p = dat + len; - break; - } - printf(" %s", buf); - break; + switch (safi) { + case SAFNUM_UNICAST: + case SAFNUM_MULTICAST: + case SAFNUM_UNIMULTICAST: + advance = decode_prefix4(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 SAFNUM_LABUNICAST: + advance = decode_labeled_prefix4(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 SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + advance = decode_labeled_vpn_prefix4(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 SAFNUM_RT_ROUTING_INFO: + advance = decode_rt_routing_info(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; + default: + TCHECK2(*(tptr-3),tlen); + printf("\n\t no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; + } + break; #ifdef INET6 case AFNUM_INET6: - advance = decode_prefix6(p, buf, sizeof(buf)); - if (advance < 0) { - p = dat + len; - break; - } - printf(" %s", buf); + switch (safi) { + case SAFNUM_UNICAST: + case SAFNUM_MULTICAST: + case SAFNUM_UNIMULTICAST: + advance = decode_prefix6(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 SAFNUM_LABUNICAST: + advance = decode_labeled_prefix6(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 SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + advance = decode_labeled_vpn_prefix6(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 SAFNUM_RT_ROUTING_INFO: + advance = decode_rt_routing_info(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; + default: + TCHECK2(*(tptr-3),tlen); + printf("\n\t no SAFI %u decoder ",safi); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; + } + break; #endif + case AFNUM_L2VPN: + switch(safi) { + case SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; + default: + TCHECK2(*tptr,tlen); + printf("no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; + } + break; + + default: - printf(" (unknown af)"); - advance = 0; - p = dat + len; - break; + TCHECK2(*(tptr-3),tlen); + printf("\n\t no AFI %u decoder ",af); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; } - - p += advance; + tptr += advance; } - break; case BGPTYPE_MP_UNREACH_NLRI: - af = EXTRACT_16BITS(p); - safi = p[2]; - if (safi >= 128) - printf(" %s vendor specific,", af_name(af)); - else { - printf(" %s %s,", af_name(af), - bgp_attr_nlri_safi(safi)); - } - p += 3; - - printf(" Withdraw"); - while (len - (p - dat) > 0) { + TCHECK2(tptr[0], 3); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)", + tok2str(bgp_afi_values, "Unknown AFI", af), + af, + (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, "Unknown SAFI", safi), + safi); + + tptr += 3; + + while (len - (tptr - pptr) > 0) { switch (af) { case AFNUM_INET: - advance = decode_prefix4(p, buf, sizeof(buf)); - if (advance < 0) { - p = dat + len; - break; - } - printf(" %s", buf); - break; + switch (safi) { + case SAFNUM_UNICAST: + case SAFNUM_MULTICAST: + case SAFNUM_UNIMULTICAST: + advance = decode_prefix4(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 SAFNUM_LABUNICAST: + advance = decode_labeled_prefix4(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 SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + advance = decode_labeled_vpn_prefix4(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; + default: + TCHECK2(*(tptr-3),tlen); + printf("\n\t no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; + } + break; + #ifdef INET6 case AFNUM_INET6: - advance = decode_prefix6(p, buf, sizeof(buf)); - if (advance < 0) { - p = dat + len; - break; - } - printf(" %s", buf); + switch (safi) { + case SAFNUM_UNICAST: + case SAFNUM_MULTICAST: + case SAFNUM_UNIMULTICAST: + advance = decode_prefix6(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 SAFNUM_LABUNICAST: + advance = decode_labeled_prefix6(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 SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + advance = decode_labeled_vpn_prefix6(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; + default: + TCHECK2(*(tptr-3),tlen); + printf("\n\t no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; break; + } + break; #endif + + case AFNUM_L2VPN: + switch(safi) { + case SAFNUM_VPNUNICAST: + case SAFNUM_VPNMULTICAST: + case SAFNUM_VPNUNIMULTICAST: + advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; + default: + TCHECK2(*(tptr-3),tlen); + printf("no SAFI %u decoder",safi); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; + } + break; + default: - printf(" (unknown af)"); + TCHECK2(*(tptr-3),tlen); + printf("\n\t no AFI %u decoder",af); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); advance = 0; - p = dat + len; + tptr = pptr + len; break; } - p += advance; + tptr += advance; } break; + case BGPTYPE_EXTD_COMMUNITIES: + if (len % 8) { + printf("invalid len"); + break; + } + while (tlen>0) { + u_int16_t extd_comm; + + TCHECK2(tptr[0], 2); + extd_comm=EXTRACT_16BITS(tptr); + + printf("\n\t %s (0x%04x), Flags [%s]", + tok2str(bgp_extd_comm_subtype_values, "unknown extd community typecode", extd_comm), + extd_comm, + bittok2str(bgp_extd_comm_flag_values, "none", extd_comm)); + + TCHECK2(*(tptr+2), 6); + switch(extd_comm) { + case BGP_EXT_COM_RT_0: + case BGP_EXT_COM_RO_0: + printf(": %u:%s", + EXTRACT_16BITS(tptr+2), + getname(tptr+4)); + break; + case BGP_EXT_COM_RT_1: + case BGP_EXT_COM_RO_1: + printf(": %s:%u", + getname(tptr+2), + EXTRACT_16BITS(tptr+6)); + 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; + case BGP_EXT_COM_LINKBAND: + bw.i = EXTRACT_32BITS(tptr+2); + printf(": bandwidth: %.3f Mbps", + bw.f*8/1000000); + break; + case BGP_EXT_COM_VPN_ORIGIN: + case BGP_EXT_COM_VPN_ORIGIN2: + case BGP_EXT_COM_VPN_ORIGIN3: + case BGP_EXT_COM_VPN_ORIGIN4: + case BGP_EXT_COM_OSPF_RID: + case BGP_EXT_COM_OSPF_RID2: + printf("%s", getname(tptr+2)); + break; + case BGP_EXT_COM_OSPF_RTYPE: + case BGP_EXT_COM_OSPF_RTYPE2: + printf(": area:%s, router-type:%s, metric-type:%s%s", + getname(tptr+2), + tok2str(bgp_extd_comm_ospf_rtype_values, + "unknown (0x%02x)", + *(tptr+6)), + (*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "", + (*(tptr+6) == (BGP_OSPF_RTYPE_EXT ||BGP_OSPF_RTYPE_NSSA )) ? "E1" : ""); + break; + case BGP_EXT_COM_L2INFO: + printf(": %s Control Flags [0x%02x]:MTU %u", + tok2str(bgp_l2vpn_encaps_values, + "unknown encaps", + *(tptr+2)), + *(tptr+3), + EXTRACT_16BITS(tptr+4)); + break; + default: + print_unknown_data(tptr,"\n\t ",8); + break; + } + tlen -=8; + tptr +=8; + } + break; + default: - break; + TCHECK2(*pptr,len); + printf("\n\t no Attribute %u decoder",attr->bgpa_type); /* we have no decoder for the attribute */ + if (vflag <= 1) + print_unknown_data(pptr,"\n\t ",len); + break; } + if (vflag > 1 && len) /* omit zero length attributes*/ + print_unknown_data(pptr,"\n\t ",len); + return 1; + +trunc: + return 0; } static void @@ -551,17 +1461,21 @@ bgp_open_print(const u_char *dat, int length) struct bgp_opt bgpopt; int hlen; const u_char *opt; - int i; + int i,cap_type,cap_len,tcap_len,cap_offset; TCHECK2(dat[0], BGP_OPEN_SIZE); memcpy(&bgpo, dat, BGP_OPEN_SIZE); hlen = ntohs(bgpo.bgpo_len); - printf(": Version %d,", bgpo.bgpo_version); - printf(" AS #%u,", ntohs(bgpo.bgpo_myas)); - printf(" Holdtime %u,", ntohs(bgpo.bgpo_holdtime)); - printf(" ID %s,", getname((u_char *)&bgpo.bgpo_id)); - printf(" Option length %u", bgpo.bgpo_optlen); + printf("\n\t Version %d, ", bgpo.bgpo_version); + printf("my AS %u, ", 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); + + /* some little sanity checking */ + if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE) + return; /* ugly! */ opt = &((const struct bgp_open *)dat)->bgpo_optlen; @@ -572,12 +1486,69 @@ bgp_open_print(const u_char *dat, int length) TCHECK2(opt[i], BGP_OPT_SIZE); memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE); if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) { - printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type); + printf("\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len); break; } - printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type), - bgpopt.bgpopt_len); + printf("\n\t Option %s (%u), length: %u", + tok2str(bgp_opt_values,"Unknown", bgpopt.bgpopt_type), + bgpopt.bgpopt_type, + bgpopt.bgpopt_len); + + /* now lets decode the options we know*/ + switch(bgpopt.bgpopt_type) { + case BGP_OPT_CAP: + cap_type=opt[i+BGP_OPT_SIZE]; + cap_len=opt[i+BGP_OPT_SIZE+1]; + tcap_len=cap_len; + printf("\n\t %s, length: %u", + tok2str(bgp_capcode_values,"Unknown", cap_type), + cap_len); + switch(cap_type) { + case BGP_CAPCODE_MP: + printf("\n\t\tAFI %s (%u), SAFI %s (%u)", + tok2str(bgp_afi_values,"Unknown", EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2)), + EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2), + tok2str(bgp_safi_values,"Unknown", opt[i+BGP_OPT_SIZE+5]), + opt[i+BGP_OPT_SIZE+5]); + break; + case BGP_CAPCODE_RESTART: + printf("\n\t\tRestart Flags: [%s], Restart Time %us", + ((opt[i+BGP_OPT_SIZE+2])&0x80) ? "R" : "none", + EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2)&0xfff); + tcap_len-=2; + cap_offset=4; + while(tcap_len>=4) { + printf("\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s", + tok2str(bgp_afi_values,"Unknown", EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset)), + EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset), + tok2str(bgp_safi_values,"Unknown", opt[i+BGP_OPT_SIZE+cap_offset+2]), + opt[i+BGP_OPT_SIZE+cap_offset+2], + ((opt[i+BGP_OPT_SIZE+cap_offset+3])&0x80) ? "yes" : "no" ); + tcap_len-=4; + cap_offset+=4; + } + break; + case BGP_CAPCODE_RR: + case BGP_CAPCODE_RR_CISCO: + break; + default: + printf("\n\t\tno decoder for Capability %u", + cap_type); + if (vflag <= 1) + print_unknown_data(&opt[i+BGP_OPT_SIZE+2],"\n\t\t",cap_len); + break; + } + if (vflag > 1) + print_unknown_data(&opt[i+BGP_OPT_SIZE+2],"\n\t\t",cap_len); + break; + case BGP_OPT_AUTH: + default: + printf("\n\t no decoder for option %u", + bgpopt.bgpopt_type); + break; + } + i += BGP_OPT_SIZE + bgpopt.bgpopt_len; } return; @@ -594,13 +1565,11 @@ bgp_update_print(const u_char *dat, int length) const u_char *p; int len; int i; - int newline; TCHECK2(dat[0], BGP_SIZE); memcpy(&bgp, dat, BGP_SIZE); hlen = ntohs(bgp.bgp_len); p = dat + BGP_SIZE; /*XXX*/ - printf(":"); /* Unfeasible routes */ len = EXTRACT_16BITS(p); @@ -611,24 +1580,28 @@ bgp_update_print(const u_char *dat, int length) * so only try to decode it if we're not v6 enabled. */ #ifdef INET6 - printf(" (Withdrawn routes: %d bytes)", len); -#else + printf("\n\t Withdrawn routes: %d bytes", len); +#else char buf[MAXHOSTNAMELEN + 100]; int wpfx; TCHECK2(p[2], len); - i = 2; + i = 2; + + printf("\n\t Withdrawn routes:"); - printf(" (Withdrawn routes:"); - while(i < 2 + len) { wpfx = decode_prefix4(&p[i], buf, sizeof(buf)); - if (wpfx < 0) + if (wpfx == -1) { + printf("\n\t (illegal prefix length)"); break; - i += wpfx; - printf(" %s", buf); + } else if (wpfx == -2) + goto trunc; + else { + i += wpfx; + printf("\n\t %s", buf); + } } - printf(")\n"); #endif } p += 2 + len; @@ -638,8 +1611,6 @@ bgp_update_print(const u_char *dat, int length) if (len) { /* do something more useful!*/ i = 2; - printf(" (Path attributes:"); /* ) */ - newline = 0; while (i < 2 + len) { int alen, aoff; @@ -648,52 +1619,42 @@ bgp_update_print(const u_char *dat, int length) alen = bgp_attr_len(&bgpa); aoff = bgp_attr_off(&bgpa); - if (vflag && newline) - printf("\n\t\t"); - else - printf(" "); - printf("("); /* ) */ - printf("%s", bgp_attr_type(bgpa.bgpa_type)); + printf("\n\t %s (%u), length: %u", + tok2str(bgp_attr_values, "Unknown Attribute", bgpa.bgpa_type), + bgpa.bgpa_type, + alen); + if (bgpa.bgpa_flags) { - printf("[%s%s%s%s", + printf(", Flags [%s%s%s%s", bgpa.bgpa_flags & 0x80 ? "O" : "", bgpa.bgpa_flags & 0x40 ? "T" : "", bgpa.bgpa_flags & 0x20 ? "P" : "", bgpa.bgpa_flags & 0x10 ? "E" : ""); if (bgpa.bgpa_flags & 0xf) printf("+%x", bgpa.bgpa_flags & 0xf); - printf("]"); + printf("]: "); } - - bgp_attr_print(&bgpa, &p[i + aoff], alen); - newline = 1; - - /* ( */ - printf(")"); - + if (!bgp_attr_print(&bgpa, &p[i + aoff], alen)) + goto trunc; i += aoff + alen; } - - /* ( */ - printf(")"); } p += 2 + len; - if (len && dat + length > p) - printf("\n\t\t"); if (dat + length > p) { - printf("(NLRI:"); /* ) */ + printf("\n\t Updated routes:"); while (dat + length > p) { char buf[MAXHOSTNAMELEN + 100]; i = decode_prefix4(p, buf, sizeof(buf)); - if (i < 0) - break; - printf(" %s", buf); - p += i; + if (i == -1) + printf("\n\t (illegal prefix length)"); + else if (i == -2) + goto trunc; + else { + printf("\n\t %s", buf); + p += i; + } } - - /* ( */ - printf(")"); } return; trunc: @@ -705,27 +1666,100 @@ bgp_notification_print(const u_char *dat, int length) { struct bgp_notification bgpn; int hlen; + const u_char *tptr; TCHECK2(dat[0], BGP_NOTIFICATION_SIZE); memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE); hlen = ntohs(bgpn.bgpn_len); - printf(": error %s,", bgp_notify_major(bgpn.bgpn_major)); - printf(" subcode %s", - bgp_notify_minor(bgpn.bgpn_major, bgpn.bgpn_minor)); + /* some little sanity checking */ + if (length<BGP_NOTIFICATION_SIZE) + return; + + printf(", %s (%u)", + tok2str(bgp_notify_major_values, "Unknown Error", bgpn.bgpn_major), + bgpn.bgpn_major); + + switch (bgpn.bgpn_major) { + + case BGP_NOTIFY_MAJOR_MSG: + printf(", subcode %s (%u)", + tok2str(bgp_notify_minor_msg_values, "Unknown", bgpn.bgpn_minor), + bgpn.bgpn_minor); + break; + case BGP_NOTIFY_MAJOR_OPEN: + printf(", subcode %s (%u)", + tok2str(bgp_notify_minor_open_values, "Unknown", bgpn.bgpn_minor), + bgpn.bgpn_minor); + break; + case BGP_NOTIFY_MAJOR_UPDATE: + printf(", subcode %s (%u)", + tok2str(bgp_notify_minor_update_values, "Unknown", bgpn.bgpn_minor), + bgpn.bgpn_minor); + break; + case BGP_NOTIFY_MAJOR_CAP: + printf(" subcode %s (%u)", + tok2str(bgp_notify_minor_cap_values, "Unknown", bgpn.bgpn_minor), + bgpn.bgpn_minor); + case BGP_NOTIFY_MAJOR_CEASE: + printf(", subcode %s (%u)", + tok2str(bgp_notify_minor_cease_values, "Unknown", bgpn.bgpn_minor), + bgpn.bgpn_minor); + + /* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes + * for the maxprefix subtype, which may contain AFI, SAFI and MAXPREFIXES + */ + if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7) { + tptr = dat + BGP_NOTIFICATION_SIZE; + TCHECK2(*tptr, 7); + printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u", + tok2str(bgp_afi_values, "Unknown", EXTRACT_16BITS(tptr)), + EXTRACT_16BITS(tptr), + tok2str(bgp_safi_values, "Unknown", *(tptr+2)), + *(tptr+2), + EXTRACT_32BITS(tptr+3)); + } + break; + default: + break; + } + return; trunc: printf("[|BGP]"); } static void +bgp_route_refresh_print(const u_char *pptr, int len) { + + const struct bgp_route_refresh *bgp_route_refresh_header; + bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr; + + printf("\n\t AFI %s (%u), SAFI %s (%u)", + tok2str(bgp_afi_values,"Unknown", + EXTRACT_16BITS(&bgp_route_refresh_header->afi)), /* this stinks but the compiler pads the structure weird */ + EXTRACT_16BITS(&bgp_route_refresh_header->afi), + tok2str(bgp_safi_values,"Unknown", + bgp_route_refresh_header->safi), + bgp_route_refresh_header->safi); + + if (vflag > 1) + print_unknown_data(pptr,"\n\t ", len); + + return; +} + +static int bgp_header_print(const u_char *dat, int length) { struct bgp bgp; TCHECK2(dat[0], BGP_SIZE); memcpy(&bgp, dat, BGP_SIZE); - printf("(%s", bgp_type(bgp.bgp_type)); /* ) */ + printf("\n\t%s Message (%u), length: %u", + tok2str(bgp_msg_values, "Unknown", bgp.bgp_type), + bgp.bgp_type, + length); switch (bgp.bgp_type) { case BGP_OPEN: @@ -737,13 +1771,21 @@ bgp_header_print(const u_char *dat, int length) case BGP_NOTIFICATION: bgp_notification_print(dat, length); break; + case BGP_KEEPALIVE: + break; + case BGP_ROUTE_REFRESH: + bgp_route_refresh_print(dat, length); + break; + default: + /* we have no decoder for the BGP message */ + printf("\n\t no Message %u decoder",bgp.bgp_type); + print_unknown_data(dat,"\n\t ",length); + break; } - - /* ( */ - printf(")"); - return; + return 1; trunc: printf("[|BGP]"); + return 0; } void @@ -753,21 +1795,22 @@ bgp_print(const u_char *dat, int length) const u_char *ep; const u_char *start; const u_char marker[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; struct bgp bgp; u_int16_t hlen; - int newline; ep = dat + length; if (snapend < dat + length) ep = snapend; - printf(": BGP"); + printf(": BGP, length: %u",length); + + if (vflag < 1) /* lets be less chatty */ + return; p = dat; - newline = 0; start = p; while (p < snapend) { if (!TTEST2(p[0], 1)) @@ -792,17 +1835,19 @@ bgp_print(const u_char *dat, int length) printf(" [|BGP]"); hlen = ntohs(bgp.bgp_len); - if (vflag && newline) - printf("\n\t"); - else - printf(" "); + if (hlen < BGP_SIZE) { + printf("\n[|BGP Bogus header length %u < %u]", hlen, + BGP_SIZE); + break; + } + if (TTEST2(p[0], hlen)) { - bgp_header_print(p, hlen); - newline = 1; + if (!bgp_header_print(p, hlen)) + return; p += hlen; start = p; } else { - printf("[|BGP %s]", bgp_type(bgp.bgp_type)); + printf("\n[|BGP %s]", tok2str(bgp_msg_values, "Unknown Message Type",bgp.bgp_type)); break; } } diff --git a/contrib/tcpdump/print-cdp.c b/contrib/tcpdump/print-cdp.c index a73fc3f..c69d962 100644 --- a/contrib/tcpdump/print-cdp.c +++ b/contrib/tcpdump/print-cdp.c @@ -25,21 +25,16 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.11 2001/09/17 21:57:56 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.19.2.5 2004/03/24 06:00:51 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> -#include <netdb.h> #include <stdio.h> #include <string.h> @@ -47,97 +42,181 @@ static const char rcsid[] = #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ +#define CDP_HEADER_LEN 4 + +static struct tok cdp_tlv_values[] = { + { 0x01, "Device-ID"}, + { 0x02, "Address"}, + { 0x03, "Port-ID"}, + { 0x04, "Capability"}, + { 0x05, "Version String"}, + { 0x06, "Platform"}, + { 0x07, "Prefixes"}, + { 0x08, "Protocol-Hello option"}, + { 0x09, "VTP Management Domain"}, + { 0x0a, "Native VLAN ID"}, + { 0x0b, "Duplex"}, + { 0x0e, "ATA-186 VoIP VLAN request"}, + { 0x0f, "ATA-186 VoIP VLAN assignment"}, + { 0x10, "power consumption"}, + { 0x11, "MTU"}, + { 0x12, "AVVID trust bitmap"}, + { 0x13, "AVVID untrusted ports CoS"}, + { 0x14, "System Name"}, + { 0x15, "System Object ID (not decoded)"}, + { 0x16, "Management Addresses"}, + { 0x17, "Physical Location"}, + { 0, NULL} +}; + +static struct tok cdp_capability_values[] = { + { 0x01, "Router" }, + { 0x02, "Transparent Bridge" }, + { 0x04, "Source Route Bridge" }, + { 0x08, "L2 Switch" }, + { 0x10, "L3 capable" }, + { 0x20, "IGMP snooping" }, + { 0x40, "L1 capable" }, + { 0, NULL } +}; + static int cdp_print_addr(const u_char *, int); static int cdp_print_prefixes(const u_char *, int); +static unsigned long cdp_get_number(const u_char *, int); void -cdp_print(const u_char *p, u_int length, u_int caplen, - const u_char *esrc, const u_char *edst) +cdp_print(const u_char *pptr, u_int length, u_int caplen) { - u_int i; - int type, len; + int type, len, i, j; + const u_char *tptr; - /* Cisco Discovery Protocol */ - - if (caplen < 4) { + if (caplen < CDP_HEADER_LEN) { (void)printf("[|cdp]"); return; } - i = 0; /* CDP data starts at offset 0 */ - printf("CDP v%u, ttl=%us", p[i], p[i + 1]); - i += 4; /* skip version, TTL and chksum */ + tptr = pptr; /* temporary pointer */ - while (i < length) { - if (i + 4 > caplen) - goto trunc; - type = (p[i] << 8) + p[i + 1]; - len = (p[i + 2] << 8) + p[i + 3]; + if (!TTEST2(*tptr, CDP_HEADER_LEN)) + goto trunc; + printf("CDPv%u, ttl: %us", *tptr, *(tptr+1)); + if (vflag) + printf(", checksum: %u (unverified), length %u", EXTRACT_16BITS(tptr), length); + tptr += CDP_HEADER_LEN; - if (vflag > 1) - printf("\n\t"); + while (tptr < (pptr+length)) { - if (vflag) - printf(" %02x/%02x", type, len); + if (!TTEST2(*tptr, 4)) /* read out Type and Length */ + goto trunc; + type = EXTRACT_16BITS(tptr); + len = EXTRACT_16BITS(tptr+2); /* object length includes the 4 bytes header length */ + tptr += 4; + len -= 4; - if (i + len > caplen) + if (!TTEST2(*tptr, len)) goto trunc; - switch (type) { - case 0x00: - printf(" Goodbye"); - break; - case 0x01: - printf(" DevID '%.*s'", len - 4, p + i + 4); + if (vflag || type == 1) { /* in non-verbose mode just print Device-ID */ + + if (vflag) + printf("\n\t%s (0x%02x), length: %u byte%s: ", + tok2str(cdp_tlv_values,"unknown field type", type), + type, + len, + len>1 ? "s" : ""); /* plural */ + + switch (type) { + + case 0x01: /* Device-ID */ + if (!vflag) + printf(", Device-ID '%.*s'", len, tptr); + else + printf("'%.*s'", len, tptr); break; - case 0x02: - printf(" Addr"); - if (cdp_print_addr(p + i + 4, len - 4) < 0) - goto trunc; + case 0x02: /* Address */ + if (cdp_print_addr(tptr, len) < 0) + goto trunc; break; - case 0x03: - printf(" PortID '%.*s'", len - 4, p + i + 4); + case 0x03: /* Port-ID */ + printf("'%.*s'", len, tptr); break; - case 0x04: - printf(" CAP 0x%02x", (unsigned) p[i + 7]); + case 0x04: /* Capabilities */ + printf("(0x%08x): %s", + EXTRACT_32BITS(tptr), + bittok2str(cdp_capability_values, "none",EXTRACT_32BITS(tptr))); break; - case 0x05: - if (vflag > 1) - printf(" Version:\n%.*s", len - 4, p + i + 4); - else - printf(" Version: (suppressed)"); + case 0x05: /* Version */ + printf("\n\t "); + for (i=0;i<len;i++) { + j = *(tptr+i); + putchar(j); + if (j == 0x0a) /* lets rework the version string to get a nice identation */ + printf("\t "); + } break; - case 0x06: - printf(" Platform: '%.*s'", len - 4, p + i + 4); + case 0x06: /* Platform */ + printf("'%.*s'", len, tptr); break; - case 0x07: - if (cdp_print_prefixes(p + i + 4, len - 4) < 0) - goto trunc; + case 0x07: /* Prefixes */ + if (cdp_print_prefixes(tptr, len) < 0) + goto trunc; break; - case 0x09: /* guess - not documented */ - printf(" VTP Management Domain: '%.*s'", len - 4, - p + i + 4); + case 0x08: /* Protocol Hello Option - not documented */ break; - case 0x0a: /* guess - not documented */ - printf(" Native VLAN ID: %d", - (p[i + 4] << 8) + p[i + 4 + 1] - 1); + case 0x09: /* VTP Mgmt Domain - not documented */ + printf("'%.*s'", len,tptr); break; - case 0x0b: /* guess - not documented */ - printf(" Duplex: %s", p[i + 4] ? "full": "half"); + case 0x0a: /* Native VLAN ID - not documented */ + printf("%d",EXTRACT_16BITS(tptr)); break; - default: - printf(" unknown field type %02x, len %d", type, len); + case 0x0b: /* Duplex - not documented */ + printf("%s", *(tptr) ? "full": "half"); break; - } + /* http://www.cisco.com/univercd/cc/td/doc/product/voice/ata/atarn/186rn21m.htm + * plus more details from other sources + */ + case 0x0e: /* ATA-186 VoIP VLAN request - incomplete doc. */ + printf("app %d, vlan %d", + *(tptr), EXTRACT_16BITS(tptr+1)); + break; + case 0x10: /* ATA-186 VoIP VLAN assignment - incomplete doc. */ + printf("%1.2fW", + cdp_get_number(tptr, len)/1000.0 ); + break; + case 0x11: /* MTU - not documented */ + printf("%u bytes", EXTRACT_32BITS(tptr)); + break; + case 0x12: /* AVVID trust bitmap - not documented */ + printf("0x%02x", *(tptr) ); + break; + case 0x13: /* AVVID untrusted port CoS - not documented */ + printf("0x%02x", *(tptr)); + break; + case 0x14: /* System Name - not documented */ + printf("'%.*s'", len, tptr); + 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 ); + break; + default: + print_unknown_data(tptr,"\n\t ",len); + break; + } + } /* avoid infinite loop */ if (len == 0) break; - i += len; + tptr = tptr+len; } + if (vflag < 1) + printf(", length %u",caplen); return; - trunc: printf("[|cdp]"); } @@ -164,18 +243,19 @@ cdp_print_addr(const u_char * p, int l) }; #endif + TCHECK2(*p, 2); num = EXTRACT_32BITS(p); p += 4; - printf(" (%d): ", num); - while (p < endp && num >= 0) { + TCHECK2(*p, 2); if (p + 2 > endp) goto trunc; pt = p[0]; /* type of "protocol" field */ pl = p[1]; /* length of "protocol" field */ p += 2; + TCHECK2(p[pl], 2); if (p + pl + 2 > endp) goto trunc; al = EXTRACT_16BITS(&p[pl]); /* address length */ @@ -188,9 +268,12 @@ cdp_print_addr(const u_char * p, int l) */ p += 3; + TCHECK2(*p, 4); if (p + 4 > endp) goto trunc; - printf("IPv4 %u.%u.%u.%u", p[0], p[1], p[2], p[3]); + printf("IPv4 (%u) %s", + num, + ipaddr_string(p)); p += 4; } #ifdef INET6 @@ -202,11 +285,14 @@ cdp_print_addr(const u_char * p, int l) * protocol = LLC+SNAP header with the IPv6 * Ethertype, address length = 16 */ - p += 10; + p += 10; + TCHECK2(*p, al); if (p + al > endp) goto trunc; - printf("IPv6 %s", ip6addr_string(p)); + printf("IPv6 (%u) %s", + num, + ip6addr_string(p)); p += al; } #endif @@ -214,16 +300,19 @@ cdp_print_addr(const u_char * p, int l) /* * Generic case: just print raw data */ + TCHECK2(*p, pl); if (p + pl > endp) goto trunc; printf("pt=0x%02x, pl=%d, pb=", *(p - 2), pl); while (pl-- > 0) printf(" %02x", *p++); + TCHECK2(*p, 2); if (p + 2 > endp) goto trunc; al = (*p << 8) + *(p + 1); printf(", al=%d, a=", al); p += 2; + TCHECK2(*p, al); if (p + al > endp) goto trunc; while (al-- > 0) @@ -260,3 +349,17 @@ cdp_print_prefixes(const u_char * p, int l) trunc: return -1; } + +/* read in a <n>-byte number, MSB first + * (of course this can handle max sizeof(long)) + */ +static unsigned long cdp_get_number(const u_char * p, int l) +{ + unsigned long res=0; + while( l>0 ) + { + res = (res<<8) + *p; + p++; l--; + } + return res; +} diff --git a/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c index f6ff533..583b0ba 100644 --- a/contrib/tcpdump/print-chdlc.c +++ b/contrib/tcpdump/print-chdlc.c @@ -1,4 +1,3 @@ -/* maybe it should be merged into print-ppp.c */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -21,21 +20,16 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.13 2001/09/17 21:57:57 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.28.2.3 2004/03/24 00:46:03 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> -#include <netdb.h> #include <pcap.h> #include <stdio.h> @@ -49,41 +43,17 @@ static const char rcsid[] = static void chdlc_slarp_print(const u_char *, u_int); /* Standard CHDLC printer */ -void -chdlc_if_print(u_char *user, const struct pcap_pkthdr *h, - register const u_char *p) +u_int +chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p) { register u_int length = h->len; register u_int caplen = h->caplen; - - ++infodelay; - ts_print(&h->ts); - - /* - * Some printers want to get back at the link level addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. - */ - packetp = p; - snapend = p + caplen; - - chdlc_print(p, length, caplen); - - putchar('\n'); - --infodelay; - if (infoprint) - info(0); -} - -void -chdlc_print(register const u_char *p, u_int length, u_int caplen) -{ const struct ip *ip; u_int proto; if (caplen < CHDLC_HDRLEN) { printf("[|chdlc]"); - return; + return (caplen); } proto = EXTRACT_16BITS(&p[2]); @@ -121,9 +91,25 @@ chdlc_print(register const u_char *p, u_int length, u_int caplen) chdlc_cdp_print((const u_char *)ip, length); break; #endif + case ETHERTYPE_MPLS: + case ETHERTYPE_MPLS_MULTI: + mpls_print((const u_char *)(ip), length); + break; + case ETHERTYPE_ISO: + /* is the fudge byte set ? lets verify by spotting ISO headers */ + if (*(p+CHDLC_HDRLEN+1) == 0x81 || + *(p+CHDLC_HDRLEN+1) == 0x82 || + *(p+CHDLC_HDRLEN+1) == 0x83) + isoclns_print(p+CHDLC_HDRLEN+1, length-1, length-1); + else + isoclns_print(p+CHDLC_HDRLEN, length, length); + break; + default: + printf("unknown CHDLC protocol (0x%04x)", proto); + break; } - if (xflag) - default_print((const u_char *)ip, caplen - CHDLC_HDRLEN); + + return (CHDLC_HDRLEN); } struct cisco_slarp { @@ -154,34 +140,45 @@ chdlc_slarp_print(const u_char *cp, u_int length) { const struct cisco_slarp *slarp; - if (length < SLARP_LEN) { - printf("[|slarp]"); - return; - } + if (length < SLARP_LEN) + goto trunc; slarp = (const struct cisco_slarp *)cp; - switch (ntohl(slarp->code)) { + TCHECK(*slarp); + printf("SLARP (length: %u), ",length); + switch (EXTRACT_32BITS(&slarp->code)) { case SLARP_REQUEST: - printf("slarp-request"); + printf("request"); + /* ok we do not know it - but lets at least dump it */ + print_unknown_data(cp+4,"\n\t",length-4); break; case SLARP_REPLY: - printf("slarp-reply %s/%s", + printf("reply %s/%s", ipaddr_string(&slarp->un.addr.addr), ipaddr_string(&slarp->un.addr.mask)); break; case SLARP_KEEPALIVE: - printf("slarp-keepalive my=0x%x your=0x%x ", - (u_int32_t)ntohl(slarp->un.keep.myseq), - (u_int32_t)ntohl(slarp->un.keep.yourseq)); - printf("reliability=0x%04x t1=%d.%d", - ntohs(slarp->un.keep.rel), ntohs(slarp->un.keep.t1), - ntohs(slarp->un.keep.t2)); + printf("keepalive: mineseen=0x%08x, yourseen=0x%08x", + EXTRACT_32BITS(&slarp->un.keep.myseq), + EXTRACT_32BITS(&slarp->un.keep.yourseq)); + printf(", reliability=0x%04x, t1=%d.%d", + EXTRACT_16BITS(&slarp->un.keep.rel), + EXTRACT_16BITS(&slarp->un.keep.t1), + EXTRACT_16BITS(&slarp->un.keep.t2)); break; default: - printf("slarp-0x%x unknown", (u_int32_t)ntohl(slarp->code)); + printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code)); + if (vflag <= 1) + print_unknown_data(cp+4,"\n\t",length-4); break; } if (SLARP_LEN < length && vflag) - printf("(trailing junk: %d bytes)", length - SLARP_LEN); + printf(", (trailing junk: %d bytes)", length - SLARP_LEN); + if (vflag > 1) + print_unknown_data(cp+4,"\n\t",length-4); + return; + +trunc: + printf("[|slarp]"); } diff --git a/contrib/tcpdump/print-cip.c b/contrib/tcpdump/print-cip.c index 40228cd..17dd308 100644 --- a/contrib/tcpdump/print-cip.c +++ b/contrib/tcpdump/print-cip.c @@ -1,6 +1,6 @@ /* - * Marko Kiiskila carnil@cs.tut.fi - * + * Marko Kiiskila carnil@cs.tut.fi + * * Tampere University of Technology - Telecommunications Laboratory * * Permission to use, copy, modify and distribute this @@ -12,17 +12,17 @@ * documentation, and that the use of this software is * acknowledged in any publications resulting from using * the software. - * + * * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS * SOFTWARE. - * + * */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.16 2001/09/23 21:52:38 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.21.2.2 2003/11/16 08:51:15 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -31,13 +31,7 @@ static const char rcsid[] = #include <string.h> -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> - - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <pcap.h> @@ -47,7 +41,7 @@ static const char rcsid[] = #include "ethertype.h" #include "ether.h" -#define RFC1483LLC_LEN 8 +#define RFC1483LLC_LEN 8 static unsigned char rfcllc[] = { 0xaa, /* DSAP: non-ISO */ @@ -58,7 +52,7 @@ static unsigned char rfcllc[] = { 0x00 }; static inline void -cip_print(register const u_char *bp, int length) +cip_print(int length) { /* * There is no MAC-layer header, so just print the length. @@ -67,36 +61,25 @@ cip_print(register const u_char *bp, int length) } /* - * This is the top level routine of the printer. 'p' is the points - * to the raw header of the packet, 'tvp' is the timestamp, - * 'length' is the length of the packet off the wire, and 'caplen' + * This is the top level routine of the printer. 'p' points + * to the LLC/SNAP or raw header of the packet, 'h->ts' is the timestamp, + * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ -void -cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +u_int +cip_if_print(const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; u_short extracted_ethertype; - ++infodelay; - ts_print(&h->ts); - if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) { printf("[|cip]"); - goto out; + return (0); } if (eflag) - cip_print(p, length); - - /* - * Some printers want to get back at the ethernet addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. - */ - packetp = p; - snapend = p + caplen; + cip_print(length); if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) { /* @@ -106,7 +89,7 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) - cip_print(p, length); + cip_print(length); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); @@ -121,11 +104,5 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) ip_print(p, length); } - if (xflag) - default_print(p, caplen); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return (0); } diff --git a/contrib/tcpdump/print-cnfp.c b/contrib/tcpdump/print-cnfp.c index 206438e..0179ba7 100644 --- a/contrib/tcpdump/print-cnfp.c +++ b/contrib/tcpdump/print-cnfp.c @@ -33,29 +33,25 @@ /* Cisco NetFlow protocol */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.8 2001/09/17 21:57:58 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.14.2.2 2003/11/16 08:51:15 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netdb.h> - -#include <netinet/in.h> - -#include <arpa/inet.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <string.h> #include "interface.h" +#include "addrtoname.h" +#include "extract.h" #include "tcp.h" +#include "ipproto.h" struct nfhdr { u_int32_t ver_cnt; /* version [15], and # of records */ @@ -83,7 +79,7 @@ struct nfrec { }; void -cnfp_print(const u_char *cp, u_int len, const u_char *bp) +cnfp_print(const u_char *cp, const u_char *bp) { register const struct nfhdr *nh; register const struct nfrec *nr; @@ -98,18 +94,18 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp) if ((const u_char *)(nh + 1) > snapend) return; - nrecs = ntohl(nh->ver_cnt) & 0xffff; - ver = (ntohl(nh->ver_cnt) & 0xffff0000) >> 16; - t = ntohl(nh->utc_sec); + nrecs = EXTRACT_32BITS(&nh->ver_cnt) & 0xffff; + ver = (EXTRACT_32BITS(&nh->ver_cnt) & 0xffff0000) >> 16; + t = EXTRACT_32BITS(&nh->utc_sec); /* (p = ctime(&t))[24] = '\0'; */ printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver, - (unsigned)ntohl(nh->msys_uptime)/1000, - (unsigned)ntohl(nh->msys_uptime)%1000, - (unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec)); + EXTRACT_32BITS(&nh->msys_uptime)/1000, + EXTRACT_32BITS(&nh->msys_uptime)%1000, + EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)); if (ver == 5 || ver == 6) { - printf("#%u, ", (unsigned)htonl(nh->sequence)); + printf("#%u, ", EXTRACT_32BITS(&nh->sequence)); nr = (const struct nfrec *)&nh[1]; snaplen -= 24; } else { @@ -124,36 +120,36 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp) char asbuf[20]; printf("\n started %u.%03u, last %u.%03u", - (unsigned)ntohl(nr->start_time)/1000, - (unsigned)ntohl(nr->start_time)%1000, - (unsigned)ntohl(nr->last_time)/1000, - (unsigned)ntohl(nr->last_time)%1000); + EXTRACT_32BITS(&nr->start_time)/1000, + EXTRACT_32BITS(&nr->start_time)%1000, + EXTRACT_32BITS(&nr->last_time)/1000, + EXTRACT_32BITS(&nr->last_time)%1000); asbuf[0] = buf[0] = '\0'; if (ver == 5 || ver == 6) { snprintf(buf, sizeof(buf), "/%u", - (unsigned)(ntohl(nr->masks) >> 24) & 0xff); + (EXTRACT_32BITS(&nr->masks) >> 24) & 0xff); snprintf(asbuf, sizeof(asbuf), ":%u", - (unsigned)(ntohl(nr->asses) >> 16) & 0xffff); + (EXTRACT_32BITS(&nr->asses) >> 16) & 0xffff); } - printf("\n %s%s%s:%u ", inet_ntoa(nr->src_ina), buf, asbuf, - (unsigned)ntohl(nr->ports) >> 16); + printf("\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf, + EXTRACT_32BITS(&nr->ports) >> 16); if (ver == 5 || ver ==6) { snprintf(buf, sizeof(buf), "/%d", - (unsigned)(ntohl(nr->masks) >> 16) & 0xff); + (EXTRACT_32BITS(&nr->masks) >> 16) & 0xff); snprintf(asbuf, sizeof(asbuf), ":%u", - (unsigned)ntohl(nr->asses) & 0xffff); + EXTRACT_32BITS(&nr->asses) & 0xffff); } - printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf, - (unsigned)ntohl(nr->ports) & 0xffff); + printf("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf, + EXTRACT_32BITS(&nr->ports) & 0xffff); - printf(">> %s\n ", inet_ntoa(nr->nhop_ina)); + printf(">> %s\n ", intoa(nr->nhop_ina.s_addr)); - pent = getprotobynumber((ntohl(nr->proto_tos) >> 8) & 0xff); + pent = getprotobynumber((EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff); if (!pent || nflag) printf("%u ", - (unsigned)(ntohl(nr->proto_tos) >> 8) & 0xff); + (EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff); else printf("%s ", pent->p_name); @@ -161,9 +157,9 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp) if (pent && pent->p_proto == IPPROTO_TCP) { int flags; if (ver == 1) - flags = (ntohl(nr->asses) >> 24) & 0xff; + flags = (EXTRACT_32BITS(&nr->asses) >> 24) & 0xff; else - flags = (ntohl(nr->proto_tos) >> 16) & 0xff; + flags = (EXTRACT_32BITS(&nr->proto_tos) >> 16) & 0xff; if (flags & TH_FIN) putchar('F'); if (flags & TH_SYN) putchar('S'); if (flags & TH_RST) putchar('R'); @@ -177,12 +173,12 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp) buf[0]='\0'; if (ver == 6) { snprintf(buf, sizeof(buf), "(%u<>%u encaps)", - (unsigned)(ntohl(nr->masks) >> 8) & 0xff, - (unsigned)(ntohl(nr->masks)) & 0xff); + (EXTRACT_32BITS(&nr->masks) >> 8) & 0xff, + (EXTRACT_32BITS(&nr->masks)) & 0xff); } printf("tos %u, %u (%u octets) %s", - (unsigned)ntohl(nr->proto_tos) & 0xff, - (unsigned)ntohl(nr->packets), - (unsigned)ntohl(nr->octets), buf); + EXTRACT_32BITS(&nr->proto_tos) & 0xff, + EXTRACT_32BITS(&nr->packets), + EXTRACT_32BITS(&nr->octets), buf); } } diff --git a/contrib/tcpdump/print-decnet.c b/contrib/tcpdump/print-decnet.c index 8c51a67..f84b080 100644 --- a/contrib/tcpdump/print-decnet.c +++ b/contrib/tcpdump/print-decnet.c @@ -20,30 +20,26 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.33 2001/09/17 21:57:59 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.36.2.2 2003/11/16 08:51:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> struct mbuf; struct rtentry; -#ifdef HAVE_LIBDNET +#ifdef HAVE_NETDNET_DNETDB_H #include <netdnet/dnetdb.h> #endif -#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include "decnet.h" #include "extract.h" @@ -63,7 +59,7 @@ static void print_reason(int); static void pdata(u_char *, int); #endif -#ifdef HAVE_LIBDNET +#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA extern char *dnet_htoa(struct dn_naddr *); #endif @@ -344,13 +340,13 @@ print_i_info(int info) } static void -print_elist(const char *elp, u_int len) +print_elist(const char *elp _U_, u_int len _U_) { /* Not enough examples available for me to debug this */ } static void -print_nsp(const u_char *nspp, u_int nsplen) +print_nsp(const u_char *nspp, u_int nsplen _U_) { const struct nsphdr *nsphp = (struct nsphdr *)nspp; int dst, src, flags; @@ -748,7 +744,7 @@ dnnum_string(u_short dnaddr) const char * dnname_string(u_short dnaddr) { -#ifdef HAVE_LIBDNET +#ifdef HAVE_DNET_HTOA struct dn_naddr dna; dna.a_len = sizeof(short); diff --git a/contrib/tcpdump/print-dhcp6.c b/contrib/tcpdump/print-dhcp6.c index 455a1f7..1193e37 100644 --- a/contrib/tcpdump/print-dhcp6.c +++ b/contrib/tcpdump/print-dhcp6.c @@ -1,7 +1,7 @@ /* * Copyright (C) 1998 and 1999 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: @@ -13,7 +13,7 @@ * 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 @@ -27,31 +27,34 @@ * SUCH DAMAGE. */ /* - * draft-ietf-dhc-dhcpv6-22.txt + * RFC3315: DHCPv6 + * supported DHCPv6 options: + * RFC3319, + * draft-ietf-dhc-dhcpv6-opt-dnsconfig-04.txt, + * draft-ietf-dhc-dhcpv6-opt-prefix-delegation-05.txt + * draft-ietf-dhc-dhcpv6-opt-timeconfig-02.txt, */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.14.4.2 2002/06/01 23:51:12 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.27.2.4 2003/11/18 23:26:14 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> #include <stdio.h> #include <string.h> -#include <arpa/inet.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" + +/* lease duration */ +#define DHCP6_DURATITION_INFINITE 0xffffffff /* Error Values */ #define DH6ERR_FAILURE 16 @@ -61,8 +64,19 @@ static const char rcsid[] = #define DH6ERR_OPTUNAVAIL 20 /* Message type */ +#define DH6_SOLICIT 1 +#define DH6_ADVERTISE 2 +#define DH6_REQUEST 3 +#define DH6_CONFIRM 4 +#define DH6_RENEW 5 +#define DH6_REBIND 6 #define DH6_REPLY 7 +#define DH6_RELEASE 8 +#define DH6_DECLINE 9 +#define DH6_RECONFIGURE 10 #define DH6_INFORM_REQ 11 +#define DH6_RELAY_FORW 12 +#define DH6_RELAY_REPLY 13 /* DHCP6 base packet format */ struct dhcp6 { @@ -70,61 +84,229 @@ struct dhcp6 { u_int8_t m; u_int32_t x; } dh6_msgtypexid; - struct in6_addr dh6_servaddr; /* options follow */ -} __attribute__ ((__packed__)); +}; #define dh6_msgtype dh6_msgtypexid.m #define dh6_xid dh6_msgtypexid.x #define DH6_XIDMASK 0x00ffffff -/* option */ -#define DH6OPT_DUID 1 /* TBD */ -#define DH6OPT_DNS 11 /* TBD */ +/* DHCPv6 relay messages */ +struct dhcp6_relay { + u_int8_t dh6relay_msgtype; + u_int8_t dh6relay_hcnt; + u_int8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */ + u_int8_t dh6relay_peeraddr[16]; + /* options follow */ +}; + +/* options */ +#define DH6OPT_CLIENTID 1 +#define DH6OPT_SERVERID 2 +#define DH6OPT_IA_NA 3 +#define DH6OPT_IA_TMP 4 +#define DH6OPT_IADDR 5 +#define DH6OPT_ORO 6 +#define DH6OPT_PREFERENCE 7 +# define DH6OPT_PREF_UNDEF -1 +# define DH6OPT_PREF_MAX 255 +#define DH6OPT_ELAPSED_TIME 8 +#define DH6OPT_RELAY_MSG 9 +/*#define DH6OPT_SERVER_MSG 10 deprecated */ +#define DH6OPT_AUTH 11 +#define DH6OPT_UNICAST 12 +#define DH6OPT_STATUS_CODE 13 +# define DH6OPT_STCODE_SUCCESS 0 +# define DH6OPT_STCODE_UNSPECFAIL 1 +# define DH6OPT_STCODE_NOADDRAVAIL 2 +# define DH6OPT_STCODE_NOBINDING 3 +# define DH6OPT_STCODE_NOTONLINK 4 +# define DH6OPT_STCODE_USEMULTICAST 5 +# define DH6OPT_STCODE_NOPREFIXAVAIL 6 +#define DH6OPT_RAPID_COMMIT 14 +#define DH6OPT_USER_CLASS 15 +#define DH6OPT_VENDOR_CLASS 16 +#define DH6OPT_VENDOR_OPTS 17 +#define DH6OPT_INTERFACE_ID 18 +#define DH6OPT_RECONF_MSG 19 +#define DH6OPT_RECONF_ACCEPT 20 +#define DH6OPT_SIP_SERVER_D 21 +#define DH6OPT_SIP_SERVER_A 22 +#define DH6OPT_DNS 23 +#define DH6OPT_DNSNAME 24 + +/* + * The option type has not been assigned for the following options. + * We temporarily adopt values used in the service specification document + * (200206xx version) by NTT Communications. + * Note that we'll change the following definitions if different type values + * are officially assigned. + */ +#define DH6OPT_PREFIX_DELEGATION 30 +#define DH6OPT_PREFIX_INFORMATION 31 +#define DH6OPT_PREFIX_REQUEST 32 + +/* + * The followings are also unassigned numbers. + * We temporarily use values as of KAME snap 20031013. + */ +#define DH6OPT_IA_PD 33 +#define DH6OPT_IA_PD_PREFIX 34 +#define DH6OPT_NTP_SERVERS 35 + struct dhcp6opt { u_int16_t dh6opt_type; u_int16_t dh6opt_len; /* type-dependent data follows */ -} __attribute__ ((__packed__)); +}; + +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_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__)); + +static const char * +dhcp6opt_name(int type) +{ + static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */ + + if (type > 65535) + return "INVALID option"; + + switch(type) { + case DH6OPT_CLIENTID: + return "client ID"; + case DH6OPT_SERVERID: + return "server ID"; + case DH6OPT_IA_NA: + return "IA_NA"; + case DH6OPT_ORO: + return "option request"; + case DH6OPT_PREFERENCE: + return "preference"; + case DH6OPT_ELAPSED_TIME: + return "elapsed time"; + case DH6OPT_RELAY_MSG: + return "relay message"; + case DH6OPT_STATUS_CODE: + return "status code"; + case DH6OPT_RAPID_COMMIT: + return "rapid commit"; + case DH6OPT_INTERFACE_ID: + return "interface ID"; + case DH6OPT_RECONF_MSG: + return "reconfigure message"; + case DH6OPT_RECONF_ACCEPT: + return "reconfigure accept"; + case DH6OPT_SIP_SERVER_D: + return "SIP Servers Domain"; + case DH6OPT_SIP_SERVER_A: + return "SIP Servers Address"; + case DH6OPT_DNS: + return "DNS"; + case DH6OPT_PREFIX_DELEGATION: + return "prefix delegation"; + case DH6OPT_PREFIX_INFORMATION: + return "prefix information"; + case DH6OPT_IA_PD: + return "IA_PD"; + case DH6OPT_IA_PD_PREFIX: + return "IA_PD prefix"; + case DH6OPT_NTP_SERVERS: + return "NTP Server"; + default: + snprintf(genstr, sizeof(genstr), "opt_%d", type); + return(genstr); + } +} + +static const char * +dhcp6stcode(int code) +{ + static char genstr[sizeof("code255") + 1]; /* XXX thread unsafe */ + + if (code > 255) + return "INVALID code"; + + switch(code) { + case DH6OPT_STCODE_SUCCESS: + return "success"; + case DH6OPT_STCODE_UNSPECFAIL: + return "unspec failure"; + case DH6OPT_STCODE_NOADDRAVAIL: + return "no addresses"; + case DH6OPT_STCODE_NOBINDING: + return "no binding"; + case DH6OPT_STCODE_NOTONLINK: + return "not on-link"; + case DH6OPT_STCODE_USEMULTICAST: + return "use multicast"; + case DH6OPT_STCODE_NOPREFIXAVAIL: + return "no prefixes"; + default: + snprintf(genstr, sizeof(genstr), "code%d", code); + return(genstr); + } +} static void -dhcp6opt_print(u_char *cp, u_char *ep) +dhcp6opt_print(const u_char *cp, const u_char *ep) { struct dhcp6opt *dh6o; u_char *tp; - int i; + size_t i; + u_int16_t opttype; size_t optlen; + u_int16_t val16; + u_int32_t val32; + struct in6_addr addr6; + struct dhcp6_ia ia; + struct dhcp6_ia_prefix ia_prefix; if (cp == ep) return; while (cp < ep) { - if (ep - cp < sizeof(*dh6o)) + if (ep < cp + sizeof(*dh6o)) goto trunc; dh6o = (struct dhcp6opt *)cp; - optlen = ntohs(dh6o->dh6opt_len); - if (ep - cp < sizeof(*dh6o) + optlen) + optlen = EXTRACT_16BITS(&dh6o->dh6opt_len); + if (ep < cp + sizeof(*dh6o) + optlen) goto trunc; - switch (ntohs(dh6o->dh6opt_type)) { - case DH6OPT_DUID: - printf(" (duid"); /*)*/ + opttype = EXTRACT_16BITS(&dh6o->dh6opt_type); + printf(" (%s", dhcp6opt_name(opttype)); + switch (opttype) { + case DH6OPT_CLIENTID: + case DH6OPT_SERVERID: if (optlen < 2) { /*(*/ - printf(" ??)"); + printf(" ?)"); break; } tp = (u_char *)(dh6o + 1); - switch (ntohs(*(u_int16_t *)tp)) { + switch (EXTRACT_16BITS(tp)) { case 1: if (optlen >= 2 + 6) { - printf(" hwaddr/time time %u type %u ", - ntohl(*(u_int32_t *)&tp[2]), - ntohs(*(u_int16_t *)&tp[6])); + printf(" hwaddr/time type %u time %u ", + EXTRACT_16BITS(&tp[2]), + EXTRACT_32BITS(&tp[4])); for (i = 8; i < optlen; i++) printf("%02x", tp[i]); /*(*/ printf(")"); } else { /*(*/ - printf(" ??)"); + printf(" ?)"); } break; case 2: @@ -136,37 +318,177 @@ dhcp6opt_print(u_char *cp, u_char *ep) printf(")"); } else { /*(*/ - printf(" ??)"); + printf(" ?)"); } break; case 3: if (optlen >= 2 + 2) { printf(" hwaddr type %u ", - ntohs(*(u_int16_t *)&tp[2])); + EXTRACT_16BITS(&tp[2])); for (i = 4; i < optlen; i++) printf("%02x", tp[i]); /*(*/ printf(")"); } else { /*(*/ - printf(" ??)"); + printf(" ?)"); } + break; + default: + printf(" type %d)", EXTRACT_16BITS(tp)); + break; + } + break; + case DH6OPT_ORO: + if (optlen % 2) { + printf(" ?)"); + break; + } + 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(")"); + break; + case DH6OPT_PREFERENCE: + if (optlen != 1) { + printf(" ?)"); + break; + } + printf(" %d)", *((u_char *)(dh6o + 1) + 1)); + break; + case DH6OPT_ELAPSED_TIME: + if (optlen != 2) { + printf(" ?)"); + break; + } + memcpy(&val16, dh6o + 1, sizeof(val16)); + val16 = ntohs(val16); + printf(" %d)", (int)val16); + break; + case DH6OPT_RELAY_MSG: + printf(" ("); + dhcp6_print((const u_char *)(dh6o + 1), optlen); + printf(")"); + break; + case DH6OPT_RAPID_COMMIT: /* nothing todo */ + printf(")"); + break; + case DH6OPT_INTERFACE_ID: + /* + * Since we cannot predict the encoding, print hex dump + * at most 10 characters. + */ + for (i = 0; i < optlen && i < 10; i++) + printf("%02x", ((u_char *)(dh6o + 1))[i]); + break; + case DH6OPT_RECONF_MSG: + tp = (u_char *)(dh6o + 1); + switch (*tp) { + case DH6_RENEW: + printf(" for renew)"); + break; + case DH6_INFORM_REQ: + printf(" for inf-req)"); + break; + default: + printf(" for ?\?\?(%02x))", *tp); + break; } break; + case DH6OPT_RECONF_ACCEPT: /* nothing todo */ + printf(")"); + break; + case DH6OPT_SIP_SERVER_A: case DH6OPT_DNS: - printf(" (dnsserver"); /*)*/ + case DH6OPT_NTP_SERVERS: if (optlen % 16) { - /*(*/ - printf(" ??)"); + printf(" ?)"); break; } tp = (u_char *)(dh6o + 1); for (i = 0; i < optlen; i += 16) printf(" %s", ip6addr_string(&tp[i])); - /*(*/ printf(")"); + break; + case DH6OPT_PREFIX_DELEGATION: + dhcp6opt_print((u_char *)(dh6o + 1), + (u_char *)(dh6o + 1) + optlen); + printf(")"); + break; + case DH6OPT_PREFIX_INFORMATION: + if (optlen % 21) + printf(" ?)"); + memcpy(&addr6, (u_char *)(dh6o + 1) + 5, + sizeof(addr6)); + printf(" %s/%d", ip6addr_string(&addr6), + (int)*((u_char *)(dh6o + 1) + 4)); + memcpy(&val32, dh6o + 1, sizeof(val32)); + val32 = ntohl(val32); + if (val32 == DHCP6_DURATITION_INFINITE) + printf(" lease-duration: infinite)"); + else + printf(" lease-duration: %u)", val32); + break; + case DH6OPT_STATUS_CODE: + if (optlen < 2) { + printf(" ?)"); + break; + } + memcpy(&val16, (u_char *)(dh6o + 1), sizeof(val16)); + val16 = ntohs(val16); + printf(" %s)", dhcp6stcode(val16)); + break; + case DH6OPT_IA_NA: + case DH6OPT_IA_PD: + if (optlen < sizeof(ia) - 4) { + 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) { + /* there are sub-options */ + dhcp6opt_print((u_char *)dh6o + sizeof(ia), + (u_char *)(dh6o + 1) + optlen); + } + printf(")"); + break; + case DH6OPT_IA_PD_PREFIX: + if (optlen < sizeof(ia_prefix) - 4) { + 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) { + /* there are sub-options */ + dhcp6opt_print((u_char *)dh6o + + sizeof(ia_prefix), + (u_char *)(dh6o + 1) + optlen); + } + printf(")"); + break; default: - printf(" (opt-%u)", ntohs(dh6o->dh6opt_type)); + printf(")"); break; } @@ -182,27 +504,63 @@ trunc: * Print dhcp6 packets */ void -dhcp6_print(register const u_char *cp, u_int length, - u_int16_t sport, u_int16_t dport) +dhcp6_print(const u_char *cp, u_int length) { struct dhcp6 *dh6; - u_char *ep; + struct dhcp6_relay *dh6relay; + const u_char *ep; u_char *extp; const char *name; printf("dhcp6"); ep = (u_char *)snapend; + if (cp + length < ep) + ep = cp + length; dh6 = (struct dhcp6 *)cp; - TCHECK(dh6->dh6_servaddr); + dh6relay = (struct dhcp6_relay *)cp; + TCHECK(dh6->dh6_xid); switch (dh6->dh6_msgtype) { + case DH6_SOLICIT: + name = "solicit"; + break; + case DH6_ADVERTISE: + name = "advertise"; + break; + case DH6_REQUEST: + name = "request"; + break; + case DH6_CONFIRM: + name = "confirm"; + break; + case DH6_RENEW: + name = "renew"; + break; + case DH6_REBIND: + name = "rebind"; + break; case DH6_REPLY: name = "reply"; break; + case DH6_RELEASE: + name = "release"; + break; + case DH6_DECLINE: + name = "decline"; + break; + case DH6_RECONFIGURE: + name = "reconfigure"; + break; case DH6_INFORM_REQ: name= "inf-req"; break; + case DH6_RELAY_FORW: + name= "relay-fwd"; + break; + case DH6_RELAY_REPLY: + name= "relay-reply"; + break; default: name = NULL; break; @@ -211,8 +569,10 @@ dhcp6_print(register const u_char *cp, u_int length, if (!vflag) { if (name) printf(" %s", name); - else + else if (dh6->dh6_msgtype != DH6_RELAY_FORW && + dh6->dh6_msgtype != DH6_RELAY_REPLY) { printf(" msgtype-%u", dh6->dh6_msgtype); + } return; } @@ -222,10 +582,24 @@ dhcp6_print(register const u_char *cp, u_int length, printf(" %s (", name); /*)*/ else printf(" msgtype-%u (", dh6->dh6_msgtype); /*)*/ - printf("xid=%x", ntohl(dh6->dh6_xid) & DH6_XIDMASK); - printf(" server=%s", ip6addr_string(&dh6->dh6_servaddr)); - extp = (u_char *)(dh6 + 1); - dhcp6opt_print(extp, ep); + if (dh6->dh6_msgtype != DH6_RELAY_FORW && + dh6->dh6_msgtype != DH6_RELAY_REPLY) { + printf("xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK); + extp = (u_char *)(dh6 + 1); + dhcp6opt_print(extp, ep); + } else { /* relay messages */ + struct in6_addr addr6; + + TCHECK(dh6relay->dh6relay_peeraddr); + + memcpy(&addr6, dh6relay->dh6relay_linkaddr, sizeof (addr6)); + printf("linkaddr=%s", ip6addr_string(&addr6)); + + memcpy(&addr6, dh6relay->dh6relay_peeraddr, sizeof (addr6)); + printf(" peeraddr=%s", ip6addr_string(&addr6)); + + dhcp6opt_print((u_char *)(dh6relay + 1), ep); + } /*(*/ printf(")"); return; diff --git a/contrib/tcpdump/print-dvmrp.c b/contrib/tcpdump/print-dvmrp.c index 273c7d6..5e45d55 100644 --- a/contrib/tcpdump/print-dvmrp.c +++ b/contrib/tcpdump/print-dvmrp.c @@ -20,24 +20,19 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.21 2001/05/10 05:30:20 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.24.2.3 2003/11/19 09:41:28 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <unistd.h> #include "interface.h" #include "extract.h" @@ -67,13 +62,13 @@ static const char rcsid[] = #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */ #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */ -static void print_probe(const u_char *, const u_char *, u_int); -static void print_report(const u_char *, const u_char *, u_int); -static void print_neighbors(const u_char *, const u_char *, u_int); -static void print_neighbors2(const u_char *, const u_char *, u_int); -static void print_prune(const u_char *, const u_char *, u_int); -static void print_graft(const u_char *, const u_char *, u_int); -static void print_graft_ack(const u_char *, const u_char *, u_int); +static int print_probe(const u_char *, const u_char *, u_int); +static int print_report(const u_char *, const u_char *, u_int); +static int print_neighbors(const u_char *, const u_char *, u_int); +static int print_neighbors2(const u_char *, const u_char *, u_int); +static int print_prune(const u_char *); +static int print_graft(const u_char *); +static int print_graft_ack(const u_char *); static u_int32_t target_level; @@ -87,6 +82,7 @@ dvmrp_print(register const u_char *bp, register u_int len) if (bp >= ep) return; + TCHECK(bp[1]); type = bp[1]; /* Skip IGMP header */ @@ -97,14 +93,18 @@ dvmrp_print(register const u_char *bp, register u_int len) case DVMRP_PROBE: printf(" Probe"); - if (vflag) - print_probe(bp, ep, len); + if (vflag) { + if (print_probe(bp, ep, len) < 0) + goto trunc; + } break; case DVMRP_REPORT: printf(" Report"); - if (vflag > 1) - print_report(bp, ep, len); + if (vflag > 1) { + if (print_report(bp, ep, len) < 0) + goto trunc; + } break; case DVMRP_ASK_NEIGHBORS: @@ -113,7 +113,8 @@ dvmrp_print(register const u_char *bp, register u_int len) case DVMRP_NEIGHBORS: printf(" Neighbors(old)"); - print_neighbors(bp, ep, len); + if (print_neighbors(bp, ep, len) < 0) + goto trunc; break; case DVMRP_ASK_NEIGHBORS2: @@ -127,45 +128,57 @@ dvmrp_print(register const u_char *bp, register u_int len) * address field */ bp -= 4; + TCHECK2(bp[0], 4); target_level = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3]; bp += 4; - print_neighbors2(bp, ep, len); + if (print_neighbors2(bp, ep, len) < 0) + goto trunc; break; case DVMRP_PRUNE: printf(" Prune"); - print_prune(bp, ep, len); + if (print_prune(bp) < 0) + goto trunc; break; case DVMRP_GRAFT: printf(" Graft"); - print_graft(bp, ep, len); + if (print_graft(bp) < 0) + goto trunc; break; case DVMRP_GRAFT_ACK: printf(" Graft-ACK"); - print_graft_ack(bp, ep, len); + if (print_graft_ack(bp) < 0) + goto trunc; break; default: printf(" [type %d]", type); break; } + return; + +trunc: + printf("[|dvmrp]"); + return; } -static void +static int print_report(register const u_char *bp, register const u_char *ep, register u_int len) { register u_int32_t mask, origin; - register int metric, i, width, done; + register int metric, done; + register u_int i, width; while (len > 0) { if (len < 3) { printf(" [|]"); - return; + return (0); } + TCHECK2(bp[0], 3); mask = (u_int32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2]; width = 1; if (bp[0]) @@ -181,18 +194,21 @@ print_report(register const u_char *bp, register const u_char *ep, do { if (bp + width + 1 > ep) { printf(" [|]"); - return; + return (0); } if (len < width + 1) { printf("\n\t [Truncated Report]"); - return; + return (0); } origin = 0; - for (i = 0; i < width; ++i) + for (i = 0; i < width; ++i) { + TCHECK(*bp); origin = origin << 8 | *bp++; + } for ( ; i < 4; ++i) origin <<= 8; + TCHECK(*bp); metric = *bp++; done = metric & 0x80; metric &= 0x7f; @@ -201,9 +217,12 @@ print_report(register const u_char *bp, register const u_char *ep, len -= width + 1; } while (!done); } + return (0); +trunc: + return (-1); } -static void +static int print_probe(register const u_char *bp, register const u_char *ep, register u_int len) { @@ -213,7 +232,7 @@ print_probe(register const u_char *bp, register const u_char *ep, if ((len < 4) || ((bp + 4) > ep)) { /* { (ctags) */ printf(" [|}"); - return; + return (0); } genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3]; bp += 4; @@ -224,19 +243,19 @@ print_probe(register const u_char *bp, register const u_char *ep, printf(" "); printf("genid %u", genid); if (vflag < 2) - return; + return (0); while ((len > 0) && (bp < ep)) { TCHECK2(bp[0], 4); printf("\n\tneighbor %s", ipaddr_string(bp)); bp += 4; len -= 4; } - return; + return (0); trunc: - (void)printf("[|dvmrp]"); + return (-1); } -static void +static int print_neighbors(register const u_char *bp, register const u_char *ep, register u_int len) { @@ -262,12 +281,12 @@ print_neighbors(register const u_char *bp, register const u_char *ep, len -= 4; } } - return; + return (0); trunc: - (void)printf("[|dvmrp]"); + return (-1); } -static void +static int print_neighbors2(register const u_char *bp, register const u_char *ep, register u_int len) { @@ -308,46 +327,43 @@ print_neighbors2(register const u_char *bp, register const u_char *ep, } if (ncount != -1) { printf(" [|]"); - return; + return (0); } } - return; + return (0); trunc: - (void)printf("[|dvmrp]"); + return (-1); } -static void -print_prune(register const u_char *bp, register const u_char *ep, - register u_int len) +static int +print_prune(register const u_char *bp) { TCHECK2(bp[0], 12); printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4)); bp += 8; (void)printf(" timer "); relts_print(EXTRACT_32BITS(bp)); - return; + return (0); trunc: - (void)printf("[|dvmrp]"); + return (-1); } -static void -print_graft(register const u_char *bp, register const u_char *ep, - register u_int len) +static int +print_graft(register const u_char *bp) { TCHECK2(bp[0], 8); printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4)); - return; + return (0); trunc: - (void)printf("[|dvmrp]"); + return (-1); } -static void -print_graft_ack(register const u_char *bp, register const u_char *ep, - register u_int len) +static int +print_graft_ack(register const u_char *bp) { TCHECK2(bp[0], 8); printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4)); - return; + return (0); trunc: - (void)printf("[|dvmrp]"); + return (-1); } diff --git a/contrib/tcpdump/print-egp.c b/contrib/tcpdump/print-egp.c index a60d438..6cfaa30 100644 --- a/contrib/tcpdump/print-egp.c +++ b/contrib/tcpdump/print-egp.c @@ -19,38 +19,34 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.28.4.1 2002/06/01 23:51:12 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.34.2.2 2003/11/16 08:51:18 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <netdb.h> #include <stdio.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" #include "ip.h" struct egp_packet { - u_char egp_version; + u_int8_t egp_version; #define EGP_VERSION 2 - u_char egp_type; + u_int8_t egp_type; #define EGPT_ACQUIRE 3 #define EGPT_REACH 5 #define EGPT_POLL 2 #define EGPT_UPDATE 1 #define EGPT_ERROR 8 - u_char egp_code; + u_int8_t egp_code; #define EGPC_REQUEST 0 #define EGPC_CONFIRM 1 #define EGPC_REFUSE 2 @@ -58,7 +54,7 @@ struct egp_packet { #define EGPC_CEASEACK 4 #define EGPC_HELLO 0 #define EGPC_HEARDU 1 - u_char egp_status; + u_int8_t egp_status; #define EGPS_UNSPEC 0 #define EGPS_ACTIVE 1 #define EGPS_PASSIVE 2 @@ -71,13 +67,13 @@ struct egp_packet { #define EGPS_UP 1 #define EGPS_DOWN 2 #define EGPS_UNSOL 0x80 - u_short egp_checksum; - u_short egp_as; - u_short egp_sequence; + u_int16_t egp_checksum; + u_int16_t egp_as; + u_int16_t egp_sequence; union { - u_short egpu_hello; - u_char egpu_gws[2]; - u_short egpu_reason; + u_int16_t egpu_hello; + u_int8_t egpu_gws[2]; + u_int16_t egpu_reason; #define EGPR_UNSPEC 0 #define EGPR_BADHEAD 1 #define EGPR_BADDATA 2 @@ -91,7 +87,7 @@ struct egp_packet { #define egp_extgw egp_handg.egpu_gws[1] #define egp_reason egp_handg.egpu_reason union { - u_short egpu_poll; + u_int16_t egpu_poll; u_int32_t egpu_sourcenet; } egp_pands; #define egp_poll egp_pands.egpu_poll @@ -139,15 +135,15 @@ const char *egp_reasons[] = { }; static void -egpnrprint(register const struct egp_packet *egp, register u_int length) +egpnrprint(register const struct egp_packet *egp) { - register const u_char *cp; + register const u_int8_t *cp; u_int32_t addr; register u_int32_t net; register u_int netlen; int gateways, distances, networks; int t_gateways; - char *comma; + const char *comma; addr = egp->egp_sourcenet; if (IN_CLASSA(addr)) { @@ -163,7 +159,7 @@ egpnrprint(register const struct egp_packet *egp, register u_int length) net = 0; netlen = 0; } - cp = (u_char *)(egp + 1); + cp = (u_int8_t *)(egp + 1); t_gateways = egp->egp_intgw + egp->egp_extgw; for (gateways = 0; gateways < t_gateways; ++gateways) { @@ -218,24 +214,25 @@ trunc: } void -egp_print(register const u_char *bp, register u_int length, - register const u_char *bp2) +egp_print(register const u_int8_t *bp) { register const struct egp_packet *egp; - register const struct ip *ip; register int status; register int code; register int type; egp = (struct egp_packet *)bp; - ip = (struct ip *)bp2; + if (!TTEST(*egp)) { + printf("[|egp]"); + return; + } (void)printf("egp: "); if (egp->egp_version != EGP_VERSION) { printf("[version %d]", egp->egp_version); return; } - printf("as:%d seq:%d", ntohs(egp->egp_as), ntohs(egp->egp_sequence)); + printf("as:%d seq:%d", EXTRACT_16BITS(&egp->egp_as), EXTRACT_16BITS(&egp->egp_sequence)); type = egp->egp_type; code = egp->egp_code; @@ -260,8 +257,8 @@ egp_print(register const u_char *bp, register u_int length, break; } printf(" hello:%d poll:%d", - ntohs(egp->egp_hello), - ntohs(egp->egp_poll)); + EXTRACT_16BITS(&egp->egp_hello), + EXTRACT_16BITS(&egp->egp_poll)); break; case EGPC_REFUSE: @@ -332,7 +329,7 @@ egp_print(register const u_char *bp, register u_int length, egp->egp_intgw, egp->egp_extgw); if (vflag) - egpnrprint(egp, length); + egpnrprint(egp); break; case EGPT_ERROR: @@ -342,10 +339,10 @@ egp_print(register const u_char *bp, register u_int length, else printf(" [status %d]", status); - if (ntohs(egp->egp_reason) <= EGPR_UVERSION) - printf(" %s", egp_reasons[ntohs(egp->egp_reason)]); + if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION) + printf(" %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]); else - printf(" [reason %d]", ntohs(egp->egp_reason)); + printf(" [reason %d]", EXTRACT_16BITS(&egp->egp_reason)); break; default: diff --git a/contrib/tcpdump/print-enc.c b/contrib/tcpdump/print-enc.c new file mode 100644 index 0000000..c7196e7 --- /dev/null +++ b/contrib/tcpdump/print-enc.c @@ -0,0 +1,78 @@ +/* $OpenBSD: print-enc.c,v 1.7 2002/02/19 19:39:40 millert Exp $ */ + +/* + * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.1.2.2 2003/11/16 08:51:19 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> + +#include "interface.h" +#include "addrtoname.h" + +#include "enc.h" + +#define ENC_PRINT_TYPE(wh, xf, nam) \ + if ((wh) & (xf)) { \ + printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \ + (wh) &= ~(xf); \ + } + +u_int +enc_if_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + register u_int length = h->len; + register u_int caplen = h->caplen; + int flags; + const struct enchdr *hdr; + + if (caplen < ENC_HDRLEN) { + printf("[|enc]"); + goto out; + } + + hdr = (struct enchdr *)p; + flags = hdr->flags; + if (flags == 0) + printf("(unprotected): "); + else + printf("("); + 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)); + + length -= ENC_HDRLEN; + /* XXX - use the address family */ + ip_print(p + ENC_HDRLEN, length); + +out: + return (ENC_HDRLEN); +} diff --git a/contrib/tcpdump/print-esp.c b/contrib/tcpdump/print-esp.c index b486346..0ca0cfa 100644 --- a/contrib/tcpdump/print-esp.c +++ b/contrib/tcpdump/print-esp.c @@ -22,8 +22,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.20.4.2 2002/02/22 09:26:27 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.44.2.4 2003/11/19 05:36:40 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -31,22 +31,14 @@ static const char rcsid[] = #endif #include <string.h> -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <stdlib.h> -#include <netinet/in.h> +#include <tcpdump-stdinc.h> + +#include <stdlib.h> #ifdef HAVE_LIBCRYPTO -#include <openssl/des.h> -#include <openssl/blowfish.h> -#ifdef HAVE_RC5_H -#include <openssl/rc5.h> -#endif -#ifdef HAVE_CAST_H -#include <openssl/cast.h> +#ifdef HAVE_OPENSSL_EVP_H +#include <openssl/evp.h> #endif #endif @@ -58,53 +50,71 @@ static const char rcsid[] = #include "ip6.h" #endif -#define AVOID_CHURN 1 +#if defined(__MINGW32__) || defined(__WATCOMC__) +extern char *strsep(char **stringp, const char *delim); /* Missing/strsep.c */ +#endif + #include "interface.h" #include "addrtoname.h" +#include "extract.h" -static struct esp_algorithm *espsecret_xform=NULL; /* cache of decoded alg. */ -static char *espsecret_key=NULL; +#ifndef HAVE_SOCKADDR_STORAGE +#ifdef INET6 +struct sockaddr_storage { + union { + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + } un; +}; +#else +#define sockaddr_storage sockaddr +#endif +#endif /* HAVE_SOCKADDR_STORAGE */ + +#ifdef HAVE_LIBCRYPTO +struct sa_list { + struct sa_list *next; + struct sockaddr_storage daddr; + u_int32_t spi; + const EVP_CIPHER *evp; + int ivlen; + int authlen; + char secret[256]; /* is that big enough for all secrets? */ + int secretlen; +}; +static struct sa_list *sa_list_head = NULL; +static struct sa_list *sa_default = NULL; -enum cipher { NONE, - DESCBC, - BLOWFISH, - RC5, - CAST128, - DES3CBC}; +static void esp_print_addsa(struct sa_list *sa, int sa_def) +{ + /* copy the "sa" */ + struct sa_list *nsa; + nsa = (struct sa_list *)malloc(sizeof(struct sa_list)); + if (nsa == NULL) + error("ran out of memory to allocate sa structure"); -struct esp_algorithm { - char *name; - enum cipher algo; - int ivlen; - int authlen; - int replaysize; -}; + *nsa = *sa; + + if (sa_def) + sa_default = nsa; + + nsa->next = sa_list_head; + sa_list_head = nsa; +} -struct esp_algorithm esp_xforms[]={ - {"none", NONE, 0, 0, 0}, - {"des-cbc", DESCBC, 8, 0, 0}, - {"des-cbc-hmac96", DESCBC, 8, 12, 4}, - {"blowfish-cbc", BLOWFISH,8, 0, 0}, - {"blowfish-cbc-hmac96", BLOWFISH,8, 12, 4}, - {"rc5-cbc", RC5, 8, 0, 0}, - {"rc5-cbc-hmac96", RC5, 8, 12, 4}, - {"cast128-cbc", CAST128, 8, 0, 0}, - {"cast128-cbc-hmac96", CAST128, 8, 12, 4}, - {"3des-cbc-hmac96", DES3CBC, 8, 12, 4}, -}; static int hexdigit(char hex) { - if(hex >= '0' && hex <= '9') { + if (hex >= '0' && hex <= '9') return (hex - '0'); - } else if(hex >= 'A' && hex <= 'F') { + else if (hex >= 'A' && hex <= 'F') return (hex - 'A' + 10); - } else if(hex >= 'a' && hex <= 'f') { + else if (hex >= 'a' && hex <= 'f') return (hex - 'a' + 10); - } else { + else { printf("invalid hex digit %c in espsecret\n", hex); return 0; } @@ -114,79 +124,236 @@ static int hex2byte(char *hexstring) { int byte; - byte = (hexdigit(hexstring[0]) << 4) + - hexdigit(hexstring[1]); + byte = (hexdigit(hexstring[0]) << 4) + hexdigit(hexstring[1]); return byte; } - -static void esp_print_decodesecret(void) +/* + * decode the form: SPINUM@IP <tab> ALGONAME:0xsecret + * + * special form: file /name + * causes us to go read from this file instead. + * + */ +static void esp_print_decode_onesecret(char *line) { - char *colon; - int len, i; - struct esp_algorithm *xf; + struct sa_list sa1; + int sa_def; + + char *spikey; + char *decode; + + spikey = strsep(&line, " \t"); + sa_def = 0; + memset(&sa1, 0, sizeof(struct sa_list)); + + /* if there is only one token, then it is an algo:key token */ + if (line == NULL) { + decode = spikey; + spikey = NULL; + /* memset(&sa1.daddr, 0, sizeof(sa1.daddr)); */ + /* sa1.spi = 0; */ + sa_def = 1; + } else + decode = line; + + if (spikey && strcasecmp(spikey, "file") == 0) { + /* open file and read it */ + FILE *secretfile; + char fileline[1024]; + char *nl; + + secretfile = fopen(line, FOPEN_READ_TXT); + if (secretfile == NULL) { + perror(line); + exit(3); + } - if(espsecret == NULL) { - /* set to NONE transform */ - espsecret_xform = esp_xforms; - return; - } + while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) { + /* remove newline from the line */ + nl = strchr(fileline, '\n'); + if (nl) + *nl = '\0'; + if (fileline[0] == '#') continue; + if (fileline[0] == '\0') continue; + + esp_print_decode_onesecret(fileline); + } + fclose(secretfile); - if(espsecret_key != NULL) { return; } - colon = strchr(espsecret, ':'); - if(colon == NULL) { - printf("failed to decode espsecret: %s\n", - espsecret); - /* set to NONE transform */ - espsecret_xform = esp_xforms; - } + if (spikey) { + char *spistr, *foo; + u_int32_t spino; + struct sockaddr_in *sin; +#ifdef INET6 + struct sockaddr_in6 *sin6; +#endif - len = colon - espsecret; - xf = esp_xforms; - while(xf->name && strncasecmp(espsecret, xf->name, len)!=0) { - xf++; - } - if(xf->name == NULL) { - printf("failed to find cipher algo %s\n", - espsecret); - espsecret_xform = esp_xforms; - return; + spistr = strsep(&spikey, "@"); + + spino = strtoul(spistr, &foo, 0); + if (spistr == foo || !spikey) { + printf("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; + if (inet_pton(AF_INET6, spikey, &sin6->sin6_addr) == 1) { +#ifdef HAVE_SOCKADDR_SA_LEN + sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif + sin6->sin6_family = AF_INET6; + } else +#endif + if (inet_pton(AF_INET, spikey, &sin->sin_addr) == 1) { +#ifdef HAVE_SOCKADDR_SA_LEN + sin->sin_len = sizeof(struct sockaddr_in); +#endif + sin->sin_family = AF_INET; + } else { + printf("print_esp: can not decode IP# %s\n", spikey); + return; + } } - espsecret_xform = xf; - - colon++; - if(colon[0]=='0' && colon[1]=='x') { - /* decode some hex! */ - colon+=2; - len = strlen(colon) / 2; - espsecret_key = (char *)malloc(len); - if(espsecret_key == NULL) { - fprintf(stderr, "%s: ran out of memory (%d) to allocate secret key\n", - program_name, len); - exit(2); + + if (decode) { + char *colon, *p; + char espsecret_key[256]; + int len; + size_t i; + const EVP_CIPHER *evp; + int ivlen = 8; + int authlen = 0; + + /* skip any blank spaces */ + while (isspace((unsigned char)*decode)) + decode++; + + colon = strchr(decode, ':'); + if (colon == NULL) { + printf("failed to decode espsecret: %s\n", decode); + 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; } - i = 0; - while(colon[0] != '\0' && colon[1]!='\0') { - espsecret_key[i]=hex2byte(colon); - colon+=2; - i++; + 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) { + printf("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 = ivlen; + + colon++; + if (colon[0] == '0' && colon[1] == 'x') { + /* decode some hex! */ + colon += 2; + len = strlen(colon) / 2; + + if (len > 256) { + printf("secret is too big: %d\n", len); + return; + } + + i = 0; + while (colon[0] != '\0' && colon[1]!='\0') { + espsecret_key[i] = hex2byte(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); + } } - } else { - espsecret_key = colon; } + + esp_print_addsa(&sa1, sa_def); } +static void esp_print_decodesecret(void) +{ + char *line; + char *p; + + p = espsecret; + + while (espsecret && espsecret[0] != '\0') { + /* pick out the first line or first thing until a comma */ + if ((line = strsep(&espsecret, "\n,")) == NULL) { + line = espsecret; + espsecret = NULL; + } + + esp_print_decode_onesecret(line); + } +} + +static void esp_init(void) +{ + + OpenSSL_add_all_algorithms(); + EVP_add_cipher_alias(SN_des_ede3_cbc, "3des"); +} +#endif + int -esp_print(register const u_char *bp, register const u_char *bp2, - int *nhdr, int *padlen) +esp_print(const u_char *bp, const u_char *bp2 +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + , + int *nhdr +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + , + int *padlen +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + ) { - register const struct esp *esp; + register const struct newesp *esp; register const u_char *ep; - u_int32_t spi; - struct ip *ip = NULL; +#ifdef HAVE_LIBCRYPTO + struct ip *ip; + struct sa_list *sa = NULL; + int espsecret_keylen; #ifdef INET6 struct ip6_hdr *ip6 = NULL; #endif @@ -195,11 +362,23 @@ esp_print(register const u_char *bp, register const u_char *bp2, char *secret; int ivlen = 0; u_char *ivoff; - u_char *p; - - esp = (struct esp *)bp; - spi = (u_int32_t)ntohl(esp->esp_spi); + const u_char *p; + EVP_CIPHER_CTX ctx; + int blocksz; + static int initialized = 0; +#endif + + esp = (struct newesp *)bp; + +#ifdef HAVE_LIBCRYPTO secret = NULL; + advance = 0; + + if (!initialized) { + esp_init(); + initialized = 1; + } +#endif #if 0 /* keep secret out of a register */ @@ -209,187 +388,109 @@ esp_print(register const u_char *bp, register const u_char *bp2, /* 'ep' points to the end of available data. */ ep = snapend; - if ((u_char *)(esp + 1) >= ep - sizeof(struct esp)) { + if ((u_char *)(esp + 1) >= ep) { fputs("[|ESP]", stdout); goto fail; } - printf("ESP(spi=0x%08x", spi); - printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(esp + 1))); + printf("ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi)); + printf(",seq=0x%x", EXTRACT_32BITS(&esp->esp_seq)); printf(")"); - /* if we don't have decryption key, we can't decrypt this packet. */ - if (!espsecret) - goto fail; +#ifndef HAVE_LIBCRYPTO + goto fail; +#else + /* initiailize SAs */ + if (sa_list_head == NULL) { + if (!espsecret) + goto fail; - if(!espsecret_xform) { esp_print_decodesecret(); } - if(espsecret_xform->algo == NONE) { + + if (sa_list_head == NULL) goto fail; - } ip = (struct ip *)bp2; switch (IP_V(ip)) { #ifdef INET6 case 6: ip6 = (struct ip6_hdr *)bp2; - ip = NULL; /* we do not attempt to decrypt jumbograms */ - if (!ntohs(ip6->ip6_plen)) + if (!EXTRACT_16BITS(&ip6->ip6_plen)) goto fail; /* if we can't get nexthdr, we do not need to decrypt it */ - len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen); + len = sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen); + + /* see if we can find the SA, and if so, decode it */ + for (sa = sa_list_head; sa != NULL; sa = sa->next) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa->daddr; + if (sa->spi == ntohl(esp->esp_spi) && + sin6->sin6_family == AF_INET6 && + memcmp(&sin6->sin6_addr, &ip6->ip6_dst, + sizeof(struct in6_addr)) == 0) { + break; + } + } break; #endif /*INET6*/ case 4: /* nexthdr & padding are in the last fragment */ - if (ntohs(ip->ip_off) & IP_MF) + if (EXTRACT_16BITS(&ip->ip_off) & IP_MF) goto fail; -#ifdef INET6 - ip6 = NULL; -#endif - len = ntohs(ip->ip_len); + len = EXTRACT_16BITS(&ip->ip_len); + + /* see if we can find the SA, and if so, decode it */ + for (sa = sa_list_head; sa != NULL; sa = sa->next) { + struct sockaddr_in *sin = (struct sockaddr_in *)&sa->daddr; + if (sa->spi == ntohl(esp->esp_spi) && + sin->sin_family == AF_INET && + sin->sin_addr.s_addr == ip->ip_dst.s_addr) { + break; + } + } break; default: goto fail; } - /* if we can't get nexthdr, we do not need to decrypt it */ - if (ep - bp2 < len) - goto fail; - - ivoff = (u_char *)(esp + 1) + espsecret_xform->replaysize; - ivlen = espsecret_xform->ivlen; - secret = espsecret_key; - - switch (espsecret_xform->algo) { - case DESCBC: -#ifdef HAVE_LIBCRYPTO - { - u_char iv[8]; - des_key_schedule schedule; - - switch (ivlen) { - case 4: - memcpy(iv, ivoff, 4); - memcpy(&iv[4], ivoff, 4); - p = &iv[4]; - *p++ ^= 0xff; - *p++ ^= 0xff; - *p++ ^= 0xff; - *p++ ^= 0xff; - break; - case 8: - memcpy(iv, ivoff, 8); - break; - default: - goto fail; - } - - des_check_key = 0; - des_set_key((void *)secret, schedule); - - p = ivoff + ivlen; - des_cbc_encrypt((void *)p, (void *)p, - (long)(ep - p), schedule, (void *)iv, - DES_DECRYPT); - advance = ivoff - (u_char *)esp + ivlen; - break; - } -#else - goto fail; -#endif /*HAVE_LIBCRYPTO*/ - - case BLOWFISH: -#ifdef HAVE_LIBCRYPTO - { - BF_KEY schedule; - - BF_set_key(&schedule, strlen(secret), secret); - - p = ivoff + ivlen; - BF_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff, - BF_DECRYPT); - advance = ivoff - (u_char *)esp + ivlen; - break; - } -#else + /* if we didn't find the specific one, then look for + * an unspecified one. + */ + if (sa == NULL) + sa = sa_default; + + /* if not found fail */ + if (sa == NULL) goto fail; -#endif /*HAVE_LIBCRYPTO*/ - case RC5: -#if defined(HAVE_LIBCRYPTO) && defined(HAVE_RC5_H) - { - RC5_32_KEY schedule; - - RC5_32_set_key(&schedule, strlen(secret), secret, - RC5_16_ROUNDS); - - p = ivoff + ivlen; - RC5_32_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff, - RC5_DECRYPT); - advance = ivoff - (u_char *)esp + ivlen; - break; - } -#else + /* if we can't get nexthdr, we do not need to decrypt it */ + if (ep - bp2 < len) goto fail; -#endif /*HAVE_LIBCRYPTO*/ + if (ep - bp2 > len) { + /* FCS included at end of frame (NetBSD 1.6 or later) */ + ep = bp2 + len; + } - case CAST128: -#if defined(HAVE_LIBCRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128) - { - CAST_KEY schedule; + ivoff = (u_char *)(esp + 1) + 0; + ivlen = sa->ivlen; + secret = sa->secret; + espsecret_keylen = sa->secretlen; - CAST_set_key(&schedule, strlen(secret), secret); + if (sa->evp) { + memset(&ctx, 0, sizeof(ctx)); + if (EVP_CipherInit(&ctx, sa->evp, secret, NULL, 0) < 0) + printf("espkey init failed"); - p = ivoff + ivlen; - CAST_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff, - CAST_DECRYPT); - advance = ivoff - (u_char *)esp + ivlen; - break; - } -#else - goto fail; -#endif /*HAVE_LIBCRYPTO*/ - - case DES3CBC: -#if defined(HAVE_LIBCRYPTO) - { - des_key_schedule s1, s2, s3; - - des_check_key = 1; - des_set_odd_parity((void *)secret); - des_set_odd_parity((void *)(secret + 8)); - des_set_odd_parity((void *)(secret + 16)); - if(des_set_key((void *)secret, s1) != 0) { - printf("failed to schedule key 1\n"); - } - if(des_set_key((void *)(secret + 8), s2)!=0) { - printf("failed to schedule key 2\n"); - } - if(des_set_key((void *)(secret + 16), s3)!=0) { - printf("failed to schedule key 3\n"); - } + blocksz = EVP_CIPHER_CTX_block_size(&ctx); - p = ivoff + ivlen; - des_ede3_cbc_encrypt((void *)p, (void *)p, - (long)(ep - p), - s1, s2, s3, - (void *)ivoff, DES_DECRYPT); + p = ivoff; + EVP_CipherInit(&ctx, NULL, NULL, p, 0); + EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen)); advance = ivoff - (u_char *)esp + ivlen; - break; - } -#else - goto fail; -#endif /*HAVE_LIBCRYPTO*/ - - case NONE: - default: - advance = sizeof(struct esp) + espsecret_xform->replaysize; - break; - } + } else + advance = sizeof(struct newesp); - ep = ep - espsecret_xform->authlen; + ep = ep - sa->authlen; /* sanity check for pad length */ if (ep - bp < *(ep - 2)) goto fail; @@ -402,9 +503,8 @@ esp_print(register const u_char *bp, register const u_char *bp2, printf(": "); return advance; +#endif fail: - if (nhdr) - *nhdr = -1; - return 65536; + return -1; } diff --git a/contrib/tcpdump/print-frag6.c b/contrib/tcpdump/print-frag6.c index 4553505..2356efb 100644 --- a/contrib/tcpdump/print-frag6.c +++ b/contrib/tcpdump/print-frag6.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.13 2001/09/17 21:58:02 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.16.2.3 2003/11/19 00:35:43 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -30,13 +30,7 @@ static const char rcsid[] = #ifdef INET6 -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> - - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> @@ -44,6 +38,7 @@ static const char rcsid[] = #include "interface.h" #include "addrtoname.h" +#include "extract.h" int frag6_print(register const u_char *bp, register const u_char *bp2) @@ -62,21 +57,21 @@ frag6_print(register const u_char *bp, register const u_char *bp2) if (vflag) { printf("frag (0x%08x:%d|%ld)", - (u_int32_t)ntohl(dp->ip6f_ident), - ntohs(dp->ip6f_offlg & IP6F_OFF_MASK), - sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) - + EXTRACT_32BITS(&dp->ip6f_ident), + EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK, + sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) - (long)(bp - bp2) - sizeof(struct ip6_frag)); } else { printf("frag (%d|%ld)", - ntohs(dp->ip6f_offlg & IP6F_OFF_MASK), - sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) - + EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK, + sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) - (long)(bp - bp2) - sizeof(struct ip6_frag)); } #if 1 /* it is meaningless to decode non-first fragment */ - if (ntohs(dp->ip6f_offlg & IP6F_OFF_MASK) != 0) - return 65535; + if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0) + return -1; else #endif { @@ -85,7 +80,7 @@ frag6_print(register const u_char *bp, register const u_char *bp2) } trunc: fputs("[|frag]", stdout); - return 65535; + return -1; #undef TCHECK } #endif /* INET6 */ diff --git a/contrib/tcpdump/print-gre.c b/contrib/tcpdump/print-gre.c index 01afb90..8657b58 100644 --- a/contrib/tcpdump/print-gre.c +++ b/contrib/tcpdump/print-gre.c @@ -1,175 +1,373 @@ +/* $OpenBSD: print-gre.c,v 1.6 2002/10/30 03:04:04 fgsch Exp $ */ + /* - * Copyright (c) 1996 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Lawrence Berkeley Laboratory, - * Berkeley, CA. The name of the University may not be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * Copyright (c) 2002 Jason L. Wright (jason@thought.net) + * All rights reserved. * - * Initial contribution from John Hawkinson <jhawk@bbnplanet.com> + * 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 Jason L. Wright + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. * - * This module implements support for decoding GRE (Generic Routing - * Encapsulation) tunnels; they're documented in RFC1701 and RFC1702. - * This code only supports the IP encapsulation thereof. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * tcpdump filter for GRE - Generic Routing Encapsulation + * RFC1701 (GRE), RFC1702 (GRE IPv4), and RFC2637 (Enhanced GRE) */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.13.4.1 2002/06/01 23:51:13 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.22.2.2 2003/11/16 08:51:24 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> -#include <netdb.h> #include <stdio.h> +#include <string.h> #include "interface.h" #include "addrtoname.h" -#include "extract.h" /* must come after interface.h */ +#include "extract.h" -struct gre { - u_int16_t flags; - u_int16_t proto; -}; +#include "ip.h" -/* RFC 2784 - GRE */ -#define GRE_CP 0x8000 /* Checksum Present */ -#define GRE_VER_MASK 0x0007 /* Version */ +#define GRE_CP 0x8000 /* checksum present */ +#define GRE_RP 0x4000 /* routing present */ +#define GRE_KP 0x2000 /* key present */ +#define GRE_SP 0x1000 /* sequence# present */ +#define GRE_sP 0x0800 /* source routing */ +#define GRE_RECRS 0x0700 /* recursion count */ +#define GRE_AP 0x0080 /* acknowledgment# present */ +#define GRE_VERS 0x0007 /* protocol version */ -/* RFC 2890 - Key and Sequence extensions to GRE */ -#define GRE_KP 0x2000 /* Key Present */ -#define GRE_SP 0x1000 /* Sequence Present */ +#define GREPROTO_IP 0x0800 /* IP */ +#define GREPROTO_PPP 0x880b /* PPTP */ +#define GREPROTO_ISO 0x00fe /* OSI */ -/* Legacy from RFC 1700 */ -#define GRE_RP 0x4000 /* Routing Present */ -#define GRE_sP 0x0800 /* strict source route present */ -#define GRE_RECUR_MASK 0x0700 /* Recursion Control */ -#define GRE_RECUR_SHIFT 8 +/* source route entry types */ +#define GRESRE_IP 0x0800 /* IP */ +#define GRESRE_ASN 0xfffe /* ASN */ -#define GRE_COP (GRE_RP|GRE_CP) /* Checksum & Offset Present */ +void gre_print_0(const u_char *, u_int); +void gre_print_1(const u_char *, u_int); +void gre_sre_print(u_int16_t, u_int8_t, u_int8_t, const u_char *, u_int); +void gre_sre_ip_print(u_int8_t, u_int8_t, const u_char *, u_int); +void gre_sre_asn_print(u_int8_t, u_int8_t, const u_char *, u_int); -/* "Enhanced GRE" from RFC2637 - PPTP */ -#define GRE_AP 0x0080 /* Ack present */ +void +gre_print(const u_char *bp, u_int length) +{ + u_int len = length, vers; -#define GRE_MBZ_MASK 0x0078 /* not defined */ + if (len < 2) { + printf("[|gre]"); + return; + } + vers = EXTRACT_16BITS(bp) & 7; + + if (vers == 0) + gre_print_0(bp, len); + else if (vers == 1) + gre_print_1(bp, len); + else + printf("gre-unknown-version=%u", vers); + return; + +} -/* - * Deencapsulate and print a GRE-tunneled IP datagram - */ void -gre_print(const u_char *bp, u_int length) +gre_print_0(const u_char *bp, u_int length) { - const u_char *cp = bp + 4; - const struct gre *gre; - u_int16_t flags, proto; - u_short ver=0; - u_short extracted_ethertype; - - gre = (const struct gre *)bp; - - TCHECK(gre->proto); - flags = EXTRACT_16BITS(&gre->flags); - proto = EXTRACT_16BITS(&gre->proto); - (void)printf("gre "); - - if (flags) { - /* Decode the flags */ - putchar('['); - if (flags & GRE_CP) - putchar('C'); - if (flags & GRE_RP) - putchar('R'); - if (flags & GRE_KP) - putchar('K'); - if (flags & GRE_SP) - putchar('S'); - if (flags & GRE_sP) - putchar('s'); - if (flags & GRE_AP) - putchar('A'); - if (flags & GRE_RECUR_MASK) - printf("R%x", (flags & GRE_RECUR_MASK) >> GRE_RECUR_SHIFT); - ver = flags & GRE_VER_MASK; - printf("v%u", ver); - - if (flags & GRE_MBZ_MASK) - printf("!%x", flags & GRE_MBZ_MASK); - fputs("] ", stdout); - } - - if (flags & GRE_COP) { - int checksum, offset; - - TCHECK2(*cp, 4); - checksum = EXTRACT_16BITS(cp); - offset = EXTRACT_16BITS(cp + 2); - - if (flags & GRE_CP) { - /* Checksum present */ - - /* todo: check checksum */ - if (vflag > 1) - printf("C:%04x ", checksum); - } - if (flags & GRE_RP) { - /* Offset present */ + u_int len = length; + u_int16_t flags, prot; - if (vflag > 1) - printf("O:%04x ", offset); - } - cp += 4; /* skip checksum and offset */ + flags = EXTRACT_16BITS(bp); + if (vflag) { + printf("[%s%s%s%s%s] ", + (flags & GRE_CP) ? "C" : "", + (flags & GRE_RP) ? "R" : "", + (flags & GRE_KP) ? "K" : "", + (flags & GRE_SP) ? "S" : "", + (flags & GRE_sP) ? "s" : ""); + } + + len -= 2; + bp += 2; + + if (len < 2) + goto trunc; + prot = EXTRACT_16BITS(bp); + len -= 2; + bp += 2; + + if ((flags & GRE_CP) | (flags & GRE_RP)) { + if (len < 2) + goto trunc; + if (vflag) + printf("sum 0x%x ", EXTRACT_16BITS(bp)); + bp += 2; + len -= 2; + + if (len < 2) + goto trunc; + printf("off 0x%x ", EXTRACT_16BITS(bp)); + bp += 2; + len -= 2; } + if (flags & GRE_KP) { - TCHECK2(*cp, 4); - if (ver == 1) { /* PPTP */ - if (vflag > 1) - printf("PL:%u ", EXTRACT_16BITS(cp)); - printf("ID:%04x ", EXTRACT_16BITS(cp+2)); - } - else - printf("K:%08x ", EXTRACT_32BITS(cp)); - cp += 4; /* skip key */ + if (len < 4) + goto trunc; + printf("key=0x%x ", EXTRACT_32BITS(bp)); + bp += 4; + len -= 4; } + if (flags & GRE_SP) { - TCHECK2(*cp, 4); - printf("S:%u ", EXTRACT_32BITS(cp)); - cp += 4; /* skip seq */ + if (len < 4) + goto trunc; + printf("seq %u ", EXTRACT_32BITS(bp)); + bp += 4; + len -= 4; + } + + if (flags & GRE_RP) { + for (;;) { + u_int16_t af; + u_int8_t sreoff; + u_int8_t srelen; + + if (len < 4) + goto trunc; + af = EXTRACT_16BITS(bp); + sreoff = *(bp + 2); + srelen = *(bp + 3); + bp += 4; + len -= 4; + + if (af == 0 && srelen == 0) + break; + + gre_sre_print(af, sreoff, srelen, bp, len); + + if (len < srelen) + goto trunc; + bp += srelen; + len -= srelen; + } + } + + switch (prot) { + case GREPROTO_IP: + ip_print(bp, len); + break; + case GREPROTO_ISO: + isoclns_print(bp, len, len); + break; + default: + printf("gre-proto-0x%x", prot); + } + return; + +trunc: + printf("[|gre]"); +} + +void +gre_print_1(const u_char *bp, u_int length) +{ + u_int len = length; + u_int16_t flags, prot; + + flags = EXTRACT_16BITS(bp); + len -= 2; + bp += 2; + + if (vflag) { + printf("[%s%s%s%s%s%s] ", + (flags & GRE_CP) ? "C" : "", + (flags & GRE_RP) ? "R" : "", + (flags & GRE_KP) ? "K" : "", + (flags & GRE_SP) ? "S" : "", + (flags & GRE_sP) ? "s" : "", + (flags & GRE_AP) ? "A" : ""); + } + + if (len < 2) + goto trunc; + prot = EXTRACT_16BITS(bp); + len -= 2; + bp += 2; + + if (flags & GRE_CP) { + printf("cpset!"); + return; + } + if (flags & GRE_RP) { + printf("rpset!"); + return; } - if (flags & GRE_AP && ver >= 1) { - TCHECK2(*cp, 4); - printf("A:%u ", EXTRACT_32BITS(cp)); - cp += 4; /* skip ack */ + if ((flags & GRE_KP) == 0) { + printf("kpunset!"); + return; } - /* We don't support routing fields (variable length) now. Punt. */ - if (flags & GRE_RP) + if (flags & GRE_sP) { + printf("spset!"); return; + } + + if (flags & GRE_KP) { + u_int32_t k; - TCHECK(cp[0]); + if (len < 4) + goto trunc; + k = EXTRACT_32BITS(bp); + printf("call %d ", k & 0xffff); + len -= 4; + bp += 4; + } + + if (flags & GRE_SP) { + if (len < 4) + goto trunc; + printf("seq %u ", EXTRACT_32BITS(bp)); + bp += 4; + len -= 4; + } + + if (flags & GRE_AP) { + if (len < 4) + goto trunc; + printf("ack %u ", EXTRACT_32BITS(bp)); + bp += 4; + len -= 4; + } - length -= cp - bp; - if (ether_encap_print(proto, cp, length, length, - &extracted_ethertype) == 0) - printf("gre-proto-0x%04X", proto); + if ((flags & GRE_SP) == 0) { + printf("no-payload"); + return; + } + + switch (prot) { + case GREPROTO_PPP: + printf("gre-ppp-payload"); + break; + default: + printf("gre-proto-0x%x", prot); + break; + } return; trunc: - fputs("[|gre]", stdout); + printf("[|gre]"); +} + +void +gre_sre_print(u_int16_t af, u_int8_t sreoff, u_int8_t srelen, + const u_char *bp, u_int len) +{ + switch (af) { + case GRESRE_IP: + printf("(rtaf=ip"); + gre_sre_ip_print(sreoff, srelen, bp, len); + printf(") "); + break; + case GRESRE_ASN: + printf("(rtaf=asn"); + gre_sre_asn_print(sreoff, srelen, bp, len); + printf(") "); + break; + default: + printf("(rtaf=0x%x) ", af); + } +} +void +gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len) +{ + struct in_addr a; + const u_char *up = bp; + if (sreoff & 3) { + printf(" badoffset=%u", sreoff); + return; + } + if (srelen & 3) { + printf(" badlength=%u", srelen); + return; + } + if (sreoff >= srelen) { + printf(" badoff/len=%u/%u", sreoff, srelen); + return; + } + + for (;;) { + if (len < 4 || srelen == 0) + return; + + memcpy(&a, bp, sizeof(a)); + printf(" %s%s", + ((bp - up) == sreoff) ? "*" : "", + inet_ntoa(a)); + + bp += 4; + len -= 4; + srelen -= 4; + } +} + +void +gre_sre_asn_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len) +{ + const u_char *up = bp; + + if (sreoff & 1) { + printf(" badoffset=%u", sreoff); + return; + } + if (srelen & 1) { + printf(" badlength=%u", srelen); + return; + } + if (sreoff >= srelen) { + printf(" badoff/len=%u/%u", sreoff, srelen); + return; + } + + for (;;) { + if (len < 2 || srelen == 0) + return; + + printf(" %s%x", + ((bp - up) == sreoff) ? "*" : "", + EXTRACT_16BITS(bp)); + + bp += 2; + len -= 2; + srelen -= 2; + } } diff --git a/contrib/tcpdump/print-hsrp.c b/contrib/tcpdump/print-hsrp.c index a7a1c82..9205038 100644 --- a/contrib/tcpdump/print-hsrp.c +++ b/contrib/tcpdump/print-hsrp.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2001 Julian Cowley * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 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 @@ -30,18 +30,17 @@ /* Cisco Hot Standby Router Protocol (HSRP). */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.2 2001/10/08 16:12:37 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.7.2.2 2003/11/16 08:51:24 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> +#include <tcpdump-stdinc.h> #include <stdio.h> -#include <netinet/in.h> #include "interface.h" #include "addrtoname.h" @@ -86,20 +85,20 @@ static struct tok states[] = { /* HSRP protocol header. */ struct hsrp { - u_char hsrp_version; - u_char hsrp_op_code; - u_char hsrp_state; - u_char hsrp_hellotime; - u_char hsrp_holdtime; - u_char hsrp_priority; - u_char hsrp_group; - u_char hsrp_reserved; - u_char hsrp_authdata[HSRP_AUTH_SIZE]; + u_int8_t hsrp_version; + u_int8_t hsrp_op_code; + u_int8_t hsrp_state; + u_int8_t hsrp_hellotime; + u_int8_t hsrp_holdtime; + u_int8_t hsrp_priority; + u_int8_t hsrp_group; + u_int8_t hsrp_reserved; + u_int8_t hsrp_authdata[HSRP_AUTH_SIZE]; struct in_addr hsrp_virtaddr; }; void -hsrp_print(register const u_char *bp, register u_int len) +hsrp_print(register const u_int8_t *bp, register u_int len) { struct hsrp *hp = (struct hsrp *) bp; @@ -119,7 +118,7 @@ hsrp_print(register const u_char *bp, register u_int len) if (hp->hsrp_reserved != 0) { printf("[reserved=%d!] ", hp->hsrp_reserved); } - TCHECK2(hp->hsrp_virtaddr, sizeof(hp->hsrp_virtaddr)); + TCHECK(hp->hsrp_virtaddr); printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr)); if (vflag) { printf(" hellotime="); diff --git a/contrib/tcpdump/print-icmp6.c b/contrib/tcpdump/print-icmp6.c index 40d71df..88580b2 100644 --- a/contrib/tcpdump/print-icmp6.c +++ b/contrib/tcpdump/print-icmp6.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.56.4.1 2002/05/31 10:08:31 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.72.2.4 2004/03/24 00:14:09 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -30,27 +30,18 @@ static const char rcsid[] = #ifdef INET6 -#include <ctype.h> - -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> - - -#include <netinet/in.h> - -#include <arpa/inet.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <string.h> -#include <netdb.h> #include "ip6.h" #include "icmp6.h" +#include "ipproto.h" #include "interface.h" #include "addrtoname.h" +#include "extract.h" #include "udp.h" #include "ah.h" @@ -58,12 +49,12 @@ static const char rcsid[] = static const char *get_rtpref(u_int); static const char *get_lifetime(u_int32_t); static void print_lladdr(const u_char *, size_t); -void icmp6_opt_print(const u_char *, int); -void mld6_print(const u_char *); -static struct udphdr *get_upperlayer(u_char *, int *); +static void icmp6_opt_print(const u_char *, int); +static void mld6_print(const u_char *); +static struct udphdr *get_upperlayer(u_char *, u_int *); static void dnsname_print(const u_char *, const u_char *); -void icmp6_nodeinfo_print(int, const u_char *, const u_char *); -void icmp6_rrenum_print(int, const u_char *, const u_char *); +static void icmp6_nodeinfo_print(u_int, const u_char *, const u_char *); +static void icmp6_rrenum_print(const u_char *, const u_char *); #ifndef abs #define abs(a) ((0 < (a)) ? (a) : -(a)) @@ -110,8 +101,51 @@ print_lladdr(const u_int8_t *p, size_t l) } } +static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp, + u_int len) +{ + size_t i; + register const u_int16_t *sp; + u_int32_t sum; + union { + struct { + struct in6_addr ph_src; + struct in6_addr ph_dst; + u_int32_t ph_len; + u_int8_t ph_zero[3]; + u_int8_t ph_nxt; + } ph; + u_int16_t pa[20]; + } phu; + + /* 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_ICMPV6; + + sum = 0; + for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) + sum += phu.pa[i]; + + sp = (const u_int16_t *)icp; + + for (i = 0; i < (len & ~1); i += 2) + sum += *sp++; + + if (len & 1) + sum += htons((*(const u_int8_t *)sp) << 8); + + while (sum > 0xffff) + sum = (sum & 0xffff) + (sum >> 16); + sum = ~sum & 0xffff; + + return (sum); +} + void -icmp6_print(const u_char *bp, const u_char *bp2) +icmp6_print(const u_char *bp, u_int length, const u_char *bp2, int fragmented) { const struct icmp6_hdr *dp; const struct ip6_hdr *ip; @@ -121,7 +155,7 @@ icmp6_print(const u_char *bp, const u_char *bp2) int dport; const u_char *ep; char buf[256]; - int icmp6len, prot; + u_int prot; dp = (struct icmp6_hdr *)bp; ip = (struct ip6_hdr *)bp2; @@ -129,13 +163,21 @@ icmp6_print(const u_char *bp, const u_char *bp2) str = buf; /* 'ep' points to the end of available data. */ ep = snapend; - if (ip->ip6_plen) - icmp6len = (ntohs(ip->ip6_plen) + sizeof(struct ip6_hdr) - - (bp - bp2)); - else /* XXX: jumbo payload case... */ - icmp6len = snapend - bp; - TCHECK(dp->icmp6_code); + TCHECK(dp->icmp6_cksum); + + if (vflag && !fragmented) { + int sum = dp->icmp6_cksum; + + if (TTEST2(bp[0], length)) { + sum = icmp6_cksum(ip, dp, length); + if (sum != 0) + (void)printf("[bad icmp6 cksum %x!] ", sum); + else + (void)printf("[icmp6 sum ok] "); + } + } + switch (dp->icmp6_type) { case ICMP6_DST_UNREACH: TCHECK(oip->ip6_dst); @@ -162,7 +204,7 @@ icmp6_print(const u_char *bp, const u_char *bp2) == NULL) goto trunc; - dport = ntohs(ouh->uh_dport); + dport = EXTRACT_16BITS(&ouh->uh_dport); switch (prot) { case IPPROTO_TCP: printf("icmp6: %s tcp port %s unreachable", @@ -190,7 +232,7 @@ icmp6_print(const u_char *bp, const u_char *bp2) break; case ICMP6_PACKET_TOO_BIG: TCHECK(dp->icmp6_mtu); - printf("icmp6: too big %u", (u_int32_t)ntohl(dp->icmp6_mtu)); + printf("icmp6: too big %u", EXTRACT_32BITS(&dp->icmp6_mtu)); break; case ICMP6_TIME_EXCEEDED: TCHECK(oip->ip6_dst); @@ -213,15 +255,15 @@ icmp6_print(const u_char *bp, const u_char *bp2) switch (dp->icmp6_code) { case ICMP6_PARAMPROB_HEADER: printf("icmp6: parameter problem errorneous - octet %u", - (u_int32_t)ntohl(dp->icmp6_pptr)); + EXTRACT_32BITS(&dp->icmp6_pptr)); break; case ICMP6_PARAMPROB_NEXTHEADER: printf("icmp6: parameter problem next header - octet %u", - (u_int32_t)ntohl(dp->icmp6_pptr)); + EXTRACT_32BITS(&dp->icmp6_pptr)); break; case ICMP6_PARAMPROB_OPTION: printf("icmp6: parameter problem option - octet %u", - (u_int32_t)ntohl(dp->icmp6_pptr)); + EXTRACT_32BITS(&dp->icmp6_pptr)); break; default: printf("icmp6: parameter problem code-#%d", @@ -230,10 +272,12 @@ icmp6_print(const u_char *bp, const u_char *bp2) } break; case ICMP6_ECHO_REQUEST: - printf("icmp6: echo request"); - break; case ICMP6_ECHO_REPLY: - printf("icmp6: echo reply"); + TCHECK(dp->icmp6_seq); + printf("icmp6: echo %s seq %u", + dp->icmp6_type == ICMP6_ECHO_REQUEST ? + "request" : "reply", + EXTRACT_16BITS(&dp->icmp6_seq)); break; case ICMP6_MEMBERSHIP_QUERY: printf("icmp6: multicast listener query "); @@ -252,7 +296,7 @@ icmp6_print(const u_char *bp, const u_char *bp2) if (vflag) { #define RTSOLLEN 8 icmp6_opt_print((const u_char *)dp + RTSOLLEN, - icmp6len - RTSOLLEN); + length - RTSOLLEN); } break; case ND_ROUTER_ADVERT: @@ -277,14 +321,14 @@ icmp6_print(const u_char *bp, const u_char *bp2) printf("pref=%s, ", get_rtpref(p->nd_ra_flags_reserved)); - printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime)); + printf("router_ltime=%d, ", EXTRACT_16BITS(&p->nd_ra_router_lifetime)); printf("reachable_time=%u, ", - (u_int32_t)ntohl(p->nd_ra_reachable)); + EXTRACT_32BITS(&p->nd_ra_reachable)); printf("retrans_time=%u)", - (u_int32_t)ntohl(p->nd_ra_retransmit)); + EXTRACT_32BITS(&p->nd_ra_retransmit)); #define RTADVLEN 16 icmp6_opt_print((const u_char *)dp + RTADVLEN, - icmp6len - RTADVLEN); + length - RTADVLEN); } break; case ND_NEIGHBOR_SOLICIT: @@ -297,7 +341,7 @@ icmp6_print(const u_char *bp, const u_char *bp2) if (vflag) { #define NDSOLLEN 24 icmp6_opt_print((const u_char *)dp + NDSOLLEN, - icmp6len - NDSOLLEN); + length - NDSOLLEN); } } break; @@ -329,7 +373,7 @@ icmp6_print(const u_char *bp, const u_char *bp2) } #define NDADVLEN 24 icmp6_opt_print((const u_char *)dp + NDADVLEN, - icmp6len - NDADVLEN); + length - NDADVLEN); #undef NDADVLEN } } @@ -339,22 +383,71 @@ icmp6_print(const u_char *bp, const u_char *bp2) TCHECK(RDR(dp)->nd_rd_dst); printf("icmp6: redirect %s", getname6((const u_char *)&RDR(dp)->nd_rd_dst)); + TCHECK(RDR(dp)->nd_rd_target); printf(" to %s", getname6((const u_char*)&RDR(dp)->nd_rd_target)); #define REDIRECTLEN 40 if (vflag) { icmp6_opt_print((const u_char *)dp + REDIRECTLEN, - icmp6len - REDIRECTLEN); + length - REDIRECTLEN); } break; #undef REDIRECTLEN #undef RDR case ICMP6_ROUTER_RENUMBERING: - icmp6_rrenum_print(icmp6len, bp, ep); + icmp6_rrenum_print(bp, ep); break; case ICMP6_NI_QUERY: case ICMP6_NI_REPLY: - icmp6_nodeinfo_print(icmp6len, bp, ep); + icmp6_nodeinfo_print(length, bp, ep); + break; + case ICMP6_HADISCOV_REQUEST: + printf("icmp6: ha discovery request"); + if (vflag) { + TCHECK(dp->icmp6_data16[0]); + printf("(id=%d)", EXTRACT_16BITS(&dp->icmp6_data16[0])); + } + break; + case ICMP6_HADISCOV_REPLY: + printf("icmp6: ha discovery reply"); + if (vflag) { + struct in6_addr *in6; + u_char *cp; + + TCHECK(dp->icmp6_data16[0]); + printf("(id=%d", EXTRACT_16BITS(&dp->icmp6_data16[0])); + cp = (u_char *)dp + length; + in6 = (struct in6_addr *)(dp + 1); + for (; (u_char *)in6 < cp; in6++) { + TCHECK(*in6); + printf(", %s", ip6addr_string(in6)); + } + printf(")"); + } + break; + case ICMP6_MOBILEPREFIX_SOLICIT: + printf("icmp6: mobile router solicitation"); + if (vflag) { + TCHECK(dp->icmp6_data16[0]); + printf("(id=%d)", EXTRACT_16BITS(&dp->icmp6_data16[0])); + } + break; + case ICMP6_MOBILEPREFIX_ADVERT: + printf("icmp6: mobile router advertisement"); + if (vflag) { + TCHECK(dp->icmp6_data16[0]); + printf("(id=%d", EXTRACT_16BITS(&dp->icmp6_data16[0])); + if (dp->icmp6_data16[1] & 0xc0) + printf(" "); + if (dp->icmp6_data16[1] & 0x80) + printf("M"); + if (dp->icmp6_data16[1] & 0x40) + printf("O"); + printf(")"); +#define MPADVLEN 8 + icmp6_opt_print((const u_char *)dp + MPADVLEN, + length - MPADVLEN); + } break; default: printf("icmp6: type-#%d", dp->icmp6_type); @@ -366,7 +459,7 @@ trunc: } static struct udphdr * -get_upperlayer(u_char *bp, int *prot) +get_upperlayer(u_char *bp, u_int *prot) { const u_char *ep; struct ip6_hdr *ip6 = (struct ip6_hdr *)bp; @@ -374,12 +467,13 @@ get_upperlayer(u_char *bp, int *prot) struct ip6_hbh *hbh; struct ip6_frag *fragh; struct ah *ah; - int nh, hlen; + u_int nh; + int hlen; /* 'ep' points to the end of available data. */ ep = snapend; - if (TTEST(ip6->ip6_nxt) == 0) + if (!TTEST(ip6->ip6_nxt)) return NULL; nh = ip6->ip6_nxt; @@ -404,7 +498,7 @@ get_upperlayer(u_char *bp, int *prot) case IPPROTO_DSTOPTS: case IPPROTO_ROUTING: hbh = (struct ip6_hbh *)bp; - if (TTEST(hbh->ip6h_len) == 0) + if (!TTEST(hbh->ip6h_len)) return(NULL); nh = hbh->ip6h_nxt; hlen = (hbh->ip6h_len + 1) << 3; @@ -412,10 +506,10 @@ get_upperlayer(u_char *bp, int *prot) case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */ fragh = (struct ip6_frag *)bp; - if (TTEST(fragh->ip6f_offlg) == 0) + if (!TTEST(fragh->ip6f_offlg)) return(NULL); /* fragments with non-zero offset are meaningless */ - if ((fragh->ip6f_offlg & IP6F_OFF_MASK) != 0) + if ((EXTRACT_16BITS(&fragh->ip6f_offlg) & IP6F_OFF_MASK) != 0) return(NULL); nh = fragh->ip6f_nxt; hlen = sizeof(struct ip6_frag); @@ -423,7 +517,7 @@ get_upperlayer(u_char *bp, int *prot) case IPPROTO_AH: ah = (struct ah *)bp; - if (TTEST(ah->ah_len) == 0) + if (!TTEST(ah->ah_len)) return(NULL); nh = ah->ah_nxt; hlen = (ah->ah_len + 2) << 2; @@ -438,7 +532,7 @@ get_upperlayer(u_char *bp, int *prot) return(NULL); /* should be notreached, though */ } -void +static void icmp6_opt_print(const u_char *bp, int resid) { const struct nd_opt_hdr *op; @@ -447,6 +541,7 @@ icmp6_opt_print(const u_char *bp, int resid) const struct icmp6_opts_redirect *opr; const struct nd_opt_mtu *opm; 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; @@ -505,9 +600,9 @@ icmp6_opt_print(const u_char *bp, int resid) if (opp->nd_opt_pi_flags_reserved) printf(" "); printf("valid_ltime=%s,", - get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_valid_time))); + get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time))); printf("preferred_ltime=%s,", - get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time))); + get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time))); printf("prefix=%s/%d", ip6addr_string(&opp->nd_opt_pi_prefix), opp->nd_opt_pi_prefix_len); @@ -531,7 +626,7 @@ icmp6_opt_print(const u_char *bp, int resid) printf(")"); break; } - printf(" mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu)); + printf(" mtu=%u", EXTRACT_32BITS(&opm->nd_opt_mtu_mtu)); if (opm->nd_opt_mtu_len != 1) printf("!"); printf(")"); @@ -541,10 +636,18 @@ icmp6_opt_print(const u_char *bp, int resid) TCHECK(opa->nd_opt_adv_interval); printf("(advint:"); /*)*/ printf(" advint=%u", - (u_int32_t)ntohl(opa->nd_opt_adv_interval)); + EXTRACT_32BITS(&opa->nd_opt_adv_interval)); /*(*/ printf(")"); - break; + break; + case ND_OPT_HOMEAGENT_INFO: + oph = (struct nd_opt_homeagent_info *)op; + TCHECK(oph->nd_opt_hai_lifetime); + printf("(ha info:"); /*)*/ + printf(" pref=%d", EXTRACT_16BITS(&oph->nd_opt_hai_preference)); + printf(", lifetime=%u", EXTRACT_16BITS(&oph->nd_opt_hai_lifetime)); + printf(")"); + break; case ND_OPT_ROUTE_INFO: opri = (struct nd_opt_route_info *)op; TCHECK(opri->nd_opt_rti_lifetime); @@ -569,7 +672,7 @@ icmp6_opt_print(const u_char *bp, int resid) opri->nd_opt_rti_prefixlen); printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags)); printf(", lifetime=%s", - get_lifetime((u_int32_t)ntohl(opri->nd_opt_rti_lifetime))); + get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime))); /*(*/ printf(")"); break; @@ -590,7 +693,7 @@ icmp6_opt_print(const u_char *bp, int resid) #undef ECHECK } -void +static void mld6_print(const u_char *bp) { struct mld6_hdr *mp = (struct mld6_hdr *)bp; @@ -602,7 +705,7 @@ mld6_print(const u_char *bp) if ((u_char *)mp + sizeof(*mp) > ep) return; - printf("max resp delay: %d ", ntohs(mp->mld6_maxdelay)); + printf("max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay)); printf("addr: %s", ip6addr_string(&mp->mld6_addr)); } @@ -642,15 +745,17 @@ dnsname_print(const u_char *cp, const u_char *ep) printf("\""); } -void -icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep) +static void +icmp6_nodeinfo_print(u_int icmp6len, const u_char *bp, const u_char *ep) { struct icmp6_nodeinfo *ni6; struct icmp6_hdr *dp; const u_char *cp; - int siz, i; + size_t siz, i; int needcomma; + if (ep < bp) + return; dp = (struct icmp6_hdr *)bp; ni6 = (struct icmp6_nodeinfo *)bp; siz = ep - bp; @@ -667,13 +772,13 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep) TCHECK2(*dp, sizeof(*ni6)); ni6 = (struct icmp6_nodeinfo *)dp; printf(" ("); /*)*/ - switch (ntohs(ni6->ni_qtype)) { + switch (EXTRACT_16BITS(&ni6->ni_qtype)) { case NI_QTYPE_NOOP: printf("noop"); break; case NI_QTYPE_SUPTYPES: printf("supported qtypes"); - i = ntohs(ni6->ni_flags); + i = EXTRACT_16BITS(&ni6->ni_flags); if (i) printf(" [%s]", (i & 0x01) ? "C" : ""); break; @@ -809,7 +914,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep) break; } - switch (ntohs(ni6->ni_qtype)) { + switch (EXTRACT_16BITS(&ni6->ni_qtype)) { case NI_QTYPE_NOOP: if (needcomma) printf(", "); @@ -822,7 +927,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep) if (needcomma) printf(", "); printf("supported qtypes"); - i = ntohs(ni6->ni_flags); + i = EXTRACT_16BITS(&ni6->ni_flags); if (i) printf(" [%s]", (i & 0x01) ? "C" : ""); break; @@ -844,7 +949,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep) printf("\""); } else dnsname_print(cp, ep); - if ((ntohs(ni6->ni_flags) & 0x01) != 0) + if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0) printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1)); break; case NI_QTYPE_NODEADDR: @@ -857,7 +962,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep) break; printf(" %s", getname6(bp + i)); i += sizeof(struct in6_addr); - printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp + i))); + printf("(%d)", (int32_t)EXTRACT_32BITS(bp + i)); i += sizeof(int32_t); } i = ni6->ni_flags; @@ -889,8 +994,8 @@ trunc: fputs("[|icmp6]", stdout); } -void -icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep) +static void +icmp6_rrenum_print(const u_char *bp, const u_char *ep) { struct icmp6_router_renum *rr6; struct icmp6_hdr *dp; @@ -901,6 +1006,8 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep) char hbuf[NI_MAXHOST]; int n; + if (ep < bp) + return; dp = (struct icmp6_hdr *)bp; rr6 = (struct icmp6_router_renum *)bp; siz = ep - bp; @@ -922,7 +1029,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep) break; } - printf(", seq=%u", (u_int32_t)ntohl(rr6->rr_seqnum)); + printf(", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum)); if (vflag) { #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "") @@ -937,7 +1044,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep) printf("seg=%u,", rr6->rr_segnum); printf("maxdelay=%u", rr6->rr_maxdelay); if (rr6->rr_reserved) - printf("rsvd=0x%x", (u_int16_t)ntohs(rr6->rr_reserved)); + printf("rsvd=0x%x", EXTRACT_16BITS(&rr6->rr_reserved)); /*[*/ printf("]"); #undef F @@ -1002,12 +1109,12 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep) printf("vltime=infty,"); else printf("vltime=%u,", - (u_int32_t)ntohl(use->rpu_vltime)); + EXTRACT_32BITS(&use->rpu_vltime)); if (~use->rpu_pltime == 0) printf("pltime=infty,"); else printf("pltime=%u,", - (u_int32_t)ntohl(use->rpu_pltime)); + EXTRACT_32BITS(&use->rpu_pltime)); } if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf, sizeof(hbuf))) diff --git a/contrib/tcpdump/print-igmp.c b/contrib/tcpdump/print-igmp.c index 3513353..717ae16 100644 --- a/contrib/tcpdump/print-igmp.c +++ b/contrib/tcpdump/print-igmp.c @@ -20,18 +20,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.5.4.1 2002/06/02 18:25:05 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.11.2.3 2003/11/19 09:41:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <string.h> @@ -50,10 +47,10 @@ static const char rcsid[] = * The packet format for a traceroute request. */ struct tr_query { - u_int tr_src; /* traceroute source */ - u_int tr_dst; /* traceroute destination */ - u_int tr_raddr; /* traceroute response address */ - u_int tr_rttlqid; /* response ttl and qid */ + u_int32_t tr_src; /* traceroute source */ + u_int32_t tr_dst; /* traceroute destination */ + u_int32_t tr_raddr; /* traceroute response address */ + u_int32_t tr_rttlqid; /* response ttl and qid */ }; #define TR_GETTTL(x) (int)(((x) >> 24) & 0xff) @@ -64,17 +61,17 @@ struct tr_query { * beginning, followed by one tr_resp for each hop taken. */ struct tr_resp { - u_int tr_qarr; /* query arrival time */ - u_int tr_inaddr; /* incoming interface address */ - u_int tr_outaddr; /* outgoing interface address */ - u_int tr_rmtaddr; /* parent address in source tree */ - u_int tr_vifin; /* input packet count on interface */ - u_int tr_vifout; /* output packet count on interface */ - u_int tr_pktcnt; /* total incoming packets for src-grp */ - u_char tr_rproto; /* routing proto deployed on router */ - u_char tr_fttl; /* ttl required to forward on outvif */ - u_char tr_smask; /* subnet mask for src addr */ - u_char tr_rflags; /* forwarding error codes */ + u_int32_t tr_qarr; /* query arrival time */ + u_int32_t tr_inaddr; /* incoming interface address */ + u_int32_t tr_outaddr; /* outgoing interface address */ + u_int32_t tr_rmtaddr; /* parent address in source tree */ + u_int32_t tr_vifin; /* input packet count on interface */ + u_int32_t tr_vifout; /* output packet count on interface */ + u_int32_t tr_pktcnt; /* total incoming packets for src-grp */ + u_int8_t tr_rproto; /* routing proto deployed on router */ + u_int8_t tr_fttl; /* ttl required to forward on outvif */ + u_int8_t tr_smask; /* subnet mask for src addr */ + u_int8_t tr_rflags; /* forwarding error codes */ }; /* defs within mtrace */ @@ -109,33 +106,51 @@ static struct tok igmpv3report2str[] = { { 0, NULL } }; -static void +static void print_mtrace(register const u_char *bp, register u_int len) { register const struct tr_query *tr = (const struct tr_query *)(bp + 8); - printf("mtrace %lu: %s to %s reply-to %s", - (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)), + TCHECK(*tr); + if (len < 8 + sizeof (struct tr_query)) { + (void)printf(" [invalid len %d]", len); + return; + } + printf("mtrace %u: %s to %s reply-to %s", + TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)), ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst), ipaddr_string(&tr->tr_raddr)); - if (IN_CLASSD(ntohl(tr->tr_raddr))) - printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid))); + if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr))) + printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))); + return; +trunc: + (void)printf("[|igmp]"); + return; } -static void +static void print_mresp(register const u_char *bp, register u_int len) { register const struct tr_query *tr = (const struct tr_query *)(bp + 8); + TCHECK(*tr); + if (len < 8 + sizeof (struct tr_query)) { + (void)printf(" [invalid len %d]", len); + return; + } printf("mresp %lu: %s to %s reply-to %s", - (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)), + (u_long)TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)), ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst), ipaddr_string(&tr->tr_raddr)); - if (IN_CLASSD(ntohl(tr->tr_raddr))) - printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid))); + if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr))) + printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))); + return; +trunc: + (void)printf("[|igmp]"); + return; } -static void +static void print_igmpv3_report(register const u_char *bp, register u_int len) { u_int group, nsrcs, ngroups; @@ -143,15 +158,15 @@ print_igmpv3_report(register const u_char *bp, register u_int len) /* Minimum len is 16, and should be a multiple of 4 */ if (len < 16 || len & 0x03) { - (void)printf(" [invalid len %d]", len); - return; + (void)printf(" [invalid len %d]", len); + return; } TCHECK2(bp[6], 2); ngroups = EXTRACT_16BITS(&bp[6]); - (void)printf(", %d group record(s)", ngroups); + (void)printf(", %d group record(s)", ngroups); if (vflag > 0) { /* Print the group records */ - group = 8; + group = 8; for (i=0; i<ngroups; i++) { if (len < group+8) { (void)printf(" [invalid number of groups]"); @@ -200,9 +215,10 @@ print_igmpv3_query(register const u_char *bp, register u_int len) (void)printf(" v3"); /* Minimum len is 12, and should be a multiple of 4 */ if (len < 12 || len & 0x03) { - (void)printf(" [invalid len %d]", len); - return; + (void)printf(" [invalid len %d]", len); + return; } + TCHECK(bp[1]); mrc = bp[1]; if (mrc < 128) { mrt = mrc; @@ -248,31 +264,35 @@ igmp_print(register const u_char *bp, register u_int len) return; } - TCHECK2(bp[0], 8); + TCHECK(bp[0]); switch (bp[0]) { case 0x11: (void)printf("igmp query"); if (len >= 12) print_igmpv3_query(bp, len); else { + TCHECK(bp[1]); if (bp[1]) { (void)printf(" v2"); if (bp[1] != 100) (void)printf(" [max resp time %d]", bp[1]); } else (void)printf(" v1"); - if (EXTRACT_32BITS(&bp[4])) + TCHECK2(bp[4], 4); + if (EXTRACT_32BITS(&bp[4])) (void)printf(" [gaddr %s]", ipaddr_string(&bp[4])); if (len != 8) (void)printf(" [len %d]", len); } break; case 0x12: + TCHECK2(bp[4], 4); (void)printf("igmp v1 report %s", ipaddr_string(&bp[4])); if (len != 8) (void)printf(" [len %d]", len); break; case 0x16: + TCHECK2(bp[4], 4); (void)printf("igmp v2 report %s", ipaddr_string(&bp[4])); break; case 0x22: diff --git a/contrib/tcpdump/print-igrp.c b/contrib/tcpdump/print-igrp.c index 19f4c83..4622a93 100644 --- a/contrib/tcpdump/print-igrp.c +++ b/contrib/tcpdump/print-igrp.c @@ -22,21 +22,16 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.16 2001/06/15 22:17:32 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.18.2.2 2003/11/16 08:51:26 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/types.h> /* concession to AIX */ -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <errno.h> #include <stdio.h> #include "interface.h" diff --git a/contrib/tcpdump/print-ip6opts.c b/contrib/tcpdump/print-ip6opts.c index 3d78a08..a6960b8 100644 --- a/contrib/tcpdump/print-ip6opts.c +++ b/contrib/tcpdump/print-ip6opts.c @@ -1,7 +1,7 @@ /* * Copyright (C) 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: @@ -13,7 +13,7 @@ * 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 @@ -32,23 +32,20 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.9 2001/05/09 02:47:26 itojun Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.14.2.3 2003/11/19 00:35:44 guy Exp $"; #endif #ifdef INET6 -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> #include <stdio.h> #include "ip6.h" #include "interface.h" #include "addrtoname.h" +#include "extract.h" /* items outside of rfc2292bis */ #ifndef IP6OPT_MINLEN @@ -64,10 +61,12 @@ static const char rcsid[] = #define IP6OPT_BU_MINLEN 10 #define IP6OPT_BA_MINLEN 13 #define IP6OPT_BR_MINLEN 2 -#define IP6SOPT_ALTCOA 0x4 -#define IP6SOPT_ALTCOA_MINLEN 18 #define IP6SOPT_UI 0x2 #define IP6SOPT_UI_MINLEN 4 +#define IP6SOPT_ALTCOA 0x3 +#define IP6SOPT_ALTCOA_MINLEN 18 +#define IP6SOPT_AUTH 0x4 +#define IP6SOPT_AUTH_MINLEN 6 static void ip6_sopt_print(const u_char *, int); @@ -100,6 +99,13 @@ ip6_sopt_print(const u_char *bp, int len) } printf(", padn"); break; + case IP6SOPT_UI: + if (len - i < IP6SOPT_UI_MINLEN) { + printf(", ui: trunc"); + goto trunc; + } + printf(", ui: 0x%04x ", EXTRACT_16BITS(&bp[i + 2])); + break; case IP6SOPT_ALTCOA: if (len - i < IP6SOPT_ALTCOA_MINLEN) { printf(", altcoa: trunc"); @@ -107,12 +113,12 @@ ip6_sopt_print(const u_char *bp, int len) } printf(", alt-CoA: %s", ip6addr_string(&bp[i+2])); break; - case IP6SOPT_UI: - if (len - i < IP6SOPT_UI_MINLEN) { - printf(", ui: trunc"); + case IP6SOPT_AUTH: + if (len - i < IP6SOPT_AUTH_MINLEN) { + printf(", auth: trunc"); goto trunc; } - printf("(ui: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2])); + printf(", auth spi: 0x%08x", EXTRACT_32BITS(&bp[i + 2])); break; default: if (len - i < IP6OPT_MINLEN) { @@ -133,7 +139,7 @@ void ip6_opt_print(const u_char *bp, int len) { int i; - int optlen; + int optlen = 0; for (i = 0; i < len; i += optlen) { if (bp[i] == IP6OPT_PAD1) @@ -167,7 +173,7 @@ ip6_opt_print(const u_char *bp, int len) printf("(rtalert: invalid len %d)", bp[i + 1]); goto trunc; } - printf("(rtalert: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2])); + printf("(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2])); break; case IP6OPT_JUMBO: if (len - i < IP6OPT_JUMBO_LEN) { @@ -178,7 +184,7 @@ ip6_opt_print(const u_char *bp, int len) printf("(jumbo: invalid len %d)", bp[i + 1]); goto trunc; } - printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 2])); + printf("(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2])); break; case IP6OPT_HOME_ADDRESS: if (len - i < IP6OPT_HOMEADDR_MINLEN) { @@ -211,16 +217,13 @@ ip6_opt_print(const u_char *bp, int len) if (bp[i + 2] & 0x40) printf("H"); if (bp[i + 2] & 0x20) - printf("R"); + printf("S"); if (bp[i + 2] & 0x10) printf("D"); - if (bp[i + 2] & 0x0f) + if ((bp[i + 2] & 0x0f) || bp[i + 3] || bp[i + 4]) printf("res"); - printf(", prefixlen: %u", bp[i + 3]); - printf(", sequence: %u", - (u_int16_t)ntohs(*(u_int16_t *)&bp[i + 4])); - printf(", lifetime: %u", - (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 8])); + printf(", sequence: %u", bp[i + 5]); + printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 6])); if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) { ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN], @@ -239,12 +242,11 @@ ip6_opt_print(const u_char *bp, int len) } printf("(ba: "); printf("status: %u", bp[i + 2]); - printf(", sequence: %u", - (u_int16_t)ntohs(*(u_int16_t *)&bp[i + 3])); - printf(", lifetime: %u", - (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 7])); - printf(", refresh: %u", - (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 11])); + if (bp[i + 3]) + printf("res"); + printf(", sequence: %u", bp[i + 4]); + printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 5])); + printf(", refresh: %u", EXTRACT_32BITS(&bp[i + 9])); if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) { ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN], @@ -303,7 +305,7 @@ hbhopt_print(register const u_char *bp) trunc: fputs("[|HBH]", stdout); - return(hbhlen); + return(-1); } int @@ -328,6 +330,6 @@ dstopt_print(register const u_char *bp) trunc: fputs("[|DSTOPT]", stdout); - return(dstoptlen); + return(-1); } #endif /* INET6 */ diff --git a/contrib/tcpdump/print-ipcomp.c b/contrib/tcpdump/print-ipcomp.c index 9975e54..7a3c1ba 100644 --- a/contrib/tcpdump/print-ipcomp.c +++ b/contrib/tcpdump/print-ipcomp.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.13 2000/12/12 09:58:41 itojun Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.17.2.3 2003/11/19 00:35:45 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -29,12 +29,7 @@ static const char rcsid[] = #endif #include <string.h> -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> @@ -50,9 +45,10 @@ struct ipcomp { #include "interface.h" #include "addrtoname.h" +#include "extract.h" int -ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr) +ipcomp_print(register const u_char *bp, int *nhdr _U_) { register const struct ipcomp *ipcomp; register const u_char *ep; @@ -62,7 +58,7 @@ ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr) #endif ipcomp = (struct ipcomp *)bp; - cpi = (u_int16_t)ntohs(ipcomp->comp_cpi); + cpi = EXTRACT_16BITS(&ipcomp->comp_cpi); /* 'ep' points to the end of available data. */ ep = snapend; @@ -91,7 +87,5 @@ ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr) #endif fail: - if (nhdr) - *nhdr = -1; - return 65536; + return -1; } diff --git a/contrib/tcpdump/print-ipfc.c b/contrib/tcpdump/print-ipfc.c new file mode 100644 index 0000000..1262ecf --- /dev/null +++ b/contrib/tcpdump/print-ipfc.c @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.4.2.2 2003/11/16 08:51:28 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ethertype.h" + +#include "ether.h" +#include "ipfc.h" + +/* + * RFC 2625 IP-over-Fibre Channel. + */ + +/* Extract src, dst addresses */ +static inline void +extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc, + char *ipfcdst) +{ + /* + * We assume that, as per RFC 2625, the lower 48 bits of the + * source and destination addresses are MAC addresses. + */ + memcpy(ipfcdst, (const char *)&ipfcp->ipfc_dhost[2], 6); + memcpy(ipfcsrc, (const char *)&ipfcp->ipfc_shost[2], 6); +} + +/* + * Print the Network_Header + */ +static inline void +ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_, + register u_int length, register const u_char *ipfcsrc, + register const u_char *ipfcdst) +{ + const char *srcname, *dstname; + + srcname = etheraddr_string(ipfcsrc); + dstname = etheraddr_string(ipfcdst); + + /* + * XXX - show the upper 16 bits? Do so only if "vflag" is set? + */ + (void) printf("%s %s %d: ", srcname, dstname, length); +} + +static void +ipfc_print(const u_char *p, u_int length, u_int caplen) +{ + const struct ipfc_header *ipfcp = (const struct ipfc_header *)p; + struct ether_header ehdr; + u_short extracted_ethertype; + + if (caplen < IPFC_HDRLEN) { + printf("[|ipfc]"); + return; + } + /* + * Get the network addresses into a canonical form + */ + extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr)); + + if (eflag) + ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr)); + + /* Skip over Network_Header */ + length -= IPFC_HDRLEN; + p += IPFC_HDRLEN; + caplen -= IPFC_HDRLEN; + + /* Frame Control field determines interpretation of packet */ + extracted_ethertype = 0; + /* Try to print the LLC-layer header & higher layers */ + if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), + &extracted_ethertype) == 0) { + /* + * Some kinds of LLC packet we cannot + * handle intelligently + */ + if (!eflag) + ipfc_hdr_print(ipfcp, length + IPFC_HDRLEN, + ESRC(&ehdr), EDST(&ehdr)); + if (extracted_ethertype) { + printf("(LLC %s) ", + etherproto_string(htons(extracted_ethertype))); + } + if (!xflag && !qflag) + default_print(p, caplen); + } +} + +/* + * This is the top level routine of the printer. 'p' points + * to the Network_Header of the packet, 'h->ts' is the timestamp, + * 'h->length' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +ipfc_if_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + ipfc_print(p, h->len, h->caplen); + + return (IPFC_HDRLEN); +} diff --git a/contrib/tcpdump/print-isakmp.c b/contrib/tcpdump/print-isakmp.c index d00d575..d5caa739 100644 --- a/contrib/tcpdump/print-isakmp.c +++ b/contrib/tcpdump/print-isakmp.c @@ -1,7 +1,7 @@ /* * 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: @@ -13,7 +13,7 @@ * 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 @@ -29,24 +29,19 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.29.2.2 2003/02/26 05:58:39 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.36.2.11 2004/03/24 01:32:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <string.h> -#include <ctype.h> -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> +#include <string.h> #include <stdio.h> -#include <netdb.h> #include "isakmp.h" #include "ipsec_doi.h" @@ -64,38 +59,38 @@ static const char rcsid[] = #define sockaddr_storage sockaddr #endif -static u_char *isakmp_sa_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_p_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_t_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_ke_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_id_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_cert_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_cr_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_sig_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_hash_print(struct isakmp_gen *, u_char *, - u_int32_t, u_int32_t, u_int32_t); -static u_char *isakmp_nonce_print(struct isakmp_gen *, u_char *, - u_int32_t, u_int32_t, u_int32_t); -static u_char *isakmp_n_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_d_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_vid_print(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t); -static u_char *isakmp_sub0_print(u_char, struct isakmp_gen *, u_char *, - u_int32_t, u_int32_t, u_int32_t); -static u_char *isakmp_sub_print(u_char, struct isakmp_gen *, u_char *, - u_int32_t, u_int32_t, u_int32_t); +static const u_char *isakmp_sa_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_p_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_t_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_ke_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_id_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_cert_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_cr_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_sig_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_hash_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_nonce_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_n_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_d_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_vid_print(const struct isakmp_gen *, + u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_sub0_print(u_char, const struct isakmp_gen *, + const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *isakmp_sub_print(u_char, const struct isakmp_gen *, + const u_char *, u_int32_t, u_int32_t, u_int32_t, int); static char *numstr(int); -static void safememcpy(void *, void *, size_t); +static void safememcpy(void *, const void *, size_t); #define MAXINITIATORS 20 int ninitiator = 0; @@ -106,19 +101,19 @@ struct { } cookiecache[MAXINITIATORS]; /* protocol id */ -static char *protoidstr[] = { +static const char *protoidstr[] = { NULL, "isakmp", "ipsec-ah", "ipsec-esp", "ipcomp", }; /* isakmp->np */ -static char *npstr[] = { +static const char *npstr[] = { "none", "sa", "p", "t", "ke", "id", "cert", "cr", "hash", "sig", "nonce", "n", "d", "vid" }; /* isakmp->np */ -static u_char *(*npfunc[])(struct isakmp_gen *, u_char *, u_int32_t, - u_int32_t, u_int32_t) = { +static const u_char *(*npfunc[])(const struct isakmp_gen *, u_int, + const u_char *, u_int32_t, u_int32_t, u_int32_t, int) = { NULL, isakmp_sa_print, isakmp_p_print, @@ -136,7 +131,7 @@ static u_char *(*npfunc[])(struct isakmp_gen *, u_char *, u_int32_t, }; /* isakmp->etype */ -static char *etypestr[] = { +static const char *etypestr[] = { "none", "base", "ident", "auth", "agg", "inf", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -326,29 +321,31 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator) return 0; } -static void +static int rawprint(caddr_t loc, size_t len) { static u_char *p; - int i; + size_t i; TCHECK2(*loc, len); p = (u_char *)loc; for (i = 0; i < len; i++) printf("%02x", p[i] & 0xff); + return 1; trunc: - + return 0; } struct attrmap { - char *type; - int nvalue; - char *value[30]; /*XXX*/ + const char *type; + u_int nvalue; + const char *value[30]; /*XXX*/ }; -static u_char * -isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap) +static const u_char * +isakmp_attrmap_print(const u_char *p, const u_char *ep, + const struct attrmap *map, size_t nmap) { u_int16_t *q; int totlen; @@ -358,35 +355,35 @@ isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap) if (p[0] & 0x80) totlen = 4; else - totlen = 4 + ntohs(q[1]); + totlen = 4 + EXTRACT_16BITS(&q[1]); if (ep < p + totlen) { printf("[|attr]"); return ep + 1; } printf("("); - t = ntohs(q[0]) & 0x7fff; + t = EXTRACT_16BITS(&q[0]) & 0x7fff; if (map && t < nmap && map[t].type) printf("type=%s ", map[t].type); else printf("type=#%d ", t); if (p[0] & 0x80) { printf("value="); - v = ntohs(q[1]); + v = EXTRACT_16BITS(&q[1]); if (map && t < nmap && v < map[t].nvalue && map[t].value[v]) printf("%s", map[t].value[v]); else rawprint((caddr_t)&q[1], 2); } else { - printf("len=%d value=", ntohs(q[1])); - rawprint((caddr_t)&p[4], ntohs(q[1])); + printf("len=%d value=", EXTRACT_16BITS(&q[1])); + rawprint((caddr_t)&p[4], EXTRACT_16BITS(&q[1])); } printf(")"); return p + totlen; } -static u_char * -isakmp_attr_print(u_char *p, u_char *ep) +static const u_char * +isakmp_attr_print(const u_char *p, const u_char *ep) { u_int16_t *q; int totlen; @@ -396,40 +393,43 @@ isakmp_attr_print(u_char *p, u_char *ep) if (p[0] & 0x80) totlen = 4; else - totlen = 4 + ntohs(q[1]); + totlen = 4 + EXTRACT_16BITS(&q[1]); if (ep < p + totlen) { printf("[|attr]"); return ep + 1; } printf("("); - t = ntohs(q[0]) & 0x7fff; + t = EXTRACT_16BITS(&q[0]) & 0x7fff; printf("type=#%d ", t); if (p[0] & 0x80) { printf("value="); t = q[1]; rawprint((caddr_t)&q[1], 2); } else { - printf("len=%d value=", ntohs(q[1])); - rawprint((caddr_t)&p[2], ntohs(q[1])); + printf("len=%d value=", EXTRACT_16BITS(&q[1])); + rawprint((caddr_t)&p[2], EXTRACT_16BITS(&q[1])); } printf(")"); return p + totlen; } -static u_char * -isakmp_sa_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi0, u_int32_t proto0) +static const u_char * +isakmp_sa_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_, + u_int32_t proto0, int depth) { - struct isakmp_pl_sa *p, sa; - u_int32_t *q; + const struct isakmp_pl_sa *p; + struct isakmp_pl_sa sa; + const u_int32_t *q; u_int32_t doi, sit, ident; - u_char *cp, *np; + const u_char *cp, *np; int t; printf("%s:", NPSTR(ISAKMP_NPTYPE_SA)); p = (struct isakmp_pl_sa *)ext; + TCHECK(*p); safememcpy(&sa, ext, sizeof(sa)); doi = ntohl(sa.doi); sit = ntohl(sa.sit); @@ -456,78 +456,92 @@ isakmp_sa_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, np = (u_char *)ext + sizeof(sa); if (sit != 0x01) { + TCHECK2(*(ext + 1), sizeof(ident)); safememcpy(&ident, ext + 1, sizeof(ident)); printf(" ident=%u", (u_int32_t)ntohl(ident)); np += sizeof(ident); } ext = (struct isakmp_gen *)np; + TCHECK(*ext); - cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0); + cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0, + depth); return cp; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_SA)); + return NULL; } -static u_char * -isakmp_p_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi0, u_int32_t proto0) +static const u_char * +isakmp_p_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase, u_int32_t doi0, + u_int32_t proto0 _U_, int depth) { - struct isakmp_pl_p *p, prop; - u_char *cp; + const struct isakmp_pl_p *p; + struct isakmp_pl_p prop; + const u_char *cp; printf("%s:", NPSTR(ISAKMP_NPTYPE_P)); p = (struct isakmp_pl_p *)ext; + TCHECK(*p); safememcpy(&prop, ext, sizeof(prop)); printf(" #%d protoid=%s transform=%d", prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t); if (prop.spi_size) { printf(" spi="); - rawprint((caddr_t)(p + 1), prop.spi_size); + if (!rawprint((caddr_t)(p + 1), prop.spi_size)) + goto trunc; } ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size); + TCHECK(*ext); cp = isakmp_sub_print(ISAKMP_NPTYPE_T, ext, ep, phase, doi0, - prop.prot_id); + prop.prot_id, depth); return cp; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_P)); + return NULL; } -static char *isakmp_p_map[] = { +static const char *isakmp_p_map[] = { NULL, "ike", }; -static char *ah_p_map[] = { +static const char *ah_p_map[] = { NULL, "(reserved)", "md5", "sha", "1des", "sha2-256", "sha2-384", "sha2-512", }; -static char *esp_p_map[] = { +static const char *esp_p_map[] = { NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast", "blowfish", "3idea", "1des-iv32", "rc4", "null", "aes" }; -static char *ipcomp_p_map[] = { +static const char *ipcomp_p_map[] = { NULL, "oui", "deflate", "lzs", }; -struct attrmap ipsec_t_map[] = { - { NULL, 0, }, +const struct attrmap ipsec_t_map[] = { + { NULL, 0, { NULL } }, { "lifetype", 3, { NULL, "sec", "kb", }, }, - { "life", 0, }, + { "life", 0, { NULL } }, { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155", "EC2N 2^185", }, }, { "enc mode", 3, { NULL, "tunnel", "transport", }, }, { "auth", 5, { NULL, "hmac-md5", "hmac-sha1", "1des-mac", "keyed", }, }, - { "keylen", 0, }, - { "rounds", 0, }, - { "dictsize", 0, }, - { "privalg", 0, }, + { "keylen", 0, { NULL } }, + { "rounds", 0, { NULL } }, + { "dictsize", 0, { NULL } }, + { "privalg", 0, { NULL } }, }; -struct attrmap oakley_t_map[] = { - { NULL, 0 }, +const struct attrmap oakley_t_map[] = { + { NULL, 0, { NULL } }, { "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5", "3des", "cast", "aes", }, }, { "hash", 7, { NULL, "md5", "sha1", "tiger", @@ -537,33 +551,36 @@ struct attrmap oakley_t_map[] = { { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155", "EC2N 2^185", }, }, { "group type", 4, { NULL, "MODP", "ECP", "EC2N", }, }, - { "group prime", 0, }, - { "group gen1", 0, }, - { "group gen2", 0, }, - { "group curve A", 0, }, - { "group curve B", 0, }, + { "group prime", 0, { NULL } }, + { "group gen1", 0, { NULL } }, + { "group gen2", 0, { NULL } }, + { "group curve A", 0, { NULL } }, + { "group curve B", 0, { NULL } }, { "lifetype", 3, { NULL, "sec", "kb", }, }, - { "lifeduration", 0, }, - { "prf", 0, }, - { "keylen", 0, }, - { "field", 0, }, - { "order", 0, }, + { "lifeduration", 0, { NULL } }, + { "prf", 0, { NULL } }, + { "keylen", 0, { NULL } }, + { "field", 0, { NULL } }, + { "order", 0, { NULL } }, }; -static u_char * -isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_t_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto, int depth _U_) { - struct isakmp_pl_t *p, t; - u_char *cp; - char *idstr; - struct attrmap *map; + const struct isakmp_pl_t *p; + struct isakmp_pl_t t; + const u_char *cp; + const char *idstr; + const struct attrmap *map; size_t nmap; - u_char *ep2; + const u_char *ep2; printf("%s:", NPSTR(ISAKMP_NPTYPE_T)); p = (struct isakmp_pl_t *)ext; + TCHECK(*p); safememcpy(&t, ext, sizeof(t)); switch (proto) { @@ -599,7 +616,7 @@ isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, else printf(" #%d id=%d ", t.t_no, t.t_id); cp = (u_char *)(p + 1); - ep2 = (u_char *)p + ntohs(t.h.len); + ep2 = (u_char *)p + item_len; while (cp < ep && cp < ep2) { if (map && nmap) { cp = isakmp_attrmap_print(cp, (ep < ep2) ? ep : ep2, @@ -610,51 +627,65 @@ isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, if (ep < ep2) printf("..."); return cp; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_T)); + return NULL; } -static u_char * -isakmp_ke_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_ke_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_KE)); + TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); printf(" key len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); - rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); + if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; } return (u_char *)ext + ntohs(e.len); +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_KE)); + return NULL; } -static u_char * -isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_id_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) { #define USE_IPSECDOI_IN_PHASE1 1 - struct isakmp_pl_id *p, id; - static char *idtypestr[] = { + const struct isakmp_pl_id *p; + struct isakmp_pl_id id; + static const char *idtypestr[] = { "IPv4", "IPv4net", "IPv6", "IPv6net", }; - static char *ipsecidtypestr[] = { + static const char *ipsecidtypestr[] = { NULL, "IPv4", "FQDN", "user FQDN", "IPv4net", "IPv6", "IPv6net", "IPv4range", "IPv6range", "ASN1 DN", "ASN1 GN", "keyid", }; int len; - u_char *data; + const u_char *data; printf("%s:", NPSTR(ISAKMP_NPTYPE_ID)); p = (struct isakmp_pl_id *)ext; + TCHECK(*p); safememcpy(&id, ext, sizeof(id)); - if (sizeof(*p) < id.h.len) + if (sizeof(*p) < item_len) { data = (u_char *)(p + 1); - else + len = item_len - sizeof(*p); + } else { data = NULL; - len = ntohs(id.h.len) - sizeof(*p); + len = 0; + } #if 0 /*debug*/ printf(" [phase=%d doi=%d proto=%d]", phase, doi, proto); @@ -674,18 +705,24 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, #endif case 2: { - struct ipsecdoi_id *p, id; + const struct ipsecdoi_id *p; + struct ipsecdoi_id id; struct protoent *pe; p = (struct ipsecdoi_id *)ext; + TCHECK(*p); safememcpy(&id, ext, sizeof(id)); printf(" idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)); if (id.proto_id) { +#ifndef WIN32 setprotoent(1); +#endif /* WIN32 */ pe = getprotobynumber(id.proto_id); if (pe) printf(" protoid=%s", pe->p_name); +#ifndef WIN32 endprotoent(); +#endif /* WIN32 */ } else { /* it DOES NOT mean IPPROTO_IP! */ printf(" protoid=%s", "0"); @@ -693,9 +730,15 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, printf(" port=%d", ntohs(id.port)); if (!len) break; + if (data == NULL) + goto trunc; + TCHECK2(*data, len); switch (id.type) { case IPSECDOI_ID_IPV4_ADDR: - printf(" len=%d %s", len, ipaddr_string(data)); + if (len < 4) + printf(" len=%d [bad: < 4]", len); + else + printf(" len=%d %s", len, ipaddr_string(data)); len = 0; break; case IPSECDOI_ID_FQDN: @@ -710,40 +753,61 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, } case IPSECDOI_ID_IPV4_ADDR_SUBNET: { - u_char *mask; - mask = data + sizeof(struct in_addr); - printf(" len=%d %s/%u.%u.%u.%u", len, - ipaddr_string(data), - mask[0], mask[1], mask[2], mask[3]); + const u_char *mask; + if (len < 8) + printf(" len=%d [bad: < 8]", len); + else { + mask = data + sizeof(struct in_addr); + printf(" len=%d %s/%u.%u.%u.%u", len, + ipaddr_string(data), + mask[0], mask[1], mask[2], mask[3]); + } len = 0; break; } #ifdef INET6 case IPSECDOI_ID_IPV6_ADDR: - printf(" len=%d %s", len, ip6addr_string(data)); + if (len < 16) + printf(" len=%d [bad: < 16]", len); + else + printf(" len=%d %s", len, ip6addr_string(data)); len = 0; break; case IPSECDOI_ID_IPV6_ADDR_SUBNET: { - u_int32_t *mask; - mask = (u_int32_t *)(data + sizeof(struct in6_addr)); - /*XXX*/ - printf(" len=%d %s/0x%08x%08x%08x%08x", len, - ip6addr_string(data), - mask[0], mask[1], mask[2], mask[3]); + const u_int32_t *mask; + if (len < 20) + printf(" len=%d [bad: < 20]", len); + else { + mask = (u_int32_t *)(data + sizeof(struct in6_addr)); + /*XXX*/ + printf(" len=%d %s/0x%08x%08x%08x%08x", len, + ip6addr_string(data), + mask[0], mask[1], mask[2], mask[3]); + } len = 0; break; } #endif /*INET6*/ case IPSECDOI_ID_IPV4_ADDR_RANGE: - printf(" len=%d %s-%s", len, ipaddr_string(data), - ipaddr_string(data + sizeof(struct in_addr))); + if (len < 8) + printf(" len=%d [bad: < 8]", len); + else { + printf(" len=%d %s-%s", len, + ipaddr_string(data), + ipaddr_string(data + sizeof(struct in_addr))); + } len = 0; break; #ifdef INET6 case IPSECDOI_ID_IPV6_ADDR_RANGE: - printf(" len=%d %s-%s", len, ip6addr_string(data), - ip6addr_string(data + sizeof(struct in6_addr))); + if (len < 32) + printf(" len=%d [bad: < 32]", len); + else { + printf(" len=%d %s-%s", len, + ip6addr_string(data), + ip6addr_string(data + sizeof(struct in6_addr))); + } len = 0; break; #endif /*INET6*/ @@ -759,18 +823,24 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, printf(" len=%d", len); if (2 < vflag) { printf(" "); - rawprint((caddr_t)data, len); + if (!rawprint((caddr_t)data, len)) + goto trunc; } } - return (u_char *)ext + ntohs(id.h.len); + return (u_char *)ext + item_len; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_ID)); + return NULL; } -static u_char * -isakmp_cert_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi0, u_int32_t proto0) +static const u_char * +isakmp_cert_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi0 _U_, + u_int32_t proto0 _U_, int depth _U_) { - struct isakmp_pl_cert *p, cert; - static char *certstr[] = { + const struct isakmp_pl_cert *p; + struct isakmp_pl_cert cert; + static const char *certstr[] = { "none", "pkcs7", "pgp", "dns", "x509sign", "x509ke", "kerberos", "crl", "arl", "spki", "x509attr", @@ -779,22 +849,29 @@ isakmp_cert_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, printf("%s:", NPSTR(ISAKMP_NPTYPE_CERT)); p = (struct isakmp_pl_cert *)ext; + TCHECK(*p); safememcpy(&cert, ext, sizeof(cert)); - printf(" len=%d", ntohs(cert.h.len) - 4); + printf(" len=%d", item_len - 4); printf(" type=%s", STR_OR_ID((cert.encode), certstr)); - if (2 < vflag && 4 < ntohs(cert.h.len)) { + if (2 < vflag && 4 < item_len) { printf(" "); - rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4); + if (!rawprint((caddr_t)(ext + 1), item_len - 4)) + goto trunc; } - return (u_char *)ext + ntohs(cert.h.len); + return (u_char *)ext + item_len; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_CERT)); + return NULL; } -static u_char * -isakmp_cr_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi0, u_int32_t proto0) +static const u_char * +isakmp_cr_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi0 _U_, + u_int32_t proto0 _U_, int depth _U_) { - struct isakmp_pl_cert *p, cert; - static char *certstr[] = { + const struct isakmp_pl_cert *p; + struct isakmp_pl_cert cert; + static const char *certstr[] = { "none", "pkcs7", "pgp", "dns", "x509sign", "x509ke", "kerberos", "crl", "arl", "spki", "x509attr", @@ -803,77 +880,101 @@ isakmp_cr_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, printf("%s:", NPSTR(ISAKMP_NPTYPE_CR)); p = (struct isakmp_pl_cert *)ext; + TCHECK(*p); safememcpy(&cert, ext, sizeof(cert)); - printf(" len=%d", ntohs(cert.h.len) - 4); + printf(" len=%d", item_len - 4); printf(" type=%s", STR_OR_ID((cert.encode), certstr)); - if (2 < vflag && 4 < ntohs(cert.h.len)) { + if (2 < vflag && 4 < item_len) { printf(" "); - rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4); + if (!rawprint((caddr_t)(ext + 1), item_len - 4)) + goto trunc; } - return (u_char *)ext + ntohs(cert.h.len); + return (u_char *)ext + item_len; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_CR)); + return NULL; } -static u_char * -isakmp_hash_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_hash_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_HASH)); + TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); printf(" len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); - rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); + if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; } return (u_char *)ext + ntohs(e.len); +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_HASH)); + return NULL; } -static u_char * -isakmp_sig_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_sig_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_SIG)); + TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); printf(" len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); - rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); + if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; } return (u_char *)ext + ntohs(e.len); +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_SIG)); + return NULL; } -static u_char * -isakmp_nonce_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_nonce_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_NONCE)); + TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); printf(" n len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); - rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); + if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; } return (u_char *)ext + ntohs(e.len); +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_NONCE)); + return NULL; } -static u_char * -isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi0, u_int32_t proto0) +static const u_char * +isakmp_n_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_, + u_int32_t proto0 _U_, int depth) { struct isakmp_pl_n *p, n; - u_char *cp; + const u_char *cp; u_char *ep2; u_int32_t doi; u_int32_t proto; - static char *notifystr[] = { + static const char *notify_error_str[] = { NULL, "INVALID-PAYLOAD-TYPE", "DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED", "INVALID-COOKIE", "INVALID-MAJOR-VERSION", @@ -891,29 +992,56 @@ isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, "CERTIFICATE-UNAVAILABLE", "UNSUPPORTED-EXCHANGE-TYPE", "UNEQUAL-PAYLOAD-LENGTHS", }; - static char *ipsecnotifystr[] = { + static const char *ipsec_notify_error_str[] = { + "RESERVED", + }; + static const char *notify_status_str[] = { + "CONNECTED", + }; + static const char *ipsec_notify_status_str[] = { "RESPONDER-LIFETIME", "REPLAY-STATUS", "INITIAL-CONTACT", }; /* NOTE: these macro must be called with x in proper range */ -#define NOTIFYSTR(x) \ - (((x) == 16384) ? "CONNECTED" : STR_OR_ID((x), notifystr)) -#define IPSECNOTIFYSTR(x) \ - (((x) == 8192) ? "RESERVED" : STR_OR_ID(((x) - 24576), ipsecnotifystr)) + +/* 0 - 8191 */ +#define NOTIFY_ERROR_STR(x) \ + STR_OR_ID((x), notify_error_str) + +/* 8192 - 16383 */ +#define IPSEC_NOTIFY_ERROR_STR(x) \ + STR_OR_ID((u_int)((x) - 8192), ipsec_notify_error_str) + +/* 16384 - 24575 */ +#define NOTIFY_STATUS_STR(x) \ + STR_OR_ID((u_int)((x) - 16384), notify_status_str) + +/* 24576 - 32767 */ +#define IPSEC_NOTIFY_STATUS_STR(x) \ + STR_OR_ID((u_int)((x) - 24576), ipsec_notify_status_str) printf("%s:", NPSTR(ISAKMP_NPTYPE_N)); p = (struct isakmp_pl_n *)ext; + TCHECK(*p); safememcpy(&n, ext, sizeof(n)); doi = ntohl(n.doi); proto = n.prot_id; if (doi != 1) { printf(" doi=%d", doi); printf(" proto=%d", proto); - printf(" type=%s", NOTIFYSTR(ntohs(n.type))); + if (ntohs(n.type) < 8192) + printf(" type=%s", NOTIFY_ERROR_STR(ntohs(n.type))); + else if (ntohs(n.type) < 16384) + printf(" type=%s", numstr(ntohs(n.type))); + else if (ntohs(n.type) < 24576) + printf(" type=%s", NOTIFY_STATUS_STR(ntohs(n.type))); + else + printf(" type=%s", numstr(ntohs(n.type))); if (n.spi_size) { printf(" spi="); - rawprint((caddr_t)(p + 1), n.spi_size); + if (!rawprint((caddr_t)(p + 1), n.spi_size)) + goto trunc; } return (u_char *)(p + 1) + n.spi_size; } @@ -921,29 +1049,30 @@ isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, printf(" doi=ipsec"); printf(" proto=%s", PROTOIDSTR(proto)); if (ntohs(n.type) < 8192) - printf(" type=%s", NOTIFYSTR(ntohs(n.type))); + printf(" type=%s", NOTIFY_ERROR_STR(ntohs(n.type))); else if (ntohs(n.type) < 16384) - printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type))); + printf(" type=%s", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type))); else if (ntohs(n.type) < 24576) - printf(" type=%s", NOTIFYSTR(ntohs(n.type))); - else if (ntohs(n.type) < 40960) - printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type))); + printf(" type=%s", NOTIFY_STATUS_STR(ntohs(n.type))); + else if (ntohs(n.type) < 32768) + printf(" type=%s", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type))); else - printf(" type=%s", NOTIFYSTR(ntohs(n.type))); + printf(" type=%s", numstr(ntohs(n.type))); if (n.spi_size) { printf(" spi="); - rawprint((caddr_t)(p + 1), n.spi_size); + if (!rawprint((caddr_t)(p + 1), n.spi_size)) + goto trunc; } cp = (u_char *)(p + 1) + n.spi_size; - ep2 = (u_char *)p + ntohs(n.h.len); + ep2 = (u_char *)p + item_len; if (cp < ep) { printf(" orig=("); switch (ntohs(n.type)) { case IPSECDOI_NTYPE_RESPONDER_LIFETIME: { - struct attrmap *map = oakley_t_map; + const struct attrmap *map = oakley_t_map; size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); while (cp < ep && cp < ep2) { cp = isakmp_attrmap_print(cp, @@ -956,26 +1085,32 @@ isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, (*(u_int32_t *)cp) ? "en" : "dis"); break; case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN: - isakmp_sub_print(ISAKMP_NPTYPE_SA, - (struct isakmp_gen *)cp, ep, phase, doi, proto); + if (isakmp_sub_print(ISAKMP_NPTYPE_SA, + (struct isakmp_gen *)cp, ep, phase, doi, proto, + depth) == NULL) + return NULL; break; default: /* NULL is dummy */ - isakmp_print(cp, - ntohs(n.h.len) - sizeof(*p) - n.spi_size, + isakmp_print(cp, item_len - sizeof(*p) - n.spi_size, NULL); } printf(")"); } - return (u_char *)ext + ntohs(n.h.len); + return (u_char *)ext + item_len; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_N)); + return NULL; } -static u_char * -isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi0, u_int32_t proto0) +static const u_char * +isakmp_d_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi0 _U_, + u_int32_t proto0 _U_, int depth _U_) { - struct isakmp_pl_d *p, d; - u_int8_t *q; + const struct isakmp_pl_d *p; + struct isakmp_pl_d d; + const u_int8_t *q; u_int32_t doi; u_int32_t proto; int i; @@ -983,6 +1118,7 @@ isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, printf("%s:", NPSTR(ISAKMP_NPTYPE_D)); p = (struct isakmp_pl_d *)ext; + TCHECK(*p); safememcpy(&d, ext, sizeof(d)); doi = ntohl(d.doi); proto = d.prot_id; @@ -1000,85 +1136,101 @@ isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, for (i = 0; i < ntohs(d.num_spi); i++) { if (i != 0) printf(","); - rawprint((caddr_t)q, d.spi_size); + if (!rawprint((caddr_t)q, d.spi_size)) + goto trunc; q += d.spi_size; } return q; +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_D)); + return NULL; } -static u_char * -isakmp_vid_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, - u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_vid_print(const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_VID)); + TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); printf(" len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); - rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); + if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; } return (u_char *)ext + ntohs(e.len); +trunc: + printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_VID)); + return NULL; } -static u_char * -isakmp_sub0_print(u_char np, struct isakmp_gen *ext, u_char *ep, - u_int32_t phase, u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_sub0_print(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_char *cp; + const u_char *cp; struct isakmp_gen e; u_int item_len; cp = (u_char *)ext; + TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - if (NPFUNC(np)) - cp = (*NPFUNC(np))(ext, ep, phase, doi, proto); - else { + /* + * Since we can't have a payload length of less than 4 bytes, + * we need to bail out here if the generic header is nonsensical + * or truncated, otherwise we could loop forever processing + * zero-length items or otherwise misdissect the packet. + */ + item_len = ntohs(e.len); + if (item_len <= 4) + return NULL; + + if (NPFUNC(np)) { + /* + * XXX - what if item_len is too short, or too long, + * for this payload type? + */ + cp = (*NPFUNC(np))(ext, item_len, ep, phase, doi, proto, depth); + } else { printf("%s", NPSTR(np)); - item_len = ntohs(e.len); - if (item_len == 0) { - /* - * We don't want to loop forever processing this - * bogus (zero-length) item; return NULL so that - * we stop dissecting. - */ - cp = NULL; - } else - cp += item_len; + cp += item_len; } + return cp; +trunc: + printf(" [|isakmp]"); + return NULL; } -static u_char * -isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep, - u_int32_t phase, u_int32_t doi, u_int32_t proto) +static const u_char * +isakmp_sub_print(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_char *cp; - static int depth = 0; + const u_char *cp; int i; struct isakmp_gen e; - cp = (u_char *)ext; + cp = (const u_char *)ext; while (np) { - TCHECK2(*ext, sizeof(e)); + TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - if (ep < (u_char *)ext + ntohs(e.len)) { - printf(" [|%s]", NPSTR(np)); - cp = ep + 1; - break; - } + TCHECK2(*ext, ntohs(e.len)); + depth++; printf("\n"); for (i = 0; i < depth; i++) printf(" "); printf("("); - cp = isakmp_sub0_print(np, ext, ep, phase, doi, proto); + cp = isakmp_sub0_print(np, ext, ep, phase, doi, proto, depth); printf(")"); depth--; @@ -1092,6 +1244,7 @@ isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep, } return cp; trunc: + printf(" [|%s]", NPSTR(np)); return NULL; } @@ -1109,7 +1262,7 @@ numstr(int x) * optimization. */ static void -safememcpy(void *p, void *q, size_t l) +safememcpy(void *p, const void *q, size_t l) { memcpy(p, q, l); } @@ -1117,15 +1270,16 @@ safememcpy(void *p, void *q, size_t l) void isakmp_print(const u_char *bp, u_int length, const u_char *bp2) { - struct isakmp *p, base; - u_char *ep; + const struct isakmp *p; + struct isakmp base; + const u_char *ep; u_char np; int i; int phase; int major, minor; - p = (struct isakmp *)bp; - ep = (u_char *)snapend; + p = (const struct isakmp *)bp; + ep = snapend; if ((struct isakmp *)ep < p + 1) { printf("[|isakmp]"); @@ -1185,40 +1339,41 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2) printf("[%s%s]", base.flags & ISAKMP_FLAG_E ? "E" : "", base.flags & ISAKMP_FLAG_C ? "C" : ""); } - printf(":"); - { - struct isakmp_gen *ext; - int nparen; + if (vflag) { + const struct isakmp_gen *ext; + int nparen; #define CHECKLEN(p, np) \ - if (ep < (u_char *)(p)) { \ - printf(" [|%s]", NPSTR(np)); \ - goto done; \ - } + if (ep < (u_char *)(p)) { \ + printf(" [|%s]", NPSTR(np)); \ + goto done; \ + } - /* regardless of phase... */ - if (base.flags & ISAKMP_FLAG_E) { - /* - * encrypted, nothing we can do right now. - * we hope to decrypt the packet in the future... - */ - printf(" [encrypted %s]", NPSTR(base.np)); - goto done; - } + printf(":"); - nparen = 0; - CHECKLEN(p + 1, base.np) + /* regardless of phase... */ + if (base.flags & ISAKMP_FLAG_E) { + /* + * encrypted, nothing we can do right now. + * we hope to decrypt the packet in the future... + */ + printf(" [encrypted %s]", NPSTR(base.np)); + goto done; + } - np = base.np; - ext = (struct isakmp_gen *)(p + 1); - isakmp_sub_print(np, ext, ep, phase, 0, 0); - } + nparen = 0; + CHECKLEN(p + 1, base.np) + + np = base.np; + ext = (struct isakmp_gen *)(p + 1); + isakmp_sub_print(np, ext, ep, phase, 0, 0, 0); + } done: if (vflag) { if (ntohl(base.len) != length) { - printf(" (len mismatch: isakmp %u/ip %d)", + printf(" (len mismatch: isakmp %u/ip %u)", (u_int32_t)ntohl(base.len), length); } } diff --git a/contrib/tcpdump/print-krb.c b/contrib/tcpdump/print-krb.c index 67f440a..1d3a6d7 100644 --- a/contrib/tcpdump/print-krb.c +++ b/contrib/tcpdump/print-krb.c @@ -22,32 +22,25 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.15 2000/09/29 04:58:42 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.21.2.2 2003/11/16 08:51:30 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> -#include <errno.h> #include <stdio.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" -const u_char *c_print(register const u_char *, register const u_char *); -const u_char *krb4_print_hdr(const u_char *); -void krb4_print(const u_char *); -void krb_print(const u_char *, u_int); - +static const u_char *c_print(register const u_char *, register const u_char *); +static const u_char *krb4_print_hdr(const u_char *); +static void krb4_print(const u_char *); #define AUTH_MSG_KDC_REQUEST 1<<1 #define AUTH_MSG_KDC_REPLY 2<<1 @@ -72,8 +65,8 @@ void krb_print(const u_char *, u_int); #define KERB_ERR_NULL_KEY 10 struct krb { - u_char pvno; /* Protocol Version */ - u_char type; /* Type+B */ + u_int8_t pvno; /* Protocol Version */ + u_int8_t type; /* Type+B */ }; static char tstr[] = " [|kerberos]"; @@ -106,26 +99,7 @@ static struct tok kerr2str[] = { { 0, NULL} }; - -/* little endian (unaligned) to host byte order */ -/* XXX need to look at this... */ -#define vtohlp(x) ((( ((char *)(x))[0] ) ) | \ - (( ((char *)(x))[1] ) << 8) | \ - (( ((char *)(x))[2] ) << 16) | \ - (( ((char *)(x))[3] ) << 24)) -#define vtohsp(x) ((( ((char *)(x))[0] ) ) | \ - (( ((char *)(x))[1] ) << 8)) -/* network (big endian) (unaligned) to host byte order */ -#define ntohlp(x) ((( ((char *)(x))[3] ) ) | \ - (( ((char *)(x))[2] ) << 8) | \ - (( ((char *)(x))[1] ) << 16) | \ - (( ((char *)(x))[0] ) << 24)) -#define ntohsp(x) ((( ((char *)(x))[1] ) ) | \ - (( ((char *)(x))[0] ) << 8)) - - - -const u_char * +static const u_char * c_print(register const u_char *s, register const u_char *ep) { register u_char c; @@ -154,7 +128,7 @@ c_print(register const u_char *s, register const u_char *ep) return (s); } -const u_char * +static const u_char * krb4_print_hdr(const u_char *cp) { cp += 2; @@ -175,7 +149,7 @@ trunc: #undef PRINT } -void +static void krb4_print(const u_char *cp) { register const struct krb *kp; @@ -185,7 +159,7 @@ krb4_print(const u_char *cp) #define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc /* True if struct krb is little endian */ #define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0) -#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? vtohsp(cp) : ntohsp(cp)) +#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp)) kp = (struct krb *)cp; @@ -253,7 +227,7 @@ trunc: } void -krb_print(const u_char *dat, u_int length) +krb_print(const u_char *dat) { register const struct krb *kp; diff --git a/contrib/tcpdump/print-l2tp.c b/contrib/tcpdump/print-l2tp.c index a765c03..a8f0568 100644 --- a/contrib/tcpdump/print-l2tp.c +++ b/contrib/tcpdump/print-l2tp.c @@ -22,19 +22,17 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.10.2.1 2002/05/25 09:47:07 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.14.2.3 2003/12/26 23:21:42 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include <tcpdump-stdinc.h> + #include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include <netinet/in.h> -#include <arpa/inet.h> #include "l2tp.h" #include "interface.h" @@ -146,27 +144,27 @@ static struct tok l2tp_avp2str[] = { { L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" }, { L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" }, { L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" }, - { L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" }, + { L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" }, { L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" }, { L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" }, { L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" }, { L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" }, { L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" }, { L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" }, - { L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" }, - { L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" }, - { L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" }, + { L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" }, + { L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" }, + { L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" }, { L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" }, - { L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" }, + { L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" }, { L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" }, { L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" }, { L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" }, - { L2TP_AVP_ACCM, "ACCM" }, - { L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" }, + { L2TP_AVP_ACCM, "ACCM" }, + { L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" }, { L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" }, - { L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" }, - { L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" }, - { L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" }, + { L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" }, + { L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" }, + { L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" }, { 0, NULL } }; @@ -243,19 +241,19 @@ static char *l2tp_error_code_general[] = { /******************************/ /* generic print out routines */ /******************************/ -static void +static void print_string(const u_char *dat, u_int length) { - int i; + u_int i; for (i=0; i<length; i++) { printf("%c", *dat++); } } -static void +static void print_octets(const u_char *dat, u_int length) { - int i; + u_int i; for (i=0; i<length; i++) { printf("%02x", *dat++); } @@ -289,7 +287,7 @@ static void l2tp_result_code_print(const u_char *dat, u_int length) { u_int16_t *ptr = (u_int16_t *)dat; - + printf("%u", EXTRACT_16BITS(ptr)); ptr++; /* Result Code */ if (length > 2) { /* Error Code (opt) */ printf("/%u", EXTRACT_16BITS(ptr)); ptr++; @@ -341,7 +339,7 @@ l2tp_q931_cc_print(const u_char *dat, u_int length) if (length > 3) { printf(" "); print_string(dat+3, length-3); - } + } } static void @@ -381,7 +379,7 @@ l2tp_proxy_auth_type_print(const u_char *dat) { u_int16_t *ptr = (u_int16_t *)dat; - printf("%s", tok2str(l2tp_authentype2str, + printf("%s", tok2str(l2tp_authentype2str, "AuthType-#%u", EXTRACT_16BITS(ptr))); } @@ -398,7 +396,7 @@ l2tp_call_errors_print(const u_char *dat) { u_int16_t *ptr = (u_int16_t *)dat; u_int16_t val_h, val_l; - + ptr++; /* skip "Reserved" */ val_h = EXTRACT_16BITS(ptr); ptr++; @@ -437,7 +435,7 @@ l2tp_accm_print(const u_char *dat) val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("send=%08x ", (val_h<<16) + val_l); - + val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("recv=%08x ", (val_h<<16) + val_l); @@ -447,10 +445,10 @@ static void l2tp_ppp_discon_cc_print(const u_char *dat, u_int length) { u_int16_t *ptr = (u_int16_t *)dat; - + printf("%04x, ", EXTRACT_16BITS(ptr)); ptr++; /* Disconnect Code */ printf("%04x ", EXTRACT_16BITS(ptr)); ptr++; /* Control Protocol Number */ - printf("%s", tok2str(l2tp_cc_direction2str, + printf("%s", tok2str(l2tp_cc_direction2str, "Direction-#%u", *((u_char *)ptr++))); if (length > 5) { @@ -507,7 +505,7 @@ l2tp_avp_print(const u_char *dat, int length) print_octets((u_char *)ptr, len-6); printf(")"); } else { - /* IETF-defined Attributes */ + /* IETF-defined Attributes */ ptr++; attr_type = EXTRACT_16BITS(ptr); ptr++; printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)); @@ -546,7 +544,7 @@ l2tp_avp_print(const u_char *dat, int length) case L2TP_AVP_CALLED_NUMBER: case L2TP_AVP_SUB_ADDRESS: case L2TP_AVP_PROXY_AUTH_NAME: - case L2TP_AVP_PRIVATE_GRP_ID: + case L2TP_AVP_PRIVATE_GRP_ID: print_string((u_char *)ptr, len-6); break; case L2TP_AVP_CHALLENGE: @@ -660,7 +658,7 @@ l2tp_print(const u_char *dat, u_int length) ptr++; cnt += 2; - + if (flag_l) { TCHECK(*ptr); /* Length */ l2tp_len = EXTRACT_16BITS(ptr); ptr++; @@ -708,4 +706,4 @@ l2tp_print(const u_char *dat, u_int length) trunc: printf("%s", tstr); -} +} diff --git a/contrib/tcpdump/print-lane.c b/contrib/tcpdump/print-lane.c index e697dba..3cdee5a 100644 --- a/contrib/tcpdump/print-lane.c +++ b/contrib/tcpdump/print-lane.c @@ -1,6 +1,6 @@ /* - * Marko Kiiskila carnil@cs.tut.fi - * + * Marko Kiiskila carnil@cs.tut.fi + * * Tampere University of Technology - Telecommunications Laboratory * * Permission to use, copy, modify and distribute this @@ -12,54 +12,69 @@ * documentation, and that the use of this software is * acknowledged in any publications resulting from using * the software. - * + * * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS * SOFTWARE. - * + * */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.12 2001/07/05 18:54:15 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.20.2.2 2003/11/16 08:51:31 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> - - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <pcap.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" #include "ether.h" #include "lane.h" +static const struct tok lecop2str[] = { + { 0x0001, "configure request" }, + { 0x0101, "configure response" }, + { 0x0002, "join request" }, + { 0x0102, "join response" }, + { 0x0003, "ready query" }, + { 0x0103, "ready indication" }, + { 0x0004, "register request" }, + { 0x0104, "register response" }, + { 0x0005, "unregister request" }, + { 0x0105, "unregister response" }, + { 0x0006, "ARP request" }, + { 0x0106, "ARP response" }, + { 0x0007, "flush request" }, + { 0x0107, "flush response" }, + { 0x0008, "NARP request" }, + { 0x0009, "topology request" }, + { 0, NULL } +}; + static inline void -lane_print(register const u_char *bp, int length) +lane_hdr_print(register const u_char *bp, int length) { register const struct lecdatahdr_8023 *ep; ep = (const struct lecdatahdr_8023 *)bp; if (qflag) - (void)printf("lecid:%d %s %s %d: ", - ntohs(ep->le_header), + (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:%d %s %s %s %d: ", - ntohs(ep->le_header), + (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), @@ -67,57 +82,66 @@ lane_print(register const u_char *bp, int length) } /* - * This is the top level routine of the printer. 'p' is the points - * to the ether header of the packet, 'h->tv' is the timestamp, + * This is the top level routine of the printer. 'p' points + * to the LANE header of the packet, 'h->ts' is the timestamp, * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. + * + * This assumes 802.3, not 802.5, LAN emulation. */ void -lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +lane_print(const u_char *p, u_int length, u_int caplen) { - int caplen = h->caplen; - int length = h->len; + struct lane_controlhdr *lec; struct lecdatahdr_8023 *ep; u_short ether_type; u_short extracted_ethertype; - ++infodelay; - ts_print(&h->ts); + if (caplen < sizeof(struct lane_controlhdr)) { + printf("[|lane]"); + return; + } + + lec = (struct lane_controlhdr *)p; + if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) { + /* + * LE Control. + */ + printf("lec: proto %x vers %x %s", + lec->lec_proto, lec->lec_vers, + tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))); + return; + } if (caplen < sizeof(struct lecdatahdr_8023)) { printf("[|lane]"); - goto out; + return; } if (eflag) - lane_print(p, length); + lane_hdr_print(p, length); /* - * Some printers want to get back at the ethernet addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. + * Go past the LANE header. */ - packetp = p; - snapend = p + caplen; - length -= sizeof(struct lecdatahdr_8023); caplen -= sizeof(struct lecdatahdr_8023); ep = (struct lecdatahdr_8023 *)p; p += sizeof(struct lecdatahdr_8023); - ether_type = ntohs(ep->h_type); + ether_type = EXTRACT_16BITS(&ep->h_type); /* * Is it (gag) an 802.3 encapsulation? */ extracted_ethertype = 0; - if (ether_type < ETHERMTU) { + if (ether_type <= ETHERMTU) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ep->h_source, ep->h_dest, &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) - lane_print((u_char *)ep, length + sizeof(*ep)); + lane_hdr_print((u_char *)ep, length + sizeof(*ep)); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); @@ -129,15 +153,16 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) - lane_print((u_char *)ep, length + sizeof(*ep)); + lane_hdr_print((u_char *)ep, length + sizeof(*ep)); if (!xflag && !qflag) default_print(p, caplen); } - if (xflag) - default_print(p, caplen); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); +} + +u_int +lane_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + lane_print(p, h->len, h->caplen); + + return (sizeof(struct lecdatahdr_8023)); } diff --git a/contrib/tcpdump/print-ldp.c b/contrib/tcpdump/print-ldp.c new file mode 100644 index 0000000..1162ac3 --- /dev/null +++ b/contrib/tcpdump/print-ldp.c @@ -0,0 +1,382 @@ +/* + * 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. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.4.2.2 2003/11/16 08:51:31 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" + +/* + * ldp common header + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | PDU Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | LDP Identifier | + * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + +struct ldp_common_header { + u_int8_t version[2]; + u_int8_t pdu_length[2]; + u_int8_t lsr_id[4]; + u_int8_t label_space[2]; +}; + +#define LDP_VERSION 1 + +/* + * ldp message header + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |U| Message Type | Message Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Message ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * + + + * | Mandatory Parameters | + * + + + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * + + + * | Optional Parameters | + * + + + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct ldp_msg_header { + u_int8_t type[2]; + u_int8_t length[2]; + u_int8_t id[4]; +}; + +#define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff) +#define LDP_MASK_U_BIT(x) ((x)&0x8000) + +#define LDP_MSG_NOTIF 0x0001 +#define LDP_MSG_HELLO 0x0100 +#define LDP_MSG_INIT 0x0200 +#define LDP_MSG_KEEPALIVE 0x0201 +#define LDP_MSG_ADDRESS 0x0300 +#define LDP_MSG_ADDRESS_WITHDRAW 0x0301 +#define LDP_MSG_LABEL_MAPPING 0x0400 +#define LDP_MSG_LABEL_REQUEST 0x0401 +#define LDP_MSG_LABEL_WITHDRAW 0x0402 +#define LDP_MSG_LABEL_RELEASE 0x0403 +#define LDP_MSG_LABEL_ABORT_REQUEST 0x0404 + +#define LDP_VENDOR_PRIVATE_MIN 0x3e00 +#define LDP_VENDOR_PRIVATE_MAX 0x3eff +#define LDP_EXPERIMENTAL_MIN 0x3f00 +#define LDP_EXPERIMENTAL_MAX 0x3fff + +static const struct tok ldp_msg_values[] = { + { LDP_MSG_NOTIF, "Notification" }, + { LDP_MSG_HELLO, "Hello" }, + { LDP_MSG_INIT, "Initialization" }, + { LDP_MSG_KEEPALIVE, "Keepalive" }, + { LDP_MSG_ADDRESS, "Address" }, + { LDP_MSG_ADDRESS_WITHDRAW, "Address Widthdraw" }, + { LDP_MSG_LABEL_MAPPING, "Label Mapping" }, + { LDP_MSG_LABEL_REQUEST, "Label Request" }, + { LDP_MSG_LABEL_WITHDRAW, "Label Withdraw" }, + { LDP_MSG_LABEL_RELEASE, "Label Release" }, + { LDP_MSG_LABEL_ABORT_REQUEST, "Label Abort Request" }, + { 0, NULL} +}; + +#define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff) +#define LDP_MASK_F_BIT(x) ((x)&0x4000) + +#define LDP_TLV_FEC 0x0100 +#define LDP_TLV_ADDRESS_LIST 0x0101 +#define LDP_TLV_HOP_COUNT 0x0103 +#define LDP_TLV_PATH_VECTOR 0x0104 +#define LDP_TLV_GENERIC_LABEL 0x0200 +#define LDP_TLV_ATM_LABEL 0x0201 +#define LDP_TLV_FR_LABEL 0x0202 +#define LDP_TLV_STATUS 0x0300 +#define LDP_TLV_EXTD_STATUS 0x0301 +#define LDP_TLV_RETURNED_PDU 0x0302 +#define LDP_TLV_RETURNED_MSG 0x0303 +#define LDP_TLV_COMMON_HELLO 0x0400 +#define LDP_TLV_IPV4_TRANSPORT_ADDR 0x0401 +#define LDP_TLV_CONFIG_SEQ_NUMBER 0x0402 +#define LDP_TLV_IPV6_TRANSPORT_ADDR 0x0403 +#define LDP_TLV_COMMON_SESSION 0x0500 +#define LDP_TLV_ATM_SESSION_PARM 0x0501 +#define LDP_TLV_FR_SESSION_PARM 0x0502 +#define LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600 + +static const struct tok ldp_tlv_values[] = { + { LDP_TLV_FEC, "FEC" }, + { LDP_TLV_ADDRESS_LIST, "Address List" }, + { LDP_TLV_HOP_COUNT, "Hop Count" }, + { LDP_TLV_PATH_VECTOR, "Path Vector" }, + { LDP_TLV_GENERIC_LABEL, "Generic Label" }, + { LDP_TLV_ATM_LABEL, "ATM Label" }, + { LDP_TLV_FR_LABEL, "Frame-Relay Label" }, + { LDP_TLV_STATUS, "Status" }, + { LDP_TLV_EXTD_STATUS, "Extended Status" }, + { LDP_TLV_RETURNED_PDU, "Returned PDU" }, + { LDP_TLV_RETURNED_MSG, "Returned Message" }, + { LDP_TLV_COMMON_HELLO, "Common Hello Parameters" }, + { LDP_TLV_IPV4_TRANSPORT_ADDR, "IPv4 Transport Address" }, + { LDP_TLV_CONFIG_SEQ_NUMBER, "Configuration Sequence Number" }, + { LDP_TLV_IPV6_TRANSPORT_ADDR, "IPv6 Transport Address" }, + { LDP_TLV_COMMON_SESSION, "Common Session Parameters" }, + { LDP_TLV_ATM_SESSION_PARM, "ATM Session Parameters" }, + { LDP_TLV_FR_SESSION_PARM, "Frame-Relay Session Parameters" }, + { LDP_TLV_LABEL_REQUEST_MSG_ID, "Label Request Message ID" }, + { 0, NULL} +}; + +#define FALSE 0 +#define TRUE 1 + +int ldp_tlv_print(register const u_char *); + +/* + * ldp tlv header + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |U|F| Type | Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * | Value | + * ~ ~ + * | | + * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +int +ldp_tlv_print(register const u_char *tptr) { + + struct ldp_tlv_header { + u_int8_t type[2]; + u_int8_t length[2]; + }; + + const struct ldp_tlv_header *ldp_tlv_header; + u_short tlv_type,tlv_len,tlv_tlen; + + ldp_tlv_header = (const struct ldp_tlv_header *)tptr; + tlv_len=EXTRACT_16BITS(ldp_tlv_header->length); + tlv_tlen=tlv_len; + tlv_type=LDP_MASK_TLV_TYPE(EXTRACT_16BITS(ldp_tlv_header->type)); + + /* FIXME vendor private / experimental check */ + printf("\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]", + tok2str(ldp_tlv_values, + "Unknown", + tlv_type), + tlv_type, + tlv_len, + LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "continue processing" : "ignore", + LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't"); + + tptr+=sizeof(struct ldp_tlv_header); + + switch(tlv_type) { + + case LDP_TLV_COMMON_HELLO: + printf("\n\t Hold Time: %us, Flags: [%s Hello%s]", + EXTRACT_16BITS(tptr), + (EXTRACT_16BITS(tptr+2)&0x8000) ? "Targeted" : "Link", + (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : ""); + break; + + case LDP_TLV_IPV4_TRANSPORT_ADDR: + printf("\n\t IPv4 Transport Address: %s", ipaddr_string(tptr)); + break; +#ifdef INET6 + case LDP_TLV_IPV6_TRANSPORT_ADDR: + printf("\n\t IPv6 Transport Address: %s", ip6addr_string(tptr)); + break; +#endif + case LDP_TLV_CONFIG_SEQ_NUMBER: + printf("\n\t Sequence Number: %u", EXTRACT_32BITS(tptr)); + break; + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case LDP_TLV_FEC: + case LDP_TLV_ADDRESS_LIST: + case LDP_TLV_HOP_COUNT: + case LDP_TLV_PATH_VECTOR: + case LDP_TLV_GENERIC_LABEL: + case LDP_TLV_ATM_LABEL: + case LDP_TLV_FR_LABEL: + case LDP_TLV_STATUS: + case LDP_TLV_EXTD_STATUS: + case LDP_TLV_RETURNED_PDU: + case LDP_TLV_RETURNED_MSG: + case LDP_TLV_COMMON_SESSION: + case LDP_TLV_ATM_SESSION_PARM: + case LDP_TLV_FR_SESSION_PARM: + case LDP_TLV_LABEL_REQUEST_MSG_ID: + + default: + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlv_tlen); + break; + } + return(tlv_len+4); /* Type & Length fields not included */ +} + +void +ldp_print(register const u_char *pptr, register u_int len) { + + const struct ldp_common_header *ldp_com_header; + const struct ldp_msg_header *ldp_msg_header; + const u_char *tptr,*msg_tptr; + u_short tlen; + u_short msg_len,msg_type,msg_tlen; + int hexdump,processed; + + tptr=pptr; + ldp_com_header = (const struct ldp_common_header *)pptr; + TCHECK(*ldp_com_header); + + /* + * Sanity checking of the header. + */ + if (EXTRACT_16BITS(&ldp_com_header->version) != LDP_VERSION) { + printf("LDP version %u packet not supported", + EXTRACT_16BITS(&ldp_com_header->version)); + return; + } + + /* print the LSR-ID, label-space & length */ + printf("%sLDP, Label-Space-ID: %s:%u, length: %u", + (vflag < 1) ? "" : "\n\t", + ipaddr_string(&ldp_com_header->lsr_id), + EXTRACT_16BITS(&ldp_com_header->label_space), + len); + + /* bail out if non-verbose */ + if (vflag < 1) + return; + + /* ok they seem to want to know everything - lets fully decode it */ + tlen=EXTRACT_16BITS(ldp_com_header->pdu_length); + + tptr+=sizeof(const struct ldp_common_header); + tlen-=sizeof(const struct ldp_common_header); + + while(tlen>0) { + /* did we capture enough for fully decoding the msg header ? */ + if (!TTEST2(*tptr, sizeof(struct ldp_msg_header))) + goto trunc; + + ldp_msg_header = (const struct ldp_msg_header *)tptr; + msg_len=EXTRACT_16BITS(ldp_msg_header->length); + msg_type=LDP_MASK_MSG_TYPE(EXTRACT_16BITS(ldp_msg_header->type)); + + /* FIXME vendor private / experimental check */ + printf("\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]", + tok2str(ldp_msg_values, + "Unknown", + msg_type), + msg_type, + msg_len, + EXTRACT_32BITS(&ldp_msg_header->id), + LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore"); + + msg_tptr=tptr+sizeof(struct ldp_msg_header); + msg_tlen=msg_len-sizeof(struct ldp_msg_header)+4; /* Type & Length fields not included */ + + /* did we capture enough for fully decoding the message ? */ + if (!TTEST2(*tptr, msg_len)) + goto trunc; + hexdump=FALSE; + + switch(msg_type) { + + case LDP_MSG_HELLO: + while(msg_tlen >= 4) { + processed = ldp_tlv_print(msg_tptr); + if (processed == 0) + break; + msg_tlen-=processed; + msg_tptr+=processed; + } + break; + + /* + * FIXME those are the defined messages that lack a decoder + * you are welcome to contribute code ;-) + */ + + case LDP_MSG_NOTIF: + case LDP_MSG_INIT: + case LDP_MSG_KEEPALIVE: + case LDP_MSG_ADDRESS: + case LDP_MSG_ADDRESS_WITHDRAW: + case LDP_MSG_LABEL_MAPPING: + case LDP_MSG_LABEL_REQUEST: + case LDP_MSG_LABEL_WITHDRAW: + case LDP_MSG_LABEL_RELEASE: + case LDP_MSG_LABEL_ABORT_REQUEST: + + default: + if (vflag <= 1) + print_unknown_data(msg_tptr,"\n\t ",msg_tlen); + break; + } + /* do we want to see an additionally hexdump ? */ + if (vflag > 1 || hexdump==TRUE) + print_unknown_data(tptr+sizeof(sizeof(struct ldp_msg_header)),"\n\t ", + msg_len); + + tptr+=msg_len; + tlen-=msg_len; + } + return; +trunc: + printf("\n\t\t packet exceeded snapshot"); +} + diff --git a/contrib/tcpdump/print-lwres.c b/contrib/tcpdump/print-lwres.c index 82ec5ae..5272d439 100644 --- a/contrib/tcpdump/print-lwres.c +++ b/contrib/tcpdump/print-lwres.c @@ -28,18 +28,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.5 2001/06/26 06:19:05 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.10.2.3 2004/03/24 01:54:58 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include "nameser.h" @@ -199,7 +196,7 @@ static int lwres_printname(size_t l, const char *p0) { const char *p; - int i; + size_t i; p = p0; /* + 1 for terminating \0 */ @@ -265,25 +262,28 @@ lwres_printaddr(lwres_addr_t *ap) int i; TCHECK(ap->length); - l = ntohs(ap->length); + l = EXTRACT_16BITS(&ap->length); /* XXX ap points to packed struct */ p = (const char *)&ap->length + sizeof(ap->length); - if (p + l > (const char *)snapend) - goto trunc; + TCHECK2(*p, l); - switch (ntohl(ap->family)) { + switch (EXTRACT_32BITS(&ap->family)) { case 1: /* IPv4 */ + if (l < 4) + return -1; printf(" %s", ipaddr_string(p)); p += sizeof(struct in_addr); break; #ifdef INET6 case 2: /* IPv6 */ + if (l < 16) + return -1; printf(" %s", ip6addr_string(p)); p += sizeof(struct in6_addr); break; #endif default: - printf(" %lu/", (unsigned long)ntohl(ap->family)); + printf(" %u/", EXTRACT_32BITS(&ap->family)); for (i = 0; i < l; i++) printf("%02x", *p++); } @@ -308,35 +308,35 @@ lwres_print(register const u_char *bp, u_int length) TCHECK(np->authlength); printf(" lwres"); - v = ntohs(np->version); + v = EXTRACT_16BITS(&np->version); if (vflag || v != LWRES_LWPACKETVERSION_0) printf(" v%u", v); if (v != LWRES_LWPACKETVERSION_0) { - s = (const char *)np + ntohl(np->length); + s = (const char *)np + EXTRACT_32BITS(&np->length); goto tail; } - response = ntohs(np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE; + response = EXTRACT_16BITS(&np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE; /* opcode and pktflags */ - v = (u_int32_t)ntohl(np->opcode); + v = EXTRACT_32BITS(&np->opcode); s = tok2str(opcode, "#0x%x", v); printf(" %s%s", s, response ? "" : "?"); /* pktflags */ - v = ntohs(np->pktflags); + v = EXTRACT_16BITS(&np->pktflags); if (v & ~LWRES_LWPACKETFLAG_RESPONSE) printf("[0x%x]", v); if (vflag > 1) { printf(" ("); /*)*/ - printf("serial:0x%lx", (unsigned long)ntohl(np->serial)); - printf(" result:0x%lx", (unsigned long)ntohl(np->result)); - printf(" recvlen:%lu", (unsigned long)ntohl(np->recvlength)); + printf("serial:0x%x", EXTRACT_32BITS(&np->serial)); + printf(" result:0x%x", EXTRACT_32BITS(&np->result)); + printf(" recvlen:%u", EXTRACT_32BITS(&np->recvlength)); /* BIND910: not used */ if (vflag > 2) { - printf(" authtype:0x%x", ntohs(np->authtype)); - printf(" authlen:%u", ntohs(np->authlength)); + printf(" authtype:0x%x", EXTRACT_16BITS(&np->authtype)); + printf(" authlen:%u", EXTRACT_16BITS(&np->authlength)); } /*(*/ printf(")"); @@ -356,7 +356,7 @@ lwres_print(register const u_char *bp, u_int length) gnba = NULL; grbn = NULL; - switch (ntohl(np->opcode)) { + switch (EXTRACT_32BITS(&np->opcode)) { case LWRES_OPCODE_NOOP: break; case LWRES_OPCODE_GETADDRSBYNAME: @@ -365,15 +365,15 @@ lwres_print(register const u_char *bp, u_int length) /* XXX gabn points to packed struct */ s = (const char *)&gabn->namelen + sizeof(gabn->namelen); - l = ntohs(gabn->namelen); + l = EXTRACT_16BITS(&gabn->namelen); /* BIND910: not used */ if (vflag > 2) { - printf(" flags:0x%lx", - (unsigned long)ntohl(gabn->flags)); + printf(" flags:0x%x", + EXTRACT_32BITS(&gabn->flags)); } - v = (u_int32_t)ntohl(gabn->addrtypes); + v = EXTRACT_32BITS(&gabn->addrtypes); switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) { case LWRES_ADDRTYPE_V4: printf(" IPv4"); @@ -399,8 +399,8 @@ lwres_print(register const u_char *bp, u_int length) /* BIND910: not used */ if (vflag > 2) { - printf(" flags:0x%lx", - (unsigned long)ntohl(gnba->flags)); + printf(" flags:0x%x", + EXTRACT_32BITS(&gnba->flags)); } s = (const char *)&gnba->addr; @@ -417,20 +417,21 @@ lwres_print(register const u_char *bp, u_int length) /* BIND910: not used */ if (vflag > 2) { - printf(" flags:0x%lx", - (unsigned long)ntohl(grbn->flags)); + printf(" flags:0x%x", + EXTRACT_32BITS(&grbn->flags)); } printf(" %s", tok2str(ns_type2str, "Type%d", - ntohs(grbn->rdtype))); - if (ntohs(grbn->rdclass) != C_IN); + EXTRACT_16BITS(&grbn->rdtype))); + if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) { printf(" %s", tok2str(ns_class2str, "Class%d", - ntohs(grbn->rdclass))); + EXTRACT_16BITS(&grbn->rdclass))); + } /* XXX grbn points to packed struct */ s = (const char *)&grbn->namelen + sizeof(grbn->namelen); - l = ntohs(gabn->namelen); + l = EXTRACT_16BITS(&grbn->namelen); advance = lwres_printname(l, s); if (advance < 0) @@ -449,13 +450,13 @@ lwres_print(register const u_char *bp, u_int length) lwres_gnbaresponse_t *gnba; lwres_grbnresponse_t *grbn; u_int32_t l, na; - int i; + u_int32_t i; gabn = NULL; gnba = NULL; grbn = NULL; - switch (ntohl(np->opcode)) { + switch (EXTRACT_32BITS(&np->opcode)) { case LWRES_OPCODE_NOOP: break; case LWRES_OPCODE_GETADDRSBYNAME: @@ -464,16 +465,16 @@ lwres_print(register const u_char *bp, u_int length) /* XXX gabn points to packed struct */ s = (const char *)&gabn->realnamelen + sizeof(gabn->realnamelen); - l = ntohs(gabn->realnamelen); + l = EXTRACT_16BITS(&gabn->realnamelen); /* BIND910: not used */ if (vflag > 2) { - printf(" flags:0x%lx", - (unsigned long)ntohl(gabn->flags)); + printf(" flags:0x%x", + EXTRACT_32BITS(&gabn->flags)); } - printf(" %u/%u", ntohs(gabn->naliases), - ntohs(gabn->naddrs)); + printf(" %u/%u", EXTRACT_16BITS(&gabn->naliases), + EXTRACT_16BITS(&gabn->naddrs)); advance = lwres_printname(l, s); if (advance < 0) @@ -481,7 +482,7 @@ lwres_print(register const u_char *bp, u_int length) s += advance; /* aliases */ - na = ntohs(gabn->naliases); + na = EXTRACT_16BITS(&gabn->naliases); for (i = 0; i < na; i++) { advance = lwres_printnamelen(s); if (advance < 0) @@ -490,7 +491,7 @@ lwres_print(register const u_char *bp, u_int length) } /* addrs */ - na = ntohs(gabn->naddrs); + na = EXTRACT_16BITS(&gabn->naddrs); for (i = 0; i < na; i++) { advance = lwres_printaddr((lwres_addr_t *)s); if (advance < 0) @@ -504,15 +505,15 @@ lwres_print(register const u_char *bp, u_int length) /* XXX gnba points to packed struct */ s = (const char *)&gnba->realnamelen + sizeof(gnba->realnamelen); - l = ntohs(gnba->realnamelen); + l = EXTRACT_16BITS(&gnba->realnamelen); /* BIND910: not used */ if (vflag > 2) { - printf(" flags:0x%lx", - (unsigned long)ntohl(gnba->flags)); + printf(" flags:0x%x", + EXTRACT_32BITS(&gnba->flags)); } - printf(" %u", ntohs(gnba->naliases)); + printf(" %u", EXTRACT_16BITS(&gnba->naliases)); advance = lwres_printname(l, s); if (advance < 0) @@ -520,7 +521,7 @@ lwres_print(register const u_char *bp, u_int length) s += advance; /* aliases */ - na = ntohs(gnba->naliases); + na = EXTRACT_16BITS(&gnba->naliases); for (i = 0; i < na; i++) { advance = lwres_printnamelen(s); if (advance < 0) @@ -535,19 +536,20 @@ lwres_print(register const u_char *bp, u_int length) /* BIND910: not used */ if (vflag > 2) { - printf(" flags:0x%lx", - (unsigned long)ntohl(grbn->flags)); + printf(" flags:0x%x", + EXTRACT_32BITS(&grbn->flags)); } printf(" %s", tok2str(ns_type2str, "Type%d", - ntohs(grbn->rdtype))); - if (ntohs(grbn->rdclass) != C_IN); + EXTRACT_16BITS(&grbn->rdtype))); + if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) { printf(" %s", tok2str(ns_class2str, "Class%d", - ntohs(grbn->rdclass))); + EXTRACT_16BITS(&grbn->rdclass))); + } printf(" TTL "); - relts_print(ntohl(grbn->ttl)); - printf(" %u/%u", ntohs(grbn->nrdatas), - ntohs(grbn->nsigs)); + relts_print(EXTRACT_32BITS(&grbn->ttl)); + printf(" %u/%u", EXTRACT_16BITS(&grbn->nrdatas), + EXTRACT_16BITS(&grbn->nsigs)); /* XXX grbn points to packed struct */ s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs); @@ -558,7 +560,7 @@ lwres_print(register const u_char *bp, u_int length) s += advance; /* rdatas */ - na = ntohs(grbn->nrdatas); + na = EXTRACT_16BITS(&grbn->nrdatas); for (i = 0; i < na; i++) { /* XXX should decode resource data */ advance = lwres_printbinlen(s); @@ -568,7 +570,7 @@ lwres_print(register const u_char *bp, u_int length) } /* sigs */ - na = ntohs(grbn->nsigs); + na = EXTRACT_16BITS(&grbn->nsigs); for (i = 0; i < na; i++) { /* XXX how should we print it? */ advance = lwres_printbinlen(s); @@ -585,11 +587,11 @@ lwres_print(register const u_char *bp, u_int length) tail: /* length mismatch */ - if (ntohl(np->length) != length) { - printf(" [len: %lu != %u]", (unsigned long)ntohl(np->length), + if (EXTRACT_32BITS(&np->length) != length) { + printf(" [len: %u != %u]", EXTRACT_32BITS(&np->length), length); } - if (!unsupported && s < (const char *)np + ntohl(np->length)) + if (!unsupported && s < (const char *)np + EXTRACT_32BITS(&np->length)) printf("[extra]"); return; diff --git a/contrib/tcpdump/print-mobile.c b/contrib/tcpdump/print-mobile.c index f585c9b..5815102 100644 --- a/contrib/tcpdump/print-mobile.c +++ b/contrib/tcpdump/print-mobile.c @@ -41,17 +41,12 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.7.4.1 2002/06/01 23:51:14 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.12.2.2 2003/11/16 08:51:33 guy Exp $"; #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <netdb.h> #include <stdio.h> #include "interface.h" @@ -94,7 +89,7 @@ mobile_print(const u_char *bp, u_int length) osp=1; cp +=4 ; } - + if (osp) { fputs("[S] ",stdout); if (vflag) diff --git a/contrib/tcpdump/print-mobility.c b/contrib/tcpdump/print-mobility.c new file mode 100644 index 0000000..f5a1a4c --- /dev/null +++ b/contrib/tcpdump/print-mobility.c @@ -0,0 +1,314 @@ +/* + * Copyright (C) 2002 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 HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.9.2.2 2003/11/16 08:51:33 guy Exp $"; +#endif + +#ifdef INET6 +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "ip6.h" + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +/* Mobility header */ +struct ip6_mobility { + u_int8_t ip6m_pproto; /* following payload protocol (for PG) */ + u_int8_t ip6m_len; /* length in units of 8 octets */ + u_int8_t ip6m_type; /* message type */ + u_int8_t reserved; /* reserved */ + u_int16_t ip6m_cksum; /* sum of IPv6 pseudo-header and MH */ + union { + u_int16_t ip6m_un_data16[1]; /* type-specific field */ + u_int8_t ip6m_un_data8[2]; /* type-specific fiedl */ + } ip6m_dataun; +}; + +#define ip6m_data16 ip6m_dataun.ip6m_un_data16 +#define ip6m_data8 ip6m_dataun.ip6m_un_data8 + +#define IP6M_MINLEN 8 + +/* message type */ +#define IP6M_BINDING_REQUEST 0 /* Binding Refresh Request */ +#define IP6M_HOME_TEST_INIT 1 /* Home Test Init */ +#define IP6M_CAREOF_TEST_INIT 2 /* Care-of Test Init */ +#define IP6M_HOME_TEST 3 /* Home Test */ +#define IP6M_CAREOF_TEST 4 /* Care-of Test */ +#define IP6M_BINDING_UPDATE 5 /* Binding Update */ +#define IP6M_BINDING_ACK 6 /* Binding Acknowledgement */ +#define IP6M_BINDING_ERROR 7 /* Binding Error */ + +/* Mobility Header Options */ +#define IP6MOPT_MINLEN 2 +#define IP6MOPT_PAD1 0x0 /* Pad1 */ +#define IP6MOPT_PADN 0x1 /* PadN */ +#define IP6MOPT_REFRESH 0x2 /* Binding Refresh Advice */ +#define IP6MOPT_REFRESH_MINLEN 4 +#define IP6MOPT_ALTCOA 0x3 /* Alternate Care-of Address */ +#define IP6MOPT_ALTCOA_MINLEN 18 +#define IP6MOPT_NONCEID 0x4 /* Nonce Indices */ +#define IP6MOPT_NONCEID_MINLEN 6 +#define IP6MOPT_AUTH 0x5 /* Binding Authorization Data */ +#define IP6MOPT_AUTH_MINLEN 12 + +static void +mobility_opt_print(const u_char *bp, int len) +{ + int i; + int optlen; + + for (i = 0; i < len; i += optlen) { + if (bp[i] == IP6MOPT_PAD1) + optlen = 1; + else { + if (i + 1 < len) + optlen = bp[i + 1] + 2; + else + goto trunc; + } + if (i + optlen > len) + goto trunc; + + switch (bp[i]) { + case IP6MOPT_PAD1: + printf("(pad1)"); + break; + case IP6MOPT_PADN: + if (len - i < IP6MOPT_MINLEN) { + printf("(padn: trunc)"); + goto trunc; + } + printf("(padn)"); + break; + case IP6MOPT_REFRESH: + if (len - i < IP6MOPT_REFRESH_MINLEN) { + printf("(refresh: trunc)"); + goto trunc; + } + /* units of 4 secs */ + printf("(refresh: %d)", + EXTRACT_16BITS(&bp[i+2]) << 2); + break; + case IP6MOPT_ALTCOA: + if (len - i < IP6MOPT_ALTCOA_MINLEN) { + printf("(altcoa: trunc)"); + goto trunc; + } + printf("(alt-CoA: %s)", ip6addr_string(&bp[i+2])); + break; + case IP6MOPT_NONCEID: + if (len - i < IP6MOPT_NONCEID_MINLEN) { + printf("(ni: trunc)"); + goto trunc; + } + printf("(ni: ho=0x%04x co=0x%04x)", + EXTRACT_16BITS(&bp[i+2]), + EXTRACT_16BITS(&bp[i+4])); + break; + case IP6MOPT_AUTH: + if (len - i < IP6MOPT_AUTH_MINLEN) { + printf("(auth: trunc)"); + goto trunc; + } + printf("(auth)"); + break; + default: + if (len - i < IP6MOPT_MINLEN) { + printf("(sopt_type %d: trunc)", bp[i]); + goto trunc; + } + printf("(type-0x%02x: len=%d)", bp[i], bp[i + 1]); + break; + } + } + return; + +trunc: + printf("[trunc] "); +} + +/* + * Mobility Header + */ +int +mobility_print(const u_char *bp, const u_char *bp2) +{ + const struct ip6_mobility *mh; + const struct ip6_hdr *ip6; + const u_char *ep; + int mhlen, hlen, type; + + mh = (struct ip6_mobility *)bp; + ip6 = (struct ip6_hdr *)bp2; + + /* 'ep' points to the end of available data. */ + ep = snapend; + + if (!TTEST(mh->ip6m_len)) { + /* + * There's not enough captured data to include the + * mobility header length. + * + * Our caller expects us to return the length, however, + * so return a value that will run to the end of the + * captured data. + * + * XXX - "ip6_print()" doesn't do anything with the + * returned length, however, as it breaks out of the + * header-processing loop. + */ + mhlen = ep - bp; + goto trunc; + } + mhlen = (int)((mh->ip6m_len + 1) << 3); + + /* XXX ip6m_cksum */ + + TCHECK(mh->ip6m_type); + type = mh->ip6m_type; + switch (type) { + case IP6M_BINDING_REQUEST: + printf("mobility: BRR"); + hlen = IP6M_MINLEN; + break; + case IP6M_HOME_TEST_INIT: + case IP6M_CAREOF_TEST_INIT: + printf("mobility: %soTI", + type == IP6M_HOME_TEST_INIT ? "H" : "C"); + hlen = IP6M_MINLEN; + if (vflag) { + TCHECK2(*mh, hlen + 8); + printf(" %s Init Cookie=%08x:%08x", + type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of", + EXTRACT_32BITS(&bp[hlen]), + EXTRACT_32BITS(&bp[hlen + 4])); + } + hlen += 8; + break; + case IP6M_HOME_TEST: + case IP6M_CAREOF_TEST: + printf("mobility: %soT", + type == IP6M_HOME_TEST ? "H" : "C"); + TCHECK(mh->ip6m_data16[0]); + printf(" nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])); + hlen = IP6M_MINLEN; + if (vflag) { + TCHECK2(*mh, hlen + 8); + printf(" %s Init Cookie=%08x:%08x", + type == IP6M_HOME_TEST ? "Home" : "Care-of", + EXTRACT_32BITS(&bp[hlen]), + EXTRACT_32BITS(&bp[hlen + 4])); + } + hlen += 8; + if (vflag) { + TCHECK2(*mh, hlen + 8); + printf(" %s Keygen Token=%08x:%08x", + type == IP6M_HOME_TEST ? "Home" : "Care-of", + EXTRACT_32BITS(&bp[hlen]), + EXTRACT_32BITS(&bp[hlen + 4])); + } + hlen += 8; + break; + case IP6M_BINDING_UPDATE: + printf("mobility: BU"); + TCHECK(mh->ip6m_data16[0]); + printf(" seq#=%d", EXTRACT_16BITS(&mh->ip6m_data16[0])); + hlen = IP6M_MINLEN; + TCHECK2(*mh, hlen + 1); + if (bp[hlen] & 0xf0) + printf(" "); + if (bp[hlen] & 0x80) + printf("A"); + if (bp[hlen] & 0x40) + printf("H"); + if (bp[hlen] & 0x20) + printf("L"); + if (bp[hlen] & 0x10) + printf("K"); + /* Reserved (4bits) */ + hlen += 1; + /* Reserved (8bits) */ + hlen += 1; + TCHECK2(*mh, hlen + 2); + /* units of 4 secs */ + printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2); + hlen += 2; + break; + case IP6M_BINDING_ACK: + printf("mobility: BA"); + TCHECK(mh->ip6m_data8[0]); + printf(" status=%d", mh->ip6m_data8[0]); + if (mh->ip6m_data8[1] & 0x80) + printf(" K"); + /* Reserved (7bits) */ + hlen = IP6M_MINLEN; + TCHECK2(*mh, hlen + 2); + printf(" seq#=%d", EXTRACT_16BITS(&bp[hlen])); + hlen += 2; + TCHECK2(*mh, hlen + 2); + /* units of 4 secs */ + printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2); + hlen += 2; + break; + case IP6M_BINDING_ERROR: + printf("mobility: BE"); + TCHECK(mh->ip6m_data8[0]); + printf(" status=%d", mh->ip6m_data8[0]); + /* Reserved */ + hlen = IP6M_MINLEN; + TCHECK2(*mh, hlen + 16); + printf(" homeaddr %s", ip6addr_string(&bp[hlen])); + hlen += 16; + break; + default: + printf("mobility: type-#%d len=%d", type, mh->ip6m_len); + return(mhlen); + break; + } + if (vflag) + mobility_opt_print(&bp[hlen], mhlen - hlen); + + return(mhlen); + + trunc: + fputs("[|MOBILITY]", stdout); + return(mhlen); +} +#endif /* INET6 */ diff --git a/contrib/tcpdump/print-mpls.c b/contrib/tcpdump/print-mpls.c index ed7defb..6e936c8 100644 --- a/contrib/tcpdump/print-mpls.c +++ b/contrib/tcpdump/print-mpls.c @@ -27,24 +27,19 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.2.4.1 2002/05/07 18:36:28 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.8.2.2 2003/11/16 08:51:34 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include "addrtoname.h" #include "interface.h" @@ -87,15 +82,14 @@ mpls_print(const u_char *bp, u_int length) TCHECK2(*p, sizeof(v)); v = EXTRACT_32BITS(p); printf(" ("); /*)*/ - printf("label 0x%x", MPLS_LABEL(v)); + printf("label %u", MPLS_LABEL(v)); if (vflag && MPLS_LABEL(v) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0])) - printf("(%s)", mpls_labelname[MPLS_LABEL(v)]); - if (MPLS_EXP(v)) - printf(" exp 0x%x", MPLS_EXP(v)); + printf(" (%s)", mpls_labelname[MPLS_LABEL(v)]); + printf(", exp %u", MPLS_EXP(v)); if (MPLS_STACK(v)) - printf("[S]"); - printf(" TTL %u", MPLS_TTL(v)); + printf(", [S]"); + printf(", ttl %u", MPLS_TTL(v)); /*(*/ printf(")"); @@ -104,6 +98,7 @@ mpls_print(const u_char *bp, u_int length) switch (MPLS_LABEL(v)) { case 0: /* IPv4 explicit NULL label */ + case 3: /* IPv4 implicit NULL label */ ip_print(p, length - (p - bp)); break; #ifdef INET6 @@ -113,12 +108,89 @@ mpls_print(const u_char *bp, u_int length) #endif default: /* - * Since there's no indication of protocol in MPLS label - * encoding, we can print nothing further. + * Generally there's no indication of protocol in MPLS label + * encoding, however draft-hsmit-isis-aal5mux-00.txt describes + * a technique that looks at the first payload byte if the BOS (bottom of stack) + * bit is set and tries to determine the network layer protocol + * 0x45-0x4f is IPv4 + * 0x60-0x6f is IPv6 + * 0x81-0x83 is OSI (CLNP,ES-IS,IS-IS) + * this technique is sometimes known as NULL encapsulation + * and decoding is particularly useful for control-plane traffic [BGP] + * which cisco by default sends MPLS encapsulated */ - return; + + if (MPLS_STACK(v)) { /* only do this if the stack bit is set */ + switch(*p) { + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4a: + case 0x4b: + case 0x4c: + case 0x4d: + case 0x4e: + case 0x4f: + if (vflag>0) { + printf("\n\t"); + ip_print(p, length - (p - bp)); + } + else printf(", IP, length: %u",length); + break; +#ifdef INET6 + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6a: + case 0x6b: + case 0x6c: + case 0x6d: + case 0x6e: + case 0x6f: + if (vflag>0) { + printf("\n\t"); + ip6_print(p, length - (p - bp)); + } + else printf(", IPv6, length: %u",length); + break; +#endif + case 0x81: + case 0x82: + case 0x83: + if (vflag>0) { + printf("\n\t"); + isoclns_print(p, length - (p - bp), length - (p - bp)); + } + else printf(", OSI, length: %u",length); + break; + default: + /* ok bail out - we did not figure out what it is*/ + break; + } + } + return; } trunc: printf("[|MPLS]"); } + +/* + * draft-ietf-mpls-lsp-ping-02.txt + */ +void +mpls_lsp_ping_print(const u_char *pptr, u_int length) +{ + printf("UDP, LSP-PING, length: %u", length); + if (vflag >1) + print_unknown_data(pptr,"\n\t ", length); +} diff --git a/contrib/tcpdump/print-msdp.c b/contrib/tcpdump/print-msdp.c index 2ffc34f..0606574 100644 --- a/contrib/tcpdump/print-msdp.c +++ b/contrib/tcpdump/print-msdp.c @@ -16,19 +16,18 @@ * FOR A PARTICULAR PURPOSE. */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.2 2001/12/10 08:06:40 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.4.2.2 2003/11/16 08:51:34 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include <tcpdump-stdinc.h> + #include <stdio.h> #include <stdlib.h> -#include <unistd.h> - -#include <netinet/in.h> #include "interface.h" #include "addrtoname.h" @@ -53,7 +52,7 @@ msdp_print(const unsigned char *sp, u_int length) type = *sp; len = EXTRACT_16BITS(sp + 1); if (len > 1400 || vflag) - printf(" [len %d]", len); + printf(" [len %u]", len); if (len < 3) goto trunc; sp += 3; @@ -66,8 +65,8 @@ msdp_print(const unsigned char *sp, u_int length) else (void)printf(" SA-Response"); TCHECK(*sp); - (void)printf(" %d entries", *sp); - if (*sp * 12 + 8 < len) { + (void)printf(" %u entries", *sp); + if ((u_int)((*sp * 12) + 8) < len) { (void)printf(" [w/data]"); if (vflag > 1) { (void)printf(" "); diff --git a/contrib/tcpdump/print-netbios.c b/contrib/tcpdump/print-netbios.c index c834729..c25f343 100644 --- a/contrib/tcpdump/print-netbios.c +++ b/contrib/tcpdump/print-netbios.c @@ -23,18 +23,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.17 2000/09/29 04:58:43 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.18.2.2 2003/11/16 08:51:35 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdlib.h> #include <stdio.h> diff --git a/contrib/tcpdump/print-ospf.c b/contrib/tcpdump/print-ospf.c index 800a44d..d239caf 100644 --- a/contrib/tcpdump/print-ospf.c +++ b/contrib/tcpdump/print-ospf.c @@ -22,245 +22,271 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.31 2001/06/28 04:34:51 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.45.2.4 2004/03/24 02:44:30 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> #include <stdio.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" +#include "gmpls.h" #include "ospf.h" #include "ip.h" -struct bits { - u_int32_t bit; - const char *str; +static struct tok ospf_option_values[] = { + { OSPF_OPTION_T, "TOS" }, + { OSPF_OPTION_E, "External" }, + { OSPF_OPTION_MC, "Multicast" }, + { OSPF_OPTION_NP, "NSSA" }, + { OSPF_OPTION_EA, "Advertise External" }, + { OSPF_OPTION_DC, "Demand Circuit" }, + { OSPF_OPTION_O, "Opaque" }, + { 0, NULL } }; -static const struct bits ospf_option_bits[] = { - { OSPF_OPTION_T, "T" }, - { OSPF_OPTION_E, "E" }, - { OSPF_OPTION_MC, "MC" }, +static struct tok ospf_authtype_values[] = { + { OSPF_AUTH_NONE, "none" }, + { OSPF_AUTH_NONE, "simple" }, + { OSPF_AUTH_MD5, "MD5" }, { 0, NULL } }; -static const struct bits ospf_rla_flag_bits[] = { - { RLA_FLAG_B, "B" }, - { RLA_FLAG_E, "E" }, - { RLA_FLAG_W1, "W1" }, +static struct tok ospf_rla_flag_values[] = { + { RLA_FLAG_B, "ABR" }, + { RLA_FLAG_E, "ASBR" }, + { RLA_FLAG_W1, "Virtual" }, { RLA_FLAG_W2, "W2" }, { 0, NULL } }; static struct tok type2str[] = { - { OSPF_TYPE_UMD, "umd" }, - { OSPF_TYPE_HELLO, "hello" }, - { OSPF_TYPE_DB, "dd" }, - { OSPF_TYPE_LSR, "ls_req" }, - { OSPF_TYPE_LSU, "ls_upd" }, - { OSPF_TYPE_LSA, "ls_ack" }, + { OSPF_TYPE_UMD, "UMD" }, + { OSPF_TYPE_HELLO, "Hello" }, + { OSPF_TYPE_DD, "Database Description" }, + { OSPF_TYPE_LS_REQ, "LS-Request" }, + { OSPF_TYPE_LS_UPDATE, "LS-Update" }, + { OSPF_TYPE_LS_ACK, "LS-Ack" }, { 0, NULL } }; -static char tstr[] = " [|ospf]"; - -/* Forwards */ -static inline void ospf_print_seqage(u_int32_t, time_t); -static inline void ospf_print_bits(const struct bits *, u_char); -static void ospf_print_ls_type(u_int, const struct in_addr *, - const struct in_addr *, const char *); -static int ospf_print_lshdr(const struct lsa_hdr *); -static int ospf_print_lsa(const struct lsa *); -static int ospf_decode_v2(const struct ospfhdr *, const u_char *); - -static inline void -ospf_print_seqage(register u_int32_t seq, register time_t us) -{ - register time_t sec = us % 60; - register time_t mins = (us / 60) % 60; - register time_t hour = us / 3600; - - printf(" S %X age ", seq); - if (hour) - printf("%u:%02u:%02u", - (u_int32_t) hour, (u_int32_t) mins, (u_int32_t) sec); - else if (mins) - printf("%u:%02u", (u_int32_t) mins, (u_int32_t) sec); - else - printf("%u", (u_int32_t) sec); -} - - -static inline void -ospf_print_bits(register const struct bits *bp, register u_char options) -{ - register char sep = ' '; - - do { - if (options & bp->bit) { - printf("%c%s", sep, bp->str); - sep = '/'; - } - } while ((++bp)->bit); -} +static struct tok lsa_values[] = { + { LS_TYPE_ROUTER, "Router" }, + { LS_TYPE_NETWORK, "Network" }, + { LS_TYPE_SUM_IP, "Summary" }, + { LS_TYPE_SUM_ABR, "ASBR Summary" }, + { LS_TYPE_ASE, "External" }, + { LS_TYPE_GROUP, "Multicast Group" }, + { LS_TYPE_NSSA, "NSSA" }, + { LS_TYPE_OPAQUE_LL, "Link Local Opaque" }, + { LS_TYPE_OPAQUE_AL, "Area Local Opaque" }, + { LS_TYPE_OPAQUE_DW, "Domain Wide Opaque" }, + { 0, NULL } +}; -static void -ospf_print_ls_type(register u_int ls_type, - register const struct in_addr *ls_stateid, - register const struct in_addr *ls_router, register const char *fmt) -{ +static struct tok ospf_dd_flag_values[] = { + { OSPF_DB_INIT, "Init" }, + { OSPF_DB_MORE, "More" }, + { OSPF_DB_MASTER, "Master" }, + { 0, NULL } +}; - switch (ls_type) { +static struct tok lsa_opaque_values[] = { + { LS_OPAQUE_TYPE_TE, "Traffic Engineering" }, + { LS_OPAQUE_TYPE_GRACE, "Graceful restart" }, + { 0, NULL } +}; - case LS_TYPE_ROUTER: - printf(" rtr %s ", ipaddr_string(ls_router)); - break; +static struct tok lsa_opaque_te_tlv_values[] = { + { LS_OPAQUE_TE_TLV_ROUTER, "Router Address" }, + { LS_OPAQUE_TE_TLV_LINK, "Link" }, + { 0, NULL } +}; - case LS_TYPE_NETWORK: - printf(" net dr %s if %s", - ipaddr_string(ls_router), - ipaddr_string(ls_stateid)); - break; +static struct tok lsa_opaque_te_link_tlv_subtlv_values[] = { + { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE, "Link Type" }, + { LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID, "Link ID" }, + { LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP, "Local Interface IP address" }, + { LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP, "Remote Interface IP address" }, + { LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC, "Traffic Engineering Metric" }, + { LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW, "Maximum Bandwidth" }, + { LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW, "Maximum Reservable Bandwidth" }, + { LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW, "Unreserved Bandwidth" }, + { LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP, "Administrative Group" }, + { LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" }, + { LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE, "Link Protection Type" }, + { LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR, "Interface Switching Capability" }, + { LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP, "Shared Risk Link Group" }, + { 0, NULL } +}; - case LS_TYPE_SUM_IP: - printf(" sum %s abr %s", - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP 1 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA 2 /* rfc3630 */ - case LS_TYPE_SUM_ABR: - printf(" abr %s rtr %s", - ipaddr_string(ls_router), - ipaddr_string(ls_stateid)); - break; +static struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = { + { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP, "Point-to-point" }, + { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA, "Multi-Access" }, + { 0, NULL } +}; - case LS_TYPE_ASE: - printf(" ase %s asbr %s", - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; +static char tstr[] = " [|ospf]"; - case LS_TYPE_GROUP: - printf(" group %s rtr %s", - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; +#ifdef WIN32 +#define inline __inline +#endif /* WIN32 */ - default: - putchar(' '); - printf(fmt, ls_type); - break; - } -} +static int ospf_print_lshdr(const struct lsa_hdr *); +static const u_char *ospf_print_lsa(const struct lsa *); +static int ospf_decode_v2(const struct ospfhdr *, const u_char *); static int ospf_print_lshdr(register const struct lsa_hdr *lshp) { + u_int ls_length; + + TCHECK(lshp->ls_length); + ls_length = EXTRACT_16BITS(&lshp->ls_length); + if (ls_length < sizeof(struct lsa_hdr)) { + printf("\n\t Bogus length %u < %lu", ls_length, + (unsigned long)sizeof(struct lsa_hdr)); + return(-1); + } - TCHECK(lshp->ls_type); - printf(" {"); /* } (ctags) */ + TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */ + printf("\n\t Advertising Router: %s, seq 0x%08x, age %us, length: %u", + ipaddr_string(&lshp->ls_router), + EXTRACT_32BITS(&lshp->ls_seq), + EXTRACT_16BITS(&lshp->ls_age), + ls_length-(u_int)sizeof(struct lsa_hdr)); + + TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */ + switch (lshp->ls_type) { + /* the LSA header for opaque LSAs was slightly changed */ + case LS_TYPE_OPAQUE_LL: + case LS_TYPE_OPAQUE_AL: + case LS_TYPE_OPAQUE_DW: + printf("\n\t %s LSA (%d), Opaque-Type: %s LSA (%u), Opaque-ID: %u", + tok2str(lsa_values,"unknown",lshp->ls_type), + lshp->ls_type, + + tok2str(lsa_opaque_values, + "unknown", + *(&lshp->un_lsa_id.opaque_field.opaque_type)), + *(&lshp->un_lsa_id.opaque_field.opaque_type), + EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id) + + ); + break; + + /* all other LSA types use regular style LSA headers */ + default: + printf("\n\t %s LSA (%d), LSA-ID: %s", + tok2str(lsa_values,"unknown",lshp->ls_type), + lshp->ls_type, + ipaddr_string(&lshp->un_lsa_id.lsa_id)); + break; + } - TCHECK(lshp->ls_options); - ospf_print_bits(ospf_option_bits, lshp->ls_options); - TCHECK(lshp->ls_seq); - ospf_print_seqage(ntohl(lshp->ls_seq), ntohs(lshp->ls_age)); - ospf_print_ls_type(lshp->ls_type, &lshp->ls_stateid, &lshp->ls_router, - "ls_type %d"); + TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */ + printf("\n\t Options: [%s]", bittok2str(ospf_option_values,"none",lshp->ls_options)); - return (0); + return (ls_length); trunc: - return (1); + return (-1); } - /* - * Print a single link state advertisement. If truncated return 1, else 0. + * Print a single link state advertisement. If truncated or if LSA length + * field is less than the length of the LSA header, return NULl, else + * return pointer to data past end of LSA. */ -static int +static const u_int8_t * ospf_print_lsa(register const struct lsa *lsap) { - register const u_char *ls_end; + register const u_int8_t *ls_end; register const struct rlalink *rlp; register const struct tos_metric *tosp; register const struct in_addr *ap; register const struct aslametric *almp; register const struct mcla *mcp; register const u_int32_t *lp; - register int j, k; + register int j, k, tlv_type, tlv_length, subtlv_type, subtlv_length, priority_level; + register int ls_length; + const u_int8_t *tptr; + int count_srlg; + union { /* int to float conversion buffer for several subTLVs */ + float f; + u_int32_t i; + } bw; + + tptr = (u_int8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */ + ls_length = ospf_print_lshdr(&lsap->ls_hdr); + if (ls_length == -1) + return(NULL); + ls_end = (u_int8_t *)lsap + ls_length; + ls_length -= sizeof(struct lsa_hdr); - if (ospf_print_lshdr(&lsap->ls_hdr)) - return (1); - TCHECK(lsap->ls_hdr.ls_length); - ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length); switch (lsap->ls_hdr.ls_type) { case LS_TYPE_ROUTER: TCHECK(lsap->lsa_un.un_rla.rla_flags); - ospf_print_bits(ospf_rla_flag_bits, - lsap->lsa_un.un_rla.rla_flags); + printf("\n\t Router LSA Options: [%s]", bittok2str(ospf_rla_flag_values,"none",lsap->lsa_un.un_rla.rla_flags)); TCHECK(lsap->lsa_un.un_rla.rla_count); - j = ntohs(lsap->lsa_un.un_rla.rla_count); + j = EXTRACT_16BITS(&lsap->lsa_un.un_rla.rla_count); TCHECK(lsap->lsa_un.un_rla.rla_link); rlp = lsap->lsa_un.un_rla.rla_link; while (j--) { TCHECK(*rlp); - printf(" {"); /* } (ctags) */ switch (rlp->link_type) { case RLA_TYPE_VIRTUAL: - printf(" virt"); - /* Fall through */ + printf("\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s", + ipaddr_string(&rlp->link_id), + ipaddr_string(&rlp->link_data)); + break; case RLA_TYPE_ROUTER: - printf(" nbrid %s if %s", + printf("\n\t Neighbor Router-ID: %s, Interface Address: %s", ipaddr_string(&rlp->link_id), ipaddr_string(&rlp->link_data)); break; case RLA_TYPE_TRANSIT: - printf(" dr %s if %s", + printf("\n\t Neighbor Network-ID: %s, Interface Address: %s", ipaddr_string(&rlp->link_id), ipaddr_string(&rlp->link_data)); break; case RLA_TYPE_STUB: - printf(" net %s mask %s", + printf("\n\t Stub Network: %s, Mask: %s", ipaddr_string(&rlp->link_id), ipaddr_string(&rlp->link_data)); break; default: - /* { (ctags) */ - printf(" ??RouterLinksType %d?? }", + printf("\n\t Unknown Router Link Type (%u)", rlp->link_type); - return (0); + return (ls_end); } - printf(" tos 0 metric %d", ntohs(rlp->link_tos0metric)); + printf(", tos 0, metric: %d", EXTRACT_16BITS(&rlp->link_tos0metric)); tosp = (struct tos_metric *) ((sizeof rlp->link_tos0metric) + (u_char *) rlp); for (k = 0; k < (int) rlp->link_toscount; ++k, ++tosp) { TCHECK(*tosp); - printf(" tos %d metric %d", + printf(", tos %d, metric: %d", tosp->tos_type, - ntohs(tosp->tos_metric)); + EXTRACT_16BITS(&tosp->tos_metric)); } - /* { (ctags) */ - printf(" }"); rlp = (struct rlalink *)((u_char *)(rlp + 1) + ((rlp->link_toscount) * sizeof(*tosp))); } @@ -268,31 +294,53 @@ ospf_print_lsa(register const struct lsa *lsap) case LS_TYPE_NETWORK: TCHECK(lsap->lsa_un.un_nla.nla_mask); - printf(" mask %s rtrs", + printf("\n\t Mask %s\n\t Connected Routers:", ipaddr_string(&lsap->lsa_un.un_nla.nla_mask)); ap = lsap->lsa_un.un_nla.nla_router; while ((u_char *)ap < ls_end) { TCHECK(*ap); - printf(" %s", ipaddr_string(ap)); + printf("\n\t %s", ipaddr_string(ap)); ++ap; } break; case LS_TYPE_SUM_IP: TCHECK(lsap->lsa_un.un_nla.nla_mask); - printf(" mask %s", + printf("\n\t Mask %s", ipaddr_string(&lsap->lsa_un.un_sla.sla_mask)); - /* Fall through */ + TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); + lp = lsap->lsa_un.un_sla.sla_tosmetric; + /* suppress tos if its not supported */ + if(!((lsap->ls_hdr.ls_options)&OSPF_OPTION_T)) { + printf(", metric: %u", EXTRACT_32BITS(lp)&SLA_MASK_METRIC); + break; + } + while ((u_char *)lp < ls_end) { + register u_int32_t ul; + + TCHECK(*lp); + ul = EXTRACT_32BITS(lp); + printf(", tos %d metric %d", + (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, + ul & SLA_MASK_METRIC); + ++lp; + } + break; case LS_TYPE_SUM_ABR: TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); lp = lsap->lsa_un.un_sla.sla_tosmetric; + /* suppress tos if its not supported */ + if(!((lsap->ls_hdr.ls_options)&OSPF_OPTION_T)) { + printf(", metric: %u", EXTRACT_32BITS(lp)&SLA_MASK_METRIC); + break; + } while ((u_char *)lp < ls_end) { register u_int32_t ul; TCHECK(*lp); - ul = ntohl(*lp); - printf(" tos %d metric %d", + ul = EXTRACT_32BITS(lp); + printf(", tos %d metric %d", (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, ul & SLA_MASK_METRIC); ++lp; @@ -301,7 +349,7 @@ ospf_print_lsa(register const struct lsa *lsap) case LS_TYPE_ASE: TCHECK(lsap->lsa_un.un_nla.nla_mask); - printf(" mask %s", + printf("\n\t Mask %s", ipaddr_string(&lsap->lsa_un.un_asla.asla_mask)); TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); @@ -310,19 +358,23 @@ ospf_print_lsa(register const struct lsa *lsap) register u_int32_t ul; TCHECK(almp->asla_tosmetric); - ul = ntohl(almp->asla_tosmetric); - printf(" type %d tos %d metric %d", + ul = EXTRACT_32BITS(&almp->asla_tosmetric); + printf(", type %d, tos %d metric:", (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1, - (ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS, - (ul & ASLA_MASK_METRIC)); + (ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS); + if ((ul & ASLA_MASK_METRIC)==0xffffff) + printf(" infinite"); + else + printf(" %d", (ul & ASLA_MASK_METRIC)); + TCHECK(almp->asla_forward); if (almp->asla_forward.s_addr) { - printf(" forward %s", + printf(", forward %s", ipaddr_string(&almp->asla_forward)); } TCHECK(almp->asla_tag); if (almp->asla_tag.s_addr) { - printf(" tag %s", + printf(", tag %s", ipaddr_string(&almp->asla_tag)); } ++almp; @@ -334,33 +386,205 @@ ospf_print_lsa(register const struct lsa *lsap) mcp = lsap->lsa_un.un_mcla; while ((u_char *)mcp < ls_end) { TCHECK(mcp->mcla_vid); - switch (ntohl(mcp->mcla_vtype)) { + switch (EXTRACT_32BITS(&mcp->mcla_vtype)) { case MCLA_VERTEX_ROUTER: - printf(" rtr rtrid %s", + printf("\n\t Router Router-ID %s", ipaddr_string(&mcp->mcla_vid)); break; case MCLA_VERTEX_NETWORK: - printf(" net dr %s", + printf("\n\t Network Designated Router %s", ipaddr_string(&mcp->mcla_vid)); break; default: - printf(" ??VertexType %u??", - (u_int32_t)ntohl(mcp->mcla_vtype)); + printf("\n\t unknown VertexType (%u)", + EXTRACT_32BITS(&mcp->mcla_vtype)); break; } ++mcp; } - } + break; - /* { (ctags) */ - fputs(" }", stdout); - return (0); + case LS_TYPE_OPAQUE_LL: /* fall through */ + case LS_TYPE_OPAQUE_AL: + case LS_TYPE_OPAQUE_DW: + + switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) { + case LS_OPAQUE_TYPE_TE: + tptr = (u_int8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type); + + while (ls_length != 0) { + TCHECK2(*tptr, 4); + if (ls_length < 4) { + printf("\n\t Remaining LS length %u < 4", ls_length); + return(ls_end); + } + tlv_type = EXTRACT_16BITS(tptr); + tlv_length = EXTRACT_16BITS(tptr+2); + tptr+=4; + ls_length-=4; + + printf("\n\t %s TLV (%u), length: %u", + tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type), + tlv_type, + tlv_length); + + if (tlv_length > ls_length) { + printf("\n\t Bogus length %u > %u", tlv_length, + ls_length); + return(ls_end); + } + ls_length-=tlv_length; + switch(tlv_type) { + case LS_OPAQUE_TE_TLV_LINK: + while (tlv_length != 0) { + if (tlv_length < 4) { + printf("\n\t Remaining TLV length %u < 4", + tlv_length); + return(ls_end); + } + TCHECK2(*tptr, 4); + subtlv_type = EXTRACT_16BITS(tptr); + subtlv_length = EXTRACT_16BITS(tptr+2); + tptr+=4; + tlv_length-=4; + + printf("\n\t %s subTLV (%u), length: %u", + tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type), + subtlv_type, + subtlv_length); + + TCHECK2(*tptr, subtlv_length); + switch(subtlv_type) { + case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP: + printf(", 0x%08x", EXTRACT_32BITS(tptr)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID: + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID: + printf(", %s (0x%08x)", + ipaddr_string(tptr), + EXTRACT_32BITS(tptr)); + if (subtlv_length == 8) /* draft-ietf-ccamp-ospf-gmpls-extensions */ + printf(", %s (0x%08x)", + ipaddr_string(tptr+4), + EXTRACT_32BITS(tptr+4)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP: + case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP: + printf(", %s", ipaddr_string(tptr)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW: + case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW: + bw.i = EXTRACT_32BITS(tptr); + printf(", %.3f Mbps", bw.f*8/1000000 ); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW: + for (priority_level = 0; priority_level < 8; priority_level++) { + bw.i = EXTRACT_32BITS(tptr+priority_level*4); + printf("\n\t\tpriority level %d: %.3f Mbps", + priority_level, + bw.f*8/1000000 ); + } + break; + case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC: + printf(", Metric %u", EXTRACT_32BITS(tptr)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE: + printf(", %s, Priority %u", + bittok2str(gmpls_link_prot_values, "none", *tptr), + *(tptr+1)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR: + printf("\n\t\tInterface Switching Capability: %s", + tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))); + printf("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:", + tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); + for (priority_level = 0; priority_level < 8; priority_level++) { + bw.i = EXTRACT_32BITS(tptr+4+(priority_level*4)); + printf("\n\t\t priority level %d: %.3f Mbps", + priority_level, + bw.f*8/1000000 ); + } + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE: + printf(", %s (%u)", + tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr), + *tptr); + break; + + case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP: + count_srlg = subtlv_length / 4; + if (count_srlg != 0) + printf("\n\t\t Shared risk group: "); + while (count_srlg > 0) { + bw.i = EXTRACT_32BITS(tptr); + printf("%d",bw.i); + tptr+=4; + count_srlg--; + if (count_srlg > 0) + printf(", "); + } + break; + + default: + if (vflag <= 1) { + if(!print_unknown_data(tptr,"\n\t\t",subtlv_length)) + return(ls_end); + } + break; + } + /* in OSPF everything has to be 32-bit aligned, including TLVs */ + if (subtlv_length%4 != 0) + subtlv_length+=4-(subtlv_length%4); + + tlv_length-=subtlv_length; + tptr+=subtlv_length; + + } + break; + + case LS_OPAQUE_TE_TLV_ROUTER: + if (tlv_length < 4) { + printf("\n\t TLV length %u < 4", tlv_length); + return(ls_end); + } + TCHECK2(*tptr, 4); + printf(", %s", ipaddr_string(tptr)); + break; + + default: + if (vflag <= 1) { + if(!print_unknown_data(tptr,"\n\t ",tlv_length)) + return(ls_end); + } + break; + } + tptr+=tlv_length; + } + break; + } + break; + default: + if (vflag <= 1) { + if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown, + "\n\t ", ls_length)) + return(ls_end); + } + break; + } + + /* do we want to see an additionally hexdump ? */ + if (vflag> 1) + if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown, + "\n\t ", ls_length)) { + return(ls_end); + } + + return (ls_end); trunc: - fputs(" }", stdout); - return (1); + return (NULL); } static int @@ -371,8 +595,7 @@ ospf_decode_v2(register const struct ospfhdr *op, register const struct lsr *lsrp; register const struct lsa_hdr *lshp; register const struct lsa *lsap; - register char sep; - register int i; + register u_int32_t lsa_count,lsa_count_max; switch (op->ospf_type) { @@ -384,114 +607,105 @@ ospf_decode_v2(register const struct ospfhdr *op, break; case OSPF_TYPE_HELLO: - if (vflag) { - TCHECK(op->ospf_hello.hello_deadint); - ospf_print_bits(ospf_option_bits, - op->ospf_hello.hello_options); - printf(" mask %s int %d pri %d dead %u", - ipaddr_string(&op->ospf_hello.hello_mask), - ntohs(op->ospf_hello.hello_helloint), - op->ospf_hello.hello_priority, - (u_int32_t)ntohl(op->ospf_hello.hello_deadint)); - } + printf("\n\tOptions: [%s]", + bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)); + + TCHECK(op->ospf_hello.hello_deadint); + printf("\n\t Hello Timer: %us, Dead Timer %us, Mask: %s, Priority: %u", + EXTRACT_16BITS(&op->ospf_hello.hello_helloint), + EXTRACT_32BITS(&op->ospf_hello.hello_deadint), + ipaddr_string(&op->ospf_hello.hello_mask), + op->ospf_hello.hello_priority); + TCHECK(op->ospf_hello.hello_dr); if (op->ospf_hello.hello_dr.s_addr != 0) - printf(" dr %s", + printf("\n\t Designated Router %s", ipaddr_string(&op->ospf_hello.hello_dr)); + TCHECK(op->ospf_hello.hello_bdr); if (op->ospf_hello.hello_bdr.s_addr != 0) - printf(" bdr %s", + printf(", Backup Designated Router %s", ipaddr_string(&op->ospf_hello.hello_bdr)); - if (vflag) { - ap = op->ospf_hello.hello_neighbor; - if ((u_char *)ap < dataend) - printf(" nbrs"); - while ((u_char *)ap < dataend) { - TCHECK(*ap); - printf(" %s", ipaddr_string(ap)); - ++ap; - } - } + + ap = op->ospf_hello.hello_neighbor; + if ((u_char *)ap < dataend) + printf("\n\t Neighbor List:"); + while ((u_char *)ap < dataend) { + TCHECK(*ap); + printf("\n\t %s", ipaddr_string(ap)); + ++ap; + } break; /* HELLO */ - case OSPF_TYPE_DB: + case OSPF_TYPE_DD: TCHECK(op->ospf_db.db_options); - ospf_print_bits(ospf_option_bits, op->ospf_db.db_options); - sep = ' '; + printf("\n\tOptions: [%s]", + bittok2str(ospf_option_values,"none",op->ospf_db.db_options)); TCHECK(op->ospf_db.db_flags); - if (op->ospf_db.db_flags & OSPF_DB_INIT) { - printf("%cI", sep); - sep = '/'; - } - if (op->ospf_db.db_flags & OSPF_DB_MORE) { - printf("%cM", sep); - sep = '/'; - } - if (op->ospf_db.db_flags & OSPF_DB_MASTER) { - printf("%cMS", sep); - sep = '/'; - } - TCHECK(op->ospf_db.db_seq); - printf(" S %X", (u_int32_t)ntohl(op->ospf_db.db_seq)); + printf(", DD Flags: [%s]", + bittok2str(ospf_dd_flag_values,"none",op->ospf_db.db_flags)); if (vflag) { /* Print all the LS adv's */ lshp = op->ospf_db.db_lshdr; - - while (!ospf_print_lshdr(lshp)) { - /* { (ctags) */ - printf(" }"); + while (ospf_print_lshdr(lshp) != -1) { ++lshp; } } break; - case OSPF_TYPE_LSR: - if (vflag) { - lsrp = op->ospf_lsr; - while ((u_char *)lsrp < dataend) { - TCHECK(*lsrp); - printf(" {"); /* } (ctags) */ - ospf_print_ls_type(ntohl(lsrp->ls_type), - &lsrp->ls_stateid, - &lsrp->ls_router, - "LinkStateType %d"); - /* { (ctags) */ - printf(" }"); - ++lsrp; - } - } + case OSPF_TYPE_LS_REQ: + lsrp = op->ospf_lsr; + while ((u_char *)lsrp < dataend) { + TCHECK(*lsrp); + + printf("\n\t Advertising Router: %s, %s LSA (%u)", + ipaddr_string(&lsrp->ls_router), + tok2str(lsa_values,"unknown",EXTRACT_32BITS(lsrp->ls_type)), + EXTRACT_32BITS(&lsrp->ls_type)); + + switch (EXTRACT_32BITS(lsrp->ls_type)) { + /* the LSA header for opaque LSAs was slightly changed */ + case LS_TYPE_OPAQUE_LL: + case LS_TYPE_OPAQUE_AL: + case LS_TYPE_OPAQUE_DW: + printf(", Opaque-Type: %s LSA (%u), Opaque-ID: %u", + tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type), + lsrp->un_ls_stateid.opaque_field.opaque_type, + EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id)); + break; + default: + printf(", LSA-ID: %s", + ipaddr_string(&lsrp->un_ls_stateid.ls_stateid)); + break; + } + + ++lsrp; + } break; - case OSPF_TYPE_LSU: - if (vflag) { - lsap = op->ospf_lsu.lsu_lsa; - TCHECK(op->ospf_lsu.lsu_count); - i = ntohl(op->ospf_lsu.lsu_count); - while (i--) { - if (ospf_print_lsa(lsap)) - goto trunc; - lsap = (struct lsa *)((u_char *)lsap + - ntohs(lsap->ls_hdr.ls_length)); - } - } + case OSPF_TYPE_LS_UPDATE: + lsap = op->ospf_lsu.lsu_lsa; + TCHECK(op->ospf_lsu.lsu_count); + lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count); + printf(", %d LSA%s",lsa_count_max, lsa_count_max > 1 ? "s" : ""); + for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) { + printf("\n\t LSA #%u",lsa_count); + lsap = (const struct lsa *)ospf_print_lsa(lsap); + if (lsap == NULL) + goto trunc; + } break; - - case OSPF_TYPE_LSA: - if (vflag) { - lshp = op->ospf_lsa.lsa_lshdr; - - while (!ospf_print_lshdr(lshp)) { - /* { (ctags) */ - printf(" }"); - ++lshp; - } - } - break; + case OSPF_TYPE_LS_ACK: + lshp = op->ospf_lsa.lsa_lshdr; + while (ospf_print_lshdr(lshp) != -1) { + ++lshp; + } + break; default: - printf("v2 type %d", op->ospf_type); + printf("v2 type (%d)", op->ospf_type); break; } return (0); @@ -513,7 +727,7 @@ ospf_print(register const u_char *bp, register u_int length, /* XXX Before we do anything else, strip off the MD5 trailer */ TCHECK(op->ospf_authtype); - if (ntohs(op->ospf_authtype) == OSPF_AUTH_MD5) { + if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) { length -= OSPF_AUTH_MD5_LEN; snapend -= OSPF_AUTH_MD5_LEN; } @@ -521,50 +735,61 @@ ospf_print(register const u_char *bp, register u_int length, /* If the type is valid translate it, or just print the type */ /* value. If it's not valid, say so and return */ TCHECK(op->ospf_type); - cp = tok2str(type2str, "type%d", op->ospf_type); - printf("OSPFv%d-%s %d:", op->ospf_version, cp, length); - if (*cp == 't') + cp = tok2str(type2str, "unknown LS-type", op->ospf_type); + printf("OSPFv%u, %s (%u), length: %u", + op->ospf_version, + cp, + op->ospf_type, + length); + if (*cp == 'u') return; + if(!vflag) /* non verbose - so lets bail out here */ + return; + TCHECK(op->ospf_len); - if (length != ntohs(op->ospf_len)) { - printf(" [len %d]", ntohs(op->ospf_len)); + if (length != EXTRACT_16BITS(&op->ospf_len)) { + printf(" [len %d]", EXTRACT_16BITS(&op->ospf_len)); return; } dataend = bp + length; - /* Print the routerid if it is not the same as the source */ TCHECK(op->ospf_routerid); - if (ip->ip_src.s_addr != op->ospf_routerid.s_addr) - printf(" rtrid %s", ipaddr_string(&op->ospf_routerid)); + printf("\n\tRouter-ID: %s", ipaddr_string(&op->ospf_routerid)); TCHECK(op->ospf_areaid); if (op->ospf_areaid.s_addr != 0) - printf(" area %s", ipaddr_string(&op->ospf_areaid)); + printf(", Area %s", ipaddr_string(&op->ospf_areaid)); else - printf(" backbone"); + printf(", Backbone Area"); if (vflag) { /* Print authentication data (should we really do this?) */ TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata)); - switch (ntohs(op->ospf_authtype)) { + + printf(", Authentication Type: %s (%u)", + tok2str(ospf_authtype_values,"unknown",EXTRACT_16BITS(&op->ospf_authtype)), + EXTRACT_16BITS(&op->ospf_authtype)); + + switch (EXTRACT_16BITS(&op->ospf_authtype)) { case OSPF_AUTH_NONE: break; case OSPF_AUTH_SIMPLE: - printf(" auth \""); (void)fn_printn(op->ospf_authdata, sizeof(op->ospf_authdata), NULL); printf("\""); break; case OSPF_AUTH_MD5: - printf(" auth MD5"); + printf("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x", + *((op->ospf_authdata)+2), + *((op->ospf_authdata)+3), + EXTRACT_32BITS((op->ospf_authdata)+4)); break; default: - printf(" ??authtype-%d??", ntohs(op->ospf_authtype)); return; } } diff --git a/contrib/tcpdump/print-ospf6.c b/contrib/tcpdump/print-ospf6.c index 5f6deb1..5e6e69a 100644 --- a/contrib/tcpdump/print-ospf6.c +++ b/contrib/tcpdump/print-ospf6.c @@ -22,26 +22,22 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.7 2001/05/09 01:08:03 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.11.2.2 2003/11/16 08:51:37 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> #include <stdio.h> #include <string.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" #include "ospf6.h" @@ -87,6 +83,10 @@ static struct tok type2str[] = { static char tstr[] = " [|ospf]"; +#ifdef WIN32 +#define inline __inline +#endif /* WIN32 */ + /* Forwards */ static inline void ospf6_print_seqage(u_int32_t, time_t); static inline void ospf6_print_bits(const struct bits *, u_char); @@ -132,7 +132,7 @@ ospf6_print_ls_type(register u_int ls_type, register const rtrid_t *ls_stateid, register const rtrid_t *ls_router, register const char *fmt) { - char *scope; + const char *scope; switch (ls_type & LS_SCOPE_MASK) { case LS_SCOPE_LINKLOCAL: @@ -218,8 +218,8 @@ ospf6_print_lshdr(register const struct lsa_hdr *lshp) printf(" {"); /* } (ctags) */ TCHECK(lshp->ls_seq); - ospf6_print_seqage(ntohl(lshp->ls_seq), ntohs(lshp->ls_age)); - ospf6_print_ls_type(ntohs(lshp->ls_type), &lshp->ls_stateid, + ospf6_print_seqage(EXTRACT_32BITS(&lshp->ls_seq), EXTRACT_16BITS(&lshp->ls_age)); + ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid, &lshp->ls_router, "ls_type %d"); return (0); @@ -230,7 +230,7 @@ trunc: static int ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp) { - int k; + u_int k; struct in6_addr prefix; TCHECK(*lsapp); @@ -241,12 +241,12 @@ ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp) } memset(&prefix, 0, sizeof(prefix)); memcpy(&prefix, lsapp->lsa_p_prefix, k * 4); - printf(" %s/%d", ip6addr_string(&prefix), + printf(" %s/%d", ip6addr_string(&prefix), lsapp->lsa_p_len); if (lsapp->lsa_p_opt) printf("(opt=%x)", lsapp->lsa_p_opt); if (lsapp->lsa_p_mbz) - printf("(mbz=%x)", ntohs(lsapp->lsa_p_mbz)); /* XXX */ + printf("(mbz=%x)", EXTRACT_16BITS(&lsapp->lsa_p_mbz)); /* XXX */ return sizeof(*lsapp) - 4 + k * 4; trunc: @@ -275,21 +275,22 @@ ospf6_print_lsa(register const struct lsa *lsap) #if 0 register const u_int32_t *lp; #endif - register int j, k; + register u_int j; + register int k; u_int32_t flags32; if (ospf6_print_lshdr(&lsap->ls_hdr)) return (1); TCHECK(lsap->ls_hdr.ls_length); - ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length); - switch (ntohs(lsap->ls_hdr.ls_type)) { + ls_end = (u_char *)lsap + EXTRACT_16BITS(&lsap->ls_hdr.ls_length); + switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) { case LS_TYPE_ROUTER | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_rla.rla_flags); ospf6_print_bits(ospf6_rla_flag_bits, lsap->lsa_un.un_rla.rla_flags); TCHECK(lsap->lsa_un.un_rla.rla_options); ospf6_print_bits(ospf6_option_bits, - ntohl(lsap->lsa_un.un_rla.rla_options)); + EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options)); TCHECK(lsap->lsa_un.un_rla.rla_link); rlp = lsap->lsa_un.un_rla.rla_link; @@ -322,7 +323,7 @@ ospf6_print_lsa(register const struct lsa *lsap) rlp->link_type); return (0); } - printf(" metric %d", ntohs(rlp->link_metric)); + printf(" metric %d", EXTRACT_16BITS(&rlp->link_metric)); /* { (ctags) */ printf(" }"); rlp++; @@ -332,7 +333,7 @@ ospf6_print_lsa(register const struct lsa *lsap) case LS_TYPE_NETWORK | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_nla.nla_options); ospf6_print_bits(ospf6_option_bits, - ntohl(lsap->lsa_un.un_nla.nla_options)); + EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options)); printf(" rtrs"); ap = lsap->lsa_un.un_nla.nla_router; while ((u_char *)ap < ls_end) { @@ -345,7 +346,7 @@ ospf6_print_lsa(register const struct lsa *lsap) case LS_TYPE_INTER_AP | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric); printf(" metric %u", - (u_int32_t)ntohl(lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC); + EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC); lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix; while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) { k = ospf6_print_lsaprefix(lsapp); @@ -356,10 +357,10 @@ ospf6_print_lsa(register const struct lsa *lsap) break; case LS_SCOPE_AS | LS_TYPE_ASE: TCHECK(lsap->lsa_un.un_asla.asla_metric); - flags32 = ntohl(lsap->lsa_un.un_asla.asla_metric); + flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric); ospf6_print_bits(ospf6_asla_flag_bits, flags32); printf(" metric %u", - (u_int32_t)ntohl(lsap->lsa_un.un_asla.asla_metric) & + EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) & ASLA_MASK_METRIC); lsapp = lsap->lsa_un.un_asla.asla_prefix; k = ospf6_print_lsaprefix(lsapp); @@ -379,7 +380,7 @@ ospf6_print_lsa(register const struct lsa *lsap) if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) { TCHECK(*(u_int32_t *)ls_opt); - printf(" tag %s", + printf(" tag %s", ipaddr_string((u_int32_t *)ls_opt)); ls_opt += sizeof(u_int32_t); @@ -402,7 +403,7 @@ ospf6_print_lsa(register const struct lsa *lsap) register u_int32_t ul; TCHECK(*lp); - ul = ntohl(*lp); + ul = EXTRACT_32BITS(lp); printf(" tos %d metric %d", (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, ul & SLA_MASK_METRIC); @@ -415,7 +416,7 @@ ospf6_print_lsa(register const struct lsa *lsap) mcp = lsap->lsa_un.un_mcla; while ((u_char *)mcp < ls_end) { TCHECK(mcp->mcla_vid); - switch (ntohl(mcp->mcla_vtype)) { + switch (EXTRACT_32BITS(&mcp->mcla_vtype)) { case MCLA_VERTEX_ROUTER: printf(" rtr rtrid %s", @@ -429,7 +430,7 @@ ospf6_print_lsa(register const struct lsa *lsap) default: printf(" ??VertexType %u??", - (u_int32_t)ntohl(mcp->mcla_vtype)); + EXTRACT_32BITS(&mcp->mcla_vtype)); break; } ++mcp; @@ -440,13 +441,13 @@ ospf6_print_lsa(register const struct lsa *lsap) /* Link LSA */ llsap = &lsap->lsa_un.un_llsa; TCHECK(llsap->llsa_options); - ospf6_print_bits(ospf6_option_bits, ntohl(llsap->llsa_options)); + ospf6_print_bits(ospf6_option_bits, EXTRACT_32BITS(&llsap->llsa_options)); TCHECK(llsap->llsa_nprefix); printf(" pri %d lladdr %s npref %d", llsap->llsa_priority, ip6addr_string(&llsap->llsa_lladdr), - (u_int32_t)ntohl(llsap->llsa_nprefix)); + EXTRACT_32BITS(&llsap->llsa_nprefix)); lsapp = llsap->llsa_prefix; - for (j = 0; j < ntohl(llsap->llsa_nprefix); j++) { + for (j = 0; j < EXTRACT_32BITS(&llsap->llsa_nprefix); j++) { k = ospf6_print_lsaprefix(lsapp); if (k) goto trunc; @@ -458,17 +459,17 @@ ospf6_print_lsa(register const struct lsa *lsap) /* Intra-Area-Prefix LSA */ TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid); ospf6_print_ls_type( - ntohs(lsap->lsa_un.un_intra_ap.intra_ap_lstype), + EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype), &lsap->lsa_un.un_intra_ap.intra_ap_lsid, &lsap->lsa_un.un_intra_ap.intra_ap_rtid, "LinkStateType %d"); TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix); printf(" npref %d", - ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix)); + EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix)); lsapp = lsap->lsa_un.un_intra_ap.intra_ap_prefix; for (j = 0; - j < ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix); + j < EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix); j++) { k = ospf6_print_lsaprefix(lsapp); if (k) @@ -479,7 +480,7 @@ ospf6_print_lsa(register const struct lsa *lsap) default: printf(" ??LinkStateType 0x%04x??", - ntohs(lsap->ls_hdr.ls_type)); + EXTRACT_16BITS(&lsap->ls_hdr.ls_type)); } /* { (ctags) */ @@ -514,12 +515,12 @@ ospf6_decode_v3(register const struct ospf6hdr *op, if (vflag) { TCHECK(op->ospf6_hello.hello_deadint); ospf6_print_bits(ospf6_option_bits, - ntohl(op->ospf6_hello.hello_options)); + EXTRACT_32BITS(&op->ospf6_hello.hello_options)); printf(" ifid %s pri %d int %d dead %u", ipaddr_string(&op->ospf6_hello.hello_ifid), op->ospf6_hello.hello_priority, - ntohs(op->ospf6_hello.hello_helloint), - ntohs(op->ospf6_hello.hello_deadint)); + EXTRACT_16BITS(&op->ospf6_hello.hello_helloint), + EXTRACT_16BITS(&op->ospf6_hello.hello_deadint)); } TCHECK(op->ospf6_hello.hello_dr); if (op->ospf6_hello.hello_dr != 0) @@ -543,7 +544,7 @@ ospf6_decode_v3(register const struct ospf6hdr *op, case OSPF_TYPE_DB: TCHECK(op->ospf6_db.db_options); ospf6_print_bits(ospf6_option_bits, - ntohl(op->ospf6_db.db_options)); + EXTRACT_32BITS(&op->ospf6_db.db_options)); sep = ' '; TCHECK(op->ospf6_db.db_flags); if (op->ospf6_db.db_flags & OSPF6_DB_INIT) { @@ -559,8 +560,8 @@ ospf6_decode_v3(register const struct ospf6hdr *op, sep = '/'; } TCHECK(op->ospf6_db.db_seq); - printf(" mtu %u S %X", ntohs(op->ospf6_db.db_mtu), - (u_int32_t)ntohl(op->ospf6_db.db_seq)); + printf(" mtu %u S %X", EXTRACT_16BITS(&op->ospf6_db.db_mtu), + EXTRACT_32BITS(&op->ospf6_db.db_seq)); if (vflag) { /* Print all the LS adv's */ @@ -580,7 +581,7 @@ ospf6_decode_v3(register const struct ospf6hdr *op, while ((u_char *)lsrp < dataend) { TCHECK(*lsrp); printf(" {"); /* } (ctags) */ - ospf6_print_ls_type(ntohs(lsrp->ls_type), + ospf6_print_ls_type(EXTRACT_16BITS(&lsrp->ls_type), &lsrp->ls_stateid, &lsrp->ls_router, "LinkStateType %d"); @@ -595,12 +596,12 @@ ospf6_decode_v3(register const struct ospf6hdr *op, if (vflag) { lsap = op->ospf6_lsu.lsu_lsa; TCHECK(op->ospf6_lsu.lsu_count); - i = ntohl(op->ospf6_lsu.lsu_count); + i = EXTRACT_32BITS(&op->ospf6_lsu.lsu_count); while (i--) { if (ospf6_print_lsa(lsap)) goto trunc; lsap = (struct lsa *)((u_char *)lsap + - ntohs(lsap->ls_hdr.ls_length)); + EXTRACT_16BITS(&lsap->ls_hdr.ls_length)); } } break; @@ -645,8 +646,8 @@ ospf6_print(register const u_char *bp, register u_int length) return; TCHECK(op->ospf6_len); - if (length != ntohs(op->ospf6_len)) { - printf(" [len %d]", ntohs(op->ospf6_len)); + if (length != EXTRACT_16BITS(&op->ospf6_len)) { + printf(" [len %d]", EXTRACT_16BITS(&op->ospf6_len)); return; } dataend = bp + length; diff --git a/contrib/tcpdump/print-pflog.c b/contrib/tcpdump/print-pflog.c new file mode 100644 index 0000000..24634b2 --- /dev/null +++ b/contrib/tcpdump/print-pflog.c @@ -0,0 +1,160 @@ +/* + * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.7.2.4 2004/03/29 21:56:26 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> + +#include "interface.h" +#include "addrtoname.h" +#include "pf.h" + +static struct tok pf_reasons[] = { + { 0, "0(match)" }, + { 1, "1(bad-offset)" }, + { 2, "2(fragment)" }, + { 3, "3(short)" }, + { 4, "4(normalize)" }, + { 5, "5(memory)" }, + { 0, NULL } +}; + +static struct tok pf_actions[] = { + { PF_PASS, "pass" }, + { PF_DROP, "block" }, + { PF_SCRUB, "scrub" }, + { PF_NAT, "nat" }, + { PF_NONAT, "nat" }, + { PF_BINAT, "binat" }, + { PF_NOBINAT, "binat" }, + { PF_RDR, "rdr" }, + { PF_NORDR, "rdr" }, + { PF_SYNPROXY_DROP, "synproxy-drop" }, + { 0, NULL } +}; + +static struct tok pf_directions[] = { + { PF_INOUT, "in/out" }, + { PF_IN, "in" }, + { PF_OUT, "out" }, + { 0, NULL } +}; + +/* For reading capture files on other systems */ +#define OPENBSD_AF_INET 2 +#define OPENBSD_AF_INET6 24 + +static void +pflog_print(const struct pfloghdr *hdr) +{ + if (ntohl(hdr->subrulenr) == (u_int32_t)-1) + printf("rule %u/", ntohl(hdr->rulenr)); + else + printf("rule %u.%s.%u/", ntohl(hdr->rulenr), hdr->ruleset, + ntohl(hdr->subrulenr)); + + printf("%s: %s %s on %s: ", + tok2str(pf_reasons, "unkn(%u)", hdr->reason), + tok2str(pf_actions, "unkn(%u)", hdr->action), + tok2str(pf_directions, "unkn(%u)", hdr->dir), + hdr->ifname); +} + +u_int +pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + u_int length = h->len; + u_int hdrlen; + u_int caplen = h->caplen; + const struct pfloghdr *hdr; + u_int8_t af; + + /* check length */ + if (caplen < sizeof(u_int8_t)) { + printf("[|pflog]"); + return (caplen); + } + +#define MIN_PFLOG_HDRLEN 45 + hdr = (struct pfloghdr *)p; + if (hdr->length < MIN_PFLOG_HDRLEN) { + printf("[pflog: invalid header length!]"); + return (hdr->length); /* XXX: not really */ + } + hdrlen = BPF_WORDALIGN(hdr->length); + + if (caplen < hdrlen) { + printf("[|pflog]"); + return (hdrlen); /* XXX: true? */ + } + + /* print what we know */ + hdr = (struct pfloghdr *)p; + TCHECK(*hdr); + if (eflag) + pflog_print(hdr); + + /* skip to the real packet */ + af = hdr->af; + length -= hdrlen; + caplen -= hdrlen; + p += hdrlen; + switch (af) { + + case AF_INET: +#if OPENBSD_AF_INET != AF_INET + case OPENBSD_AF_INET: /* XXX: read pcap files */ +#endif + ip_print(p, length); + break; + +#ifdef INET6 + case AF_INET6: +#if OPENBSD_AF_INET6 != AF_INET6 + case OPENBSD_AF_INET6: /* XXX: read pcap files */ +#endif + ip6_print(p, length); + break; +#endif + + default: + /* address family not handled, print raw packet */ + if (!eflag) + pflog_print(hdr); + if (!xflag && !qflag) + default_print(p, caplen); + } + + return (hdrlen); +trunc: + printf("[|pflog]"); + return (hdrlen); +} diff --git a/contrib/tcpdump/print-pppoe.c b/contrib/tcpdump/print-pppoe.c index 0cb9453..69179c6 100644 --- a/contrib/tcpdump/print-pppoe.c +++ b/contrib/tcpdump/print-pppoe.c @@ -17,22 +17,20 @@ * 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. + * + * Original code by Greg Stark <gsstark@mit.edu> */ #ifndef lint -static const char rcsid[] = -"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.15 2001/07/05 18:54:17 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = +"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.24.2.4 2004/03/24 03:04:22 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <string.h> @@ -92,44 +90,22 @@ static struct tok pppoetag2str[] = { }; #define PPPOE_HDRLEN 6 +#define MAXTAGPRINT 80 -void -pppoe_if_print(u_char *user, const struct pcap_pkthdr *h, - register const u_char *p) +u_int +pppoe_if_print(const struct pcap_pkthdr *h, register const u_char *p) { - register u_int length = h->len; - register u_int caplen = h->caplen; - - ++infodelay; - ts_print(&h->ts); - - /* - * Some printers want to get back at the link level addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. - */ - packetp = p; - snapend = p + caplen; - - pppoe_print(p, length); - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return (pppoe_print(p, h->len)); } -void +u_int pppoe_print(register const u_char *bp, u_int length) { u_short pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid, pppoe_length; const u_char *pppoe_packet, *pppoe_payload; pppoe_packet = bp; - if (pppoe_packet > snapend) { - printf("[|pppoe]"); - return; - } - + TCHECK2(*pppoe_packet, PPPOE_HDRLEN); pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4; pppoe_type = (pppoe_packet[0] & 0x0F); pppoe_code = pppoe_packet[1]; @@ -139,7 +115,7 @@ pppoe_print(register const u_char *bp, u_int length) if (snapend < pppoe_payload) { printf(" truncated PPPoE"); - return; + return (PPPOE_HDRLEN); } if (pppoe_ver != 1) { @@ -157,14 +133,19 @@ pppoe_print(register const u_char *bp, u_int length) printf(" [ses 0x%x]", pppoe_sessionid); } - if (pppoe_payload + pppoe_length < snapend) { -#if 0 - const u_char *x = pppoe_payload + pppoe_length; + if (pppoe_payload + pppoe_length < snapend && snapend-pppoe_payload+14 > 64) { + /* (small packets are probably just padded up to the ethernet + minimum of 64 bytes) */ printf(" [length %d (%d extra bytes)]", pppoe_length, snapend - pppoe_payload - pppoe_length); - default_print(x, snapend - x); -#endif +#if RESPECT_PAYLOAD_LENGTH snapend = pppoe_payload+pppoe_length; +#else + /* Actual PPPoE implementations appear to ignore the payload + length and use the full ethernet frame anyways */ + pppoe_length = snapend-pppoe_payload; +#endif + } if (pppoe_code) { @@ -185,25 +166,38 @@ pppoe_print(register const u_char *bp, u_int length) /* p points to tag_value */ if (tag_len) { - int isascii = 1; + unsigned isascii = 0, isgarbage = 0; const u_char *v = p; - u_short l; - - for (v = p; v < p + tag_len; v++) - if (*v >= 127 || *v < 32) { - isascii = 0; - break; + char tag_str[MAXTAGPRINT]; + unsigned tag_str_len = 0; + + /* TODO print UTF-8 decoded text */ + for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++) + if (*v >= 32 && *v < 127) { + tag_str[tag_str_len++] = *v; + isascii++; + } else { + tag_str[tag_str_len++] = '.'; + isgarbage++; } + tag_str[tag_str_len] = 0; - /* TODO print UTF8 decoded text */ - if (isascii) { - l = (tag_len < 80 ? tag_len : 80); + if (isascii > isgarbage) { printf(" [%s \"%*.*s\"]", - tok2str(pppoetag2str, "TAG-0x%x", tag_type), - l, l, p); - } else - printf(" [%s UTF8]", - tok2str(pppoetag2str, "TAG-0x%x", tag_type)); + tok2str(pppoetag2str, "TAG-0x%x", tag_type), + (int)tag_str_len, + (int)tag_str_len, + tag_str); + } else { + /* Print hex, not fast to abuse printf but this doesn't get used much */ + printf(" [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type)); + for (v=p; v<p+tag_len; v++) { + printf("%02X", *v); + } + printf("]"); + } + + } else printf(" [%s]", tok2str(pppoetag2str, "TAG-0x%x", tag_type)); @@ -211,9 +205,14 @@ pppoe_print(register const u_char *bp, u_int length) p += tag_len; /* p points to next tag */ } + return (0); } else { + /* PPPoE data */ printf(" "); - ppp_print(pppoe_payload, pppoe_length); + return (PPPOE_HDRLEN + ppp_print(pppoe_payload, pppoe_length)); } - return; + +trunc: + printf("[|pppoe]"); + return (PPPOE_HDRLEN); } diff --git a/contrib/tcpdump/print-pptp.c b/contrib/tcpdump/print-pptp.c index 1798fd3..11e8330 100644 --- a/contrib/tcpdump/print-pptp.c +++ b/contrib/tcpdump/print-pptp.c @@ -23,21 +23,20 @@ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.3 2001/10/31 08:54:31 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.9.2.2 2003/11/16 08:51:39 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include <tcpdump-stdinc.h> + #include <stdio.h> -#include <sys/types.h> -#include <sys/param.h> -#include <netinet/in.h> -#include <arpa/inet.h> #include "interface.h" +#include "extract.h" static char tstr[] = " [|pptp]"; @@ -55,7 +54,7 @@ static char tstr[] = " [|pptp]"; #define PPTP_CTRL_MSG_TYPE_SCCRQ 1 #define PPTP_CTRL_MSG_TYPE_SCCRP 2 -#define PPTP_CTRL_MSG_TYPE_StopCCRQ 3 +#define PPTP_CTRL_MSG_TYPE_StopCCRQ 3 #define PPTP_CTRL_MSG_TYPE_StopCCRP 4 #define PPTP_CTRL_MSG_TYPE_ECHORQ 5 #define PPTP_CTRL_MSG_TYPE_ECHORP 6 @@ -75,7 +74,7 @@ static char tstr[] = " [|pptp]"; #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */ #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */ -static char *pptp_message_type_string[] = { +static const char *pptp_message_type_string[] = { "NOT_DEFINED", /* 0 Not defined in the RFC2637 */ "SCCRQ", /* 1 Start-Control-Connection-Request */ "SCCRP", /* 2 Start-Control-Connection-Reply */ @@ -185,8 +184,8 @@ struct pptp_msg_icrq { u_int16_t call_ser; u_int32_t bearer_type; u_int32_t phy_chan_id; - u_int16_t dialed_no_len; - u_int16_t dialing_no_len; + u_int16_t dialed_no_len; + u_int16_t dialing_no_len; u_char dialed_no[64]; /* DNIS */ u_char dialing_no[64]; /* CLID */ u_char subaddr[64]; @@ -245,7 +244,7 @@ struct pptp_msg_sli { /* attributes that appear more than once in above messages: - Number of + Number of occurence attributes -------------------------------------- 2 u_int32_t bearer_cap; @@ -272,7 +271,7 @@ struct pptp_msg_sli { 2 u_char subaddr[64]; 2 u_char vendor[64]; - so I will prepare print out functions for these attributes (except for + so I will prepare print out functions for these attributes (except for reserved*). */ @@ -288,10 +287,10 @@ static void pptp_bearer_cap_print(const u_int32_t *bearer_cap) { printf(" BEARER_CAP("); - if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) { + if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) { printf("D"); } - if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) { + if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) { printf("A"); } printf(")"); @@ -301,14 +300,14 @@ static void pptp_bearer_type_print(const u_int32_t *bearer_type) { printf(" BEARER_TYPE("); - switch (ntohl(*bearer_type)) { + switch (EXTRACT_32BITS(bearer_type)) { case 1: printf("A"); /* Analog */ break; case 2: printf("D"); /* Digital */ break; - case 3: + case 3: printf("Any"); break; default: @@ -321,25 +320,25 @@ pptp_bearer_type_print(const u_int32_t *bearer_type) static void pptp_call_id_print(const u_int16_t *call_id) { - printf(" CALL_ID(%u)", ntohs(*call_id)); + printf(" CALL_ID(%u)", EXTRACT_16BITS(call_id)); } static void pptp_call_ser_print(const u_int16_t *call_ser) { - printf(" CALL_SER_NUM(%u)", ntohs(*call_ser)); + printf(" CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)); } static void pptp_cause_code_print(const u_int16_t *cause_code) { - printf(" CAUSE_CODE(%u)", ntohs(*cause_code)); + printf(" CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)); } static void pptp_conn_speed_print(const u_int32_t *conn_speed) { - printf(" CONN_SPEED(%lu)", (unsigned long)ntohl(*conn_speed)); + printf(" CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)); } static void @@ -380,17 +379,17 @@ pptp_err_code_print(const u_int8_t *err_code) static void pptp_firm_rev_print(const u_int16_t *firm_rev) { - printf(" FIRM_REV(%u)", ntohs(*firm_rev)); + printf(" FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)); } static void pptp_framing_cap_print(const u_int32_t *framing_cap) { printf(" FRAME_CAP("); - if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) { + if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) { printf("A"); /* Async */ } - if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) { + if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) { printf("S"); /* Sync */ } printf(")"); @@ -400,7 +399,7 @@ static void pptp_framing_type_print(const u_int32_t *framing_type) { printf(" FRAME_TYPE("); - switch (ntohl(*framing_type)) { + switch (EXTRACT_32BITS(framing_type)) { case 1: printf("A"); /* Async */ break; @@ -426,44 +425,45 @@ pptp_hostname_print(const u_char *hostname) static void pptp_id_print(const u_int32_t *id) { - printf(" ID(%lu)", (unsigned long)ntohl(*id)); + printf(" ID(%u)", EXTRACT_32BITS(id)); } static void pptp_max_channel_print(const u_int16_t *max_channel) { - printf(" MAX_CHAN(%u)", ntohs(*max_channel)); + printf(" MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)); } static void pptp_peer_call_id_print(const u_int16_t *peer_call_id) { - printf(" PEER_CALL_ID(%u)", ntohs(*peer_call_id)); + printf(" PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)); } static void pptp_phy_chan_id_print(const u_int32_t *phy_chan_id) { - printf(" PHY_CHAN_ID(%lu)", (unsigned long)ntohl(*phy_chan_id)); + printf(" PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)); } static void pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay) { - printf(" PROC_DELAY(%u)", ntohs(*pkt_proc_delay)); + printf(" PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)); } static void pptp_proto_ver_print(const u_int16_t *proto_ver) { printf(" PROTO_VER(%u.%u)", /* Version.Revision */ - ntohs(*proto_ver) >> 8, ntohs(*proto_ver) & 0xff); + EXTRACT_16BITS(proto_ver) >> 8, + EXTRACT_16BITS(proto_ver) & 0xff); } static void pptp_recv_winsiz_print(const u_int16_t *recv_winsiz) { - printf(" RECV_WIN(%u)", ntohs(*recv_winsiz)); + printf(" RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)); } static void @@ -707,7 +707,7 @@ pptp_echorq_print(const u_char *dat) TCHECK(ptr->id); pptp_id_print(&ptr->id); - + return; trunc: @@ -726,7 +726,7 @@ pptp_echorp_print(const u_char *dat) TCHECK(ptr->err_code); pptp_err_code_print(&ptr->err_code); TCHECK(ptr->reserved1); - + return; trunc: @@ -743,9 +743,9 @@ pptp_ocrq_print(const u_char *dat) TCHECK(ptr->call_ser); pptp_call_ser_print(&ptr->call_ser); TCHECK(ptr->min_bps); - printf(" MIN_BPS(%lu)", (unsigned long)ntohl(ptr->min_bps)); + printf(" MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)); TCHECK(ptr->max_bps); - printf(" MAX_BPS(%lu)", (unsigned long)ntohl(ptr->max_bps)); + printf(" MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)); TCHECK(ptr->bearer_type); pptp_bearer_type_print(&ptr->bearer_type); TCHECK(ptr->framing_type); @@ -755,7 +755,7 @@ pptp_ocrq_print(const u_char *dat) TCHECK(ptr->pkt_proc_delay); pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); TCHECK(ptr->phone_no_len); - printf(" PHONE_NO_LEN(%u)", ntohs(ptr->phone_no_len)); + printf(" PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)); TCHECK(ptr->reserved1); TCHECK(ptr->phone_no); printf(" PHONE_NO(%.64s)", ptr->phone_no); @@ -812,9 +812,9 @@ pptp_icrq_print(const u_char *dat) TCHECK(ptr->phy_chan_id); pptp_phy_chan_id_print(&ptr->phy_chan_id); TCHECK(ptr->dialed_no_len); - printf(" DIALED_NO_LEN(%u)", ntohs(ptr->dialed_no_len)); + printf(" DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)); TCHECK(ptr->dialing_no_len); - printf(" DIALING_NO_LEN(%u)", ntohs(ptr->dialing_no_len)); + printf(" DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)); TCHECK(ptr->dialed_no); printf(" DIALED_NO(%.64s)", ptr->dialed_no); TCHECK(ptr->dialing_no); @@ -832,7 +832,7 @@ static void pptp_icrp_print(const u_char *dat) { struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat; - + TCHECK(ptr->call_id); pptp_call_id_print(&ptr->call_id); TCHECK(ptr->peer_call_id); @@ -923,19 +923,17 @@ pptp_wen_print(const u_char *dat) pptp_peer_call_id_print(&ptr->peer_call_id); TCHECK(ptr->reserved1); TCHECK(ptr->crc_err); - printf(" CRC_ERR(%lu)", (unsigned long)ntohl(ptr->crc_err)); + printf(" CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)); TCHECK(ptr->framing_err); - printf(" FRAMING_ERR(%lu)", (unsigned long)ntohl(ptr->framing_err)); + printf(" FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)); TCHECK(ptr->hardware_overrun); - printf(" HARDWARE_OVERRUN(%lu)", - (unsigned long)ntohl(ptr->hardware_overrun)); + printf(" HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)); TCHECK(ptr->buffer_overrun); - printf(" BUFFER_OVERRUN(%lu)", - (unsigned long)ntohl(ptr->buffer_overrun)); + printf(" BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)); TCHECK(ptr->timeout_err); - printf(" TIMEOUT_ERR(%lu)", (unsigned long)ntohl(ptr->timeout_err)); + printf(" TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)); TCHECK(ptr->align_err); - printf(" ALIGN_ERR(%lu)", (unsigned long)ntohl(ptr->align_err)); + printf(" ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)); return; @@ -952,9 +950,9 @@ pptp_sli_print(const u_char *dat) pptp_peer_call_id_print(&ptr->peer_call_id); TCHECK(ptr->reserved1); TCHECK(ptr->send_accm); - printf(" SEND_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->send_accm)); + printf(" SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)); TCHECK(ptr->recv_accm); - printf(" RECV_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->recv_accm)); + printf(" RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)); return; @@ -963,7 +961,7 @@ trunc: } void -pptp_print(const u_char *dat, u_int length) +pptp_print(const u_char *dat) { const struct pptp_hdr *hdr; u_int32_t mc; @@ -975,11 +973,11 @@ pptp_print(const u_char *dat, u_int length) TCHECK(hdr->length); if (vflag) { - printf(" Length=%u", ntohs(hdr->length)); + printf(" Length=%u", EXTRACT_16BITS(&hdr->length)); } TCHECK(hdr->msg_type); if (vflag) { - switch(ntohs(hdr->msg_type)) { + switch(EXTRACT_16BITS(&hdr->msg_type)) { case PPTP_MSG_TYPE_CTRL: printf(" CTRL-MSG"); break; @@ -993,7 +991,7 @@ pptp_print(const u_char *dat, u_int length) } TCHECK(hdr->magic_cookie); - mc = ntohl(hdr->magic_cookie); + mc = EXTRACT_32BITS(&hdr->magic_cookie); if (mc != PPTP_MAGIC_COOKIE) { printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc); } @@ -1001,9 +999,9 @@ pptp_print(const u_char *dat, u_int length) printf(" Magic-Cookie=%08x", mc); } TCHECK(hdr->ctrl_msg_type); - ctrl_msg_type = ntohs(hdr->ctrl_msg_type); + ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type); if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) { - printf(" CTRL_MSGTYPE=%s", + printf(" CTRL_MSGTYPE=%s", pptp_message_type_string[ctrl_msg_type]); } else { printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type); @@ -1067,4 +1065,4 @@ pptp_print(const u_char *dat, u_int length) trunc: printf("%s", tstr); -} +} diff --git a/contrib/tcpdump/print-radius.c b/contrib/tcpdump/print-radius.c index 72cf22e..b3f790e 100644 --- a/contrib/tcpdump/print-radius.c +++ b/contrib/tcpdump/print-radius.c @@ -1,10 +1,10 @@ /* * Copyright (C) 2000 Alfredo Andres Omella. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -14,7 +14,7 @@ * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. @@ -39,33 +39,28 @@ * * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15 * - * TODO: Among other things to print ok MacIntosh and Vendor values + * TODO: Among other things to print ok MacIntosh and Vendor values */ #ifndef lint -static const char rcsid[] = - "$Id: print-radius.c,v 1.10.2.2 2002/07/03 16:35:04 fenner Exp $"; +static const char rcsid[] _U_ = + "$Id: print-radius.c,v 1.19.2.4 2004/02/06 14:38:51 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <string.h> - -#include <sys/param.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> +#include <string.h> #include <stdio.h> -#ifdef TIME_WITH_SYS_TIME -#include <time.h> -#endif - #include "interface.h" #include "addrtoname.h" #include "extract.h" +#include "oui.h" #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) ) @@ -89,6 +84,18 @@ static const char rcsid[] = #define RADCMD_STATUS_CLI 13 /* Status-Client */ #define RADCMD_RESERVED 255 /* Reserved */ +static struct tok radius_command_values[] = { + { RADCMD_ACCESS_REQ, "Access Request" }, + { RADCMD_ACCESS_ACC, "Access Accept" }, + { RADCMD_ACCESS_REJ, "Access Reject" }, + { RADCMD_ACCOUN_REQ, "Accounting Request" }, + { RADCMD_ACCOUN_RES, "Accounting Response" }, + { RADCMD_ACCESS_CHA, "Access Challenge" }, + { RADCMD_STATUS_SER, "Status Server" }, + { RADCMD_STATUS_CLI, "Status Client" }, + { RADCMD_RESERVED, "Reserved" }, + { 0, NULL} +}; /********************************/ /* Begin Radius Attribute types */ @@ -131,6 +138,7 @@ static const char rcsid[] = static void print_attr_string(register u_char *, u_int, u_short ); static void print_attr_num(register u_char *, u_int, u_short ); +static void print_vendor_attr(register u_char *, u_int, u_short ); static void print_attr_address(register u_char *, u_int, u_short); static void print_attr_time(register u_char *, u_int, u_short); static void print_attr_strange(register u_char *, u_int, u_short); @@ -149,20 +157,20 @@ struct radius_attr { u_int8_t type; /* Attribute type */ }; -/* Service-Type Attribute standard values */ +/* Service-Type Attribute standard values */ static const char *serv_type[]={ NULL, "Login", - "Framed", + "Framed", "Callback Login", "Callback Framed", "Outbound", "Administrative", - "NAS Prompt", + "NAS Prompt", "Authenticate Only", "Callback NAS Prompt", "Call Check", "Callback Administrative", - }; + }; /* Framed-Protocol Attribute standard values */ static const char *frm_proto[]={ NULL, @@ -172,14 +180,14 @@ static const char *frm_proto[]={ NULL, "Gandalf proprietary", "Xylogics IPX/SLIP", "X.75 Synchronous", - }; + }; /* Framed-Routing Attribute standard values */ static const char *frm_routing[]={ "None", "Send", "Listen", "Send&Listen", - }; + }; /* Framed-Compression Attribute standard values */ static const char *frm_comp[]={ "None", @@ -227,7 +235,7 @@ static const char *nas_port_type[]={ "Async", "Cable", "Wireless - Other", "Wireless - IEEE 802.11", - }; + }; /* Acct-Status-Type Accounting Attribute standard values */ static const char *acct_status[]={ NULL, @@ -292,7 +300,7 @@ static const char *tunnel_type[]={ NULL, "DVS", "IP-in-IP Tunneling", }; - + /* Tunnel-Medium-Type Attribute standard values */ static const char *tunnel_medium[]={ NULL, "IPv4", @@ -323,114 +331,110 @@ static const char *arap_zone[]={ NULL, static const char *prompt[]={ "No Echo", "Echo", }; - - -struct attrtype { char *name; /* Attribute name */ + + +struct attrtype { const char *name; /* Attribute name */ const char **subtypes; /* Standard Values (if any) */ u_char siz_subtypes; /* Size of total standard values */ u_char first_subtype; /* First standard value is 0 or 1 */ void (*print_func)(register u_char *, u_int, u_short ); } attr_type[]= { - { NULL, NULL, 0, 0, NULL }, - { "User", NULL, 0, 0, print_attr_string }, - { "Pass", NULL, 0, 0, NULL }, - { "CHAP-Pass", NULL, 0, 0, NULL }, - { "NAS_ipaddr", NULL, 0, 0, print_attr_address }, - { "NAS_port", NULL, 0, 0, print_attr_num }, - { "Service_type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num }, - { "Framed_proto", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num }, - { "Framed_ipaddr", NULL, 0, 0, print_attr_address }, - { "Framed_ipnet", NULL, 0, 0, print_attr_address }, - { "Framed_routing", frm_routing, TAM_SIZE(frm_routing), 0, - print_attr_num }, - { "Filter_id", NULL, 0, 0, print_attr_string }, - { "Framed_mtu", NULL, 0, 0, print_attr_num }, - { "Framed_compress", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num }, - { "Login_iphost", NULL, 0, 0, print_attr_address }, - { "Login_service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num }, - { "Login_TCP_port", NULL, 0, 0, print_attr_num }, -/*17*/ { "Unassigned", NULL, 0, 0, NULL }, - { "Reply", NULL, 0, 0, print_attr_string }, - { "Callback-number", NULL, 0, 0, print_attr_string }, - { "Callback-id", NULL, 0, 0, print_attr_string }, -/*21*/ { "Unassigned", NULL, 0, 0, NULL }, - { "Framed_route", NULL, 0, 0, print_attr_string }, - { "Framed_ipx_net", NULL, 0, 0, print_attr_num }, - { "State", NULL, 0, 0, print_attr_string }, - { "Class", NULL, 0, 0, print_attr_string }, - { "Vendor_specific", NULL, 0, 0, print_attr_string }, - { "Session_timeout", NULL, 0, 0, print_attr_num }, - { "Idle_timeout", NULL, 0, 0, print_attr_num }, - { "Term_action", term_action, TAM_SIZE(term_action), 0, print_attr_num }, - { "Called_station", NULL, 0, 0, print_attr_string }, - { "Calling_station", NULL, 0, 0, print_attr_string }, - { "NAS_id", NULL, 0, 0, print_attr_string }, - { "Proxy_state", NULL, 0, 0, print_attr_string }, - { "Login_LAT_service", NULL, 0, 0, print_attr_string }, - { "Login_LAT_node", NULL, 0, 0, print_attr_string }, - { "Login_LAT_group", NULL, 0, 0, print_attr_string }, - { "Framed_atalk_link", NULL, 0, 0, print_attr_num }, - { "Framed_atalk_net", NULL, 0, 0, print_attr_num }, - { "Framed_atalk_zone", NULL, 0, 0, print_attr_string }, - { "Acct_status", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num }, - { "Acct_delay", NULL, 0, 0, print_attr_num }, - { "Acct_in_octets", NULL, 0, 0, print_attr_num }, - { "Acct_out_octets", NULL, 0, 0, print_attr_num }, - { "Acct_session_id", NULL, 0, 0, print_attr_string }, - { "Acct_authentic", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num }, - { "Acct_session_time", NULL, 0, 0, print_attr_num }, - { "Acct_in_packets", NULL, 0, 0, print_attr_num }, - { "Acct_out_packets", NULL, 0, 0, print_attr_num }, - { "Acct_term_cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num }, - { "Acct_multi_session_id", NULL, 0, 0, print_attr_string }, - { "Acct_link_count", NULL, 0, 0, print_attr_num }, - { "Acct_in_giga", NULL, 0, 0, print_attr_num }, - { "Acct_out_giga", NULL, 0, 0, print_attr_num }, -/*54*/ { "Unassigned", NULL, 0, 0, NULL }, - { "Event_timestamp", NULL, 0, 0, print_attr_time }, -/*56*/ { "Unassigned", NULL, 0, 0, NULL }, -/*57*/ { "Unassigned", NULL, 0, 0, NULL }, -/*58*/ { "Unassigned", NULL, 0, 0, NULL }, -/*59*/ { "Unassigned", NULL, 0, 0, NULL }, - { "CHAP_challenge", NULL, 0, 0, print_attr_string }, - { "NAS_port_type", nas_port_type, TAM_SIZE(nas_port_type), 0, - print_attr_num }, - { "Port_limit", NULL, 0, 0, print_attr_num }, -/*63*/ { "Login_LAT_port", NULL, 0, 0, print_attr_string }, - { "Tunnel_type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num }, - { "Tunnel_medium", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, - print_attr_num }, - { "Tunnel_client_end", NULL, 0, 0, print_attr_string }, - { "Tunnel_server_end", NULL, 0, 0, print_attr_string }, - { "Acct_tunnel_connect", NULL, 0, 0, print_attr_string }, - { "Tunnel_pass", NULL, 0, 0, print_attr_string }, - { "ARAP_pass", NULL, 0, 0, print_attr_strange }, - { "ARAP_feature", NULL, 0, 0, print_attr_strange }, -/*72*/ { "ARAP_zone_acces", arap_zone, TAM_SIZE(arap_zone)-1, 1, - print_attr_num }, - { "ARAP_security", NULL, 0, 0, print_attr_string }, - { "ARAP_security_data", NULL, 0, 0, print_attr_string }, - { "Password_retry", NULL, 0, 0, print_attr_num }, - { "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num }, - { "Connect_info", NULL, 0, 0, print_attr_string }, - { "Config_token", NULL, 0, 0, print_attr_string }, - { "EAP_msg", NULL, 0, 0, print_attr_string }, -/*80*/ { "Message_auth", NULL, 0, 0, print_attr_string }, - { "Tunnel_priv_group", NULL, 0, 0, print_attr_string }, - { "Tunnel_assign_id", NULL, 0, 0, print_attr_string }, - { "Tunnel_pref", NULL, 0, 0, print_attr_num }, - { "ARAP_challenge_resp", NULL, 0, 0, print_attr_strange }, - { "Acct_interim_interval", NULL, 0, 0, print_attr_num }, -/*86*/ { "Acct_tunnel_pack_lost", NULL, 0, 0, print_attr_num }, - { "NAS_port_id", NULL, 0, 0, print_attr_string }, - { "Framed_pool", NULL, 0, 0, print_attr_string }, - { "Unassigned", NULL, 0, 0, NULL }, - { "Tunnel_client_auth_id", NULL, 0, 0, print_attr_string }, - { "Tunnel_server_auth_id", NULL, 0, 0, print_attr_string }, -/*92*/ { "Unassigned", NULL, 0, 0, NULL }, -/*93*/ { "Unassigned", NULL, 0, 0, NULL } - }; + { NULL, NULL, 0, 0, NULL }, + { "Username", NULL, 0, 0, print_attr_string }, + { "Password", NULL, 0, 0, NULL }, + { "CHAP Password", NULL, 0, 0, NULL }, + { "NAS IP Address", NULL, 0, 0, print_attr_address }, + { "NAS Port", NULL, 0, 0, print_attr_num }, + { "Service Type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num }, + { "Framed Protocol", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num }, + { "Framed IP Address", NULL, 0, 0, print_attr_address }, + { "Framed IP Network", NULL, 0, 0, print_attr_address }, + { "Framed Routing", frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num }, + { "Filter ID", NULL, 0, 0, print_attr_string }, + { "Framed MTU", NULL, 0, 0, print_attr_num }, + { "Framed Compression", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num }, + { "Login IP Host", NULL, 0, 0, print_attr_address }, + { "Login Service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num }, + { "Login TCP Port", NULL, 0, 0, print_attr_num }, + { "Unassigned", NULL, 0, 0, NULL }, /*17*/ + { "Reply", NULL, 0, 0, print_attr_string }, + { "Callback-number", NULL, 0, 0, print_attr_string }, + { "Callback-ID", NULL, 0, 0, print_attr_string }, + { "Unassigned", NULL, 0, 0, NULL }, /*21*/ + { "Framed Route", NULL, 0, 0, print_attr_string }, + { "Framed IPX Network", NULL, 0, 0, print_attr_num }, + { "State", NULL, 0, 0, print_attr_string }, + { "Class", NULL, 0, 0, print_attr_string }, + { "Vendor Specific", NULL, 0, 0, print_vendor_attr }, + { "Session Timeout", NULL, 0, 0, print_attr_num }, + { "Idle Timeout", NULL, 0, 0, print_attr_num }, + { "Termination Action", term_action, TAM_SIZE(term_action), 0, print_attr_num }, + { "Called Station", NULL, 0, 0, print_attr_string }, + { "Calling Station", NULL, 0, 0, print_attr_string }, + { "NAS ID", NULL, 0, 0, print_attr_string }, + { "Proxy State", NULL, 0, 0, print_attr_string }, + { "Login LAT Service", NULL, 0, 0, print_attr_string }, + { "Login LAT Node", NULL, 0, 0, print_attr_string }, + { "Login LAT Group", NULL, 0, 0, print_attr_string }, + { "Framed Appletalk Link", NULL, 0, 0, print_attr_num }, + { "Framed Appltalk Net", NULL, 0, 0, print_attr_num }, + { "Framed Appletalk Zone", NULL, 0, 0, print_attr_string }, + { "Accounting Status", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num }, + { "Accounting Delay", NULL, 0, 0, print_attr_num }, + { "Accounting Input Octets", NULL, 0, 0, print_attr_num }, + { "Accounting Output Octets", NULL, 0, 0, print_attr_num }, + { "Accounting Session ID", NULL, 0, 0, print_attr_string }, + { "Accounting Authentication", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num }, + { "Accounting Session Time", NULL, 0, 0, print_attr_num }, + { "Accounting Input Packets", NULL, 0, 0, print_attr_num }, + { "Accounting Output Packets", NULL, 0, 0, print_attr_num }, + { "Accounting Termination Cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num }, + { "Accounting Multilink Session ID", NULL, 0, 0, print_attr_string }, + { "Accounting Link Count", NULL, 0, 0, print_attr_num }, + { "Accounting Input Giga", NULL, 0, 0, print_attr_num }, + { "Accounting Output Giga", NULL, 0, 0, print_attr_num }, + { "Unassigned", NULL, 0, 0, NULL }, /*54*/ + { "Event Timestamp", NULL, 0, 0, print_attr_time }, + { "Unassigned", NULL, 0, 0, NULL }, /*56*/ + { "Unassigned", NULL, 0, 0, NULL }, /*57*/ + { "Unassigned", NULL, 0, 0, NULL }, /*58*/ + { "Unassigned", NULL, 0, 0, NULL }, /*59*/ + { "CHAP challenge", NULL, 0, 0, print_attr_string }, + { "NAS Port Type", nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num }, + { "Port Limit", NULL, 0, 0, print_attr_num }, + { "Login LAT Port", NULL, 0, 0, print_attr_string }, /*63*/ + { "Tunnel Type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num }, + { "Tunnel Medium", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num }, + { "Tunnel Client End", NULL, 0, 0, print_attr_string }, + { "Tunnel Server End", NULL, 0, 0, print_attr_string }, + { "Accounting Tunnel connect", NULL, 0, 0, print_attr_string }, + { "Tunnel Password", NULL, 0, 0, print_attr_string }, + { "ARAP Password", NULL, 0, 0, print_attr_strange }, + { "ARAP Feature", NULL, 0, 0, print_attr_strange }, + { "ARAP Zone Acces", arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/ + { "ARAP Security", NULL, 0, 0, print_attr_string }, + { "ARAP Security Data", NULL, 0, 0, print_attr_string }, + { "Password Retry", NULL, 0, 0, print_attr_num }, + { "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num }, + { "Connect Info", NULL, 0, 0, print_attr_string }, + { "Config Token", NULL, 0, 0, print_attr_string }, + { "EAP Message", NULL, 0, 0, print_attr_string }, + { "Message Authentication", NULL, 0, 0, print_attr_string }, /*80*/ + { "Tunnel Private Group", NULL, 0, 0, print_attr_string }, + { "Tunnel Assigned ID", NULL, 0, 0, print_attr_string }, + { "Tunnel Preference", NULL, 0, 0, print_attr_num }, + { "ARAP Challenge Response", NULL, 0, 0, print_attr_strange }, + { "Accounting Interim Interval", NULL, 0, 0, print_attr_num }, + { "Accounting Tunnel packets lost", NULL, 0, 0, print_attr_num }, /*86*/ + { "NAS Port ID", NULL, 0, 0, print_attr_string }, + { "Framed Pool", NULL, 0, 0, print_attr_string }, + { "Unassigned", NULL, 0, 0, NULL }, + { "Tunnel Client Authentication ID", NULL, 0, 0, print_attr_string }, + { "Tunnel Server Authentication ID", NULL, 0, 0, print_attr_string }, + { "Unassigned", NULL, 0, 0, NULL }, /*92*/ + { "Unassigned", NULL, 0, 0, NULL } /*93*/ + }; /*****************************/ @@ -444,17 +448,16 @@ static void print_attr_string(register u_char *data, u_int length, u_short attr_code ) { register u_int i; - + TCHECK2(data[0],length); - - printf("{"); + switch(attr_code) { case TUNNEL_PASS: if (*data && (*data <=0x1F) ) - printf("Tag[%d] ",*data); + printf("Tag %u, ",*data); data++; - printf("Salt[%d] ",EXTRACT_16BITS(data) ); + printf("Salt %u ",EXTRACT_16BITS(data) ); data+=2; length-=2; break; @@ -466,7 +469,7 @@ print_attr_string(register u_char *data, u_int length, u_short attr_code ) case TUNNEL_SERVER_AUTH: if (*data <= 0x1F) { - printf("Tag[%d] ",*data); + printf("Tag %u",*data); data++; length--; } @@ -476,13 +479,53 @@ print_attr_string(register u_char *data, u_int length, u_short attr_code ) for (i=0; *data && i < length ; i++, data++) printf("%c",(*data < 32 || *data > 128) ? '.' : *data ); - printf("}"); - return; - + trunc: printf("|radius"); -} +} + +/* + * print vendor specific attributes + */ + +static void +print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_) +{ + u_int idx; + u_int vendor_id; + u_int vendor_type; + u_int vendor_length; + + /* FIXME: all sort of boundary checks */ + vendor_id = EXTRACT_32BITS(data); + data+=4; + length-=4; + + printf("Vendor: %s (%u)", + tok2str(smi_values,"Unknown",vendor_id), + vendor_id); + + while (length >= 2) { + if(!TTEST2(*data, 2)) + return; + + vendor_type = *(data); + vendor_length = *(data+1); + + data+=2; + if(!TTEST2(*data, vendor_length)) + return; + + printf("\n\t Vendor Attribute: %u, Length: %u, Value: ", + vendor_type, + vendor_length); + for (idx = 0; idx < vendor_length ; idx++, data++) + printf("%c",(*data < 32 || *data > 128) ? '.' : *data ); + length-=vendor_length; + } +} + /******************************/ @@ -497,27 +540,27 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code ) { u_int8_t tag; u_int32_t timeout; - + if (length != 4) { - printf("{length %u != 4}", length); + printf("ERROR: length %u != 4", length); return; } TCHECK2(data[0],4); /* This attribute has standard values */ - if (attr_type[attr_code].siz_subtypes) + if (attr_type[attr_code].siz_subtypes) { static const char **table; u_int32_t data_value; table = attr_type[attr_code].subtypes; - + if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) ) { if (!*data) - printf("{Tag[Unused]"); + printf("Tag[Unused]"); else - printf("{Tag[%d]", *data); + printf("Tag[%d]", *data); data++; data_value = EXTRACT_24BITS(data); } @@ -525,12 +568,12 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code ) { data_value = EXTRACT_32BITS(data); } - if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 + + if ( data_value <= (u_int32_t)(attr_type[attr_code].siz_subtypes - 1 + attr_type[attr_code].first_subtype) && data_value >= attr_type[attr_code].first_subtype ) - printf("{%s}",table[data_value]); + printf("%s",table[data_value]); else - printf("{#%d}",data_value); + printf("#%u",data_value); } else { @@ -538,9 +581,9 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code ) { case FRM_IPX: if (EXTRACT_32BITS( data) == 0xFFFFFFFE ) - printf("{NAS_select}"); + printf("NAS Select"); else - printf("{%d}",EXTRACT_32BITS( data) ); + printf("%d",EXTRACT_32BITS( data) ); break; case SESSION_TIMEOUT: @@ -550,52 +593,52 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code ) case ACCT_INT_INTERVAL: timeout = EXTRACT_32BITS( data); if ( timeout < 60 ) - printf( "{%02d secs}", timeout); + printf( "%02d secs", timeout); else { if ( timeout < 3600 ) - printf( "{%02d:%02d min}", + printf( "%02d:%02d min", timeout / 60, timeout % 60); else - printf( "{%02d:%02d:%02d hours}", - timeout / 3600, (timeout % 3600) / 60, + printf( "%02d:%02d:%02d hours", + timeout / 3600, (timeout % 3600) / 60, timeout % 60); } break; case FRM_ATALK_LINK: - if (EXTRACT_32BITS(data) ) - printf("{%d}",EXTRACT_32BITS(data) ); + if (EXTRACT_32BITS(data) ) + printf("%d",EXTRACT_32BITS(data) ); else - printf("{Unnumbered}" ); + printf("Unnumbered" ); break; - + case FRM_ATALK_NETWORK: - if (EXTRACT_32BITS(data) ) - printf("{%d}",EXTRACT_32BITS(data) ); + if (EXTRACT_32BITS(data) ) + printf("%d",EXTRACT_32BITS(data) ); else - printf("{NAS_assign}" ); + printf("NAS assigned" ); break; case TUNNEL_PREFERENCE: tag = *data; data++; if (tag == 0) - printf("{Tag[Unused] %d}",EXTRACT_24BITS(data) ); + printf("Tag (Unused) %d",EXTRACT_24BITS(data) ); else - printf("{Tag[%d] %d}", tag, EXTRACT_24BITS(data) ); + printf("Tag (%d) %d", tag, EXTRACT_24BITS(data) ); break; default: - printf("{%d}",EXTRACT_32BITS( data) ); + printf("%d",EXTRACT_32BITS( data) ); break; - + } /* switch */ - + } /* if-else */ return; - + trunc: printf("|radius}"); } @@ -613,34 +656,34 @@ print_attr_address(register u_char *data, u_int length, u_short attr_code ) { if (length != 4) { - printf("{length %u != 4}", length); + printf("ERROR: length %u != 4", length); return; } TCHECK2(data[0],4); - + switch(attr_code) { case FRM_IPADDR: case LOG_IPHOST: if (EXTRACT_32BITS(data) == 0xFFFFFFFF ) - printf("{User_select}"); + printf("User Selected"); else if (EXTRACT_32BITS(data) == 0xFFFFFFFE ) - printf("{NAS_select}"); + printf("NAS Select"); else - printf("{%s}",ipaddr_string(data)); + printf("%s",ipaddr_string(data)); break; - + default: - printf("{%s}",ipaddr_string(data) ); + printf("%s",ipaddr_string(data) ); break; } - + return; - + trunc: - printf("{|radius}"); + printf("|radius"); } @@ -652,31 +695,31 @@ print_attr_address(register u_char *data, u_int length, u_short attr_code ) /*************************************/ /* Returns nothing. */ /*************************************/ -static void print_attr_time(register u_char *data, u_int length, u_short attr_code) +static void print_attr_time(register u_char *data, u_int length, u_short attr_code _U_) { time_t attr_time; char string[26]; if (length != 4) { - printf("{length %u != 4}", length); + printf("ERROR: length %u != 4", length); return; } TCHECK2(data[0],4); - + attr_time = EXTRACT_32BITS(data); strlcpy(string, ctime(&attr_time), sizeof(string)); /* Get rid of the newline */ string[24] = '\0'; - printf("{%.24s}", string); + printf("%.24s", string); return; - + trunc: - printf("{|radius}"); + printf("|radius"); } - + /***********************************/ /* Print an attribute of 'strange' */ /* data format pointed by 'data' */ @@ -687,70 +730,67 @@ static void print_attr_time(register u_char *data, u_int length, u_short attr_co static void print_attr_strange(register u_char *data, u_int length, u_short attr_code) { u_short len_data; - + switch(attr_code) { case ARAP_PASS: if (length != 16) { - printf("{length %u != 16}", length); + printf("ERROR: length %u != 16", length); return; } - printf("{User_challenge["); + printf("User_challenge ("); TCHECK2(data[0],8); len_data = 8; PRINT_HEX(len_data, data); - printf("] User_resp["); + printf(") User_resp("); TCHECK2(data[0],8); len_data = 8; PRINT_HEX(len_data, data); - printf("]}"); + printf(")"); break; - + case ARAP_FEATURES: if (length != 14) { - printf("{length %u != 14}", length); + printf("ERROR: length %u != 14", length); return; } TCHECK2(data[0],1); if (*data) - printf("{User_can_change_pass"); + printf("User can change password"); else - printf("{User_cant_change_pass"); + printf("User cannot change password"); data++; TCHECK2(data[0],1); - printf(" Min_pass_len[%d]",*data); + printf(", Min password length: %d",*data); data++; - printf(" Pass_created_at["); + printf(", created at: "); TCHECK2(data[0],4); len_data = 4; PRINT_HEX(len_data, data); - printf("] Pass_expired_in["); + printf(", expires in: "); TCHECK2(data[0],4); len_data = 4; PRINT_HEX(len_data, data); - printf("] Current_time["); + printf(", Current Time: "); len_data = 4; TCHECK2(data[0],4); PRINT_HEX(len_data, data); - printf("]}"); break; case ARAP_CHALLENGE_RESP: if (length < 8) { - printf("{length %u != 8}", length); + printf("ERROR: length %u != 8", length); return; } - printf("{"); TCHECK2(data[0],8); len_data = 8; PRINT_HEX(len_data, data); - printf("}"); break; } - + trunc: printf("|radius}"); } @@ -761,48 +801,52 @@ static void radius_attr_print(register const u_char *attr, u_int length) { register const struct radius_attr *rad_attr = (struct radius_attr *)attr; - + if (length < 3) { printf(" [|radius]"); return; } - - printf(" Attr[ "); + while (length > 0) { - if (rad_attr->len == 0) + if (rad_attr->len == 0 && rad_attr->type < (TAM_SIZE(attr_type)-1)) { - printf("(zero-length attribute)"); - return; + printf("\n\t %s Attribute (%u), zero-length", + attr_type[rad_attr->type].name, + rad_attr->type); + return; } - if ( rad_attr->len <= length ) + if ( rad_attr->len <= length && rad_attr->type < (TAM_SIZE(attr_type)-1)) { - if ( !rad_attr->type || (rad_attr->type > (TAM_SIZE(attr_type)-1)) ) - printf("#%d",rad_attr->type); - else - { - printf(" %s",attr_type[rad_attr->type].name); - - if (rad_attr->len > 2) - { - if ( attr_type[rad_attr->type].print_func ) - (*attr_type[rad_attr->type].print_func)( - ((u_char *)(rad_attr+1)), - rad_attr->len - 2, rad_attr->type); - } - } + printf("\n\t %s Attribute (%u), length: %u, Value: ", + attr_type[rad_attr->type].name, + rad_attr->type, + rad_attr->len); + + if ( !rad_attr->type || (rad_attr->type > (TAM_SIZE(attr_type)-1)) ) { + } + else { + if (rad_attr->len > 2) + { + if ( attr_type[rad_attr->type].print_func ) + (*attr_type[rad_attr->type].print_func)( + ((u_char *)(rad_attr+1)), + rad_attr->len - 2, rad_attr->type); + } + } } - else - { + else { printf(" [|radius]"); return; } + /* do we want to see an additionally hexdump ? */ + if (vflag> 1 && rad_attr->len >= 2) + print_unknown_data((char *)rad_attr+2,"\n\t ",(rad_attr->len)-2); + length-=(rad_attr->len); rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len); } - - printf(" ]"); } @@ -810,10 +854,17 @@ void radius_print(const u_char *dat, u_int length) { register const struct radius_hdr *rad; - register int i; - int len; - - i = min(length, snapend - dat); + register u_int i; + u_int len, auth_idx; + + if (snapend < dat) + { + printf(" [|radius]"); + return; + } + i = snapend - dat; + if (i > length) + i = length; if (i < MIN_RADIUS_LEN) { @@ -822,7 +873,7 @@ radius_print(const u_char *dat, u_int length) } rad = (struct radius_hdr *)dat; - len = ntohs(rad->len); + len = EXTRACT_16BITS(&rad->len); if (len < MIN_RADIUS_LEN) { @@ -832,53 +883,28 @@ radius_print(const u_char *dat, u_int length) if (len < i) i = len; - - i -= MIN_RADIUS_LEN; - - switch (rad->code) - { - case RADCMD_ACCESS_REQ: - printf(" rad-access-req %d", length); - break; - - case RADCMD_ACCESS_ACC: - printf(" rad-access-accept %d", length); - break; - - case RADCMD_ACCESS_REJ: - printf(" rad-access-reject %d", length); - break; - case RADCMD_ACCOUN_REQ: - printf(" rad-account-req %d", length); - break; - - case RADCMD_ACCOUN_RES: - printf(" rad-account-resp %d", length); - break; - - case RADCMD_ACCESS_CHA: - printf(" rad-access-cha %d", length); - break; - - case RADCMD_STATUS_SER: - printf(" rad-status-serv %d", length); - break; - - case RADCMD_STATUS_CLI: - printf(" rad-status-cli %d", length); - break; - - case RADCMD_RESERVED: - printf(" rad-reserved %d", length); - break; + i -= MIN_RADIUS_LEN; - default: - printf(" rad-#%d %d", rad->code, length); - break; + if (vflag < 1) { + printf("RADIUS, %s (%u), id: 0x%02x length: %u", + tok2str(radius_command_values,"Unknown Command",rad->code), + rad->code, + rad->id, + length); + return; } - printf(" [id %d]", rad->id); - + else { + printf("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ", + length, + tok2str(radius_command_values,"Unknown Command",rad->code), + rad->code, + rad->id); + + for(auth_idx=0; auth_idx < 16; auth_idx++) + printf("%02x", rad->auth[auth_idx] ); + } + if (i) - radius_attr_print( dat + MIN_RADIUS_LEN, i); + radius_attr_print( dat + MIN_RADIUS_LEN, i); } diff --git a/contrib/tcpdump/print-raw.c b/contrib/tcpdump/print-raw.c index a3bfda8..00153e5 100644 --- a/contrib/tcpdump/print-raw.c +++ b/contrib/tcpdump/print-raw.c @@ -20,19 +20,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.34.4.1 2002/06/01 23:51:15 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.39.2.2 2003/11/16 08:51:40 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <pcap.h> #include <stdio.h> @@ -45,32 +41,13 @@ static const char rcsid[] = * The DLT_RAW packet has no header. It contains a raw IP packet. */ -void -raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +u_int +raw_if_print(const struct pcap_pkthdr *h, const u_char *p) { - u_int length = h->len; - u_int caplen = h->caplen; - - ++infodelay; - ts_print(&h->ts); - - /* - * Some printers want to get back at the link level addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. - */ - packetp = p; - snapend = p + caplen; - if (eflag) printf("ip: "); - ipN_print(p, length); + ipN_print(p, h->len); - if (xflag) - default_print(p, caplen); - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return (0); } diff --git a/contrib/tcpdump/print-rip.c b/contrib/tcpdump/print-rip.c index bb3d53a..8c4301f 100644 --- a/contrib/tcpdump/print-rip.c +++ b/contrib/tcpdump/print-rip.c @@ -20,22 +20,17 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.49 2001/05/10 05:30:22 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.55.2.2 2003/11/16 08:51:41 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> -#include <ctype.h> #include <string.h> #include "interface.h" @@ -43,10 +38,11 @@ static const char rcsid[] = #include "extract.h" /* must come after interface.h */ struct rip { - u_char rip_cmd; /* request/response */ - u_char rip_vers; /* protocol version # */ - u_short rip_zero2; /* unused */ + u_int8_t rip_cmd; /* request/response */ + u_int8_t rip_vers; /* protocol version # */ + u_int8_t unused[2]; /* unused */ }; + #define RIPCMD_REQUEST 1 /* want info */ #define RIPCMD_RESPONSE 2 /* responding to request */ #define RIPCMD_TRACEON 3 /* turn tracing on */ @@ -54,11 +50,43 @@ struct rip { #define RIPCMD_POLL 5 /* want info from everybody */ #define RIPCMD_POLLENTRY 6 /* poll for entry */ -#define RIP_AUTHLEN 16 +static const struct tok rip_cmd_values[] = { + { RIPCMD_REQUEST, "Request" }, + { RIPCMD_RESPONSE, "Response" }, + { RIPCMD_TRACEON, "Trace on" }, + { RIPCMD_TRACEOFF, "Trace off" }, + { RIPCMD_POLL, "Poll" }, + { RIPCMD_POLLENTRY, "Poll Entry" }, + { 0, NULL} +}; + +#define RIP_AUTHLEN 16 +#define RIP_ROUTELEN 20 + +/* + * rfc 1723 + * + * 0 1 2 3 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Command (1) | Version (1) | unused | + * +---------------+---------------+-------------------------------+ + * | Address Family Identifier (2) | Route Tag (2) | + * +-------------------------------+-------------------------------+ + * | IP Address (4) | + * +---------------------------------------------------------------+ + * | Subnet Mask (4) | + * +---------------------------------------------------------------+ + * | Next Hop (4) | + * +---------------------------------------------------------------+ + * | Metric (4) | + * +---------------------------------------------------------------+ + * + */ struct rip_netinfo { - u_short rip_family; - u_short rip_tag; + u_int16_t rip_family; + u_int16_t rip_tag; u_int32_t rip_dest; u_int32_t rip_dest_mask; u_int32_t rip_router; @@ -66,91 +94,65 @@ struct rip_netinfo { }; static void -rip_printblk(const u_char *cp, const u_char *ep) -{ - for (; cp < ep; cp += 2) - printf(" %04x", EXTRACT_16BITS(cp)); - return; -} - -static void -rip_entry_print_v1(register int vers, register const struct rip_netinfo *ni) +rip_entry_print_v1(register const struct rip_netinfo *ni) { register u_short family; /* RFC 1058 */ family = EXTRACT_16BITS(&ni->rip_family); if (family != AF_INET) { - printf(" [family %d:", family); - rip_printblk((u_char *)&ni->rip_tag, - (u_char *)&ni->rip_metric + - sizeof(ni->rip_metric)); - printf("]"); + printf("\n\t AFI: %u:", family); + print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN); return; } - if (ni->rip_tag || ni->rip_dest_mask || ni->rip_router) { + if (EXTRACT_16BITS(&ni->rip_tag) || + EXTRACT_32BITS(&ni->rip_dest_mask) || + EXTRACT_32BITS(&ni->rip_router)) { /* MBZ fields not zero */ - printf(" ["); - rip_printblk((u_char *)&ni->rip_family, - (u_char *)&ni->rip_metric + - sizeof(ni->rip_metric)); - printf("]"); + print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN); return; - } - printf(" {%s}(%d)", ipaddr_string(&ni->rip_dest), + } /* AF_INET */ + printf("\n\t %s, metric: %u", + ipaddr_string(&ni->rip_dest), EXTRACT_32BITS(&ni->rip_metric)); } static void -rip_entry_print_v2(register int vers, register const struct rip_netinfo *ni) +rip_entry_print_v2(register const struct rip_netinfo *ni) { register u_char *p; register u_short family; u_char buf[RIP_AUTHLEN]; - /* RFC 1723 */ family = EXTRACT_16BITS(&ni->rip_family); - if (family == 0xFFFF) { - if (EXTRACT_16BITS(&ni->rip_tag) == 2) { + if (family == 0xFFFF) { /* 16 bytes authentication ? */ + if (EXTRACT_16BITS(&ni->rip_tag) == 2) { /* simple text authentication ? */ memcpy(buf, &ni->rip_dest, sizeof(buf)); buf[sizeof(buf)-1] = '\0'; for (p = buf; *p; p++) { if (!isprint(*p)) break; } - if (!*p) { - printf(" [password %s]", buf); - } else { - printf(" [password: "); - rip_printblk((u_char *)&ni->rip_dest, - (u_char *)&ni->rip_metric + - sizeof(ni->rip_metric)); - printf("]"); - } - } else { - printf(" [auth %d:", + printf("\n\t Simple Text Authentication data: %s", buf); + } else { + printf("\n\t Unknown (%u) Authentication data:", EXTRACT_16BITS(&ni->rip_tag)); - rip_printblk((u_char *)&ni->rip_dest, - (u_char *)&ni->rip_metric + - sizeof(ni->rip_metric)); - printf("]"); + print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",RIP_AUTHLEN); } } else if (family != AF_INET) { - printf(" [family %d:", family); - rip_printblk((u_char *)&ni->rip_tag, - (u_char *)&ni->rip_metric + - sizeof(ni->rip_metric)); - printf("]"); + printf("\n\t AFI: %u", family); + print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t ",RIP_ROUTELEN-2); return; } else { /* AF_INET */ - printf(" {%s", ipaddr_string(&ni->rip_dest)); - if (ni->rip_dest_mask) - printf("/%s", ipaddr_string(&ni->rip_dest_mask)); - if (ni->rip_router) - printf("->%s", ipaddr_string(&ni->rip_router)); - if (ni->rip_tag) - printf(" tag %04x", EXTRACT_16BITS(&ni->rip_tag)); - printf("}(%d)", EXTRACT_32BITS(&ni->rip_metric)); + printf("\n\t AFI: IPv4: %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ", + ipaddr_string(&ni->rip_dest), + mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)), + EXTRACT_16BITS(&ni->rip_tag), + EXTRACT_32BITS(&ni->rip_metric)); + if (EXTRACT_32BITS(&ni->rip_router)) + printf("%s", ipaddr_string(&ni->rip_router)); + else + printf("self"); } } @@ -159,15 +161,28 @@ rip_print(const u_char *dat, u_int length) { register const struct rip *rp; register const struct rip_netinfo *ni; - register int i, j, trunc; + register u_int i, j; + register int trunc; - i = min(length, snapend - dat) - sizeof(*rp); - if (i < 0) { + if (snapend < dat) { printf(" [|rip]"); return; } + i = snapend - dat; + if (i > length) + i = length; + if (i < sizeof(*rp)) { + printf(" [|rip]"); + return; + } + i -= sizeof(*rp); rp = (struct rip *)dat; + + printf("%sRIPv%u", + (vflag >= 1) ? "\n\t" : "", + rp->rip_vers); + switch (rp->rip_vers) { case 0: /* @@ -179,57 +194,61 @@ rip_print(const u_char *dat, u_int length) * These are from a previous version of the protocol, whose * packet format was machine-specific. * - * so perhaps we should just dump the first few words of - * the packet, in hex. + * so perhaps we should just dump the packet, in hex. */ - printf(" RIPv0: "); - ni = (struct rip_netinfo *)(rp + 1); - rip_printblk((u_char *)&ni->rip_family, - (u_char *)&ni->rip_metric + - sizeof(ni->rip_metric)); + print_unknown_data((u_int8_t *)&rp->rip_cmd,"\n\t",length); break; default: + /* dump version and lets see if we know the commands name*/ + printf(", %s, length: %u", + tok2str(rip_cmd_values, + "unknown command (%u)", + rp->rip_cmd), + length); + + if (vflag < 1) + return; + switch (rp->rip_cmd) { - case RIPCMD_REQUEST: - printf(" RIPv%d-req %d", rp->rip_vers, length); - break; case RIPCMD_RESPONSE: j = length / sizeof(*ni); - if (j * sizeof(*ni) != length - 4) - printf(" RIPv%d-resp [items %d] [%d]:", - rp->rip_vers, j, length); - else - printf(" RIPv%d-resp [items %d]:", - rp->rip_vers, j); + printf(", routes: %u",j); trunc = (i / sizeof(*ni)) != j; ni = (struct rip_netinfo *)(rp + 1); - for (; (i -= sizeof(*ni)) >= 0; ++ni) { + for (; i >= sizeof(*ni); ++ni) { if (rp->rip_vers == 1) - rip_entry_print_v1(rp->rip_vers, ni); - else - rip_entry_print_v2(rp->rip_vers, ni); + rip_entry_print_v1(ni); + else if (rp->rip_vers == 2) + rip_entry_print_v2(ni); + else + break; + i -= sizeof(*ni); } if (trunc) printf("[|rip]"); break; - case RIPCMD_TRACEON: - printf(" RIPv%d-traceon %d: \"", rp->rip_vers, length); - (void)fn_print((const u_char *)(rp + 1), snapend); - fputs("\"", stdout); - break; + + case RIPCMD_REQUEST: case RIPCMD_TRACEOFF: - printf(" RIPv%d-traceoff %d", rp->rip_vers, length); - break; case RIPCMD_POLL: - printf(" RIPv%d-poll %d", rp->rip_vers, length); - break; case RIPCMD_POLLENTRY: - printf(" RIPv%d-pollentry %d", rp->rip_vers, length); - break; - default: - printf(" RIPv%d-#%d %d", rp->rip_vers, rp->rip_cmd, - length); break; - } - } + + case RIPCMD_TRACEON: + /* fall through */ + default: + if (vflag <= 1) { + if(!print_unknown_data((u_int8_t *)rp,"\n\t",length)) + return; + } + break; + } + /* do we want to see an additionally hexdump ? */ + if (vflag> 1) { + if(!print_unknown_data((u_int8_t *)rp,"\n\t",length)) + return; + } + } } + + diff --git a/contrib/tcpdump/print-ripng.c b/contrib/tcpdump/print-ripng.c index ad6d3f8..3432207 100644 --- a/contrib/tcpdump/print-ripng.c +++ b/contrib/tcpdump/print-ripng.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.10 2001/11/16 08:59:22 itojun Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.15.2.2 2003/11/16 08:51:42 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -30,19 +30,29 @@ static const char rcsid[] = #ifdef INET6 -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> +#ifdef WIN32 +const struct in6_addr in6addr_any; /* :: */ +#endif /* WIN32 */ + +#ifdef __MINGW32__ +int +IN6_ADDR_EQUAL(const struct in6_addr *a, const struct in6_addr *b) +{ + return (memcmp(a, b, sizeof(struct in6_addr)) == 0); +} + +#define IN6_IS_ADDR_UNSPECIFIED(a) IN6_ADDR_EQUAL((a), &in6addr_any) + +#endif /* __MINGW32__ */ -#include <errno.h> #include <stdio.h> #include "route6d.h" #include "interface.h" #include "addrtoname.h" +#include "extract.h" static int rip6_entry_print(register const struct netinfo6 *ni, int metric) @@ -50,7 +60,7 @@ rip6_entry_print(register const struct netinfo6 *ni, int metric) int l; l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen); if (ni->rip6_tag) - l += printf(" [%d]", ntohs(ni->rip6_tag)); + l += printf(" [%d]", EXTRACT_16BITS(&ni->rip6_tag)); if (metric) l += printf(" (%d)", ni->rip6_metric); return l; @@ -61,14 +71,18 @@ ripng_print(const u_char *dat, unsigned int length) { register const struct rip6 *rp = (struct rip6 *)dat; register const struct netinfo6 *ni; - register int amt = snapend - dat; - register int i = min(length, amt) - - (sizeof(struct rip6) - sizeof(struct netinfo6)); + register u_int amt; + register u_int i; int j; int trunc; - if (i < 0) + if (snapend < dat) + return; + amt = snapend - dat; + i = min(length, amt); + if (i < (sizeof(struct rip6) - sizeof(struct netinfo6))) return; + i -= (sizeof(struct rip6) - sizeof(struct netinfo6)); switch (rp->rip6_cmd) { @@ -85,7 +99,8 @@ ripng_print(const u_char *dat, unsigned int length) else printf(" ripng-req %d:", j); trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i); - for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) { + for (ni = rp->rip6_nets; i >= sizeof(*ni); + i -= sizeof(*ni), ++ni) { if (vflag > 1) printf("\n\t"); else @@ -100,7 +115,8 @@ ripng_print(const u_char *dat, unsigned int length) else printf(" ripng-resp %d:", j); trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i); - for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) { + for (ni = rp->rip6_nets; i >= sizeof(*ni); + i -= sizeof(*ni), ++ni) { if (vflag > 1) printf("\n\t"); else diff --git a/contrib/tcpdump/print-rsvp.c b/contrib/tcpdump/print-rsvp.c new file mode 100644 index 0000000..534878e --- /dev/null +++ b/contrib/tcpdump/print-rsvp.c @@ -0,0 +1,1254 @@ +/* + * 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. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.24.2.3 2004/03/24 04:01:08 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" +#include "ethertype.h" +#include "gmpls.h" + +/* + * RFC 2205 common header + * + * 0 1 2 3 + * +-------------+-------------+-------------+-------------+ + * | Vers | Flags| Msg Type | RSVP Checksum | + * +-------------+-------------+-------------+-------------+ + * | Send_TTL | (Reserved) | RSVP Length | + * +-------------+-------------+-------------+-------------+ + * + */ + +struct rsvp_common_header { + u_int8_t version_flags; + u_int8_t msg_type; + u_int8_t checksum[2]; + u_int8_t ttl; + u_int8_t reserved; + u_int8_t length[2]; +}; + +/* + * RFC2205 object header + * + * + * 0 1 2 3 + * +-------------+-------------+-------------+-------------+ + * | Length (bytes) | Class-Num | C-Type | + * +-------------+-------------+-------------+-------------+ + * | | + * // (Object contents) // + * | | + * +-------------+-------------+-------------+-------------+ + */ + +struct rsvp_object_header { + u_int8_t length[2]; + u_int8_t class_num; + u_int8_t ctype; +}; + +#define RSVP_VERSION 1 +#define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) +#define RSVP_EXTRACT_FLAGS(x) ((x)&0x0f) + +#define RSVP_MSGTYPE_PATH 1 +#define RSVP_MSGTYPE_RESV 2 +#define RSVP_MSGTYPE_PATHERR 3 +#define RSVP_MSGTYPE_RESVERR 4 +#define RSVP_MSGTYPE_PATHTEAR 5 +#define RSVP_MSGTYPE_RESVTEAR 6 +#define RSVP_MSGTYPE_RESVCONF 7 +#define RSVP_MSGTYPE_AGGREGATE 12 +#define RSVP_MSGTYPE_ACK 13 +#define RSVP_MSGTYPE_HELLO_OLD 14 /* ancient Hellos */ +#define RSVP_MSGTYPE_SREFRESH 15 +#define RSVP_MSGTYPE_HELLO 20 + +static const struct tok rsvp_msg_type_values[] = { + { RSVP_MSGTYPE_PATH, "Path" }, + { RSVP_MSGTYPE_RESV, "Resv" }, + { RSVP_MSGTYPE_PATHERR, "PathErr" }, + { RSVP_MSGTYPE_RESVERR, "ResvErr" }, + { RSVP_MSGTYPE_PATHTEAR, "PathTear" }, + { RSVP_MSGTYPE_RESVTEAR, "ResvTear" }, + { RSVP_MSGTYPE_RESVCONF, "ResvConf" }, + { RSVP_MSGTYPE_AGGREGATE, "Aggregate" }, + { RSVP_MSGTYPE_ACK, "Acknowledgement" }, + { RSVP_MSGTYPE_HELLO_OLD, "Hello (Old)" }, + { RSVP_MSGTYPE_SREFRESH, "Refresh" }, + { RSVP_MSGTYPE_HELLO, "Hello" }, + { 0, NULL} +}; + +static const struct tok rsvp_header_flag_values[] = { + { 0x01, "Refresh reduction capable" }, /* rfc2961 */ + { 0, NULL} +}; + +#define RSVP_OBJ_SESSION 1 /* rfc2205 */ +#define RSVP_OBJ_RSVP_HOP 3 /* rfc2205, rfc3473 */ +#define RSVP_OBJ_INTEGRITY 4 +#define RSVP_OBJ_TIME_VALUES 5 /* rfc2205 */ +#define RSVP_OBJ_ERROR_SPEC 6 +#define RSVP_OBJ_SCOPE 7 +#define RSVP_OBJ_STYLE 8 /* rfc2205 */ +#define RSVP_OBJ_FLOWSPEC 9 /* rfc2215 */ +#define RSVP_OBJ_FILTERSPEC 10 /* rfc2215 */ +#define RSVP_OBJ_SENDER_TEMPLATE 11 +#define RSVP_OBJ_SENDER_TSPEC 12 /* rfc2215 */ +#define RSVP_OBJ_ADSPEC 13 /* rfc2215 */ +#define RSVP_OBJ_POLICY_DATA 14 +#define RSVP_OBJ_CONFIRM 15 /* rfc2205 */ +#define RSVP_OBJ_LABEL 16 /* rfc3209 */ +#define RSVP_OBJ_LABEL_REQ 19 /* rfc3209 */ +#define RSVP_OBJ_ERO 20 /* rfc3209 */ +#define RSVP_OBJ_RRO 21 /* rfc3209 */ +#define RSVP_OBJ_HELLO 22 /* rfc3209 */ +#define RSVP_OBJ_MESSAGE_ID 23 +#define RSVP_OBJ_MESSAGE_ID_ACK 24 +#define RSVP_OBJ_MESSAGE_ID_LIST 25 +#define RSVP_OBJ_RECOVERY_LABEL 34 /* rfc3473 */ +#define RSVP_OBJ_UPSTREAM_LABEL 35 /* rfc3473 */ +#define RSVP_OBJ_LABEL_SET 36 /* rfc3473 */ +#define RSVP_OBJ_PROTECTION 37 /* rfc3473 */ +#define RSVP_OBJ_DETOUR 63 /* draft-ietf-mpls-rsvp-lsp-fastreroute-01 */ +#define RSVP_OBJ_SUGGESTED_LABEL 129 /* rfc3473 */ +#define RSVP_OBJ_ACCEPT_LABEL_SET 130 /* rfc3473 */ +#define RSVP_OBJ_RESTART_CAPABILITY 131 /* rfc3473 */ +#define RSVP_OBJ_NOTIFY_REQ 195 /* rfc3473 */ +#define RSVP_OBJ_ADMIN_STATUS 196 /* rfc3473 */ +#define RSVP_OBJ_PROPERTIES 204 /* juniper proprietary */ +#define RSVP_OBJ_FASTREROUTE 205 /* draft-ietf-mpls-rsvp-lsp-fastreroute-01 */ +#define RSVP_OBJ_SESSION_ATTRIBUTE 207 /* rfc3209 */ +#define RSVP_OBJ_CALL_ID 230 /* rfc3474 */ +#define RSVP_OBJ_CALL_OPS 236 /* rfc3474 */ + +static const struct tok rsvp_obj_values[] = { + { RSVP_OBJ_SESSION, "Session" }, + { RSVP_OBJ_RSVP_HOP, "RSVP Hop" }, + { RSVP_OBJ_INTEGRITY, "Integrity" }, + { RSVP_OBJ_TIME_VALUES, "Time Values" }, + { RSVP_OBJ_ERROR_SPEC, "Error Spec" }, + { RSVP_OBJ_SCOPE, "Scope" }, + { RSVP_OBJ_STYLE, "Style" }, + { RSVP_OBJ_FLOWSPEC, "Flowspec" }, + { RSVP_OBJ_FILTERSPEC, "FilterSpec" }, + { RSVP_OBJ_SENDER_TEMPLATE, "Sender Template" }, + { RSVP_OBJ_SENDER_TSPEC, "Sender TSpec" }, + { RSVP_OBJ_ADSPEC, "Adspec" }, + { RSVP_OBJ_POLICY_DATA, "Policy Data" }, + { RSVP_OBJ_CONFIRM, "Confirm" }, + { RSVP_OBJ_LABEL, "Label" }, + { RSVP_OBJ_LABEL_REQ, "Label Request" }, + { RSVP_OBJ_ERO, "ERO" }, + { RSVP_OBJ_RRO, "RRO" }, + { RSVP_OBJ_HELLO, "Hello" }, + { RSVP_OBJ_MESSAGE_ID, "Message ID" }, + { RSVP_OBJ_MESSAGE_ID_ACK, "Message ID Ack" }, + { RSVP_OBJ_MESSAGE_ID_LIST, "Message ID List" }, + { RSVP_OBJ_RECOVERY_LABEL, "Recovery Label" }, + { RSVP_OBJ_UPSTREAM_LABEL, "Upstream Label" }, + { RSVP_OBJ_LABEL_SET, "Label Set" }, + { RSVP_OBJ_ACCEPT_LABEL_SET, "Acceptable Label Set" }, + { RSVP_OBJ_DETOUR, "Detour" }, + { RSVP_OBJ_SUGGESTED_LABEL, "Suggested Label" }, + { RSVP_OBJ_PROPERTIES, "Properties" }, + { RSVP_OBJ_FASTREROUTE, "Fast Re-Route" }, + { RSVP_OBJ_SESSION_ATTRIBUTE, "Session Attribute" }, + { RSVP_OBJ_CALL_ID, "Call-ID" }, + { RSVP_OBJ_CALL_OPS, "Call Capability" }, + { RSVP_OBJ_RESTART_CAPABILITY, "Restart Capability" }, + { RSVP_OBJ_NOTIFY_REQ, "Notify Request" }, + { RSVP_OBJ_PROTECTION, "Protection" }, + { RSVP_OBJ_ADMIN_STATUS, "Administrative Status" }, + { 0, NULL} +}; + +#define RSVP_CTYPE_IPV4 1 +#define RSVP_CTYPE_IPV6 2 +#define RSVP_CTYPE_TUNNEL_IPV4 7 +#define RSVP_CTYPE_TUNNEL_IPV6 8 +#define RSVP_CTYPE_1 1 +#define RSVP_CTYPE_2 2 +#define RSVP_CTYPE_3 3 +#define RSVP_CTYPE_4 4 + +/* + * the ctypes are not globally unique so for + * translating it to strings we build a table based + * on objects offsetted by the ctype + */ + +static const struct tok rsvp_ctype_values[] = { + { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV4, "IPv4" }, + { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV6, "IPv6" }, + { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_3, "IPv4 plus opt. TLVs" }, + { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_4, "IPv6 plus opt. TLVs" }, + { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV4, "IPv4" }, + { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV6, "IPv6" }, + { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV4, "IPv4" }, + { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV6, "IPv6" }, + { 256*RSVP_OBJ_TIME_VALUES+RSVP_CTYPE_1, "1" }, + { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_1, "obsolete" }, + { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_2, "IntServ" }, + { 256*RSVP_OBJ_SENDER_TSPEC+RSVP_CTYPE_2, "IntServ" }, + { 256*RSVP_OBJ_ADSPEC+RSVP_CTYPE_2, "IntServ" }, + { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV4, "IPv4" }, + { 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_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_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_STYLE+RSVP_CTYPE_1, "1" }, + { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_1, "Hello Request" }, + { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_2, "Hello Ack" }, + { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_1, "without label range" }, + { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_2, "with ATM label range" }, + { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_3, "with FR label range" }, + { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_4, "Generalized Label" }, + { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_1, "Label" }, + { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_2, "Generalized Label" }, + { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, + { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_1, "Label" }, + { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_2, "Generalized Label" }, + { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, + { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_1, "Label" }, + { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_2, "Generalized Label" }, + { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, + { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_1, "Label" }, + { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_2, "Generalized Label" }, + { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, + { 256*RSVP_OBJ_ERO+RSVP_CTYPE_IPV4, "IPv4" }, + { 256*RSVP_OBJ_RRO+RSVP_CTYPE_IPV4, "IPv4" }, + { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV4, "IPv4" }, + { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV6, "IPv6" }, + { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_3, "IPv4 plus opt. TLVs" }, + { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_4, "IPv6 plus opt. TLVs" }, + { 256*RSVP_OBJ_RESTART_CAPABILITY+RSVP_CTYPE_1, "IPv4" }, + { 256*RSVP_OBJ_SESSION_ATTRIBUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, + { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, + { 256*RSVP_OBJ_DETOUR+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, + { 256*RSVP_OBJ_PROPERTIES+RSVP_CTYPE_1, "1" }, + { 0, NULL} +}; + +#define RSVP_OBJ_XRO_MASK_SUBOBJ(x) ((x)&0x7f) +#define RSVP_OBJ_XRO_MASK_LOOSE(x) ((x)&0x80) + +#define RSVP_OBJ_XRO_RES 0 +#define RSVP_OBJ_XRO_IPV4 1 +#define RSVP_OBJ_XRO_IPV6 2 +#define RSVP_OBJ_XRO_ASN 32 +#define RSVP_OBJ_XRO_MPLS 64 + +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_ASN, "Autonomous system number" }, + { RSVP_OBJ_XRO_MPLS, "MPLS label switched path termination" }, + { 0, NULL} +}; + +/* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */ +static const struct tok rsvp_obj_rro_flag_values[] = { + { 0x01, "Local protection available" }, + { 0x02, "Local protection in use" }, + { 0x04, "Bandwidth protection" }, + { 0x08, "Node protection" }, + { 0, NULL} +}; + +static const struct tok rsvp_resstyle_values[] = { + { 17, "Wildcard Filter" }, + { 10, "Fixed Filter" }, + { 18, "Shared Explicit" }, + { 0, NULL} +}; + +#define RSVP_OBJ_INTSERV_GUARANTEED_SERV 2 +#define RSVP_OBJ_INTSERV_CONTROLLED_LOAD 5 + +static const struct tok rsvp_intserv_service_type_values[] = { + { 1, "Default/Global Information" }, + { RSVP_OBJ_INTSERV_GUARANTEED_SERV, "Guaranteed Service" }, + { RSVP_OBJ_INTSERV_CONTROLLED_LOAD, "Controlled Load" }, + { 0, NULL} +}; + +static const struct tok rsvp_intserv_parameter_id_values[] = { + { 4, "IS hop cnt" }, + { 6, "Path b/w estimate" }, + { 8, "Minimum path latency" }, + { 10, "Composed MTU" }, + { 127, "Token Bucket TSpec" }, + { 130, "Guaranteed Service RSpec" }, + { 133, "End-to-end composed value for C" }, + { 134, "End-to-end composed value for D" }, + { 135, "Since-last-reshaping point composed C" }, + { 136, "Since-last-reshaping point composed D" }, + { 0, NULL} +}; + +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 */ + { 0, NULL} +}; + +static struct tok rsvp_obj_prop_tlv_values[] = { + { 0x01, "Cos" }, + { 0x02, "Metric 1" }, + { 0x04, "Metric 2" }, + { 0x08, "CCC Status" }, + { 0x10, "Path Type" }, + { 0, NULL} +}; + +#define RSVP_OBJ_ERROR_SPEC_CODE_ROUTING 24 +#define RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY 25 + +static struct tok rsvp_obj_error_code_values[] = { + { RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" }, + { RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY, "Notify Error" }, + { 0, NULL} +}; + +static struct tok rsvp_obj_error_code_routing_values[] = { + { 1, "Bad EXPLICIT_ROUTE object" }, + { 2, "Bad strict node" }, + { 3, "Bad loose node" }, + { 4, "Bad initial subobject" }, + { 5, "No route available toward destination" }, + { 6, "Unacceptable label value" }, + { 7, "RRO indicated routing loops" }, + { 8, "non-RSVP-capable router in the path" }, + { 9, "MPLS label allocation failure" }, + { 10, "Unsupported L3PID" }, + { 0, NULL} +}; + +#define FALSE 0 +#define TRUE 1 + + +static int rsvp_intserv_print(const u_char *, u_short); + +/* + * this is a dissector for all the intserv defined + * specs as defined per rfc2215 + * it is called from various rsvp objects; + * returns the amount of bytes being processed + */ +static int +rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) { + + int parameter_id,parameter_length; + union { + float f; + u_int32_t i; + } bw; + + if (obj_tlen < 4) + return 0; + parameter_id = *(tptr); + parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */ + + printf("\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]", + tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id), + parameter_id, + parameter_length, + *(tptr+1)); + + if (obj_tlen < parameter_length+4) + return 0; + switch(parameter_id) { /* parameter_id */ + + case 4: + /* + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 4 (e) | (f) | 1 (g) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IS hop cnt (32-bit unsigned integer) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + if (parameter_length == 4) + printf("\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr+4)); + break; + + case 6: + /* + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 6 (h) | (i) | 1 (j) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Path b/w estimate (32-bit IEEE floating point number) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + if (parameter_length == 4) { + bw.i = EXTRACT_32BITS(tptr+4); + printf("\n\t\tPath b/w estimate: %.10g Mbps", bw.f/125000); + } + break; + + case 8: + /* + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 8 (k) | (l) | 1 (m) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Minimum path latency (32-bit integer) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + if (parameter_length == 4) { + printf("\n\t\tMinimum path latency: "); + if (EXTRACT_32BITS(tptr+4) == 0xffffffff) + printf("don't care"); + else + printf("%u", EXTRACT_32BITS(tptr+4)); + } + break; + + case 10: + + /* + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 10 (n) | (o) | 1 (p) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Composed MTU (32-bit unsigned integer) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + if (parameter_length == 4) + printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4)); + break; + case 127: + /* + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 127 (e) | 0 (f) | 5 (g) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Token Bucket Rate [r] (32-bit IEEE floating point number) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Token Bucket Size [b] (32-bit IEEE floating point number) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Peak Data Rate [p] (32-bit IEEE floating point number) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Minimum Policed Unit [m] (32-bit integer) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Maximum Packet Size [M] (32-bit integer) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + if (parameter_length == 20) { + bw.i = EXTRACT_32BITS(tptr+4); + printf("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f/125000); + bw.i = EXTRACT_32BITS(tptr+8); + printf("\n\t\tToken Bucket Size: %.10g bytes", bw.f); + bw.i = EXTRACT_32BITS(tptr+12); + printf("\n\t\tPeak Data Rate: %.10g Mbps", bw.f/125000); + printf("\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr+16)); + printf("\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr+20)); + } + break; + + case 130: + /* + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 130 (h) | 0 (i) | 2 (j) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Rate [R] (32-bit IEEE floating point number) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Slack Term [S] (32-bit integer) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + if (parameter_length == 8) { + bw.i = EXTRACT_32BITS(tptr+4); + printf("\n\t\tRate: %.10g Mbps", bw.f/125000); + printf("\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr+8)); + } + break; + + case 133: + case 134: + case 135: + case 136: + if (parameter_length == 4) + printf("\n\t\tValue: %u", EXTRACT_32BITS(tptr+4)); + break; + + default: + if (vflag <= 1) + print_unknown_data(tptr+4,"\n\t\t",parameter_length); + } + return (parameter_length+4); /* header length 4 bytes */ +} + +void +rsvp_print(register const u_char *pptr, register u_int len) { + + const struct rsvp_common_header *rsvp_com_header; + const struct rsvp_object_header *rsvp_obj_header; + const u_char *tptr,*obj_tptr; + u_short tlen,rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen; + int hexdump,processed,padbytes,error_code,error_value; + union { + float f; + u_int32_t i; + } bw; + u_int8_t namelen; + u_int i; + + tptr=pptr; + rsvp_com_header = (const struct rsvp_common_header *)pptr; + TCHECK(*rsvp_com_header); + + /* + * Sanity checking of the header. + */ + if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) { + printf("RSVP version %u packet not supported", + RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)); + return; + } + + /* in non-verbose mode just lets print the basic Message Type*/ + if (vflag < 1) { + printf("RSVP %s Message, length: %u", + tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type), + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + + tlen=EXTRACT_16BITS(rsvp_com_header->length); + + printf("RSVP\n\tv: %u, msg-type: %s, Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x", + RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags), + tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type), + bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)), + tlen, + rsvp_com_header->ttl, + EXTRACT_16BITS(rsvp_com_header->checksum)); + + if (tlen < sizeof(const struct rsvp_common_header)) + return; + tptr+=sizeof(const struct rsvp_common_header); + tlen-=sizeof(const struct rsvp_common_header); + + while(tlen>0) { + /* did we capture enough for fully decoding the object header ? */ + if (!TTEST2(*tptr, sizeof(struct rsvp_object_header))) + goto trunc; + + rsvp_obj_header = (const struct rsvp_object_header *)tptr; + rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length); + rsvp_obj_ctype=rsvp_obj_header->ctype; + + if(rsvp_obj_len % 4 || rsvp_obj_len < sizeof(struct rsvp_object_header)) + return; + + printf("\n\t %s Object (%u) Flags: [%s", + tok2str(rsvp_obj_values, + "Unknown", + rsvp_obj_header->class_num), + rsvp_obj_header->class_num, + ((rsvp_obj_header->class_num)&0x80) ? "ignore" : "reject"); + + if (rsvp_obj_header->class_num > 128) + printf(" %s", + ((rsvp_obj_header->class_num)&0x40) ? "and forward" : "silently"); + + printf(" if unknown], Class-Type: %s (%u), length: %u", + tok2str(rsvp_ctype_values, + "Unknown", + ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype), + rsvp_obj_ctype, + rsvp_obj_len); + + obj_tptr=tptr+sizeof(struct rsvp_object_header); + obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header); + + /* did we capture enough for fully decoding the object ? */ + if (!TTEST2(*tptr, rsvp_obj_len)) + goto trunc; + hexdump=FALSE; + + switch(rsvp_obj_header->class_num) { + case RSVP_OBJ_SESSION: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return; + printf("\n\t IPv4 DestAddress: %s, Protocol ID: 0x%02x", + ipaddr_string(obj_tptr), + *(obj_tptr+4)); + printf("\n\t Flags: [0x%02x], DestPort %u", + *(obj_tptr+5), + EXTRACT_16BITS(obj_tptr+6)); + obj_tlen-=8; + obj_tptr+=8; + break; +#ifdef INET6 + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return; + printf("\n\t IPv6 DestAddress: %s, Protocol ID: 0x%02x", + ip6addr_string(obj_tptr), + *(obj_tptr+16)); + printf("\n\t Flags: [0x%02x], DestPort %u", + *(obj_tptr+17), + EXTRACT_16BITS(obj_tptr+18)); + obj_tlen-=20; + obj_tptr+=20; + break; + + case RSVP_CTYPE_TUNNEL_IPV6: + if (obj_tlen < 36) + return; + printf("\n\t IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", + ip6addr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+18), + ip6addr_string(obj_tptr+20)); + obj_tlen-=36; + obj_tptr+=36; + break; +#endif + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 12) + return; + printf("\n\t IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", + ipaddr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ipaddr_string(obj_tptr+8)); + obj_tlen-=12; + obj_tptr+=12; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_CONFIRM: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 4) + return; + printf("\n\t IPv4 Receiver Address: %s", + ipaddr_string(obj_tptr)); + obj_tlen-=4; + obj_tptr+=4; + break; +#ifdef INET6 + case RSVP_CTYPE_IPV6: + if (obj_tlen < 16) + return; + printf("\n\t IPv6 Receiver Address: %s", + ip6addr_string(obj_tptr)); + obj_tlen-=16; + obj_tptr+=16; + break; +#endif + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_NOTIFY_REQ: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 4) + return; + printf("\n\t IPv4 Notify Node Address: %s", + ipaddr_string(obj_tptr)); + obj_tlen-=4; + obj_tptr+=4; + break; +#ifdef INET6 + case RSVP_CTYPE_IPV6: + if (obj_tlen < 16) + return; + printf("\n\t IPv6 Notify Node Address: %s", + ip6addr_string(obj_tptr)); + obj_tlen-=16; + obj_tptr+=16; + break; +#endif + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */ + case RSVP_OBJ_UPSTREAM_LABEL: /* fall through */ + case RSVP_OBJ_RECOVERY_LABEL: /* fall through */ + case RSVP_OBJ_LABEL: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + while(obj_tlen >= 4 ) { + printf("\n\t Label: %u", EXTRACT_32BITS(obj_tptr)); + obj_tlen-=4; + obj_tptr+=4; + } + break; + case RSVP_CTYPE_2: + if (obj_tlen < 4) + return; + printf("\n\t Generalized Label: %u", + EXTRACT_32BITS(obj_tptr)); + obj_tlen-=4; + obj_tptr+=4; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 12) + return; + printf("\n\t Waveband ID: %u\n\t Start Label: %u, Stop Label: %u", + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr+4), + EXTRACT_32BITS(obj_tptr+8)); + obj_tlen-=12; + obj_tptr+=12; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_STYLE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return; + printf("\n\t Reservation Style: %s, Flags: [0x%02x]", + tok2str(rsvp_resstyle_values, + "Unknown", + EXTRACT_24BITS(obj_tptr+1)), + *(obj_tptr)); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SENDER_TEMPLATE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return; + printf("\n\t Source Address: %s, Source Port: %u", + ipaddr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+6)); + obj_tlen-=8; + obj_tptr+=8; + break; +#ifdef INET6 + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return; + printf("\n\t Source Address: %s, Source Port: %u", + ip6addr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+18)); + obj_tlen-=20; + obj_tptr+=20; + break; +#endif + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 8) + return; + printf("\n\t IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x", + ipaddr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+6)); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_LABEL_REQ: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + while(obj_tlen >= 4 ) { + printf("\n\t L3 Protocol ID: %s", + tok2str(ethertype_values, + "Unknown Protocol (0x%04x)", + EXTRACT_16BITS(obj_tptr+2))); + obj_tlen-=4; + obj_tptr+=4; + } + break; + case RSVP_CTYPE_2: + if (obj_tlen < 12) + return; + printf("\n\t L3 Protocol ID: %s", + tok2str(ethertype_values, + "Unknown Protocol (0x%04x)", + EXTRACT_16BITS(obj_tptr+2))); + printf(",%s merge capability",((*(obj_tptr+4))&0x80) ? "no" : "" ); + printf("\n\t Minimum VPI/VCI: %u/%u", + (EXTRACT_16BITS(obj_tptr+4))&0xfff, + (EXTRACT_16BITS(obj_tptr+6))&0xfff); + printf("\n\t Maximum VPI/VCI: %u/%u", + (EXTRACT_16BITS(obj_tptr+8))&0xfff, + (EXTRACT_16BITS(obj_tptr+10))&0xfff); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 12) + return; + printf("\n\t L3 Protocol ID: %s", + tok2str(ethertype_values, + "Unknown Protocol (0x%04x)", + EXTRACT_16BITS(obj_tptr+2))); + printf("\n\t Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI", + (EXTRACT_32BITS(obj_tptr+4))&0x7fffff, + (EXTRACT_32BITS(obj_tptr+8))&0x7fffff, + (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "", + (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 2 ) ? "23" : ""); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_4: + if (obj_tlen < 8) + return; + printf("\n\t LSP Encoding Type: %s (%u)", + tok2str(gmpls_encoding_values, + "Unknown", + *obj_tptr), + *obj_tptr); + printf("\n\t Switching Type: %s (%u), Payload ID: %s (0x%04x)", + tok2str(gmpls_switch_cap_values, + "Unknown", + *(obj_tptr+1)), + *(obj_tptr+1), + tok2str(gmpls_payload_values, + "Unknown", + EXTRACT_16BITS(obj_tptr+2)), + EXTRACT_16BITS(obj_tptr+2)); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RRO: + case RSVP_OBJ_ERO: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + while(obj_tlen >= 4 ) { + printf("\n\t Subobject Type: %s", + tok2str(rsvp_obj_xro_values, + "Unknown %u", + RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr))); + switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) { + case RSVP_OBJ_XRO_IPV4: + printf(", %s, %s/%u, Flags: [%s]", + RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict", + ipaddr_string(obj_tptr+2), + *(obj_tptr+6), + bittok2str(rsvp_obj_rro_flag_values, + "none", + *(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */ + } + obj_tlen-=*(obj_tptr+1); + obj_tptr+=*(obj_tptr+1); + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_HELLO: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + case RSVP_CTYPE_2: + if (obj_tlen < 8) + return; + printf("\n\t Source Instance: 0x%08x, Destination Instance: 0x%08x", + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr+4)); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RESTART_CAPABILITY: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 8) + return; + printf("\n\t Restart Time: %ums, Recovery Time: %ums", + EXTRACT_16BITS(obj_tptr), + EXTRACT_16BITS(obj_tptr+4)); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SESSION_ATTRIBUTE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 4) + return; + namelen = *(obj_tptr+3); + if (obj_tlen < 4+namelen) + return; + printf("\n\t Session Name: "); + for (i = 0; i < namelen; i++) + safeputchar(*(obj_tptr+4+i)); + printf("\n\t Setup Priority: %u, Holding Priority: %u, Flags: [%s]", + (int)*obj_tptr, + (int)*(obj_tptr+1), + tok2str(rsvp_session_attribute_flag_values, + "none", + *(obj_tptr+2))); + + obj_tlen-=4+*(obj_tptr+3); + obj_tptr+=4+*(obj_tptr+3); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RSVP_HOP: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return; + printf("\n\t Previous/Next Interface: %s, Logical Interface Handle: 0x%08x", + ipaddr_string(obj_tptr), + EXTRACT_32BITS(obj_tptr+4)); + obj_tlen-=8; + obj_tptr+=8; + hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ + break; +#ifdef INET6 + case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return; + printf("\n\t Previous/Next Interface: %s, Logical Interface Handle: 0x%08x", + ip6addr_string(obj_tptr), + EXTRACT_32BITS(obj_tptr+16)); + obj_tlen-=20; + obj_tptr+=20; + hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ + break; +#endif + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_TIME_VALUES: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return; + printf("\n\t Refresh Period: %ums", + EXTRACT_32BITS(obj_tptr)); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + /* those three objects do share the same semantics */ + case RSVP_OBJ_SENDER_TSPEC: + case RSVP_OBJ_ADSPEC: + case RSVP_OBJ_FLOWSPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_2: + if (obj_tlen < 4) + return; + printf("\n\t Msg-Version: %u, length: %u", + (*obj_tptr & 0xf0) >> 4, + EXTRACT_16BITS(obj_tptr+2)<<2); + obj_tptr+=4; /* get to the start of the service header */ + obj_tlen-=4; + + while (obj_tlen >= 4) { + intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2; + printf("\n\t Service Type: %s (%u), break bit %s set, Service length: %u", + tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)), + *(obj_tptr), + (*(obj_tptr+1)&0x80) ? "" : "not", + intserv_serv_tlen); + + obj_tptr+=4; /* get to the start of the parameter list */ + obj_tlen-=4; + + while (intserv_serv_tlen>=4) { + processed = rsvp_intserv_print(obj_tptr, obj_tlen); + if (processed == 0) + break; + obj_tlen-=processed; + intserv_serv_tlen-=processed; + obj_tptr+=processed; + } + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_FILTERSPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return; + printf("\n\t Source Address: %s, Source Port: %u", + ipaddr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+6)); + obj_tlen-=8; + obj_tptr+=8; + break; +#ifdef INET6 + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return; + printf("\n\t Source Address: %s, Source Port: %u", + ip6addr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+18)); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 20) + return; + printf("\n\t Source Address: %s, Flow Label: %u", + ip6addr_string(obj_tptr), + EXTRACT_24BITS(obj_tptr+17)); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_TUNNEL_IPV6: + if (obj_tlen < 20) + return; + printf("\n\t Source Address: %s, LSP-ID: 0x%04x", + ipaddr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+18)); + obj_tlen-=20; + obj_tptr+=20; + break; +#endif + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 8) + return; + printf("\n\t Source Address: %s, LSP-ID: 0x%04x", + ipaddr_string(obj_tptr), + EXTRACT_16BITS(obj_tptr+6)); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_FASTREROUTE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 16) + return; + bw.i = EXTRACT_32BITS(obj_tptr+4); + printf("\n\t Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps", + (int)*obj_tptr, + (int)*(obj_tptr+1), + (int)*(obj_tptr+2), + bw.f*8/1000000); + printf("\n\t Include Colors: 0x%08x, Exclude Colors: 0x%08x", + EXTRACT_32BITS(obj_tptr+8), + EXTRACT_32BITS(obj_tptr+12)); + obj_tlen-=16; + obj_tptr+=16; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_DETOUR: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_TUNNEL_IPV4: + while(obj_tlen >= 8) { + printf("\n\t PLR-ID: %s, Avoid-Node-ID: %s", + ipaddr_string(obj_tptr), + ipaddr_string(obj_tptr+4)); + obj_tlen-=8; + obj_tptr+=8; + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_ERROR_SPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return; + error_code=*(obj_tptr+5); + error_value=EXTRACT_16BITS(obj_tptr+6); + printf("\n\t Error Node Adress: %s, Flags: [0x%02x]\n\t Error Code: %s (%u)", + ipaddr_string(obj_tptr), + *(obj_tptr+4), + tok2str(rsvp_obj_error_code_values,"unknown",error_code), + error_code); + switch (error_code) { + case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: + printf(", Error Value: %s (%u)", + tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value), + error_value); + break; + default: + printf(", Unknown Error Value (%u)", error_value); + break; + } + obj_tlen-=8; + obj_tptr+=8; + break; +#ifdef INET6 + case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return; + error_code=*(obj_tptr+17); + error_value=EXTRACT_16BITS(obj_tptr+18); + printf("\n\t Error Node Adress: %s, Flags: [0x%02x]\n\t Error Code: %s (%u)", + ip6addr_string(obj_tptr), + *(obj_tptr+16), + tok2str(rsvp_obj_error_code_values,"unknown",error_code), + error_code); + + switch (error_code) { + case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: + printf(", Error Value: %s (%u)", + tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value), + error_value); + break; + default: + break; + } + obj_tlen-=20; + obj_tptr+=20; + break; +#endif + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_PROPERTIES: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return; + padbytes = EXTRACT_16BITS(obj_tptr+2); + printf("\n\t TLV count: %u, padding bytes: %u", + EXTRACT_16BITS(obj_tptr), + padbytes); + obj_tlen-=4; + obj_tptr+=4; + /* loop through as long there is anything longer than the TLV header (2) */ + while(obj_tlen >= 2 + padbytes) { + printf("\n\t %s TLV (0x%02x), length: %u", /* length includes header */ + tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr), + *obj_tptr, + *(obj_tptr+1)); + if (obj_tlen < *(obj_tptr+1)) + return; + print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2); + obj_tlen-=*(obj_tptr+1); + obj_tptr+=*(obj_tptr+1); + } + break; + default: + hexdump=TRUE; + } + break; + + /* + * FIXME those are the defined objects that lack a decoder + * you are welcome to contribute code ;-) + */ + + case RSVP_OBJ_INTEGRITY: + case RSVP_OBJ_SCOPE: + case RSVP_OBJ_POLICY_DATA: + case RSVP_OBJ_MESSAGE_ID: + case RSVP_OBJ_MESSAGE_ID_ACK: + case RSVP_OBJ_MESSAGE_ID_LIST: + case RSVP_OBJ_LABEL_SET: + case RSVP_OBJ_ACCEPT_LABEL_SET: + case RSVP_OBJ_PROTECTION: + default: + if (vflag <= 1) + print_unknown_data(obj_tptr,"\n\t ",obj_tlen); + break; + } + /* do we want to see an additionally hexdump ? */ + if (vflag > 1 || hexdump==TRUE) + print_unknown_data(tptr+sizeof(sizeof(struct rsvp_object_header)),"\n\t ", + rsvp_obj_len-sizeof(struct rsvp_object_header)); + + tptr+=rsvp_obj_len; + tlen-=rsvp_obj_len; + } + return; +trunc: + printf("\n\t\t packet exceeded snapshot"); +} diff --git a/contrib/tcpdump/print-rt6.c b/contrib/tcpdump/print-rt6.c index dc5f0f3..6adc009 100644 --- a/contrib/tcpdump/print-rt6.c +++ b/contrib/tcpdump/print-rt6.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.18 2001/06/15 22:17:34 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.23.2.3 2003/11/19 00:35:45 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -30,13 +30,7 @@ static const char rcsid[] = #ifdef INET6 -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> - - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> @@ -44,6 +38,7 @@ static const char rcsid[] = #include "interface.h" #include "addrtoname.h" +#include "extract.h" int rt6_print(register const u_char *bp, register const u_char *bp2) @@ -72,13 +67,17 @@ rt6_print(register const u_char *bp, register const u_char *bp2) #ifndef IPV6_RTHDR_TYPE_0 #define IPV6_RTHDR_TYPE_0 0 #endif +#ifndef IPV6_RTHDR_TYPE_2 +#define IPV6_RTHDR_TYPE_2 2 +#endif case IPV6_RTHDR_TYPE_0: + case IPV6_RTHDR_TYPE_2: /* Mobile IPv6 ID-20 */ dp0 = (struct ip6_rthdr0 *)dp; TCHECK(dp0->ip6r0_reserved); if (dp0->ip6r0_reserved || vflag) { printf(", rsv=0x%0x", - (u_int32_t)ntohl(dp0->ip6r0_reserved)); + EXTRACT_32BITS(&dp0->ip6r0_reserved)); } if (len % 2 == 1) @@ -88,7 +87,7 @@ rt6_print(register const u_char *bp, register const u_char *bp2) for (i = 0; i < len; i++) { if ((u_char *)(addr + 1) > ep) goto trunc; - + printf(", [%d]%s", i, ip6addr_string(addr)); addr++; } @@ -103,6 +102,6 @@ rt6_print(register const u_char *bp, register const u_char *bp2) trunc: fputs("[|srcrt]", stdout); - return 65535; /* XXX */ + return -1; } #endif /* INET6 */ diff --git a/contrib/tcpdump/print-rx.c b/contrib/tcpdump/print-rx.c index a448804..64ec7ed 100644 --- a/contrib/tcpdump/print-rx.c +++ b/contrib/tcpdump/print-rx.c @@ -5,7 +5,7 @@ * 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 @@ -15,7 +15,7 @@ * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. @@ -33,8 +33,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.27.2.2 2002/07/10 07:17:57 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.35.2.2 2003/11/16 08:51:43 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -44,15 +44,7 @@ static const char rcsid[] = #include <stdio.h> #include <stdlib.h> #include <string.h> -#ifdef TIME_WITH_SYS_TIME -#include <time.h> -#endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#include <tcpdump-stdinc.h> #include "interface.h" #include "addrtoname.h" @@ -79,7 +71,7 @@ static struct tok rx_types[] = { static struct double_tok { int flag; /* Rx flag */ int packetType; /* Packet type */ - char *s; /* Flag string */ + const char *s; /* Flag string */ } rx_flags[] = { { RX_CLIENT_INITIATED, 0, "client-init" }, { RX_REQUEST_ACK, 0, "req-ack" }, @@ -351,7 +343,7 @@ static struct tok ubik_lock_types[] = { { 0, NULL }, }; -static char *voltype[] = { "read-write", "read-only", "backup" }; +static const char *voltype[] = { "read-write", "read-only", "backup" }; static struct tok afs_fs_errors[] = { { 101, "salvage volume" }, @@ -383,6 +375,7 @@ static struct tok rx_ack_reasons[] = { { 6, "ping" }, { 7, "ping response" }, { 8, "delay" }, + { 9, "idle" }, { 0, NULL }, }; @@ -406,11 +399,10 @@ static struct rx_cache_entry rx_cache[RX_CACHE_SIZE]; static int rx_cache_next = 0; static int rx_cache_hint = 0; -static void rx_cache_insert(const u_char *, const struct ip *, int, int); +static void rx_cache_insert(const u_char *, const struct ip *, int); static int rx_cache_find(const struct rx_header *, const struct ip *, int, int32_t *); -static void ack_print(const u_char *, int); static void fs_print(const u_char *, int); static void fs_reply_print(const u_char *, int, int32_t); static void acl_print(u_char *, int, u_char *); @@ -426,7 +418,7 @@ static void vol_print(const u_char *, int); static void vol_reply_print(const u_char *, int, int32_t); static void bos_print(const u_char *, int); static void bos_reply_print(const u_char *, int, int32_t); -static void ubik_print(const u_char *, int); +static void ubik_print(const u_char *); static void ubik_reply_print(const u_char *, int, int32_t); static void rx_ack_print(const u_char *, int); @@ -446,7 +438,7 @@ rx_print(register const u_char *bp, int length, int sport, int dport, int i; int32_t opcode; - if (snapend - bp < sizeof (struct rx_header)) { + if (snapend - bp < (int)sizeof (struct rx_header)) { printf(" [|rx] (%d)", length); return; } @@ -497,9 +489,7 @@ rx_print(register const u_char *bp, int length, int sport, int dport, * as well. */ - if (rxh->type == RX_PACKET_TYPE_ACK) - ack_print(bp, length); - else if (rxh->type == RX_PACKET_TYPE_DATA && + if (rxh->type == RX_PACKET_TYPE_DATA && EXTRACT_32BITS(&rxh->seq) == 1 && rxh->flags & RX_CLIENT_INITIATED) { @@ -508,7 +498,7 @@ rx_print(register const u_char *bp, int length, int sport, int dport, * have a chance to print out replies */ - rx_cache_insert(bp, (const struct ip *) bp2, dport, length); + rx_cache_insert(bp, (const struct ip *) bp2, dport); switch (dport) { case FS_RX_PORT: /* AFS file service */ @@ -535,7 +525,7 @@ rx_print(register const u_char *bp, int length, int sport, int dport, default: ; } - + /* * If it's a reply (client-init is _not_ set, but seq is one) * then look it up in the cache. If we find it, call the reply @@ -594,20 +584,19 @@ rx_print(register const u_char *bp, int length, int sport, int dport, */ static void -rx_cache_insert(const u_char *bp, const struct ip *ip, int dport, - int length) +rx_cache_insert(const u_char *bp, const struct ip *ip, int dport) { struct rx_cache_entry *rxent; const struct rx_header *rxh = (const struct rx_header *) bp; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) return; rxent = &rx_cache[rx_cache_next]; if (++rx_cache_next >= RX_CACHE_SIZE) rx_cache_next = 0; - + rxent->callnum = rxh->callNumber; rxent->client = ip->ip_src; rxent->server = ip->ip_dst; @@ -639,7 +628,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, rxent = &rx_cache[i]; if (rxent->callnum == rxh->callNumber && rxent->client.s_addr == clip && - rxent->server.s_addr == sip && + rxent->server.s_addr == sip && rxent->serviceId == rxh->serviceId && rxent->dport == sport) { @@ -712,18 +701,18 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, TCHECK2(bp[0], (sizeof(int32_t)*6)); \ mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask) printf (" StoreStatus"); \ - if (mask & 1) { printf(" date"); DATEOUT(); } \ + if (mask & 1) { printf(" date"); DATEOUT(); } \ else bp += sizeof(int32_t); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ - if (mask & 2) printf(" owner %lu", i); \ + if (mask & 2) printf(" owner %lu", i); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ - if (mask & 4) printf(" group %lu", i); \ + if (mask & 4) printf(" group %lu", i); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ - if (mask & 8) printf(" mode %lo", i & 07777); \ + if (mask & 8) printf(" mode %lo", i & 07777); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ - if (mask & 16) printf(" segsize %lu", i); \ + if (mask & 16) printf(" segsize %lu", i); \ /* undocumented in 3.3 docu */ \ - if (mask & 1024) printf(" fsync"); \ + if (mask & 1024) printf(" fsync"); \ } #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \ @@ -774,75 +763,6 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, printf("\""); \ } -static void -ack_print(register const u_char *bp, int length) -{ - u_char nAcks; - int i; - - if (vflag <= 1) - return; - - if (length <= sizeof(struct rx_header)) - return; - - bp += sizeof(struct rx_header); - - /* - * Packets < firstPacket are implicitly acknowledged and may - * be discarded by the sender. - * - * Packets >= firstPacket+nAcks are implicitly NOT acknowledged. - * - * No packets with sequence numbers >= firstPacket should be - * discarded by the sender (they may thrown out at any time by - * the receiver) - */ -#define RX_ACK_REASONS "RDOXSprn" - /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space, - * Ping, ping_Response, No_{progress, particular_reason}. - */ -#if 0 - struct rx_ackPacket { - u_short bufferSpace; /* Skip! */ - u_short maxSkew; /* Skip! */ - u_long firstPacket; - u_long previousPacket; /* Obsolete! */ - u_long serial; /* Serial that prompted the ack, */ - u_char reason; /* and the reason why. */ - u_char nAcks; - u_char acks[RX_MAXACKS]; /* Selective acks (not a bitmap). */ - }; -#endif -#define RX_ACK_TYPE_NACK 0 - - TCHECK2(bp[0], 8); /* bufferSpace and maxSkew */ - bp += 4; - printf(" fir %u", (unsigned)EXTRACT_32BITS(bp)); - bp += 4; - TCHECK2(bp[0], 8); /* previousPacket and serial */ - bp += 4; - printf(" %u", (unsigned)EXTRACT_32BITS(bp)); - bp += 4; - TCHECK2(bp[0], 1); - printf("%c", RX_ACK_REASONS[(*bp - 1) & 07u]); - bp += 1; /* reason */ - TCHECK2(bp[0], 1); - nAcks = *bp; - bp += 1; /* nAcks */ - - for (i = 0; i < nAcks; i++) { - TCHECK2(bp[0], 1); - putchar(*bp == RX_ACK_TYPE_NACK? '-' : '*'); - bp += 1; - } - - return; - -trunc: - printf(" [|ack]"); -} - /* * Handle calls to the AFS file service (fs) */ @@ -853,10 +773,10 @@ fs_print(register const u_char *bp, int length) int fs_op; unsigned long i; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } @@ -1004,7 +924,7 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode) unsigned long i; struct rx_header *rxh; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -1055,12 +975,12 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode) } else if (rxh->type == RX_PACKET_TYPE_ABORT) { int i; - /* - * Otherwise, just print out the return code - */ - TCHECK2(bp[0], sizeof(int32_t)); - i = (int) EXTRACT_32BITS(bp); - bp += sizeof(int32_t); + /* + * Otherwise, just print out the return code + */ + TCHECK2(bp[0], sizeof(int32_t)); + i = (int) EXTRACT_32BITS(bp); + bp += sizeof(int32_t); printf(" error %s", tok2str(afs_fs_errors, "#%d", i)); } else { @@ -1080,7 +1000,7 @@ trunc: * <positive> <negative> * <uid1> <aclbits1> * .... - * + * * "positive" and "negative" are integers which contain the number of * positive and negative ACL's in the string. The uid/aclbits pair are * ASCII strings containing the UID/PTS record and and a ascii number @@ -1099,7 +1019,7 @@ acl_print(u_char *s, int maxsize, u_char *end) if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2) goto finish; - + s += n; if (s > end) @@ -1168,10 +1088,10 @@ cb_print(register const u_char *bp, int length) int cb_op; unsigned long i; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } @@ -1249,7 +1169,7 @@ cb_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -1258,7 +1178,7 @@ cb_reply_print(register const u_char *bp, int length, int32_t opcode) * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afscbint.xg */ - + printf(" cb reply %s", tok2str(cb_req, "op#%d", opcode)); bp += sizeof(struct rx_header); @@ -1299,10 +1219,10 @@ prot_print(register const u_char *bp, int length) unsigned long i; int pt_op; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } @@ -1316,7 +1236,7 @@ prot_print(register const u_char *bp, int length) printf(" pt"); if (is_ubik(pt_op)) { - ubik_print(bp, length); + ubik_print(bp); return; } @@ -1441,7 +1361,7 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode) struct rx_header *rxh; unsigned long i; - if (length < sizeof(struct rx_header)) + if (length < (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -1553,10 +1473,10 @@ vldb_print(register const u_char *bp, int length) int vldb_op; unsigned long i; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } @@ -1570,7 +1490,7 @@ vldb_print(register const u_char *bp, int length) printf(" vldb"); if (is_ubik(vldb_op)) { - ubik_print(bp, length); + ubik_print(bp); return; } printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op)); @@ -1646,7 +1566,7 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode) struct rx_header *rxh; unsigned long i; - if (length < sizeof(struct rx_header)) + if (length < (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -1695,7 +1615,7 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode) TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) printf(" %s", - inet_ntoa(*((struct in_addr *) bp))); + intoa(((struct in_addr *) bp)->s_addr)); bp += sizeof(int32_t); } printf(" partitions"); @@ -1742,7 +1662,7 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode) TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) printf(" %s", - inet_ntoa(*((struct in_addr *) bp))); + intoa(((struct in_addr *) bp)->s_addr)); bp += sizeof(int32_t); } printf(" partitions"); @@ -1808,7 +1728,7 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode) default: ; } - + else { /* * Otherwise, just print out the return code @@ -1832,10 +1752,10 @@ kauth_print(register const u_char *bp, int length) { int kauth_op; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } @@ -1849,7 +1769,7 @@ kauth_print(register const u_char *bp, int length) printf(" kauth"); if (is_ubik(kauth_op)) { - ubik_print(bp, length); + ubik_print(bp); return; } @@ -1925,7 +1845,7 @@ kauth_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -1934,7 +1854,7 @@ kauth_reply_print(register const u_char *bp, int length, int32_t opcode) * Print out the afs call we're invoking. The table used here was * gleaned from kauth/kauth.rg */ - + printf(" kauth"); if (is_ubik(opcode)) { @@ -1976,10 +1896,10 @@ vol_print(register const u_char *bp, int length) { int vol_op; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } @@ -2014,7 +1934,7 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -2023,7 +1943,7 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode) * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ - + printf(" vol reply %s", tok2str(vol_req, "op#%d", opcode)); bp += sizeof(struct rx_header); @@ -2058,10 +1978,10 @@ bos_print(register const u_char *bp, int length) { int bos_op; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; - if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { + if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } @@ -2149,7 +2069,7 @@ bos_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; - if (length <= sizeof(struct rx_header)) + if (length <= (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -2158,7 +2078,7 @@ bos_reply_print(register const u_char *bp, int length, int32_t opcode) * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ - + printf(" bos reply %s", tok2str(bos_req, "op#%d", opcode)); bp += sizeof(struct rx_header); @@ -2203,7 +2123,7 @@ is_ubik(u_int32_t opcode) */ static void -ubik_print(register const u_char *bp, int length) +ubik_print(register const u_char *bp) { int ubik_op; int32_t temp; @@ -2316,7 +2236,7 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; - if (length < sizeof(struct rx_header)) + if (length < (int)sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; @@ -2333,7 +2253,7 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode) /* * If it was a data packet, print out the arguments to the Ubik calls */ - + if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 10000: /* Beacon */ @@ -2346,7 +2266,7 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode) default: ; } - + /* * Otherwise, print out "yes" it it was a beacon packet (because * that's how yes votes are returned, go figure), otherwise @@ -2380,7 +2300,7 @@ rx_ack_print(register const u_char *bp, int length) struct rx_ackPacket *rxa; int i, start, last; - if (length < sizeof(struct rx_header)) + if (length < (int)sizeof(struct rx_header)) return; bp += sizeof(struct rx_header); @@ -2406,11 +2326,11 @@ rx_ack_print(register const u_char *bp, int length) printf(" bufspace %d maxskew %d", (int) EXTRACT_16BITS(&rxa->bufferSpace), (int) EXTRACT_16BITS(&rxa->maxSkew)); - + printf(" first %d serial %d reason %s", EXTRACT_32BITS(&rxa->firstPacket), EXTRACT_32BITS(&rxa->serial), tok2str(rx_ack_reasons, "#%d", (int) rxa->reason)); - + /* * Okay, now we print out the ack array. The way _this_ works * is that we start at "first", and step through the ack array. @@ -2423,7 +2343,7 @@ rx_ack_print(register const u_char *bp, int length) * yield the start of the ack array (because RX_MAXACKS is 255 * and the structure will likely get padded to a 2 or 4 byte * boundary). However, this is the way it's implemented inside - * of AFS - the start of the extra fields are at + * of AFS - the start of the extra fields are at * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_ * the exact start of the ack array. Sigh. That's why we aren't * using bp, but instead use rxa->acks[]. But nAcks gets added @@ -2492,7 +2412,7 @@ rx_ack_print(register const u_char *bp, int length) */ } else if (last == i - 1 && start != last) printf("-%d", rxa->firstPacket + i - 1); - + /* * So, what's going on here? We ran off the end of the * ack list, and if we got a range we need to finish it up. @@ -2510,7 +2430,7 @@ rx_ack_print(register const u_char *bp, int length) /* * Same as above, just without comments */ - + for (i = 0, start = last = -2; i < rxa->nAcks; i++) if (rxa->acks[i] == RX_ACK_TYPE_NACK) { if (last == -2) { @@ -2524,7 +2444,7 @@ rx_ack_print(register const u_char *bp, int length) last = i; } else if (last == i - 1 && start != last) printf("-%d", rxa->firstPacket + i - 1); - + if (last == i - 1 && start != last) printf("-%d", rxa->firstPacket + i - 1); diff --git a/contrib/tcpdump/print-sctp.c b/contrib/tcpdump/print-sctp.c index 4f48aaa..deac239 100644 --- a/contrib/tcpdump/print-sctp.c +++ b/contrib/tcpdump/print-sctp.c @@ -34,25 +34,20 @@ */ #ifndef lint -static const char rcsid[] = -"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.7.2.1 2002/07/10 07:20:57 guy Exp $ (NETLAB/PEL)"; +static const char rcsid[] _U_ = +"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.13.2.2 2003/11/16 08:51:44 guy Exp $ (NETLAB/PEL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <unistd.h> #include "sctpHeader.h" #include "sctpConstants.h" #include <assert.h> -#include <netinet/in.h> - #include <stdio.h> #include <string.h> @@ -67,7 +62,7 @@ static const char rcsid[] = void sctp_print(const u_char *bp, /* beginning of sctp packet */ const u_char *bp2, /* beginning of enclosing */ u_int sctpPacketLength) /* ip packet */ -{ +{ const struct sctpHeader *sctpPktHdr; const struct ip *ip; #ifdef INET6 @@ -82,7 +77,7 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ sctpPktHdr = (const struct sctpHeader*) bp; endPacketPtr = (const u_char*)sctpPktHdr+sctpPacketLength; - + if( (u_long) endPacketPtr > (u_long) snapend) endPacketPtr = (const void *) snapend; ip = (struct ip *)bp2; @@ -94,72 +89,62 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ #endif /*INET6*/ cp = (const u_char *)(sctpPktHdr + 1); if (cp > snapend) - { + { printf("[|sctp]"); - return; - } + return; + } - if (sctpPacketLength < sizeof(struct sctpHeader)) + if (sctpPacketLength < sizeof(struct sctpHeader)) { - (void)printf("truncated-sctp - %ld bytes missing!", + (void)printf("truncated-sctp - %ld bytes missing!", (long)sctpPacketLength-sizeof(struct sctpHeader)); return; } - + /* sctpPacketLength -= sizeof(struct sctpHeader); packet length */ /* is now only as long as the payload */ - sourcePort = ntohs(sctpPktHdr->source); - destPort = ntohs(sctpPktHdr->destination); - + sourcePort = EXTRACT_16BITS(&sctpPktHdr->source); + destPort = EXTRACT_16BITS(&sctpPktHdr->destination); + #ifdef INET6 if (ip6) { - if (ip6->ip6_nxt == IPPROTO_SCTP) { - (void)printf("%s.%d > %s.%d: sctp", - ip6addr_string(&ip6->ip6_src), - sourcePort, - ip6addr_string(&ip6->ip6_dst), - destPort); - } else { - (void)printf("%d > %d: sctp", - sourcePort, destPort); - } + (void)printf("%s.%d > %s.%d: sctp", + ip6addr_string(&ip6->ip6_src), + sourcePort, + ip6addr_string(&ip6->ip6_dst), + destPort); } else #endif /*INET6*/ { - if (ip->ip_p == IPPROTO_SCTP) { - (void)printf("%s.%d > %s.%d: sctp", - ipaddr_string(&ip->ip_src), - sourcePort, - ipaddr_string(&ip->ip_dst), - destPort); - } else { - (void)printf("%d > %d: sctp", - sourcePort, destPort); - } + (void)printf("%s.%d > %s.%d: sctp", + ipaddr_string(&ip->ip_src), + sourcePort, + ipaddr_string(&ip->ip_dst), + destPort); } fflush(stdout); if (vflag < 2) return; - + /* cycle through all chunks, printing information on each one */ - for (chunkCount = 0, + for (chunkCount = 0, chunkDescPtr = (const struct sctpChunkDesc *) ((const u_char*) sctpPktHdr + sizeof(struct sctpHeader)); chunkDescPtr != NULL && ( (const void *) ((const u_char *) chunkDescPtr + sizeof(struct sctpChunkDesc)) <= endPacketPtr); - + chunkDescPtr = (const struct sctpChunkDesc *) nextChunk, chunkCount++) { u_short align; const u_char *chunkEnd; - - chunkEnd = ((const u_char*)chunkDescPtr + ntohs(chunkDescPtr->chunkLength)); - - align=ntohs(chunkDescPtr->chunkLength) % 4; + + chunkEnd = ((const u_char*)chunkDescPtr + EXTRACT_16BITS(&chunkDescPtr->chunkLength)); + + align=EXTRACT_16BITS(&chunkDescPtr->chunkLength) % 4; if (align != 0) align = 4 - align; @@ -171,51 +156,59 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ case SCTP_DATA : { const struct sctpDataPart *dataHdrPtr; - + printf("[DATA] "); - - if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED) + + if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED) == SCTP_DATA_UNORDERED) printf("(U)"); - if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG) + if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG) == SCTP_DATA_FIRST_FRAG) printf("(B)"); - - if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG) + + if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) printf("(E)"); - if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED) - == SCTP_DATA_UNORDERED) + if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED) + == SCTP_DATA_UNORDERED) || - ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG) + ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG) == SCTP_DATA_FIRST_FRAG) || - ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG) + ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) ) printf(" "); dataHdrPtr=(const struct sctpDataPart*)(chunkDescPtr+1); - - printf("[TSN: %u] ", (u_int32_t)ntohl(dataHdrPtr->TSN)); - printf("[SID: %u] ", ntohs(dataHdrPtr->streamId)); - printf("[SSEQ %u] ", ntohs(dataHdrPtr->sequence)); - printf("[PPID 0x%x] ", (u_int32_t)ntohl(dataHdrPtr->payloadtype)); + + printf("[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN)); + printf("[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId)); + printf("[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence)); + printf("[PPID 0x%x] ", EXTRACT_32BITS(&dataHdrPtr->payloadtype)); fflush(stdout); if (vflag) /* if verbose output is specified */ { /* at the command line */ const u_char *payloadPtr; - + printf("[Payload"); if (!xflag && !qflag) { payloadPtr = (const u_char *) (++dataHdrPtr); printf(":"); + if (htons(chunkDescPtr->chunkLength) < + sizeof(struct sctpDataPart)+ + sizeof(struct sctpChunkDesc)+1) { + printf("bogus chunk length %u]", + htons(chunkDescPtr->chunkLength)); + return; + } default_print(payloadPtr, - htons(chunkDescPtr->chunkLength)-1 - - sizeof(struct sctpDataPart)-sizeof(struct sctpChunkDesc)); + htons(chunkDescPtr->chunkLength) - + (sizeof(struct sctpDataPart)+ + sizeof(struct sctpChunkDesc)+1)); } else printf("]"); } @@ -227,11 +220,11 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ printf("[INIT] "); init=(const struct sctpInitiation*)(chunkDescPtr+1); - printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag)); - printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit)); - printf("[OS: %u] ", ntohs(init->NumPreopenStreams)); - printf("[MIS: %u] ", ntohs(init->MaxInboundStreams)); - printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN)); + printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag)); + printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)); + printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)); + printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)); + printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)); #if(0) /* ALC you can add code for optional params here */ if( (init+1) < chunkEnd ) @@ -243,15 +236,15 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ case SCTP_INITIATION_ACK : { const struct sctpInitiation *init; - + printf("[INIT ACK] "); init=(const struct sctpInitiation*)(chunkDescPtr+1); - printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag)); - printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit)); - printf("[OS: %u] ", ntohs(init->NumPreopenStreams)); - printf("[MIS: %u] ", ntohs(init->MaxInboundStreams)); - printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN)); - + printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag)); + printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)); + printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)); + printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)); + printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)); + #if(0) /* ALC you can add code for optional params here */ if( (init+1) < chunkEnd ) printf(" @@@@@ UNFINISHED @@@@@@%s\n", @@ -262,36 +255,36 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ case SCTP_SELECTIVE_ACK: { const struct sctpSelectiveAck *sack; - const struct sctpSelectiveFrag *frag; + const struct sctpSelectiveFrag *frag; int fragNo, tsnNo; const u_long *dupTSN; printf("[SACK] "); sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1); - printf("[cum ack %u] ", (u_int32_t)ntohl(sack->highestConseqTSN)); - printf("[a_rwnd %u] ", (u_int32_t)ntohl(sack->updatedRwnd)); - printf("[#gap acks %u] ", ntohs(sack->numberOfdesc)); - printf("[#dup tsns %u] ", ntohs(sack->numDupTsns)); - - + printf("[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN)); + printf("[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd)); + printf("[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc)); + printf("[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns)); + + /* print gaps */ for (frag = ( (const struct sctpSelectiveFrag *) ((const struct sctpSelectiveAck *) sack+1)), fragNo=0; - (const void *)frag < nextChunk && fragNo < ntohs(sack->numberOfdesc); + (const void *)frag < nextChunk && fragNo < EXTRACT_16BITS(&sack->numberOfdesc); frag++, fragNo++) - printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ", + printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ", fragNo+1, - (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentStart)), - (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentEnd))); - + EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentStart), + EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd)); + /* print duplicate TSNs */ - for (dupTSN = (const u_long*)frag, tsnNo=0; - (const void *) dupTSN < nextChunk && tsnNo<ntohs(sack->numDupTsns); + for (dupTSN = (const u_long*)frag, tsnNo=0; + (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns); dupTSN++, tsnNo++) printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1, - (u_int32_t)ntohl(*dupTSN)); + EXTRACT_32BITS(dupTSN)); break; } @@ -302,7 +295,7 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ hb=(const struct sctpHBsender*)chunkDescPtr; printf("[HB REQ] "); - + break; } case SCTP_HEARTBEAT_ACK : @@ -329,7 +322,7 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ case SCTP_ECN_ECHO : printf("[ECN ECHO] "); break; - case SCTP_ECN_CWR : + case SCTP_ECN_CWR : printf("[ECN CWR] "); break; case SCTP_SHUTDOWN_COMPLETE : diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c index 22bcb15..df0ce59 100644 --- a/contrib/tcpdump/print-sll.c +++ b/contrib/tcpdump/print-sll.c @@ -19,19 +19,15 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.6.4.1 2002/06/01 23:51:16 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.12.2.2 2003/11/16 08:51:44 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <string.h> @@ -91,25 +87,20 @@ sll_print(register const struct sll_header *sllp, u_int length) } /* - * This is the top level routine of the printer. 'p' is the points - * to the ether header of the packet, 'h->tv' is the timestamp, + * This is the top level routine of the printer. 'p' points to the + * Linux "cooked capture" header of the packet, 'h->ts' is the timestamp, * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ -void -sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +u_int +sll_if_print(const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; register const struct sll_header *sllp; - u_short pkttype; - struct ether_header ehdr; u_short ether_type; u_short extracted_ethertype; - ++infodelay; - ts_print(&h->ts); - if (caplen < SLL_HDR_LEN) { /* * XXX - this "can't happen" because "pcap-linux.c" always @@ -117,67 +108,17 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) * cooked socket capture. */ printf("[|sll]"); - goto out; + return (caplen); } sllp = (const struct sll_header *)p; - /* - * Fake up an Ethernet header for the benefit of printers that - * insist on "packetp" pointing to an Ethernet header. - */ - pkttype = ntohs(sllp->sll_pkttype); - - /* The source address is in the packet header */ - memcpy(ehdr.ether_shost, sllp->sll_addr, ETHER_ADDR_LEN); - - if (pkttype != LINUX_SLL_OUTGOING) { - /* - * We received this packet. - * - * We don't know the destination address, so - * we fake it - all 0's except that the - * bottommost bit of the bottommost octet - * is set for a unicast packet, all 0's except - * that the bottommost bit of the uppermost - * octet is set for a multicast packet, all - * 1's for a broadcast packet. - */ - if (pkttype == LINUX_SLL_BROADCAST) - memset(ehdr.ether_dhost, 0xFF, ETHER_ADDR_LEN); - else { - memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN); - if (pkttype == LINUX_SLL_MULTICAST) - ehdr.ether_dhost[0] = 1; - else - ehdr.ether_dhost[ETHER_ADDR_LEN-1] = 1; - } - } else { - /* - * We sent this packet; we don't know whether it's - * broadcast, multicast, or unicast, so just make - * the destination address all 0's. - */ - memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN); - } - if (eflag) sll_print(sllp, length); /* - * Some printers want to get back at the ethernet addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. + * Go past the cooked-mode header. */ - snapend = p + caplen; - /* - * Actually, the only printers that use packetp are print-arp.c - * and print-bootp.c, and they assume that packetp points to an - * Ethernet header. The right thing to do is to fix them to know - * which link type is in use when they excavate. XXX - */ - packetp = (u_char *)&ehdr; - length -= SLL_HDR_LEN; caplen -= SLL_HDR_LEN; p += SLL_HDR_LEN; @@ -207,8 +148,8 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) * 802.2. * Try to print the LLC-layer header & higher layers. */ - if (llc_print(p, length, caplen, ESRC(&ehdr), - EDST(&ehdr), &extracted_ethertype) == 0) + if (llc_print(p, length, caplen, NULL, NULL, + &extracted_ethertype) == 0) goto unknown; /* unknown LLC type */ break; @@ -233,11 +174,6 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) if (!xflag && !qflag) default_print(p, caplen); } - if (xflag) - default_print(p, caplen); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + + return (SLL_HDR_LEN); } diff --git a/contrib/tcpdump/print-smb.c b/contrib/tcpdump/print-smb.c index c61d866..5f683ef 100644 --- a/contrib/tcpdump/print-smb.c +++ b/contrib/tcpdump/print-smb.c @@ -11,15 +11,14 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.20.2.4 2002/07/11 07:47:01 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.27.2.2 2003/11/16 08:51:45 guy Exp $"; #endif +#include <tcpdump-stdinc.h> + #include <stdio.h> #include <string.h> -#include <sys/types.h> - -#include <netinet/in.h> #include "interface.h" #include "extract.h" @@ -170,7 +169,7 @@ struct smbfnsint trans2_fns[] = { static void -print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf) +print_trans2(const u_char *words, const u_char *dat _U_, const u_char *buf, const u_char *maxbuf) { static struct smbfnsint *fn = &trans2_fns[0]; const u_char *data, *param; @@ -383,27 +382,28 @@ trunc: static void -print_negprot(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf) +print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf) { + u_int wcnt; const char *f1 = NULL, *f2 = NULL; TCHECK(words[0]); + wcnt = words[0]; if (request) f2 = "*|Dialect=[Z]\n"; else { - if (words[0] == 1) + if (wcnt == 1) f1 = "Core Protocol\nDialectIndex=[d]"; - else if (words[0] == 17) + else if (wcnt == 17) f1 = "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey="; - else if (words[0] == 13) + else if (wcnt == 13) f1 = "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[d]\nSecMode=[w]\nMaxXMit=[d]\nMaxMux=[d]\nMaxVcs=[d]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[d]\nRes=[W]\nCryptKey="; } if (f1) - smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf)); + smb_fdata(words + 1, f1, SMBMIN(words + 1 + wcnt * 2, maxbuf)); else - print_data(words + 1, SMBMIN(words[0] * 2, - PTR_DIFF(maxbuf, words + 1))); + print_data(words + 1, SMBMIN(wcnt * 2, PTR_DIFF(maxbuf, words + 1))); TCHECK2(*data, 2); if (f2) @@ -417,9 +417,9 @@ trunc: } static void -print_sesssetup(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf) +print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf) { - int wcnt; + u_int wcnt; const char *f1 = NULL, *f2 = NULL; TCHECK(words[0]); @@ -430,19 +430,18 @@ print_sesssetup(const u_char *words, const u_char *data, const u_char *buf, cons else f1 = "Com2=[B]\nRes1=[B]\nOff2=[d]\nMaxBuffer=[d]\nMaxMpx=[d]\nVcNumber=[d]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[d]\nCaseSensitivePasswordLength=[d]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n"; } else { - if (words[0] == 3) { + if (wcnt == 3) { f1 = "Com2=[w]\nOff2=[d]\nAction=[w]\n"; - } else if (words[0] == 13) { + } else if (wcnt == 13) { f1 = "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n"; f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n"; } } if (f1) - smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf)); + smb_fdata(words + 1, f1, SMBMIN(words + 1 + wcnt * 2, maxbuf)); else - print_data(words + 1, SMBMIN(words[0] * 2, - PTR_DIFF(maxbuf, words + 1))); + print_data(words + 1, SMBMIN(wcnt * 2, PTR_DIFF(maxbuf, words + 1))); TCHECK2(*data, 2); if (f2) @@ -540,7 +539,7 @@ static struct smbfns smb_fns[] = { { pSETDIR, "SMBsetdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBlseek, "SMBlseek", 0, - { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL } }, + { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL, NULL } }, { SMBflush, "SMBflush", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, @@ -718,7 +717,7 @@ static struct smbfns smb_fns[] = { { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[d]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n", "Path=[S]\n", "Com2=[w]\nOff2=[d]\nOplockLevel=[b]\nFid=[d]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n", - NULL } }, + NULL, NULL } }, { SMBntcancel, "SMBntcancel", 0, DEFDESCRIPT }, @@ -735,7 +734,7 @@ print_smb(const u_char *buf, const u_char *maxbuf) int command; const u_char *words, *data; struct smbfns *fn; - char *fmt_smbheader = + const char *fmt_smbheader = "[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n"; @@ -766,7 +765,7 @@ print_smb(const u_char *buf, const u_char *maxbuf) for (;;) { const char *f1, *f2; int wct; - int bcc; + u_int bcc; TCHECK(words[0]); wct = words[0]; @@ -807,7 +806,7 @@ print_smb(const u_char *buf, const u_char *maxbuf) smb_fdata(data + 2, f2, data + 2 + bcc); } } else { - printf("smb_bcc=%d\n", bcc); + printf("smb_bcc=%u\n", bcc); if (bcc > 0) { printf("smb_buf[]=\n"); print_data(data + 2, SMBMIN(bcc, PTR_DIFF(maxbuf, data + 2))); @@ -848,7 +847,7 @@ nbt_tcp_print(const u_char *data, int length) { const u_char *maxbuf = data + length; int flags; - int nbt_len; + u_int nbt_len; TCHECK2(data[2], 2); flags = data[0]; @@ -950,7 +949,7 @@ nbt_udp137_print(const u_char *data, int length) const u_char *maxbuf = data + length; int name_trn_id, response, opcode, nm_flags, rcode; int qdcount, ancount, nscount, arcount; - char *opcodestr; + const char *opcodestr; const u_char *p; int total, i; diff --git a/contrib/tcpdump/print-snmp.c b/contrib/tcpdump/print-snmp.c index cdb189e..e1db216 100644 --- a/contrib/tcpdump/print-snmp.c +++ b/contrib/tcpdump/print-snmp.c @@ -57,18 +57,16 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.50.4.2 2002/07/20 23:33:08 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.56.2.3 2004/03/23 06:59:59 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> +#include <tcpdump-stdinc.h> -#include <ctype.h> #include <stdio.h> #include <string.h> @@ -83,7 +81,7 @@ static const char rcsid[] = * Universal ASN.1 types * (we only care about the tag values for those allowed in the Internet SMI) */ -char *Universal[] = { +const char *Universal[] = { "U-0", "Boolean", "Integer", @@ -106,7 +104,7 @@ char *Universal[] = { /* * Application-wide ASN.1 types from the Internet SMI and their tags */ -char *Application[] = { +const char *Application[] = { "IpAddress", #define IPADDR 0 "Counter", @@ -125,7 +123,7 @@ char *Application[] = { /* * Context-specific ASN.1 types for the SNMP PDUs and their tags */ -char *Context[] = { +const char *Context[] = { "GetRequest", #define GETREQ 0 "GetNextRequest", @@ -155,7 +153,7 @@ char *Context[] = { /* * Context-specific ASN.1 types for the SNMP Exceptions and their tags */ -char *Exceptions[] = { +const char *Exceptions[] = { "noSuchObject", #define NOSUCHOBJECT 0 "noSuchInstance", @@ -168,14 +166,14 @@ char *Exceptions[] = { * Private ASN.1 types * The Internet SMI does not specify any */ -char *Private[] = { +const char *Private[] = { "P-0" }; /* * error-status values for any SNMP PDU */ -char *ErrorStatus[] = { +const char *ErrorStatus[] = { "noError", "tooBig", "noSuchName", @@ -197,14 +195,14 @@ char *ErrorStatus[] = { "inconsistentName" }; #define DECODE_ErrorStatus(e) \ - ( e >= 0 && e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \ + ( e >= 0 && (size_t)e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \ ? ErrorStatus[e] \ : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf)) /* * generic-trap values in the SNMP Trap-PDU */ -char *GenericTrap[] = { +const char *GenericTrap[] = { "coldStart", "warmStart", "linkDown", @@ -212,10 +210,10 @@ char *GenericTrap[] = { "authenticationFailure", "egpNeighborLoss", "enterpriseSpecific" -#define GT_ENTERPRISE 7 +#define GT_ENTERPRISE 6 }; #define DECODE_GenericTrap(t) \ - ( t >= 0 && t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \ + ( t >= 0 && (size_t)t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \ ? GenericTrap[t] \ : (snprintf(buf, sizeof(buf), "gt=%d", t), buf)) @@ -226,8 +224,8 @@ char *GenericTrap[] = { */ #define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */ struct { - char *name; - char **Id; + const char *name; + const char **Id; int numIDs; } Class[] = { defineCLASS(Universal), @@ -245,7 +243,7 @@ struct { /* * defined forms for ASN.1 types */ -char *Form[] = { +const char *Form[] = { "Primitive", #define PRIMITIVE 0 "Constructed", @@ -257,7 +255,7 @@ char *Form[] = { * This is stored as a general-order tree. */ struct obj { - char *desc; /* name of object */ + const char *desc; /* name of object */ u_char oid; /* sub-id following parent */ u_char type; /* object type (unused) */ struct obj *child, *next; /* child and next sibling pointers */ @@ -279,9 +277,9 @@ struct obj { * private enterprises tree, and the experimental tree. */ struct obj_abrev { - char *prefix; /* prefix for this abrev */ + const char *prefix; /* prefix for this abrev */ struct obj *node; /* pointer into object table */ - char *oid; /* ASN.1 encoded OID */ + const char *oid; /* ASN.1 encoded OID */ } obj_abrev_list[] = { #ifndef NO_ABREV_MIB /* .iso.org.dod.internet.mgmt.mib */ @@ -360,7 +358,7 @@ struct be { /* * SNMP versions recognized by this module */ -char *SnmpVersion[] = { +const char *SnmpVersion[] = { "SNMPv1", #define SNMP_VERSION_1 0 "SNMPv2c", @@ -462,7 +460,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem) elem->asnlen = *p; p++; len--; hdr++; if (elem->asnlen & ASN_BIT8) { - int noct = elem->asnlen % ASN_BIT8; + u_int32_t noct = elem->asnlen % ASN_BIT8; elem->asnlen = 0; if (len < noct) { ifNotTruncated printf("[asnlen? %d<%d]", len, noct); @@ -559,7 +557,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem) elem->type = BE_UNS64; high = 0, low = 0; for (i = elem->asnlen; i-- > 0; p++) { - high = (high << 8) | + high = (high << 8) | ((low & 0xFF000000) >> 24); low = (low << 8) | *p; } @@ -651,7 +649,7 @@ asn1_print(struct be *elem) { u_char *p = (u_char *)elem->data.raw; u_int32_t asnlen = elem->asnlen; - int i; + u_int32_t i; switch (elem->type) { @@ -685,7 +683,7 @@ asn1_print(struct be *elem) o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8); if (*p & ASN_LONGLEN) continue; - + /* * first subitem encodes two items with 1st*OIDMUX+2nd * (see X.690:1997 clause 8.19 for the details) @@ -725,7 +723,7 @@ asn1_print(struct be *elem) break; } d = elem->data.uns64.high * 4294967296.0; /* 2^32 */ - if (elem->data.uns64.high <= 0x1fffff) { + if (elem->data.uns64.high <= 0x1fffff) { d += elem->data.uns64.low; #if 0 /*is looks illegal, but what is the intention?*/ printf("%.f", d); @@ -783,7 +781,7 @@ asn1_print(struct be *elem) case BE_INETADDR: if (asnlen != ASNLEN_INETADDR) printf("[inetaddr len!=%d]", ASNLEN_INETADDR); - for (i = asnlen; i-- > 0; p++) { + for (i = asnlen; i-- != 0; p++) { printf((i == asnlen-1) ? "%u" : ".%u", *p); } break; @@ -876,7 +874,7 @@ static void smi_decode_oid(struct be *elem, unsigned int *oid, o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8); if (*p & ASN_LONGLEN) continue; - + /* * first subitem encodes two items with 1st*OIDMUX+2nd * (see X.690:1997 clause 8.19 for the details) @@ -914,7 +912,7 @@ static int smi_check_a_range(SmiType *smiType, SmiRange *smiRange, struct be *elem) { int ok = 1; - + switch (smiType->basetype) { case SMI_BASETYPE_OBJECTIDENTIFIER: case SMI_BASETYPE_OCTETSTRING: @@ -931,12 +929,12 @@ static int smi_check_a_range(SmiType *smiType, SmiRange *smiRange, ok = (elem->data.integer >= smiRange->minValue.value.integer32 && elem->data.integer <= smiRange->maxValue.value.integer32); break; - + case SMI_BASETYPE_UNSIGNED32: ok = (elem->data.uns >= smiRange->minValue.value.unsigned32 && elem->data.uns <= smiRange->maxValue.value.unsigned32); break; - + case SMI_BASETYPE_UNSIGNED64: /* XXX */ break; @@ -1066,7 +1064,7 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem) /* apply display hints (integer, octetstring) */ /* convert instance identifier to index type values */ - + switch (elem->type) { case BE_OID: if (smiType->basetype == SMI_BASETYPE_BITS) { @@ -1083,7 +1081,7 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem) } fputs(smiNode->name, stdout); if (smiNode->oidlen < oidlen) { - for (i = smiNode->oidlen; + for (i = smiNode->oidlen; i < oidlen; i++) { printf(".%u", oid[i]); } @@ -1169,7 +1167,7 @@ varbind_print(u_char pduid, const u_char *np, u_int length) asn1_print(&elem); return; } - if (count < length) + if ((u_int)count < length) printf("[%d extra after SEQ of varbind]", length - count); /* descend */ length = elem.asnlen; @@ -1422,7 +1420,7 @@ pdu_print(const u_char *np, u_int length, int version) fputs("[no PDU]", stdout); return; } - if (count < length) + if ((u_int)count < length) printf("[%d extra after PDU]", length - count); if (vflag) { fputs("{ ", stdout); @@ -1434,7 +1432,7 @@ pdu_print(const u_char *np, u_int length, int version) np = (u_char *)pdu.data.raw; if (version == SNMP_VERSION_1 && - (pdu.id == GETBULKREQ || pdu.id == INFORMREQ || + (pdu.id == GETBULKREQ || pdu.id == INFORMREQ || pdu.id == V2TRAP || pdu.id == REPORT)) { printf("[v2 PDU in v1 message]"); return; @@ -1462,7 +1460,7 @@ pdu_print(const u_char *np, u_int length, int version) } if (vflag) { - fputs("} ", stdout); + fputs(" } ", stdout); } } @@ -1587,7 +1585,7 @@ usm_print(const u_char *np, u_int length) asn1_print(&elem); return; } - if (vflag) + if (vflag) printf("B=%d ", elem.data.integer); length -= count; np += count; @@ -1600,7 +1598,7 @@ usm_print(const u_char *np, u_int length) asn1_print(&elem); return; } - if (vflag) + if (vflag) printf("T=%d ", elem.data.integer); length -= count; np += count; @@ -1640,7 +1638,7 @@ usm_print(const u_char *np, u_int length) length -= count; np += count; - if (count < length) + if ((u_int)count < length) printf("[%d extra after usm SEQ]", length - count); } @@ -1707,7 +1705,7 @@ v3msg_print(const u_char *np, u_int length) return; } flags = elem.data.str[0]; - if (flags != 0x00 && flags != 0x01 && flags != 0x03 + if (flags != 0x00 && flags != 0x01 && flags != 0x03 && flags != 0x04 && flags != 0x05 && flags != 0x07) { printf("[msgFlags=0x%02X]", flags); return; @@ -1733,7 +1731,7 @@ v3msg_print(const u_char *np, u_int length) length -= count; np += count; - if (count < length) + if ((u_int)count < length) printf("[%d extra after message SEQ]", length - count); if (vflag) { @@ -1809,7 +1807,7 @@ snmp_print(const u_char *np, u_int length) asn1_print(&elem); return; } - if (count < length) + if ((u_int)count < length) printf("[%d extra after iSEQ]", length - count); /* descend */ length = elem.asnlen; diff --git a/contrib/tcpdump/print-stp.c b/contrib/tcpdump/print-stp.c index 40d4d79..7b28070 100644 --- a/contrib/tcpdump/print-stp.c +++ b/contrib/tcpdump/print-stp.c @@ -10,19 +10,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.6.6.1 2002/05/29 10:00:00 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.11.2.2 2003/11/16 08:51:46 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdlib.h> #include <stdio.h> @@ -40,7 +36,7 @@ stp_print_bridge_id(const u_char *p) } static void -stp_print_config_bpdu(const u_char *p, u_int length) +stp_print_config_bpdu(const u_char *p) { printf("config "); if (p[7] & 1) @@ -63,7 +59,7 @@ stp_print_config_bpdu(const u_char *p, u_int length) } static void -stp_print_tcn_bpdu(const u_char *p, u_int length) +stp_print_tcn_bpdu(void) { printf("tcn"); } @@ -82,17 +78,17 @@ stp_print(const u_char *p, u_int length) printf("unknown version"); return; } - + switch (p[6]) { - case 0: + case 0x00: if (length < 10) goto trunc; - stp_print_config_bpdu(p, length); + stp_print_config_bpdu(p); break; - case 1: - stp_print_tcn_bpdu(p, length); + case 0x80: + stp_print_tcn_bpdu(); break; default: diff --git a/contrib/tcpdump/print-sunatm.c b/contrib/tcpdump/print-sunatm.c new file mode 100644 index 0000000..10be487 --- /dev/null +++ b/contrib/tcpdump/print-sunatm.c @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1997 Yen Yen Lim and North Dakota State University + * 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 Yen Yen Lim and + North Dakota State University + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.5.2.2 2003/11/16 08:51:47 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +struct mbuf; +struct rtentry; + +#include <stdio.h> +#include <pcap.h> + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" + +#include "atm.h" +#include "atmuni31.h" + +/* SunATM header for ATM packet */ +#define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */ +#define VPI_POS 1 /* VPI */ +#define VCI_POS 2 /* VCI */ +#define PKT_BEGIN_POS 4 /* Start of the ATM packet */ + +/* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */ +#define PT_LANE 0x01 /* LANE */ +#define PT_LLC 0x02 /* LLC encapsulation */ + +/* + * This is the top level routine of the printer. 'p' points + * to the SunATM pseudo-header for the packet, 'h->ts' is the timestamp, + * 'h->length' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + u_int length = h->len; + u_short vci; + u_char vpi; + u_int traftype; + + if (caplen < PKT_BEGIN_POS) { + printf("[|atm]"); + return (caplen); + } + + if (eflag) { + if (p[DIR_POS] & 0x80) + printf("Tx: "); + else + printf("Rx: "); + } + + switch (p[DIR_POS] & 0x0f) { + + case PT_LANE: + traftype = ATM_LANE; + break; + + case PT_LLC: + traftype = ATM_LLC; + break; + + default: + traftype = ATM_UNKNOWN; + break; + } + + vci = EXTRACT_16BITS(&p[VCI_POS]); + vpi = p[VPI_POS]; + + p += PKT_BEGIN_POS; + caplen -= PKT_BEGIN_POS; + length -= PKT_BEGIN_POS; + atm_print(vpi, vci, traftype, p, length, caplen); + + return (PKT_BEGIN_POS); +} diff --git a/contrib/tcpdump/print-tcp.c b/contrib/tcpdump/print-tcp.c index a5f69fe..5b0b06c 100644 --- a/contrib/tcpdump/print-tcp.c +++ b/contrib/tcpdump/print-tcp.c @@ -20,26 +20,21 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.95 2001/12/10 08:21:24 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.107.2.3 2003/11/19 00:17:02 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> +#include <tcpdump-stdinc.h> #include <rpc/rpc.h> -#include <netinet/in.h> - #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> -#include <unistd.h> #include "interface.h" #include "addrtoname.h" @@ -51,6 +46,7 @@ static const char rcsid[] = #ifdef INET6 #include "ip6.h" #endif +#include "ipproto.h" #include "nameser.h" @@ -100,10 +96,11 @@ static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE]; #define NFS_PORT 2049 #endif #define MSDP_PORT 639 +#define LDP_PORT 646 static int tcp_cksum(register const struct ip *ip, register const struct tcphdr *tp, - register int len) + register u_int len) { union phu { struct phdr { @@ -118,11 +115,14 @@ static int tcp_cksum(register const struct ip *ip, const u_int16_t *sp; /* pseudo-header.. */ - phu.ph.len = htons(len); /* XXX */ + phu.ph.len = htons((u_int16_t)len); phu.ph.mbz = 0; phu.ph.proto = IPPROTO_TCP; memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t)); - memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); + if (IP_HL(ip) == 5) + memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); + else + phu.ph.dst = ip_finddst(ip); sp = &phu.pa[0]; return in_cksum((u_short *)tp, len, @@ -131,9 +131,9 @@ static int tcp_cksum(register const struct ip *ip, #ifdef INET6 static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp, - int len) + u_int len) { - int i, tlen; + size_t i; register const u_int16_t *sp; u_int32_t sum; union { @@ -147,14 +147,11 @@ static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp, u_int16_t pa[20]; } phu; - tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) - - ((const char *)tp - (const char*)ip6); - /* pseudo-header */ memset(&phu, 0, sizeof(phu)); phu.ph.ph_src = ip6->ip6_src; phu.ph.ph_dst = ip6->ip6_dst; - phu.ph.ph_len = htonl(tlen); + phu.ph.ph_len = htonl(len); phu.ph.ph_nxt = IPPROTO_TCP; sum = 0; @@ -163,10 +160,10 @@ static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp, sp = (const u_int16_t *)tp; - for (i = 0; i < (tlen & ~1); i += 2) + for (i = 0; i < (len & ~1); i += 2) sum += *sp++; - if (tlen & 1) + if (len & 1) sum += htons((*(const u_int8_t *)sp) << 8); while (sum > 0xffff) @@ -184,7 +181,7 @@ tcp_print(register const u_char *bp, register u_int length, register const struct tcphdr *tp; register const struct ip *ip; register u_char flags; - register int hlen; + register u_int hlen; register char ch; u_int16_t sport, dport, win, urp; u_int32_t seq, ack, thseq, thack; @@ -209,8 +206,8 @@ tcp_print(register const u_char *bp, register u_int length, return; } - sport = ntohs(tp->th_sport); - dport = ntohs(tp->th_dport); + sport = EXTRACT_16BITS(&tp->th_sport); + dport = EXTRACT_16BITS(&tp->th_dport); hlen = TH_OFF(tp) * 4; @@ -262,10 +259,10 @@ tcp_print(register const u_char *bp, register u_int length, TCHECK(*tp); - seq = (u_int32_t)ntohl(tp->th_seq); - ack = (u_int32_t)ntohl(tp->th_ack); - win = ntohs(tp->th_win); - urp = ntohs(tp->th_urp); + seq = EXTRACT_32BITS(&tp->th_seq); + ack = EXTRACT_32BITS(&tp->th_ack); + win = EXTRACT_16BITS(&tp->th_win); + urp = EXTRACT_16BITS(&tp->th_urp); if (qflag) { (void)printf("tcp %d", length - TH_OFF(tp) * 4); @@ -290,6 +287,7 @@ tcp_print(register const u_char *bp, register u_int length, if (!Sflag && (flags & TH_ACK)) { register struct tcp_seq_hash *th; + const void *src, *dst; register int rev; struct tha tha; /* @@ -302,63 +300,68 @@ tcp_print(register const u_char *bp, register u_int length, memset(&tha, 0, sizeof(tha)); rev = 0; if (ip6) { + src = &ip6->ip6_src; + dst = &ip6->ip6_dst; if (sport > dport) rev = 1; else if (sport == dport) { - int i; - - for (i = 0; i < 4; i++) { - if (((u_int32_t *)(&ip6->ip6_src))[i] > - ((u_int32_t *)(&ip6->ip6_dst))[i]) { - rev = 1; - break; - } - } + if (memcmp(src, dst, sizeof ip6->ip6_dst) > 0) + rev = 1; } if (rev) { - tha.src = ip6->ip6_dst; - tha.dst = ip6->ip6_src; + memcpy(&tha.src, dst, sizeof ip6->ip6_dst); + memcpy(&tha.dst, src, sizeof ip6->ip6_src); tha.port = dport << 16 | sport; } else { - tha.dst = ip6->ip6_dst; - tha.src = ip6->ip6_src; + memcpy(&tha.dst, dst, sizeof ip6->ip6_dst); + memcpy(&tha.src, src, sizeof ip6->ip6_src); tha.port = sport << 16 | dport; } } else { - if (sport > dport || - (sport == dport && - ip->ip_src.s_addr > ip->ip_dst.s_addr)) { + src = &ip->ip_src; + dst = &ip->ip_dst; + if (sport > dport) rev = 1; + else if (sport == dport) { + if (memcmp(src, dst, sizeof ip->ip_dst) > 0) + rev = 1; } if (rev) { - *(struct in_addr *)&tha.src = ip->ip_dst; - *(struct in_addr *)&tha.dst = ip->ip_src; + memcpy(&tha.src, dst, sizeof ip->ip_dst); + memcpy(&tha.dst, src, sizeof ip->ip_src); tha.port = dport << 16 | sport; } else { - *(struct in_addr *)&tha.dst = ip->ip_dst; - *(struct in_addr *)&tha.src = ip->ip_src; + memcpy(&tha.dst, dst, sizeof ip->ip_dst); + memcpy(&tha.src, src, sizeof ip->ip_src); tha.port = sport << 16 | dport; } } #else - if (sport < dport || - (sport == dport && - ip->ip_src.s_addr < ip->ip_dst.s_addr)) { - tha.src = ip->ip_src, tha.dst = ip->ip_dst; - tha.port = sport << 16 | dport; - rev = 0; - } else { - tha.src = ip->ip_dst, tha.dst = ip->ip_src; - tha.port = dport << 16 | sport; + rev = 0; + src = &ip->ip_src; + dst = &ip->ip_dst; + if (sport > dport) rev = 1; + else if (sport == dport) { + if (memcmp(src, dst, sizeof ip->ip_dst) > 0) + rev = 1; + } + if (rev) { + memcpy(&tha.src, dst, sizeof ip->ip_dst); + memcpy(&tha.dst, src, sizeof ip->ip_src); + tha.port = dport << 16 | sport; + } else { + memcpy(&tha.dst, dst, sizeof ip->ip_dst); + memcpy(&tha.src, src, sizeof ip->ip_src); + tha.port = sport << 16 | dport; } #endif threv = rev; for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE]; th->nxt; th = th->nxt) - if (!memcmp((char *)&tha, (char *)&th->addr, - sizeof(th->addr))) + if (memcmp((char *)&tha, (char *)&th->addr, + sizeof(th->addr)) == 0) break; if (!th->nxt || (flags & TH_SYN)) { @@ -393,12 +396,14 @@ tcp_print(register const u_char *bp, register u_int length, } if (IP_V(ip) == 4 && vflag && !fragmented) { - int sum; + u_int16_t sum, tcp_sum; if (TTEST2(tp->th_sport, length)) { sum = tcp_cksum(ip, tp, length); - if (sum != 0) - (void)printf(" [bad tcp cksum %x!]", sum); - else + if (sum != 0) { + tcp_sum = EXTRACT_16BITS(&tp->th_sum); + (void)printf(" [bad tcp cksum %x (->%x)!]", + tcp_sum, in_cksum_shouldbe(tcp_sum, sum)); + } else (void)printf(" [tcp sum ok]"); } } @@ -428,10 +433,12 @@ tcp_print(register const u_char *bp, register u_int length, /* * Handle any options. */ - if ((hlen -= sizeof(*tp)) > 0) { + if (hlen > sizeof(*tp)) { register const u_char *cp; - register int i, opt, len, datalen; + register u_int i, opt, datalen; + register u_int len; + hlen -= sizeof(*tp); cp = (const u_char *)tp + sizeof(*tp); putchar(' '); ch = '<'; @@ -555,7 +562,7 @@ tcp_print(register const u_char *bp, register u_int length, break; default: - (void)printf("opt-%d:", opt); + (void)printf("opt-%u:", opt); datalen = len - 2; for (i = 0; i < datalen; ++i) { LENCHECK(i); @@ -598,7 +605,7 @@ tcp_print(register const u_char *bp, register u_int length, } else if (sport == BGP_PORT || dport == BGP_PORT) bgp_print(bp, length); else if (sport == PPTP_PORT || dport == PPTP_PORT) - pptp_print(bp, length); + pptp_print(bp); #ifdef TCPDUMP_DO_SMB else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT) nbt_tcp_print(bp, length); @@ -606,15 +613,18 @@ tcp_print(register const u_char *bp, register u_int length, else if (sport == BEEP_PORT || dport == BEEP_PORT) beep_print(bp, length); else if (length > 2 && - (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT)) { + (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT || + sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) { /* * TCP DNS query has 2byte length at the head. * XXX packet could be unaligned, it can go strange */ - ns_print(bp + 2, length - 2); + ns_print(bp + 2, length - 2, 0); } else if (sport == MSDP_PORT || dport == MSDP_PORT) { msdp_print(bp, length); } + else if (sport == LDP_PORT || dport == LDP_PORT) + printf(": LDP, length: %u", length); } return; bad: diff --git a/contrib/tcpdump/print-telnet.c b/contrib/tcpdump/print-telnet.c index c070c44..b420d35 100644 --- a/contrib/tcpdump/print-telnet.c +++ b/contrib/tcpdump/print-telnet.c @@ -37,11 +37,11 @@ */ /* * @(#)Copyright (c) 1994, Simon J. Gerraty. - * + * * This is free software. It comes with NO WARRANTY. - * Permission to use, modify and distribute this source code + * Permission to use, modify and distribute this source code * is granted subject to the following conditions. - * 1/ that the above copyright notice and this notice + * 1/ that the above copyright notice and this notice * are preserved in all copies. */ @@ -50,20 +50,14 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.18 2001/09/10 06:40:08 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.21.2.3 2003/12/29 22:42:23 hannes Exp $"; #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <ctype.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> #include "interface.h" @@ -115,7 +109,8 @@ numstr(int x) static int telnet_parse(const u_char *sp, u_int length, int print) { - int i, c, x; + int i, x; + u_int c; const u_char *osp, *p; #define FETCH(c, sp, length) \ do { \ @@ -161,7 +156,7 @@ telnet_parse(const u_char *sp, u_int length, int print) break; /* IAC SB .... IAC SE */ p = sp; - while (length > p + 1 - sp) { + while (length > (u_int)(p + 1 - sp)) { if (p[0] == IAC && p[1] == SE) break; p++; @@ -237,7 +232,7 @@ telnet_print(const u_char *sp, u_int length) int l; osp = sp; - + while (length > 0 && *sp == IAC) { l = telnet_parse(sp, length, 0); if (l < 0) @@ -249,7 +244,7 @@ telnet_print(const u_char *sp, u_int length) if (Xflag && 2 < vflag) { if (first) printf("\nTelnet:"); - hex_print_with_offset(sp, l, sp - osp); + hex_print_with_offset("\n", sp, l, sp - osp); if (l > 8) printf("\n\t\t\t\t"); else diff --git a/contrib/tcpdump/print-tftp.c b/contrib/tcpdump/print-tftp.c index 66c1392..261b594 100644 --- a/contrib/tcpdump/print-tftp.c +++ b/contrib/tcpdump/print-tftp.c @@ -22,30 +22,27 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.31 1999/11/21 09:37:03 fenner Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.35.2.2 2003/11/16 08:51:50 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #ifdef SEGSIZE #undef SEGSIZE /* SINIX sucks */ #endif #include <arpa/tftp.h> -#include <ctype.h> #include <stdio.h> #include <string.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" /* op code to string mapping */ static struct tok op2str[] = { @@ -89,7 +86,7 @@ tftp_print(register const u_char *bp, u_int length) /* Print tftp request type */ TCHECK(tp->th_opcode); - opcode = ntohs(tp->th_opcode); + opcode = EXTRACT_16BITS(&tp->th_opcode); cp = tok2str(op2str, "tftp-#%d", opcode); printf(" %s", cp); /* Bail if bogus opcode */ @@ -112,6 +109,18 @@ tftp_print(register const u_char *bp, u_int length) fputs(" \"", stdout); i = fn_print(p, snapend); putchar('"'); + + /* Print the mode and any options */ + while ((p = (const u_char *)strchr((const char *)p, '\0')) != NULL) { + if (length <= (u_int)(p - (const u_char *)&tp->th_block)) + break; + p++; + if (*p != '\0') { + putchar(' '); + fn_print(p, snapend); + } + } + if (i) goto trunc; break; @@ -119,14 +128,14 @@ tftp_print(register const u_char *bp, u_int length) case ACK: case DATA: TCHECK(tp->th_block); - printf(" block %d", ntohs(tp->th_block)); + printf(" block %d", EXTRACT_16BITS(&tp->th_block)); break; case ERROR: /* Print error code string */ TCHECK(tp->th_code); printf(" %s ", tok2str(err2str, "tftp-err-#%d \"", - ntohs(tp->th_code))); + EXTRACT_16BITS(&tp->th_code))); /* Print error message string */ i = fn_print((const u_char *)tp->th_data, snapend); putchar('"'); diff --git a/contrib/tcpdump/print-timed.c b/contrib/tcpdump/print-timed.c index af73ddb..9ad7668 100644 --- a/contrib/tcpdump/print-timed.c +++ b/contrib/tcpdump/print-timed.c @@ -20,31 +20,31 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.3 2001/05/17 18:33:23 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.7.2.2 2003/11/16 08:51:51 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> -#include <sys/time.h> -#include <netinet/in.h> +#include <tcpdump-stdinc.h> + #include <stdio.h> #include <string.h> #include "timed.h" #include "interface.h" +#include "extract.h" -static char *tsptype[TSPTYPENUMBER] = +static const char *tsptype[TSPTYPENUMBER] = { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; void -timed_print(register const u_char *bp, u_int length) +timed_print(register const u_char *bp) { #define endof(x) ((u_char *)&(x) + sizeof (x)) struct tsp *tsp = (struct tsp *)bp; @@ -86,8 +86,8 @@ timed_print(register const u_char *bp, u_int length) fputs(" [|timed]", stdout); return; } - sec = ntohl((long)tsp->tsp_time.tv_sec); - usec = ntohl((long)tsp->tsp_time.tv_usec); + sec = EXTRACT_32BITS(&tsp->tsp_time.tv_sec); + usec = EXTRACT_32BITS(&tsp->tsp_time.tv_usec); if (usec < 0) /* corrupt, skip the rest of the packet */ return; diff --git a/contrib/tcpdump/print-vjc.c b/contrib/tcpdump/print-vjc.c index 4283da6..f1877f2 100644 --- a/contrib/tcpdump/print-vjc.c +++ b/contrib/tcpdump/print-vjc.c @@ -24,17 +24,12 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.9 2000/10/09 01:53:21 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.11.2.3 2003/11/19 01:09:12 guy Exp $ (LBL)"; #endif -#include <sys/param.h> -#include <sys/time.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> -#include <netdb.h> #include <pcap.h> #include <stdio.h> @@ -44,8 +39,50 @@ static const char rcsid[] = #include "slcompress.h" #include "ppp.h" +/* + * XXX - for BSD/OS PPP, what packets get supplied with a PPP header type + * of PPP_VJC and what packets get supplied with a PPP header type of + * PPP_VJNC? PPP_VJNC is for "UNCOMPRESSED_TCP" packets, and PPP_VJC + * is for COMPRESSED_TCP packets (PPP_IP is used for TYPE_IP packets). + * + * RFC 1144 implies that, on the wire, the packet type is *not* needed + * for PPP, as different PPP protocol types can be used; it only needs + * to be put on the wire for SLIP. + * + * It also indicates that, for compressed SLIP: + * + * If the COMPRESSED_TCP bit is set in the first byte, it's + * a COMPRESSED_TCP packet; that byte is the change byte, and + * the COMPRESSED_TCP bit, 0x80, isn't used in the change byte. + * + * If the upper 4 bits of the first byte are 7, it's an + * UNCOMPRESSED_TCP packet; that byte is the first byte of + * the UNCOMPRESSED_TCP modified IP header, with a connection + * number in the protocol field, and with the version field + * being 7, not 4. + * + * Otherwise, the packet is an IPv4 packet (where the upper 4 bits + * of the packet are 4). + * + * So this routine looks as if it's sort-of intended to handle + * compressed SLIP, although it doesn't handle UNCOMPRESSED_TCP + * correctly for that (it doesn't fix the version number and doesn't + * do anything to the protocol field), and doesn't check for COMPRESSED_TCP + * packets correctly for that (you only check the first bit - see + * B.1 in RFC 1144). + * + * But it's called for BSD/OS PPP, not SLIP - perhaps BSD/OS does weird + * things with the headers? + * + * Without a BSD/OS VJC-compressed PPP trace, or knowledge of what the + * BSD/OS VJC code does, we can't say what's the case. + * + * We therefore leave "proto" - which is the PPP protocol type - in place, + * *not* marked as unused, for now, so that GCC warnings about the + * unused argument remind us that we should fix this some day. + */ int -vjc_print(register const char *bp, register u_int length, u_short proto) +vjc_print(register const char *bp, u_short proto) { int i; diff --git a/contrib/tcpdump/print-vrrp.c b/contrib/tcpdump/print-vrrp.c index 9bc29d1..f615dfd 100644 --- a/contrib/tcpdump/print-vrrp.c +++ b/contrib/tcpdump/print-vrrp.c @@ -24,19 +24,18 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.5 2001/07/23 22:27:30 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.7.2.2 2003/11/16 08:51:55 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include <tcpdump-stdinc.h> + #include <stdio.h> #include <stdlib.h> -#include <unistd.h> - -#include <netinet/in.h> #include "interface.h" #include "extract.h" @@ -69,7 +68,7 @@ static const char rcsid[] = #define VRRP_TYPE_ADVERTISEMENT 1 static const struct tok type2str[] = { - { VRRP_TYPE_ADVERTISEMENT, "advertisement" }, + { VRRP_TYPE_ADVERTISEMENT, "Advertisement" }, { 0, NULL } }; @@ -94,27 +93,27 @@ vrrp_print(register const u_char *bp, register u_int len, int ttl) TCHECK(bp[0]); version = (bp[0] & 0xf0) >> 4; type = bp[0] & 0x0f; - type_s = tok2str(type2str, "type#%d", type); - printf("VRRPv%d-%s %d: ", version, type_s, len); + type_s = tok2str(type2str, "unknown type (%u)", type); + printf("VRRPv%u, %s", version, type_s); if (ttl != 255) - printf("[ttl=%d!] ", ttl); + printf(", (ttl %u)", ttl); if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT) return; TCHECK(bp[2]); - printf("vrid=%d prio=%d", bp[1], bp[2]); + printf(", vrid %u, prio %u", bp[1], bp[2]); TCHECK(bp[5]); auth_type = bp[4]; - printf(" authtype=%s", tok2str(auth2str, NULL, auth_type)); - printf(" intvl=%d", bp[5]); + printf(", authtype %s", tok2str(auth2str, NULL, auth_type)); + printf(", intvl %us, length %u", bp[5],len); if (vflag) { int naddrs = bp[3]; int i; char c; if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0)) - printf(" (bad vrrp cksum %x!)", + printf(", (bad vrrp cksum %x)", EXTRACT_16BITS(&bp[6])); - printf(" addrs"); + printf(", addrs"); if (naddrs > 1) printf("(%d)", naddrs); printf(":"); diff --git a/contrib/tcpdump/print-wb.c b/contrib/tcpdump/print-wb.c index 7b0281b..678e325 100644 --- a/contrib/tcpdump/print-wb.c +++ b/contrib/tcpdump/print-wb.c @@ -20,25 +20,24 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.26 2001/06/27 05:37:19 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.30.2.3 2004/03/24 04:06:52 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> -#include <sys/time.h> - -#include <netinet/in.h> +#include <tcpdump-stdinc.h> #include <stdio.h> #include "interface.h" #include "addrtoname.h" +#include "extract.h" /* XXX need to add byte-swapping macros! */ +/* XXX - you mean like the ones in "extract.h"? */ /* * Largest packet size. Everything should fit within this space. @@ -54,7 +53,7 @@ static const char rcsid[] = #define DOP_ROUNDUP(x) ((((int)(x)) + (DOP_ALIGN - 1)) & ~(DOP_ALIGN - 1)) #define DOP_NEXT(d)\ ((struct dophdr *)((u_char *)(d) + \ - DOP_ROUNDUP(ntohs((d)->dh_len) + sizeof(*(d))))) + DOP_ROUNDUP(EXTRACT_16BITS(&(d)->dh_len) + sizeof(*(d))))) /* * Format of the whiteboard packet header. @@ -63,7 +62,7 @@ static const char rcsid[] = struct pkt_hdr { u_int32_t ph_src; /* site id of source */ u_int32_t ph_ts; /* time stamp (for skew computation) */ - u_short ph_version; /* version number */ + u_int16_t ph_version; /* version number */ u_char ph_type; /* message type */ u_char ph_flags; /* message flags */ }; @@ -92,7 +91,7 @@ struct PageID { struct dophdr { u_int32_t dh_ts; /* sender's timestamp */ - u_short dh_len; /* body length */ + u_int16_t dh_len; /* body length */ u_char dh_flags; u_char dh_type; /* body type */ /* body follows */ @@ -153,8 +152,8 @@ struct id_off { struct pgstate { u_int32_t slot; struct PageID page; - u_short nid; - u_short rsvd; + u_int16_t nid; + u_int16_t rsvd; /* seqptr's */ }; @@ -195,14 +194,14 @@ wb_id(const struct pkt_id *id, u_int len) len -= sizeof(*id); printf(" %u/%s:%u (max %u/%s:%u) ", - (u_int32_t)ntohl(id->pi_ps.slot), + EXTRACT_32BITS(&id->pi_ps.slot), ipaddr_string(&id->pi_ps.page.p_sid), - (u_int32_t)ntohl(id->pi_ps.page.p_uid), - (u_int32_t)ntohl(id->pi_mslot), + EXTRACT_32BITS(&id->pi_ps.page.p_uid), + EXTRACT_32BITS(&id->pi_mslot), ipaddr_string(&id->pi_mpage.p_sid), - (u_int32_t)ntohl(id->pi_mpage.p_uid)); + EXTRACT_32BITS(&id->pi_mpage.p_uid)); - nid = ntohs(id->pi_ps.nid); + nid = EXTRACT_16BITS(&id->pi_ps.nid); len -= sizeof(*io) * nid; io = (struct id_off *)(id + 1); cp = (char *)(io + nid); @@ -213,9 +212,9 @@ wb_id(const struct pkt_id *id, u_int len) } c = '<'; - for (i = 0; i < nid && (u_char *)io < snapend; ++io, ++i) { + for (i = 0; i < nid && (u_char *)(io + 1) <= snapend; ++io, ++i) { printf("%c%s:%u", - c, ipaddr_string(&io->id), (u_int32_t)ntohl(io->off)); + c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off)); c = ','; } if (i >= nid) { @@ -235,9 +234,9 @@ wb_rreq(const struct pkt_rreq *rreq, u_int len) printf(" please repair %s %s:%u<%u:%u>", ipaddr_string(&rreq->pr_id), ipaddr_string(&rreq->pr_page.p_sid), - (u_int32_t)ntohl(rreq->pr_page.p_uid), - (u_int32_t)ntohl(rreq->pr_sseq), - (u_int32_t)ntohl(rreq->pr_eseq)); + EXTRACT_32BITS(&rreq->pr_page.p_uid), + EXTRACT_32BITS(&rreq->pr_sseq), + EXTRACT_32BITS(&rreq->pr_eseq)); return (0); } @@ -249,9 +248,9 @@ wb_preq(const struct pkt_preq *preq, u_int len) return (-1); printf(" need %u/%s:%u", - (u_int32_t)ntohl(preq->pp_low), + EXTRACT_32BITS(&preq->pp_low), ipaddr_string(&preq->pp_page.p_sid), - (u_int32_t)ntohl(preq->pp_page.p_uid)); + EXTRACT_32BITS(&preq->pp_page.p_uid)); return (0); } @@ -266,20 +265,20 @@ wb_prep(const struct pkt_prep *prep, u_int len) if (len < sizeof(*prep)) { return (-1); } - n = ntohl(prep->pp_n); + n = EXTRACT_32BITS(&prep->pp_n); ps = (const struct pgstate *)(prep + 1); - while (--n >= 0 && (u_char *)ps < ep) { + while (--n >= 0 && (u_char *)(ps + 1) <= ep) { const struct id_off *io, *ie; char c = '<'; printf(" %u/%s:%u", - (u_int32_t)ntohl(ps->slot), + EXTRACT_32BITS(&ps->slot), ipaddr_string(&ps->page.p_sid), - (u_int32_t)ntohl(ps->page.p_uid)); + EXTRACT_32BITS(&ps->page.p_uid)); io = (struct id_off *)(ps + 1); - for (ie = io + ps->nid; io < ie && (u_char *)io < ep; ++io) { + for (ie = io + ps->nid; io < ie && (u_char *)(io + 1) <= ep; ++io) { printf("%c%s:%u", c, ipaddr_string(&io->id), - (u_int32_t)ntohl(io->off)); + EXTRACT_32BITS(&io->off)); c = ','; } printf(">"); @@ -289,7 +288,7 @@ wb_prep(const struct pkt_prep *prep, u_int len) } -char *dopstr[] = { +const char *dopstr[] = { "dop-0!", "dop-1!", "RECT", @@ -320,7 +319,7 @@ wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es) else { printf(" %s", dopstr[t]); if (t == DT_SKIP || t == DT_HOLE) { - int ts = ntohl(dh->dh_ts); + u_int32_t ts = EXTRACT_32BITS(&dh->dh_ts); printf("%d", ts - ss + 1); if (ss > ts || ts > es) { printf("[|]"); @@ -353,13 +352,14 @@ wb_rrep(const struct pkt_rrep *rrep, u_int len) printf(" for %s %s:%u<%u:%u>", ipaddr_string(&rrep->pr_id), ipaddr_string(&dop->pd_page.p_sid), - (u_int32_t)ntohl(dop->pd_page.p_uid), - (u_int32_t)ntohl(dop->pd_sseq), - (u_int32_t)ntohl(dop->pd_eseq)); + EXTRACT_32BITS(&dop->pd_page.p_uid), + EXTRACT_32BITS(&dop->pd_sseq), + EXTRACT_32BITS(&dop->pd_eseq)); if (vflag) return (wb_dops((const struct dophdr *)(dop + 1), - ntohl(dop->pd_sseq), ntohl(dop->pd_eseq))); + EXTRACT_32BITS(&dop->pd_sseq), + EXTRACT_32BITS(&dop->pd_eseq))); return (0); } @@ -373,13 +373,14 @@ wb_drawop(const struct pkt_dop *dop, u_int len) printf(" %s:%u<%u:%u>", ipaddr_string(&dop->pd_page.p_sid), - (u_int32_t)ntohl(dop->pd_page.p_uid), - (u_int32_t)ntohl(dop->pd_sseq), - (u_int32_t)ntohl(dop->pd_eseq)); + EXTRACT_32BITS(&dop->pd_page.p_uid), + EXTRACT_32BITS(&dop->pd_sseq), + EXTRACT_32BITS(&dop->pd_eseq)); if (vflag) return (wb_dops((const struct dophdr *)(dop + 1), - ntohl(dop->pd_sseq), ntohl(dop->pd_eseq))); + EXTRACT_32BITS(&dop->pd_sseq), + EXTRACT_32BITS(&dop->pd_eseq))); return (0); } diff --git a/contrib/tcpdump/print-zephyr.c b/contrib/tcpdump/print-zephyr.c index f1b7907..186960c 100644 --- a/contrib/tcpdump/print-zephyr.c +++ b/contrib/tcpdump/print-zephyr.c @@ -19,19 +19,19 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.2.4.2 2002/07/11 07:49:19 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.6.2.2 2003/11/16 08:51:56 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include <tcpdump-stdinc.h> + #include <stdio.h> -#include <ctype.h> #include <string.h> #include <stdlib.h> -#include <sys/types.h> #include "interface.h" @@ -48,7 +48,7 @@ struct z_packet { char *inst; char *opcode; char *sender; - char *recipient; + const char *recipient; char *format; int cksum; int multi; @@ -105,7 +105,7 @@ parse_field(char **pptr, int *len) } static const char * -z_triple(char *class, char *inst, char *recipient) +z_triple(char *class, char *inst, const char *recipient) { if (!*recipient) recipient = "*"; diff --git a/contrib/tcpdump/route6d.h b/contrib/tcpdump/route6d.h index 2adf409..ee00331 100644 --- a/contrib/tcpdump/route6d.h +++ b/contrib/tcpdump/route6d.h @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ /* - * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.3 2001/10/22 04:27:47 itojun Exp $ + * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.5 2002/12/11 07:14:10 guy Exp $ */ #define RIP6_VERSION 1 diff --git a/contrib/tcpdump/rx.h b/contrib/tcpdump/rx.h index 247be99..1912e51 100644 --- a/contrib/tcpdump/rx.h +++ b/contrib/tcpdump/rx.h @@ -5,7 +5,7 @@ * 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 @@ -15,7 +15,7 @@ * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. @@ -23,7 +23,7 @@ /* * Rx protocol format * - * $Id: rx.h,v 1.5 2001/10/22 04:23:37 itojun Exp $ + * $Id: rx.h,v 1.8 2002/12/11 07:14:11 guy Exp $ */ #define FS_RX_PORT 7000 diff --git a/contrib/tcpdump/sctpConstants.h b/contrib/tcpdump/sctpConstants.h index 3267e83..f70226b 100644 --- a/contrib/tcpdump/sctpConstants.h +++ b/contrib/tcpdump/sctpConstants.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/sctpConstants.h,v 1.2 2001/06/28 10:17:22 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/sctpConstants.h,v 1.4 2003/06/03 23:49:23 guy Exp $ (LBL) */ /* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola * @@ -31,14 +31,14 @@ * * This file is part of the SCTP reference Implementation * - * + * * Please send any bug reports or fixes you make to one of the following email * addresses: - * + * * rstewar1@email.mot.com * kmorneau@cisco.com * qxie1@email.mot.com - * + * * Any bugs reported given to us we will try to fix... any fixes shared will * be incorperated into the next SCTP release. */ @@ -58,7 +58,7 @@ */ /*#define USE_MD5 1*/ -/* the SCTP protocol signature +/* the SCTP protocol signature * this includes the version number * encoded in the last 4 bits of the * signature. @@ -82,7 +82,7 @@ /* default max I can burst out after a fast retransmit */ #define SCTP_DEF_MAX_BURST 4 -/* Packet transmit states in the sent +/* Packet transmit states in the sent * field in the SCTP_transmitOnQueue struct */ #define SCTP_DATAGRAM_UNSENT 0 @@ -106,8 +106,8 @@ #define SCTP_DATA 0x00 #define SCTP_INITIATION 0x01 #define SCTP_INITIATION_ACK 0x02 -#define SCTP_SELECTIVE_ACK 0x03 -#define SCTP_HEARTBEAT_REQUEST 0x04 +#define SCTP_SELECTIVE_ACK 0x03 +#define SCTP_HEARTBEAT_REQUEST 0x04 #define SCTP_HEARTBEAT_ACK 0x05 #define SCTP_ABORT_ASSOCIATION 0x06 #define SCTP_SHUTDOWN 0x07 @@ -239,7 +239,7 @@ #define SCTP_STARTING_MAPARRAY 10000 /* Here we define the timer types used - * by the implementation has + * by the implementation has * arguments in the set/get timer type calls. */ #define SCTP_TIMER_INIT 0 @@ -248,7 +248,7 @@ #define SCTP_TIMER_SHUTDOWN 3 #define SCTP_TIMER_HEARTBEAT 4 #define SCTP_TIMER_PMTU 5 -/* number of timer types in the base SCTP +/* number of timer types in the base SCTP * structure used in the set/get and has * the base default. */ @@ -352,7 +352,7 @@ /* Events that SCTP will look for, these * are or'd together to declare what SCTP - * wants. Each select mask/poll list should be + * wants. Each select mask/poll list should be * set for the fd, if the bit is on. */ #define SCTP_EVENT_READ 0x000001 @@ -361,7 +361,7 @@ /* The following constant is a value for this * particular implemenation. It is quite arbitrary and - * is used to limit how much data will be queued up to + * is used to limit how much data will be queued up to * a sender, waiting for cwnd to be larger than flightSize. * All implementations will need this protection is some * way due to buffer size constraints. @@ -371,9 +371,9 @@ -/* This constant (SCTP_MAX_READBUFFER) define +/* This constant (SCTP_MAX_READBUFFER) define * how big the read/write buffer is - * when we enter the fd event notification + * when we enter the fd event notification * the buffer is put on the stack, so the bigger * it is the more stack you chew up, however it * has got to be big enough to handle the bigest @@ -392,7 +392,7 @@ #define SCTP_MIN_RWND 1500 #define SCTP_WINDOW_MIN 1500 /* smallest rwnd can be */ -#define SCTP_WINDOW_MAX 1048576 /* biggest I can grow rwnd to +#define SCTP_WINDOW_MAX 1048576 /* biggest I can grow rwnd to * My playing around suggests a * value greater than 64k does not * do much, I guess via the kernel @@ -411,7 +411,7 @@ * size to. This governs what is the * largest size we will use, of course * PMTU will raise this up to - * the largest interface MTU or the + * the largest interface MTU or the * ceiling below if there is no * SIOCGIFMTU. */ @@ -514,11 +514,6 @@ #define SCTP_DEAMON_PORT 9899 - -#ifndef IPPROTO_SCTP -#define IPPROTO_SCTP 132 /* the Official IANA number :-) */ -#endif - /* Deamon registration message types/responses */ #define DEAMON_REGISTER 0x01 #define DEAMON_REGISTER_ACK 0x02 @@ -542,7 +537,7 @@ { \ (ts)->tv_sec = (tv)->tv_sec; \ (ts)->tv_nsec = (tv)->tv_usec * 1000; \ -} +} #endif /* pegs */ diff --git a/contrib/tcpdump/sctpHeader.h b/contrib/tcpdump/sctpHeader.h index b4a131a..3b26094 100644 --- a/contrib/tcpdump/sctpHeader.h +++ b/contrib/tcpdump/sctpHeader.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.3 2001/08/01 03:34:00 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002/12/11 07:14:11 guy Exp $ (LBL) */ /* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola * @@ -31,14 +31,14 @@ * * This file is part of the SCTP reference Implementation * - * + * * Please send any bug reports or fixes you make to one of the following email * addresses: - * + * * rstewar1@email.mot.com * kmorneau@cisco.com * qxie1@email.mot.com - * + * * Any bugs reported given to us we will try to fix... any fixes shared will * be incorperated into the next SCTP release. */ @@ -57,39 +57,39 @@ extern "C" { #ifdef TRU64 #define _64BITS 1 -#endif +#endif struct sctpHeader{ - u_short source; - u_short destination; - u_int verificationTag; - u_int adler32; + u_int16_t source; + u_int16_t destination; + u_int32_t verificationTag; + u_int32_t adler32; }; /* various descriptor parsers */ struct sctpChunkDesc{ - u_char chunkID; - u_char chunkFlg; - u_short chunkLength; + u_int8_t chunkID; + u_int8_t chunkFlg; + u_int16_t chunkLength; }; struct sctpParamDesc{ - u_short paramType; - u_short paramLength; + u_int16_t paramType; + u_int16_t paramLength; }; struct sctpRelChunkDesc{ struct sctpChunkDesc chk; - u_int serialNumber; + u_int32_t serialNumber; }; struct sctpVendorSpecificParam { struct sctpParamDesc p; /* type must be 0xfffe */ - u_int vendorId; /* vendor ID from RFC 1700 */ - u_short vendorSpecificType; - u_short vendorSpecificLen; + u_int32_t vendorId; /* vendor ID from RFC 1700 */ + u_int16_t vendorSpecificType; + u_int16_t vendorSpecificLen; }; @@ -101,55 +101,55 @@ struct sctpVendorSpecificParam { /* this is used for init ack, too */ struct sctpInitiation{ - u_int initTag; /* tag of mine */ - u_int rcvWindowCredit; /* rwnd */ - u_short NumPreopenStreams; /* OS */ - u_short MaxInboundStreams; /* MIS */ - u_int initialTSN; + u_int32_t initTag; /* tag of mine */ + u_int32_t rcvWindowCredit; /* rwnd */ + u_int16_t NumPreopenStreams; /* OS */ + u_int16_t MaxInboundStreams; /* MIS */ + u_int32_t initialTSN; /* optional param's follow in sctpParamDesc form */ }; struct sctpV4IpAddress{ struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */ - u_int ipAddress; + u_int32_t ipAddress; }; struct sctpV6IpAddress{ struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */ - u_char ipAddress[16]; + u_int8_t ipAddress[16]; }; struct sctpDNSName{ struct sctpParamDesc param; - u_char name[1]; + u_int8_t name[1]; }; struct sctpCookiePreserve{ struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */ - u_int extraTime; + u_int32_t extraTime; }; struct sctpTimeStamp{ - u_int ts_sec; - u_int ts_usec; + u_int32_t ts_sec; + u_int32_t ts_usec; }; /* wire structure of my cookie */ struct cookieMessage{ - u_int TieTag_curTag; /* copied from assoc if present */ - u_int TieTag_hisTag; /* copied from assoc if present */ - int cookieLife; /* life I will award this cookie */ + u_int32_t TieTag_curTag; /* copied from assoc if present */ + u_int32_t TieTag_hisTag; /* copied from assoc if present */ + int32_t cookieLife; /* life I will award this cookie */ struct sctpTimeStamp timeEnteringState; /* the time I built cookie */ struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */ - u_int addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */ - int addrtype; /* address type */ - u_short locScope; /* V6 local scope flag */ - u_short siteScope; /* V6 site scope flag */ + u_int32_t addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */ + int32_t addrtype; /* address type */ + u_int16_t locScope; /* V6 local scope flag */ + u_int16_t siteScope; /* V6 site scope flag */ /* at the end is tacked on the INIT chunk sent in - * its entirety and of course our + * its entirety and of course our * signature. */ }; @@ -171,23 +171,23 @@ struct sctpSendableInit{ }; -/* Selective Acknowledgement +/* Selective Acknowledgement * has the following structure with * a optional ammount of trailing int's - * on the last part (based on the numberOfDesc + * on the last part (based on the numberOfDesc * field). */ struct sctpSelectiveAck{ - u_int highestConseqTSN; - u_int updatedRwnd; - u_short numberOfdesc; - u_short numDupTsns; + u_int32_t highestConseqTSN; + u_int32_t updatedRwnd; + u_int16_t numberOfdesc; + u_int16_t numDupTsns; }; struct sctpSelectiveFrag{ - u_short fragmentStart; - u_short fragmentEnd; + u_int16_t fragmentStart; + u_int16_t fragmentEnd; }; @@ -197,12 +197,12 @@ struct sctpUnifiedSack{ }; /* for both RTT request/response the - * following is sent + * following is sent */ struct sctpHBrequest { - u_int time_value_1; - u_int time_value_2; + u_int32_t time_value_1; + u_int32_t time_value_2; }; /* here is what I read and respond with to. */ @@ -217,13 +217,13 @@ struct sctpHBsender{ struct sctpChunkDesc hdr; struct sctpParamDesc hb; struct sctpHBrequest rtt; - char addrFmt[SCTP_ADDRMAX]; - unsigned short userreq; + int8_t addrFmt[SCTP_ADDRMAX]; + u_int16_t userreq; }; - -/* for the abort and shutdown ACK + +/* for the abort and shutdown ACK * we must carry the init tag in the common header. Just the * common header is all that is needed with a chunk descriptor. */ @@ -239,15 +239,15 @@ struct sctpUnifiedAbortLight{ struct sctpUnifiedAbortHeavy{ struct sctpHeader mh; struct sctpChunkDesc uh; - unsigned short causeCode; - unsigned short causeLen; + u_int16_t causeCode; + u_int16_t causeLen; }; /* For the graceful shutdown we must carry * the tag (in common header) and the highest consequitive acking value */ struct sctpShutdown { - u_int TSN_Seen; + u_int32_t TSN_Seen; }; struct sctpUnifiedShutdown{ @@ -260,8 +260,8 @@ struct sctpUnifiedShutdown{ * that is defined as a operation error. */ struct sctpOpErrorCause{ - u_short cause; - u_short causeLen; + u_int16_t cause; + u_int16_t causeLen; }; struct sctpUnifiedOpError{ @@ -273,15 +273,15 @@ struct sctpUnifiedStreamError{ struct sctpHeader mh; struct sctpChunkDesc uh; struct sctpOpErrorCause c; - u_short strmNum; - u_short reserved; + u_int16_t strmNum; + u_int16_t reserved; }; struct staleCookieMsg{ struct sctpHeader mh; struct sctpChunkDesc uh; struct sctpOpErrorCause c; - u_int moretime; + u_int32_t moretime; }; /* the following is used in all sends @@ -294,10 +294,10 @@ struct sctpUnifiedSingleMsg{ }; struct sctpDataPart{ - u_int TSN; - u_short streamId; - u_short sequence; - u_int payloadtype; + u_int32_t TSN; + u_int16_t streamId; + u_int16_t sequence; + u_int32_t payloadtype; }; struct sctpUnifiedDatagram{ @@ -307,14 +307,14 @@ struct sctpUnifiedDatagram{ struct sctpECN_echo{ struct sctpChunkDesc uh; - u_int Lowest_TSN; -}; + u_int32_t Lowest_TSN; +}; struct sctpCWR{ struct sctpChunkDesc uh; - u_int TSN_reduced_at; -}; + u_int32_t TSN_reduced_at; +}; #ifdef __cplusplus } diff --git a/contrib/tcpdump/setsignal.c b/contrib/tcpdump/setsignal.c index eff2727..b772264 100644 --- a/contrib/tcpdump/setsignal.c +++ b/contrib/tcpdump/setsignal.c @@ -20,15 +20,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.7 2000/07/11 00:49:03 assar Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.9.2.2 2003/11/16 08:51:56 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> +#include <tcpdump-stdinc.h> #include <signal.h> #ifdef HAVE_SIGACTION @@ -42,15 +42,33 @@ static const char rcsid[] = #include "setsignal.h" /* - * An os independent signal() with BSD semantics, e.g. the signal - * catcher is restored following service of the signal. + * An OS-independent signal() with, whenever possible, partial BSD + * semantics, i.e. the signal handler is restored following service + * of the signal, but system calls are *not* restarted, so that if + * "pcap_breakloop()" is called in a signal handler in a live capture, + * the read/recvfrom/whatever in the live capture doesn't get restarted, + * it returns -1 and sets "errno" to EINTR, so we can break out of the + * live capture loop. * - * When sigset() is available, signal() has SYSV semantics and sigset() - * has BSD semantics and call interface. Unfortunately, Linux does not - * have sigset() so we use the more complicated sigaction() interface - * there. + * We use "sigaction()" if available. We don't specify that the signal + * should restart system calls, so that should always do what we want. * - * Did I mention that signals suck? + * Otherwise, if "sigset()" is available, it probably has BSD semantics + * while "signal()" has traditional semantics, so we use "sigset()"; it + * might cause system calls to be restarted for the signal, however. + * I don't know whether, in any systems where it did cause system calls to + * be restarted, there was a way to ask it not to do so; there may no + * longer be any interesting systems without "sigaction()", however, + * and, if there are, they might have "sigvec()" with SV_INTERRUPT + * (which I think first appeared in 4.3BSD). + * + * Otherwise, we use "signal()" - which means we might get traditional + * semantics, wherein system calls don't get restarted *but* the + * signal handler is reset to SIG_DFL and the signal is not blocked, + * so that a subsequent signal would kill the process immediately. + * + * Did I mention that signals suck? At least in POSIX-compliant systems + * they suck far less, as those systems have "sigaction()". */ RETSIGTYPE (*setsignal (int sig, RETSIGTYPE (*func)(int)))(int) @@ -60,9 +78,6 @@ RETSIGTYPE memset(&new, 0, sizeof(new)); new.sa_handler = func; -#ifdef SA_RESTART - new.sa_flags |= SA_RESTART; -#endif if (sigaction(sig, &new, &old) < 0) return (SIG_ERR); return (old.sa_handler); diff --git a/contrib/tcpdump/sll.h b/contrib/tcpdump/sll.h index 821a845..693f05e 100644 --- a/contrib/tcpdump/sll.h +++ b/contrib/tcpdump/sll.h @@ -4,7 +4,7 @@ * * This code is derived from the Stanford/CMU enet packet filter, * (net/enet.c) distributed as part of 4.3BSD, and code contributed - * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence * Berkeley Laboratory. * * Redistribution and use in source and binary forms, with or without @@ -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.4 2000/12/23 07:52:11 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.7 2002/12/11 07:14:11 guy Exp $ (LBL) */ /* diff --git a/contrib/tcpdump/smb.h b/contrib/tcpdump/smb.h index 3c5ba7d..883ba64 100644 --- a/contrib/tcpdump/smb.h +++ b/contrib/tcpdump/smb.h @@ -1,5 +1,5 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.7 2002/01/17 04:38:29 guy Exp $ (LBL) */ -/* +/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.8 2002/06/11 17:09:00 itojun Exp $ (LBL) */ +/* * Copyright (C) Andrew Tridgell 1995-1999 * * This software may be distributed either under the terms of the diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c index 84c6f33..5c1350f 100644 --- a/contrib/tcpdump/smbutil.c +++ b/contrib/tcpdump/smbutil.c @@ -11,24 +11,15 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.18.2.3 2002/07/10 07:29:23 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.26.2.2 2003/11/16 08:51:56 guy Exp $"; #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#ifdef TIME_WITH_SYS_TIME -#include <time.h> -#endif #include "interface.h" #include "extract.h" @@ -261,10 +252,10 @@ print_asc(const unsigned char *buf, int len) safeputchar(buf[i]); } -static char * +static const char * name_type_str(int name_type) { - char *f = NULL; + const char *f = NULL; switch (name_type) { case 0: f = "Workstation"; break; @@ -322,9 +313,9 @@ print_data(const unsigned char *buf, int len) static void -write_bits(unsigned int val, char *fmt) +write_bits(unsigned int val, const char *fmt) { - char *p = fmt; + const char *p = fmt; int i = 0; while ((p = strchr(fmt, '|'))) { @@ -365,7 +356,7 @@ unistr(const u_char *s, int *len) *len = 1; } - while (l < (sizeof(buf) - 1) && s[0] && s[1] == 0) { + while (l < (int)(sizeof(buf) - 1) && s[0] && s[1] == 0) { buf[l] = s[0]; s += 2; l++; @@ -380,7 +371,7 @@ static const u_char * smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) { int reverse = 0; - char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|"; + const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|"; int len; while (*fmt && buf<maxbuf) { @@ -405,8 +396,12 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) p = strchr(++fmt, '}'); l = PTR_DIFF(p, fmt); + + if ((unsigned int)l > sizeof(bitfmt) - 1) + l = sizeof(bitfmt)-1; + strncpy(bitfmt, fmt, l); - bitfmt[l] = 0; + bitfmt[l] = '\0'; fmt = p + 1; write_bits(buf[0], bitfmt); buf++; @@ -581,19 +576,21 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) case 'T': { time_t t; - int x; + struct tm *lt; + const char *tstring; + u_int32_t x; x = EXTRACT_LE_32BITS(buf); switch (atoi(fmt + 1)) { case 1: - if (x == 0 || x == -1 || x == 0xFFFFFFFF) + if (x == 0 || x == 0xFFFFFFFF) t = 0; else t = make_unix_date(buf); buf += 4; break; case 2: - if (x == 0 || x == -1 || x == 0xFFFFFFFF) + if (x == 0 || x == 0xFFFFFFFF) t = 0; else t = make_unix_date2(buf); @@ -604,7 +601,15 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) buf += 8; break; } - printf("%s", t ? asctime(localtime(&t)) : "NULL\n"); + if (t != 0) { + lt = localtime(&t); + if (lt != NULL) + tstring = asctime(lt); + else + tstring = "(Can't convert time)\n"; + } else + tstring = "NULL\n"; + printf("%s", tstring); fmt++; while (isdigit((unsigned char)*fmt)) fmt++; @@ -674,7 +679,7 @@ smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf) return(buf); memset(s, 0, sizeof(s)); p = strchr(fmt, ']'); - if (p - fmt + 1 > sizeof(s)) { + if ((size_t)(p - fmt + 1) > sizeof(s)) { /* overrun */ return(buf); } @@ -801,7 +806,7 @@ err_code_struct hard_msgs[] = { static struct { int code; - char *class; + const char *class; err_code_struct *err_msgs; } err_classes[] = { { 0, "SUCCESS", NULL }, diff --git a/contrib/tcpdump/strcasecmp.c b/contrib/tcpdump/strcasecmp.c index acba36a..7f087a4 100644 --- a/contrib/tcpdump/strcasecmp.c +++ b/contrib/tcpdump/strcasecmp.c @@ -15,11 +15,11 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/strcasecmp.c,v 1.3 2000/01/09 21:34:21 fenner Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/strcasecmp.c,v 1.4.2.2 2003/11/16 08:51:57 guy Exp $"; #endif -#include <sys/types.h> +#include <tcpdump-stdinc.h> #include "interface.h" diff --git a/contrib/tcpdump/tcp.h b/contrib/tcpdump/tcp.h index fe0e261..414b481 100644 --- a/contrib/tcpdump/tcp.h +++ b/contrib/tcpdump/tcp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.8 2001/05/09 01:16:57 fenner Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.10 2002/12/11 07:14:11 guy Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. diff --git a/contrib/tcpdump/tcpdump-stdinc.h b/contrib/tcpdump/tcpdump-stdinc.h new file mode 100644 index 0000000..00e6abe --- /dev/null +++ b/contrib/tcpdump/tcpdump-stdinc.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2002 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * 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 Politecnico di Torino 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 COPYRIGHT HOLDERS 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 COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.7.2.1 2003/11/16 09:57:50 guy Exp $ (LBL) + */ + +/* + * Include the appropriate OS header files on Windows and various flavors + * of UNIX, and also define some additional items and include various + * non-OS header files on Windows, and; this isolates most of the platform + * differences to this one file. + */ + +#ifndef tcpdump_stdinc_h +#define tcpdump_stdinc_h + +#ifdef WIN32 + +#include <stdio.h> +#include <winsock2.h> +#include "bittypes.h" +#include <ctype.h> +#include <time.h> +#include <io.h> +#include "IP6_misc.h" +#include <fcntl.h> + +#ifdef __MINGW32__ +#include <stdint.h> +int* _errno(); +#define errno (*_errno()) + +#define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 + +#endif /* __MINGW32__ */ + +#ifndef toascii +#define toascii(c) ((c) & 0x7f) +#endif + +#ifndef caddr_t +typedef char* caddr_t; +#endif /* caddr_t */ + +#define MAXHOSTNAMELEN 64 +#define NI_MAXHOST 1025 +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#define RETSIGTYPE void + +#if !defined(__MINGW32__) && !defined(__WATCOMC__) +#undef toascii +#define isascii __isascii +#define toascii __toascii +#define stat _stat +#define open _open +#define fstat _fstat +#define read _read +#define O_RDONLY _O_RDONLY + +typedef short ino_t; +#endif /* __MINGW32__ */ + +#else /* WIN32 */ + +#include <ctype.h> +#include <unistd.h> +#include <netdb.h> +#include <sys/param.h> +#include <sys/types.h> /* concession to AIX */ +#include <sys/time.h> +#include <sys/socket.h> +#include <netinet/in.h> + +#ifdef TIME_WITH_SYS_TIME +#include <time.h> +#endif + +#include <arpa/inet.h> + +#endif /* WIN32 */ + +#ifdef INET6 +#include "ip6.h" +#endif + +#if defined(WIN32) || defined(MSDOS) + #define FOPEN_READ_TXT "rt" + #define FOPEN_READ_BIN "rb" + #define FOPEN_WRITE_TXT "wt" + #define FOPEN_WRITE_BIN "wb" +#else + #define FOPEN_READ_TXT "r" + #define FOPEN_READ_BIN FOPEN_READ_TXT + #define FOPEN_WRITE_TXT "w" + #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT +#endif + +#endif /* tcpdump_stdinc_h */ diff --git a/contrib/tcpdump/telnet.h b/contrib/tcpdump/telnet.h index c29aeac..da11043 100644 --- a/contrib/tcpdump/telnet.h +++ b/contrib/tcpdump/telnet.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.3 2001/09/17 21:58:06 fenner Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.4 2002/06/11 17:09:01 itojun Exp $ (LBL) */ /* $NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp $ */ @@ -220,12 +220,12 @@ const char *telopts[NTELOPTS+1] = { * list of names if SLC_NAMES is not defined. */ #define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ - "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ - "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \ - "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \ - "MCEOL", "INSRT", "OVER", "ECR", "EWR", \ - "EBOL", "EEOL", \ - 0, + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \ + "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \ + "MCEOL", "INSRT", "OVER", "ECR", "EWR", \ + "EBOL", "EEOL", \ + 0, #ifdef SLC_NAMES const char *slc_names[] = { diff --git a/contrib/tcpdump/timed.h b/contrib/tcpdump/timed.h index 136e55e..0a5c5fe 100644 --- a/contrib/tcpdump/timed.h +++ b/contrib/tcpdump/timed.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.3 2000/12/17 23:07:51 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.5 2002/12/11 07:14:12 guy Exp $ (LBL) */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -45,14 +45,14 @@ #define ANYADDR NULL struct tsp { - u_char tsp_type; - u_char tsp_vers; - u_short tsp_seq; + u_int8_t tsp_type; + u_int8_t tsp_vers; + u_int16_t tsp_seq; union { struct timeval tspu_time; - char tspu_hopcnt; + int8_t tspu_hopcnt; } tsp_u; - char tsp_name[256]; + int8_t tsp_name[256]; }; #define tsp_time tsp_u.tspu_time diff --git a/contrib/tcpdump/udp.h b/contrib/tcpdump/udp.h index 089ca01..eb6c20b 100644 --- a/contrib/tcpdump/udp.h +++ b/contrib/tcpdump/udp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.2 2000/10/03 02:55:03 itojun Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.5 2003/10/27 22:44:37 hannes Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -44,3 +44,41 @@ struct udphdr { u_int16_t uh_ulen; /* udp length */ u_int16_t uh_sum; /* udp checksum */ }; + +#define TFTP_PORT 69 /*XXX*/ +#define KERBEROS_PORT 88 /*XXX*/ +#define SUNRPC_PORT 111 /*XXX*/ +#define SNMP_PORT 161 /*XXX*/ +#define NTP_PORT 123 /*XXX*/ +#define SNMPTRAP_PORT 162 /*XXX*/ +#define ISAKMP_PORT 500 /*XXX*/ +#define TIMED_PORT 525 /*XXX*/ +#define RIP_PORT 520 /*XXX*/ +#define LDP_PORT 646 +#define AODV_PORT 654 /*XXX*/ +#define KERBEROS_SEC_PORT 750 /*XXX*/ +#define L2TP_PORT 1701 /*XXX*/ +#define ISAKMP_PORT_USER1 7500 /*XXX - nonstandard*/ +#define ISAKMP_PORT_USER2 8500 /*XXX - nonstandard*/ +#define RX_PORT_LOW 7000 /*XXX*/ +#define RX_PORT_HIGH 7009 /*XXX*/ +#define NETBIOS_NS_PORT 137 +#define NETBIOS_DGRAM_PORT 138 +#define CISCO_AUTORP_PORT 496 /*XXX*/ +#define RADIUS_PORT 1645 +#define RADIUS_NEW_PORT 1812 +#define RADIUS_ACCOUNTING_PORT 1646 +#define RADIUS_NEW_ACCOUNTING_PORT 1813 +#define HSRP_PORT 1985 /*XXX*/ +#define LWRES_PORT 921 +#define ZEPHYR_SRV_PORT 2103 +#define ZEPHYR_CLT_PORT 2104 +#define MPLS_LSP_PING_PORT 3503 /* draft-ietf-mpls-lsp-ping-02.txt */ +#define BFD_CONTROL_PORT 3784 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */ +#define BFD_ECHO_PORT 3785 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */ + +#ifdef INET6 +#define RIPNG_PORT 521 /*XXX*/ +#define DHCP6_SERV_PORT 546 /*XXX*/ +#define DHCP6_CLI_PORT 547 /*XXX*/ +#endif diff --git a/contrib/tcpdump/util.c b/contrib/tcpdump/util.c index f5bd7ca..f7df263 100644 --- a/contrib/tcpdump/util.c +++ b/contrib/tcpdump/util.c @@ -20,20 +20,18 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.72.2.2 2002/07/16 04:03:54 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.87.2.3 2003/12/29 22:42:23 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/types.h> -#include <sys/time.h> -#include <sys/file.h> +#include <tcpdump-stdinc.h> + #include <sys/stat.h> -#include <ctype.h> #include <errno.h> #ifdef HAVE_FCNTL_H #include <fcntl.h> @@ -43,10 +41,6 @@ static const char rcsid[] = #include <stdarg.h> #include <stdlib.h> #include <string.h> -#ifdef TIME_WITH_SYS_TIME -#include <time.h> -#endif -#include <unistd.h> #include "interface.h" @@ -91,15 +85,10 @@ int fn_printn(register const u_char *s, register u_int n, register const u_char *ep) { - register int ret; register u_char c; - ret = 1; /* assume truncated */ - while (ep == NULL || s < ep) { - if (n-- <= 0) { - ret = 0; - break; - } + while (n > 0 && (ep == NULL || s < ep)) { + n--; c = *s++; if (!isascii(c)) { c = toascii(c); @@ -112,7 +101,7 @@ fn_printn(register const u_char *s, register u_int n, } putchar(c); } - return(ret); + return (n == 0) ? 0 : 1; } /* @@ -145,7 +134,7 @@ ts_print(register const struct timeval *tvp) } else { int d_usec = tvp->tv_usec - b_usec; int d_sec = tvp->tv_sec - b_sec; - + while (d_usec < 0) { d_usec += 1000000; d_sec--; @@ -160,12 +149,14 @@ ts_print(register const struct timeval *tvp) case -3: /* Default + Date*/ s = (tvp->tv_sec + thiszone) % 86400; Time = (tvp->tv_sec + thiszone) - s; - tm = gmtime (&Time); - (void)printf("%02d/%02d/%04d %02d:%02d:%02d.%06u ", - tm->tm_mon+1, tm->tm_mday, - tm->tm_year+1900, - s / 3600, (s % 3600) / 60, - s % 60, (unsigned)tvp->tv_usec); + tm = gmtime (&Time); + if (!tm) + printf("Date fail "); + else + printf("%04d-%02d-%02d ", + tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday); + printf("%02d:%02d:%02d.%06u ", + s / 3600, (s % 3600) / 60, s % 60, (unsigned)tvp->tv_usec); break; } } @@ -202,6 +193,19 @@ relts_print(int secs) } /* + * this is a generic routine for printing unknown data; + * we pass on the linefeed plus indentation string to + * get a proper output - returns 0 on error + */ + +int +print_unknown_data(const u_char *cp,const char *ident,int len) +{ + hex_print(ident,cp,len); + return(1); /* everything is ok */ +} + +/* * Convert a token value to a string; use "fmt" if not found. */ const char * @@ -222,6 +226,51 @@ tok2str(register const struct tok *lp, register const char *fmt, } /* + * Convert a bit token value to a string; use "fmt" if not found. + * this is useful for parsing bitfields, the output strings are comma seperated + */ +char * +bittok2str(register const struct tok *lp, register const char *fmt, + register int v) +{ + static char buf[256]; /* our stringbuffer */ + int buflen=0; + register int rotbit; /* this is the bit we rotate through all bitpositions */ + register int tokval; + + while (lp->s != NULL) { + tokval=lp->v; /* load our first value */ + rotbit=1; + while (rotbit != 0) { + /* + * lets AND the rotating bit with our token value + * and see if we have got a match + */ + if (tokval == (v&rotbit)) { + /* ok we have found something */ + buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s, ",lp->s); + break; + } + rotbit=rotbit<<1; /* no match - lets shift and try again */ + } + lp++; + } + + if (buflen != 0) { /* did we find anything */ + /* yep, set the the trailing zero 2 bytes before to eliminate the last comma & whitespace */ + buf[buflen-2] = '\0'; + return (buf); + } + else { + /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */ + if (fmt == NULL) + fmt = "#%d"; + (void)snprintf(buf, sizeof(buf), fmt, v); + return (buf); + } +} + +/* * Convert a value to a string using an array; the macro * tok2strary() in <interface.h> is the public interface to * this function and ensures that the second argument is @@ -241,6 +290,37 @@ tok2strary_internal(register const char **lp, int n, register const char *fmt, return (buf); } +/* + * Convert a 32-bit netmask to prefixlen if possible + * the function returns the prefix-len; if plen == -1 + * then conversion was not possible; + */ + +int +mask2plen (u_int32_t mask) +{ + u_int32_t bitmasks[33] = { + 0x00000000, + 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, + 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, + 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, + 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, + 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, + 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, + 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, + 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff + }; + int prefix_len = 32; + + /* let's see if we can transform the mask into a prefixlen */ + while (prefix_len >= 0) { + if (bitmasks[prefix_len] == mask) + break; + prefix_len--; + } + return (prefix_len); +} + /* VARARGS */ void error(const char *fmt, ...) @@ -311,14 +391,24 @@ copy_argv(register char **argv) return buf; } +/* + * On Windows, we need to open the file in binary mode, so that + * we get all the bytes specified by the size we get from "fstat()". + * On UNIX, that's not necessary. O_BINARY is defined on Windows; + * we define it as 0 if it's not defined, so it does nothing. + */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + char * read_infile(char *fname) { - register int fd, cc; + register int i, fd, cc; register char *cp; struct stat buf; - fd = open(fname, O_RDONLY); + fd = open(fname, O_RDONLY|O_BINARY); if (fd < 0) error("can't open %s: %s", fname, pcap_strerror(errno)); @@ -334,8 +424,15 @@ read_infile(char *fname) error("read %s: %s", fname, pcap_strerror(errno)); if (cc != buf.st_size) error("short read %s (%d != %d)", fname, cc, (int)buf.st_size); - cp[(int)buf.st_size] = '\0'; + close(fd); + /* replace "# comment" with spaces */ + for (i = 0; i < cc; i++) { + if (cp[i] == '#') + while (i < cc && cp[i] != '\n') + cp[i++] = ' '; + } + cp[cc] = '\0'; return (cp); } diff --git a/contrib/tcpdump/vfprintf.c b/contrib/tcpdump/vfprintf.c index 9fea58e..0a9e235 100644 --- a/contrib/tcpdump/vfprintf.c +++ b/contrib/tcpdump/vfprintf.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/vfprintf.c,v 1.4 2000/07/01 03:39:12 assar Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/vfprintf.c,v 1.4.8.2 2003/11/16 08:51:58 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H |